All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: krkumar2@in.ibm.com, habanero@linux.vnet.ibm.com,
	aliguori@us.ibm.com, rusty@rustcorp.com.au, mst@redhat.com,
	mashirle@us.ibm.com, qemu-devel@nongnu.org,
	virtualization@lists.linux-foundation.org,
	tahm@linux.vnet.ibm.com, jwhan@filewood.snu.ac.kr,
	akong@redhat.com
Cc: kvm@vger.kernel.org
Subject: [RFC V3 1/5] option: introduce qemu_get_opt_all()
Date: Fri,  6 Jul 2012 17:31:06 +0800	[thread overview]
Message-ID: <1341567070-14136-2-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1341567070-14136-1-git-send-email-jasowang@redhat.com>

Sometimes, we need to pass option like -netdev tap,fd=100,fd=101,fd=102 which
can not be properly parsed by qemu_find_opt() because it only returns the first
matched option. So qemu_get_opt_all() were introduced to return an array of
pointers which contains all matched option.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 qemu-option.c |   19 +++++++++++++++++++
 qemu-option.h |    2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/qemu-option.c b/qemu-option.c
index bb3886c..9263125 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -545,6 +545,25 @@ static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
     return NULL;
 }
 
+int qemu_opt_get_all(QemuOpts *opts, const char *name, const char **optp,
+                     int max)
+{
+    QemuOpt *opt;
+    int index = 0;
+
+    QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {
+        if (strcmp(opt->name, name) == 0) {
+            if (index < max) {
+                optp[index++] = opt->str;
+            }
+            if (index == max) {
+                break;
+            }
+        }
+    }
+    return index;
+}
+
 const char *qemu_opt_get(QemuOpts *opts, const char *name)
 {
     QemuOpt *opt = qemu_opt_find(opts, name);
diff --git a/qemu-option.h b/qemu-option.h
index 951dec3..3c9a273 100644
--- a/qemu-option.h
+++ b/qemu-option.h
@@ -106,6 +106,8 @@ struct QemuOptsList {
     QemuOptDesc desc[];
 };
 
+int qemu_opt_get_all(QemuOpts *opts, const char *name, const char **optp,
+                     int max);
 const char *qemu_opt_get(QemuOpts *opts, const char *name);
 bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval);
 uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval);
-- 
1.7.1

WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: krkumar2@in.ibm.com, habanero@linux.vnet.ibm.com,
	aliguori@us.ibm.com, rusty@rustcorp.com.au, mst@redhat.com,
	mashirle@us.ibm.com, qemu-devel@nongnu.org,
	virtualization@lists.linux-foundation.org,
	tahm@linux.vnet.ibm.com, jwhan@filewood.snu.ac.kr,
	akong@redhat.com
Cc: Jason Wang <jasowang@redhat.com>, kvm@vger.kernel.org
Subject: [Qemu-devel] [RFC V3 1/5] option: introduce qemu_get_opt_all()
Date: Fri,  6 Jul 2012 17:31:06 +0800	[thread overview]
Message-ID: <1341567070-14136-2-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1341567070-14136-1-git-send-email-jasowang@redhat.com>

Sometimes, we need to pass option like -netdev tap,fd=100,fd=101,fd=102 which
can not be properly parsed by qemu_find_opt() because it only returns the first
matched option. So qemu_get_opt_all() were introduced to return an array of
pointers which contains all matched option.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 qemu-option.c |   19 +++++++++++++++++++
 qemu-option.h |    2 ++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/qemu-option.c b/qemu-option.c
index bb3886c..9263125 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -545,6 +545,25 @@ static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name)
     return NULL;
 }
 
+int qemu_opt_get_all(QemuOpts *opts, const char *name, const char **optp,
+                     int max)
+{
+    QemuOpt *opt;
+    int index = 0;
+
+    QTAILQ_FOREACH_REVERSE(opt, &opts->head, QemuOptHead, next) {
+        if (strcmp(opt->name, name) == 0) {
+            if (index < max) {
+                optp[index++] = opt->str;
+            }
+            if (index == max) {
+                break;
+            }
+        }
+    }
+    return index;
+}
+
 const char *qemu_opt_get(QemuOpts *opts, const char *name)
 {
     QemuOpt *opt = qemu_opt_find(opts, name);
diff --git a/qemu-option.h b/qemu-option.h
index 951dec3..3c9a273 100644
--- a/qemu-option.h
+++ b/qemu-option.h
@@ -106,6 +106,8 @@ struct QemuOptsList {
     QemuOptDesc desc[];
 };
 
+int qemu_opt_get_all(QemuOpts *opts, const char *name, const char **optp,
+                     int max);
 const char *qemu_opt_get(QemuOpts *opts, const char *name);
 bool qemu_opt_get_bool(QemuOpts *opts, const char *name, bool defval);
 uint64_t qemu_opt_get_number(QemuOpts *opts, const char *name, uint64_t defval);
-- 
1.7.1

  reply	other threads:[~2012-07-06  9:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06  9:31 [RFC V3 0/5] Multiqueue support for tap and virtio-net/vhost Jason Wang
2012-07-06  9:31 ` [Qemu-devel] " Jason Wang
2012-07-06  9:31 ` Jason Wang [this message]
2012-07-06  9:31   ` [Qemu-devel] [RFC V3 1/5] option: introduce qemu_get_opt_all() Jason Wang
2012-07-06  9:31 ` [RFC V3 2/5] tap: multiqueue support Jason Wang
2012-07-06  9:31   ` [Qemu-devel] " Jason Wang
2012-07-06  9:31 ` [RFC V3 3/5] net: " Jason Wang
2012-07-06  9:31 ` Jason Wang
2012-07-06  9:31   ` [Qemu-devel] " Jason Wang
2012-07-06  9:31 ` [RFC V3 4/5] vhost: " Jason Wang
2012-07-06  9:31 ` Jason Wang
2012-07-06  9:31   ` [Qemu-devel] " Jason Wang
2012-07-06  9:31 ` [RFC V3 5/5] virtio-net: add " Jason Wang
2012-07-06  9:31   ` [Qemu-devel] " Jason Wang
2012-07-06  9:31 ` Jason Wang

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=1341567070-14136-2-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=akong@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=habanero@linux.vnet.ibm.com \
    --cc=jwhan@filewood.snu.ac.kr \
    --cc=krkumar2@in.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mashirle@us.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tahm@linux.vnet.ibm.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.