All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] Add save-snapshot, load-snapshot and delete-snapshot to QAPI
@ 2018-01-07 12:23 Richard Palethorpe
  2018-01-07 12:23 ` [Qemu-devel] [PATCH 2/2] Add test cases for saving, loading and deleting snapshots using QAPI Richard Palethorpe
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Richard Palethorpe @ 2018-01-07 12:23 UTC (permalink / raw)
  To: qemu-devel
  Cc: quintela, dgilbert, eblake, armbru, rpalethorpe, Richard Palethorpe

Add QAPI wrapper functions for the existing snapshot functionality. These
functions behave the same way as the HMP savevm, loadvm and delvm
commands. This will allow applications, such as OpenQA, to programmatically
revert the VM to a previous state with no dependence on HMP or qemu-img.

I used the term snapshot instead of VM because I think it is less ambiguous
and matches the internal function names.

Signed-off-by: Richard Palethorpe <richiejp@f-m.fm>
---
 migration/savevm.c | 27 ++++++++++++++++++++++
 qapi-schema.json   | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)

diff --git a/migration/savevm.c b/migration/savevm.c
index b7908f62be..d7bc0f0d41 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2242,6 +2242,11 @@ int save_snapshot(const char *name, Error **errp)
     return ret;
 }
 
+void qmp_save_snapshot(const char *name, Error **errp)
+{
+    save_snapshot(name, errp);
+}
+
 void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
                                 Error **errp)
 {
@@ -2404,6 +2409,28 @@ err_drain:
     return ret;
 }
 
+void qmp_load_snapshot(const char *name, Error **errp)
+{
+    int saved_vm_running = runstate_is_running();
+
+    vm_stop(RUN_STATE_RESTORE_VM);
+
+    if (!load_snapshot(name, errp) && saved_vm_running) {
+        vm_start();
+    }
+}
+
+void qmp_delete_snapshot(const char *name, Error **errp)
+{
+    BlockDriverState *bs;
+
+    if (bdrv_all_delete_snapshot(name, &bs, errp) < 0) {
+        error_prepend(errp,
+                      "Error while deleting snapshot on device '%s': ",
+                      bdrv_get_device_name(bs));
+    }
+}
+
 void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)
 {
     qemu_ram_set_idstr(mr->ram_block,
diff --git a/qapi-schema.json b/qapi-schema.json
index 5c06745c79..906f7c1f74 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1125,6 +1125,72 @@
 { 'command': 'pmemsave',
   'data': {'val': 'int', 'size': 'int', 'filename': 'str'} }
 
+##
+# @save-snapshot:
+#
+# Save a snapshot of the entire Virtual Machine
+#
+# @name: A string identifying the snapshot. This can later be used with
+#        @load-snapshot or @delete-snapshot
+#
+# Since: 2.12.0
+#
+# Returns: If successful, nothing
+#
+# Notes: The equivalent HMP command is savevm. This stores all of the virtual
+#        machine's current state within the virtual machine's
+#        image(s)/storage. If the VM is currently running, this includes the
+#        state of the CPU and RAM. Later the VM can be reverted to this state.
+#
+#        qemu-img can also be used to manipulate snapshots.
+#
+# Examples:
+#
+# -> { "execute": "save-snapshot", "arguments": { "name": "lastgood" } }
+# <- { "return": {} }
+##
+{ 'command': 'save-snapshot',
+  'data': {'name': 'str'} }
+
+##
+# @load-snapshot:
+#
+# Load a snapshot of the entire Virtual Machine, completely reverting it to
+# that state
+#
+# Since: 2.12.0
+#
+# Returns: If successful, nothing
+#
+# Notes: The equivalent HMP command is loadvm. See the @save-snapshot notes.
+#
+# Examples:
+#
+# -> { "execute": "load-snapshot", "arguments": { "name": "lastgood" } }
+# <- { "return": {} }
+##
+{ 'command': 'load-snapshot',
+  'data': {'name': 'str'} }
+
+##
+# @delete-snapshot:
+#
+# Delete a VM snapshot
+#
+# Since: 2.12.0
+#
+# Returns: If successful, nothing
+#
+# Notes: The equivalent HMP command is delvm. See the @save-snapshot notes.
+#
+# Examples:
+#
+# -> { "execute": "delete-snapshot", "arguments": { "name": "lastgood" } }
+# <- { "return": {} }
+##
+{ 'command': 'delete-snapshot',
+  'data': {'name': 'str'} }
+
 ##
 # @cont:
 #
-- 
2.15.1

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

end of thread, other threads:[~2018-02-15 15:21 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-07 12:23 [Qemu-devel] [PATCH 1/2] Add save-snapshot, load-snapshot and delete-snapshot to QAPI Richard Palethorpe
2018-01-07 12:23 ` [Qemu-devel] [PATCH 2/2] Add test cases for saving, loading and deleting snapshots using QAPI Richard Palethorpe
2018-01-08 13:52 ` [Qemu-devel] [PATCH 1/2] Add save-snapshot, load-snapshot and delete-snapshot to QAPI Eric Blake
2018-01-10 16:19   ` Richard Palethorpe
2018-01-10 16:48     ` Eric Blake
2018-02-03 13:28       ` Markus Armbruster
2018-01-11 12:46   ` Max Reitz
2018-01-11 13:04     ` Daniel P. Berrange
2018-01-11 13:23       ` Dr. David Alan Gilbert
2018-01-11 13:36         ` Daniel P. Berrange
2018-01-11 16:55           ` Juan Quintela
2018-02-12 13:25             ` Richard Palethorpe
2018-02-13 10:50       ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2018-02-13 11:43         ` Dr. David Alan Gilbert
2018-02-13 11:51           ` Daniel P. Berrangé
2018-02-13 13:20             ` Kevin Wolf
2018-02-13 13:25               ` Daniel P. Berrangé
     [not found]         ` <20180213143001.GA2354@rkaganb.sw.ru>
2018-02-13 14:36           ` Daniel P. Berrangé
2018-02-13 14:45             ` Kevin Wolf
2018-02-13 14:48               ` Daniel P. Berrangé
2018-02-13 14:51                 ` Denis V. Lunev
2018-02-13 14:59                 ` Dr. David Alan Gilbert
2018-02-13 15:01                   ` Denis V. Lunev
2018-02-13 15:05                     ` Dr. David Alan Gilbert
     [not found]                       ` <20180213151352.GF2307@rkaganb.sw.ru>
2018-02-13 15:27                         ` Dr. David Alan Gilbert
2018-02-13 15:29                           ` Denis V. Lunev
2018-02-13 16:01                       ` Denis Plotnikov
2018-02-15 15:21                         ` Dr. David Alan Gilbert
2018-02-13 16:46                 ` Eric Blake
2018-02-13 19:45                   ` Denis V. Lunev
2018-02-13 14:43           ` Kevin Wolf
2018-02-13 14:50             ` Denis V. Lunev
2018-02-13 14:58             ` Daniel P. Berrangé
2018-02-13 15:23               ` Kevin Wolf
2018-02-13 15:30                 ` Daniel P. Berrangé
2018-02-13 15:51                   ` Kevin Wolf
2018-02-13 16:14             ` Denis Plotnikov
2018-01-10  6:17 ` [Qemu-devel] " Peter Xu

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.