diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c index fe567f440c48645ac8953a4d74e0d6f7ee6be6d2..afec0e53284fe3e3b1590556d107e23ab3bf570e 100644 --- a/src/qemu/qemu_tpm.c +++ b/src/qemu/qemu_tpm.c @@ -680,14 +680,9 @@ qemuExtTPMInitPaths(virQEMUDriverPtr driver, { g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); - switch (def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) return qemuTPMEmulatorInitPaths(def->tpm, cfg->swtpmStorageDir, def->uuid); - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; - } return 0; } @@ -700,8 +695,7 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); g_autofree char *shortName = NULL; - switch (def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { shortName = virDomainDefGetShortName(def); if (!shortName) return -1; @@ -711,9 +705,6 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, cfg->swtpm_group, cfg->swtpmStateDir, cfg->user, shortName); - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } return 0; @@ -723,15 +714,8 @@ qemuExtTPMPrepareHost(virQEMUDriverPtr driver, void qemuExtTPMCleanupHost(virDomainDefPtr def) { - switch (def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) qemuTPMDeleteEmulatorStorage(def->tpm); - break; - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - /* nothing to do */ - break; - } } @@ -825,15 +809,9 @@ qemuExtTPMStart(virQEMUDriverPtr driver, { virDomainTPMDefPtr tpm = vm->def->tpm; - switch (tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) return qemuExtTPMStartEmulator(driver, vm, incomingMigration); - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; - } - return 0; } @@ -845,18 +823,13 @@ qemuExtTPMStop(virQEMUDriverPtr driver, g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver); g_autofree char *shortName = NULL; - switch (vm->def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (vm->def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { shortName = virDomainDefGetShortName(vm->def); if (!shortName) return; qemuTPMEmulatorStop(cfg->swtpmStateDir, shortName); qemuSecurityCleanupTPMEmulator(driver, vm); - break; - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } return; @@ -873,8 +846,7 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, int rc; pid_t pid; - switch (def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { shortName = virDomainDefGetShortName(def); if (!shortName) return -1; @@ -886,10 +858,6 @@ qemuExtTPMSetupCgroup(virQEMUDriverPtr driver, } if (virCgroupAddProcess(cgroup, pid) < 0) return -1; - break; - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } return 0; diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index 4cc2707c3b0b1d12ac0191dab8f613561ed94543..a16de2466daf56e05e506504e8ed3d7fd9725356 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -3532,10 +3532,7 @@ virSecuritySELinuxSetTPMLabels(virSecurityManagerPtr mgr, if (seclabel == NULL) return 0; - switch (def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - break; - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { ret = virSecuritySELinuxSetFileLabels( mgr, def->tpm->data.emulator.storagepath, seclabel); @@ -3543,9 +3540,6 @@ virSecuritySELinuxSetTPMLabels(virSecurityManagerPtr mgr, ret = virSecuritySELinuxSetFileLabels( mgr, def->tpm->data.emulator.logfile, seclabel); - break; - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } return ret; @@ -3558,18 +3552,12 @@ virSecuritySELinuxRestoreTPMLabels(virSecurityManagerPtr mgr, { int ret = 0; - switch (def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - break; - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { ret = virSecuritySELinuxRestoreFileLabels( mgr, def->tpm->data.emulator.storagepath); if (ret == 0 && def->tpm->data.emulator.logfile) ret = virSecuritySELinuxRestoreFileLabels( mgr, def->tpm->data.emulator.logfile); - break; - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } return ret; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 34c281100ef42fd1b1475361dfd9b47dc2121860..7e8f0a84be10065f7ed868b37102116faff7fb85 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1222,8 +1222,7 @@ get_files(vahControl * ctl) char *shortName = NULL; const char *tpmpath = NULL; - switch (ctl->def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (ctl->def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { shortName = virDomainDefGetShortName(ctl->def); switch (ctl->def->tpm->version) { @@ -1256,10 +1255,6 @@ get_files(vahControl * ctl) RUNSTATEDIR, shortName); VIR_FREE(shortName); - break; - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } } diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 6df5a3597cf55812fc8f2a530224ffa16f9a6725..7d7aff77ef886a5b41e0291da6677ad94c86c2ba 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -438,15 +438,10 @@ testCompareXMLToArgvCreateArgs(virQEMUDriverPtr drv, } if (vm->def->tpm) { - switch (vm->def->tpm->type) { - case VIR_DOMAIN_TPM_TYPE_EMULATOR: + if (vm->def->tpm->type == VIR_DOMAIN_TPM_TYPE_EMULATOR) { VIR_FREE(vm->def->tpm->data.emulator.source.data.file.path); vm->def->tpm->data.emulator.source.data.file.path = g_strdup("/dev/test"); vm->def->tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_FILE; - break; - case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH: - case VIR_DOMAIN_TPM_TYPE_LAST: - break; } }