[libvirt] [PATCH 1/3] qemu: Handle EEXIST gracefully in qemuDomainCreateDevice

Martin Kletzander mkletzan at redhat.com
Wed Jan 4 14:22:54 UTC 2017


On Wed, Jan 04, 2017 at 03:13:55PM +0100, Michal Privoznik wrote:
>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 at redhat.com>
>---
> src/qemu/qemu_domain.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index 25cb4ad590..d05ebcb416 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c
>@@ -6957,10 +6957,12 @@ qemuDomainCreateDevice(const char *device,
>     }
>
>     if (mknod(devicePath, sb.st_mode, sb.st_rdev) < 0) {
>-        virReportSystemError(errno,
>-                             _("Failed to make device %s"),
>-                             devicePath);
>-        goto cleanup;
>+        if (errno != EEXIST) {
>+            virReportSystemError(errno,
>+                                 _("Failed to make device %s"),
>+                                 devicePath);
>+            goto cleanup;
>+        }
>     }
>

You can also skip the chown here if you want.  ACK either way.

>     if (chown(devicePath, sb.st_uid, sb.st_gid) < 0) {
>--
>2.11.0
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170104/bb2774f2/attachment-0001.sig>


More information about the libvir-list mailing list