[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 07/17] hw/xen: add get_frontend_path() method to XenDeviceClas
From: |
David Woodhouse |
Subject: |
[PATCH v4 07/17] hw/xen: add get_frontend_path() method to XenDeviceClass |
Date: |
Mon, 6 Nov 2023 14:34:57 +0000 |
From: David Woodhouse <dwmw@amazon.co.uk>
The primary Xen console is special. The guest's side is set up for it by
the toolstack automatically and not by the standard PV init sequence.
Accordingly, its *frontend* doesn't appear in …/device/console/0 either;
instead it appears under …/console in the guest's XenStore node.
To allow the Xen console driver to override the frontend path for the
primary console, add a method to the XenDeviceClass which can be used
instead of the standard xen_device_get_frontend_path()
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
---
hw/xen/xen-bus.c | 11 ++++++++++-
include/hw/xen/xen-bus.h | 2 ++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index ece8ec40cd..12ff782005 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -711,8 +711,17 @@ static void xen_device_frontend_create(XenDevice *xendev,
Error **errp)
{
ERRP_GUARD();
XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
+ XenDeviceClass *xendev_class = XEN_DEVICE_GET_CLASS(xendev);
- xendev->frontend_path = xen_device_get_frontend_path(xendev);
+ if (xendev_class->get_frontend_path) {
+ xendev->frontend_path = xendev_class->get_frontend_path(xendev, errp);
+ if (!xendev->frontend_path) {
+ error_prepend(errp, "failed to create frontend: ");
+ return;
+ }
+ } else {
+ xendev->frontend_path = xen_device_get_frontend_path(xendev);
+ }
/*
* The frontend area may have already been created by a legacy
diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h
index f435898164..eb440880b5 100644
--- a/include/hw/xen/xen-bus.h
+++ b/include/hw/xen/xen-bus.h
@@ -33,6 +33,7 @@ struct XenDevice {
};
typedef struct XenDevice XenDevice;
+typedef char *(*XenDeviceGetFrontendPath)(XenDevice *xendev, Error **errp);
typedef char *(*XenDeviceGetName)(XenDevice *xendev, Error **errp);
typedef void (*XenDeviceRealize)(XenDevice *xendev, Error **errp);
typedef void (*XenDeviceFrontendChanged)(XenDevice *xendev,
@@ -46,6 +47,7 @@ struct XenDeviceClass {
/*< public >*/
const char *backend;
const char *device;
+ XenDeviceGetFrontendPath get_frontend_path;
XenDeviceGetName get_name;
XenDeviceRealize realize;
XenDeviceFrontendChanged frontend_changed;
--
2.34.1
- [PATCH v4 00/17] Get Xen PV shim running in QEMU, add net and console, David Woodhouse, 2023/11/06
- [PATCH v4 01/17] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer(), David Woodhouse, 2023/11/06
- [PATCH v4 04/17] i386/xen: advertise XEN_HVM_CPUID_UPCALL_VECTOR in CPUID, David Woodhouse, 2023/11/06
- [PATCH v4 02/17] hw/xen: Clean up event channel 'type_val' handling to use union, David Woodhouse, 2023/11/06
- [PATCH v4 03/17] include: update Xen public headers to Xen 4.17.2 release, David Woodhouse, 2023/11/06
- [PATCH v4 05/17] hw/xen: populate store frontend nodes with XenStore PFN/port, David Woodhouse, 2023/11/06
- [PATCH v4 06/17] hw/xen: automatically assign device index to block devices, David Woodhouse, 2023/11/06
- [PATCH v4 09/17] hw/xen: update Xen console to XenDevice model, David Woodhouse, 2023/11/06
- [PATCH v4 07/17] hw/xen: add get_frontend_path() method to XenDeviceClass,
David Woodhouse <=
- [PATCH v4 15/17] xen-platform: unplug AHCI disks, David Woodhouse, 2023/11/06
- [PATCH v4 08/17] hw/xen: do not repeatedly try to create a failing backend device, David Woodhouse, 2023/11/06
- [PATCH v4 12/17] hw/xen: update Xen PV NIC to XenDevice model, David Woodhouse, 2023/11/06
- [PATCH v4 10/17] hw/xen: add support for Xen primary console in emulated mode, David Woodhouse, 2023/11/06
- [PATCH v4 17/17] docs: update Xen-on-KVM documentation, David Woodhouse, 2023/11/06
- [PATCH v4 14/17] net: do not delete nics in net_cleanup(), David Woodhouse, 2023/11/06
- [PATCH v4 13/17] hw/i386/pc: support '-nic' for xen-net-device, David Woodhouse, 2023/11/06