494e2d1303
d8a0a788-xmlbuilder-01.patch 559e813b-xmlbuilder-02.patch a931a1a6-xmlbuilder-03.patch 835ddc5f-xmlbuilder-04.patch b08647c2-xmlbuilder-05.patch b31c0b44-Add-classes-for-defining-SMBios-information.patch a3206f89-Add-the-sysinfo-option.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=329
259 lines
10 KiB
Diff
259 lines
10 KiB
Diff
Subject: virtinst: Add the --sysinfo option
|
|
From: Charles Arnold carnold@suse.com Tue Sep 6 16:12:20 2016 -0600
|
|
Date: Thu Sep 8 11:36:59 2016 -0400:
|
|
Git: a3206f89c89ff4f197748f2a7d1040380afc835d
|
|
|
|
Allow passing SMBios information to the guest using the new sysinfo
|
|
option. Also update the appropriate files with test cases.
|
|
|
|
Index: virt-manager-1.4.0/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
|
|
===================================================================
|
|
--- virt-manager-1.4.0.orig/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
|
|
+++ virt-manager-1.4.0/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
|
|
@@ -36,6 +36,7 @@
|
|
<boot dev="fd"/>
|
|
<boot dev="hd"/>
|
|
<boot dev="network"/>
|
|
+ <smbios mode="sysinfo"/>
|
|
<bootmenu enable="no"/>
|
|
</os>
|
|
<idmap>
|
|
@@ -122,6 +123,31 @@
|
|
<seclabel type="static" model="selinux" relabel="yes">
|
|
<label>system_u:object_r:svirt_image_t:s0:c100,c200</label>
|
|
</seclabel>
|
|
+ <sysinfo type="smbios">
|
|
+ <bios>
|
|
+ <entry name="vendor">Acme LLC</entry>
|
|
+ <entry name="version">1.2.3</entry>
|
|
+ <entry name="date">01/01/1970</entry>
|
|
+ <entry name="release">10.22</entry>
|
|
+ </bios>
|
|
+ <system>
|
|
+ <entry name="manufacturer">Acme Inc.</entry>
|
|
+ <entry name="product">Computer</entry>
|
|
+ <entry name="version">3.2.1</entry>
|
|
+ <entry name="serial">123456789</entry>
|
|
+ <entry name="uuid">00000000-1111-2222-3333-444444444444</entry>
|
|
+ <entry name="sku">abc-123</entry>
|
|
+ <entry name="family">Server</entry>
|
|
+ </system>
|
|
+ <baseBoard>
|
|
+ <entry name="manufacturer">Acme Corp.</entry>
|
|
+ <entry name="product">Motherboard</entry>
|
|
+ <entry name="version">A01</entry>
|
|
+ <entry name="serial">1234-5678</entry>
|
|
+ <entry name="asset">Tag</entry>
|
|
+ <entry name="location">Chassis</entry>
|
|
+ </baseBoard>
|
|
+ </sysinfo>
|
|
<on_lockfailure>ignore</on_lockfailure>
|
|
</domain>
|
|
<domain type="kvm">
|
|
@@ -162,6 +188,7 @@
|
|
<boot dev="fd"/>
|
|
<boot dev="hd"/>
|
|
<boot dev="network"/>
|
|
+ <smbios mode="sysinfo"/>
|
|
<bootmenu enable="no"/>
|
|
</os>
|
|
<idmap>
|
|
@@ -248,5 +275,30 @@
|
|
<seclabel type="static" model="selinux" relabel="yes">
|
|
<label>system_u:object_r:svirt_image_t:s0:c100,c200</label>
|
|
</seclabel>
|
|
+ <sysinfo type="smbios">
|
|
+ <bios>
|
|
+ <entry name="vendor">Acme LLC</entry>
|
|
+ <entry name="version">1.2.3</entry>
|
|
+ <entry name="date">01/01/1970</entry>
|
|
+ <entry name="release">10.22</entry>
|
|
+ </bios>
|
|
+ <system>
|
|
+ <entry name="manufacturer">Acme Inc.</entry>
|
|
+ <entry name="product">Computer</entry>
|
|
+ <entry name="version">3.2.1</entry>
|
|
+ <entry name="serial">123456789</entry>
|
|
+ <entry name="uuid">00000000-1111-2222-3333-444444444444</entry>
|
|
+ <entry name="sku">abc-123</entry>
|
|
+ <entry name="family">Server</entry>
|
|
+ </system>
|
|
+ <baseBoard>
|
|
+ <entry name="manufacturer">Acme Corp.</entry>
|
|
+ <entry name="product">Motherboard</entry>
|
|
+ <entry name="version">A01</entry>
|
|
+ <entry name="serial">1234-5678</entry>
|
|
+ <entry name="asset">Tag</entry>
|
|
+ <entry name="location">Chassis</entry>
|
|
+ </baseBoard>
|
|
+ </sysinfo>
|
|
<on_lockfailure>ignore</on_lockfailure>
|
|
</domain>
|
|
Index: virt-manager-1.4.0/tests/clitest.py
|
|
===================================================================
|
|
--- virt-manager-1.4.0.orig/tests/clitest.py
|
|
+++ virt-manager-1.4.0/tests/clitest.py
|
|
@@ -427,6 +427,9 @@ c.add_compare("""--pxe \
|
|
--memorybacking size=1,unit='G',nodeset='1,2-5',nosharepages=yes,locked=yes \
|
|
--features acpi=off,eoi=on,privnet=on,hyperv_spinlocks=on,hyperv_spinlocks_retries=1234,vmport=off,pmu=off \
|
|
--clock offset=utc,hpet_present=no,rtc_tickpolicy=merge \
|
|
+--sysinfo type=smbios,bios_vendor="Acme LLC",bios_version=1.2.3,bios_date=01/01/1970,bios_release=10.22 \
|
|
+--sysinfo type=smbios,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 \
|
|
+--sysinfo type=smbios,baseBoard_manufacturer="Acme Corp.",baseBoard_product=Motherboard,baseBoard_version=A01,baseBoard_serial=1234-5678,baseBoard_asset=Tag,baseBoard_location=Chassis \
|
|
--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 \
|
|
Index: virt-manager-1.4.0/virtinst/cli.py
|
|
===================================================================
|
|
--- virt-manager-1.4.0.orig/virtinst/cli.py
|
|
+++ virt-manager-1.4.0/virtinst/cli.py
|
|
@@ -21,6 +21,7 @@
|
|
|
|
import argparse
|
|
import collections
|
|
+import datetime
|
|
import logging
|
|
import logging.handlers
|
|
import os
|
|
@@ -67,6 +68,7 @@ from .osxml import OSXML
|
|
from .pm import PM
|
|
from .seclabel import Seclabel
|
|
from .storage import StoragePool, StorageVolume
|
|
+from .sysinfo import SYSInfo
|
|
|
|
|
|
##########################
|
|
@@ -722,6 +724,13 @@ def add_guest_xml_options(geng):
|
|
help=_("Configure VM lifecycle management policy"))
|
|
geng.add_argument("--resource", action="append",
|
|
help=_("Configure VM resource partitioning (cgroups)"))
|
|
+ geng.add_argument("--sysinfo", action="append",
|
|
+ help=_("Configure SMBIOS System Information. Ex:\n"
|
|
+ "--sysinfo emulate\n"
|
|
+ "--sysinfo host\n"
|
|
+ "--sysinfo bios_vendor=Vendor_Inc.,bios_version=1.2.3-abc,...\n"
|
|
+ "--sysinfo system_manufacturer=System_Corp.,system_product=Computer,...\n"
|
|
+ "--sysinfo baseBoard_manufacturer=Baseboard_Corp.,baseBoard_product=Motherboard,...\n"))
|
|
|
|
|
|
def add_boot_options(insg):
|
|
@@ -1541,6 +1550,13 @@ class ParserBoot(VirtCLIParser):
|
|
def set_initargs_cb(self, inst, val, virtarg):
|
|
inst.os.set_initargs_string(val)
|
|
|
|
+ def set_smbios_mode_cb(self, inst, val, virtarg):
|
|
+ if not val.startswith("emulate") and not val.startswith("host"):
|
|
+ inst.sysinfo.parse(val)
|
|
+ val = "sysinfo"
|
|
+ inst.os.smbios_mode = val
|
|
+ self.optdict["smbios_mode"] = val
|
|
+
|
|
def noset_cb(self, inst, val, virtarg):
|
|
pass
|
|
|
|
@@ -1584,6 +1600,8 @@ ParserBoot.add_arg("os.kernel_args", "ke
|
|
ParserBoot.add_arg("os.init", "init")
|
|
ParserBoot.add_arg("os.machine", "machine")
|
|
ParserBoot.add_arg("os.initargs", "initargs", cb=ParserBoot.set_initargs_cb)
|
|
+ParserBoot.add_arg("os.smbios_mode", "smbios_mode",
|
|
+ can_comma=True, cb=ParserBoot.set_smbios_mode_cb)
|
|
|
|
# This is simply so the boot options are advertised with --boot help,
|
|
# actual processing is handled by _parse
|
|
@@ -1702,6 +1720,95 @@ ParserPM.add_arg("suspend_to_mem", "susp
|
|
ParserPM.add_arg("suspend_to_disk", "suspend_to_disk", is_onoff=True)
|
|
|
|
|
|
+#####################
|
|
+# --sysinfo parsing #
|
|
+#####################
|
|
+
|
|
+class ParserSYSInfo(VirtCLIParser):
|
|
+ cli_arg_name = "sysinfo"
|
|
+ objclass = SYSInfo
|
|
+ remove_first = "type"
|
|
+
|
|
+ def set_type_cb(self, inst, val, virtarg):
|
|
+ if val == "host" or val == "emulate":
|
|
+ self.guest.os.smbios_mode = val
|
|
+ elif val == "smbios":
|
|
+ self.guest.os.smbios_mode = "sysinfo"
|
|
+ inst.type = val
|
|
+ else:
|
|
+ fail(_("Unknown sysinfo flag '%s'") % val)
|
|
+
|
|
+ def validate_date_cb(self, inst, val, virtarg):
|
|
+ # If supplied, date must be in either mm/dd/yy or mm/dd/yyyy format
|
|
+ try:
|
|
+ datetime.datetime.strptime(val, '%m/%d/%Y')
|
|
+ except ValueError:
|
|
+ try:
|
|
+ datetime.datetime.strptime(val, '%m/%d/%y')
|
|
+ except ValueError:
|
|
+ raise RuntimeError(_("SMBios date string '%s' is invalid.")
|
|
+ % val)
|
|
+ inst.bios_date = val
|
|
+ return val
|
|
+
|
|
+ def validate_uuid_cb(self, inst, val, virtarg):
|
|
+ # If a uuid is supplied it must match the guest UUID. This would be
|
|
+ # impossible to guess if the guest uuid is autogenerated so just
|
|
+ # overwrite the guest uuid with what is passed in assuming it passes
|
|
+ # the sanity checking below.
|
|
+ try:
|
|
+ util.validate_uuid(val)
|
|
+ except ValueError:
|
|
+ raise ValueError(_("Invalid uuid for SMBios: %s") % val)
|
|
+
|
|
+ if util.vm_uuid_collision(self.guest.conn, val):
|
|
+ raise ValueError(_("UUID '%s' is in use by another guest.") %
|
|
+ val)
|
|
+
|
|
+ # Override guest uuid with passed in SMBios value (they must match)
|
|
+ self.guest.uuid = val
|
|
+ inst.system_uuid = val
|
|
+
|
|
+ def _parse(self, inst):
|
|
+ if self.optstr == "none":
|
|
+ self.guest.skip_default_sysinfo = True
|
|
+ return
|
|
+ if self.optstr == "host" or self.optstr == "emulate":
|
|
+ self.optdict['type'] = self.optstr
|
|
+
|
|
+ return VirtCLIParser._parse(self, inst)
|
|
+
|
|
+_register_virt_parser(ParserSYSInfo)
|
|
+# <sysinfo type='smbios'>
|
|
+ParserSYSInfo.add_arg("type", "type",
|
|
+ cb=ParserSYSInfo.set_type_cb, can_comma=True)
|
|
+
|
|
+# <bios> type 0 BIOS Information
|
|
+ParserSYSInfo.add_arg("bios_vendor", "bios_vendor")
|
|
+ParserSYSInfo.add_arg("bios_version", "bios_version")
|
|
+ParserSYSInfo.add_arg("bios_date", "bios_date",
|
|
+ cb=ParserSYSInfo.validate_date_cb)
|
|
+ParserSYSInfo.add_arg("bios_release", "bios_release")
|
|
+
|
|
+# <system> type 1 System Information
|
|
+ParserSYSInfo.add_arg("system_manufacturer", "system_manufacturer")
|
|
+ParserSYSInfo.add_arg("system_product", "system_product")
|
|
+ParserSYSInfo.add_arg("system_version", "system_version")
|
|
+ParserSYSInfo.add_arg("system_serial", "system_serial")
|
|
+ParserSYSInfo.add_arg("system_uuid", "system_uuid",
|
|
+ cb=ParserSYSInfo.validate_uuid_cb)
|
|
+ParserSYSInfo.add_arg("system_sku", "system_sku")
|
|
+ParserSYSInfo.add_arg("system_family", "system_family")
|
|
+
|
|
+# <baseBoard> type 2 Baseboard (or Module) Information
|
|
+ParserSYSInfo.add_arg("baseBoard_manufacturer", "baseBoard_manufacturer")
|
|
+ParserSYSInfo.add_arg("baseBoard_product", "baseBoard_product")
|
|
+ParserSYSInfo.add_arg("baseBoard_version", "baseBoard_version")
|
|
+ParserSYSInfo.add_arg("baseBoard_serial", "baseBoard_serial")
|
|
+ParserSYSInfo.add_arg("baseBoard_asset", "baseBoard_asset")
|
|
+ParserSYSInfo.add_arg("baseBoard_location", "baseBoard_location")
|
|
+
|
|
+
|
|
##########################
|
|
# Guest <device> parsing #
|
|
##########################
|