]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Handle EEXIST gracefully in qemuDomainCreateDevice
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Jan 2017 12:57:06 +0000 (13:57 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Jan 2017 14:36:42 +0000 (15:36 +0100)
https://bugzilla.redhat.com/show_bug.cgi?id=1406837

Imagine you have a domain configured in such way that you are
assigning two PCI devices that fall into the same IOMMU group.
With mount namespace enabled what happens is that for the first
PCI device corresponding /dev/vfio/X entry is created and when
the code tries to do the same for the second mknod() fails as
/dev/vfio/X already exists:

2016-12-21 14:40:45.648+0000: 24681: error :
qemuProcessReportLogError:1792 : internal error: Process exited
prior to exec: libvirt: QEMU Driver error : Failed to make device
/var/run/libvirt/qemu/windoze.dev//vfio/22: File exists

Worse, by default there are some devices that are created in the
namespace regardless of domain configuration (e.g. /dev/null,
/dev/urandom, etc.). If one of them is set as backend for some
guest device (e.g. rng, chardev, etc.) it's the same story as
described above.

Weirdly, in attach code this is already handled.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 25cb4ad5901e987648dfe9e49bcaf2558eab2104..ad80be034b1f64632535df1c3303ed8009f0847f 100644 (file)
@@ -6957,9 +6957,13 @@ qemuDomainCreateDevice(const char *device,
     }
 
     if (mknod(devicePath, sb.st_mode, sb.st_rdev) < 0) {
-        virReportSystemError(errno,
-                             _("Failed to make device %s"),
-                             devicePath);
+        if (errno == EEXIST) {
+            ret = 0;
+        } else {
+            virReportSystemError(errno,
+                                 _("Failed to make device %s"),
+                                 devicePath);
+        }
         goto cleanup;
     }