[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v3 08/38] hw/xen_backend: refactor xen_be_init()
From: |
David Woodhouse |
Subject: |
[RFC PATCH v3 08/38] hw/xen_backend: refactor xen_be_init() |
Date: |
Fri, 16 Dec 2022 00:40:47 +0000 |
From: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/xen/xen-legacy-backend.c | 40 +++++++++++++++++++++--------
include/hw/xen/xen-legacy-backend.h | 3 +++
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/hw/xen/xen-legacy-backend.c b/hw/xen/xen-legacy-backend.c
index 085fd31ef7..694e7bbc54 100644
--- a/hw/xen/xen-legacy-backend.c
+++ b/hw/xen/xen-legacy-backend.c
@@ -676,17 +676,40 @@ void xenstore_update_fe(char *watch, struct
XenLegacyDevice *xendev)
}
/* -------------------------------------------------------------------- */
-int xen_be_init(void)
+int xen_be_xenstore_open(void)
{
- xengnttab_handle *gnttabdev;
-
xenstore = xs_daemon_open();
if (!xenstore) {
- xen_pv_printf(NULL, 0, "can't connect to xenstored\n");
return -1;
}
qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL);
+ return 0;
+}
+
+void xen_be_xenstore_close(void)
+{
+ qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
+ xs_daemon_close(xenstore);
+ xenstore = NULL;
+}
+
+void xen_be_sysdev_init(void)
+{
+ xen_sysdev = qdev_new(TYPE_XENSYSDEV);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(xen_sysdev), &error_fatal);
+ xen_sysbus = qbus_new(TYPE_XENSYSBUS, xen_sysdev, "xen-sysbus");
+ qbus_set_bus_hotplug_handler(xen_sysbus);
+}
+
+int xen_be_init(void)
+{
+ xengnttab_handle *gnttabdev;
+
+ if (xen_be_xenstore_open()) {
+ xen_pv_printf(NULL, 0, "can't connect to xenstored\n");
+ return -1;
+ }
if (xen_xc == NULL || xen_fmem == NULL) {
/* Check if xen_init() have been called */
@@ -701,17 +724,12 @@ int xen_be_init(void)
xengnttab_close(gnttabdev);
}
- xen_sysdev = qdev_new(TYPE_XENSYSDEV);
- sysbus_realize_and_unref(SYS_BUS_DEVICE(xen_sysdev), &error_fatal);
- xen_sysbus = qbus_new(TYPE_XENSYSBUS, xen_sysdev, "xen-sysbus");
- qbus_set_bus_hotplug_handler(xen_sysbus);
+ xen_be_sysdev_init();
return 0;
err:
- qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
- xs_daemon_close(xenstore);
- xenstore = NULL;
+ xen_be_xenstore_close();
return -1;
}
diff --git a/include/hw/xen/xen-legacy-backend.h
b/include/hw/xen/xen-legacy-backend.h
index be281e1f38..0aa171f6c2 100644
--- a/include/hw/xen/xen-legacy-backend.h
+++ b/include/hw/xen/xen-legacy-backend.h
@@ -42,6 +42,9 @@ int xenstore_read_fe_uint64(struct XenLegacyDevice *xendev,
const char *node,
void xen_be_check_state(struct XenLegacyDevice *xendev);
/* xen backend driver bits */
+int xen_be_xenstore_open(void);
+void xen_be_xenstore_close(void);
+void xen_be_sysdev_init(void);
int xen_be_init(void);
void xen_be_register_common(void);
int xen_be_register(const char *type, struct XenDevOps *ops);
--
2.35.3
- [RFC PATCH v3 12/38] i386/xen: add pc_machine_kvm_type to initialize XEN_EMULATE mode, (continued)
- [RFC PATCH v3 12/38] i386/xen: add pc_machine_kvm_type to initialize XEN_EMULATE mode, David Woodhouse, 2022/12/15
- [RFC PATCH v3 38/38] hw/xen: Support HVM_PARAM_CALLBACK_TYPE_PCI_INTX callback, David Woodhouse, 2022/12/15
- [RFC PATCH v3 06/38] xen-platform: exclude vfio-pci from the PCI platform unplug, David Woodhouse, 2022/12/15
- [RFC PATCH v3 22/38] i386/xen: HVMOP_set_param / HVM_PARAM_CALLBACK_IRQ, David Woodhouse, 2022/12/15
- [RFC PATCH v3 29/38] hw/xen: Implement EVTCHNOP_bind_ipi, David Woodhouse, 2022/12/15
- [RFC PATCH v3 02/38] xen: add CONFIG_XENFV_MACHINE and CONFIG_XEN_EMU options for Xen emulation, David Woodhouse, 2022/12/15
- [RFC PATCH v3 32/38] hw/xen: Implement EVTCHNOP_bind_interdomain, David Woodhouse, 2022/12/15
- [RFC PATCH v3 25/38] hw/xen: Implement EVTCHNOP_status, David Woodhouse, 2022/12/15
- [RFC PATCH v3 08/38] hw/xen_backend: refactor xen_be_init(),
David Woodhouse <=
- [RFC PATCH v3 15/38] i386/xen: implement XENMEM_add_to_physmap_batch, David Woodhouse, 2022/12/15
- [RFC PATCH v3 23/38] i386/xen: implement HYPERVISOR_event_channel_op, David Woodhouse, 2022/12/15
- [RFC PATCH v3 31/38] hw/xen: Implement EVTCHNOP_alloc_unbound, David Woodhouse, 2022/12/15
- [RFC PATCH v3 36/38] i386/xen: Implement SCHEDOP_poll, David Woodhouse, 2022/12/15
- [RFC PATCH v3 11/38] hw/xen: Add xen_overlay device for emulating shared xenheap pages, David Woodhouse, 2022/12/15
- [RFC PATCH v3 19/38] i386/xen: handle VCPUOP_register_vcpu_time_info, David Woodhouse, 2022/12/15
- [RFC PATCH v3 28/38] hw/xen: Implement EVTCHNOP_bind_virq, David Woodhouse, 2022/12/15
- [RFC PATCH v3 21/38] i386/xen: implement HVMOP_set_evtchn_upcall_vector, David Woodhouse, 2022/12/15
- [RFC PATCH v3 33/38] hw/xen: Implement EVTCHNOP_bind_vcpu, David Woodhouse, 2022/12/15