hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs

When instantiating XenBus itself, for each NIC which is configured with
either the model unspecified, or set to to "xen" or "xen-net-device",
create a corresponding xen-net-device for it.

Now we can revert the previous more hackish version which relied on the
platform code explicitly registering the NICs on its own XenBus, having
returned the BusState* from xen_bus_init() itself.

This also fixes the setup for Xen PV guests, which was previously broken
in various ways and never actually managed to peer with the netdev.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
David Woodhouse 2023-10-17 17:53:58 +01:00
parent 8d39f9ba14
commit 7d6eff13b3
9 changed files with 10 additions and 54 deletions

View file

@ -19,6 +19,7 @@
#include "qapi/error.h"
#include "qapi/qmp/qdict.h"
#include "sysemu/sysemu.h"
#include "net/net.h"
#include "trace.h"
static char *xen_device_get_backend_path(XenDevice *xendev)
@ -1133,7 +1134,7 @@ static void xen_register_types(void)
type_init(xen_register_types)
BusState *xen_bus_init(void)
void xen_bus_init(void)
{
DeviceState *dev = qdev_new(TYPE_XEN_BRIDGE);
BusState *bus = qbus_new(TYPE_XEN_BUS, dev, NULL);
@ -1141,5 +1142,6 @@ BusState *xen_bus_init(void)
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
qbus_set_bus_hotplug_handler(bus);
return bus;
qemu_create_nic_bus_devices(bus, TYPE_XEN_DEVICE, "xen-net-device",
"xen", "xen-net-device");
}