mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Provide non-linux stub for qemuDomainAttachDeviceMknodRecursive
The way we create devices under /dev is highly linux specific. For instance we do mknod(), mount(), umount(), etc. Some platforms are even missing some of these functions. Then again, as declared in qemuDomainNamespaceAvailable(): namespaces are linux only. Therefore, to avoid obfuscating the code by trying to make it compile on weird platforms, just provide a non-linux stub for qemuDomainAttachDeviceMknodRecursive(). At the same time, qemuDomainAttachDeviceMknodHelper() which actually calls the non-existent functions is moved under ifdef __linux__ block since its only caller is in that block too. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
fde654be53
commit
a4d9c31eac
@ -8542,6 +8542,8 @@ struct qemuDomainAttachDeviceMknodData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Our way of creating devices is highly linux specific */
|
||||||
|
#if defined(__linux__)
|
||||||
static int
|
static int
|
||||||
qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
|
qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
@ -8639,7 +8641,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_SELINUX
|
# ifdef WITH_SELINUX
|
||||||
if (data->tcon &&
|
if (data->tcon &&
|
||||||
lsetfilecon_raw(data->file, (VIR_SELINUX_CTX_CONST char *) data->tcon) < 0) {
|
lsetfilecon_raw(data->file, (VIR_SELINUX_CTX_CONST char *) data->tcon) < 0) {
|
||||||
VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
|
||||||
@ -8651,7 +8653,7 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
/* Finish mount process started earlier. */
|
/* Finish mount process started earlier. */
|
||||||
if (isReg &&
|
if (isReg &&
|
||||||
@ -8662,9 +8664,9 @@ qemuDomainAttachDeviceMknodHelper(pid_t pid ATTRIBUTE_UNUSED,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0 && delDevice)
|
if (ret < 0 && delDevice)
|
||||||
unlink(data->file);
|
unlink(data->file);
|
||||||
#ifdef WITH_SELINUX
|
# ifdef WITH_SELINUX
|
||||||
freecon(data->tcon);
|
freecon(data->tcon);
|
||||||
#endif
|
# endif
|
||||||
virFileFreeACLs(&data->acl);
|
virFileFreeACLs(&data->acl);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -8755,14 +8757,14 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_SELINUX
|
# ifdef WITH_SELINUX
|
||||||
if (lgetfilecon_raw(file, &data.tcon) < 0 &&
|
if (lgetfilecon_raw(file, &data.tcon) < 0 &&
|
||||||
(errno != ENOTSUP && errno != ENODATA)) {
|
(errno != ENOTSUP && errno != ENODATA)) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
_("Unable to get SELinux label from %s"), file);
|
_("Unable to get SELinux label from %s"), file);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (STRPREFIX(file, DEVPREFIX)) {
|
if (STRPREFIX(file, DEVPREFIX)) {
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -8799,9 +8801,9 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
#ifdef WITH_SELINUX
|
# ifdef WITH_SELINUX
|
||||||
freecon(data.tcon);
|
freecon(data.tcon);
|
||||||
#endif
|
# endif
|
||||||
virFileFreeACLs(&data.acl);
|
virFileFreeACLs(&data.acl);
|
||||||
if (isReg && target)
|
if (isReg && target)
|
||||||
umount(target);
|
umount(target);
|
||||||
@ -8811,6 +8813,26 @@ qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else /* !defined(__linux__) */
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainAttachDeviceMknodRecursive(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
|
||||||
|
virDomainObjPtr vm ATTRIBUTE_UNUSED,
|
||||||
|
const char *file ATTRIBUTE_UNUSED,
|
||||||
|
char * const *devMountsPath ATTRIBUTE_UNUSED,
|
||||||
|
size_t ndevMountsPath ATTRIBUTE_UNUSED,
|
||||||
|
unsigned int ttl ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
virReportSystemError(ENOSYS, "%s",
|
||||||
|
_("Namespaces are not supported on this platform."));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* !defined(__linux__) */
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
|
qemuDomainAttachDeviceMknod(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
|
Loading…
Reference in New Issue
Block a user