[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/28] hw/xen: fix XenStore watch delivery to guest
|
From: |
David Woodhouse |
|
Subject: |
[PATCH v3 05/28] hw/xen: fix XenStore watch delivery to guest |
|
Date: |
Wed, 25 Oct 2023 15:50:19 +0100 |
From: David Woodhouse <dwmw@amazon.co.uk>
When fire_watch_cb() found the response buffer empty, it would call
deliver_watch() to generate the XS_WATCH_EVENT message in the response
buffer and send an event channel notification to the guest… without
actually *copying* the response buffer into the ring. So there was
nothing for the guest to see. The pending response didn't actually get
processed into the ring until the guest next triggered some activity
from its side.
Add the missing call to put_rsp().
It might have been slightly nicer to call xen_xenstore_event() here,
which would *almost* have worked. Except for the fact that it calls
xen_be_evtchn_pending() to check that it really does have an event
pending (and clear the eventfd for next time). And under Xen it's
defined that setting that fd to O_NONBLOCK isn't guaranteed to work,
so the emu implementation follows suit.
This fixes Xen device hot-unplug.
Fixes: 0254c4d19df ("hw/xen: Add xenstore wire implementation and
implementation stubs")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
hw/i386/kvm/xen_xenstore.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/hw/i386/kvm/xen_xenstore.c b/hw/i386/kvm/xen_xenstore.c
index 660d0b72f9..8e716a7009 100644
--- a/hw/i386/kvm/xen_xenstore.c
+++ b/hw/i386/kvm/xen_xenstore.c
@@ -1357,10 +1357,12 @@ static void fire_watch_cb(void *opaque, const char
*path, const char *token)
} else {
deliver_watch(s, path, token);
/*
- * If the message was queued because there was already ring activity,
- * no need to wake the guest. But if not, we need to send the evtchn.
+ * Attempt to queue the message into the actual ring, and send
+ * the event channel notification if any bytes are copied.
*/
- xen_be_evtchn_notify(s->eh, s->be_port);
+ if (s->rsp_pending && put_rsp(s) > 0) {
+ xen_be_evtchn_notify(s->eh, s->be_port);
+ }
}
}
--
2.40.1
- [PATCH v3 26/28] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), (continued)
- [PATCH v3 26/28] hw/i386/pc: use qemu_get_nic_info() and pci_init_nic_devices(), David Woodhouse, 2023/10/25
- [PATCH v3 23/28] net: report list of available models according to platform, David Woodhouse, 2023/10/25
- [PATCH v3 27/28] hw/xen: use qemu_create_nic_bus_devices() to instantiate Xen NICs, David Woodhouse, 2023/10/25
- [PATCH v3 22/28] net: add qemu_{configure, create}_nic_device(), qemu_find_nic_info(), David Woodhouse, 2023/10/25
- [PATCH v3 18/28] hw/xen: only remove peers of PCI NICs on unplug, David Woodhouse, 2023/10/25
- [PATCH v3 17/28] hw/xen: add support for Xen primary console in emulated mode, David Woodhouse, 2023/10/25
- [PATCH v3 05/28] hw/xen: fix XenStore watch delivery to guest,
David Woodhouse <=
- [PATCH v3 12/28] hw/xen: populate store frontend nodes with XenStore PFN/port, David Woodhouse, 2023/10/25
- [PATCH v3 09/28] hw/xen: Clean up event channel 'type_val' handling to use union, David Woodhouse, 2023/10/25
- [PATCH v3 20/28] net: do not delete nics in net_cleanup(), David Woodhouse, 2023/10/25
- [PATCH v3 08/28] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer(), David Woodhouse, 2023/10/25
- [PATCH v3 10/28] include: update Xen public headers to Xen 4.17.2 release, David Woodhouse, 2023/10/25
- [PATCH v3 24/28] net: add qemu_create_nic_bus_devices(), David Woodhouse, 2023/10/25