X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=qemu-config.c;h=b2ec40bd66f8ec82cc1cd76f307caae65cf5ab36;hb=e69ae5c49af45a67ebdf6a7cf465eb91b5c8ee11;hp=8254b35169fc85bad4c5a29f7cdd49521dda2acc;hpb=dcfb0939bd7042c9d2622181263c01d78531f272;p=qemu.git diff --git a/qemu-config.c b/qemu-config.c index 8254b3516..b2ec40bd6 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -2,10 +2,9 @@ #include "qemu-error.h" #include "qemu-option.h" #include "qemu-config.h" -#include "sysemu.h" #include "hw/qdev.h" -QemuOptsList qemu_drive_opts = { +static QemuOptsList qemu_drive_opts = { .name = "drive", .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), .desc = { @@ -24,6 +23,7 @@ QemuOptsList qemu_drive_opts = { },{ .name = "index", .type = QEMU_OPT_NUMBER, + .help = "index number", },{ .name = "cyls", .type = QEMU_OPT_NUMBER, @@ -47,6 +47,7 @@ QemuOptsList qemu_drive_opts = { },{ .name = "snapshot", .type = QEMU_OPT_BOOL, + .help = "enable/disable snapshot mode", },{ .name = "file", .type = QEMU_OPT_STRING, @@ -54,7 +55,7 @@ QemuOptsList qemu_drive_opts = { },{ .name = "cache", .type = QEMU_OPT_STRING, - .help = "host cache usage (none, writeback, writethrough)", + .help = "host cache usage (none, writeback, writethrough, unsafe)", },{ .name = "aio", .type = QEMU_OPT_STRING, @@ -66,12 +67,15 @@ QemuOptsList qemu_drive_opts = { },{ .name = "serial", .type = QEMU_OPT_STRING, + .help = "disk serial number", },{ .name = "rerror", .type = QEMU_OPT_STRING, + .help = "read error action", },{ .name = "werror", .type = QEMU_OPT_STRING, + .help = "write error action", },{ .name = "addr", .type = QEMU_OPT_STRING, @@ -79,12 +83,13 @@ QemuOptsList qemu_drive_opts = { },{ .name = "readonly", .type = QEMU_OPT_BOOL, + .help = "open drive file as read-only", }, - { /* end if list */ } + { /* end of list */ } }, }; -QemuOptsList qemu_chardev_opts = { +static QemuOptsList qemu_chardev_opts = { .name = "chardev", .implied_opt_name = "backend", .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), @@ -146,12 +151,60 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "signal", .type = QEMU_OPT_BOOL, + },{ + .name = "name", + .type = QEMU_OPT_STRING, + },{ + .name = "debug", + .type = QEMU_OPT_NUMBER, }, - { /* end if list */ } + { /* end of list */ } }, }; -QemuOptsList qemu_device_opts = { +QemuOptsList qemu_fsdev_opts = { + .name = "fsdev", + .implied_opt_name = "fstype", + .head = QTAILQ_HEAD_INITIALIZER(qemu_fsdev_opts.head), + .desc = { + { + .name = "fstype", + .type = QEMU_OPT_STRING, + }, { + .name = "path", + .type = QEMU_OPT_STRING, + }, { + .name = "security_model", + .type = QEMU_OPT_STRING, + }, + { /*End of list */ } + }, +}; + +QemuOptsList qemu_virtfs_opts = { + .name = "virtfs", + .implied_opt_name = "fstype", + .head = QTAILQ_HEAD_INITIALIZER(qemu_virtfs_opts.head), + .desc = { + { + .name = "fstype", + .type = QEMU_OPT_STRING, + }, { + .name = "path", + .type = QEMU_OPT_STRING, + }, { + .name = "mount_tag", + .type = QEMU_OPT_STRING, + }, { + .name = "security_model", + .type = QEMU_OPT_STRING, + }, + + { /*End of list */ } + }, +}; + +static QemuOptsList qemu_device_opts = { .name = "device", .implied_opt_name = "driver", .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head), @@ -161,11 +214,11 @@ QemuOptsList qemu_device_opts = { * sanity checking will happen later * when setting device properties */ - { /* end if list */ } + { /* end of list */ } }, }; -QemuOptsList qemu_netdev_opts = { +static QemuOptsList qemu_netdev_opts = { .name = "netdev", .implied_opt_name = "type", .head = QTAILQ_HEAD_INITIALIZER(qemu_netdev_opts.head), @@ -178,7 +231,7 @@ QemuOptsList qemu_netdev_opts = { }, }; -QemuOptsList qemu_net_opts = { +static QemuOptsList qemu_net_opts = { .name = "net", .implied_opt_name = "type", .head = QTAILQ_HEAD_INITIALIZER(qemu_net_opts.head), @@ -191,7 +244,7 @@ QemuOptsList qemu_net_opts = { }, }; -QemuOptsList qemu_rtc_opts = { +static QemuOptsList qemu_rtc_opts = { .name = "rtc", .head = QTAILQ_HEAD_INITIALIZER(qemu_rtc_opts.head), .desc = { @@ -201,17 +254,15 @@ QemuOptsList qemu_rtc_opts = { },{ .name = "clock", .type = QEMU_OPT_STRING, -#ifdef TARGET_I386 },{ .name = "driftfix", .type = QEMU_OPT_STRING, -#endif }, - { /* end if list */ } + { /* end of list */ } }, }; -QemuOptsList qemu_global_opts = { +static QemuOptsList qemu_global_opts = { .name = "global", .head = QTAILQ_HEAD_INITIALIZER(qemu_global_opts.head), .desc = { @@ -225,11 +276,11 @@ QemuOptsList qemu_global_opts = { .name = "value", .type = QEMU_OPT_STRING, }, - { /* end if list */ } + { /* end of list */ } }, }; -QemuOptsList qemu_mon_opts = { +static QemuOptsList qemu_mon_opts = { .name = "mon", .implied_opt_name = "chardev", .head = QTAILQ_HEAD_INITIALIZER(qemu_mon_opts.head), @@ -243,12 +294,30 @@ QemuOptsList qemu_mon_opts = { },{ .name = "default", .type = QEMU_OPT_BOOL, + },{ + .name = "pretty", + .type = QEMU_OPT_BOOL, + }, + { /* end of list */ } + }, +}; + +#ifdef CONFIG_SIMPLE_TRACE +static QemuOptsList qemu_trace_opts = { + .name = "trace", + .implied_opt_name = "trace", + .head = QTAILQ_HEAD_INITIALIZER(qemu_trace_opts.head), + .desc = { + { + .name = "file", + .type = QEMU_OPT_STRING, }, - { /* end if list */ } + { /* end of list */ } }, }; +#endif -QemuOptsList qemu_cpudef_opts = { +static QemuOptsList qemu_cpudef_opts = { .name = "cpudef", .head = QTAILQ_HEAD_INITIALIZER(qemu_cpudef_opts.head), .desc = { @@ -296,7 +365,122 @@ QemuOptsList qemu_cpudef_opts = { }, }; -static QemuOptsList *lists[] = { +QemuOptsList qemu_spice_opts = { + .name = "spice", + .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head), + .desc = { + { + .name = "port", + .type = QEMU_OPT_NUMBER, + },{ + .name = "tls-port", + .type = QEMU_OPT_NUMBER, + },{ + .name = "addr", + .type = QEMU_OPT_STRING, + },{ + .name = "ipv4", + .type = QEMU_OPT_BOOL, + },{ + .name = "ipv6", + .type = QEMU_OPT_BOOL, + },{ + .name = "password", + .type = QEMU_OPT_STRING, + },{ + .name = "disable-ticketing", + .type = QEMU_OPT_BOOL, + },{ + .name = "disable-copy-paste", + .type = QEMU_OPT_BOOL, + },{ + .name = "sasl", + .type = QEMU_OPT_BOOL, + },{ + .name = "x509-dir", + .type = QEMU_OPT_STRING, + },{ + .name = "x509-key-file", + .type = QEMU_OPT_STRING, + },{ + .name = "x509-key-password", + .type = QEMU_OPT_STRING, + },{ + .name = "x509-cert-file", + .type = QEMU_OPT_STRING, + },{ + .name = "x509-cacert-file", + .type = QEMU_OPT_STRING, + },{ + .name = "x509-dh-key-file", + .type = QEMU_OPT_STRING, + },{ + .name = "tls-ciphers", + .type = QEMU_OPT_STRING, + },{ + .name = "tls-channel", + .type = QEMU_OPT_STRING, + },{ + .name = "plaintext-channel", + .type = QEMU_OPT_STRING, + },{ + .name = "image-compression", + .type = QEMU_OPT_STRING, + },{ + .name = "jpeg-wan-compression", + .type = QEMU_OPT_STRING, + },{ + .name = "zlib-glz-wan-compression", + .type = QEMU_OPT_STRING, + },{ + .name = "streaming-video", + .type = QEMU_OPT_STRING, + },{ + .name = "agent-mouse", + .type = QEMU_OPT_BOOL, + },{ + .name = "playback-compression", + .type = QEMU_OPT_BOOL, + }, + { /* end of list */ } + }, +}; + +QemuOptsList qemu_option_rom_opts = { + .name = "option-rom", + .implied_opt_name = "romfile", + .head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head), + .desc = { + { + .name = "bootindex", + .type = QEMU_OPT_NUMBER, + }, { + .name = "romfile", + .type = QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + +static QemuOptsList qemu_machine_opts = { + .name = "machine", + .implied_opt_name = "type", + .head = QTAILQ_HEAD_INITIALIZER(qemu_machine_opts.head), + .desc = { + { + .name = "type", + .type = QEMU_OPT_STRING, + .help = "emulated machine" + }, { + .name = "accel", + .type = QEMU_OPT_STRING, + .help = "accelerator list", + }, + { /* End of list */ } + }, +}; + +static QemuOptsList *vm_config_groups[32] = { &qemu_drive_opts, &qemu_chardev_opts, &qemu_device_opts, @@ -306,10 +490,15 @@ static QemuOptsList *lists[] = { &qemu_global_opts, &qemu_mon_opts, &qemu_cpudef_opts, +#ifdef CONFIG_SIMPLE_TRACE + &qemu_trace_opts, +#endif + &qemu_option_rom_opts, + &qemu_machine_opts, NULL, }; -QemuOptsList *qemu_find_opts(const char *group) +static QemuOptsList *find_list(QemuOptsList **lists, const char *group) { int i; @@ -323,6 +512,27 @@ QemuOptsList *qemu_find_opts(const char *group) return lists[i]; } +QemuOptsList *qemu_find_opts(const char *group) +{ + return find_list(vm_config_groups, group); +} + +void qemu_add_opts(QemuOptsList *list) +{ + int entries, i; + + entries = ARRAY_SIZE(vm_config_groups); + entries--; /* keep list NULL terminated */ + for (i = 0; i < entries; i++) { + if (vm_config_groups[i] == NULL) { + vm_config_groups[i] = list; + return; + } + } + fprintf(stderr, "ran out of space in vm_config_groups"); + abort(); +} + int qemu_set_option(const char *str) { char group[64], id[64], arg[64]; @@ -373,23 +583,6 @@ int qemu_global_option(const char *str) return 0; } -static int qemu_add_one_global(QemuOpts *opts, void *opaque) -{ - GlobalProperty *g; - - g = qemu_mallocz(sizeof(*g)); - g->driver = qemu_opt_get(opts, "driver"); - g->property = qemu_opt_get(opts, "property"); - g->value = qemu_opt_get(opts, "value"); - qdev_prop_register_global(g); - return 0; -} - -void qemu_add_globals(void) -{ - qemu_opts_foreach(&qemu_global_opts, qemu_add_one_global, NULL, 0); -} - struct ConfigWriteData { QemuOptsList *list; FILE *fp; @@ -421,6 +614,7 @@ static int config_write_opts(QemuOpts *opts, void *opaque) void qemu_config_write(FILE *fp) { struct ConfigWriteData data = { .fp = fp }; + QemuOptsList **lists = vm_config_groups; int i; fprintf(fp, "# qemu config file\n\n"); @@ -430,7 +624,7 @@ void qemu_config_write(FILE *fp) } } -int qemu_config_parse(FILE *fp, const char *fname) +int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) { char line[1024], group[64], id[64], arg[64], value[1024]; Location loc; @@ -451,7 +645,7 @@ int qemu_config_parse(FILE *fp, const char *fname) } if (sscanf(line, "[%63s \"%63[^\"]\"]", group, id) == 2) { /* group with id */ - list = qemu_find_opts(group); + list = find_list(lists, group); if (list == NULL) goto out; opts = qemu_opts_create(list, id, 1); @@ -459,7 +653,7 @@ int qemu_config_parse(FILE *fp, const char *fname) } if (sscanf(line, "[%63[^]]]", group) == 1) { /* group without id */ - list = qemu_find_opts(group); + list = find_list(lists, group); if (list == NULL) goto out; opts = qemu_opts_create(list, NULL, 0); @@ -492,14 +686,18 @@ out: int qemu_read_config_file(const char *filename) { FILE *f = fopen(filename, "r"); + int ret; + if (f == NULL) { return -errno; } - if (qemu_config_parse(f, filename) != 0) { - return -EINVAL; - } + ret = qemu_config_parse(f, vm_config_groups, filename); fclose(f); - return 0; + if (ret == 0) { + return 0; + } else { + return -EINVAL; + } }