Skip to contentSkip to conversation

change the name of the qemu save file at restore time

PATCH Applied Stefano Stabellini 2 participants 5 messages Jan 19, 2011 – Jan 21, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 change the name of the qemu save file at restore time

Change the name of the qemu save file to qemu-resume at restore time so that it doesn't collide with the name of the next save file.

tools/libxc/xc_domain_restore.c +1 -1
diff -r 59396addc940 tools/libxc/xc_domain_restore.c
@@ -436,7 +436,7 @@ static int dump_qemu(xc_interface *xch, 
     char path[256];
     FILE *fp;
 
-    sprintf(path, "/var/lib/xen/qemu-save.%u", dom);
+    sprintf(path, "/var/lib/xen/qemu-resume.%u", dom);
     fp = fopen(path, "wb");
     if ( !fp )
         return -1;
tools/libxl/libxl_create.c +1 -1
diff -r 59396addc940 tools/libxl/libxl_create.c
@@ -251,7 +251,7 @@ static int domain_restore(libxl_ctx *ctx
     dm_info->saved_state = NULL;
     if (info->hvm) {
         ret = asprintf(&dm_info->saved_state,
-                       "/var/lib/xen/qemu-save.%d", domid);
+                       RESTOREFILE".%d", domid);
         ret = (ret < 0) ? ERROR_FAIL : 0;
     }
 
tools/libxl/libxl_internal.h +2 -0
diff -r 59396addc940 tools/libxl/libxl_internal.h
@@ -45,6 +45,8 @@
 #define LIBXL_HVM_EXTRA_MEMORY 2048
 #define LIBXL_MIN_DOM0_MEM (128*1024)
 #define QEMU_SIGNATURE "DeviceModelRecord0002"
+#define SAVEFILE "/var/lib/xen/qemu-save"
+#define RESTOREFILE "/var/lib/xen/qemu-resume"
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 
tools/python/xen/xend/image.py +1 -1
diff -r 59396addc940 tools/python/xen/xend/image.py
@@ -936,7 +936,7 @@ class HVMImageHandler(ImageHandler):
         args = ImageHandler.getDeviceModelArgs(self, restore)
         args = args + ([ "-M", "xenfv"])
         if restore:
-            args = args + ([ "-loadvm", "/var/lib/xen/qemu-save.%d" %
+            args = args + ([ "-loadvm", "/var/lib/xen/qemu-resume.%d" %
                              self.vm.getDomid() ])
         return args
#1 lore raw

Stefano Stabellini writes ("[Xen-devel] [PATCH 1/5] change the name of the qemu save file at restore time"):

Quoted 2 lines

Change the name of the qemu save file to qemu-resume at restore time so that it doesn't collide with the name of the next save file.

...

Quoted 2 lines
tools/libxc/xc_domain_restore.c +1 -1
-    sprintf(path, "/var/lib/xen/qemu-save.%u", dom);
+    sprintf(path, "/var/lib/xen/qemu-resume.%u", dom);

...

Quoted 2 lines
tools/libxl/libxl_create.c +1 -1
-                       "/var/lib/xen/qemu-save.%d", domid);
+                       RESTOREFILE".%d", domid);

...

tools/libxl/libxl_internal.h line 49

Quoted 2 lines
tools/libxl/libxl_internal.h +2 -0
+#define SAVEFILE "/var/lib/xen/qemu-save"
+#define RESTOREFILE "/var/lib/xen/qemu-resume"

Uh, why is the latter not in libxc so that libxc can use it too ?

tools/python/xen/xend/image.py class HVMImageHandler(ImageHandler): · line 939

Quoted 2 lines
tools/python/xen/xend/image.py +1 -1
-            args = args + ([ "-loadvm", "/var/lib/xen/qemu-save.%d" %
+            args = args + ([ "-loadvm", "/var/lib/xen/qemu-resume.%d" %

At least this has some kind of excuse. It's probably too painful to do anything else but keep the 2nd hardcoded value (and anyway this is in xend).

Ian.

#2 lore raw
Quoted 6 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH 1/5] change the name of the qemu save file at restore time"):

Quoted 2 lines

Change the name of the qemu save file to qemu-resume at restore time so that it doesn't collide with the name of the next save file.

...

tools/libxc/xc_domain_restore.c static int dump_qemu(xc_interface *xch, · line 439

Quoted 2 lines
tools/libxc/xc_domain_restore.c +1 -1
-    sprintf(path, "/var/lib/xen/qemu-save.%u", dom);
+    sprintf(path, "/var/lib/xen/qemu-resume.%u", dom);
Quoted 8 lines

...

Quoted 2 lines
tools/libxl/libxl_create.c +1 -1
-                       "/var/lib/xen/qemu-save.%d", domid);
+                       RESTOREFILE".%d", domid);

...

tools/libxl/libxl_internal.h line 49

Quoted 2 lines
tools/libxl/libxl_internal.h +2 -0
+#define SAVEFILE "/var/lib/xen/qemu-save"
+#define RESTOREFILE "/var/lib/xen/qemu-resume"

Uh, why is the latter not in libxc so that libxc can use it too ?

It should probably be in xenguest.h, close to xc_domain_restore.

#3 lore raw
Quoted 10 lines · Stefano Stabellini
Quoted 9 lines · Ian Jackson

Stefano Stabellini writes ("[Xen-devel] [PATCH 1/5] change the name of the qemu save file at restore time"):

Quoted 2 lines

Change the name of the qemu save file to qemu-resume at restore time so that it doesn't collide with the name of the next save file.

...

Quoted 2 lines
(quoted diff) +1 -1
-    sprintf(path, "/var/lib/xen/qemu-save.%u", dom);
+    sprintf(path, "/var/lib/xen/qemu-resume.%u", dom);

...

Quoted 2 lines
(quoted diff) +1 -1
-                       "/var/lib/xen/qemu-save.%d", domid);
+                       RESTOREFILE".%d", domid);
Quoted 8 lines
Quoted 5 lines

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+#define SAVEFILE "/var/lib/xen/qemu-save"
+#define RESTOREFILE "/var/lib/xen/qemu-resume"

Uh, why is the latter not in libxc so that libxc can use it too ?

It should probably be in xenguest.h, close to xc_domain_restore.

I am appending the updated version of this patch.

---

Change the name of the qemu save file to qemu-resume at restore time so that it doesn't collide with the name of the next save file.

tools/libxc/xc_domain_restore.c +1 -1
diff -r 59396addc940 tools/libxc/xc_domain_restore.c
@@ -436,7 +436,7 @@ static int dump_qemu(xc_interface *xch, 
     char path[256];
     FILE *fp;
 
-    sprintf(path, "/var/lib/xen/qemu-save.%u", dom);
+    sprintf(path, XC_DEVICE_MODEL_RESTORE_FILE".%u", dom);
     fp = fopen(path, "wb");
     if ( !fp )
         return -1;
tools/libxc/xenguest.h +8 -0
diff -r 59396addc940 tools/libxc/xenguest.h
@@ -77,6 +77,14 @@ int xc_domain_restore(xc_interface *xch,
                       unsigned int store_evtchn, unsigned long *store_mfn,
                       unsigned int console_evtchn, unsigned long *console_mfn,
                       unsigned int hvm, unsigned int pae, int superpages);
+/**
+ * xc_domain_restore writes a file to disk that contains the device
+ * model saved state.
+ * The pathname of this file is XC_DEVICE_MODEL_RESTORE_FILE; The domid
+ * of the new domain is automatically appended to the filename,
+ * separated by a ".".
+ */
+#define XC_DEVICE_MODEL_RESTORE_FILE "/var/lib/xen/qemu-resume"
 
 /**
  * This function will create a domain for a paravirtualized Linux
tools/libxl/libxl_create.c +4 -1
diff -r 59396addc940 tools/libxl/libxl_create.c
@@ -22,6 +22,9 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <xenctrl.h>
+#include <xc_dom.h>
+#include <xenguest.h>
 #include "libxl.h"
 #include "libxl_utils.h"
 #include "libxl_internal.h"
@@ -251,7 +254,7 @@ static int domain_restore(libxl_ctx *ctx
     dm_info->saved_state = NULL;
     if (info->hvm) {
         ret = asprintf(&dm_info->saved_state,
-                       "/var/lib/xen/qemu-save.%d", domid);
+                       XC_DEVICE_MODEL_RESTORE_FILE".%d", domid);
         ret = (ret < 0) ? ERROR_FAIL : 0;
     }
 
tools/libxl/libxl_internal.h +1 -0
diff -r 59396addc940 tools/libxl/libxl_internal.h
@@ -45,6 +45,7 @@
 #define LIBXL_HVM_EXTRA_MEMORY 2048
 #define LIBXL_MIN_DOM0_MEM (128*1024)
 #define QEMU_SIGNATURE "DeviceModelRecord0002"
+#define SAVEFILE "/var/lib/xen/qemu-save"
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 
tools/python/xen/xend/image.py +1 -1
diff -r 59396addc940 tools/python/xen/xend/image.py
@@ -936,7 +936,7 @@ class HVMImageHandler(ImageHandler):
         args = ImageHandler.getDeviceModelArgs(self, restore)
         args = args + ([ "-M", "xenfv"])
         if restore:
-            args = args + ([ "-loadvm", "/var/lib/xen/qemu-save.%d" %
+            args = args + ([ "-loadvm", "/var/lib/xen/qemu-resume.%d" %
                              self.vm.getDomid() ])
         return args
Applied
#4 lore raw

Stefano Stabellini writes ("Re: [Xen-devel] [PATCH 1/5] change the name of the qemu save file at restore time"):

Quoted 1 line

I am appending the updated version of this patch.

Thanks, applied.

Ian.