mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
cli: support --sysinfo type=fwcfg,entry...
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
5643a560d5
commit
65f93e5d60
@ -38,6 +38,9 @@
|
||||
<entry name="location">Chassis</entry>
|
||||
</baseBoard>
|
||||
</sysinfo>
|
||||
<sysinfo type="fwcfg">
|
||||
<entry name="foo" file="bar">baz</entry>
|
||||
</sysinfo>
|
||||
<os>
|
||||
<type arch="x86_64" machine="q35">hvm</type>
|
||||
<loader readonly="yes" type="rom">/tmp/foo</loader>
|
||||
|
@ -540,6 +540,7 @@ memnode0.cellid=1,memnode0.mode=strict,memnode0.nodeset=2
|
||||
--sysinfo type=smbios,baseBoard_manufacturer="Acme Corp.",baseBoard_product=Motherboard,baseBoard_version=A01,baseBoard_serial=1234-5678,baseBoard_asset=Tag,baseBoard_location=Chassis
|
||||
--sysinfo type=smbios,chassis.manufacturer="Chassis Corp.",chassis.serial=1234chassis,chassis.asset=chasset,chassis.sku=chassku,chassis.version=4.0
|
||||
--sysinfo type=smbios,oemStrings.entry2="complicated parsing, foo=bar",oemStrings.entry1=test1,oemStrings.entry0=test0
|
||||
|
||||
--pm suspend_to_mem=yes,suspend_to_disk=no
|
||||
--resource partition=/virtualmachines/production
|
||||
--events on_poweroff=destroy,on_reboot=restart,on_crash=preserve,on_lockfailure=ignore
|
||||
@ -576,6 +577,7 @@ c.add_compare("""
|
||||
--memballoon default
|
||||
|
||||
--sysinfo bios.vendor="Acme LLC",bios.version=1.2.3,bios.date=01/01/1970,bios.release=10.22,system.manufacturer="Acme Inc.",system.product=Computer,system.version=3.2.1,system.serial=123456789,system.uuid=00000000-1111-2222-3333-444444444444,system.sku=abc-123,system.family=Server,baseBoard.manufacturer="Acme Corp.",baseBoard.product=Motherboard,baseBoard.version=A01,baseBoard.serial=1234-5678,baseBoard.asset=Tag,baseBoard.location=Chassis
|
||||
--sysinfo type=fwcfg,entry0.name=foo,entry0.file=bar,entry0=baz
|
||||
""", "singleton-config-3", predefine_check="5.7.0")
|
||||
|
||||
|
||||
|
@ -2837,13 +2837,24 @@ class ParserSysinfo(VirtCLIParser):
|
||||
"baseBoard.location": "baseBoard_location",
|
||||
}
|
||||
|
||||
def _parse(self, inst):
|
||||
def parse(self, inst):
|
||||
if self.optstr and 'type' not in self.optdict:
|
||||
# If any string specified, default to type=smbios otherwise
|
||||
# libvirt errors. User args can still override this though
|
||||
self.optdict['type'] = 'smbios'
|
||||
|
||||
return super()._parse(inst)
|
||||
# Previously libvirt treated sysinfo as a singleton object, but
|
||||
# that changed with fwcfg support. Our cli would merge all options
|
||||
# together but now needs to support multiple. Maintain sorta
|
||||
# backcompat behavior by mergin options if 'type' matches
|
||||
if not inst:
|
||||
typ = self.optdict["type"]
|
||||
for sysinfo in self.guest.sysinfo:
|
||||
if sysinfo.type == typ:
|
||||
inst = sysinfo
|
||||
break
|
||||
|
||||
return super().parse(inst)
|
||||
|
||||
|
||||
###################
|
||||
@ -2874,6 +2885,14 @@ class ParserSysinfo(VirtCLIParser):
|
||||
cb = self._make_find_inst_cb(cliarg, list_propname)
|
||||
return cb(*args, **kwargs)
|
||||
|
||||
def entry_find_inst_cb(self, *args, **kwargs):
|
||||
# pylint: disable=protected-access
|
||||
cliarg = "entry" # entry[0-9]*
|
||||
list_propname = "entries" # sysinfo.entries
|
||||
cb = self._make_find_inst_cb(cliarg, list_propname)
|
||||
return cb(*args, **kwargs)
|
||||
|
||||
|
||||
@classmethod
|
||||
def _init_class(cls, **kwargs):
|
||||
VirtCLIParser._init_class(**kwargs)
|
||||
@ -2909,9 +2928,16 @@ class ParserSysinfo(VirtCLIParser):
|
||||
cls.add_arg("chassis.asset", "chassis_asset")
|
||||
cls.add_arg("chassis.sku", "chassis_sku")
|
||||
|
||||
cls.add_arg("oemStrings.entry[0-9]", "value", can_comma=True,
|
||||
cls.add_arg("oemStrings.entry[0-9]*", "value", can_comma=True,
|
||||
find_inst_cb=cls.oem_find_inst_cb)
|
||||
|
||||
cls.add_arg("entry[0-9]*", "value", can_comma=True,
|
||||
find_inst_cb=cls.entry_find_inst_cb)
|
||||
cls.add_arg("entry[0-9]*.name", "name", can_comma=True,
|
||||
find_inst_cb=cls.entry_find_inst_cb)
|
||||
cls.add_arg("entry[0-9]*.file", "file", can_comma=True,
|
||||
find_inst_cb=cls.entry_find_inst_cb)
|
||||
|
||||
|
||||
##############################
|
||||
# --qemu-commandline parsing #
|
||||
|
@ -10,7 +10,13 @@ from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
|
||||
class _SysinfoEntry(XMLBuilder):
|
||||
XML_NAME = "entry"
|
||||
name = XMLProperty("./@name")
|
||||
value = XMLProperty(".")
|
||||
file = XMLProperty("./@file")
|
||||
|
||||
|
||||
class _SysinfoOemString(_SysinfoEntry):
|
||||
pass
|
||||
|
||||
|
||||
class DomainSysinfo(XMLBuilder):
|
||||
@ -57,4 +63,6 @@ class DomainSysinfo(XMLBuilder):
|
||||
chassis_asset = XMLProperty("./chassis/entry[@name='asset']")
|
||||
chassis_sku = XMLProperty("./chassis/entry[@name='sku']")
|
||||
|
||||
oemStrings = XMLChildProperty(_SysinfoEntry, relative_xpath="./oemStrings")
|
||||
oemStrings = XMLChildProperty(
|
||||
_SysinfoOemString, relative_xpath="./oemStrings")
|
||||
entries = XMLChildProperty(_SysinfoEntry)
|
||||
|
@ -277,7 +277,7 @@ class Guest(XMLBuilder):
|
||||
memoryBacking = XMLChildProperty(DomainMemoryBacking, is_single=True)
|
||||
idmap = XMLChildProperty(DomainIdmap, is_single=True)
|
||||
resource = XMLChildProperty(DomainResource, is_single=True)
|
||||
sysinfo = XMLChildProperty(DomainSysinfo, is_single=True)
|
||||
sysinfo = XMLChildProperty(DomainSysinfo)
|
||||
launchSecurity = XMLChildProperty(DomainLaunchSecurity, is_single=True)
|
||||
_metadata = XMLChildProperty(DomainMetadata, is_single=True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user