aboutsummaryrefslogtreecommitdiff
path: root/hmp.c
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2011-11-25 16:15:19 -0200
committerLuiz Capitulino <lcapitulino@redhat.com>2011-12-06 11:40:01 -0200
commit6106e2492fe0080ad85d4862dec9c3bebc57b2f0 (patch)
tree8ebe7e833fdbf1cd3d2caffccbee2cd420fcfa1e /hmp.c
parent5e7caacb2583e6a4657fec51a92147f33c5bae43 (diff)
qapi: Convert blockdev_snapshot_sync
Unfortunately, this conversion required an additional change. In the old QMP command, the 'snapshot-file' argument is specified as optional. The idea is to take the snapshot internally if 'snapshot-file' is not passed. However, internal snapshots are not supported yet so the command returns a MissingParamater error if 'snapshot-file' is not passed. Which makes the argument actually required and will cause compatibility breakage if we change that in the future. To fix this the QAPI converted blockdev_snapshot_sync command makes the 'snapshot-file' argument required. Again, in practice it's actually required, so this is not incompatible. If we do implement internal snapshots someday, we'll need a new argument for it. Note that this discussion doesn't affect HMP. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'hmp.c')
-rw-r--r--hmp.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/hmp.c b/hmp.c
index db199b2995..934e93193a 100644
--- a/hmp.c
+++ b/hmp.c
@@ -643,3 +643,22 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
qmp_block_resize(device, size, &errp);
hmp_handle_error(mon, &errp);
}
+
+void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
+{
+ const char *device = qdict_get_str(qdict, "device");
+ const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+ const char *format = qdict_get_try_str(qdict, "format");
+ Error *errp = NULL;
+
+ if (!filename) {
+ /* In the future, if 'snapshot-file' is not specified, the snapshot
+ will be taken internally. Today it's actually required. */
+ error_set(&errp, QERR_MISSING_PARAMETER, "snapshot-file");
+ hmp_handle_error(mon, &errp);
+ return;
+ }
+
+ qmp_blockdev_snapshot_sync(device, filename, !!format, format, &errp);
+ hmp_handle_error(mon, &errp);
+}