Blame SOURCES/kvm-blockdev-add-x-blockdev-set-iothread-force-boolean.patch

4a2fec
From 322e74b00634817abd82f66d8c98effc07d532a8 Mon Sep 17 00:00:00 2001
4a2fec
From: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Date: Fri, 22 Dec 2017 11:08:57 +0100
4a2fec
Subject: [PATCH 39/42] blockdev: add x-blockdev-set-iothread force boolean
4a2fec
4a2fec
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Message-id: <20171222110900.24813-18-stefanha@redhat.com>
4a2fec
Patchwork-id: 78495
4a2fec
O-Subject: [RHV7.5 qemu-kvm-rhev PATCH 17/20] blockdev: add x-blockdev-set-iothread force boolean
4a2fec
Bugzilla: 1519721
4a2fec
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
4a2fec
When a node is already associated with a BlockBackend the
4a2fec
x-blockdev-set-iothread command refuses to set the IOThread.  This is to
4a2fec
prevent accidentally changing the IOThread when the nodes are in use.
4a2fec
4a2fec
When the nodes are created with -drive they automatically get a
4a2fec
BlockBackend.  In that case we know nothing is using them yet and it's
4a2fec
safe to set the IOThread.  Add a force boolean to override the check.
4a2fec
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Reviewed-by: Eric Blake <eblake@redhat.com>
4a2fec
Message-id: 20171207201320.19284-4-stefanha@redhat.com
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
(cherry picked from commit 882e9b89af7c1086d97cee11b2437337e756fa00)
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 blockdev.c           | 11 ++++++-----
4a2fec
 qapi/block-core.json |  6 +++++-
4a2fec
 2 files changed, 11 insertions(+), 6 deletions(-)
4a2fec
4a2fec
diff --git a/blockdev.c b/blockdev.c
4a2fec
index 6cbe627..17e2cf1 100644
4a2fec
--- a/blockdev.c
4a2fec
+++ b/blockdev.c
4a2fec
@@ -4192,7 +4192,7 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp)
4a2fec
 }
4a2fec
 
4a2fec
 void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
4a2fec
-                                 Error **errp)
4a2fec
+                                 bool has_force, bool force, Error **errp)
4a2fec
 {
4a2fec
     AioContext *old_context;
4a2fec
     AioContext *new_context;
4a2fec
@@ -4204,10 +4204,11 @@ void qmp_x_blockdev_set_iothread(const char *node_name, StrOrNull *iothread,
4a2fec
         return;
4a2fec
     }
4a2fec
 
4a2fec
-    /* If we want to allow more extreme test scenarios this guard could be
4a2fec
-     * removed.  For now it protects against accidents. */
4a2fec
-    if (bdrv_has_blk(bs)) {
4a2fec
-        error_setg(errp, "Node %s is in use", node_name);
4a2fec
+    /* Protects against accidents. */
4a2fec
+    if (!(has_force && force) && bdrv_has_blk(bs)) {
4a2fec
+        error_setg(errp, "Node %s is associated with a BlockBackend and could "
4a2fec
+                         "be in use (use force=true to override this check)",
4a2fec
+                         node_name);
4a2fec
         return;
4a2fec
     }
4a2fec
 
4a2fec
diff --git a/qapi/block-core.json b/qapi/block-core.json
4a2fec
index d579c99..305f7ff 100644
4a2fec
--- a/qapi/block-core.json
4a2fec
+++ b/qapi/block-core.json
4a2fec
@@ -3895,6 +3895,9 @@
4a2fec
 #
4a2fec
 # @iothread: the name of the IOThread object or null for the main loop
4a2fec
 #
4a2fec
+# @force: true if the node and its children should be moved when a BlockBackend
4a2fec
+#         is already attached
4a2fec
+#
4a2fec
 # Note: this command is experimental and intended for test cases that need
4a2fec
 # control over IOThreads only.
4a2fec
 #
4a2fec
@@ -3917,4 +3920,5 @@
4a2fec
 ##
4a2fec
 { 'command': 'x-blockdev-set-iothread',
4a2fec
   'data' : { 'node-name': 'str',
4a2fec
-             'iothread': 'StrOrNull' } }
4a2fec
+             'iothread': 'StrOrNull',
4a2fec
+             '*force': 'bool' } }
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec