cli: --clock: Explicitly register options

Rather than do so based off the TIMER_NAMES list. Makes it less
easy to accidentally break cli API
This commit is contained in:
Cole Robinson 2019-05-12 18:51:54 -04:00
parent 167bae862b
commit a1165b2981
2 changed files with 33 additions and 9 deletions

View File

@ -25,7 +25,7 @@ from virtcli import CLIConfig
from . import util
from .devices import (Device, DeviceController, DeviceDisk, DeviceGraphics,
DeviceInterface, DevicePanic)
from .domain import DomainClock, DomainOs
from .domain import DomainOs
from .nodedev import NodeDevice
from .storage import StoragePool, StorageVolume
from .unattended import UnattendedData
@ -2229,14 +2229,40 @@ class ParserClock(VirtCLIParser):
@classmethod
def _init_class(cls, **kwargs):
VirtCLIParser._init_class(**kwargs)
cls.add_arg("offset", "offset")
for _tname in DomainClock.TIMER_NAMES:
cls.add_arg(_tname + "_present", None, lookup_cb=None,
is_onoff=True,
# Timer convenience helpers
cls.add_arg("platform_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg(_tname + "_tickpolicy", None, lookup_cb=None,
cls.add_arg("pit_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg("rtc_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg("hpet_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg("tsc_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg("kvmclock_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg("hypervclock_tickpolicy", None, lookup_cb=None,
cb=cls.set_timer)
cls.add_arg("platform_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
cls.add_arg("pit_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
cls.add_arg("rtc_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
cls.add_arg("hpet_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
cls.add_arg("tsc_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
cls.add_arg("kvmclock_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
cls.add_arg("hypervclock_present", None, lookup_cb=None, is_onoff=True,
cb=cls.set_timer)
# Standard XML options
cls.add_arg("offset", "offset")
################

View File

@ -18,12 +18,10 @@ class _ClockTimer(XMLBuilder):
class DomainClock(XMLBuilder):
XML_NAME = "clock"
TIMER_NAMES = ["platform", "pit", "rtc", "hpet", "tsc", "kvmclock",
"hypervclock"]
offset = XMLProperty("./@offset")
timers = XMLChildProperty(_ClockTimer)
##################
# Default config #
##################