qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 7.0 qemu-kvm 1/1] QMP: Relax __com.redhat_drive_add parameter checking
Date: Wed, 12 Mar 2014 17:58:59 +0100	[thread overview]
Message-ID: <1394643539-26913-2-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1394643539-26913-1-git-send-email-armbru@redhat.com>

Many new features are unavailable with this command, because its
parameter checking is overly restrictive.  Relax it.

The command was forward-ported from RHEL-6 (commit 75ad257).  It
provides access to drive_init() via QMP with the parameters restricted
to a subset of the ones recognized by drive_init().  We did that
because some parameters make sense only when configuring a frontend in
addition to a backend, and the command doesn't do that.

The parameter filtering is implemented as a whitelist.  The
forward-port neglected to update the whitelist for all the stuff that
has changed since RHEL-6.

Due to new features like driver-specific parameters, a whitelist is no
longer convenient.  Replace by a blacklist that contains exactly the
drive_init() parameters that are already filtered out on RHEL-6.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 device-hotplug.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/device-hotplug.c b/device-hotplug.c
index 20f6b7f..78a18f2 100644
--- a/device-hotplug.c
+++ b/device-hotplug.c
@@ -80,13 +80,8 @@ err:
 
 static void check_parm(const char *key, QObject *obj, void *opaque)
 {
-    static const char *valid_keys[] = {
-        "id", "cyls", "heads", "secs", "trans", "media", "snapshot",
-        "file", "cache", "aio", "format", "serial", "rerror", "werror",
-        "readonly", "copy-on-read",
-#ifdef CONFIG_BLOCK_IO_THROTTLING
-        "bps", "bps_rd", "bps_wr", "iops", "iops_rd", "iops_wr",
-#endif
+    static const char *unwanted_keys[] = {
+        "bus", "unit", "index", "if", "boot", "addr",
         NULL
 
     };
@@ -97,14 +92,14 @@ static void check_parm(const char *key, QObject *obj, void *opaque)
         return;
     }
 
-    for (p = valid_keys; *p; p++) {
+    for (p = unwanted_keys; *p; p++) {
         if (!strcmp(key, *p)) {
+            qerror_report(QERR_INVALID_PARAMETER, key);
+            *stopped = 1;
             return;
         }
     }
 
-    qerror_report(QERR_INVALID_PARAMETER, key);
-    *stopped = 1;
 }
 
 int simple_drive_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
-- 
1.8.1.4

  reply	other threads:[~2014-03-12 16:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12 16:58 [Qemu-devel] [PATCH 7.0 qemu-kvm 0/1] QMP: Relax __com.redhat_drive_add parameter checking Markus Armbruster
2014-03-12 16:58 ` Markus Armbruster [this message]
2014-03-12 17:03   ` [Qemu-devel] [PATCH 7.0 qemu-kvm 1/1] " Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1394643539-26913-2-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).