mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
hw/xen: Subsume xen_be_register_common() into xen_be_init()
Every caller of xen_be_init() checks and exits on error, then calls xen_be_register_common(). Just make xen_be_init() abort for itself and return void, and register the common devices too. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
parent
c1eaa6d0df
commit
79807f3e6b
4 changed files with 25 additions and 48 deletions
|
@ -676,21 +676,30 @@ void xenstore_update_fe(char *watch, struct XenLegacyDevice *xendev)
|
|||
}
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
int xen_be_init(void)
|
||||
static void xen_set_dynamic_sysbus(void)
|
||||
{
|
||||
Object *machine = qdev_get_machine();
|
||||
ObjectClass *oc = object_get_class(machine);
|
||||
MachineClass *mc = MACHINE_CLASS(oc);
|
||||
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV);
|
||||
}
|
||||
|
||||
void xen_be_init(void)
|
||||
{
|
||||
xengnttab_handle *gnttabdev;
|
||||
|
||||
xenstore = xs_daemon_open();
|
||||
if (!xenstore) {
|
||||
xen_pv_printf(NULL, 0, "can't connect to xenstored\n");
|
||||
return -1;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
qemu_set_fd_handler(xs_fileno(xenstore), xenstore_update, NULL, NULL);
|
||||
|
||||
if (xen_xc == NULL || xen_fmem == NULL) {
|
||||
/* Check if xen_init() have been called */
|
||||
goto err;
|
||||
xen_pv_printf(NULL, 0, "Xen operations not set up\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gnttabdev = xengnttab_open(NULL, 0);
|
||||
|
@ -706,23 +715,16 @@ int xen_be_init(void)
|
|||
xen_sysbus = qbus_new(TYPE_XENSYSBUS, xen_sysdev, "xen-sysbus");
|
||||
qbus_set_bus_hotplug_handler(xen_sysbus);
|
||||
|
||||
return 0;
|
||||
xen_set_dynamic_sysbus();
|
||||
|
||||
err:
|
||||
qemu_set_fd_handler(xs_fileno(xenstore), NULL, NULL, NULL);
|
||||
xs_daemon_close(xenstore);
|
||||
xenstore = NULL;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void xen_set_dynamic_sysbus(void)
|
||||
{
|
||||
Object *machine = qdev_get_machine();
|
||||
ObjectClass *oc = object_get_class(machine);
|
||||
MachineClass *mc = MACHINE_CLASS(oc);
|
||||
|
||||
machine_class_allow_dynamic_sysbus_dev(mc, TYPE_XENSYSDEV);
|
||||
xen_be_register("console", &xen_console_ops);
|
||||
xen_be_register("vkbd", &xen_kbdmouse_ops);
|
||||
#ifdef CONFIG_VIRTFS
|
||||
xen_be_register("9pfs", &xen_9pfs_ops);
|
||||
#endif
|
||||
#ifdef CONFIG_USB_LIBUSB
|
||||
xen_be_register("qusb", &xen_usb_ops);
|
||||
#endif
|
||||
}
|
||||
|
||||
int xen_be_register(const char *type, struct XenDevOps *ops)
|
||||
|
@ -744,20 +746,6 @@ int xen_be_register(const char *type, struct XenDevOps *ops)
|
|||
return xenstore_scan(type, xen_domid, ops);
|
||||
}
|
||||
|
||||
void xen_be_register_common(void)
|
||||
{
|
||||
xen_set_dynamic_sysbus();
|
||||
|
||||
xen_be_register("console", &xen_console_ops);
|
||||
xen_be_register("vkbd", &xen_kbdmouse_ops);
|
||||
#ifdef CONFIG_VIRTFS
|
||||
xen_be_register("9pfs", &xen_9pfs_ops);
|
||||
#endif
|
||||
#ifdef CONFIG_USB_LIBUSB
|
||||
xen_be_register("qusb", &xen_usb_ops);
|
||||
#endif
|
||||
}
|
||||
|
||||
int xen_be_bind_evtchn(struct XenLegacyDevice *xendev)
|
||||
{
|
||||
if (xendev->local_port != -1) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue