From: Amos Kong <akong@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: libvir-list@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [libvirt] [PATCH RFC] blockdev: copy legacy and common opts to qemu_drive_opts
Date: Wed, 6 Nov 2013 00:34:17 +0800 [thread overview]
Message-ID: <20131105163417.GA26314@amosk.info> (raw)
In-Reply-To: <20131104112710.GF4199@dhcp-200-207.str.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3148 bytes --]
Hi Kevin,
On Mon, Nov 04, 2013 at 12:27:10PM +0100, Kevin Wolf wrote:
> Am 04.11.2013 um 08:01 hat Amos Kong geschrieben:
> > Currently we have three QemuOptsList (qemu_common_drive_opts,
> > qemu_legacy_drive_opts, and qemu_drive_opts), only qemu_drive_opts
> > is added to vm_config_groups[].
> >
> > We query commandline options by checking information in
> > vm_config_groups[], so we can only get a NULL parameter list now.
> >
> > This patch copied desc items of qemu_legacy_drive_opts and
> > qemu_common_drive_opts to qemu_drive_opts.
> >
> > Signed-off-by: Amos Kong <akong@redhat.com>
>
> This breaks driver-specific options because they aren't (and cannot be)
> listed in the QemuOptsList.
>
> For example:
>
> $ x86_64-softmmu/qemu-system-x86_64 -drive file.driver=nbd,file.host=localhost
> qemu-system-x86_64: -drive file.driver=nbd,file.host=localhost: Invalid parameter 'file.driver'
>
> query-command-line-options isn't an appropriate API to query the -drive
> capabilities in the blockdev-add world. You really want to have
> introspection for that.
>
> For compatibility, we might want to at least expose part of the provided
> options there. In this case you should modify the monitor command to
> access the local QemuOptsLists of drive_init() and blockdev_init() for
> option="drive".
It's to access the local QemuOptsLists of drive_init() and
blockdev_init() for option="drive".
I saw there are two repeat items ("copy-on-read", "read-only")
I will merge the two desc lists together, remove the repeat items,
and output once.
Attached my draft patch, I can use it to compile qemu binary, but
touched following error, any note?
------------------------
[amos@amosk qemu]$ make
CC util/qemu-config.o
AR libqemuutil.a
LINK qemu-ga
LINK qemu-nbd
LINK qemu-img
LINK qemu-io
libqemuutil.a(qemu-config.o): In function `qmp_query_command_line_options':
/home/devel/qemu/util/qemu-config.c:141: undefined reference to `qemu_legacy_drive_opts'
/home/devel/qemu/util/qemu-config.c:142: undefined reference to `qemu_common_drive_opts'
/home/devel/qemu/util/qemu-config.c:144: undefined reference to `qemu_drive_opts'
collect2: error: ld returned 1 exit status
make: *** [qemu-nbd] Error 1
make: *** Waiting for unfinished jobs....
libqemuutil.a(qemu-config.o): In function `qmp_query_command_line_options':
/home/devel/qemu/util/qemu-config.c:141: undefined reference to `qemu_legacy_drive_opts'
/home/devel/qemu/util/qemu-config.c:142: undefined reference to `qemu_common_drive_opts'
/home/devel/qemu/util/qemu-config.c:144: undefined reference to `qemu_drive_opts'
collect2: error: ld returned 1 exit status
make: *** [qemu-img] Error 1
libqemuutil.a(qemu-config.o): In function `qmp_query_command_line_options':
/home/devel/qemu/util/qemu-config.c:141: undefined reference to `qemu_legacy_drive_opts'
/home/devel/qemu/util/qemu-config.c:142: undefined reference to `qemu_common_drive_opts'
/home/devel/qemu/util/qemu-config.c:144: undefined reference to `qemu_drive_opts'
collect2: error: ld returned 1 exit status
make: *** [qemu-io] Error 1
LINK x86_64-softmmu/qemu-system-x86_64
--
Amos.
[-- Attachment #2: 0001-qmp-access-the-local-QemuOptsLists-for-drive-option.patch --]
[-- Type: text/plain, Size: 4565 bytes --]
>From c95a05bde835481e861853c4365c768be26335e1 Mon Sep 17 00:00:00 2001
From: Amos Kong <akong@redhat.com>
Date: Tue, 5 Nov 2013 17:59:13 +0800
Subject: [PATCH] qmp: access the local QemuOptsLists for drive option
Currently we have three QemuOptsList (qemu_common_drive_opts,
qemu_legacy_drive_opts, and qemu_drive_opts), only qemu_drive_opts
is added to vm_config_groups[].
This patch changes query-command-line-options to access three list,
and merge the result together.
Signed-off-by: Amos Kong <akong@redhat.com>
---
blockdev.c | 1 -
include/sysemu/sysemu.h | 2 ++
util/qemu-config.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index b260477..f09f991 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -47,7 +47,6 @@
#include "sysemu/arch_init.h"
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
-extern QemuOptsList qemu_common_drive_opts;
static const char *const if_name[IF_COUNT] = {
[IF_NONE] = "none",
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index cd5791e..495dae8 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -193,6 +193,8 @@ QemuOpts *qemu_get_machine_opts(void);
bool usb_enabled(bool default_usb);
+extern QemuOptsList qemu_legacy_drive_opts;
+extern QemuOptsList qemu_common_drive_opts;
extern QemuOptsList qemu_drive_opts;
extern QemuOptsList qemu_chardev_opts;
extern QemuOptsList qemu_device_opts;
diff --git a/util/qemu-config.c b/util/qemu-config.c
index a59568d..573c5ad 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -6,6 +6,7 @@
#include "hw/qdev.h"
#include "qapi/error.h"
#include "qmp-commands.h"
+#include "sysemu/sysemu.h"
static QemuOptsList *vm_config_groups[32];
@@ -77,19 +78,77 @@ static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
return param_list;
}
+static void delete_infolist_entry(CommandLineParameterInfoList *head,
+ CommandLineParameterInfoList *del_entry)
+{
+ CommandLineParameterInfoList *cur;
+
+ cur = head;
+ while (cur->next) {
+ if (cur->next == del_entry) {
+ cur->next = del_entry->next;
+ g_free(del_entry);
+ }
+ cur = cur->next;
+ }
+}
+
+static void cleanup_infolist(CommandLineParameterInfoList *head)
+{
+ CommandLineParameterInfoList *pre_entry, *cur;
+
+ cur = head->next;
+ while (cur) {
+ pre_entry = head;
+ while (pre_entry != cur) {
+ if (!strcmp(pre_entry->value->name, cur->value->name)) {
+ delete_infolist_entry(head, cur);
+ break;
+ }
+ pre_entry = pre_entry->next;
+ }
+ cur = cur->next;
+ }
+}
+
+static void connect_infolist(CommandLineParameterInfoList *head,
+ CommandLineParameterInfoList *new)
+{
+ CommandLineParameterInfoList *cur;
+
+ cur = head;
+ while (cur->next) {
+ cur = cur->next;
+ }
+ cur->next = new;
+}
+
CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
const char *option,
Error **errp)
{
CommandLineOptionInfoList *conf_list = NULL, *entry;
CommandLineOptionInfo *info;
+ CommandLineParameterInfoList *new;
int i;
for (i = 0; vm_config_groups[i] != NULL; i++) {
if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
info = g_malloc0(sizeof(*info));
info->option = g_strdup(vm_config_groups[i]->name);
- info->parameters = query_option_descs(vm_config_groups[i]->desc);
+ if (!strcmp("drive", vm_config_groups[i]->name)) {
+ info->parameters =
+ query_option_descs(qemu_legacy_drive_opts.desc);
+ new = query_option_descs(qemu_common_drive_opts.desc);
+ connect_infolist(info->parameters, new);
+ new = query_option_descs(qemu_drive_opts.desc);
+ connect_infolist(info->parameters, new);
+
+ cleanup_infolist(info->parameters);
+ } else {
+ info->parameters =
+ query_option_descs(vm_config_groups[i]->desc);
+ }
entry = g_malloc0(sizeof(*entry));
entry->value = info;
entry->next = conf_list;
--
1.8.3.1
next prev parent reply other threads:[~2013-11-05 16:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-04 7:01 [Qemu-devel] [PATCH RFC] blockdev: copy legacy and common opts to qemu_drive_opts Amos Kong
2013-11-04 11:27 ` Kevin Wolf
2013-11-05 16:34 ` Amos Kong [this message]
2013-11-06 5:16 ` [Qemu-devel] [PATCH v2] qmp: access the local QemuOptsLists for drive option Amos Kong
2013-11-08 9:18 ` Fam Zheng
2013-11-09 3:19 ` Amos Kong
2013-11-09 4:05 ` Fam Zheng
2013-11-09 4:15 ` [Qemu-devel] [PATCH v3] " Amos Kong
2013-11-12 11:12 ` Kevin Wolf
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=20131105163417.GA26314@amosk.info \
--to=akong@redhat.com \
--cc=kwolf@redhat.com \
--cc=libvir-list@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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.