[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/12] hw/xen: automatically assign device index to console devic
From: |
David Woodhouse |
Subject: |
[PATCH 10/12] hw/xen: automatically assign device index to console devices |
Date: |
Mon, 16 Oct 2023 16:19:07 +0100 |
From: David Woodhouse <dwmw@amazon.co.uk>
Now that we can reliably tell whether a given device already exists, we
can allow the user to add console devices on the command line with just
'-device xen-console,chardev=foo'.
Start at 1, because we can't add the *primary* console; that's special
because the toolstack has to set up the guest end of that.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/char/xen_console.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c
index 2825b8c511..1a0f5ed3e1 100644
--- a/hw/char/xen_console.c
+++ b/hw/char/xen_console.c
@@ -333,6 +333,22 @@ static char *xen_console_get_name(XenDevice *xendev, Error
**errp)
{
XenConsole *con = XEN_CONSOLE_DEVICE(xendev);
+ if (con->dev == -1) {
+ char name[11];
+ int idx = 1;
+
+ /* Theoretically we could go up to INT_MAX here but that's overkill */
+ while (idx < 100) {
+ snprintf(name, sizeof(name), "%u", idx);
+ if (!xen_backend_exists("console", name)) {
+ con->dev = idx;
+ return g_strdup(name);
+ }
+ idx++;
+ }
+ error_setg(errp, "cannot find device index for console device");
+ return NULL;
+ }
return g_strdup_printf("%u", con->dev);
}
--
2.40.1
- [PATCH 0/12] Get Xen PV shim running in qemu, David Woodhouse, 2023/10/16
- [PATCH 10/12] hw/xen: automatically assign device index to console devices,
David Woodhouse <=
- [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, David Woodhouse, 2023/10/16
- Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, Paul Durrant, 2023/10/24
- Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, David Woodhouse, 2023/10/24
- Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, Paul Durrant, 2023/10/24
- Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, David Woodhouse, 2023/10/24
- Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, Paul Durrant, 2023/10/24
- Re: [PATCH 06/12] hw/xen: add get_frontend_path() method to XenDeviceClass, David Woodhouse, 2023/10/25
[PATCH 07/12] hw/xen: update Xen console to XenDevice model, David Woodhouse, 2023/10/16
[PATCH 01/12] i386/xen: fix per-vCPU upcall vector for Xen emulation, David Woodhouse, 2023/10/16