[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 3/6] xen: decouple generic xen code from legacy backends codeb
From: |
Volodymyr Babchuk |
Subject: |
[PATCH v4 3/6] xen: decouple generic xen code from legacy backends codebase |
Date: |
Sat, 2 Dec 2023 01:41:22 +0000 |
In xen-all.c there are unneeded dependencies on xen-legacy-backend.c:
- xen_init() uses xen_pv_printf() to report errors, but it does not
provide a pointer to the struct XenLegacyDevice, so it is kind of
useless, we can use standard error_report() instead.
- xen-all.c has function xenstore_record_dm_state() which uses global
variable "xenstore" defined and initialized in xen-legacy-backend.c
It is used exactly once, so we can just open a new connection to the
xenstore, update DM state and close connection back.
Those two changes allows us to remove xen-legacy-backend.c at all,
what should be done in the future anyways. But right now this patch
moves us one step close to have QEMU build without legacy Xen
backends.
Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
---
In v4:
- New in v4, previous was part of "xen: add option to disable legacy
backends"
- Do not move xenstore global variable from xen-legacy-backend.c,
instead use a local variable.
---
accel/xen/xen-all.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/accel/xen/xen-all.c b/accel/xen/xen-all.c
index 5ff0cb8bd9..6c2342581f 100644
--- a/accel/xen/xen-all.c
+++ b/accel/xen/xen-all.c
@@ -33,12 +33,20 @@ xendevicemodel_handle *xen_dmod;
static void xenstore_record_dm_state(const char *state)
{
char path[50];
+ struct qemu_xs_handle *xsh = qemu_xen_xs_open();
+
+ if (!xsh) {
+ error_report("error opening xenstore");
+ exit(1);
+ }
snprintf(path, sizeof (path), "device-model/%u/state", xen_domid);
- if (!qemu_xen_xs_write(xenstore, XBT_NULL, path, state, strlen(state))) {
+ if (!qemu_xen_xs_write(xsh, XBT_NULL, path, state, strlen(state))) {
error_report("error recording dm state");
exit(1);
}
+
+ qemu_xen_xs_close(xsh);
}
@@ -80,18 +88,18 @@ static int xen_init(MachineState *ms)
xen_xc = xc_interface_open(0, 0, 0);
if (xen_xc == NULL) {
- xen_pv_printf(NULL, 0, "can't open xen interface\n");
+ error_report("can't open xen interface\n");
return -1;
}
xen_fmem = xenforeignmemory_open(0, 0);
if (xen_fmem == NULL) {
- xen_pv_printf(NULL, 0, "can't open xen fmem interface\n");
+ error_report("can't open xen fmem interface\n");
xc_interface_close(xen_xc);
return -1;
}
xen_dmod = xendevicemodel_open(0, 0);
if (xen_dmod == NULL) {
- xen_pv_printf(NULL, 0, "can't open xen devicemodel interface\n");
+ error_report("can't open xen devicemodel interface\n");
xenforeignmemory_close(xen_fmem);
xc_interface_close(xen_xc);
return -1;
--
2.42.0
- [PATCH v4 0/6] xen-arm: add support for virtio-pci, Volodymyr Babchuk, 2023/12/01
- [PATCH v4 3/6] xen: decouple generic xen code from legacy backends codebase,
Volodymyr Babchuk <=
- [PATCH v4 5/6] xen_arm: set mc->max_cpus to GUEST_MAX_VCPUS, Volodymyr Babchuk, 2023/12/01
- [PATCH v4 6/6] xen_arm: Add virtual PCIe host bridge support, Volodymyr Babchuk, 2023/12/01
- [PATCH v4 2/6] xen: backends: don't overwrite XenStore nodes created by toolstack, Volodymyr Babchuk, 2023/12/01
- [PATCH v4 1/6] hw/xen: Set XenBackendInstance in the XenDevice before realizing it, Volodymyr Babchuk, 2023/12/01
- [RFC PATCH v4 4/6] xen: add option to disable legacy backends, Volodymyr Babchuk, 2023/12/01