diff --git a/man/virt-install.pod b/man/virt-install.pod index 8aa7ead67..7268a6463 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -129,6 +129,12 @@ Specify events values for the guest. Possible options include on_poweroff, on_re Use --events=? to see a list of all available sub options. Complete details at L +=item --resource OPT=VAL,[...] + +Specify resource partitioning for the guest. + +Use --resource=? to see a list of all available sub options. Complete details at L + =item --vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#][,cpuset=CPUSET] Number of virtual cpus to configure for the guest. If 'maxvcpus' is specified, diff --git a/tests/clitest.py b/tests/clitest.py index 3f44e9162..bb605a5cd 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -472,6 +472,7 @@ c.add_valid("--blkiotune weight=100,device_path=/home/test/1.img,device_weight=2 c.add_valid("--memtune hard_limit=10,soft_limit=20,swap_hard_limit=30,min_guarantee=40") # --memtune c.add_valid("--memorybacking hugepages=yes,nosharepages=yes,locked=yes") # --memorybacking nosharepages,locked c.add_valid("--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10") # --idmap +c.add_valid("--resource partition=/virtualmachines/production") # --resource c.add_compare("--connect %(DEFAULTURI)s --cpuset auto --vcpus 2", "cpuset-auto") # --cpuset=auto actually works c.add_invalid("--vcpus 32 --cpuset=969-1000") # Bogus cpuset c.add_invalid("--vcpus 32 --cpuset=autofoo") # Bogus cpuset diff --git a/tests/xmlparse-xml/change-guest-out.xml b/tests/xmlparse-xml/change-guest-out.xml index 42a8ae299..e2638bd92 100644 --- a/tests/xmlparse-xml/change-guest-out.xml +++ b/tests/xmlparse-xml/change-guest-out.xml @@ -86,6 +86,9 @@ + + /virtualmachines/production + 2048 200 diff --git a/tests/xmlparse.py b/tests/xmlparse.py index a1ca94146..0295d60f6 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -213,6 +213,9 @@ class XMLParseTest(unittest.TestCase): check("gid_target", None, 1000) check("gid_count", None, 10) + check = self._make_checker(guest.resource) + check("partition", None, "/virtualmachines/production") + check = self._make_checker(guest.get_devices("memballoon")[0]) check("model", "virtio", "none") diff --git a/virtinst/__init__.py b/virtinst/__init__.py index 31beae411..8c4cc1407 100644 --- a/virtinst/__init__.py +++ b/virtinst/__init__.py @@ -29,6 +29,7 @@ from virtinst.domainnumatune import DomainNumatune from virtinst.domainblkiotune import DomainBlkiotune from virtinst.domainmemorytune import DomainMemorytune from virtinst.domainmemorybacking import DomainMemorybacking +from virtinst.domainresource import DomainResource from virtinst.clock import Clock from virtinst.cpu import CPU, CPUFeature from virtinst.seclabel import Seclabel diff --git a/virtinst/cli.py b/virtinst/cli.py index a309f1dd7..921feeaf5 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -800,6 +800,8 @@ def add_guest_xml_options(geng): geng.add_argument("--pm", help=_("Config power management features")) geng.add_argument("--events", help=_("Config OS lifecycle operation management features")) + geng.add_argument("--resource", action="append", + help=_("Config OS resource management features")) def add_boot_options(insg): @@ -1239,6 +1241,18 @@ class ParserEvents(VirtCLIParser): self.set_param("on_crash", "on_crash") +###################### +# --resource parsing # +###################### + +class ParserResource(VirtCLIParser): + def _init_params(self): + self.remove_first = "partition" + self.clear_attr = "resource" + + self.set_param("resource.partition", "partition") + + ###################### # --numatune parsing # ###################### @@ -2234,6 +2248,7 @@ def build_parser_map(options, skip=None, only=None): register_parser("metadata", ParserMetadata) register_parser("events", ParserEvents) + register_parser("resource", ParserResource) register_parser("memory", ParserMemory) register_parser("memtune", ParserMemorytune) register_parser("vcpus", ParserVCPU) diff --git a/virtinst/domainresource.py b/virtinst/domainresource.py new file mode 100644 index 000000000..102409a17 --- /dev/null +++ b/virtinst/domainresource.py @@ -0,0 +1,31 @@ +# +# Copyright 2014 Fujitsu Limited. +# Chen Hanxiao +# +# 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 DomainResource(XMLBuilder): + """ + Class for generating XML + """ + + _XML_ROOT_NAME = "resource" + _XML_PROP_ORDER = ["partition"] + + partition = XMLProperty("./partition") diff --git a/virtinst/guest.py b/virtinst/guest.py index df43a5e29..a59f59eee 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -39,6 +39,7 @@ from virtinst import DomainMemorytune from virtinst import DomainMemorybacking from virtinst import DomainBlkiotune from virtinst import DomainFeatures +from virtinst import DomainResource from virtinst import PM from virtinst import IdMap from virtinst.xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty @@ -93,9 +94,9 @@ class Guest(XMLBuilder): _XML_ROOT_NAME = "domain" _XML_PROP_ORDER = ["type", "name", "uuid", "title", "description", - "maxmemory", "memory", "memoryBacking", "vcpus", "curvcpus", "memtune", - "numatune", "blkiotune", "bootloader", "os", "idmap", "features", - "cpu", "clock", "on_poweroff", "on_reboot", "on_crash", "pm", + "maxmemory", "memory", "memoryBacking", "vcpus", "resource", "curvcpus", + "memtune", "numatune", "blkiotune", "bootloader", "os", "idmap", + "features", "cpu", "clock", "on_poweroff", "on_reboot", "on_crash", "pm", "emulator", "_devices", "seclabel"] def __init__(self, *args, **kwargs): @@ -196,6 +197,7 @@ class Guest(XMLBuilder): memtune = XMLChildProperty(DomainMemorytune, is_single=True) memoryBacking = XMLChildProperty(DomainMemorybacking, is_single=True) idmap = XMLChildProperty(IdMap, is_single=True) + resource = XMLChildProperty(DomainResource, is_single=True) ###############################