mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-06 17:17:56 +03:00
src: Convert some _virDomainSecDef::sectype checks to switch()
In a few instances there is a plain if() check for _virDomainSecDef::sectype. While this works perfectly for now, soon there'll be another type and we can utilize compiler to identify all the places that need adaptation. Switch those if() statements to switch(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
a44a43361f
commit
7d16c296e3
@ -845,10 +845,20 @@ qemuSetupDevicesCgroup(virDomainObj *vm)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (vm->def->sec &&
|
||||
vm->def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_SEV &&
|
||||
qemuSetupSEVCgroup(vm) < 0)
|
||||
return -1;
|
||||
if (vm->def->sec) {
|
||||
switch (vm->def->sec->sectype) {
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
if (qemuSetupSEVCgroup(vm) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, vm->def->sec->sectype);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -19111,10 +19111,22 @@ qemuDomainGetLaunchSecurityInfo(virDomainPtr domain,
|
||||
if (virDomainGetLaunchSecurityInfoEnsureACL(domain->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (vm->def->sec &&
|
||||
vm->def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_SEV) {
|
||||
if (!vm->def->sec) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
switch (vm->def->sec->sectype) {
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
if (qemuDomainGetSEVInfo(vm, params, nparams, flags) < 0)
|
||||
goto cleanup;
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, vm->def->sec->sectype);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
@ -6741,11 +6741,20 @@ qemuProcessPrepareDomain(virQEMUDriver *driver,
|
||||
for (i = 0; i < vm->def->nshmems; i++)
|
||||
qemuDomainPrepareShmemChardev(vm->def->shmems[i]);
|
||||
|
||||
if (vm->def->sec &&
|
||||
vm->def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_SEV) {
|
||||
VIR_DEBUG("Updating SEV platform info");
|
||||
if (qemuProcessUpdateSEVInfo(vm) < 0)
|
||||
if (vm->def->sec) {
|
||||
switch (vm->def->sec->sectype) {
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
VIR_DEBUG("Updating SEV platform info");
|
||||
if (qemuProcessUpdateSEVInfo(vm) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, vm->def->sec->sectype);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1951,10 +1951,19 @@ virSecurityDACRestoreAllLabel(virSecurityManager *mgr,
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
if (def->sec &&
|
||||
def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_SEV) {
|
||||
if (virSecurityDACRestoreSEVLabel(mgr, def) < 0)
|
||||
rc = -1;
|
||||
if (def->sec) {
|
||||
switch (def->sec->sectype) {
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
if (virSecurityDACRestoreSEVLabel(mgr, def) < 0)
|
||||
rc = -1;
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, def->sec->sectype);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < def->nsysinfo; i++) {
|
||||
@ -2175,10 +2184,19 @@ virSecurityDACSetAllLabel(virSecurityManager *mgr,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (def->sec &&
|
||||
def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_SEV) {
|
||||
if (virSecurityDACSetSEVLabel(mgr, def) < 0)
|
||||
if (def->sec) {
|
||||
switch (def->sec->sectype) {
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
if (virSecurityDACSetSEVLabel(mgr, def) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, def->sec->sectype);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (virSecurityDACGetImageIds(secdef, priv, &user, &group))
|
||||
|
Loading…
Reference in New Issue
Block a user