|
|
3e5111 |
From c5e142b3b9bc25ed508b8b7b62907ed99daba84d Mon Sep 17 00:00:00 2001
|
|
|
3e5111 |
Message-Id: <c5e142b3b9bc25ed508b8b7b62907ed99daba84d@dist-git>
|
|
|
3e5111 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3e5111 |
Date: Thu, 11 May 2017 15:38:40 +0200
|
|
|
3e5111 |
Subject: [PATCH] qemuDomainAttachDeviceMknodRecursive: Don't try to create
|
|
|
3e5111 |
devices under preserved mount points
|
|
|
3e5111 |
|
|
|
3e5111 |
https://bugzilla.redhat.com/show_bug.cgi?id=1449510
|
|
|
3e5111 |
|
|
|
3e5111 |
Just like in previous commit, this fixes the same issue for
|
|
|
3e5111 |
hotplug.
|
|
|
3e5111 |
|
|
|
3e5111 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3e5111 |
Reviewed-by: Cedric Bosdonnat <cbosdonnat@suse.com>
|
|
|
3e5111 |
(cherry picked from commit b3418f36be75eb4bdecd6aa37cda7a268519ee46)
|
|
|
3e5111 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3e5111 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
3e5111 |
---
|
|
|
3e5111 |
src/qemu/qemu_domain.c | 114 ++++++++++++++++++++++++++++++++++++++++++-------
|
|
|
3e5111 |
1 file changed, 98 insertions(+), 16 deletions(-)
|
|
|
3e5111 |
|
|
|
3e5111 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
index 9217747d5..671569f6f 100644
|
|
|
3e5111 |
--- a/src/qemu/qemu_domain.c
|
|
|
3e5111 |
+++ b/src/qemu/qemu_domain.c
|
|
|
3e5111 |
@@ -8314,6 +8314,8 @@ static int
|
|
|
3e5111 |
qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
const char *file,
|
|
|
3e5111 |
+ char * const *devMountsPath,
|
|
|
3e5111 |
+ size_t ndevMountsPath,
|
|
|
3e5111 |
unsigned int ttl)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
struct qemuDomainAttachDeviceMknodData data;
|
|
|
3e5111 |
@@ -8391,20 +8393,36 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|
|
3e5111 |
#endif
|
|
|
3e5111 |
|
|
|
3e5111 |
if (STRPREFIX(file, DEVPREFIX)) {
|
|
|
3e5111 |
- if (qemuSecurityPreFork(driver->securityManager) < 0)
|
|
|
3e5111 |
- goto cleanup;
|
|
|
3e5111 |
+ size_t i;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (virProcessRunInMountNamespace(vm->pid,
|
|
|
3e5111 |
- qemuDomainAttachDeviceMknodHelper,
|
|
|
3e5111 |
- &data) < 0) {
|
|
|
3e5111 |
- qemuSecurityPostFork(driver->securityManager);
|
|
|
3e5111 |
- goto cleanup;
|
|
|
3e5111 |
+ for (i = 0; i < ndevMountsPath; i++) {
|
|
|
3e5111 |
+ if (STREQ(devMountsPath[i], "/dev"))
|
|
|
3e5111 |
+ continue;
|
|
|
3e5111 |
+ if (STRPREFIX(file, devMountsPath[i]))
|
|
|
3e5111 |
+ break;
|
|
|
3e5111 |
+ }
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (i == ndevMountsPath) {
|
|
|
3e5111 |
+ if (qemuSecurityPreFork(driver->securityManager) < 0)
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (virProcessRunInMountNamespace(vm->pid,
|
|
|
3e5111 |
+ qemuDomainAttachDeviceMknodHelper,
|
|
|
3e5111 |
+ &data) < 0) {
|
|
|
3e5111 |
+ qemuSecurityPostFork(driver->securityManager);
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+ }
|
|
|
3e5111 |
+ qemuSecurityPostFork(driver->securityManager);
|
|
|
3e5111 |
+ } else {
|
|
|
3e5111 |
+ VIR_DEBUG("Skipping dev %s because of %s mount point",
|
|
|
3e5111 |
+ file, devMountsPath[i]);
|
|
|
3e5111 |
}
|
|
|
3e5111 |
- qemuSecurityPostFork(driver->securityManager);
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
if (isLink &&
|
|
|
3e5111 |
- qemuDomainAttachDeviceMknodRecursive(driver, vm, target, ttl -1) < 0)
|
|
|
3e5111 |
+ qemuDomainAttachDeviceMknodRecursive(driver, vm, target,
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath,
|
|
|
3e5111 |
+ ttl -1) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
@@ -8421,11 +8439,15 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|
|
3e5111 |
static int
|
|
|
3e5111 |
qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
- const char *file)
|
|
|
3e5111 |
+ const char *file,
|
|
|
3e5111 |
+ char * const *devMountsPath,
|
|
|
3e5111 |
+ size_t ndevMountsPath)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
long symloop_max = sysconf(_SC_SYMLOOP_MAX);
|
|
|
3e5111 |
|
|
|
3e5111 |
- return qemuDomainAttachDeviceMknodRecursive(driver, vm, file, symloop_max);
|
|
|
3e5111 |
+ return qemuDomainAttachDeviceMknodRecursive(driver, vm, file,
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath,
|
|
|
3e5111 |
+ symloop_max);
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8465,6 +8487,9 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
virStorageSourcePtr src)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUDriverConfigPtr cfg = NULL;
|
|
|
3e5111 |
+ char **devMountsPath = NULL;
|
|
|
3e5111 |
+ size_t ndevMountsPath = 0;
|
|
|
3e5111 |
virStorageSourcePtr next;
|
|
|
3e5111 |
struct stat sb;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
@@ -8472,6 +8497,12 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
|
|
|
3e5111 |
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
+ if (qemuDomainGetPreservedMounts(cfg, vm,
|
|
|
3e5111 |
+ &devMountsPath, NULL,
|
|
|
3e5111 |
+ &ndevMountsPath) < 0)
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
for (next = src; next; next = next->backingStore) {
|
|
|
3e5111 |
if (virStorageSourceIsEmpty(next) ||
|
|
|
3e5111 |
!virStorageSourceIsLocalStorage(next)) {
|
|
|
3e5111 |
@@ -8490,12 +8521,15 @@ qemuDomainNamespaceSetupDisk(virQEMUDriverPtr driver,
|
|
|
3e5111 |
|
|
|
3e5111 |
if (qemuDomainAttachDeviceMknod(driver,
|
|
|
3e5111 |
vm,
|
|
|
3e5111 |
- next->path) < 0)
|
|
|
3e5111 |
+ next->path,
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
+ virStringListFreeCount(devMountsPath, ndevMountsPath);
|
|
|
3e5111 |
+ virObjectUnref(cfg);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8520,6 +8554,9 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
virDomainHostdevDefPtr hostdev)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUDriverConfigPtr cfg = NULL;
|
|
|
3e5111 |
+ char **devMountsPath = NULL;
|
|
|
3e5111 |
+ size_t ndevMountsPath = 0;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
char **path = NULL;
|
|
|
3e5111 |
size_t i, npaths = 0;
|
|
|
3e5111 |
@@ -8530,10 +8567,17 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver,
|
|
|
3e5111 |
if (qemuDomainGetHostdevPath(NULL, hostdev, false, &npaths, &path, NULL) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
+ if (qemuDomainGetPreservedMounts(cfg, vm,
|
|
|
3e5111 |
+ &devMountsPath, NULL,
|
|
|
3e5111 |
+ &ndevMountsPath) < 0)
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
for (i = 0; i < npaths; i++) {
|
|
|
3e5111 |
if (qemuDomainAttachDeviceMknod(driver,
|
|
|
3e5111 |
vm,
|
|
|
3e5111 |
- path[i]) < 0)
|
|
|
3e5111 |
+ path[i],
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8542,6 +8586,8 @@ qemuDomainNamespaceSetupHostdev(virQEMUDriverPtr driver,
|
|
|
3e5111 |
for (i = 0; i < npaths; i++)
|
|
|
3e5111 |
VIR_FREE(path[i]);
|
|
|
3e5111 |
VIR_FREE(path);
|
|
|
3e5111 |
+ virStringListFreeCount(devMountsPath, ndevMountsPath);
|
|
|
3e5111 |
+ virObjectUnref(cfg);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8581,6 +8627,9 @@ qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
virDomainMemoryDefPtr mem)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUDriverConfigPtr cfg = NULL;
|
|
|
3e5111 |
+ char **devMountsPath = NULL;
|
|
|
3e5111 |
+ size_t ndevMountsPath = 0;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
|
|
|
3e5111 |
if (mem->model != VIR_DOMAIN_MEMORY_MODEL_NVDIMM)
|
|
|
3e5111 |
@@ -8589,10 +8638,19 @@ qemuDomainNamespaceSetupMemory(virQEMUDriverPtr driver,
|
|
|
3e5111 |
if (!qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT))
|
|
|
3e5111 |
return 0;
|
|
|
3e5111 |
|
|
|
3e5111 |
- if (qemuDomainAttachDeviceMknod(driver, vm, mem->nvdimmPath) < 0)
|
|
|
3e5111 |
+ cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
+ if (qemuDomainGetPreservedMounts(cfg, vm,
|
|
|
3e5111 |
+ &devMountsPath, NULL,
|
|
|
3e5111 |
+ &ndevMountsPath) < 0)
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
+ if (qemuDomainAttachDeviceMknod(driver, vm, mem->nvdimmPath,
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
+ virStringListFreeCount(devMountsPath, ndevMountsPath);
|
|
|
3e5111 |
+ virObjectUnref(cfg);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8623,6 +8681,9 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
virDomainChrDefPtr chr)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUDriverConfigPtr cfg = NULL;
|
|
|
3e5111 |
+ char **devMountsPath = NULL;
|
|
|
3e5111 |
+ size_t ndevMountsPath = 0;
|
|
|
3e5111 |
const char *path;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8634,12 +8695,21 @@ qemuDomainNamespaceSetupChardev(virQEMUDriverPtr driver,
|
|
|
3e5111 |
|
|
|
3e5111 |
path = chr->source->data.file.path;
|
|
|
3e5111 |
|
|
|
3e5111 |
+ cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
+ if (qemuDomainGetPreservedMounts(cfg, vm,
|
|
|
3e5111 |
+ &devMountsPath, NULL,
|
|
|
3e5111 |
+ &ndevMountsPath) < 0)
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
if (qemuDomainAttachDeviceMknod(driver,
|
|
|
3e5111 |
vm,
|
|
|
3e5111 |
- path) < 0)
|
|
|
3e5111 |
+ path,
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
+ virStringListFreeCount(devMountsPath, ndevMountsPath);
|
|
|
3e5111 |
+ virObjectUnref(cfg);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8674,6 +8744,9 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver,
|
|
|
3e5111 |
virDomainObjPtr vm,
|
|
|
3e5111 |
virDomainRNGDefPtr rng)
|
|
|
3e5111 |
{
|
|
|
3e5111 |
+ virQEMUDriverConfigPtr cfg = NULL;
|
|
|
3e5111 |
+ char **devMountsPath = NULL;
|
|
|
3e5111 |
+ size_t ndevMountsPath = 0;
|
|
|
3e5111 |
const char *path = NULL;
|
|
|
3e5111 |
int ret = -1;
|
|
|
3e5111 |
|
|
|
3e5111 |
@@ -8691,12 +8764,21 @@ qemuDomainNamespaceSetupRNG(virQEMUDriverPtr driver,
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
+ cfg = virQEMUDriverGetConfig(driver);
|
|
|
3e5111 |
+ if (qemuDomainGetPreservedMounts(cfg, vm,
|
|
|
3e5111 |
+ &devMountsPath, NULL,
|
|
|
3e5111 |
+ &ndevMountsPath) < 0)
|
|
|
3e5111 |
+ goto cleanup;
|
|
|
3e5111 |
+
|
|
|
3e5111 |
if (qemuDomainAttachDeviceMknod(driver,
|
|
|
3e5111 |
vm,
|
|
|
3e5111 |
- path) < 0)
|
|
|
3e5111 |
+ path,
|
|
|
3e5111 |
+ devMountsPath, ndevMountsPath) < 0)
|
|
|
3e5111 |
goto cleanup;
|
|
|
3e5111 |
ret = 0;
|
|
|
3e5111 |
cleanup:
|
|
|
3e5111 |
+ virStringListFreeCount(devMountsPath, ndevMountsPath);
|
|
|
3e5111 |
+ virObjectUnref(cfg);
|
|
|
3e5111 |
return ret;
|
|
|
3e5111 |
}
|
|
|
3e5111 |
|
|
|
3e5111 |
--
|
|
|
3e5111 |
2.13.0
|
|
|
3e5111 |
|