virtio: quick fix
Fixes a regression in virtio that's causing issues for many people. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJaaMBYAAoJECgfDbjSjVRpH9cH/izjScalZuvCN57+fqEtDW6C oudm+wWac91qAKY4U8UfWsR1Aph8bGqZKXwBPM7c/DTdzPAPjBmkY+P/E392wWAY 6IoJIRTyQUYhABuftWt61UV6+waEGDFXegGlgcse8JZ/ddD62v/9Bll78w4nfivE w5DvMBYPzVJV4N7Q7CiP3XOf4qHD9TNAd/s6wSdmPCLT0VztLYsjvrfwuEY58bTa i3W16BUV3R1SUGBq+EWG2LjAUfyUDleTyTVA6tI+hWbazPFHDFfZO9/xFsAfgTpv Wmx45OAhPwr8lVeatF9ljh1AxBQUiUHHBN8rRKljU5evEERS/4lrR/FXWdalEvI= =2+BS -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into staging virtio: quick fix Fixes a regression in virtio that's causing issues for many people. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> # gpg: Signature made Wed 24 Jan 2018 17:20:24 GMT # gpg: using RSA key 0x281F0DB8D28D5469 # gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>" # gpg: aka "Michael S. Tsirkin <mst@redhat.com>" # Primary key fingerprint: 0270 606B 6F3C DF3D 0B17 0970 C350 3912 AFBE 8E67 # Subkey fingerprint: 5D09 FD08 71C8 F85B 94CA 8A0D 281F 0DB8 D28D 5469 * remotes/mst/tags/for_upstream: Revert "qemu: add a cleanup callback function to EventNotifier" Revert "virtio: postpone the execution of event_notifier_cleanup function" Revert "virtio: improve virtio devices initialization time" Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
834a336eb9
@ -812,10 +812,6 @@ static void kvm_mem_ioeventfd_del(MemoryListener *listener,
|
|||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e->cleanup) {
|
|
||||||
e->cleanup(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kvm_io_ioeventfd_add(MemoryListener *listener,
|
static void kvm_io_ioeventfd_add(MemoryListener *listener,
|
||||||
|
@ -256,15 +256,6 @@ bool virtio_bus_ioeventfd_enabled(VirtioBusState *bus)
|
|||||||
return k->ioeventfd_assign && k->ioeventfd_enabled(proxy);
|
return k->ioeventfd_assign && k->ioeventfd_enabled(proxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_bus_cleanup_event_notifier(EventNotifier *notifier)
|
|
||||||
{
|
|
||||||
/* Test and clear notifier after disabling event,
|
|
||||||
* in case poll callback didn't have time to run.
|
|
||||||
*/
|
|
||||||
virtio_queue_host_notifier_read(notifier);
|
|
||||||
event_notifier_cleanup(notifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function switches ioeventfd on/off in the device.
|
* This function switches ioeventfd on/off in the device.
|
||||||
* The caller must set or clear the handlers for the EventNotifier.
|
* The caller must set or clear the handlers for the EventNotifier.
|
||||||
@ -292,13 +283,19 @@ int virtio_bus_set_host_notifier(VirtioBusState *bus, int n, bool assign)
|
|||||||
r = k->ioeventfd_assign(proxy, notifier, n, true);
|
r = k->ioeventfd_assign(proxy, notifier, n, true);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
error_report("%s: unable to assign ioeventfd: %d", __func__, r);
|
error_report("%s: unable to assign ioeventfd: %d", __func__, r);
|
||||||
virtio_bus_cleanup_event_notifier(notifier);
|
goto cleanup_event_notifier;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
notifier->cleanup = virtio_bus_cleanup_event_notifier;
|
|
||||||
k->ioeventfd_assign(proxy, notifier, n, false);
|
k->ioeventfd_assign(proxy, notifier, n, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup_event_notifier:
|
||||||
|
/* Test and clear notifier after disabling event,
|
||||||
|
* in case poll callback didn't have time to run.
|
||||||
|
*/
|
||||||
|
virtio_queue_host_notifier_read(notifier);
|
||||||
|
event_notifier_cleanup(notifier);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2574,7 +2574,6 @@ static int virtio_device_start_ioeventfd_impl(VirtIODevice *vdev)
|
|||||||
VirtioBusState *qbus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
VirtioBusState *qbus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
||||||
int n, r, err;
|
int n, r, err;
|
||||||
|
|
||||||
memory_region_transaction_begin();
|
|
||||||
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
|
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
|
||||||
VirtQueue *vq = &vdev->vq[n];
|
VirtQueue *vq = &vdev->vq[n];
|
||||||
if (!virtio_queue_get_num(vdev, n)) {
|
if (!virtio_queue_get_num(vdev, n)) {
|
||||||
@ -2597,7 +2596,6 @@ static int virtio_device_start_ioeventfd_impl(VirtIODevice *vdev)
|
|||||||
}
|
}
|
||||||
event_notifier_set(&vq->host_notifier);
|
event_notifier_set(&vq->host_notifier);
|
||||||
}
|
}
|
||||||
memory_region_transaction_commit();
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
assign_error:
|
assign_error:
|
||||||
@ -2611,7 +2609,6 @@ assign_error:
|
|||||||
r = virtio_bus_set_host_notifier(qbus, n, false);
|
r = virtio_bus_set_host_notifier(qbus, n, false);
|
||||||
assert(r >= 0);
|
assert(r >= 0);
|
||||||
}
|
}
|
||||||
memory_region_transaction_commit();
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2628,7 +2625,6 @@ static void virtio_device_stop_ioeventfd_impl(VirtIODevice *vdev)
|
|||||||
VirtioBusState *qbus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
VirtioBusState *qbus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev)));
|
||||||
int n, r;
|
int n, r;
|
||||||
|
|
||||||
memory_region_transaction_begin();
|
|
||||||
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
|
for (n = 0; n < VIRTIO_QUEUE_MAX; n++) {
|
||||||
VirtQueue *vq = &vdev->vq[n];
|
VirtQueue *vq = &vdev->vq[n];
|
||||||
|
|
||||||
@ -2639,7 +2635,6 @@ static void virtio_device_stop_ioeventfd_impl(VirtIODevice *vdev)
|
|||||||
r = virtio_bus_set_host_notifier(qbus, n, false);
|
r = virtio_bus_set_host_notifier(qbus, n, false);
|
||||||
assert(r >= 0);
|
assert(r >= 0);
|
||||||
}
|
}
|
||||||
memory_region_transaction_commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void virtio_device_stop_ioeventfd(VirtIODevice *vdev)
|
void virtio_device_stop_ioeventfd(VirtIODevice *vdev)
|
||||||
|
@ -26,7 +26,6 @@ struct EventNotifier {
|
|||||||
int rfd;
|
int rfd;
|
||||||
int wfd;
|
int wfd;
|
||||||
#endif
|
#endif
|
||||||
void (*cleanup)(EventNotifier *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void EventNotifierHandler(EventNotifier *);
|
typedef void EventNotifierHandler(EventNotifier *);
|
||||||
|
@ -29,7 +29,6 @@ void event_notifier_init_fd(EventNotifier *e, int fd)
|
|||||||
{
|
{
|
||||||
e->rfd = fd;
|
e->rfd = fd;
|
||||||
e->wfd = fd;
|
e->wfd = fd;
|
||||||
e->cleanup = NULL;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -66,7 +65,6 @@ int event_notifier_init(EventNotifier *e, int active)
|
|||||||
e->rfd = fds[0];
|
e->rfd = fds[0];
|
||||||
e->wfd = fds[1];
|
e->wfd = fds[1];
|
||||||
}
|
}
|
||||||
e->cleanup = NULL;
|
|
||||||
if (active) {
|
if (active) {
|
||||||
event_notifier_set(e);
|
event_notifier_set(e);
|
||||||
}
|
}
|
||||||
@ -82,11 +80,10 @@ void event_notifier_cleanup(EventNotifier *e)
|
|||||||
{
|
{
|
||||||
if (e->rfd != e->wfd) {
|
if (e->rfd != e->wfd) {
|
||||||
close(e->rfd);
|
close(e->rfd);
|
||||||
|
e->rfd = -1;
|
||||||
}
|
}
|
||||||
close(e->wfd);
|
close(e->wfd);
|
||||||
e->rfd = -1;
|
|
||||||
e->wfd = -1;
|
e->wfd = -1;
|
||||||
e->cleanup = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int event_notifier_get_fd(const EventNotifier *e)
|
int event_notifier_get_fd(const EventNotifier *e)
|
||||||
|
@ -19,7 +19,6 @@ int event_notifier_init(EventNotifier *e, int active)
|
|||||||
{
|
{
|
||||||
e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
assert(e->event);
|
assert(e->event);
|
||||||
e->cleanup = NULL;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ void event_notifier_cleanup(EventNotifier *e)
|
|||||||
{
|
{
|
||||||
CloseHandle(e->event);
|
CloseHandle(e->event);
|
||||||
e->event = NULL;
|
e->event = NULL;
|
||||||
e->cleanup = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE event_notifier_get_handle(EventNotifier *e)
|
HANDLE event_notifier_get_handle(EventNotifier *e)
|
||||||
|
Loading…
Reference in New Issue
Block a user