thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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