clock: Add timer parsing

This commit is contained in:
Cole Robinson 2013-10-05 16:05:31 -04:00
parent fdb79b9832
commit a163f44a27
4 changed files with 33 additions and 3 deletions

View File

@ -26,7 +26,10 @@
<feature policy='optional' name='cr8legacy'/>
<feature name='foo' policy='bar'/>
</cpu>
<clock offset="utc"/>
<clock offset="utc">
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>

View File

@ -30,7 +30,10 @@
<feature policy="optional" name="cr8legacy"/>
<feature name="addfeature" policy="require"/>
</cpu>
<clock offset="localtime"/>
<clock offset="localtime">
<timer name="rtc" tickpolicy="merge"/>
<timer name="hpet" present="no"/>
</clock>
<on_poweroff>restart</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>

View File

@ -123,6 +123,14 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(guest.clock)
check("offset", "utc", "localtime")
guest.clock.remove_timer(guest.clock.timers[0])
check = self._make_checker(guest.clock.timers[0])
check("name", "pit", "rtc")
check("tickpolicy", "delay", "merge")
timer = guest.clock.add_timer()
check = self._make_checker(timer)
check("name", None, "hpet")
check("present", None, False)
check = self._make_checker(guest.seclabel)
check("type", "static", "static")

View File

@ -17,10 +17,26 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
from virtinst.xmlbuilder import XMLBuilder, XMLProperty
from virtinst.xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
class _ClockTimer(XMLBuilder):
_XML_ROOT_NAME = "timer"
name = XMLProperty("./@name")
present = XMLProperty("./@present", is_yesno=True)
tickpolicy = XMLProperty("./@tickpolicy")
class Clock(XMLBuilder):
_XML_ROOT_NAME = "clock"
offset = XMLProperty("./@offset")
timers = XMLChildProperty(_ClockTimer)
def add_timer(self):
obj = _ClockTimer(self.conn)
self._add_child(obj)
return obj
def remove_timer(self, obj):
self._remove_child(obj)