[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/27] hw/xen: Avoid crash when backend watch fires too early
From: |
David Woodhouse |
Subject: |
[PULL 18/27] hw/xen: Avoid crash when backend watch fires too early |
Date: |
Tue, 7 Mar 2023 18:26:58 +0000 |
From: Paul Durrant <pdurrant@amazon.com>
The xen-block code ends up calling aio_poll() through blkconf_geometry(),
which means we see watch events during the indirect call to
xendev_class->realize() in xen_device_realize(). Unfortunately this call
is made before populating the initial frontend and backend device nodes
in xenstore and hence xen_block_frontend_changed() (which is called from
a watch event) fails to read the frontend's 'state' node, and hence
believes the device is being torn down. This in-turn sets the backend
state to XenbusStateClosed and causes the device to be deleted before it
is fully set up, leading to the crash.
By simply moving the call to xendev_class->realize() after the initial
xenstore nodes are populated, this sorry state of affairs is avoided.
Reported-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
---
hw/xen/xen-bus.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
index 9fe54967d4..c59850b1de 100644
--- a/hw/xen/xen-bus.c
+++ b/hw/xen/xen-bus.c
@@ -1034,13 +1034,6 @@ static void xen_device_realize(DeviceState *dev, Error
**errp)
goto unrealize;
}
- if (xendev_class->realize) {
- xendev_class->realize(xendev, errp);
- if (*errp) {
- goto unrealize;
- }
- }
-
xen_device_backend_printf(xendev, "frontend", "%s",
xendev->frontend_path);
xen_device_backend_printf(xendev, "frontend-id", "%u",
@@ -1059,6 +1052,13 @@ static void xen_device_realize(DeviceState *dev, Error
**errp)
xen_device_frontend_set_state(xendev, XenbusStateInitialising, true);
}
+ if (xendev_class->realize) {
+ xendev_class->realize(xendev, errp);
+ if (*errp) {
+ goto unrealize;
+ }
+ }
+
xendev->exit.notify = xen_device_exit;
qemu_add_exit_notifier(&xendev->exit);
return;
--
2.39.0
- [PULL 24/27] hw/xen: Implement soft reset for emulated gnttab, (continued)
- [PULL 24/27] hw/xen: Implement soft reset for emulated gnttab, David Woodhouse, 2023/03/07
- [PULL 07/27] hw/xen: Implement core serialize/deserialize methods for xenstore_impl, David Woodhouse, 2023/03/07
- [PULL 15/27] hw/xen: Use XEN_PAGE_SIZE in PV backend drivers, David Woodhouse, 2023/03/07
- [PULL 06/27] hw/xen: Implement XenStore permissions, David Woodhouse, 2023/03/07
- [PULL 08/27] hw/xen: Create initial XenStore nodes, David Woodhouse, 2023/03/07
- [PULL 14/27] hw/xen: Move xenstore_store_pv_console_info to xen_console.c, David Woodhouse, 2023/03/07
- [PULL 23/27] hw/xen: Map guest XENSTORE_PFN grant in emulated Xenstore, David Woodhouse, 2023/03/07
- [PULL 04/27] hw/xen: Implement XenStore transactions, David Woodhouse, 2023/03/07
- [PULL 21/27] hw/xen: Add emulated implementation of grant table operations, David Woodhouse, 2023/03/07
- [PULL 12/27] hw/xen: Add foreignmem operations to allow redirection to internal emulation, David Woodhouse, 2023/03/07
- [PULL 18/27] hw/xen: Avoid crash when backend watch fires too early,
David Woodhouse <=
- [PULL 16/27] hw/xen: Rename xen_common.h to xen_native.h, David Woodhouse, 2023/03/07
- [PULL 17/27] hw/xen: Build PV backend drivers for CONFIG_XEN_BUS, David Woodhouse, 2023/03/07
- [PULL 25/27] i386/xen: Initialize Xen backends from pc_basic_device_init() for emulation, David Woodhouse, 2023/03/07
- [PULL 26/27] MAINTAINERS: Add entry for Xen on KVM emulation, David Woodhouse, 2023/03/07
- [PULL 27/27] docs: Update Xen-on-KVM documentation for PV disk support, David Woodhouse, 2023/03/07
- Re: [PULL 00/27] Enable PV backends with Xen/KVM emulation, Philippe Mathieu-Daudé, 2023/03/07
- Re: [PULL 00/27] Enable PV backends with Xen/KVM emulation, Peter Maydell, 2023/03/09