mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
qemu: Drop virQEMUDriverIsPrivileged()
Introduced in v1.2.17-rc1~121, the assumption was that the driver->privileged is immutable at the time but it might change in the future. Well, it did not ever since. It is still immutable variable. Drop the needless accessor then. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
f00f4ea7b1
commit
0e4ec86978
@ -915,7 +915,7 @@ qemuInitCgroup(virDomainObjPtr vm,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(priv->driver))
|
if (!priv->driver->privileged)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!virCgroupAvailable())
|
if (!virCgroupAvailable())
|
||||||
@ -1042,7 +1042,7 @@ qemuConnectCgroup(virDomainObjPtr vm)
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(priv->driver))
|
if (!priv->driver->privileged)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!virCgroupAvailable())
|
if (!virCgroupAvailable())
|
||||||
|
@ -8109,7 +8109,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
|
|||||||
/* network and bridge use a tap device, and direct uses a
|
/* network and bridge use a tap device, and direct uses a
|
||||||
* macvtap device
|
* macvtap device
|
||||||
*/
|
*/
|
||||||
if (virQEMUDriverIsPrivileged(driver) && nicindexes && nnicindexes &&
|
if (driver->privileged && nicindexes && nnicindexes &&
|
||||||
net->ifname) {
|
net->ifname) {
|
||||||
if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
|
if (virNetDevGetIndex(net->ifname, &nicindex) < 0 ||
|
||||||
VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
|
VIR_APPEND_ELEMENT(*nicindexes, *nnicindexes, nicindex) < 0)
|
||||||
@ -9649,7 +9649,7 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver,
|
|||||||
int spice = 0;
|
int spice = 0;
|
||||||
int egl_headless = 0;
|
int egl_headless = 0;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
/* If we have no cgroups then we can have no tunings that
|
/* If we have no cgroups then we can have no tunings that
|
||||||
* require them */
|
* require them */
|
||||||
|
|
||||||
|
@ -1224,12 +1224,6 @@ virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver)
|
|||||||
return conf;
|
return conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
virQEMUDriverIsPrivileged(virQEMUDriverPtr driver)
|
|
||||||
{
|
|
||||||
return driver->privileged;
|
|
||||||
}
|
|
||||||
|
|
||||||
virDomainXMLOptionPtr
|
virDomainXMLOptionPtr
|
||||||
virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver,
|
virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver,
|
||||||
const char *defsecmodel)
|
const char *defsecmodel)
|
||||||
|
@ -333,7 +333,6 @@ int
|
|||||||
virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr cfg);
|
virQEMUDriverConfigSetDefaults(virQEMUDriverConfigPtr cfg);
|
||||||
|
|
||||||
virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver);
|
virQEMUDriverConfigPtr virQEMUDriverGetConfig(virQEMUDriverPtr driver);
|
||||||
bool virQEMUDriverIsPrivileged(virQEMUDriverPtr driver);
|
|
||||||
|
|
||||||
virCapsHostNUMAPtr virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver);
|
virCapsHostNUMAPtr virQEMUDriverGetHostNUMACaps(virQEMUDriverPtr driver);
|
||||||
virCPUDefPtr virQEMUDriverGetHostCPU(virQEMUDriverPtr driver);
|
virCPUDefPtr virQEMUDriverGetHostCPU(virQEMUDriverPtr driver);
|
||||||
|
@ -7163,7 +7163,7 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = obj->privateData;
|
qemuDomainObjPrivatePtr priv = obj->privateData;
|
||||||
bool custom_hypervisor_feat = false;
|
bool custom_hypervisor_feat = false;
|
||||||
|
|
||||||
if (virQEMUDriverIsPrivileged(driver) &&
|
if (driver->privileged &&
|
||||||
(cfg->user == 0 ||
|
(cfg->user == 0 ||
|
||||||
cfg->group == 0))
|
cfg->group == 0))
|
||||||
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, logCtxt);
|
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, logCtxt);
|
||||||
@ -7262,7 +7262,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
|
|||||||
ctxt->path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
|
ctxt->path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
|
||||||
|
|
||||||
if (cfg->stdioLogD) {
|
if (cfg->stdioLogD) {
|
||||||
ctxt->manager = virLogManagerNew(virQEMUDriverIsPrivileged(driver));
|
ctxt->manager = virLogManagerNew(driver->privileged);
|
||||||
if (!ctxt->manager)
|
if (!ctxt->manager)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -7292,7 +7292,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
|
|||||||
* we can't rely on logrotate. We don't use O_TRUNC since
|
* we can't rely on logrotate. We don't use O_TRUNC since
|
||||||
* it is better for SELinux policy if we truncate afterwards */
|
* it is better for SELinux policy if we truncate afterwards */
|
||||||
if (mode == QEMU_DOMAIN_LOG_CONTEXT_MODE_START &&
|
if (mode == QEMU_DOMAIN_LOG_CONTEXT_MODE_START &&
|
||||||
!virQEMUDriverIsPrivileged(driver) &&
|
!driver->privileged &&
|
||||||
ftruncate(ctxt->writefd, 0) < 0) {
|
ftruncate(ctxt->writefd, 0) < 0) {
|
||||||
virReportSystemError(errno, _("failed to truncate %s"),
|
virReportSystemError(errno, _("failed to truncate %s"),
|
||||||
ctxt->path);
|
ctxt->path);
|
||||||
@ -7436,7 +7436,7 @@ qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
|
|||||||
path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
|
path = g_strdup_printf("%s/%s.log", cfg->logDir, vm->def->name);
|
||||||
|
|
||||||
if (cfg->stdioLogD) {
|
if (cfg->stdioLogD) {
|
||||||
if (!(manager = virLogManagerNew(virQEMUDriverIsPrivileged(driver))))
|
if (!(manager = virLogManagerNew(driver->privileged)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virLogManagerDomainAppendMessage(manager, "qemu", vm->def->uuid,
|
if (virLogManagerDomainAppendMessage(manager, "qemu", vm->def->uuid,
|
||||||
@ -12991,7 +12991,7 @@ qemuDomainGetMachineName(virDomainObjPtr vm)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
ret = virDomainGenerateMachineName("qemu", cfg->root,
|
ret = virDomainGenerateMachineName("qemu", cfg->root,
|
||||||
vm->def->id, vm->def->name,
|
vm->def->id, vm->def->name,
|
||||||
virQEMUDriverIsPrivileged(driver));
|
driver->privileged);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ qemuSecurityInit(virQEMUDriverPtr driver)
|
|||||||
flags |= VIR_SECURITY_MANAGER_DEFAULT_CONFINED;
|
flags |= VIR_SECURITY_MANAGER_DEFAULT_CONFINED;
|
||||||
if (cfg->securityRequireConfined)
|
if (cfg->securityRequireConfined)
|
||||||
flags |= VIR_SECURITY_MANAGER_REQUIRE_CONFINED;
|
flags |= VIR_SECURITY_MANAGER_REQUIRE_CONFINED;
|
||||||
if (virQEMUDriverIsPrivileged(driver))
|
if (driver->privileged)
|
||||||
flags |= VIR_SECURITY_MANAGER_PRIVILEGED;
|
flags |= VIR_SECURITY_MANAGER_PRIVILEGED;
|
||||||
|
|
||||||
if (cfg->securityDriverNames &&
|
if (cfg->securityDriverNames &&
|
||||||
@ -333,7 +333,7 @@ qemuSecurityInit(virQEMUDriverPtr driver)
|
|||||||
mgr = NULL;
|
mgr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virQEMUDriverIsPrivileged(driver)) {
|
if (driver->privileged) {
|
||||||
if (cfg->dynamicOwnership)
|
if (cfg->dynamicOwnership)
|
||||||
flags |= VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP;
|
flags |= VIR_SECURITY_MANAGER_DYNAMIC_OWNERSHIP;
|
||||||
if (virBitmapIsBitSet(cfg->namespaces, QEMU_DOMAIN_NS_MOUNT))
|
if (virBitmapIsBitSet(cfg->namespaces, QEMU_DOMAIN_NS_MOUNT))
|
||||||
@ -1199,7 +1199,7 @@ static virDrvOpenStatus qemuConnectOpen(virConnectPtr conn,
|
|||||||
} else {
|
} else {
|
||||||
if (!virConnectValidateURIPath(conn->uri->path,
|
if (!virConnectValidateURIPath(conn->uri->path,
|
||||||
"qemu",
|
"qemu",
|
||||||
virQEMUDriverIsPrivileged(qemu_driver)))
|
qemu_driver->privileged))
|
||||||
return VIR_DRV_OPEN_ERROR;
|
return VIR_DRV_OPEN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9274,7 +9274,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom,
|
|||||||
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerTypeEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("CPU tuning is not available in session mode"));
|
_("CPU tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -9350,7 +9350,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
|
|||||||
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetBlkioParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Block I/O tuning is not available in session mode"));
|
_("Block I/O tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -9430,7 +9430,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
|
|||||||
if (virDomainGetBlkioParametersEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetBlkioParametersEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Block I/O tuning is not available in session mode"));
|
_("Block I/O tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -9526,7 +9526,7 @@ qemuDomainSetMemoryParameters(virDomainPtr dom,
|
|||||||
if (virDomainSetMemoryParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetMemoryParametersEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("Memory tuning is not available in session mode"));
|
_("Memory tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -9602,7 +9602,7 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
|
|||||||
if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetMemoryParametersEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("Memory tuning is not available in session mode"));
|
_("Memory tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -9789,7 +9789,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (def) {
|
if (def) {
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
||||||
_("NUMA tuning is not available in session mode"));
|
_("NUMA tuning is not available in session mode"));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -10263,7 +10263,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
if (virDomainSetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("CPU tuning is not available in session mode"));
|
_("CPU tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -10670,7 +10670,7 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom,
|
|||||||
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
if (virDomainGetSchedulerParametersFlagsEnsureACL(dom->conn, vm->def) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("CPU tuning is not available in session mode"));
|
_("CPU tuning is not available in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -410,7 +410,7 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
|
|||||||
|
|
||||||
if (net->backend.tap) {
|
if (net->backend.tap) {
|
||||||
tunpath = net->backend.tap;
|
tunpath = net->backend.tap;
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("cannot use custom tap device in session mode"));
|
_("cannot use custom tap device in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -538,7 +538,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
|
|||||||
|
|
||||||
if (net->backend.tap) {
|
if (net->backend.tap) {
|
||||||
tunpath = net->backend.tap;
|
tunpath = net->backend.tap;
|
||||||
if (!(virQEMUDriverIsPrivileged(driver))) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("cannot use custom tap device in session mode"));
|
_("cannot use custom tap device in session mode"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -562,7 +562,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def,
|
|||||||
if (virDomainNetIsVirtioModel(net))
|
if (virDomainNetIsVirtioModel(net))
|
||||||
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
|
tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR;
|
||||||
|
|
||||||
if (virQEMUDriverIsPrivileged(driver)) {
|
if (driver->privileged) {
|
||||||
if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
|
if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
|
||||||
def->uuid, tunpath, tapfd, *tapfdSize,
|
def->uuid, tunpath, tapfd, *tapfdSize,
|
||||||
virDomainNetGetActualVirtPortProfile(net),
|
virDomainNetGetActualVirtPortProfile(net),
|
||||||
|
@ -2979,7 +2979,7 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
|
case VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS:
|
||||||
if (!virQEMUDriverIsPrivileged(driver)) {
|
if (!driver->privileged) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("virtiofs is not yet supported in session mode"));
|
_("virtiofs is not yet supported in session mode"));
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user