|
|
9ae3a8 |
From 9f8e26c9d8485647072b2cbe7848b8d0054597c6 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 29 Sep 2017 21:45:31 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 11/27] vfio/pci: Handle host oversight
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20170929214531.16765.45212.stgit@gimli.home>
|
|
|
9ae3a8 |
Patchwork-id: 76769
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.5 qemu-kvm PATCH 11/16] vfio/pci: Handle host oversight
|
|
|
9ae3a8 |
Bugzilla: 1494181
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Eric Auger <eric.auger@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Upstream: 4a946268504e72fe0c547b9dda97adbe277a585f
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
In case the end-user calls qemu with -vfio-pci option without passing
|
|
|
9ae3a8 |
either sysfsdev or host property value, the device is interpreted as
|
|
|
9ae3a8 |
0000:00:00.0. Let's create a specific error message to guide the end-user.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Eric Auger <eric.auger@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/misc/vfio.c | 13 +++++++++++++
|
|
|
9ae3a8 |
1 file changed, 13 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
|
|
|
9ae3a8 |
index 0af8613..a95bbaf 100644
|
|
|
9ae3a8 |
--- a/hw/misc/vfio.c
|
|
|
9ae3a8 |
+++ b/hw/misc/vfio.c
|
|
|
9ae3a8 |
@@ -3864,6 +3864,13 @@ static int vfio_initfn(PCIDevice *pdev)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (!vdev->vbasedev.sysfsdev) {
|
|
|
9ae3a8 |
+ if (!(~vdev->host.domain || ~vdev->host.bus ||
|
|
|
9ae3a8 |
+ ~vdev->host.slot || ~vdev->host.function)) {
|
|
|
9ae3a8 |
+ error_report("No provided host device - "
|
|
|
9ae3a8 |
+ "Use -vfio-pci,host=DDDD:BB:DD.F "
|
|
|
9ae3a8 |
+ "or -vfio-pci,sysfsdev=PATH_TO_DEVICE");
|
|
|
9ae3a8 |
+ return -EINVAL;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
vdev->vbasedev.sysfsdev =
|
|
|
9ae3a8 |
g_strdup_printf("/sys/bus/pci/devices/%04x:%02x:%02x.%01x",
|
|
|
9ae3a8 |
vdev->host.domain, vdev->host.bus,
|
|
|
9ae3a8 |
@@ -4062,6 +4069,12 @@ post_reset:
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void vfio_instance_init(Object *obj)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
+ VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, PCI_DEVICE(obj));
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ vdev->host.domain = ~0U;
|
|
|
9ae3a8 |
+ vdev->host.bus = ~0U;
|
|
|
9ae3a8 |
+ vdev->host.slot = ~0U;
|
|
|
9ae3a8 |
+ vdev->host.function = ~0U;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static Property vfio_pci_dev_properties[] = {
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|