}
+static bool
+qemuNamespaceMknodItemNeedsBindMount(mode_t st_mode)
+{
+ /* A block device S_ISBLK() or a chardev S_ISCHR() is intentionally not
+ * handled. We want to mknod() it instead of passing in through bind
+ * mounting. */
+ return S_ISREG(st_mode) || S_ISFIFO(st_mode) ||
+ S_ISSOCK(st_mode) || S_ISDIR(st_mode);
+}
+
+
static int
qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int ret = -1;
g_autofree char *target = NULL;
bool isLink;
- bool isReg;
- bool isDir;
+ bool needsBindMount;
if (!ttl) {
virReportSystemError(ELOOP,
}
isLink = S_ISLNK(data.sb.st_mode);
- isReg = S_ISREG(data.sb.st_mode) || S_ISFIFO(data.sb.st_mode) || S_ISSOCK(data.sb.st_mode);
- isDir = S_ISDIR(data.sb.st_mode);
+ needsBindMount = qemuNamespaceMknodItemNeedsBindMount(data.sb.st_mode);
- if ((isReg || isDir) && STRPREFIX(file, QEMU_DEVPREFIX)) {
+ if (needsBindMount && STRPREFIX(file, QEMU_DEVPREFIX)) {
cfg = virQEMUDriverGetConfig(driver);
if (!(target = qemuDomainGetPreservedMountPath(cfg, vm, file)))
goto cleanup;
freecon(data.tcon);
# endif
virFileFreeACLs(&data.acl);
- if (isReg && target)
+ if (needsBindMount && target)
umount(target);
return ret;
}