[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 09/38] pci-assign: make assign_failed_examine() just
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PULL 09/38] pci-assign: make assign_failed_examine() just format the cause |
Date: |
Thu, 8 May 2014 14:52:33 -0400 |
From: Laszlo Ersek <address@hidden>
This allows us to report the entire error with one error_report() call,
easing future error propagation.
Signed-off-by: Laszlo Ersek <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Luiz Capitulino <address@hidden>
---
hw/i386/kvm/pci-assign.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index bfce97f..6b8db25 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -731,7 +731,12 @@ static void free_assigned_device(AssignedDevice *dev)
free_msi_virqs(dev);
}
-static void assign_failed_examine(AssignedDevice *dev)
+/* This function tries to determine the cause of the PCI assignment failure. It
+ * always returns the cause as a dynamically allocated, human readable string.
+ * If the function fails to determine the cause for any internal reason, then
+ * the returned string will state that fact.
+ */
+static char *assign_failed_examine(const AssignedDevice *dev)
{
char name[PATH_MAX], dir[PATH_MAX], driver[PATH_MAX] = {}, *ns;
uint16_t vendor_id, device_id;
@@ -761,8 +766,8 @@ static void assign_failed_examine(AssignedDevice *dev)
goto fail;
}
- error_printf("*** The driver '%s' is occupying your device "
- "%04x:%02x:%02x.%x.\n"
+ return g_strdup_printf(
+ "*** The driver '%s' is occupying your device %04x:%02x:%02x.%x.\n"
"***\n"
"*** You can try the following commands to free it:\n"
"***\n"
@@ -778,10 +783,8 @@ static void assign_failed_examine(AssignedDevice *dev)
ns, dev->host.domain, dev->host.bus, dev->host.slot,
dev->host.function, vendor_id, device_id);
- return;
-
fail:
- error_report("Couldn't find out why.");
+ return g_strdup("Couldn't find out why.");
}
static int assign_device(AssignedDevice *dev)
@@ -810,14 +813,19 @@ static int assign_device(AssignedDevice *dev)
r = kvm_device_pci_assign(kvm_state, &dev->host, flags, &dev->dev_id);
if (r < 0) {
- error_report("Failed to assign device \"%s\" : %s",
- dev->dev.qdev.id, strerror(-r));
-
switch (r) {
- case -EBUSY:
- assign_failed_examine(dev);
+ case -EBUSY: {
+ char *cause;
+
+ cause = assign_failed_examine(dev);
+ error_report("Failed to assign device \"%s\" : %s\n%s",
+ dev->dev.qdev.id, strerror(-r), cause);
+ g_free(cause);
break;
+ }
default:
+ error_report("Failed to assign device \"%s\" : %s",
+ dev->dev.qdev.id, strerror(-r));
break;
}
}
--
1.9.0
- [Qemu-devel] [PULL 07/38] monitor: add Error-propagating monitor_handle_fd_param2(), (continued)
- [Qemu-devel] [PULL 07/38] monitor: add Error-propagating monitor_handle_fd_param2(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 08/38] pci-assign: accept Error from monitor_handle_fd_param2(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 05/38] qapi: treat all negative return of strtosz_suffix() as error, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 11/38] pci-assign: propagate Error from check_irqchip_in_kernel(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 10/38] pci-assign: propagate errors from get_real_id(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 14/38] pci-assign: assignment should fail if we can't read config space, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 12/38] pci: add Error-propagating pci_add_capability2(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 13/38] pci-assign: accept Error from pci_add_capability2(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 15/38] pci-assign: propagate errors from get_real_device(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 16/38] pci-assign: propagate errors from assigned_device_pci_cap_init(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 09/38] pci-assign: make assign_failed_examine() just format the cause,
Luiz Capitulino <=
- [Qemu-devel] [PULL 18/38] pci-assign: propagate errors from assigned_dev_register_regions(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 17/38] pci-assign: propagate errors from assigned_dev_register_msix_mmio(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 19/38] pci-assign: propagate errors from assign_device(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 20/38] pci-assign: propagate errors from assign_intx(), Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 21/38] pci-assign: assigned_initfn(): set monitor error in common error handler, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 23/38] qga: Consistently name Error ** objects errp, and not err, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 22/38] qmp hmp: Consistently name Error * objects err, and not errp, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 24/38] qmp: Consistently name Error ** objects errp, and not err, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 25/38] error: Consistently name Error ** objects errp, and not err, Luiz Capitulino, 2014/05/08
- [Qemu-devel] [PULL 27/38] hmp: Guard against misuse of hmp_handle_error(), Luiz Capitulino, 2014/05/08