From 52e7c241ac766406f05fa331eec9dbb33ebd2640 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 6 Mar 2012 18:55:57 +0100 Subject: rename blockdev-group-snapshot-sync We will add other kinds of operation. Prepare for this by adjusting the schema. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- qmp-commands.hx | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) (limited to 'qmp-commands.hx') diff --git a/qmp-commands.hx b/qmp-commands.hx index 0c9bfac..fb4f1df 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -687,41 +687,45 @@ EQMP .mhandler.cmd_new = qmp_marshal_input_block_job_cancel, }, { - .name = "blockdev-group-snapshot-sync", - .args_type = "devlist:O", - .params = "device:B,snapshot-file:s,format:s?", - .mhandler.cmd_new = qmp_marshal_input_blockdev_group_snapshot_sync, + .name = "transaction", + .args_type = "actions:O", + .mhandler.cmd_new = qmp_marshal_input_transaction, }, SQMP -blockdev-group-snapshot-sync ----------------------- - -Synchronous snapshot of one or more block devices. A list array input -is accepted, that contains the device and snapshot file information for -each device in group. The default format, if not specified, is qcow2. +transaction +----------- -If there is any failure creating or opening a new snapshot, all snapshots -for the group are abandoned, and the original disks pre-snapshot attempt -are used. +Atomically operate on one or more block devices. The only supported +operation for now is snapshotting. If there is any failure performing +any of the operations, all snapshots for the group are abandoned, and +the original disks pre-snapshot attempt are used. +A list of dictionaries is accepted, that contains the actions to be performed. +For snapshots this is the device, the file to use for the new snapshot, +and the format. The default format, if not specified, is qcow2. Arguments: -devlist array: - - "device": device name to snapshot (json-string) - - "snapshot-file": name of new image file (json-string) - - "format": format of new image (json-string, optional) +actions array: + - "type": the operation to perform. The only supported + value is "blockdev-snapshot-sync". (json-string) + - "data": a dictionary. The contents depend on the value + of "type". When "type" is "blockdev-snapshot-sync": + - "device": device name to snapshot (json-string) + - "snapshot-file": name of new image file (json-string) + - "format": format of new image (json-string, optional) Example: --> { "execute": "blockdev-group-snapshot-sync", "arguments": - { "devlist": [{ "device": "ide-hd0", - "snapshot-file": "/some/place/my-image", - "format": "qcow2" }, - { "device": "ide-hd1", - "snapshot-file": "/some/place/my-image2", - "format": "qcow2" }] } } +-> { "execute": "transaction", + "arguments": { "actions": [ + { 'type': 'blockdev-snapshot-sync', 'data' : { "device": "ide-hd0", + "snapshot-file": "/some/place/my-image", + "format": "qcow2" } }, + { 'type': 'blockdev-snapshot-sync', 'data' : { "device": "ide-hd1", + "snapshot-file": "/some/place/my-image2", + "format": "qcow2" } } ] } } <- { "return": {} } EQMP -- cgit v1.1 From bc8b094feb61c5f3ad55113f1c9b3288dd843b10 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 6 Mar 2012 18:55:58 +0100 Subject: add mode field to blockdev-snapshot-sync transaction item The mode field lets a management application create the snapshot destination outside QEMU. Right now, the only modes are "existing" and "absolute-paths". Mirroring introduces "no-backing-file". In the future "relative-paths" could be implemented too. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- qmp-commands.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'qmp-commands.hx') diff --git a/qmp-commands.hx b/qmp-commands.hx index fb4f1df..7c03b62 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -705,6 +705,13 @@ A list of dictionaries is accepted, that contains the actions to be performed. For snapshots this is the device, the file to use for the new snapshot, and the format. The default format, if not specified, is qcow2. +Each new snapshot defaults to being created by QEMU (wiping any +contents if the file already exists), but it is also possible to reuse +an externally-created file. In the latter case, you should ensure that +the new image file has the same contents as the current one; QEMU cannot +perform any meaningful check. Typically this is achieved by using the +current image file as the backing file for the new image. + Arguments: actions array: @@ -715,6 +722,8 @@ actions array: - "device": device name to snapshot (json-string) - "snapshot-file": name of new image file (json-string) - "format": format of new image (json-string, optional) + - "mode": whether and how QEMU should create the snapshot file + (NewImageMode, optional, default "absolute-paths") Example: @@ -725,6 +734,7 @@ Example: "format": "qcow2" } }, { 'type': 'blockdev-snapshot-sync', 'data' : { "device": "ide-hd1", "snapshot-file": "/some/place/my-image2", + "mode": "existing", "format": "qcow2" } } ] } } <- { "return": {} } -- cgit v1.1 From 6cc2a4157b31c47303da96c5ed7836db3c10def6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 6 Mar 2012 18:55:59 +0100 Subject: qmp: convert blockdev-snapshot-sync to a wrapper around transactions Simplify the blockdev-snapshot-sync code and gain failsafe operation by turning it into a wrapper around the new transaction command. A new option is also added matching "mode". Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- qmp-commands.hx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qmp-commands.hx') diff --git a/qmp-commands.hx b/qmp-commands.hx index 7c03b62..dfe8a5b 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -760,6 +760,8 @@ Arguments: - "device": device name to snapshot (json-string) - "snapshot-file": name of new image file (json-string) +- "mode": whether and how QEMU should create the snapshot file + (NewImageMode, optional, default "absolute-paths") - "format": format of new image (json-string, optional) Example: -- cgit v1.1