|
|
9ae3a8 |
From 80e1dce1b2b514b1553f6d02194110db0d330c2d Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 9 Sep 2013 14:27:53 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 02/38] block: move input parsing code in qmp_transaction()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1378736903-18489-3-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54189
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 02/32] block: move input parsing code in qmp_transaction()
|
|
|
9ae3a8 |
Bugzilla: 1005818
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: 1005818
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The code is moved into preparation function, and changed
|
|
|
9ae3a8 |
a bit to tip more clearly what it is doing.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit e2a31e8798e8246bed8ab396a71cd06bf95edde6)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 38 +++++++++++++++++++-------------------
|
|
|
9ae3a8 |
1 file changed, 19 insertions(+), 19 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 38 +++++++++++++++++++-------------------
|
|
|
9ae3a8 |
1 files changed, 19 insertions(+), 19 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 1bff654..9eab803 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -785,10 +785,7 @@ typedef struct BlkTransactionStates {
|
|
|
9ae3a8 |
QSIMPLEQ_ENTRY(BlkTransactionStates) entry;
|
|
|
9ae3a8 |
} BlkTransactionStates;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static void external_snapshot_prepare(const char *device,
|
|
|
9ae3a8 |
- const char *format,
|
|
|
9ae3a8 |
- const char *new_image_file,
|
|
|
9ae3a8 |
- enum NewImageMode mode,
|
|
|
9ae3a8 |
+static void external_snapshot_prepare(BlockdevAction *action,
|
|
|
9ae3a8 |
BlkTransactionStates *states,
|
|
|
9ae3a8 |
Error **errp)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
@@ -796,7 +793,24 @@ static void external_snapshot_prepare(const char *device,
|
|
|
9ae3a8 |
BlockDriver *drv;
|
|
|
9ae3a8 |
int flags, ret;
|
|
|
9ae3a8 |
Error *local_err = NULL;
|
|
|
9ae3a8 |
+ const char *device;
|
|
|
9ae3a8 |
+ const char *new_image_file;
|
|
|
9ae3a8 |
+ const char *format = "qcow2";
|
|
|
9ae3a8 |
+ enum NewImageMode mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* get parameters */
|
|
|
9ae3a8 |
+ g_assert(action->kind == BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ device = action->blockdev_snapshot_sync->device;
|
|
|
9ae3a8 |
+ new_image_file = action->blockdev_snapshot_sync->snapshot_file;
|
|
|
9ae3a8 |
+ if (action->blockdev_snapshot_sync->has_format) {
|
|
|
9ae3a8 |
+ format = action->blockdev_snapshot_sync->format;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (action->blockdev_snapshot_sync->has_mode) {
|
|
|
9ae3a8 |
+ mode = action->blockdev_snapshot_sync->mode;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* start processing */
|
|
|
9ae3a8 |
drv = bdrv_find_format(format);
|
|
|
9ae3a8 |
if (!drv) {
|
|
|
9ae3a8 |
error_set(errp, QERR_INVALID_BLOCK_FORMAT, format);
|
|
|
9ae3a8 |
@@ -877,10 +891,6 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
|
|
|
9ae3a8 |
/* We don't do anything in this loop that commits us to the snapshot */
|
|
|
9ae3a8 |
while (NULL != dev_entry) {
|
|
|
9ae3a8 |
BlockdevAction *dev_info = NULL;
|
|
|
9ae3a8 |
- enum NewImageMode mode;
|
|
|
9ae3a8 |
- const char *new_image_file;
|
|
|
9ae3a8 |
- const char *device;
|
|
|
9ae3a8 |
- const char *format = "qcow2";
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
dev_info = dev_entry->value;
|
|
|
9ae3a8 |
dev_entry = dev_entry->next;
|
|
|
9ae3a8 |
@@ -890,17 +900,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
switch (dev_info->kind) {
|
|
|
9ae3a8 |
case BLOCKDEV_ACTION_KIND_BLOCKDEV_SNAPSHOT_SYNC:
|
|
|
9ae3a8 |
- device = dev_info->blockdev_snapshot_sync->device;
|
|
|
9ae3a8 |
- if (!dev_info->blockdev_snapshot_sync->has_mode) {
|
|
|
9ae3a8 |
- dev_info->blockdev_snapshot_sync->mode = NEW_IMAGE_MODE_ABSOLUTE_PATHS;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- new_image_file = dev_info->blockdev_snapshot_sync->snapshot_file;
|
|
|
9ae3a8 |
- if (dev_info->blockdev_snapshot_sync->has_format) {
|
|
|
9ae3a8 |
- format = dev_info->blockdev_snapshot_sync->format;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
- mode = dev_info->blockdev_snapshot_sync->mode;
|
|
|
9ae3a8 |
- external_snapshot_prepare(device, format, new_image_file,
|
|
|
9ae3a8 |
- mode, states, &local_err);
|
|
|
9ae3a8 |
+ external_snapshot_prepare(dev_info, states, errp);
|
|
|
9ae3a8 |
if (error_is_set(&local_err)) {
|
|
|
9ae3a8 |
error_propagate(errp, local_err);
|
|
|
9ae3a8 |
goto delete_and_fail;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|