render / rpms / libvirt

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