From a404444a276a16cccd21a62db6428e0fd808f6d4 Mon Sep 17 00:00:00 2001 From: Michael S. Tsirkin Date: Wed, 19 Jan 2011 11:49:50 -0200 Subject: [PATCH 15/24] ioeventfd: error handling cleanup RH-Author: Michael S. Tsirkin Message-id: Patchwork-id: 16562 O-Subject: [PATCHv4 RHEL6.1 8/8] ioeventfd: error handling cleanup Bugzilla: 633394 RH-Acked-by: Christoph Hellwig RH-Acked-by: Alex Williamson RH-Acked-by: Jes Sorensen commit b36e391441906c36ed0856b69de84001860402bf Author: Michael S. Tsirkin Date: Tue Jan 11 14:10:15 2011 +0200 ioeventfd: error handling cleanup - Don't return status from start/stop functions where it's ignored - report errors to make debugging easier - assert on unexpected failures - don't disable notifiers on error so that we'll retry when guest driver restarts Signed-off-by: Michael S. Tsirkin Acked-by: Stefan Hajnoczi Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=633394 --- hw/virtio-pci.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) Signed-off-by: Luiz Capitulino --- hw/virtio-pci.c | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index 98f7f73..c2db1d1 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -192,12 +192,16 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, if (assign) { r = event_notifier_init(notifier, 1); if (r < 0) { + error_report("%s: unable to init event notifier: %d", + __func__, r); return r; } r = kvm_set_ioeventfd_pio_word(event_notifier_get_fd(notifier), proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY, n, assign); if (r < 0) { + error_report("%s: unable to map ioeventfd: %d", + __func__, r); event_notifier_cleanup(notifier); } } else { @@ -205,6 +209,8 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, proxy->addr + VIRTIO_PCI_QUEUE_NOTIFY, n, assign); if (r < 0) { + error_report("%s: unable to unmap ioeventfd: %d", + __func__, r); return r; } @@ -243,14 +249,14 @@ static void virtio_pci_set_host_notifier_fd_handler(VirtIOPCIProxy *proxy, } } -static int virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) +static void virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) { int n, r; if (!(proxy->flags & VIRTIO_PCI_FLAG_USE_IOEVENTFD) || proxy->ioeventfd_disabled || proxy->ioeventfd_started) { - return 0; + return; } for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { @@ -266,7 +272,7 @@ static int virtio_pci_start_ioeventfd(VirtIOPCIProxy *proxy) virtio_pci_set_host_notifier_fd_handler(proxy, n, true); } proxy->ioeventfd_started = true; - return 0; + return; assign_error: while (--n >= 0) { @@ -275,19 +281,20 @@ assign_error: } virtio_pci_set_host_notifier_fd_handler(proxy, n, false); - virtio_pci_set_host_notifier_internal(proxy, n, false); + r = virtio_pci_set_host_notifier_internal(proxy, n, false); + assert(r >= 0); } proxy->ioeventfd_started = false; - proxy->ioeventfd_disabled = true; - return r; + error_report("%s: failed. Fallback to a userspace (slower).", __func__); } -static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) +static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) { + int r; int n; if (!proxy->ioeventfd_started) { - return 0; + return; } for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) { @@ -296,10 +303,10 @@ static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy) } virtio_pci_set_host_notifier_fd_handler(proxy, n, false); - virtio_pci_set_host_notifier_internal(proxy, n, false); + r = virtio_pci_set_host_notifier_internal(proxy, n, false); + assert(r >= 0); } proxy->ioeventfd_started = false; - return 0; } static void virtio_pci_reset(DeviceState *d) @@ -784,7 +791,6 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, proxy->host_features |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY; proxy->host_features |= 0x1 << VIRTIO_F_BAD_FEATURE; proxy->host_features = vdev->get_features(vdev, proxy->host_features); - } static int virtio_blk_init_pci(PCIDevice *pci_dev) -- 1.7.4.rc1.16.gd2f15e