Revision 968854c8

b/blockdev.c
47 47
#include "sysemu/arch_init.h"
48 48

  
49 49
static QTAILQ_HEAD(drivelist, DriveInfo) drives = QTAILQ_HEAD_INITIALIZER(drives);
50
extern QemuOptsList qemu_common_drive_opts;
51 50

  
52 51
static const char *const if_name[IF_COUNT] = {
53 52
    [IF_NONE] = "none",
b/include/qemu/config-file.h
8 8
QemuOptsList *qemu_find_opts(const char *group);
9 9
QemuOptsList *qemu_find_opts_err(const char *group, Error **errp);
10 10
void qemu_add_opts(QemuOptsList *list);
11
void qemu_add_drive_opts(QemuOptsList *list);
11 12
int qemu_set_option(const char *str);
12 13
int qemu_global_option(const char *str);
13 14
void qemu_add_globals(void);
b/include/sysemu/sysemu.h
193 193

  
194 194
bool usb_enabled(bool default_usb);
195 195

  
196
extern QemuOptsList qemu_legacy_drive_opts;
197
extern QemuOptsList qemu_common_drive_opts;
196 198
extern QemuOptsList qemu_drive_opts;
197 199
extern QemuOptsList qemu_chardev_opts;
198 200
extern QemuOptsList qemu_device_opts;
b/util/qemu-config.c
8 8
#include "qmp-commands.h"
9 9

  
10 10
static QemuOptsList *vm_config_groups[32];
11
static QemuOptsList *drive_config_groups[4];
11 12

  
12 13
static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
13 14
                               Error **errp)
......
77 78
    return param_list;
78 79
}
79 80

  
81
/* remove repeated entry from the info list */
82
static void cleanup_infolist(CommandLineParameterInfoList *head)
83
{
84
    CommandLineParameterInfoList *pre_entry, *cur, *del_entry;
85

  
86
    cur = head;
87
    while (cur->next) {
88
        pre_entry = head;
89
        while (pre_entry != cur->next) {
90
            if (!strcmp(pre_entry->value->name, cur->next->value->name)) {
91
                del_entry = cur->next;
92
                cur->next = cur->next->next;
93
                g_free(del_entry);
94
                break;
95
            }
96
            pre_entry = pre_entry->next;
97
        }
98
        cur = cur->next;
99
    }
100
}
101

  
102
/* merge the description items of two parameter infolists */
103
static void connect_infolist(CommandLineParameterInfoList *head,
104
                             CommandLineParameterInfoList *new)
105
{
106
    CommandLineParameterInfoList *cur;
107

  
108
    cur = head;
109
    while (cur->next) {
110
        cur = cur->next;
111
    }
112
    cur->next = new;
113
}
114

  
115
/* access all the local QemuOptsLists for drive option */
116
static CommandLineParameterInfoList *get_drive_infolist(void)
117
{
118
    CommandLineParameterInfoList *head = NULL, *cur;
119
    int i;
120

  
121
    for (i = 0; drive_config_groups[i] != NULL; i++) {
122
        if (!head) {
123
            head = query_option_descs(drive_config_groups[i]->desc);
124
        } else {
125
            cur = query_option_descs(drive_config_groups[i]->desc);
126
            connect_infolist(head, cur);
127
        }
128
    }
129
    cleanup_infolist(head);
130

  
131
    return head;
132
}
133

  
80 134
CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
81 135
                                                          const char *option,
82 136
                                                          Error **errp)
......
89 143
        if (!has_option || !strcmp(option, vm_config_groups[i]->name)) {
90 144
            info = g_malloc0(sizeof(*info));
91 145
            info->option = g_strdup(vm_config_groups[i]->name);
92
            info->parameters = query_option_descs(vm_config_groups[i]->desc);
146
            if (!strcmp("drive", vm_config_groups[i]->name)) {
147
                info->parameters = get_drive_infolist();
148
            } else {
149
                info->parameters =
150
                    query_option_descs(vm_config_groups[i]->desc);
151
            }
93 152
            entry = g_malloc0(sizeof(*entry));
94 153
            entry->value = info;
95 154
            entry->next = conf_list;
......
109 168
    return find_list(vm_config_groups, group, errp);
110 169
}
111 170

  
171
void qemu_add_drive_opts(QemuOptsList *list)
172
{
173
    int entries, i;
174

  
175
    entries = ARRAY_SIZE(drive_config_groups);
176
    entries--; /* keep list NULL terminated */
177
    for (i = 0; i < entries; i++) {
178
        if (drive_config_groups[i] == NULL) {
179
            drive_config_groups[i] = list;
180
            return;
181
        }
182
    }
183
    fprintf(stderr, "ran out of space in drive_config_groups");
184
    abort();
185
}
186

  
112 187
void qemu_add_opts(QemuOptsList *list)
113 188
{
114 189
    int entries, i;
b/vl.c
2867 2867
    module_call_init(MODULE_INIT_QOM);
2868 2868

  
2869 2869
    qemu_add_opts(&qemu_drive_opts);
2870
    qemu_add_drive_opts(&qemu_legacy_drive_opts);
2871
    qemu_add_drive_opts(&qemu_common_drive_opts);
2872
    qemu_add_drive_opts(&qemu_drive_opts);
2870 2873
    qemu_add_opts(&qemu_chardev_opts);
2871 2874
    qemu_add_opts(&qemu_device_opts);
2872 2875
    qemu_add_opts(&qemu_netdev_opts);

Also available in: Unified diff