|
|
9ae3a8 |
From 6d981002b5ccbcb4905e5fa45b4606cf4ddc9c9e Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 25 Feb 2014 07:56:50 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 1/6] qmp: access the local QemuOptsLists for drive option
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1393315010-20614-1-git-send-email-akong@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 57771
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v3] qmp: access the local QemuOptsLists for drive option
|
|
|
9ae3a8 |
Bugzilla: 1026184
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: 1026184
|
|
|
9ae3a8 |
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7104270
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Currently we have three QemuOptsList (qemu_common_drive_opts,
|
|
|
9ae3a8 |
qemu_legacy_drive_opts, and qemu_drive_opts), only qemu_drive_opts
|
|
|
9ae3a8 |
is added to vm_config_groups[].
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This patch changes query-command-line-options to access three local
|
|
|
9ae3a8 |
QemuOptsLists for drive option, and merge the description items
|
|
|
9ae3a8 |
together.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 968854c8a106243eae7a68394ce1cb85dc138837)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
v2: re-backport when patch is merged to mainline
|
|
|
9ae3a8 |
v3: rebase to latest qemu-kvm-rhel7
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
redo/fix query-command-line-options isn't finished, let's fix the
|
|
|
9ae3a8 |
blkdev issue in rhel7.0 by this backport.
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 1 -
|
|
|
9ae3a8 |
include/qemu/config-file.h | 1 +
|
|
|
9ae3a8 |
include/sysemu/sysemu.h | 2 +
|
|
|
9ae3a8 |
util/qemu-config.c | 77 +++++++++++++++++++++++++++++++++++++++++++-
|
|
|
9ae3a8 |
vl.c | 3 ++
|
|
|
9ae3a8 |
5 files changed, 82 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 1 -
|
|
|
9ae3a8 |
include/qemu/config-file.h | 1 +
|
|
|
9ae3a8 |
include/sysemu/sysemu.h | 2 +
|
|
|
9ae3a8 |
util/qemu-config.c | 77 +++++++++++++++++++++++++++++++++++++++++++-
|
|
|
9ae3a8 |
vl.c | 3 ++
|
|
|
9ae3a8 |
5 files changed, 82 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 80c6bb4..e51203c 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -47,7 +47,6 @@
|
|
|
9ae3a8 |
#include "sysemu/arch_init.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
|
|
|
9ae3a8 |
-extern QemuOptsList qemu_common_drive_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static const char *const if_name[IF_COUNT] = {
|
|
|
9ae3a8 |
[IF_NONE] = "none",
|
|
|
9ae3a8 |
diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h
|
|
|
9ae3a8 |
index ccfccae..3f92282 100644
|
|
|
9ae3a8 |
--- a/include/qemu/config-file.h
|
|
|
9ae3a8 |
+++ b/include/qemu/config-file.h
|
|
|
9ae3a8 |
@@ -9,6 +9,7 @@
|
|
|
9ae3a8 |
QemuOptsList *qemu_find_opts(const char *group);
|
|
|
9ae3a8 |
QemuOptsList *qemu_find_opts_err(const char *group, Error **errp);
|
|
|
9ae3a8 |
void qemu_add_opts(QemuOptsList *list);
|
|
|
9ae3a8 |
+void qemu_add_drive_opts(QemuOptsList *list);
|
|
|
9ae3a8 |
int qemu_set_option(const char *str);
|
|
|
9ae3a8 |
int qemu_global_option(const char *str);
|
|
|
9ae3a8 |
void qemu_add_globals(void);
|
|
|
9ae3a8 |
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
|
|
|
9ae3a8 |
index c70d2dd..8dc0a4c 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/sysemu.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/sysemu.h
|
|
|
9ae3a8 |
@@ -191,6 +191,8 @@ QemuOpts *qemu_get_machine_opts(void);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bool usb_enabled(bool default_usb);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+extern QemuOptsList qemu_legacy_drive_opts;
|
|
|
9ae3a8 |
+extern QemuOptsList qemu_common_drive_opts;
|
|
|
9ae3a8 |
extern QemuOptsList qemu_drive_opts;
|
|
|
9ae3a8 |
extern QemuOptsList qemu_simple_drive_opts;
|
|
|
9ae3a8 |
extern QemuOptsList qemu_chardev_opts;
|
|
|
9ae3a8 |
diff --git a/util/qemu-config.c b/util/qemu-config.c
|
|
|
9ae3a8 |
index a59568d..04da942 100644
|
|
|
9ae3a8 |
--- a/util/qemu-config.c
|
|
|
9ae3a8 |
+++ b/util/qemu-config.c
|
|
|
9ae3a8 |
@@ -8,6 +8,7 @@
|
|
|
9ae3a8 |
#include "qmp-commands.h"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static QemuOptsList *vm_config_groups[32];
|
|
|
9ae3a8 |
+static QemuOptsList *drive_config_groups[4];
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
|
|
|
9ae3a8 |
Error **errp)
|
|
|
9ae3a8 |
@@ -77,6 +78,59 @@ static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
|
|
|
9ae3a8 |
return param_list;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+/* remove repeated entry from the info list */
|
|
|
9ae3a8 |
+static void cleanup_infolist(CommandLineParameterInfoList *head)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ CommandLineParameterInfoList *pre_entry, *cur, *del_entry;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ cur = head;
|
|
|
9ae3a8 |
+ while (cur->next) {
|
|
|
9ae3a8 |
+ pre_entry = head;
|
|
|
9ae3a8 |
+ while (pre_entry != cur->next) {
|
|
|
9ae3a8 |
+ if (!strcmp(pre_entry->value->name, cur->next->value->name)) {
|
|
|
9ae3a8 |
+ del_entry = cur->next;
|
|
|
9ae3a8 |
+ cur->next = cur->next->next;
|
|
|
9ae3a8 |
+ g_free(del_entry);
|
|
|
9ae3a8 |
+ break;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ pre_entry = pre_entry->next;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ cur = cur->next;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+/* merge the description items of two parameter infolists */
|
|
|
9ae3a8 |
+static void connect_infolist(CommandLineParameterInfoList *head,
|
|
|
9ae3a8 |
+ CommandLineParameterInfoList *new)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ CommandLineParameterInfoList *cur;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ cur = head;
|
|
|
9ae3a8 |
+ while (cur->next) {
|
|
|
9ae3a8 |
+ cur = cur->next;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ cur->next = new;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+/* access all the local QemuOptsLists for drive option */
|
|
|
9ae3a8 |
+static CommandLineParameterInfoList *get_drive_infolist(void)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ CommandLineParameterInfoList *head = NULL, *cur;
|
|
|
9ae3a8 |
+ int i;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ for (i = 0; drive_config_groups[i] != NULL; i++) {
|
|
|
9ae3a8 |
+ if (!head) {
|
|
|
9ae3a8 |
+ head = query_option_descs(drive_config_groups[i]->desc);
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ cur = query_option_descs(drive_config_groups[i]->desc);
|
|
|
9ae3a8 |
+ connect_infolist(head, cur);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ cleanup_infolist(head);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return head;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
|
|
|
9ae3a8 |
const char *option,
|
|
|
9ae3a8 |
Error **errp)
|
|
|
9ae3a8 |
@@ -89,7 +143,12 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
|
|
|
9ae3a8 |
if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
|
|
|
9ae3a8 |
info = g_malloc0(sizeof(*info));
|
|
|
9ae3a8 |
info->option = g_strdup(vm_config_groups[i]->name);
|
|
|
9ae3a8 |
- info->parameters = query_option_descs(vm_config_groups[i]->desc);
|
|
|
9ae3a8 |
+ if (!strcmp("drive", vm_config_groups[i]->name)) {
|
|
|
9ae3a8 |
+ info->parameters = get_drive_infolist();
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ info->parameters =
|
|
|
9ae3a8 |
+ query_option_descs(vm_config_groups[i]->desc);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
entry = g_malloc0(sizeof(*entry));
|
|
|
9ae3a8 |
entry->value = info;
|
|
|
9ae3a8 |
entry->next = conf_list;
|
|
|
9ae3a8 |
@@ -109,6 +168,22 @@ QemuOptsList *qemu_find_opts_err(const char *group, Error **errp)
|
|
|
9ae3a8 |
return find_list(vm_config_groups, group, errp);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void qemu_add_drive_opts(QemuOptsList *list)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ int entries, i;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ entries = ARRAY_SIZE(drive_config_groups);
|
|
|
9ae3a8 |
+ entries--; /* keep list NULL terminated */
|
|
|
9ae3a8 |
+ for (i = 0; i < entries; i++) {
|
|
|
9ae3a8 |
+ if (drive_config_groups[i] == NULL) {
|
|
|
9ae3a8 |
+ drive_config_groups[i] = list;
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ fprintf(stderr, "ran out of space in drive_config_groups");
|
|
|
9ae3a8 |
+ abort();
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
void qemu_add_opts(QemuOptsList *list)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int entries, i;
|
|
|
9ae3a8 |
diff --git a/vl.c b/vl.c
|
|
|
9ae3a8 |
index deb5884..51300e7 100644
|
|
|
9ae3a8 |
--- a/vl.c
|
|
|
9ae3a8 |
+++ b/vl.c
|
|
|
9ae3a8 |
@@ -2851,6 +2851,9 @@ int main(int argc, char **argv, char **envp)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_drive_opts);
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_simple_drive_opts);
|
|
|
9ae3a8 |
+ qemu_add_drive_opts(&qemu_legacy_drive_opts);
|
|
|
9ae3a8 |
+ qemu_add_drive_opts(&qemu_common_drive_opts);
|
|
|
9ae3a8 |
+ qemu_add_drive_opts(&qemu_drive_opts);
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_chardev_opts);
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_device_opts);
|
|
|
9ae3a8 |
qemu_add_opts(&qemu_netdev_opts);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|