639072
From 1772cf15e26cc620f71513689f2ac2409a22df93 Mon Sep 17 00:00:00 2001
639072
Message-Id: <1772cf15e26cc620f71513689f2ac2409a22df93@dist-git>
639072
From: Michal Privoznik <mprivozn@redhat.com>
639072
Date: Tue, 6 Sep 2022 13:43:58 +0200
639072
Subject: [PATCH] qemu_namespace: Introduce qemuDomainNamespaceSetupPath()
639072
639072
Sometimes it may come handy to just bind mount a directory/file
639072
into domain's namespace. Implement a thin wrapper over
639072
qemuNamespaceMknodPaths() which has all the logic we need.
639072
639072
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
639072
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
639072
(cherry picked from commit 5853d707189005a4ea5b2215e80853867b822fd9)
639072
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2132176
639072
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
639072
---
639072
 src/qemu/qemu_namespace.c | 19 +++++++++++++++++++
639072
 src/qemu/qemu_namespace.h |  4 ++++
639072
 2 files changed, 23 insertions(+)
639072
639072
diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
639072
index fc286ab0be..74ffd6fb90 100644
639072
--- a/src/qemu/qemu_namespace.c
639072
+++ b/src/qemu/qemu_namespace.c
639072
@@ -1398,6 +1398,25 @@ qemuNamespaceUnlinkPaths(virDomainObj *vm,
639072
 }
639072
 
639072
 
639072
+int
639072
+qemuDomainNamespaceSetupPath(virDomainObj *vm,
639072
+                             const char *path,
639072
+                             bool *created)
639072
+{
639072
+    g_autoptr(virGSListString) paths = NULL;
639072
+
639072
+    if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
639072
+        return 0;
639072
+
639072
+    paths = g_slist_prepend(paths, g_strdup(path));
639072
+
639072
+    if (qemuNamespaceMknodPaths(vm, paths, created) < 0)
639072
+        return -1;
639072
+
639072
+    return 0;
639072
+}
639072
+
639072
+
639072
 int
639072
 qemuDomainNamespaceSetupDisk(virDomainObj *vm,
639072
                              virStorageSource *src,
639072
diff --git a/src/qemu/qemu_namespace.h b/src/qemu/qemu_namespace.h
639072
index 020aca13d8..1ab9322061 100644
639072
--- a/src/qemu/qemu_namespace.h
639072
+++ b/src/qemu/qemu_namespace.h
639072
@@ -49,6 +49,10 @@ void qemuDomainDestroyNamespace(virQEMUDriver *driver,
639072
 
639072
 bool qemuDomainNamespaceAvailable(qemuDomainNamespace ns);
639072
 
639072
+int qemuDomainNamespaceSetupPath(virDomainObj *vm,
639072
+                                 const char *path,
639072
+                                 bool *created);
639072
+
639072
 int qemuDomainNamespaceSetupDisk(virDomainObj *vm,
639072
                                  virStorageSource *src,
639072
                                  bool *created);
639072
-- 
639072
2.38.1
639072