[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 4/6] add reuse field
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 4/6] add reuse field |
Date: |
Thu, 1 Mar 2012 12:21:46 +0100 |
Signed-off-by: Paolo Bonzini <address@hidden>
---
blockdev.c | 18 +++++++++++-------
qapi-schema.json | 3 ++-
qmp-commands.hx | 10 ++++++++++
3 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 1aa544a..8fcdf0e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -749,6 +749,7 @@ void qmp_blockdev_transaction(BlockdevActionList *dev_list,
const char *device;
const char *format = "qcow2";
const char *new_image_file = NULL;
+ bool do_snapshot;
dev_info = dev_entry->value;
dev_entry = dev_entry->next;
@@ -760,6 +761,7 @@ void qmp_blockdev_transaction(BlockdevActionList *dev_list,
switch (dev_info->kind) {
case BLOCKDEV_ACTION_KIND_SNAPSHOT:
device = dev_info->snapshot->device;
+ do_snapshot = !dev_info->snapshot->has_reuse ||
!dev_info->snapshot->reuse;
if (dev_info->snapshot->has_format) {
format = dev_info->snapshot->format;
}
@@ -803,13 +805,15 @@ void qmp_blockdev_transaction(BlockdevActionList
*dev_list,
}
/* create new image w/backing file */
- ret = bdrv_img_create(new_image_file, format,
- states->old_bs->filename,
- states->old_bs->drv->format_name,
- NULL, -1, flags);
- if (ret) {
- error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
- goto delete_and_fail;
+ if (do_snapshot) {
+ ret = bdrv_img_create(new_image_file, format,
+ states->old_bs->filename,
+ states->old_bs->drv->format_name,
+ NULL, -1, flags);
+ if (ret) {
+ error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
+ goto delete_and_fail;
+ }
}
/* We will manually add the backing_hd field to the bs later */
diff --git a/qapi-schema.json b/qapi-schema.json
index d2fbee3..78df122 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1127,7 +1127,8 @@
# @format: #optional the format of the snapshot image, default is 'qcow2'.
##
{ 'type': 'BlockdevSnapshot',
- 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str' } }
+ 'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str',
+ '*reuse': 'bool' } }
##
# @BlockdevAction
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 71d4825..817b689 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)
+ - "reuse": whether QEMU should look for an existing image file
+ (json-bool, optional, default false)
Example:
@@ -725,6 +734,7 @@ Example:
"format": "qcow2" } },
{ 'type': 'snapshot, 'data' : { "device": "ide-hd1",
"snapshot-file":
"/some/place/my-image2",
+ "reuse": true,
"format": "qcow2" } } ] } }
<- { "return": {} }
--
1.7.7.6
- [Qemu-devel] [PATCH v2 0/6] Mirrored writes using blockdev-transaction, Paolo Bonzini, 2012/03/01
- [Qemu-devel] [PATCH v2 1/6] fix format name for backing file, Paolo Bonzini, 2012/03/01
- [Qemu-devel] [PATCH v2 2/6] qapi: complete implementation of unions, Paolo Bonzini, 2012/03/01
- [Qemu-devel] [PATCH v2 4/6] add reuse field,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v2 5/6] Add blkmirror block driver, Paolo Bonzini, 2012/03/01
- [Qemu-devel] [PATCH v2 3/6] rename blockdev-group-snapshot-sync, Paolo Bonzini, 2012/03/01
- [Qemu-devel] [PATCH v2 6/6] add mirroring to blockdev-transaction, Paolo Bonzini, 2012/03/01
- Re: [Qemu-devel] [PATCH v2 0/6] Mirrored writes using blockdev-transaction, Luiz Capitulino, 2012/03/01
- Re: [Qemu-devel] [PATCH v2 0/6] Mirrored writes using blockdev-transaction, Anthony Liguori, 2012/03/01