[PATCH] qemu_namespace: Move umount() call into #fdef __linux__

Michal Privoznik posted 1 patch 1 year, 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/d5f8db2ecfa0af83a2cb951e1a07712243750f2e.1672933046.git.mprivozn@redhat.com
src/qemu/qemu_namespace.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] qemu_namespace: Move umount() call into #fdef __linux__
Posted by Michal Privoznik 1 year, 3 months ago
In a recent commit I've introduced an umount() call. But the
function where the call lives is compiled on all OSes, not just
Linux. But umount() is Linux specific. Other OSes have unmount
(FreeBSD), or maybe something else. But since namespaces are
Linux specific, we can wrap the call in #ifdef __linux__ and not
care about other OSes.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_namespace.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
index fc348c043e..5769a4dfe0 100644
--- a/src/qemu/qemu_namespace.c
+++ b/src/qemu/qemu_namespace.c
@@ -776,10 +776,12 @@ qemuDomainUnshareNamespace(virQEMUDriverConfig *cfg,
             goto cleanup;
     }
 
+#if defined(__linux__)
     if (umount("/dev") < 0) {
         virReportSystemError(errno, "%s", _("failed to umount devfs on /dev"));
         return -1;
     }
+#endif /* !defined(__linux__) */
 
     if (virFileMoveMount(devPath, "/dev") < 0)
         goto cleanup;
-- 
2.38.2
Re: [PATCH] qemu_namespace: Move umount() call into #fdef __linux__
Posted by Michal Prívozník 1 year, 3 months ago
On 1/5/23 16:37, Michal Privoznik wrote:
> In a recent commit I've introduced an umount() call. But the
> function where the call lives is compiled on all OSes, not just
> Linux. But umount() is Linux specific. Other OSes have unmount
> (FreeBSD), or maybe something else. But since namespaces are
> Linux specific, we can wrap the call in #ifdef __linux__ and not
> care about other OSes.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_namespace.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

I've pushed this under build breaker and trivial rules.

Michal