From: Alex Williamson <alex.williamson@redhat.com>
To: qemu-devel@nongnu.org
Cc: Eric Auger <eric.auger@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PULL 05/19] vfio/pci: Pass an error object to vfio_intx_enable
Date: Mon, 17 Oct 2016 13:52:30 -0600 [thread overview]
Message-ID: <20161017195227.17307.85151.stgit@gimli.home> (raw)
In-Reply-To: <20161017194945.17307.78340.stgit@gimli.home>
From: Eric Auger <eric.auger@redhat.com>
Pass an error object to prepare for migration to VFIO-PCI realize.
The error object is propagated down to vfio_intx_enable_kvm().
The three other callers, vfio_intx_enable_kvm(), vfio_msi_disable_common()
and vfio_pci_post_reset() do not propagate the error and simply call
error_reportf_err() with the ERR_PREFIX formatting.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/pci.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 02e92b0..42161c8 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -100,7 +100,7 @@ static void vfio_intx_eoi(VFIODevice *vbasedev)
vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX);
}
-static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev)
+static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp)
{
#ifdef CONFIG_KVM
struct kvm_irqfd irqfd = {
@@ -126,7 +126,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev)
/* Get an eventfd for resample/unmask */
if (event_notifier_init(&vdev->intx.unmask, 0)) {
- error_report("vfio: Error: event_notifier_init failed eoi");
+ error_setg(errp, "event_notifier_init failed eoi");
goto fail;
}
@@ -134,7 +134,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev)
irqfd.resamplefd = event_notifier_get_fd(&vdev->intx.unmask);
if (kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd)) {
- error_report("vfio: Error: Failed to setup resample irqfd: %m");
+ error_setg_errno(errp, errno, "failed to setup resample irqfd");
goto fail_irqfd;
}
@@ -153,7 +153,7 @@ static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev)
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
g_free(irq_set);
if (ret) {
- error_report("vfio: Error: Failed to setup INTx unmask fd: %m");
+ error_setg_errno(errp, -ret, "failed to setup INTx unmask fd");
goto fail_vfio;
}
@@ -222,6 +222,7 @@ static void vfio_intx_update(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
PCIINTxRoute route;
+ Error *err = NULL;
if (vdev->interrupt != VFIO_INT_INTx) {
return;
@@ -244,18 +245,22 @@ static void vfio_intx_update(PCIDevice *pdev)
return;
}
- vfio_intx_enable_kvm(vdev);
+ vfio_intx_enable_kvm(vdev, &err);
+ if (err) {
+ error_reportf_err(err, WARN_PREFIX, vdev->vbasedev.name);
+ }
/* Re-enable the interrupt in cased we missed an EOI */
vfio_intx_eoi(&vdev->vbasedev);
}
-static int vfio_intx_enable(VFIOPCIDevice *vdev)
+static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp)
{
uint8_t pin = vfio_pci_read_config(&vdev->pdev, PCI_INTERRUPT_PIN, 1);
int ret, argsz;
struct vfio_irq_set *irq_set;
int32_t *pfd;
+ Error *err = NULL;
if (!pin) {
return 0;
@@ -279,7 +284,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev)
ret = event_notifier_init(&vdev->intx.interrupt, 0);
if (ret) {
- error_report("vfio: Error: event_notifier_init failed");
+ error_setg_errno(errp, -ret, "event_notifier_init failed");
return ret;
}
@@ -299,13 +304,16 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev)
ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_SET_IRQS, irq_set);
g_free(irq_set);
if (ret) {
- error_report("vfio: Error: Failed to setup INTx fd: %m");
+ error_setg_errno(errp, -ret, "failed to setup INTx fd");
qemu_set_fd_handler(*pfd, NULL, NULL, vdev);
event_notifier_cleanup(&vdev->intx.interrupt);
return -errno;
}
- vfio_intx_enable_kvm(vdev);
+ vfio_intx_enable_kvm(vdev, &err);
+ if (err) {
+ error_reportf_err(err, WARN_PREFIX, vdev->vbasedev.name);
+ }
vdev->interrupt = VFIO_INT_INTx;
@@ -707,6 +715,7 @@ retry:
static void vfio_msi_disable_common(VFIOPCIDevice *vdev)
{
+ Error *err = NULL;
int i;
for (i = 0; i < vdev->nr_vectors; i++) {
@@ -726,7 +735,10 @@ static void vfio_msi_disable_common(VFIOPCIDevice *vdev)
vdev->nr_vectors = 0;
vdev->interrupt = VFIO_INT_NONE;
- vfio_intx_enable(vdev);
+ vfio_intx_enable(vdev, &err);
+ if (err) {
+ error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name);
+ }
}
static void vfio_msix_disable(VFIOPCIDevice *vdev)
@@ -1908,7 +1920,12 @@ static void vfio_pci_pre_reset(VFIOPCIDevice *vdev)
static void vfio_pci_post_reset(VFIOPCIDevice *vdev)
{
- vfio_intx_enable(vdev);
+ Error *err = NULL;
+
+ vfio_intx_enable(vdev, &err);
+ if (err) {
+ error_reportf_err(err, ERR_PREFIX, vdev->vbasedev.name);
+ }
}
static bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
@@ -2724,7 +2741,7 @@ static int vfio_initfn(PCIDevice *pdev)
vdev->intx.mmap_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL,
vfio_intx_mmap_enable, vdev);
pci_device_set_intx_routing_notifier(&vdev->pdev, vfio_intx_update);
- ret = vfio_intx_enable(vdev);
+ ret = vfio_intx_enable(vdev, &err);
if (ret) {
goto out_teardown;
}
next prev parent reply other threads:[~2016-10-17 19:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 19:51 [Qemu-devel] [PULL 00/19] VFIO updates 2016-10-17 Alex Williamson
2016-10-17 19:51 ` [Qemu-devel] [PULL 01/19] vfio/pci: Use local error object in vfio_initfn Alex Williamson
2016-10-17 19:52 ` [Qemu-devel] [PULL 02/19] vfio/pci: Pass an error object to vfio_populate_vga Alex Williamson
2016-10-17 19:52 ` [Qemu-devel] [PULL 03/19] vfio/pci: Pass an error object to vfio_populate_device Alex Williamson
2016-10-17 19:52 ` [Qemu-devel] [PULL 04/19] vfio/pci: Pass an error object to vfio_msix_early_setup Alex Williamson
2016-10-17 19:52 ` Alex Williamson [this message]
2016-10-17 19:52 ` [Qemu-devel] [PULL 06/19] vfio/pci: Pass an error object to vfio_add_capabilities Alex Williamson
2016-10-17 19:52 ` [Qemu-devel] [PULL 07/19] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init Alex Williamson
2016-10-17 19:52 ` [Qemu-devel] [PULL 08/19] vfio: Pass an Error object to vfio_connect_container Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 09/19] vfio: Pass an error object to vfio_get_group Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 10/19] vfio: Pass an error object to vfio_get_device Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 11/19] vfio/platform: Pass an error object to vfio_populate_device Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 12/19] vfio/platform: fix a wrong returned value in vfio_populate_device Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 13/19] vfio/platform: Pass an error object to vfio_base_device_init Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 14/19] vfio/pci: Conversion to realize Alex Williamson
2016-10-17 19:53 ` [Qemu-devel] [PULL 15/19] vfio/pci: Remove vfio_msix_early_setup returned value Alex Williamson
2016-10-17 19:54 ` [Qemu-devel] [PULL 16/19] vfio/pci: Remove vfio_populate_device " Alex Williamson
2016-10-17 19:54 ` [Qemu-devel] [PULL 17/19] vfio/pci: Handle host oversight Alex Williamson
2016-10-17 19:54 ` [Qemu-devel] [PULL 18/19] vfio/pci: Fix vfio_rtl8168_quirk_data_read address offset Alex Williamson
2016-10-17 19:54 ` [Qemu-devel] [PULL 19/19] vfio: fix duplicate function call Alex Williamson
2016-10-18 11:34 ` [Qemu-devel] [PULL 00/19] VFIO updates 2016-10-17 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161017195227.17307.85151.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=eric.auger@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).