Blame SOURCES/kvm-block-Fix-drive-for-certain-non-string-scalars.patch

1bdc94
From 0a45c26f9838054d3f97b35e82877239d4e7c920 Mon Sep 17 00:00:00 2001
1bdc94
From: Markus Armbruster <armbru@redhat.com>
1bdc94
Date: Mon, 18 Jun 2018 08:43:18 +0200
1bdc94
Subject: [PATCH 11/54] block: Fix -drive for certain non-string scalars
1bdc94
1bdc94
RH-Author: Markus Armbruster <armbru@redhat.com>
1bdc94
Message-id: <20180618084330.30009-12-armbru@redhat.com>
1bdc94
Patchwork-id: 80737
1bdc94
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 11/23] block: Fix -drive for certain non-string scalars
1bdc94
Bugzilla: 1557995
1bdc94
RH-Acked-by: Max Reitz <mreitz@redhat.com>
1bdc94
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
1bdc94
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
1bdc94
The previous commit fixed -blockdev breakage due to misuse of the
1bdc94
qobject input visitor's keyval flavor in bdrv_file_open().  The commit
1bdc94
message explain why using the plain flavor would be just as wrong; it
1bdc94
would break -drive.  Turns out we break it in three places:
1bdc94
nbd_open(), sd_open() and ssh_file_open().  They are even marked
1bdc94
FIXME.  Example breakage:
1bdc94
1bdc94
    $ qemu-system-x86 -drive node-name=n1,driver=nbd,server.type=inet,server.host=localhost,server.port=1234,server.numeric=off
1bdc94
    qemu-system-x86: -drive node-name=n1,driver=nbd,server.type=inet,server.host=localhost,server.port=1234,server.numeric=off: Invalid parameter type for 'numeric', expected: boolean
1bdc94
1bdc94
Fix it the same way: replace qdict_crumple() by
1bdc94
qdict_crumple_for_keyval_qiv(), and switch from plain to the keyval
1bdc94
flavor.
1bdc94
1bdc94
Signed-off-by: Markus Armbruster <armbru@redhat.com>
1bdc94
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
(cherry picked from commit 374c52467a38c2e811f6c0db4edc9ea7d5f34341)
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 block/nbd.c      | 12 ++----------
1bdc94
 block/sheepdog.c | 12 ++----------
1bdc94
 block/ssh.c      | 12 ++----------
1bdc94
 3 files changed, 6 insertions(+), 30 deletions(-)
1bdc94
1bdc94
diff --git a/block/nbd.c b/block/nbd.c
1bdc94
index f499830..b0be357 100644
1bdc94
--- a/block/nbd.c
1bdc94
+++ b/block/nbd.c
1bdc94
@@ -273,20 +273,12 @@ static SocketAddress *nbd_config(BDRVNBDState *s, QDict *options,
1bdc94
         goto done;
1bdc94
     }
1bdc94
 
1bdc94
-    crumpled_addr = qdict_crumple(addr, errp);
1bdc94
+    crumpled_addr = qdict_crumple_for_keyval_qiv(addr, errp);
1bdc94
     if (!crumpled_addr) {
1bdc94
         goto done;
1bdc94
     }
1bdc94
 
1bdc94
-    /*
1bdc94
-     * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive
1bdc94
-     * server.type=inet.  .to doesn't matter, it's ignored anyway.
1bdc94
-     * That's because when @options come from -blockdev or
1bdc94
-     * blockdev_add, members are typed according to the QAPI schema,
1bdc94
-     * but when they come from -drive, they're all QString.  The
1bdc94
-     * visitor expects the former.
1bdc94
-     */
1bdc94
-    iv = qobject_input_visitor_new(crumpled_addr);
1bdc94
+    iv = qobject_input_visitor_new_keyval(crumpled_addr);
1bdc94
     visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
1bdc94
     if (local_err) {
1bdc94
         error_propagate(errp, local_err);
1bdc94
diff --git a/block/sheepdog.c b/block/sheepdog.c
1bdc94
index 821a3c4..dd582d5 100644
1bdc94
--- a/block/sheepdog.c
1bdc94
+++ b/block/sheepdog.c
1bdc94
@@ -546,20 +546,12 @@ static SocketAddress *sd_server_config(QDict *options, Error **errp)
1bdc94
 
1bdc94
     qdict_extract_subqdict(options, &server, "server.");
1bdc94
 
1bdc94
-    crumpled_server = qdict_crumple(server, errp);
1bdc94
+    crumpled_server = qdict_crumple_for_keyval_qiv(server, errp);
1bdc94
     if (!crumpled_server) {
1bdc94
         goto done;
1bdc94
     }
1bdc94
 
1bdc94
-    /*
1bdc94
-     * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive
1bdc94
-     * server.type=inet.  .to doesn't matter, it's ignored anyway.
1bdc94
-     * That's because when @options come from -blockdev or
1bdc94
-     * blockdev_add, members are typed according to the QAPI schema,
1bdc94
-     * but when they come from -drive, they're all QString.  The
1bdc94
-     * visitor expects the former.
1bdc94
-     */
1bdc94
-    iv = qobject_input_visitor_new(crumpled_server);
1bdc94
+    iv = qobject_input_visitor_new_keyval(crumpled_server);
1bdc94
     visit_type_SocketAddress(iv, NULL, &saddr, &local_err);
1bdc94
     if (local_err) {
1bdc94
         error_propagate(errp, local_err);
1bdc94
diff --git a/block/ssh.c b/block/ssh.c
1bdc94
index 5931064..2fc7cd9 100644
1bdc94
--- a/block/ssh.c
1bdc94
+++ b/block/ssh.c
1bdc94
@@ -623,20 +623,12 @@ static BlockdevOptionsSsh *ssh_parse_options(QDict *options, Error **errp)
1bdc94
     }
1bdc94
 
1bdc94
     /* Create the QAPI object */
1bdc94
-    crumpled = qdict_crumple(options, errp);
1bdc94
+    crumpled = qdict_crumple_for_keyval_qiv(options, errp);
1bdc94
     if (crumpled == NULL) {
1bdc94
         goto fail;
1bdc94
     }
1bdc94
 
1bdc94
-    /*
1bdc94
-     * FIXME .numeric, .to, .ipv4 or .ipv6 don't work with -drive.
1bdc94
-     * .to doesn't matter, it's ignored anyway.
1bdc94
-     * That's because when @options come from -blockdev or
1bdc94
-     * blockdev_add, members are typed according to the QAPI schema,
1bdc94
-     * but when they come from -drive, they're all QString.  The
1bdc94
-     * visitor expects the former.
1bdc94
-     */
1bdc94
-    v = qobject_input_visitor_new(crumpled);
1bdc94
+    v = qobject_input_visitor_new_keyval(crumpled);
1bdc94
     visit_type_BlockdevOptionsSsh(v, NULL, &result, &local_err);
1bdc94
     visit_free(v);
1bdc94
     qobject_unref(crumpled);
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94