diff options
author | Eric Auger <eric.auger@redhat.com> | 2016-10-17 10:58:02 -0600 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2016-10-17 10:58:02 -0600 |
commit | 4a946268504e72fe0c547b9dda97adbe277a585f (patch) | |
tree | 4f91362ab0ecb0e9d966540a8074e7991a1b212b /hw | |
parent | e04cff9d975389b83d59b89cc3904b20ae0b4ce1 (diff) |
vfio/pci: Handle host oversight
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 <eric.auger@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/vfio/pci.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 6d013249fc..fef436a1de 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[] = { |