Skip to contentSkip to conversation

QMP wrappers for VM snapshot operations

PATCH Superseded Denis V. Lunev 4 participants 24 messages Nov 16, 2015 – Dec 1, 2015

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover QMP wrappers for VM snapshot operations

EFI based VM with pflash storage for NVRAM could not be snapshoted as libvirt configures storage as 'raw' and writable. OK, this is a libvirt problem.

Another problem is that libvirt can not detect this failure at all as it uses HMP for this operation. This create snapshot/delete snapshot sequence passes silently.

The patchset adds QMP wrappers for the purpose.

At the moment I have placed 2.6 version into QAPI. Though (if you feel appropriate) I can change it to 2.5 :) This is up to you to decide.

Please note, this patchset is made on top of
[PATCH for 2.5 v8 0/10] dataplane snapshot fixes

CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>

Denis V. Lunev (5):
migration: split hmp_savevm to do_savevm and hmp_savevm wrapper
qmp: create qmp_savevm command
qmp: create qmp_delvm command
migration: improve error reporting for hmp_loadvm
qmp: create QMP implementation of loadvm command

 include/sysemu/sysemu.h |   2 +-
 migration/savevm.c      | 100 +++++++++++++++++++++++++++++++-----------------
 monitor.c               |   7 +++-
 qapi-schema.json        |  39 +++++++++++++++++++
 qmp-commands.hx         |  71 ++++++++++++++++++++++++++++++++++
 vl.c                    |   5 ++-
 6 files changed, 185 insertions(+), 39 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/5 migration: split hmp_savevm to do_savevm and hmp_savevm wrapper

This would be useful in the next step when QMP version of this call will be introduced.

CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
migration/savevm.c +23 -15
index 2c65ab2..f83ffd0 100644
@@ -1905,7 +1905,7 @@ int qemu_loadvm_state(QEMUFile *f)
     return ret;
 }
 
-void hmp_savevm(Monitor *mon, const QDict *qdict)
+static void do_savevm(const char *name, Error **errp)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -1915,28 +1915,26 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     uint64_t vm_state_size;
     qemu_timeval tv;
     struct tm tm;
-    const char *name = qdict_get_try_str(qdict, "name");
     Error *local_err = NULL;
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        monitor_printf(mon, "Device '%s' is writable but does not "
-                       "support snapshots.\n", bdrv_get_device_name(bs));
+        error_setg(errp, "Device '%s' is writable but does not "
+                   "support snapshots.", bdrv_get_device_name(bs));
         return;
     }
 
     /* Delete old snapshots of the same name */
     if (name && bdrv_all_delete_snapshot(name, &bs1, &local_err) < 0) {
-        monitor_printf(mon,
-                       "Error while deleting snapshot on device '%s': %s\n",
-                       bdrv_get_device_name(bs1), error_get_pretty(local_err));
+        error_setg(errp, "Error while deleting snapshot on device '%s': %s",
+                   bdrv_get_device_name(bs1), error_get_pretty(local_err));
         error_free(local_err);
         return;
     }
 
     bs = bdrv_all_find_vmstate_bs();
     if (bs == NULL) {
-        monitor_printf(mon, "No block device can accept snapshots\n");
+        error_setg(errp, "No block device can accept snapshots");
         return;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -1945,7 +1943,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
 
     ret = global_state_store();
     if (ret) {
-        monitor_printf(mon, "Error saving global state\n");
+        error_setg(errp, "Error saving global state");
         return;
     }
     vm_stop(RUN_STATE_SAVE_VM);
@@ -1977,22 +1975,20 @@ void hmp_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");
+        error_setg(errp, "Could not open VM state file");
         goto the_end;
     }
-    ret = qemu_savevm_state(f, &local_err);
+    ret = qemu_savevm_state(f, errp);
     vm_state_size = qemu_ftell(f);
     qemu_fclose(f);
     if (ret < 0) {
-        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
-        error_free(local_err);
         goto the_end;
     }
 
     ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
     if (ret < 0) {
-        monitor_printf(mon, "Error while creating snapshot on '%s'\n",
-                       bdrv_get_device_name(bs));
+        error_setg(errp, "Error while creating snapshot on '%s'",
+                   bdrv_get_device_name(bs));
     }
 
  the_end:
@@ -2002,6 +1998,18 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     }
 }
 
+void hmp_savevm(Monitor *mon, const QDict *qdict)
+{
+    Error *local_err = NULL;
+
+    do_savevm(qdict_get_try_str(qdict, "name"), &local_err);
+
+    if (local_err != NULL) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);
+    }
+}
+
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
Signature · 1 line
2.5.0
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] migration: split hmp_savevm to do_savevm and hmp_savevm wrapper

Quoted 28 lines · Denis V. Lunev

This would be useful in the next step when QMP version of this call will be introduced.

CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c | 38 +++++++++++++++++++++++---------------
 1 file changed, 23 insertions(+), 15 deletions(-)
migration/savevm.c +1 -1
index 2c65ab2..f83ffd0 100644
@@ -1905,7 +1905,7 @@ int qemu_loadvm_state(QEMUFile *f)
     return ret;
 }
 
-void hmp_savevm(Monitor *mon, const QDict *qdict)
+static void do_savevm(const char *name, Error **errp)
 {
     BlockDriverState *bs, *bs1;
     QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
@@ -1915,28 +1915,26 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     uint64_t vm_state_size;
     qemu_timeval tv;

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 1923

Quoted 10 lines
migration/savevm.c +2 -3
     struct tm tm;
-    const char *name = qdict_get_try_str(qdict, "name");
     Error *local_err = NULL;
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        monitor_printf(mon, "Device '%s' is writable but does not "
-                       "support snapshots.\n", bdrv_get_device_name(bs));
+        error_setg(errp, "Device '%s' is writable but does not "
+                   "support snapshots.", bdrv_get_device_name(bs));

Since you're touching this already, please drop the period and clean up the line wrapping:

error_setg(errp,
"Device '%s' is writable but does not support snapshots", bdrv_get_device_name(bs));

Quoted 60 lines
migration/savevm.c +8 -11
         return;
     }
 
     /* Delete old snapshots of the same name */
     if (name && bdrv_all_delete_snapshot(name, &bs1, &local_err) < 0) {
-        monitor_printf(mon,
-                       "Error while deleting snapshot on device '%s': %s\n",
-                       bdrv_get_device_name(bs1), error_get_pretty(local_err));
+        error_setg(errp, "Error while deleting snapshot on device '%s': %s",
+                   bdrv_get_device_name(bs1), error_get_pretty(local_err));
         error_free(local_err);
         return;
     }
 
     bs = bdrv_all_find_vmstate_bs();
     if (bs == NULL) {
-        monitor_printf(mon, "No block device can accept snapshots\n");
+        error_setg(errp, "No block device can accept snapshots");
         return;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -1945,7 +1943,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
 
     ret = global_state_store();
     if (ret) {
-        monitor_printf(mon, "Error saving global state\n");
+        error_setg(errp, "Error saving global state");
         return;
     }
     vm_stop(RUN_STATE_SAVE_VM);
@@ -1977,22 +1975,20 @@ void hmp_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");
+        error_setg(errp, "Could not open VM state file");
         goto the_end;
     }
-    ret = qemu_savevm_state(f, &local_err);
+    ret = qemu_savevm_state(f, errp);
     vm_state_size = qemu_ftell(f);
     qemu_fclose(f);
     if (ret < 0) {
-        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
-        error_free(local_err);
         goto the_end;
     }
 
     ret = bdrv_all_create_snapshot(sn, bs, vm_state_size, &bs);
     if (ret < 0) {
-        monitor_printf(mon, "Error while creating snapshot on '%s'\n",
-                       bdrv_get_device_name(bs));
+        error_setg(errp, "Error while creating snapshot on '%s'",
+                   bdrv_get_device_name(bs));
     }
 
  the_end:
@@ -2002,6 +1998,18 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     }
 }

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2009

Quoted 10 lines
migration/savevm.c +9 -0
 
+void hmp_savevm(Monitor *mon, const QDict *qdict)
+{
+    Error *local_err = NULL;
+
+    do_savevm(qdict_get_try_str(qdict, "name"), &local_err);
+
+    if (local_err != NULL) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);

Easier:

        error_report_err(local_err);

Already used elsewhere in this file.

Quoted 6 lines
migration/savevm.c +3 -0
+    }
+}
+
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
Reviewed-by on v1 1/5
#3 lore raw

Re: [Qemu-devel] [PATCH 1/5] migration: split hmp_savevm to do_savevm and hmp_savevm wrapper

In reply to Denis V. Lunev
Quoted 8 lines · Denis V. Lunev

This would be useful in the next step when QMP version of this call will be introduced.

CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
#4 lore raw

PATCH 2/5 qmp: create qmp_savevm command

In reply to Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c |  5 +++++
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
migration/savevm.c +5 -0
index f83ffd0..565b10a 100644
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     }
 }
 
+void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
qapi-schema.json +13 -0
index b65905f..8cc8b44 100644
@@ -3962,3 +3962,16 @@
 ##
 { 'enum': 'ReplayMode',
   'data': [ 'none', 'record', 'play' ] }
+
+##
+# @savevm
+#
+# Save a VM snapshot. Without a name new snapshot is created",
+#
+# @name: identifier of a snapshot to be created
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'savevm', 'data': {'*name': 'str'} }
qmp-commands.hx +25 -0
index 9d8b42f..cd895f6 100644
@@ -4739,3 +4739,28 @@ Example:
                  {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840,
                   "pop-vlan": 1, "id": 251658240}
    ]}
+
+EQMP
+
+SQMP
+savevm
+------------------
+
+Save a VM snapshot. If no tag or id are provided, a new snapshot is created
+
+Arguments:
+
+- "name": (optional) snapshot name
+
+Example:
+
+-> { "execute": "savevm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+    {
+        .name       = "savevm",
+        .args_type  = "name:s?",
+        .mhandler.cmd_new = qmp_marshal_savevm,
+    },
Signature · 1 line
2.5.0
#5 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c |  5 +++++
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2017

Quoted 8 lines
migration/savevm.c +5 -0
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     }
 }
 
+void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

We're working on omitting has_FOO for pointer-valued FOO.

Quoted 8 lines
migration/savevm.c +0 -0
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
qapi-schema.json +0 -0
index b65905f..8cc8b44 100644

qapi-schema.json line 3971

Quoted 10 lines
qapi-schema.json +7 -0
@@ -3962,3 +3962,16 @@
 ##
 { 'enum': 'ReplayMode',
   'data': [ 'none', 'record', 'play' ] }
+
+##
+# @savevm
+#
+# Save a VM snapshot. Without a name new snapshot is created",
+#
+# @name: identifier of a snapshot to be created

Missing #optional tag.

What happens when @name is missing?

What happens when @name names an existing snapshot?

Do we want @name to be optional in QMP? I dimly remember ambiguity problems between names and IDs. Perhaps it'll become clear later in the series.

The QMP interface needs to make sense on its own, even if that means deviating from HMP. Juan, Amit, do you have opinions on the proper QMP interface for internal snapshots?

Quoted 39 lines
qapi-schema.json +6 -0
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'savevm', 'data': {'*name': 'str'} }
qmp-commands.hx +25 -0
index 9d8b42f..cd895f6 100644
@@ -4739,3 +4739,28 @@ Example:
                  {"type": 0, "out-pport": 0, "pport": 0, "vlan-id": 3840,
                   "pop-vlan": 1, "id": 251658240}
    ]}
+
+EQMP
+
+SQMP
+savevm
+------------------
+
+Save a VM snapshot. If no tag or id are provided, a new snapshot is created
+
+Arguments:
+
+- "name": (optional) snapshot name
+
+Example:
+
+-> { "execute": "savevm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+    {
+        .name       = "savevm",
+        .args_type  = "name:s?",
+        .mhandler.cmd_new = qmp_marshal_savevm,
+    },
#6 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

Quoted 29 lines · Markus Armbruster
Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c |  5 +++++
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 25 +++++++++++++++++++++++++
 3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2017

Quoted 8 lines
migration/savevm.c +5 -0
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
     }
 }
 
+void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

Quoted 1 line

We're working on omitting has_FOO for pointer-valued FOO.

Agreed.

Quoted 22 lines
Quoted 9 lines
migration/savevm.c +0 -0
 void qmp_xen_save_devices_state(const char *filename, Error **errp)
 {
     QEMUFile *f;
qapi-schema.json +0 -0
index b65905f..8cc8b44 100644

qapi-schema.json line 3971

Quoted 10 lines
qapi-schema.json +7 -0
@@ -3962,3 +3962,16 @@
 ##
 { 'enum': 'ReplayMode',
   'data': [ 'none', 'record', 'play' ] }
+
+##
+# @savevm
+#
+# Save a VM snapshot. Without a name new snapshot is created",
+#
+# @name: identifier of a snapshot to be created

Missing #optional tag.

Quoted 1 line

What happens when @name is missing?

Why are we allowing this? QMP is going to be called by libvirt or similar, they can choose a name, thanks very much.

Quoted 1 line

What happens when @name names an existing snapshot?

We remove them.

    /* Delete old snapshots of the same name */
    if (name && del_existing_snapshots(mon, name) < 0) {
        goto the_end;
    }

I think we should give one error. Let the hmp code remove them. I would preffer to change the interface to "require" a flag if we want it to be removed. But requiring a flag is the equivalent of requiring

qmp_deletevm
qmp_savevm

or whatever they are called.

Quoted 3 lines

Do we want @name to be optional in QMP? I dimly remember ambiguity problems between names and IDs. Perhaps it'll become clear later in the series.

Again, I think that requiring a name is the best thing to do. Libvirt, openstack and friends are good at choosen names, qemu is not.

Quoted 3 lines

The QMP interface needs to make sense on its own, even if that means deviating from HMP. Juan, Amit, do you have opinions on the proper QMP interface for internal snapshots?

I agree that the "requirement" of a name is a good idea. Not deleting the existing snapshots looks like a good idea also. It is not difficult to romeve them previously.

Thanks, Juan.

#7 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

Quoted 29 lines · Juan Quintela
Quoted 28 lines · Markus Armbruster
Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
  migration/savevm.c |  5 +++++
  qapi-schema.json   | 13 +++++++++++++
  qmp-commands.hx    | 25 +++++++++++++++++++++++++
  3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2017

Quoted 8 lines
migration/savevm.c +5 -0
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
      }
  }
 
+void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

Quoted 3 lines
Quoted 1 line

We're working on omitting has_FOO for pointer-valued FOO.

Agreed.

is there a tree with this stuff in or something I could be based on? This series is simple enough to be written fast and be merged early when the hard freeze will be done.

Above stuff could have a way harder way due to the amount of changes to be performed.

Den

#8 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

Quoted 7 lines · Denis V. Lunev
Quoted 7 lines
Quoted 7 lines

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2017

Quoted 5 lines

+void qmp_savevm(bool has_name, const char *name, Error **errp)

migration/savevm.c +4 -0
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

We're working on omitting has_FOO for pointer-valued FOO.

Agreed.

is there a tree with this stuff in or something I could be based on? This series is simple enough to be written fast and be merged early when the hard freeze will be done.

I have started the work in my local tree, but have not posted it yet. I'll try and remember to cc you when it's ready (right now, there are more than 20 qapi patches from me and another 35 or so from Marc-Andre that need reviewing before we'd even get to the point of my work on dropping has_FOO for pointers).

Quoted 3 lines

Above stuff could have a way harder way due to the amount of changes to be performed.

Dropping has_FOO will be rather invasive; my plan is to add a per-struct marker to the .json files on which structs are ready to use the leaner layout, then do a series of patches that adjusts a couple structs at a time and catches all fallout for those structs. Then, if everything converts nicely to the leaner form, I can remove the per-struct marker in the end. So it's not a problem to just keep the three-argument form with has_name for now.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#9 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

In reply to Denis V. Lunev
Quoted 33 lines · Denis V. Lunev
Quoted 28 lines · Juan Quintela
Quoted 27 lines · Markus Armbruster
Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
  migration/savevm.c |  5 +++++
  qapi-schema.json   | 13 +++++++++++++
  qmp-commands.hx    | 25 +++++++++++++++++++++++++
  3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2016

Quoted 7 lines
migration/savevm.c +4 -0
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
      }
  }
  +void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

Quoted 3 lines
Quoted 1 line

We're working on omitting has_FOO for pointer-valued FOO.

Agreed.

Quoted 6 lines

is there a tree with this stuff in or something I could be based on? This series is simple enough to be written fast and be merged early when the hard freeze will be done.

Above stuff could have a way harder way due to the amount of changes to be performed.

I recommend not to base on our qapi work just for the has_FOO change. I mentioned it only because once it lands, the wrapper I want you to drop would become entirely pointless. Go ahead and get your patches in, and let us deal with cleaning up all has_FOO.

#10 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

In reply to Markus Armbruster
Quoted 21 lines · Markus Armbruster
Quoted 19 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
  migration/savevm.c |  5 +++++
  qapi-schema.json   | 13 +++++++++++++
  qmp-commands.hx    | 25 +++++++++++++++++++++++++
  3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
      }
  }
 
Quoted 8 lines

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2017

Quoted 5 lines
migration/savevm.c +5 -0
+void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

We're working on omitting has_FOO for pointer-valued FOO.

error code is used in the qemu-img.
I can drop error code check there and replace it with checking of Error pointer. Is this OK for you?

Den

#11 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

Quoted 28 lines · Denis V. Lunev
Quoted 27 lines · Markus Armbruster
Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
  migration/savevm.c |  5 +++++
  qapi-schema.json   | 13 +++++++++++++
  qmp-commands.hx    | 25 +++++++++++++++++++++++++
  3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2016

Quoted 7 lines
migration/savevm.c +4 -0
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
      }
  }
  +void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

Quoted 5 lines
Quoted 1 line

We're working on omitting has_FOO for pointer-valued FOO.

error code is used in the qemu-img.
I can drop error code check there and replace it with checking of Error pointer.
Is this OK for you?

Let me rephrase my request:

1. Instead of wrapping do_savevm() in qmp_savevm(), use it directly.

2. Rename do_savevm() to qmp_savevm(), and change its arguments to make it work as QMP command handler.

Does that make sense to you?

#12 lore raw

Re: [Qemu-devel] [PATCH 2/5] qmp: create qmp_savevm command

Quoted 35 lines · Markus Armbruster
Quoted 28 lines · Denis V. Lunev
Quoted 27 lines · Markus Armbruster
Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
   migration/savevm.c |  5 +++++
   qapi-schema.json   | 13 +++++++++++++
   qmp-commands.hx    | 25 +++++++++++++++++++++++++
   3 files changed, 43 insertions(+)
migration/savevm.c +0 -0
index f83ffd0..565b10a 100644

migration/savevm.c void hmp_savevm(Monitor *mon, const QDict *qdict) · line 2016

Quoted 7 lines
migration/savevm.c +4 -0
@@ -2010,6 +2010,11 @@ void hmp_savevm(Monitor *mon, const QDict *qdict)
       }
   }
   +void qmp_savevm(bool has_name, const char *name, Error **errp)
+{
+    do_savevm(has_name ? name : NULL, errp);
+}
+

Please name do_savevm() qmp_savevm() and drop this wrapper.

Quoted 5 lines
Quoted 1 line

We're working on omitting has_FOO for pointer-valued FOO.

error code is used in the qemu-img.
I can drop error code check there and replace it with checking of Error pointer.
Is this OK for you?

Quoted 8 lines

Let me rephrase my request:

1. Instead of wrapping do_savevm() in qmp_savevm(), use it directly.

2. Rename do_savevm() to qmp_savevm(), and change its arguments to make it work as QMP command handler.

Does that make sense to you?

sure!

I have mismatched with load_vmstate which has return code and the error code was really checked in qemu_img.c

I'll address that there, sorry for confusion.

Den

#13 lore raw

PATCH 3/5 qmp: create qmp_delvm command

In reply to Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c | 27 ++++++++++++++++++---------
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 23 +++++++++++++++++++++++
 3 files changed, 54 insertions(+), 9 deletions(-)
migration/savevm.c +18 -9
index 565b10a..90b6850 100644
@@ -2115,17 +2115,26 @@ int load_vmstate(const char *name)
     return 0;
 }
 
-void hmp_delvm(Monitor *mon, const QDict *qdict)
+void qmp_delvm(const char *name, Error **errp)
 {
     BlockDriverState *bs;
-    Error *err;
-    const char *name = qdict_get_str(qdict, "name");
-
-    if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
-        monitor_printf(mon,
-                       "Error while deleting snapshot on device '%s': %s\n",
-                       bdrv_get_device_name(bs), error_get_pretty(err));
-        error_free(err);
+    Error *local_err = NULL;
+
+    if (bdrv_all_delete_snapshot(name, &bs, errp) < 0) {
+        error_setg(errp, "Error while deleting snapshot on device '%s': %s",
+                   bdrv_get_device_name(bs), error_get_pretty(local_err));
+        error_free(local_err);
+    }
+}
+
+void hmp_delvm(Monitor *mon, const QDict *qdict)
+{
+    Error *local_err = NULL;
+    qmp_delvm(qdict_get_str(qdict, "name"), &local_err);
+
+    if (local_err != NULL) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);
     }
 }
 
qapi-schema.json +13 -0
index 8cc8b44..193b34f 100644
@@ -3975,3 +3975,16 @@
 # Since 2.6
 ##
 { 'command': 'savevm', 'data': {'*name': 'str'} }
+
+##
+# @delvm
+#
+# Delete a VM snapshot
+#
+# @name: identifier of a snapshot to be deleted
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'delvm', 'data': {'name': 'str'} }
qmp-commands.hx +23 -0
index cd895f6..b2b17ff 100644
@@ -4764,3 +4764,26 @@ EQMP
         .args_type  = "name:s?",
         .mhandler.cmd_new = qmp_marshal_savevm,
     },
+
+SQMP
+delvm
+------------------
+
+Delete a VM snapshot
+
+Arguments:
+
+- "name": snapshot name
+
+Example:
+
+-> { "execute": "delvm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+    {
+        .name       = "delvm",
+        .args_type  = "name:s",
+        .mhandler.cmd_new = qmp_marshal_delvm,
+    },
Signature · 1 line
2.5.0
#14 lore raw

Re: [Qemu-devel] [PATCH 3/5] qmp: create qmp_delvm command

Quoted 38 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c | 27 ++++++++++++++++++---------
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 23 +++++++++++++++++++++++
 3 files changed, 54 insertions(+), 9 deletions(-)
migration/savevm.c +8 -9
index 565b10a..90b6850 100644
@@ -2115,17 +2115,26 @@ int load_vmstate(const char *name)
     return 0;
 }
 
-void hmp_delvm(Monitor *mon, const QDict *qdict)
+void qmp_delvm(const char *name, Error **errp)
 {
     BlockDriverState *bs;
-    Error *err;
-    const char *name = qdict_get_str(qdict, "name");
-
-    if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
-        monitor_printf(mon,
-                       "Error while deleting snapshot on device '%s': %s\n",
-                       bdrv_get_device_name(bs), error_get_pretty(err));
-        error_free(err);
+    Error *local_err = NULL;
+
+    if (bdrv_all_delete_snapshot(name, &bs, errp) < 0) {
+        error_setg(errp, "Error while deleting snapshot on device '%s': %s",
+                   bdrv_get_device_name(bs), error_get_pretty(local_err));
+        error_free(local_err);
+    }

migration/savevm.c int load_vmstate(const char *name) · line 2137

Quoted 10 lines
migration/savevm.c +10 -0
+}
+
+void hmp_delvm(Monitor *mon, const QDict *qdict)
+{
+    Error *local_err = NULL;
+    qmp_delvm(qdict_get_str(qdict, "name"), &local_err);
+
+    if (local_err != NULL) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);

error_report_err(), please.

migration/savevm.c int load_vmstate(const char *name) · line 2139

Quoted 2 lines
migration/savevm.c +0 -0
     }
 }

Juan, Amit, in case you'd prefer to move out the parts that implement HMP on top of QMP: they can go into hmp.c as long as they're as simple as this one.

Quoted 52 lines
qapi-schema.json +13 -0
index 8cc8b44..193b34f 100644
@@ -3975,3 +3975,16 @@
 # Since 2.6
 ##
 { 'command': 'savevm', 'data': {'*name': 'str'} }
+
+##
+# @delvm
+#
+# Delete a VM snapshot
+#
+# @name: identifier of a snapshot to be deleted
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'delvm', 'data': {'name': 'str'} }
qmp-commands.hx +23 -0
index cd895f6..b2b17ff 100644
@@ -4764,3 +4764,26 @@ EQMP
         .args_type  = "name:s?",
         .mhandler.cmd_new = qmp_marshal_savevm,
     },
+
+SQMP
+delvm
+------------------
+
+Delete a VM snapshot
+
+Arguments:
+
+- "name": snapshot name
+
+Example:
+
+-> { "execute": "delvm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+    {
+        .name       = "delvm",
+        .args_type  = "name:s",
+        .mhandler.cmd_new = qmp_marshal_delvm,
+    },
#15 lore raw

Re: [Qemu-devel] [PATCH 3/5] qmp: create qmp_delvm command

Quoted 53 lines · Markus Armbruster
Quoted 38 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c | 27 ++++++++++++++++++---------
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 23 +++++++++++++++++++++++
 3 files changed, 54 insertions(+), 9 deletions(-)
migration/savevm.c +8 -9
index 565b10a..90b6850 100644
@@ -2115,17 +2115,26 @@ int load_vmstate(const char *name)
     return 0;
 }
 
-void hmp_delvm(Monitor *mon, const QDict *qdict)
+void qmp_delvm(const char *name, Error **errp)
 {
     BlockDriverState *bs;
-    Error *err;
-    const char *name = qdict_get_str(qdict, "name");
-
-    if (bdrv_all_delete_snapshot(name, &bs, &err) < 0) {
-        monitor_printf(mon,
-                       "Error while deleting snapshot on device '%s': %s\n",
-                       bdrv_get_device_name(bs), error_get_pretty(err));
-        error_free(err);
+    Error *local_err = NULL;
+
+    if (bdrv_all_delete_snapshot(name, &bs, errp) < 0) {
+        error_setg(errp, "Error while deleting snapshot on device '%s': %s",
+                   bdrv_get_device_name(bs), error_get_pretty(local_err));
+        error_free(local_err);
+    }

migration/savevm.c int load_vmstate(const char *name) · line 2137

Quoted 10 lines
migration/savevm.c +10 -0
+}
+
+void hmp_delvm(Monitor *mon, const QDict *qdict)
+{
+    Error *local_err = NULL;
+    qmp_delvm(qdict_get_str(qdict, "name"), &local_err);
+
+    if (local_err != NULL) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);

error_report_err(), please.

Quoted 6 lines

migration/savevm.c int load_vmstate(const char *name) · line 2139

Quoted 2 lines
migration/savevm.c +0 -0
     }
 }

Juan, Amit, in case you'd prefer to move out the parts that implement HMP on top of QMP: they can go into hmp.c as long as they're as simple as this one.

Perfect for me.

Thanks, Juan.

#17 lore raw

PATCH 4/5 migration: improve error reporting for hmp_loadvm

In reply to Denis V. Lunev

The patch adds Error ** parameter to load_vmstate call and fills error inside. The caller after that properly reports error either through monitor or via local stderr facility during VM start.

This helper will be usefull too for qmp_load_vmstate implementation.

CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 include/sysemu/sysemu.h |  2 +-
 migration/savevm.c      | 25 +++++++++++++------------
 monitor.c               |  7 ++++++-
 vl.c                    |  5 ++++-
 4 files changed, 24 insertions(+), 15 deletions(-)
include/sysemu/sysemu.h +1 -1
index 3bb8897..d9ccf45 100644
@@ -78,7 +78,7 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 
 void hmp_savevm(Monitor *mon, const QDict *qdict);
-int load_vmstate(const char *name);
+int load_vmstate(const char *name, Error **errp);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
 
migration/savevm.c +13 -12
index 90b6850..08c6c65 100644
@@ -2042,7 +2042,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
     }
 }
 
-int load_vmstate(const char *name)
+int load_vmstate(const char *name, Error **errp)
 {
     BlockDriverState *bs, *bs_vm_state;
     QEMUSnapshotInfo sn;
@@ -2051,20 +2051,20 @@ int load_vmstate(const char *name)
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        error_report("Device '%s' is writable but does not support snapshots.",
-                     bdrv_get_device_name(bs));
+        error_setg(errp, "Device '%s' is writable but does not support "
+                   "snapshots.", bdrv_get_device_name(bs));
         return -ENOTSUP;
     }
     ret = bdrv_all_find_snapshot(name, true, &bs);
     if (ret < 0) {
-        error_report("Device '%s' does not have the requested snapshot '%s'",
-                     bdrv_get_device_name(bs), name);
+        error_setg(errp, "Device '%s' does not have the requested "
+                   "snapshot '%s'", bdrv_get_device_name(bs), name);
         return ret;
     }
 
     bs_vm_state = bdrv_all_find_vmstate_bs();
     if (!bs_vm_state) {
-        error_report("No block device supports snapshots");
+        error_setg(errp, "No block device supports snapshots");
         return -ENOTSUP;
     }
     aio_context = bdrv_get_aio_context(bs);
@@ -2074,10 +2074,11 @@ int load_vmstate(const char *name)
     ret = bdrv_snapshot_find(bs_vm_state, &sn, name);
     aio_context_release(aio_context);
     if (ret < 0) {
+        error_setg_errno(errp, ret, "Snapshot '%s' not found", name);
         return ret;
     } else if (sn.vm_state_size == 0) {
-        error_report("This is a disk-only snapshot. Revert to it offline "
-            "using qemu-img.");
+        error_setg(errp, "This is a disk-only snapshot. Revert to it offline "
+                   "using qemu-img.");
         return -EINVAL;
     }
 
@@ -2086,15 +2087,15 @@ int load_vmstate(const char *name)
 
     ret = bdrv_all_goto_snapshot(name, &bs);
     if (ret < 0) {
-        error_report("Error %d while activating snapshot '%s' on '%s'",
-                     ret, name, bdrv_get_device_name(bs));
+        error_setg_errno(errp, ret, "Error while activating snapshot "
+                         "'%s' on '%s'", name, bdrv_get_device_name(bs));
         return ret;
     }
 
     /* restore the VM state */
     f = qemu_fopen_bdrv(bs_vm_state, 0);
     if (!f) {
-        error_report("Could not open VM state file");
+        error_setg(errp, "Could not open VM state file");
         return -EINVAL;
     }
 
@@ -2108,7 +2109,7 @@ int load_vmstate(const char *name)
 
     migration_incoming_state_destroy();
     if (ret < 0) {
-        error_report("Error %d while loading VM state", ret);
+        error_setg_errno(errp, ret, "Error while loading VM state");
         return ret;
     }
 
monitor.c +6 -1
index e4cf34e..1a0c932 100644
@@ -1739,10 +1739,15 @@ static void hmp_loadvm(Monitor *mon, const QDict *qdict)
 {
     int saved_vm_running  = runstate_is_running();
     const char *name = qdict_get_str(qdict, "name");
+    Error *local_err = NULL;
 
     vm_stop(RUN_STATE_RESTORE_VM);
 
-    if (load_vmstate(name) == 0 && saved_vm_running) {
+    if (load_vmstate(name, &local_err) < 0) {
+        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
+        error_free(local_err);
+    }
+    if (saved_vm_running) {
         vm_start();
     }
 }
vl.c +4 -1
index 7d993a5..9912366 100644
@@ -4645,8 +4645,11 @@ int main(int argc, char **argv, char **envp)
     qemu_system_reset(VMRESET_SILENT);
     register_global_state();
     if (loadvm) {
-        if (load_vmstate(loadvm) < 0) {
+        Error *local_err = NULL;
+        if (load_vmstate(loadvm, &local_err) < 0) {
             autostart = 0;
+            error_report("%s", error_get_pretty(local_err));
+            error_free(local_err);
         }
     }
 
Signature · 1 line
2.5.0
#18 lore raw

Re: [Qemu-devel] [PATCH 4/5] migration: improve error reporting for hmp_loadvm

Quoted 45 lines · Denis V. Lunev

The patch adds Error ** parameter to load_vmstate call and fills error inside. The caller after that properly reports error either through monitor or via local stderr facility during VM start.

This helper will be usefull too for qmp_load_vmstate implementation.

CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 include/sysemu/sysemu.h |  2 +-
 migration/savevm.c      | 25 +++++++++++++------------
 monitor.c               |  7 ++++++-
 vl.c                    |  5 ++++-
 4 files changed, 24 insertions(+), 15 deletions(-)
include/sysemu/sysemu.h +1 -1
index 3bb8897..d9ccf45 100644
@@ -78,7 +78,7 @@ void qemu_remove_exit_notifier(Notifier *notify);
 void qemu_add_machine_init_done_notifier(Notifier *notify);
 
 void hmp_savevm(Monitor *mon, const QDict *qdict);
-int load_vmstate(const char *name);
+int load_vmstate(const char *name, Error **errp);
 void hmp_delvm(Monitor *mon, const QDict *qdict);
 void hmp_info_snapshots(Monitor *mon, const QDict *qdict);
 
migration/savevm.c +1 -1
index 90b6850..08c6c65 100644
@@ -2042,7 +2042,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp)
     }
 }
 
-int load_vmstate(const char *name)
+int load_vmstate(const char *name, Error **errp)
 {
     BlockDriverState *bs, *bs_vm_state;
     QEMUSnapshotInfo sn;

migration/savevm.c int load_vmstate(const char *name) · line 2055

Quoted 7 lines
migration/savevm.c +2 -2
@@ -2051,20 +2051,20 @@ int load_vmstate(const char *name)
     AioContext *aio_context;
 
     if (!bdrv_all_can_snapshot(&bs)) {
-        error_report("Device '%s' is writable but does not support snapshots.",
-                     bdrv_get_device_name(bs));
+        error_setg(errp, "Device '%s' is writable but does not support "
+                   "snapshots.", bdrv_get_device_name(bs));

Since you're touching this already, please drop the period.

I'd prefer breaking lines between arguments instead of in the middle of an argument:

error_setg(errp,
"Device '%s' is writable but does not support snapshots", bdrv_get_device_name(bs));

I'll continue to review when I have something that applies.

[...]

#19 lore raw

PATCH 5/5 qmp: create QMP implementation of loadvm command

In reply to Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c |  5 +++++
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 23 +++++++++++++++++++++++
 3 files changed, 41 insertions(+)
migration/savevm.c +5 -0
index 08c6c65..f67b5d9 100644
@@ -2116,6 +2116,11 @@ int load_vmstate(const char *name, Error **errp)
     return 0;
 }
 
+void qmp_loadvm(const char *name, Error **errp)
+{
+    load_vmstate(name, errp);
+}
+
 void qmp_delvm(const char *name, Error **errp)
 {
     BlockDriverState *bs;
qapi-schema.json +13 -0
index 193b34f..d133711 100644
@@ -3988,3 +3988,16 @@
 # Since 2.6
 ##
 { 'command': 'delvm', 'data': {'name': 'str'} }
+
+##
+# @loadvm
+#
+# Load a VM snapshot
+#
+# @name: identifier of a snapshot to be loaded
+#
+# Returns: Nothing on success
+#
+# Since 2.6
+##
+{ 'command': 'loadvm', 'data': {'name': 'str'} }
qmp-commands.hx +23 -0
index b2b17ff..d5f80a1 100644
@@ -4787,3 +4787,26 @@ EQMP
         .args_type  = "name:s",
         .mhandler.cmd_new = qmp_marshal_delvm,
     },
+
+SQMP
+loadvm
+------------------
+
+Load a VM snapshot
+
+Arguments:
+
+- "name": snapshot name
+
+Example:
+
+-> { "execute": "loadvm", "arguments": { "name": "snapshot1" } }
+<- { "return": {} }
+
+EQMP
+
+    {
+        .name       = "loadvm",
+        .args_type  = "name:s",
+        .mhandler.cmd_new = qmp_marshal_loadvm,
+    },
Signature · 1 line
2.5.0
#20 lore raw

Re: [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command

Quoted 16 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
 migration/savevm.c |  5 +++++
 qapi-schema.json   | 13 +++++++++++++
 qmp-commands.hx    | 23 +++++++++++++++++++++++
 3 files changed, 41 insertions(+)
migration/savevm.c +0 -0
index 08c6c65..f67b5d9 100644

migration/savevm.c int load_vmstate(const char *name, Error **errp) · line 2123

Quoted 8 lines
migration/savevm.c +5 -0
@@ -2116,6 +2116,11 @@ int load_vmstate(const char *name, Error **errp)
     return 0;
 }
 
+void qmp_loadvm(const char *name, Error **errp)
+{
+    load_vmstate(name, errp);
+}
+

As Markus suggested for the other functions, rename load_vmstate qmp_loadvm()

Thanks, Juan.

#21 lore raw

Re: [Qemu-devel] [PATCH 5/5] qmp: create QMP implementation of loadvm command

Quoted 20 lines · Juan Quintela
Quoted 19 lines · Denis V. Lunev
CC Juan Quintela <[email protected]>
CC Amit Shah <[email protected]>
CC Markus Armbruster <[email protected]>
CC Eric Blake <[email protected]>
---
  migration/savevm.c |  5 +++++
  qapi-schema.json   | 13 +++++++++++++
  qmp-commands.hx    | 23 +++++++++++++++++++++++
  3 files changed, 41 insertions(+)
migration/savevm.c +0 -0
index 08c6c65..f67b5d9 100644
@@ -2116,6 +2116,11 @@ int load_vmstate(const char *name, Error **errp)
      return 0;
  }
 
Quoted 8 lines

migration/savevm.c int load_vmstate(const char *name, Error **errp) · line 2123

Quoted 5 lines
migration/savevm.c +5 -0
+void qmp_loadvm(const char *name, Error **errp)
+{
+    load_vmstate(name, errp);
+}
+

As Markus suggested for the other functions, rename load_vmstate qmp_loadvm()

Thanks, Juan.

load_vmstate is actually 'int load_vmstate' and return code is checked in qemu_img.c

Should I replace error code check there with a check to *errp != 0 or this would lead us into a problem with block level guys?

Den

#22 lore raw
In reply to Denis V. Lunev
Quoted 4 lines · Denis V. Lunev

EFI based VM with pflash storage for NVRAM could not be snapshoted as libvirt configures storage as 'raw' and writable. OK, this is a libvirt problem.

Quoted 8 lines

Another problem is that libvirt can not detect this failure at all as it uses HMP for this operation. This create snapshot/delete snapshot sequence passes silently.

The patchset adds QMP wrappers for the purpose.

At the moment I have placed 2.6 version into QAPI. Though (if you feel appropriate) I can change it to 2.5 :) This is up to you to decide.

Nice try, but I the soft freeze boat has sailed.

Quoted 2 lines

Please note, this patchset is made on top of
[PATCH for 2.5 v8 0/10] dataplane snapshot fixes

That one applies fine, but this one on top doesn't. Rebase?

#23 lore raw
Quoted 10 lines · Markus Armbruster
Quoted 8 lines · Denis V. Lunev

EFI based VM with pflash storage for NVRAM could not be snapshoted as libvirt configures storage as 'raw' and writable. OK, this is a libvirt problem.

Another problem is that libvirt can not detect this failure at all as it uses HMP for this operation. This create snapshot/delete snapshot sequence passes silently.

Quoted 5 lines
Quoted 4 lines

The patchset adds QMP wrappers for the purpose.

At the moment I have placed 2.6 version into QAPI. Though (if you feel appropriate) I can change it to 2.5 :) This is up to you to decide.

Nice try, but I the soft freeze boat has sailed.

OK. no problem

Quoted 3 lines
Quoted 2 lines

Please note, this patchset is made on top of
[PATCH for 2.5 v8 0/10] dataplane snapshot fixes

That one applies fine, but this one on top doesn't. Rebase?

yep. The difference is really small there (just additional 'true' parameter in bdrv_find_all_snapshot). I think that I'll wait a day or two before rework to give Juan and Amit their chances to blame me :)

Den