From 7f8b6126e7d4417a7faa8fdd18d5870d937aadf8 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 12:37:00 +0100 Subject: vl: move icount configuration earlier MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Once qemu_tcg_configure is turned into a QOM property setter, it will not be able to set a default value for mttcg_enabled. Setting the default will move to the TCG instance_init function, which currently runs before "-icount" is processed. However, it is harmless to do configure_icount for all accelerators; we will just fail later if a non-TCG accelerator is selected. So do that. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- vl.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 94508300c3..6e58c1d08d 100644 --- a/vl.c +++ b/vl.c @@ -2700,6 +2700,12 @@ static void user_register_global_props(void) global_init_func, NULL, NULL); } +static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) +{ + configure_icount(opts, errp); + return 0; +} + int main(int argc, char **argv, char **envp) { int i; @@ -4010,6 +4016,8 @@ int main(int argc, char **argv, char **envp) * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ + qemu_opts_foreach(qemu_find_opts("icount"), + do_configure_icount, NULL, &error_fatal); configure_accelerator(current_machine, argv[0]); /* @@ -4095,13 +4103,9 @@ int main(int argc, char **argv, char **envp) qemu_spice_init(); cpu_ticks_init(); - if (icount_opts) { - if (!tcg_enabled()) { - error_report("-icount is not allowed with hardware virtualization"); - exit(1); - } - configure_icount(icount_opts, &error_abort); - qemu_opts_del(icount_opts); + if (use_icount && !(tcg_enabled() || qtest_enabled())) { + error_report("-icount is not allowed with hardware virtualization"); + exit(1); } if (tcg_enabled()) { -- cgit v1.2.3 From deda73e89f271e15044334ad6c0dcdae5341b71d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 14 Nov 2019 11:10:43 +0100 Subject: vl: extract accelerator option processing to a separate function As a first step towards supporting multiple "-accel" options, push the late processing of -icount and -accel into a new function, and use qemu_opts_foreach to retrieve -accel options instead of stashing them into globals. Signed-off-by: Paolo Bonzini --- vl.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 6e58c1d08d..7ed90263e7 100644 --- a/vl.c +++ b/vl.c @@ -2706,6 +2706,25 @@ static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) return 0; } +static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) +{ + if (tcg_enabled()) { + qemu_tcg_configure(opts, &error_fatal); + } + return 0; +} + +static void configure_accelerators(void) +{ + qemu_opts_foreach(qemu_find_opts("accel"), + do_configure_accelerator, NULL, &error_fatal); + + if (use_icount && !(tcg_enabled() || qtest_enabled())) { + error_report("-icount is not allowed with hardware virtualization"); + exit(1); + } +} + int main(int argc, char **argv, char **envp) { int i; @@ -4103,14 +4122,7 @@ int main(int argc, char **argv, char **envp) qemu_spice_init(); cpu_ticks_init(); - if (use_icount && !(tcg_enabled() || qtest_enabled())) { - error_report("-icount is not allowed with hardware virtualization"); - exit(1); - } - - if (tcg_enabled()) { - qemu_tcg_configure(accel_opts, &error_fatal); - } + configure_accelerators(); if (default_net) { QemuOptsList *net = qemu_find_opts("net"); -- cgit v1.2.3 From 28a0961757fcf1354a8a8f4df9f40d75c5b633dc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 09:59:04 +0100 Subject: vl: merge -accel processing into configure_accelerators MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The next step is to move the parsing of "-machine accel=..." into vl.c, unifying it with the configure_accelerators() function that has just been introduced. This way, we will be able to desugar it into multiple "-accel" options, without polluting accel/accel.c. The CONFIG_TCG and CONFIG_KVM symbols are not available in vl.c, but we can use accel_find instead to find their value at runtime. Once we know that the binary has one of TCG or KVM, the default accelerator can be expressed simply as "tcg:kvm", because TCG never fails to initialize. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- vl.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 5 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 7ed90263e7..28adf38285 100644 --- a/vl.c +++ b/vl.c @@ -2714,8 +2714,65 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) return 0; } -static void configure_accelerators(void) +static void configure_accelerators(const char *progname) { + const char *accel; + char **accel_list, **tmp; + int ret; + bool accel_initialised = false; + bool init_failed = false; + AccelClass *acc = NULL; + + qemu_opts_foreach(qemu_find_opts("icount"), + do_configure_icount, NULL, &error_fatal); + + accel = qemu_opt_get(qemu_get_machine_opts(), "accel"); + if (accel == NULL) { + /* Select the default accelerator */ + if (!accel_find("tcg") && !accel_find("kvm")) { + error_report("No accelerator selected and" + " no default accelerator available"); + exit(1); + } else { + int pnlen = strlen(progname); + if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { + /* If the program name ends with "kvm", we prefer KVM */ + accel = "kvm:tcg"; + } else { + accel = "tcg:kvm"; + } + } + } + + accel_list = g_strsplit(accel, ":", 0); + + for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) { + acc = accel_find(*tmp); + if (!acc) { + continue; + } + ret = accel_init_machine(acc, current_machine); + if (ret < 0) { + init_failed = true; + error_report("failed to initialize %s: %s", + acc->name, strerror(-ret)); + } else { + accel_initialised = true; + } + } + g_strfreev(accel_list); + + if (!accel_initialised) { + if (!init_failed) { + error_report("-machine accel=%s: No accelerator found", accel); + } + exit(1); + } + + if (init_failed) { + error_report("Back to %s accelerator", acc->name); + } + qemu_opts_foreach(qemu_find_opts("accel"), do_configure_accelerator, NULL, &error_fatal); @@ -4035,9 +4092,7 @@ int main(int argc, char **argv, char **envp) * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ - qemu_opts_foreach(qemu_find_opts("icount"), - do_configure_icount, NULL, &error_fatal); - configure_accelerator(current_machine, argv[0]); + configure_accelerators(argv[0]); /* * Beware, QOM objects created before this point miss global and @@ -4122,7 +4177,6 @@ int main(int argc, char **argv, char **envp) qemu_spice_init(); cpu_ticks_init(); - configure_accelerators(); if (default_net) { QemuOptsList *net = qemu_find_opts("net"); -- cgit v1.2.3 From e5db4bd863c8fdf155b003446b98a7aec65a931c Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 11:44:48 +0100 Subject: vl: introduce object_parse_property_opt We will reuse the parsing loop of machine_set_property soon for "-accel", but we do not want the "_" -> "-" conversion since "-accel" can just standardize on dashes. We will also add a bunch of legacy option handling to keep the QOM machine object clean. Extract the loop into a separate function, and keep the legacy handling in machine_set_property. Signed-off-by: Paolo Bonzini --- vl.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 28adf38285..efd3b11431 100644 --- a/vl.c +++ b/vl.c @@ -2490,27 +2490,17 @@ static MachineClass *select_machine(void) return machine_class; } -static int machine_set_property(void *opaque, - const char *name, const char *value, - Error **errp) +static int object_parse_property_opt(Object *obj, + const char *name, const char *value, + const char *skip, Error **errp) { - Object *obj = OBJECT(opaque); Error *local_err = NULL; - char *p, *qom_name; - if (strcmp(name, "type") == 0) { + if (g_str_equal(name, skip)) { return 0; } - qom_name = g_strdup(name); - for (p = qom_name; *p; p++) { - if (*p == '_') { - *p = '-'; - } - } - - object_property_parse(obj, value, qom_name, &local_err); - g_free(qom_name); + object_property_parse(obj, value, name, &local_err); if (local_err) { error_propagate(errp, local_err); @@ -2520,6 +2510,21 @@ static int machine_set_property(void *opaque, return 0; } +static int machine_set_property(void *opaque, + const char *name, const char *value, + Error **errp) +{ + g_autofree char *qom_name = g_strdup(name); + char *p; + + for (p = qom_name; *p; p++) { + if (*p == '_') { + *p = '-'; + } + } + + return object_parse_property_opt(opaque, name, value, "type", errp); +} /* * Initial object creation happens before all other -- cgit v1.2.3 From 6f6e1698a68ceb49e57676528612f22eaf2c16c3 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 10:10:47 +0100 Subject: vl: configure accelerators from -accel options Drop the "accel" property from MachineState, and instead desugar "-machine accel=" to a list of "-accel" options. This has a semantic change due to removing merge_lists from -accel. For example: - "-accel kvm -accel tcg" all but ignored "-accel kvm". This is a bugfix. - "-accel kvm -accel thread=single" ignored "thread=single", since it applied the option to KVM. Now it fails due to not specifying the accelerator on "-accel thread=single". - "-accel tcg -accel thread=single" chose single-threaded TCG, while now it will fail due to not specifying the accelerator on "-accel thread=single". Also, "-machine accel" and "-accel" become incompatible. Signed-off-by: Paolo Bonzini --- vl.c | 93 +++++++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 54 insertions(+), 39 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index efd3b11431..0f620be8b1 100644 --- a/vl.c +++ b/vl.c @@ -292,7 +292,6 @@ static QemuOptsList qemu_accel_opts = { .name = "accel", .implied_opt_name = "accel", .head = QTAILQ_HEAD_INITIALIZER(qemu_accel_opts.head), - .merge_lists = true, .desc = { { .name = "accel", @@ -2523,6 +2522,11 @@ static int machine_set_property(void *opaque, } } + /* Legacy options do not correspond to MachineState properties. */ + if (g_str_equal(qom_name, "accel")) { + return 0; + } + return object_parse_property_opt(opaque, name, value, "type", errp); } @@ -2713,74 +2717,88 @@ static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) { + bool *p_init_failed = opaque; + const char *acc = qemu_opt_get(opts, "accel"); + AccelClass *ac = accel_find(acc); + int ret; + + if (!ac) { + return 0; + } + ret = accel_init_machine(ac, current_machine); + if (ret < 0) { + *p_init_failed = true; + error_report("failed to initialize %s: %s", + acc, strerror(-ret)); + return 0; + } + if (tcg_enabled()) { qemu_tcg_configure(opts, &error_fatal); } - return 0; + return 1; } static void configure_accelerators(const char *progname) { const char *accel; char **accel_list, **tmp; - int ret; bool accel_initialised = false; bool init_failed = false; - AccelClass *acc = NULL; qemu_opts_foreach(qemu_find_opts("icount"), do_configure_icount, NULL, &error_fatal); accel = qemu_opt_get(qemu_get_machine_opts(), "accel"); - if (accel == NULL) { - /* Select the default accelerator */ - if (!accel_find("tcg") && !accel_find("kvm")) { - error_report("No accelerator selected and" - " no default accelerator available"); - exit(1); - } else { - int pnlen = strlen(progname); - if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { - /* If the program name ends with "kvm", we prefer KVM */ - accel = "kvm:tcg"; + if (QTAILQ_EMPTY(&qemu_accel_opts.head)) { + if (accel == NULL) { + /* Select the default accelerator */ + if (!accel_find("tcg") && !accel_find("kvm")) { + error_report("No accelerator selected and" + " no default accelerator available"); + exit(1); } else { - accel = "tcg:kvm"; + int pnlen = strlen(progname); + if (pnlen >= 3 && g_str_equal(&progname[pnlen - 3], "kvm")) { + /* If the program name ends with "kvm", we prefer KVM */ + accel = "kvm:tcg"; + } else { + accel = "tcg:kvm"; + } } } - } - accel_list = g_strsplit(accel, ":", 0); + accel_list = g_strsplit(accel, ":", 0); - for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) { - acc = accel_find(*tmp); - if (!acc) { - continue; + for (tmp = accel_list; !accel_initialised && tmp && *tmp; tmp++) { + /* + * Filter invalid accelerators here, to prevent obscenities + * such as "-machine accel=tcg,,thread=single". + */ + if (accel_find(*tmp)) { + qemu_opts_parse_noisily(qemu_find_opts("accel"), *tmp, true); + } } - ret = accel_init_machine(acc, current_machine); - if (ret < 0) { - init_failed = true; - error_report("failed to initialize %s: %s", - acc->name, strerror(-ret)); - } else { - accel_initialised = true; + } else { + if (accel != NULL) { + error_report("The -accel and \"-machine accel=\" options are incompatible"); + exit(1); } } - g_strfreev(accel_list); - if (!accel_initialised) { + if (!qemu_opts_foreach(qemu_find_opts("accel"), + do_configure_accelerator, &init_failed, &error_fatal)) { if (!init_failed) { - error_report("-machine accel=%s: No accelerator found", accel); + error_report("no accelerator found"); } exit(1); } if (init_failed) { - error_report("Back to %s accelerator", acc->name); + AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator); + error_report("Back to %s accelerator", ac->name); } - qemu_opts_foreach(qemu_find_opts("accel"), - do_configure_accelerator, NULL, &error_fatal); - if (use_icount && !(tcg_enabled() || qtest_enabled())) { error_report("-icount is not allowed with hardware virtualization"); exit(1); @@ -3461,9 +3479,6 @@ int main(int argc, char **argv, char **envp) "use -M accel=... for now instead"); exit(1); } - opts = qemu_opts_create(qemu_find_opts("machine"), NULL, - false, &error_abort); - qemu_opt_set(opts, "accel", optarg, &error_abort); break; case QEMU_OPTION_usb: olist = qemu_find_opts("machine"); -- cgit v1.2.3 From 8b90f1c5aca6cfabe97a567150560d06485182fa Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 12:08:38 +0100 Subject: vl: warn for unavailable accelerators, clarify messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So far, specifying an accelerator that was not compiled in did not result in an error; fix that. While at it, clarify the mysterious "Back to TCG" message. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 0f620be8b1..c350eef046 100644 --- a/vl.c +++ b/vl.c @@ -2723,6 +2723,8 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) int ret; if (!ac) { + *p_init_failed = true; + error_report("invalid accelerator %s", acc); return 0; } ret = accel_init_machine(ac, current_machine); @@ -2777,6 +2779,9 @@ static void configure_accelerators(const char *progname) */ if (accel_find(*tmp)) { qemu_opts_parse_noisily(qemu_find_opts("accel"), *tmp, true); + } else { + init_failed = true; + error_report("invalid accelerator %s", *tmp); } } } else { @@ -2796,7 +2801,7 @@ static void configure_accelerators(const char *progname) if (init_failed) { AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator); - error_report("Back to %s accelerator", ac->name); + error_report("falling back to %s", ac->name); } if (use_icount && !(tcg_enabled() || qtest_enabled())) { -- cgit v1.2.3 From 1fff3c206f320104e929b22e6b9e82fc6e4c2ae6 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 13:33:44 +0100 Subject: qom: introduce object_register_sugar_prop Similar to the existing "-rtc driftfix" option, we will convert some legacy "-machine" command line options to global properties on accelerators. Because accelerators are not devices, we cannot use qdev_prop_register_global. Instead, provide a slot in the generic object_compat_props arrays for command line syntactic sugar. Signed-off-by: Paolo Bonzini --- vl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index c350eef046..b95c161c1d 100644 --- a/vl.c +++ b/vl.c @@ -895,13 +895,9 @@ static void configure_rtc(QemuOpts *opts) value = qemu_opt_get(opts, "driftfix"); if (value) { if (!strcmp(value, "slew")) { - static GlobalProperty slew_lost_ticks = { - .driver = "mc146818rtc", - .property = "lost_tick_policy", - .value = "slew", - }; - - qdev_prop_register_global(&slew_lost_ticks); + object_register_sugar_prop("mc146818rtc", + "lost_tick_policy", + "slew"); } else if (!strcmp(value, "none")) { /* discard is default */ } else { -- cgit v1.2.3 From 3c75e12ea64666f2fc9f822675490e8672f45453 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 13:57:55 +0100 Subject: qom: add object_new_with_class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Similar to CPU and machine classes, "-accel" class names are mangled, so we have to first get a class via accel_find and then instantiate it. Provide a new function to instantiate a class without going through object_class_get_name, and use it for CPUs and machines already. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- vl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index b95c161c1d..65e6b75a74 100644 --- a/vl.c +++ b/vl.c @@ -3834,8 +3834,7 @@ int main(int argc, char **argv, char **envp) cleanup_add_fd, NULL, &error_fatal); #endif - current_machine = MACHINE(object_new(object_class_get_name( - OBJECT_CLASS(machine_class)))); + current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class))); if (machine_help_func(qemu_get_machine_opts(), current_machine)) { exit(0); } -- cgit v1.2.3 From fc5cf8262113e80d35177f06d49bcc1a9d3dc9fc Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 14:03:46 +0100 Subject: accel: pass object to accel_init_machine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We will have to set QOM properties before accel_init_machine, based on the options provided to -accel. Construct the object outside it so that it will be possible to iterate on properties between object_new_with_class and accel_init_machine. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- vl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 65e6b75a74..b2f00ccd54 100644 --- a/vl.c +++ b/vl.c @@ -2716,6 +2716,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) bool *p_init_failed = opaque; const char *acc = qemu_opt_get(opts, "accel"); AccelClass *ac = accel_find(acc); + AccelState *accel; int ret; if (!ac) { @@ -2723,7 +2724,8 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) error_report("invalid accelerator %s", acc); return 0; } - ret = accel_init_machine(ac, current_machine); + accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + ret = accel_init_machine(accel, current_machine); if (ret < 0) { *p_init_failed = true; error_report("failed to initialize %s: %s", -- cgit v1.2.3 From 12ceaef6ae0b4d0eec4712aaf54ad3b8434c1afb Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 10:36:01 +0100 Subject: tcg: convert "-accel threads" to a QOM property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the ad-hoc qemu_tcg_configure with generic code invoking QOM property getters and setters. More properties (and thus more valid -accel suboptions) will be added in the next patches, which will move accelerator-related "-machine" options to accelerators. Reviewed-by: Marc-André Lureau Signed-off-by: Paolo Bonzini --- vl.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index b2f00ccd54..7f2f3fb63c 100644 --- a/vl.c +++ b/vl.c @@ -293,17 +293,12 @@ static QemuOptsList qemu_accel_opts = { .implied_opt_name = "accel", .head = QTAILQ_HEAD_INITIALIZER(qemu_accel_opts.head), .desc = { - { - .name = "accel", - .type = QEMU_OPT_STRING, - .help = "Select the type of accelerator", - }, - { - .name = "thread", - .type = QEMU_OPT_STRING, - .help = "Enable/disable multi-threaded TCG", - }, - { /* end of list */ } + /* + * no elements => accept any + * sanity checking will happen later + * when setting accelerator properties + */ + { } }, }; @@ -2711,6 +2706,13 @@ static int do_configure_icount(void *opaque, QemuOpts *opts, Error **errp) return 0; } +static int accelerator_set_property(void *opaque, + const char *name, const char *value, + Error **errp) +{ + return object_parse_property_opt(opaque, name, value, "accel", errp); +} + static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) { bool *p_init_failed = opaque; @@ -2725,6 +2727,10 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) return 0; } accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + qemu_opt_foreach(opts, accelerator_set_property, + accel, + &error_fatal); + ret = accel_init_machine(accel, current_machine); if (ret < 0) { *p_init_failed = true; @@ -2732,10 +2738,6 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) acc, strerror(-ret)); return 0; } - - if (tcg_enabled()) { - qemu_tcg_configure(opts, &error_fatal); - } return 1; } -- cgit v1.2.3 From fe174132478b4e7b0086f2305a511fd94c9aca8b Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 15:16:44 +0100 Subject: tcg: add "-accel tcg,tb-size" and deprecate "-tb-size" -tb-size fits nicely in the new framework for accelerator-specific options. It is a very niche option, so insta-deprecate it. Signed-off-by: Paolo Bonzini --- vl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 7f2f3fb63c..900f97a36a 100644 --- a/vl.c +++ b/vl.c @@ -2727,6 +2727,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) return 0; } accel = ACCEL(object_new_with_class(OBJECT_CLASS(ac))); + object_apply_compat_props(OBJECT(accel)); qemu_opt_foreach(opts, accelerator_set_property, accel, &error_fatal); @@ -2738,6 +2739,7 @@ static int do_configure_accelerator(void *opaque, QemuOpts *opts, Error **errp) acc, strerror(-ret)); return 0; } + return 1; } @@ -3590,10 +3592,8 @@ int main(int argc, char **argv, char **envp) error_report("TCG is disabled"); exit(1); #endif - if (qemu_strtoul(optarg, NULL, 0, &tcg_tb_size) < 0) { - error_report("Invalid argument to -tb-size"); - exit(1); - } + warn_report("The -tb-size option is deprecated, use -accel tcg,tb-size instead"); + object_register_sugar_prop(ACCEL_CLASS_NAME("tcg"), "tb-size", optarg); break; case QEMU_OPTION_icount: icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"), -- cgit v1.2.3 From 46472d82322d0af23c7074c1101a791b5a27ca46 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 10:56:53 +0100 Subject: xen: convert "-machine igd-passthru" to an accelerator property The first machine property to fall is Xen's Intel integrated graphics passthrough. The "-machine igd-passthru" option does not set anymore a property on the machine object, but desugars to a GlobalProperty on accelerator objects. The setter is very simple, since the value ends up in a global variable, so this patch also provides an example before the more complicated cases that follow it. Signed-off-by: Paolo Bonzini --- vl.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 900f97a36a..774305c3f7 100644 --- a/vl.c +++ b/vl.c @@ -1133,13 +1133,6 @@ static void configure_msg(QemuOpts *opts) } -/* Now we still need this for compatibility with XEN. */ -bool has_igd_gfx_passthru; -static void igd_gfx_passthru(void) -{ - has_igd_gfx_passthru = current_machine->igd_gfx_passthru; -} - /***********************************************************/ /* USB devices */ @@ -2517,6 +2510,10 @@ static int machine_set_property(void *opaque, if (g_str_equal(qom_name, "accel")) { return 0; } + if (g_str_equal(qom_name, "igd-passthru")) { + object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value); + return 0; + } return object_parse_property_opt(opaque, name, value, "type", errp); } @@ -4297,9 +4294,6 @@ int main(int argc, char **argv, char **envp) exit(1); } - /* Check if IGD GFX passthrough. */ - igd_gfx_passthru(); - /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); qemu_opts_foreach(qemu_find_opts("device"), -- cgit v1.2.3 From 23b0898e4471f42e62aa1fea304f6a6e23d03310 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 10:56:53 +0100 Subject: kvm: convert "-machine kvm_shadow_mem" to an accelerator property Signed-off-by: Paolo Bonzini --- vl.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 774305c3f7..8c6fcdac3c 100644 --- a/vl.c +++ b/vl.c @@ -2514,6 +2514,10 @@ static int machine_set_property(void *opaque, object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value); return 0; } + if (g_str_equal(qom_name, "kvm-shadow-mem")) { + object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value); + return 0; + } return object_parse_property_opt(opaque, name, value, "type", errp); } -- cgit v1.2.3 From 11bc4a13d1f4b07dafbd1dda4d4bf0fdd7ad65f2 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 13 Nov 2019 10:56:53 +0100 Subject: kvm: convert "-machine kernel_irqchip" to an accelerator property Signed-off-by: Paolo Bonzini --- vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 8c6fcdac3c..4034c2343e 100644 --- a/vl.c +++ b/vl.c @@ -2514,7 +2514,8 @@ static int machine_set_property(void *opaque, object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value); return 0; } - if (g_str_equal(qom_name, "kvm-shadow-mem")) { + if (g_str_equal(qom_name, "kvm-shadow-mem") || + g_str_equal(qom_name, "kernel-irqchip")) { object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value); return 0; } -- cgit v1.2.3