virt-install: Add --pm option

This commit is contained in:
Cole Robinson
2014-02-03 11:11:38 -05:00
parent 4fbee9aa41
commit 0654784643
14 changed files with 94 additions and 2 deletions
+7
View File
@@ -238,6 +238,13 @@ might be catchup, delay, etc. Refer to the libvirt docs for all values.
Use --clock=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsTime>
=item --pm=PMOPTS
Configure guest power management features. Example suboptions include suspend_to_ram=on|off and suspend_to_disk=on|off
Use --pm=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsPowerManagement>
=back
+2
View File
@@ -188,6 +188,8 @@ Before defining or updating the domain, show the generated XML diff and interact
=item --clock
=item --pm
=item --boot
=item --filesystem
@@ -28,6 +28,10 @@
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled="yes"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/test-hv</emulator>
<disk type="file" device="disk">
@@ -147,6 +151,10 @@
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled="yes"/>
<suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/bin/test-hv</emulator>
<disk type="file" device="disk">
@@ -0,0 +1,12 @@
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
- <suspend-to-mem enabled="no"/>
+ <suspend-to-mem enabled="yes"/>
+ <suspend-to-disk enabled="no"/>
</pm>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
Domain 'test-many-devices' defined successfully.
Changes will take effect after the next domain shutdown.
+2
View File
@@ -566,6 +566,7 @@ c.add_compare("""--hvm --pxe \
--host-device net_00_1c_25_10_b1_e4 \
--features acpi=off,eoi=on,privnet=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234 \
--clock offset=localtime,hpet_present=no,rtc_tickpolicy=merge \
--pm suspend_to_mem=yes,suspend_to_disk=no \
""", "many-devices") # Lots of devices
c.add_valid("--hvm --disk path=virt-install,device=cdrom") # Specifying cdrom media via --disk
c.add_valid("--hvm --import --disk path=virt-install") # FV Import install
@@ -800,6 +801,7 @@ c.add_compare("--boot loader=foo.bar,network,useserial=on,init=/bin/bash", "virt
c.add_compare("--security label=foo,bar,baz,UNKNOWN=val,relabel=on", "virtxml-edit-simple-security")
c.add_compare("--features eoi=on,hyperv_relaxed=off,acpi=", "virtxml-edit-simple-features")
c.add_compare("--clock offset=localtime,hpet_present=yes,kvmclock_present=no,rtc_tickpolicy=merge", "virtxml-edit-simple-clock")
c.add_compare("--pm suspend_to_mem=yes,suspend_to_disk=no", "virtxml-edit-simple-pm")
c.add_compare("--disk /dev/zero,perms=ro,startup_policy=optional", "virtxml-edit-simple-disk")
c.add_compare("--disk path=", "virtxml-edit-simple-disk-remove-path")
c.add_compare("--network source=br0,type=bridge,model=virtio,mac=", "virtxml-edit-simple-network")
+5
View File
@@ -108,6 +108,11 @@
<feature policy="require" name="xtpr"/>
<feature policy="require" name="acpi"/>
</cpu>
<pm>
<suspend-to-mem enabled='no'/>
</pm>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+1 -1
View File
@@ -29,7 +29,7 @@ from virtinst import VirtualGraphics
from virtinst import VirtualVideoDevice
# Enable this to refresh test output
REGENERATE_OUTPUT = False
REGENERATE_OUTPUT = True
# pylint: disable=W0212
# Access to protected member, needed to unittest stuff
+3
View File
@@ -33,6 +33,9 @@
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
</pm>
<vcpu cpuset="1-3">5</vcpu>
<devices>
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
+4
View File
@@ -37,6 +37,10 @@
<on_poweroff>restart</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled="yes"/>
<suspend-to-disk enabled="no"/>
</pm>
<vcpu cpuset="1-5,15" current="10">12</vcpu>
<devices>
<emulator>/usr/binnnn/fooemu</emulator>
+4
View File
@@ -133,6 +133,10 @@ class XMLParseTest(unittest.TestCase):
check("name", None, "hpet")
check("present", None, False)
check = self._make_checker(guest.pm)
check("suspend_to_mem", False, True)
check("suspend_to_disk", None, False)
check = self._make_checker(guest.seclabel)
check("type", "static", "static")
check("model", "selinux", "apparmor")
+1
View File
@@ -29,6 +29,7 @@ from virtinst.domainnumatune import DomainNumatune
from virtinst.clock import Clock
from virtinst.cpu import CPU, CPUFeature
from virtinst.seclabel import Seclabel
from virtinst.pm import PM
import virtinst.capabilities as CapabilitiesParser
from virtinst.interface import Interface, InterfaceProtocol
+15
View File
@@ -943,6 +943,7 @@ def add_guest_xml_options(geng):
geng.add_argument("--clock",
help=_("Set domain <clock> XML. Ex:\n"
"--clock offset=localtime,rtc_tickpolicy=catchup"))
geng.add_argument("--pm", help=_("Config power management features"))
def add_boot_option(insg):
@@ -1615,6 +1616,18 @@ class ParserClock(VirtCLIParser):
self.set_param(None, tname + "_tickpolicy", setter_cb=set_timer)
################
# --pm parsing #
################
class ParserPM(VirtCLIParser):
def _init_params(self):
self.clear_attr = "pm"
self.set_param("pm.suspend_to_mem", "suspend_to_mem", is_onoff=True)
self.set_param("pm.suspend_to_disk", "suspend_to_disk", is_onoff=True)
##########################
# Guest <device> parsing #
##########################
@@ -2222,6 +2235,8 @@ def build_parser_map(options, skip=None, only=None):
register_parser("security", ParserSecurity)
register_parser("features", ParserFeatures)
register_parser("clock", ParserClock)
register_parser("pm", ParserPM)
register_parser("features", ParserFeatures)
register_parser("disk", ParserDisk)
register_parser("network", ParserNetwork)
register_parser("graphics", ParserGraphics)
+3 -1
View File
@@ -36,6 +36,7 @@ from virtinst import Seclabel
from virtinst import CPU
from virtinst import DomainNumatune
from virtinst import DomainFeatures
from virtinst import PM
from virtinst.xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty
from virtinst import osdict
@@ -90,7 +91,7 @@ class Guest(XMLBuilder):
_XML_PROP_ORDER = ["type", "name", "uuid", "title", "description",
"maxmemory", "memory", "hugepage", "vcpus", "curvcpus",
"numatune", "bootloader", "os", "features", "cpu", "clock",
"on_poweroff", "on_reboot", "on_crash", "emulator", "_devices",
"on_poweroff", "on_reboot", "on_crash", "pm", "emulator", "_devices",
"seclabel"]
def __init__(self, *args, **kwargs):
@@ -183,6 +184,7 @@ class Guest(XMLBuilder):
seclabel = XMLChildProperty(Seclabel, is_single=True)
cpu = XMLChildProperty(CPU, is_single=True)
numatune = XMLChildProperty(DomainNumatune, is_single=True)
pm = XMLChildProperty(PM, is_single=True)
###############################
+27
View File
@@ -0,0 +1,27 @@
#
# Copyright 2014 Red Hat, Inc.
# Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
from virtinst.xmlbuilder import XMLBuilder, XMLProperty
class PM(XMLBuilder):
_XML_ROOT_NAME = "pm"
suspend_to_mem = XMLProperty("./suspend-to-mem/@enabled", is_yesno=True)
suspend_to_disk = XMLProperty("./suspend-to-disk/@enabled", is_yesno=True)