Revision d0fef6fb qemu-config.c

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;

Also available in: Unified diff