aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-03-06 18:55:58 +0100
committerKevin Wolf <kwolf@redhat.com>2012-03-12 15:14:07 +0100
commitbc8b094feb61c5f3ad55113f1c9b3288dd843b10 (patch)
treeca553ea3a0a95fa7a9ccf48d001e90049c0cc0d9 /blockdev.c
parent52e7c241ac766406f05fa331eec9dbb33ebd2640 (diff)
downloadqemu-bc8b094feb61c5f3ad55113f1c9b3288dd843b10.zip
qemu-bc8b094feb61c5f3ad55113f1c9b3288dd843b10.tar.gz
qemu-bc8b094feb61c5f3ad55113f1c9b3288dd843b10.tar.bz2
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 <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/blockdev.c b/blockdev.c
index 88730c1..0a6edc3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -748,9 +748,10 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
BlockDriver *proto_drv;
BlockDriver *drv;
int flags;
+ enum NewImageMode mode;
+ const char *new_image_file;
const char *device;
const char *format = "qcow2";
- const char *new_image_file = NULL;
dev_info = dev_entry->value;
dev_entry = dev_entry->next;
@@ -761,10 +762,14 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
switch (dev_info->kind) {
case BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:
device = dev_info->blockdev_snapshot_sync->device;
+ if (!dev_info->blockdev_snapshot_sync->has_mode) {
+ dev_info->blockdev_snapshot_sync->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
+ }
+ new_image_file = dev_info->blockdev_snapshot_sync->snapshot_file;
if (dev_info->blockdev_snapshot_sync->has_format) {
format = dev_info->blockdev_snapshot_sync->format;
}
- new_image_file = dev_info->blockdev_snapshot_sync->snapshot_file;
+ mode = dev_info->blockdev_snapshot_sync->mode;
break;
default:
abort();
@@ -805,13 +810,15 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
}
/* 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 (mode != NEW_IMAGE_MODE_EXISTING) {
+ 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 */