All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] [RFC] savevm only saves disk state
@ 2010-09-10  1:43 disheng.su
  2010-09-10  2:08 ` Anthony Liguori
  0 siblings, 1 reply; 4+ messages in thread
From: disheng.su @ 2010-09-10  1:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: edison

From: edison <edison@cloud.com>

Add a new option when "savevm": savevm -n snapshotName, which only takes snapshot on disk, but doesn't save vm state(memory,cpu,devices...).
Saving vm state on QCOW2 disk will take a long time, per my test, it will take 1~2 minutes to "savevm" on VM with 1G memory. Even worse, the VM is wholely stopped at that time, makes "savevm" not that useful.
All we know the side effect of it:) but does it make sense to give user the choice?
---
 qemu-monitor.hx |    6 +++---
 savevm.c        |   34 ++++++++++++++++++++++------------
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 49bcd8d..724e0a2 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -327,9 +327,9 @@ ETEXI
 
     {
         .name       = "savevm",
-        .args_type  = "name:s?",
-        .params     = "[tag|id]",
-        .help       = "save a VM snapshot. If no tag or id are provided, a new snapshot is created",
+        .args_type  = "nostate:-n,name:s?",
+        .params     = "[-n] [tag|id]",
+        .help       = "save a VM snapshot. If no tag or id are provided, a new snapshot is created. If -n is specified, do not save vm state",
         .mhandler.cmd = do_savevm,
     },
 
diff --git a/savevm.c b/savevm.c
index 6fa7a5f..b0963b5 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1834,7 +1834,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
     int ret;
     QEMUFile *f;
     int saved_vm_running;
-    uint32_t vm_state_size;
+    uint32_t vm_state_size = 0;
+    
 #ifdef _WIN32
     struct _timeb tb;
     struct tm *ptm;
@@ -1844,6 +1845,8 @@ void do_savevm(Monitor *mon, const QDict *qdict)
 #endif
     const char *name = qdict_get_try_str(qdict, "name");
 
+    int nostate = qdict_get_try_bool(qdict, "nostate", 0);
+
     /* Verify if there is a device that doesn't support snapshots and is writable */
     bs = NULL;
     while ((bs = bdrv_next(bs))) {
@@ -1909,17 +1912,19 @@ void do_savevm(Monitor *mon, const QDict *qdict)
     }
 
     /* save the VM state */
-    f = qemu_fopen_bdrv(bs, 1);
-    if (!f) {
-        monitor_printf(mon, "Could not open VM state file\n");
-        goto the_end;
-    }
-    ret = qemu_savevm_state(mon, f);
-    vm_state_size = qemu_ftell(f);
-    qemu_fclose(f);
-    if (ret < 0) {
-        monitor_printf(mon, "Error %d while writing VM\n", ret);
-        goto the_end;
+    if (!nostate) {
+        f = qemu_fopen_bdrv(bs, 1);
+        if (!f) {
+            monitor_printf(mon, "Could not open VM state file\n");
+            goto the_end;
+        }
+        ret = qemu_savevm_state(mon, f);
+        vm_state_size = qemu_ftell(f);
+        qemu_fclose(f);
+        if (ret < 0) {
+            monitor_printf(mon, "Error %d while writing VM\n", ret);
+            goto the_end;
+        }
     }
 
     /* create the snapshots */
@@ -1984,6 +1989,11 @@ int load_vmstate(const char *name)
                            bdrv_get_device_name(bs), name);
             return ret;
         }
+        
+        if (sn.vm_state_size == 0) {
+            error_report("No vm state stored on snapshot: '%s'.", name);
+            return -ENOTSUP;
+        }
     }
 
     /* Flush all IO requests so they don't interfere with the new state.  */
-- 
1.7.2.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-09-16 10:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-10  1:43 [Qemu-devel] [PATCH] [RFC] savevm only saves disk state disheng.su
2010-09-10  2:08 ` Anthony Liguori
2010-09-15 18:24   ` edison
2010-09-16 10:03     ` Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.