mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
conf: Enforce supported options for certain timers
According to the documentation various timer options are only supported by certain timer types. Add a post parse check to verify that the user didn't specify invalid options. Also fix the qemu command line parsing function to set correct default values for the kvmclock timer so that it passes the new check.
This commit is contained in:
parent
bbd392ff86
commit
8ffaa42d7b
@ -2924,6 +2924,61 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
|
||||
|
||||
if (virDomainDefRejectDuplicateControllers(def) < 0)
|
||||
return -1;
|
||||
|
||||
/* verify settings of guest timers */
|
||||
for (i = 0; i < def->clock.ntimers; i++) {
|
||||
virDomainTimerDefPtr timer = def->clock.timers[i];
|
||||
|
||||
if (timer->name == VIR_DOMAIN_TIMER_NAME_KVMCLOCK) {
|
||||
if (timer->tickpolicy != -1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("timer %s doesn't support setting of "
|
||||
"timer tickpolicy"),
|
||||
virDomainTimerNameTypeToString(timer->name));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (timer->tickpolicy != VIR_DOMAIN_TIMER_TICKPOLICY_CATCHUP &&
|
||||
(timer->catchup.threshold != 0 ||
|
||||
timer->catchup.limit != 0 ||
|
||||
timer->catchup.slew != 0)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("setting of timer catchup policies is only "
|
||||
"supported with tickpolicy='catchup'"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (timer->name != VIR_DOMAIN_TIMER_NAME_TSC) {
|
||||
if (timer->frequency != 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("timer %s doesn't support setting of "
|
||||
"timer frequency"),
|
||||
virDomainTimerNameTypeToString(timer->name));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (timer->mode != -1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("timer %s doesn't support setting of "
|
||||
"timer mode"),
|
||||
virDomainTimerNameTypeToString(timer->name));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (timer->name != VIR_DOMAIN_TIMER_NAME_PLATFORM &&
|
||||
timer->name != VIR_DOMAIN_TIMER_NAME_RTC) {
|
||||
if (timer->track != -1) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("timer %s doesn't support setting of "
|
||||
"timer track"),
|
||||
virDomainTimerNameTypeToString(timer->name));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -10924,6 +10924,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
|
||||
dom->clock.timers[j]->present = present;
|
||||
dom->clock.timers[j]->tickpolicy = -1;
|
||||
dom->clock.timers[j]->track = -1;
|
||||
dom->clock.timers[j]->mode = -1;
|
||||
dom->clock.ntimers++;
|
||||
} else if (dom->clock.timers[j]->present != -1 &&
|
||||
dom->clock.timers[j]->present != present) {
|
||||
|
Loading…
Reference in New Issue
Block a user