[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: do not leak qemu saved state on restore



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1323790938 0
# Node ID e9c66c268a1f7432f60c83f63a3aa0770628e9a6
# Parent  983b551e44077ace454a397181c93533e0a534b5
libxl: do not leak qemu saved state on restore

In particular do not leak /var/lib/xen/qemu-resume.<domid>.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---


diff -r 983b551e4407 -r e9c66c268a1f tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c        Tue Dec 13 15:39:28 2011 +0000
+++ b/tools/libxl/libxl_create.c        Tue Dec 13 15:42:18 2011 +0000
@@ -620,7 +620,7 @@
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
             libxl__qmp_initializations(ctx, domid);
         }
-        ret = libxl__confirm_device_model_startup(gc, dm_starting);
+        ret = libxl__confirm_device_model_startup(gc, dm_info, dm_starting);
         if (ret < 0) {
             LIBXL__LOG(ctx, LIBXL__LOG_ERROR,
                        "device model did not start: %d", ret);
diff -r 983b551e4407 -r e9c66c268a1f tools/libxl/libxl_dm.c
--- a/tools/libxl/libxl_dm.c    Tue Dec 13 15:39:28 2011 +0000
+++ b/tools/libxl/libxl_dm.c    Tue Dec 13 15:42:18 2011 +0000
@@ -751,7 +751,8 @@
         ret = ERROR_FAIL;
         goto out_free;
     }
-    if (libxl__confirm_device_model_startup(gc, dm_starting) < 0) {
+    if (libxl__confirm_device_model_startup(gc, &xenpv_dm_info,
+                                            dm_starting) < 0) {
         ret = ERROR_FAIL;
         goto out_free;
     }
@@ -892,14 +893,26 @@
 
 
 int libxl__confirm_device_model_startup(libxl__gc *gc,
-                                       libxl__spawner_starting *starting)
+                                libxl_device_model_info *dm_info,
+                                libxl__spawner_starting *starting)
 {
+    libxl_ctx *ctx = libxl__gc_owner(gc);
     char *path;
     int domid = starting->domid;
+    int ret, ret2;
     path = libxl__sprintf(gc, "/local/domain/0/device-model/%d/state", domid);
-    return libxl__spawn_confirm_offspring_startup(gc,
+    ret = libxl__spawn_confirm_offspring_startup(gc,
                                      LIBXL_DEVICE_MODEL_START_TIMEOUT,
                                      "Device Model", path, "running", 
starting);
+    if (dm_info->saved_state) {
+        ret2 = unlink(dm_info->saved_state);
+        if (ret2) LIBXL__LOG_ERRNO(ctx, XTL_ERROR,
+                                   "failed to remove device-model state %s\n",
+                                   dm_info->saved_state);
+        /* Do not clobber spawn_confirm error code with unlink error code. */
+        if (!ret) ret = ret2;
+    }
+    return ret;
 }
 
 int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
diff -r 983b551e4407 -r e9c66c268a1f tools/libxl/libxl_internal.h
--- a/tools/libxl/libxl_internal.h      Tue Dec 13 15:39:28 2011 +0000
+++ b/tools/libxl/libxl_internal.h      Tue Dec 13 15:42:18 2011 +0000
@@ -438,6 +438,7 @@
    * return pass *starting_r (which will be non-0) to
    * libxl__confirm_device_model_startup or libxl__detach_device_model. */
 _hidden int libxl__confirm_device_model_startup(libxl__gc *gc,
+                              libxl_device_model_info *dm_info,
                               libxl__spawner_starting *starting);
 _hidden int libxl__detach_device_model(libxl__gc *gc, libxl__spawner_starting 
*starting);
 _hidden int libxl__wait_for_device_model(libxl__gc *gc,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.