From: Pavel Hrdina <phrdina@redhat.com>
To: qemu-devel@nongnu.org
Cc: phrdina@redhat.com, armbru@redhat.com, lcapitulino@redhat.com
Subject: [Qemu-devel] [PATCH v3 11/11] savevm: add force parameter to HMP command and return snapshot info
Date: Thu, 28 Mar 2013 17:47:15 +0100 [thread overview]
Message-ID: <72b352c53d8684c210c57c49e35e81fab019f61f.1364487348.git.phrdina@redhat.com> (raw)
In-Reply-To: <cover.1364487348.git.phrdina@redhat.com>
In-Reply-To: <cover.1364487348.git.phrdina@redhat.com>
HMP command "savevm" now takes extra optional force parameter to specify
whether replace existing snapshot or not. It also returns information
about created snapshot.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
hmp-commands.hx | 16 ++++++++--------
hmp.c | 18 +++++++++++++++++-
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 382b87d..9719cc0 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -307,19 +307,19 @@ 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 = "force:-f,name:s?",
+ .params = "[-f] [tag|id]",
+ .help = "save a VM snapshot, to replace existing snapshot use force flag",
.mhandler.cmd = hmp_vm_snapshot_save,
},
STEXI
-@item savevm [@var{tag}|@var{id}]
+@item savevm [@var{-f}] @var{tag}|@var{id}
@findex savevm
-Create a snapshot of the whole virtual machine. If @var{tag} is
-provided, it is used as human readable identifier. If there is already
-a snapshot with the same @var{tag} or @var{id}, it is replaced. More info at
-@ref{vm_snapshots}.
+Create a snapshot of the whole virtual machine. Parameter "name" is optional.
+If @var{tag} is provided, it is used as human readable identifier. If there is
+already a snapshot with the same @var{tag} or @var{id}, @var{-f} flag needs to
+be specified. More info at @ref{vm_snapshots}.
ETEXI
{
diff --git a/hmp.c b/hmp.c
index b38b6ce..adf586b 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1437,10 +1437,26 @@ void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
void hmp_vm_snapshot_save(Monitor *mon, const QDict *qdict)
{
const char *name = qdict_get_try_str(qdict, "name");
+ bool force = qdict_get_try_bool(qdict, "force", 0);
Error *err = NULL;
SnapshotInfo *info = NULL;
- info = qmp_vm_snapshot_save(!!name, name, true, true, &err);
+ info = qmp_vm_snapshot_save(!!name, name, !!force, force, &err);
+
+ if (info) {
+ char buf[256];
+ QEMUSnapshotInfo sn = {
+ .vm_state_size = info->vm_state_size,
+ .date_sec = info->date_sec,
+ .date_nsec = info->date_nsec,
+ .vm_clock_nsec = info->vm_clock_sec * 1000000000 +
+ info->vm_clock_nsec,
+ };
+ pstrcpy(sn.id_str, sizeof(sn.id_str), info->id);
+ pstrcpy(sn.name, sizeof(sn.name), info->name);
+ monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), &sn));
+ }
+
qapi_free_SnapshotInfo(info);
hmp_handle_error(mon, &err);
}
--
1.8.1.4
next prev parent reply other threads:[~2013-03-28 16:47 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-28 16:47 [Qemu-devel] [PATCH v3 00/11] convert savevm to use qapi and introduce qmp command Pavel Hrdina
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 01/11] block: add error parameter to bdrv_snapshot_create() and related functions Pavel Hrdina
2013-03-28 21:23 ` Eric Blake
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 02/11] block: add error parameter to del_existing_snapshots() Pavel Hrdina
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 03/11] savevm: add error parameter to qemu_savevm_state_begin() Pavel Hrdina
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 04/11] savevm: add error parameter to qemu_savevm_state_iterate() Pavel Hrdina
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 05/11] savevm: add error parameter to qemu_savevm_state_complete() Pavel Hrdina
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 06/11] savevm: add error parameter to qemu_savevm_state() Pavel Hrdina
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 07/11] qapi: Convert savevm Pavel Hrdina
2013-03-28 21:35 ` Eric Blake
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 08/11] qemu-img: introduce qemu_img_handle_error Pavel Hrdina
2013-03-28 21:42 ` Eric Blake
2013-03-28 21:55 ` Eric Blake
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 09/11] block: update return value from bdrv_snapshot_create Pavel Hrdina
2013-03-28 21:53 ` Eric Blake
2013-03-28 16:47 ` [Qemu-devel] [PATCH v3 10/11] savevm: update return value from qemu_savevm_state Pavel Hrdina
2013-03-28 22:00 ` Eric Blake
2013-03-28 16:47 ` Pavel Hrdina [this message]
2013-03-28 22:03 ` [Qemu-devel] [PATCH v3 11/11] savevm: add force parameter to HMP command and return snapshot info Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=72b352c53d8684c210c57c49e35e81fab019f61f.1364487348.git.phrdina@redhat.com \
--to=phrdina@redhat.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).