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

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