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(a)redhat.com>
---
src/qemu/qemu_domain.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 50b401f79..2d9b2d647 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6862,6 +6862,53 @@ qemuDomainSetupDev(virQEMUDriverPtr driver,
}
+static int
+qemuDomainSetupDisk(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+ virDomainDiskDefPtr disk,
+ const char *devPath)
+{
+ virStorageSourcePtr next;
+ char *dst = NULL;
+ int ret = -1;
+
+ for (next = disk->src; next; next = next->backingStore) {
+ if (!next->path || !virStorageSourceIsLocalStorage(next) ||
+ !STRPREFIX(next->path, "/dev")) {
+ /* Not creating device. Just continue. */
+ continue;
+ }
+
+ if (qemuDomainCreateDevice(next->path, devPath, false) < 0)
+ goto cleanup;
+ }
+
+ ret = 0;
+ cleanup:
+ VIR_FREE(dst);
+ return ret;
+}
+
+
+static int
+qemuDomainSetupAllDisks(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ const char *devPath)
+{
+ size_t i;
+ VIR_DEBUG("Setting up disks");
+
+ for (i = 0; i < vm->def->ndisks; i++) {
+ if (qemuDomainSetupDisk(driver,
+ vm->def->disks[i],
+ devPath) < 0)
+ return -1;
+ }
+
+ VIR_DEBUG("Setup all disks");
+ return 0;
+}
+
+
int
qemuDomainBuildNamespace(virQEMUDriverPtr driver,
virDomainObjPtr vm)
@@ -6894,6 +6941,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
goto cleanup;
}
+ if (qemuDomainSetupAllDisks(driver, vm, devPath) < 0)
+ goto cleanup;
+
if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
virReportSystemError(errno,
_("Failed to mount %s on /dev"),
--
2.11.0