[PATCH v1 12/21] qemu: Prepare chardevs when starting a domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When starting a domain and separate mount namespace is used, we
have to create all the /dev entries that are configured for the
domain.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 17fb3d0..9871f4d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6986,6 +6986,38 @@ qemuDomainSetupAllHostdevs(virQEMUDriverPtr driver,
 }
 
 
+static int
+qemuDomainSetupChardev(virDomainDefPtr def ATTRIBUTE_UNUSED,
+                       virDomainChrDefPtr dev,
+                       void *opaque)
+{
+    const char *devPath = opaque;
+
+    if (dev->source->type != VIR_DOMAIN_CHR_TYPE_DEV)
+        return 0;
+
+    return qemuDomainCreateDevice(dev->source->data.file.path, devPath, false);
+}
+
+
+static int
+qemuDomainSetupAllChardevs(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+                           virDomainObjPtr vm,
+                           const char *devPath)
+{
+    VIR_DEBUG("Setting up chardevs");
+
+    if (virDomainChrDefForeach(vm->def,
+                               true,
+                               qemuDomainSetupChardev,
+                               (void *) devPath) < 0)
+        return -1;
+
+    VIR_DEBUG("Setup all chardevs");
+    return 0;
+}
+
+
 int
 qemuDomainBuildNamespace(virQEMUDriverPtr driver,
                          virDomainObjPtr vm)
@@ -7025,6 +7057,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
     if (qemuDomainSetupAllHostdevs(driver, vm, devPath) < 0)
         goto cleanup;
 
+    if (qemuDomainSetupAllChardevs(driver, vm, devPath) < 0)
+        goto cleanup;
+
     if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
         virReportSystemError(errno,
                              _("Failed to mount %s on /dev"),
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux