libxl: Clear device-model info when destroying an HVM domain with stubdom.
authorJun Zhu <Jun.Zhu@citrix.com>
Thu, 16 Sep 2010 16:49:43 +0000 (17:49 +0100)
committerJun Zhu <Jun.Zhu@citrix.com>
Thu, 16 Sep 2010 16:49:43 +0000 (17:49 +0100)
Signed-off-by: Jun Zhu <Jun.Zhu@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl.c

index 5e5c48234728ae1568e00b3fc431b99fd5977ba5..32cfc7cea4d656a9ff685a1dda6b66bf1863ba0c 100644 (file)
@@ -899,21 +899,25 @@ static int libxl_destroy_device_model(libxl_ctx *ctx, uint32_t domid)
         }
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Device model is a stubdom, domid=%d\n", stubdomid);
         ret = libxl_domain_destroy(ctx, stubdomid, 0);
-        goto out;
+        if (ret)
+            goto out;
+    } else {
+        ret = kill(atoi(pid), SIGHUP);
+        if (ret < 0 && errno == ESRCH) {
+            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model already exited");
+            ret = 0;
+        } else if (ret == 0) {
+            LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model signaled");
+            ret = 0;
+        } else {
+            LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to kill Device Model [%d]",
+                    atoi(pid));
+            ret = ERROR_FAIL;
+            goto out;
+        }
     }
     xs_rm(ctx->xsh, XBT_NULL, libxl__sprintf(&gc, "/local/domain/0/device-model/%d", domid));
 
-    ret = kill(atoi(pid), SIGHUP);
-    if (ret < 0 && errno == ESRCH) {
-        LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model already exited");
-        ret = 0;
-    } else if (ret == 0) {
-        LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "Device Model signaled");
-        ret = 0;
-    } else {
-        LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "failed to kill Device Model [%d]",
-                     atoi(pid));
-    }
 out:
     libxl__free_all(&gc);
     return ret;