提交 f8e923c1 编写于 作者: A Andrea Bolognani

qemu: Use switch statement in qemuBuildCpuCommandLine()

Make sure we are taking all possible virDomainTimerNameType values
into account. This will make upcoming changes easier.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 9b82e2c4
...@@ -6594,16 +6594,30 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, ...@@ -6594,16 +6594,30 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
for (i = 0; i < def->clock.ntimers; i++) { for (i = 0; i < def->clock.ntimers; i++) {
virDomainTimerDefPtr timer = def->clock.timers[i]; virDomainTimerDefPtr timer = def->clock.timers[i];
if (timer->name == VIR_DOMAIN_TIMER_NAME_KVMCLOCK && switch ((virDomainTimerNameType)timer->name) {
timer->present != -1) { case VIR_DOMAIN_TIMER_NAME_KVMCLOCK:
qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock", if (timer->present != -1) {
!!timer->present); qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock",
} else if (timer->name == VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK && !!timer->present);
timer->present == 1) { }
virBufferAddLit(&buf, ",hv-time"); break;
} else if (timer->name == VIR_DOMAIN_TIMER_NAME_TSC && case VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK:
timer->frequency > 0) { if (timer->present == 1)
virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency); virBufferAddLit(&buf, ",hv-time");
break;
case VIR_DOMAIN_TIMER_NAME_TSC:
if (timer->frequency > 0)
virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency);
break;
case VIR_DOMAIN_TIMER_NAME_PLATFORM:
case VIR_DOMAIN_TIMER_NAME_PIT:
case VIR_DOMAIN_TIMER_NAME_RTC:
case VIR_DOMAIN_TIMER_NAME_HPET:
break;
case VIR_DOMAIN_TIMER_NAME_LAST:
default:
virReportEnumRangeError(virDomainTimerNameType, timer->name);
return -1;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册