#include "qemu/error-report.h"
#include "qemu/sockets.h"
-#include "sysemu/accel.h"
+#include "qemu/accel.h"
#include "hw/usb.h"
#include "hw/isa/isa.h"
#include "hw/scsi/scsi.h"
#include "qemu/plugin.h"
#include "qemu/queue.h"
#include "sysemu/arch_init.h"
+#include "exec/confidential-guest-support.h"
#include "ui/qemu-spice.h"
#include "qapi/string-input-visitor.h"
},
};
-static QemuOptsList qemu_realtime_opts = {
- .name = "realtime",
- .head = QTAILQ_HEAD_INITIALIZER(qemu_realtime_opts.head),
- .desc = {
- {
- .name = "mlock",
- .type = QEMU_OPT_BOOL,
- },
- { /* end of list */ }
- },
-};
-
static QemuOptsList qemu_overcommit_opts = {
.name = "overcommit",
.head = QTAILQ_HEAD_INITIALIZER(qemu_overcommit_opts.head),
static void configure_msg(QemuOpts *opts)
{
- error_with_timestamp = qemu_opt_get_bool(opts, "timestamp", false);
+ message_with_timestamp = qemu_opt_get_bool(opts, "timestamp", false);
error_with_guestname = qemu_opt_get_bool(opts, "guest-name", false);
}
* display access.
*/
if (*opts == '=') {
- vnc_parse(opts + 1, &error_fatal);
+ vnc_parse(opts + 1);
} else {
error_report("VNC requires a display argument vnc=<display>");
exit(1);
if (!qemu_display_find_default(&dpy)) {
dpy.type = DISPLAY_TYPE_NONE;
#if defined(CONFIG_VNC)
- vnc_parse("localhost:0,to=99,id=default", &error_abort);
+ vnc_parse("localhost:0,to=99,id=default");
#endif
}
}
return 0;
}
if (g_str_equal(qom_name, "igd-passthru")) {
- object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value,
+ false);
return 0;
}
if (g_str_equal(qom_name, "kvm-shadow-mem")) {
- object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value,
+ false);
return 0;
}
if (g_str_equal(qom_name, "kernel-irqchip")) {
- object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value);
- object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), qom_name, value);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value,
+ false);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), qom_name, value,
+ false);
return 0;
}
return false;
}
- /* Allocation of large amounts of memory may delay
+ /*
+ * Allocation of large amounts of memory may delay
* chardev initialization for too long, and trigger timeouts
* on software that waits for a monitor socket to be created
* (e.g. libvirt).
return 0;
}
-static int qemu_read_default_config_file(void)
+static void qemu_read_default_config_file(Error **errp)
{
+ ERRP_GUARD();
int ret;
g_autofree char *file = get_relocated_path(CONFIG_QEMU_CONFDIR "/qemu.conf");
- ret = qemu_read_config_file(file);
- if (ret < 0 && ret != -ENOENT) {
- return ret;
+ ret = qemu_read_config_file(file, errp);
+ if (ret < 0) {
+ if (ret == -ENOENT) {
+ error_free(*errp);
+ *errp = NULL;
+ }
}
-
- return 0;
}
static int qemu_set_option(const char *str)
static void configure_accelerators(const char *progname)
{
- const char *accel;
+ const char *accelerators;
bool init_failed = false;
qemu_opts_foreach(qemu_find_opts("icount"),
do_configure_icount, NULL, &error_fatal);
- accel = qemu_opt_get(qemu_get_machine_opts(), "accel");
+ accelerators = qemu_opt_get(qemu_get_machine_opts(), "accel");
if (QTAILQ_EMPTY(&qemu_accel_opts.head)) {
char **accel_list, **tmp;
- if (accel == NULL) {
+ if (accelerators == NULL) {
/* Select the default accelerator */
bool have_tcg = accel_find("tcg");
bool have_kvm = accel_find("kvm");
if (have_tcg && have_kvm) {
if (g_str_has_suffix(progname, "kvm")) {
/* If the program name ends with "kvm", we prefer KVM */
- accel = "kvm:tcg";
+ accelerators = "kvm:tcg";
} else {
- accel = "tcg:kvm";
+ accelerators = "tcg:kvm";
}
} else if (have_kvm) {
- accel = "kvm";
+ accelerators = "kvm";
} else if (have_tcg) {
- accel = "tcg";
+ accelerators = "tcg";
} else {
error_report("No accelerator selected and"
" no default accelerator available");
exit(1);
}
}
- accel_list = g_strsplit(accel, ":", 0);
+ accel_list = g_strsplit(accelerators, ":", 0);
for (tmp = accel_list; *tmp; tmp++) {
/*
}
g_strfreev(accel_list);
} else {
- if (accel != NULL) {
+ if (accelerators != NULL) {
error_report("The -accel and \"-machine accel=\" options are incompatible");
exit(1);
}
val = g_strdup_printf("%d",
(uint32_t) qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1));
- object_register_sugar_prop("memory-backend", "prealloc-threads", val);
+ object_register_sugar_prop("memory-backend", "prealloc-threads", val,
+ false);
g_free(val);
- object_register_sugar_prop("memory-backend", "prealloc", "on");
+ object_register_sugar_prop("memory-backend", "prealloc", "on", false);
}
if (watchdog) {
cleanup_add_fd, NULL, &error_fatal);
#endif
- if (!trace_init_backends()) {
- exit(1);
- }
- trace_init_file();
-
/* Open the logfile at this point and set the log mask if necessary. */
- qemu_set_log_filename(log_file, &error_fatal);
+ if (log_file) {
+ qemu_set_log_filename(log_file, &error_fatal);
+ }
if (log_mask) {
int mask;
mask = qemu_str_to_log_mask(log_mask);
static void qemu_machine_creation_done(void)
{
+ MachineState *machine = MACHINE(qdev_get_machine());
+
/* Did we create any drives that we failed to create a device for? */
drive_check_orphaned();
qdev_machine_creation_done();
+ if (machine->cgs) {
+ /*
+ * Verify that Confidential Guest Support has actually been initialized
+ */
+ assert(machine->cgs->ready);
+ }
+
if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
exit(1);
}
if (loadvm) {
Error *local_err = NULL;
- if (load_snapshot(loadvm, &local_err) < 0) {
+ if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) {
error_report_err(local_err);
autostart = 0;
exit(1);
qemu_add_opts(&qemu_add_fd_opts);
qemu_add_opts(&qemu_object_opts);
qemu_add_opts(&qemu_tpmdev_opts);
- qemu_add_opts(&qemu_realtime_opts);
qemu_add_opts(&qemu_overcommit_opts);
qemu_add_opts(&qemu_msg_opts);
qemu_add_opts(&qemu_name_opts);
}
if (userconfig) {
- if (qemu_read_default_config_file() < 0) {
- exit(1);
- }
+ qemu_read_default_config_file(&error_fatal);
}
/* second pass of option parsing */
}
break;
case QEMU_OPTION_vnc:
- vnc_parse(optarg, &error_fatal);
+ vnc_parse(optarg);
break;
case QEMU_OPTION_no_acpi:
olist = qemu_find_opts("machine");
break;
case QEMU_OPTION_no_shutdown:
olist = qemu_find_opts("action");
- qemu_opts_parse_noisily(olist, "panic=pause,shutdown=pause", false);
- break;
- case QEMU_OPTION_show_cursor:
- warn_report("The -show-cursor option is deprecated. Please "
- "add show-cursor=on to your -display options.");
- warn_report("When using the default display you can use "
- "-display default,show-cursor=on");
- dpy.has_show_cursor = true;
- dpy.show_cursor = true;
+ qemu_opts_parse_noisily(olist, "shutdown=pause", false);
break;
case QEMU_OPTION_uuid:
if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) {
exit(1);
}
break;
- case QEMU_OPTION_tb_size:
-#ifndef CONFIG_TCG
- error_report("TCG is disabled");
- exit(1);
-#endif
- 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"),
optarg, true);
qemu_plugin_opt_parse(optarg, &plugin_list);
break;
case QEMU_OPTION_readconfig:
- {
- int ret = qemu_read_config_file(optarg);
- if (ret < 0) {
- error_report("read config %s: %s", optarg,
- strerror(-ret));
- exit(1);
- }
- break;
- }
+ qemu_read_config_file(optarg, &error_fatal);
+ break;
case QEMU_OPTION_spice:
olist = qemu_find_opts_err("spice", NULL);
if (!olist) {
case QEMU_OPTION_writeconfig:
{
FILE *fp;
+ warn_report("-writeconfig is deprecated and will go away without a replacement");
if (strcmp(optarg, "-") == 0) {
fp = stdout;
} else {
exit(1);
}
break;
- case QEMU_OPTION_realtime:
- warn_report("'-realtime mlock=...' is deprecated, please use "
- "'-overcommit mem-lock=...' instead");
- opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"),
- optarg, false);
- if (!opts) {
- exit(1);
- }
- /* Don't override the -overcommit option if set */
- enable_mlock = enable_mlock ||
- qemu_opt_get_bool(opts, "mlock", true);
- break;
case QEMU_OPTION_overcommit:
opts = qemu_opts_parse_noisily(qemu_find_opts("overcommit"),
optarg, false);
if (!opts) {
exit(1);
}
- /* Don't override the -realtime option if set */
- enable_mlock = enable_mlock ||
- qemu_opt_get_bool(opts, "mem-lock", false);
+ enable_mlock = qemu_opt_get_bool(opts, "mem-lock", false);
enable_cpu_pm = qemu_opt_get_bool(opts, "cpu-pm", false);
break;
case QEMU_OPTION_msg:
qemu_process_help_options();
qemu_maybe_daemonize(pid_file);
+ /*
+ * The trace backend must be initialized after daemonizing.
+ * trace_init_backends() will call st_init(), which will create the
+ * trace thread in the parent, and also register st_flush_trace_buffer()
+ * in atexit(). This function will force the parent to wait for the
+ * writeout thread to finish, which will not occur, and the parent
+ * process will be left in the host.
+ */
+ if (!trace_init_backends()) {
+ exit(1);
+ }
+ trace_init_file();
+
qemu_init_main_loop(&error_fatal);
cpu_timers_init();
*
* Machine compat properties: object_set_machine_compat_props().
* Accelerator compat props: object_set_accelerator_compat_props(),
- * called from configure_accelerator().
+ * called from do_configure_accelerator().
*/
machine_class = MACHINE_GET_CLASS(current_machine);
if (cpu_option) {
current_machine->cpu_type = parse_cpu_option(cpu_option);
}
+ /* NB: for machine none cpu_type could STILL be NULL here! */
+ accel_init_interfaces(ACCEL_GET_CLASS(current_machine->accelerator));
qemu_resolve_machine_memdev();
parse_numa_opts(current_machine);
exit(0);
}
- qemu_init_displays();
if (!preconfig_requested) {
qmp_x_exit_preconfig(&error_fatal);
}
+ qemu_init_displays();
accel_setup_post(current_machine);
os_setup_post();
resume_mux_open();