6d3351
From 819c3b24c77321202d820bbe08963f313035cb3c Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <819c3b24c77321202d820bbe08963f313035cb3c@dist-git>
6d3351
From: Andrea Bolognani <abologna@redhat.com>
6d3351
Date: Mon, 28 Aug 2017 16:59:14 +0200
6d3351
Subject: [PATCH] qemu: Handle host devices not being available better
6d3351
6d3351
We can't retrieve the isolation group of a device that's not present
6d3351
in the system. However, it's very common for VFs to be created late
6d3351
in the boot, so they might not be present yet when libvirtd starts,
6d3351
which would cause the guests using them to disappear.
6d3351
6d3351
Moreover, for other architectures and even ppc64 before isolation
6d3351
groups were introduced, it's considered perfectly fine to configure a
6d3351
guest to use a device that's not yet (or no longer) available to the
6d3351
host, with the obvious caveat that such a guest won't be able to
6d3351
start before the device is available.
6d3351
6d3351
In order to be consistent, when a device's isolation group can't be
6d3351
determined fall back to not isolating it rather than erroring out or,
6d3351
worse, making the guest disappear.
6d3351
6d3351
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1484254
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
(cherry picked from commit 1f43393283ff04d1a3905abb3669cdd5665610b4)
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/qemu/qemu_domain_address.c | 29 +++++++++++------------------
6d3351
 1 file changed, 11 insertions(+), 18 deletions(-)
6d3351
6d3351
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
6d3351
index 3d5e7cc442..4fa17c76b5 100644
6d3351
--- a/src/qemu/qemu_domain_address.c
6d3351
+++ b/src/qemu/qemu_domain_address.c
6d3351
@@ -977,8 +977,6 @@ int
6d3351
 qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def,
6d3351
                                    virDomainDeviceDefPtr dev)
6d3351
 {
6d3351
-    int ret = -1;
6d3351
-
6d3351
     /* Only host devices need their isolation group to be different from
6d3351
      * the default. Interfaces of type hostdev are just host devices in
6d3351
      * disguise, but we don't need to handle them separately because for
6d3351
@@ -1007,12 +1005,11 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def,
6d3351
         tmp = virPCIDeviceAddressGetIOMMUGroupNum(hostAddr);
6d3351
 
6d3351
         if (tmp < 0) {
6d3351
-            virReportError(VIR_ERR_INTERNAL_ERROR,
6d3351
-                           _("Can't look up isolation group for host device "
6d3351
-                             "%04x:%02x:%02x.%x"),
6d3351
-                           hostAddr->domain, hostAddr->bus,
6d3351
-                           hostAddr->slot, hostAddr->function);
6d3351
-            goto cleanup;
6d3351
+            VIR_WARN("Can't look up isolation group for host device "
6d3351
+                     "%04x:%02x:%02x.%x, device won't be isolated",
6d3351
+                     hostAddr->domain, hostAddr->bus,
6d3351
+                     hostAddr->slot, hostAddr->function);
6d3351
+            goto skip;
6d3351
         }
6d3351
 
6d3351
         /* The isolation group for a host device is its IOMMU group,
6d3351
@@ -1052,12 +1049,11 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def,
6d3351
         tmp = qemuDomainFindUnusedIsolationGroup(def);
6d3351
 
6d3351
         if (tmp == 0) {
6d3351
-            virReportError(VIR_ERR_INTERNAL_ERROR,
6d3351
-                           _("Can't obtain usable isolation group for "
6d3351
-                             "interface configured to use hostdev-backed "
6d3351
-                             "network '%s'"),
6d3351
-                             iface->data.network.name);
6d3351
-            goto cleanup;
6d3351
+            VIR_WARN("Can't obtain usable isolation group for interface "
6d3351
+                     "configured to use hostdev-backed network '%s', "
6d3351
+                     "device won't be isolated",
6d3351
+                     iface->data.network.name);
6d3351
+            goto skip;
6d3351
         }
6d3351
 
6d3351
         info->isolationGroup = tmp;
6d3351
@@ -1068,10 +1064,7 @@ qemuDomainFillDeviceIsolationGroup(virDomainDefPtr def,
6d3351
     }
6d3351
 
6d3351
  skip:
6d3351
-    ret = 0;
6d3351
-
6d3351
- cleanup:
6d3351
-    return ret;
6d3351
+    return 0;
6d3351
 }
6d3351
 
6d3351
 
6d3351
-- 
6d3351
2.14.1
6d3351