Blame SOURCES/kvm-QMP-Relax-__com.redhat_drive_add-parameter-checking.patch

0a122b
From 5ed1e31ed43f8bdfe765c7c564d69fb437961d42 Mon Sep 17 00:00:00 2001
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Wed, 5 Mar 2014 17:32:58 +0100
0a122b
Subject: [PATCH 02/16] QMP: Relax __com.redhat_drive_add parameter checking
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1394040778-1544-2-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 58021
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 1/1] QMP: Relax __com.redhat_drive_add parameter checking
0a122b
Bugzilla: 1057471
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Amos Kong <akong@redhat.com>
0a122b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
I/O throttling and many new features are unavailable with this
0a122b
command, because its parameter checking is overly restrictive.
0a122b
Relax it.
0a122b
0a122b
The command was forward-ported from RHEL-6 (commit 75ad257).  It
0a122b
provides access to drive_init() via QMP with the parameters restricted
0a122b
to a subset of the ones recognized by drive_init().  We did that
0a122b
because some parameters make sense only when configuring a frontend in
0a122b
addition to a backend, and the command doesn't do that.
0a122b
0a122b
The parameter filtering is implemented as a whitelist.  The
0a122b
forward-port neglected to update the whitelist for all the stuff that
0a122b
has changed since RHEL-6.
0a122b
0a122b
Due to new features like driver-specific parameters, a whitelist is no
0a122b
longer convenient.  Replace by a blacklist that contains exactly the
0a122b
drive_init() parameters that are already filtered out on RHEL-6.
0a122b
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
---
0a122b
 device-hotplug.c | 15 +++++----------
0a122b
 1 file changed, 5 insertions(+), 10 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 device-hotplug.c |   15 +++++----------
0a122b
 1 files changed, 5 insertions(+), 10 deletions(-)
0a122b
0a122b
diff --git a/device-hotplug.c b/device-hotplug.c
0a122b
index 20f6b7f..78a18f2 100644
0a122b
--- a/device-hotplug.c
0a122b
+++ b/device-hotplug.c
0a122b
@@ -80,13 +80,8 @@ err:
0a122b
 
0a122b
 static void check_parm(const char *key, QObject *obj, void *opaque)
0a122b
 {
0a122b
-    static const char *valid_keys[] = {
0a122b
-        "id", "cyls", "heads", "secs", "trans", "media", "snapshot",
0a122b
-        "file", "cache", "aio", "format", "serial", "rerror", "werror",
0a122b
-        "readonly", "copy-on-read",
0a122b
-#ifdef CONFIG_BLOCK_IO_THROTTLING
0a122b
-        "bps", "bps_rd", "bps_wr", "iops", "iops_rd", "iops_wr",
0a122b
-#endif
0a122b
+    static const char *unwanted_keys[] = {
0a122b
+        "bus", "unit", "index", "if", "boot", "addr",
0a122b
         NULL
0a122b
 
0a122b
     };
0a122b
@@ -97,14 +92,14 @@ static void check_parm(const char *key, QObject *obj, void *opaque)
0a122b
         return;
0a122b
     }
0a122b
 
0a122b
-    for (p = valid_keys; *p; p++) {
0a122b
+    for (p = unwanted_keys; *p; p++) {
0a122b
         if (!strcmp(key, *p)) {
0a122b
+            qerror_report(QERR_INVALID_PARAMETER, key);
0a122b
+            *stopped = 1;
0a122b
             return;
0a122b
         }
0a122b
     }
0a122b
 
0a122b
-    qerror_report(QERR_INVALID_PARAMETER, key);
0a122b
-    *stopped = 1;
0a122b
 }
0a122b
 
0a122b
 int simple_drive_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
0a122b
-- 
0a122b
1.7.1
0a122b