>From c95a05bde835481e861853c4365c768be26335e1 Mon Sep 17 00:00:00 2001 From: Amos Kong 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 --- 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