[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/19] vfio/pci: Handle host oversight
From: |
Alex Williamson |
Subject: |
[Qemu-devel] [PULL 17/19] vfio/pci: Handle host oversight |
Date: |
Mon, 17 Oct 2016 13:54:11 -0600 |
User-agent: |
StGit/0.17.1-dirty |
From: Eric Auger <address@hidden>
In case the end-user calls qemu with -vfio-pci option without passing
either sysfsdev or host property value, the device is interpreted as
0000:00:00.0. Let's create a specific error message to guide the end-user.
Signed-off-by: Eric Auger <address@hidden>
Reviewed-by: Markus Armbruster <address@hidden>
Signed-off-by: Alex Williamson <address@hidden>
---
hw/vfio/pci.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 6d01324..fef436a 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2520,6 +2520,13 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
int i, ret;
if (!vdev->vbasedev.sysfsdev) {
+ if (!(~vdev->host.domain || ~vdev->host.bus ||
+ ~vdev->host.slot || ~vdev->host.function)) {
+ error_setg(errp, "No provided host device");
+ error_append_hint(errp, "Use -vfio-pci,host=DDDD:BB:DD.F "
+ "or -vfio-pci,sysfsdev=PATH_TO_DEVICE\n");
+ return;
+ }
vdev->vbasedev.sysfsdev =
g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%01x",
vdev->host.domain, vdev->host.bus,
@@ -2828,6 +2835,10 @@ static void vfio_instance_init(Object *obj)
device_add_bootindex_property(obj, &vdev->bootindex,
"bootindex", NULL,
&pci_dev->qdev, NULL);
+ vdev->host.domain = ~0U;
+ vdev->host.bus = ~0U;
+ vdev->host.slot = ~0U;
+ vdev->host.function = ~0U;
}
static Property vfio_pci_dev_properties[] = {
- [Qemu-devel] [PULL 07/19] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init, (continued)
- [Qemu-devel] [PULL 07/19] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 08/19] vfio: Pass an Error object to vfio_connect_container, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 09/19] vfio: Pass an error object to vfio_get_group, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 10/19] vfio: Pass an error object to vfio_get_device, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 11/19] vfio/platform: Pass an error object to vfio_populate_device, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 12/19] vfio/platform: fix a wrong returned value in vfio_populate_device, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 13/19] vfio/platform: Pass an error object to vfio_base_device_init, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 14/19] vfio/pci: Conversion to realize, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 15/19] vfio/pci: Remove vfio_msix_early_setup returned value, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 16/19] vfio/pci: Remove vfio_populate_device returned value, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 17/19] vfio/pci: Handle host oversight,
Alex Williamson <=
- [Qemu-devel] [PULL 18/19] vfio/pci: Fix vfio_rtl8168_quirk_data_read address offset, Alex Williamson, 2016/10/17
- [Qemu-devel] [PULL 19/19] vfio: fix duplicate function call, Alex Williamson, 2016/10/17
- Re: [Qemu-devel] [PULL 00/19] VFIO updates 2016-10-17, Peter Maydell, 2016/10/18