a3bc25
From 4f54b2f401e4e1a443f6c889cbd2373aaa249d28 Mon Sep 17 00:00:00 2001
a3bc25
Message-Id: <4f54b2f401e4e1a443f6c889cbd2373aaa249d28@dist-git>
a3bc25
From: Michal Privoznik <mprivozn@redhat.com>
a3bc25
Date: Mon, 17 Jul 2017 14:48:21 +0200
a3bc25
Subject: [PATCH] qemuDomainBuildNamespace: Handle special file mount points
a3bc25
a3bc25
RHEL-7.5: https://bugzilla.redhat.com/show_bug.cgi?id=1459592
a3bc25
RHEL-7.4.z: https://bugzilla.redhat.com/show_bug.cgi?id=1471660
a3bc25
a3bc25
In 290a00e41d I've tried to fix the process of building a
a3bc25
qemu namespace when dealing with file mount points. What I
a3bc25
haven't realized then is that we might be dealing not with just
a3bc25
regular files but also special files (like sockets). Indeed, try
a3bc25
the following:
a3bc25
a3bc25
1) socat unix-listen:/tmp/soket stdio
a3bc25
2) touch /dev/socket
a3bc25
3) mount --bind /tmp/socket /dev/socket
a3bc25
4) virsh start anyDomain
a3bc25
a3bc25
Problem with my previous approach is that I wasn't creating the
a3bc25
temporary location (where mount points under /dev are moved) for
a3bc25
anything but directories and regular files.
a3bc25
a3bc25
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a3bc25
Reviewed-by: John Ferlan <jferlan@redhat.com>
a3bc25
(cherry picked from commit 7154917908d9f712a950a2716c4687e57ccb74e7)
a3bc25
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
a3bc25
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
a3bc25
---
a3bc25
 src/qemu/qemu_domain.c | 6 ++++--
a3bc25
 1 file changed, 4 insertions(+), 2 deletions(-)
a3bc25
a3bc25
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a3bc25
index 6ccc9f6f5b..c9c668b892 100644
a3bc25
--- a/src/qemu/qemu_domain.c
a3bc25
+++ b/src/qemu/qemu_domain.c
a3bc25
@@ -8305,9 +8305,11 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
a3bc25
             goto cleanup;
a3bc25
         }
a3bc25
 
a3bc25
-        /* At this point, devMountsPath is either a regular file or a directory. */
a3bc25
+        /* At this point, devMountsPath is either:
a3bc25
+         * a file (regular or special), or
a3bc25
+         * a directory. */
a3bc25
         if ((S_ISDIR(sb.st_mode) && virFileMakePath(devMountsSavePath[i]) < 0) ||
a3bc25
-            (S_ISREG(sb.st_mode) && virFileTouch(devMountsSavePath[i], sb.st_mode) < 0)) {
a3bc25
+            (!S_ISDIR(sb.st_mode) && virFileTouch(devMountsSavePath[i], sb.st_mode) < 0)) {
a3bc25
             virReportSystemError(errno,
a3bc25
                                  _("Failed to create %s"),
a3bc25
                                  devMountsSavePath[i]);
a3bc25
-- 
a3bc25
2.13.3
a3bc25