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

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