qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: eric.auger@redhat.com, eric.auger.pro@gmail.com,
	qemu-devel@nongnu.org, alex.williamson@redhat.com,
	armbru@redhat.com
Cc: david@gibson.dropbear.id.au
Subject: [Qemu-devel] [PATCH v5 17/17] vfio/pci: Handle host oversight
Date: Thu,  6 Oct 2016 16:07:38 +0000	[thread overview]
Message-ID: <1475770058-20409-18-git-send-email-eric.auger@redhat.com> (raw)
In-Reply-To: <1475770058-20409-1-git-send-email-eric.auger@redhat.com>

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>

---
---
 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[] = {
-- 
1.9.1

  parent reply	other threads:[~2016-10-06 16:08 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-06 16:07 [Qemu-devel] [PATCH v5 00/17] Convert VFIO-PCI to realize Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 01/17] vfio/pci: Use local error object in vfio_initfn Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 02/17] vfio/pci: Pass an error object to vfio_populate_vga Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 03/17] vfio/pci: Pass an error object to vfio_populate_device Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 04/17] vfio/pci: Pass an error object to vfio_msix_early_setup Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 05/17] vfio/pci: Pass an error object to vfio_intx_enable Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 06/17] vfio/pci: Pass an error object to vfio_add_capabilities Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 07/17] vfio/pci: Pass an error object to vfio_pci_igd_opregion_init Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 08/17] vfio: Pass an Error object to vfio_connect_container Eric Auger
2016-10-07  7:01   ` Markus Armbruster
2016-10-07  7:36     ` Auger Eric
2016-10-10  2:02       ` Alexey Kardashevskiy
2016-10-10  5:34       ` David Gibson
2016-10-10  7:44         ` Auger Eric
2016-10-10 12:36           ` Markus Armbruster
2016-10-10 13:21             ` Auger Eric
2016-10-10 13:36               ` David Gibson
2016-10-10 15:27                 ` Markus Armbruster
2016-10-11  3:04             ` David Gibson
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 09/17] vfio: Pass an error object to vfio_get_group Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 10/17] vfio: Pass an error object to vfio_get_device Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 11/17] vfio/platform: Pass an error object to vfio_populate_device Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 12/17] vfio/platform: fix a wrong returned value in vfio_populate_device Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 13/17] vfio/platform: Pass an error object to vfio_base_device_init Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 14/17] vfio/pci: Conversion to realize Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 15/17] vfio/pci: Remove vfio_msix_early_setup returned value Eric Auger
2016-10-06 16:07 ` [Qemu-devel] [PATCH v5 16/17] vfio/pci: Remove vfio_populate_device " Eric Auger
2016-10-06 16:07 ` Eric Auger [this message]
2016-10-07  7:17 ` [Qemu-devel] [PATCH v5 00/17] Convert VFIO-PCI to realize Markus Armbruster
2016-10-11  2:07 ` no-reply

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=1475770058-20409-18-git-send-email-eric.auger@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=eric.auger.pro@gmail.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).