From: David Woodhouse Date: Tue, 10 Jan 2023 08:01:47 +0000 (+0000) Subject: i386/xen: Initialize XenBus and legacy backends from pc_init1() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=468aa255c8e40a95b769809a75a385ad27390f6e;p=people%2Fpauldu%2Fqemu.git i386/xen: Initialize XenBus and legacy backends from pc_init1() Now that we're close to being able to use the PV backends without actual Xen, move the bus instantiation out from xen_hvm_init_pc() to pc_init1(). However, still only do it for (xen_mode == XEN_ATTACH) (i.e. when running on true Xen) because we don't have XenStore ops for emulation yet, and the XenBus instantiation failure is fatal. Once we have a functional XenStore for emulated mode, this will become (xen_mode != XEN_DISABLED). Signed-off-by: David Woodhouse --- diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 4a4825e81d..c85950bc6d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -57,6 +57,10 @@ #include #include "hw/xen/xen_pt.h" #endif +#ifdef CONFIG_XEN_BUS +#include "hw/xen/xen-legacy-backend.h" +#include "hw/xen/xen-bus.h" +#endif #include "hw/xen/xen-x86.h" #include "hw/xen/xen.h" #include "migration/global_state.h" @@ -170,6 +174,19 @@ static void pc_init1(MachineState *machine, } } +#ifdef CONFIG_XEN_BUS + if (xen_mode == XEN_ATTACH) { + /* Initialize backend core & drivers */ + xen_bus_init(); + + if (xen_be_init() != 0) { + error_report("xen backend core setup failed"); + exit(1); + } + xen_be_register_common(); + } +#endif + pc_machine_init_sgx_epc(pcms); x86_cpus_init(x86ms, pcmc->default_cpu_version); diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 543e5a7a94..da21bac378 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -20,8 +20,6 @@ #include "hw/i386/apic-msidef.h" #include "hw/xen/xen_native.h" #include "hw/xen/xen_backend_ops.h" -#include "hw/xen/xen-legacy-backend.h" -#include "hw/xen/xen-bus.h" #include "hw/xen/xen-x86.h" #include "qapi/error.h" #include "qapi/qapi-commands-migration.h" @@ -1505,15 +1503,6 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion **ram_memory) QLIST_INIT(&state->dev_list); device_listener_register(&state->device_listener); - xen_bus_init(); - - /* Initialize backend core & drivers */ - if (xen_be_init() != 0) { - error_report("xen backend core setup failed"); - goto err; - } - xen_be_register_common(); - QLIST_INIT(&xen_physmap); xen_read_physmap(state);