]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
pc_piix: handle XEN_EMULATE backend init
authorJoao Martins <joao.m.martins@oracle.com>
Mon, 5 Dec 2022 15:08:59 +0000 (15:08 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 7 Dec 2022 16:19:48 +0000 (16:19 +0000)
And use newly added xen_emulated_machine_init() to iniitalize
the xenstore and the sysdev bus for future emulated devices.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
[dwmw2: Move it to xen-legacy-backend.c]
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
hw/i386/pc_piix.c
hw/xen/xen-legacy-backend.c
include/hw/xen/xen-legacy-backend.h

index 13286d0739ac3312e292a1ebe1e57a4fe95c9b03..3dcac2f4b6374472fd957a73744e94acc690615e 100644 (file)
@@ -47,6 +47,7 @@
 #include "hw/sysbus.h"
 #include "hw/i2c/smbus_eeprom.h"
 #include "hw/xen/xen-x86.h"
+#include "hw/xen/xen-legacy-backend.h"
 #include "exec/memory.h"
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/piix4.h"
@@ -155,6 +156,10 @@ static void pc_init1(MachineState *machine,
             x86ms->above_4g_mem_size = 0;
             x86ms->below_4g_mem_size = machine->ram_size;
         }
+
+        if (pcms->xen_version && !xen_be_xenstore_open()) {
+            xen_emulated_machine_init();
+        }
     }
 
     pc_machine_init_sgx_epc(pcms);
index 694e7bbc548f12bfa768bf7e89ccf9e59d0ed37c..60a7bc7ab60c7459d165f329719e038ff17331e4 100644 (file)
@@ -31,6 +31,7 @@
 #include "qapi/error.h"
 #include "hw/xen/xen-legacy-backend.h"
 #include "hw/xen/xen_pvdev.h"
+#include "hw/xen/xen-bus.h"
 #include "monitor/qdev.h"
 
 DeviceState *xen_sysdev;
@@ -294,13 +295,15 @@ static struct XenLegacyDevice *xen_be_get_xendev(const char *type, int dom,
     xendev->debug      = debug;
     xendev->local_port = -1;
 
-    xendev->evtchndev = xenevtchn_open(NULL, 0);
-    if (xendev->evtchndev == NULL) {
-        xen_pv_printf(NULL, 0, "can't open evtchn device\n");
-        qdev_unplug(DEVICE(xendev), NULL);
-        return NULL;
+    if (xen_mode != XEN_EMULATE) {
+        xendev->evtchndev = xenevtchn_open(NULL, 0);
+        if (xendev->evtchndev == NULL) {
+            xen_pv_printf(NULL, 0, "can't open evtchn device\n");
+            qdev_unplug(DEVICE(xendev), NULL);
+            return NULL;
+        }
+        qemu_set_cloexec(xenevtchn_fd(xendev->evtchndev));
     }
-    qemu_set_cloexec(xenevtchn_fd(xendev->evtchndev));
 
     xen_pv_insert_xendev(xendev);
 
@@ -859,3 +862,10 @@ static void xenbe_register_types(void)
 }
 
 type_init(xenbe_register_types)
+
+void xen_emulated_machine_init(void)
+{
+    xen_bus_init();
+    xen_be_sysdev_init();
+    xen_be_register_common();
+}
index 0aa171f6c263a1c4a0bc91b3f7c9d90b66d16656..aa0901566239b0d3a26e05c9269818930a6e105d 100644 (file)
@@ -105,4 +105,6 @@ int xen_config_dev_vfb(int vdev, const char *type);
 int xen_config_dev_vkbd(int vdev);
 int xen_config_dev_console(int vdev);
 
+void xen_emulated_machine_init(void);
+
 #endif /* HW_XEN_LEGACY_BACKEND_H */