thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-block-move-input-parsing-code-in-qmp_transaction.patch

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