Revision d0fef6fb

b/qemu-config.c
2 2
#include "qemu-option.h"
3 3
#include "qemu-config.h"
4 4
#include "sysemu.h"
5
#include "hw/qdev.h"
5 6

  
6 7
QemuOptsList qemu_drive_opts = {
7 8
    .name = "drive",
......
205 206
    },
206 207
};
207 208

  
209
QemuOptsList qemu_global_opts = {
210
    .name = "global",
211
    .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head),
212
    .desc = {
213
        {
214
            .name = "driver",
215
            .type = QEMU_OPT_STRING,
216
        },{
217
            .name = "property",
218
            .type = QEMU_OPT_STRING,
219
        },{
220
            .name = "value",
221
            .type = QEMU_OPT_STRING,
222
        },
223
        { /* end if list */ }
224
    },
225
};
226

  
208 227
static QemuOptsList *lists[] = {
209 228
    &qemu_drive_opts,
210 229
    &qemu_chardev_opts,
......
212 231
    &qemu_netdev_opts,
213 232
    &qemu_net_opts,
214 233
    &qemu_rtc_opts,
234
    &qemu_global_opts,
215 235
    NULL,
216 236
};
217 237

  
......
260 280
    return 0;
261 281
}
262 282

  
283
int qemu_global_option(const char *str)
284
{
285
    char driver[64], property[64];
286
    QemuOpts *opts;
287
    int rc, offset;
288

  
289
    rc = sscanf(str, "%63[^.].%63[^=]%n", driver, property, &offset);
290
    if (rc < 2 || str[offset] != '=') {
291
        qemu_error("can't parse: \"%s\"\n", str);
292
        return -1;
293
    }
294

  
295
    opts = qemu_opts_create(&qemu_global_opts, NULL, 0);
296
    qemu_opt_set(opts, "driver", driver);
297
    qemu_opt_set(opts, "property", property);
298
    qemu_opt_set(opts, "value", str+offset+1);
299
    return 0;
300
}
301

  
302
static int qemu_add_one_global(QemuOpts *opts, void *opaque)
303
{
304
    GlobalProperty *g;
305

  
306
    g = qemu_mallocz(sizeof(*g));
307
    g->driver   = qemu_opt_get(opts, "driver");
308
    g->property = qemu_opt_get(opts, "property");
309
    g->value    = qemu_opt_get(opts, "value");
310
    qdev_prop_register_global(g);
311
    return 0;
312
}
313

  
314
void qemu_add_globals(void)
315
{
316
    qemu_opts_foreach(&qemu_global_opts, qemu_add_one_global, NULL, 0);
317
}
318

  
263 319
struct ConfigWriteData {
264 320
    QemuOptsList *list;
265 321
    FILE *fp;
b/qemu-config.h
9 9
extern QemuOptsList qemu_rtc_opts;
10 10

  
11 11
int qemu_set_option(const char *str);
12
int qemu_global_option(const char *str);
13
void qemu_add_globals(void);
12 14

  
13 15
void qemu_config_write(FILE *fp);
14 16
int qemu_config_parse(FILE *fp);
b/qemu-options.hx
109 109
    "-set group.id.arg=value\n"
110 110
    "                set <arg> parameter for item <id> of type <group>\n"
111 111
    "                i.e. -set drive.$id.file=/path/to/image\n")
112
DEF("global", HAS_ARG, QEMU_OPTION_global,
113
    "-global driver.property=value\n"
114
    "                set a global default for a driver property\n")
112 115
STEXI
113 116
@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
114 117

  
b/vl.c
4851 4851
                if (qemu_set_option(optarg) != 0)
4852 4852
                    exit(1);
4853 4853
	        break;
4854
            case QEMU_OPTION_global:
4855
                if (qemu_global_option(optarg) != 0)
4856
                    exit(1);
4857
	        break;
4854 4858
            case QEMU_OPTION_mtdblock:
4855 4859
                drive_add(optarg, MTD_ALIAS);
4856 4860
                break;
......
5781 5785
    if (machine->compat_props) {
5782 5786
        qdev_prop_register_global_list(machine->compat_props);
5783 5787
    }
5788
    qemu_add_globals();
5789

  
5784 5790
    machine->init(ram_size, boot_devices,
5785 5791
                  kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
5786 5792

  

Also available in: Unified diff