[virt-tools-list] [PATCH 1/5] virtinst: Add --smbios command line option
Charles Arnold
carnold at suse.com
Tue Jul 12 19:29:03 UTC 2016
Add the --smbios command line option with all supported arguments.
Signed-off-by: Charles Arnold <carnold at suse.com>
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 432640b..4f9a13b 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -67,6 +67,7 @@ from .osxml import OSXML
from .pm import PM
from .seclabel import Seclabel
from .storage import StoragePool, StorageVolume
+from .sysinfo import SYSInfo
##########################
@@ -722,6 +723,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("--smbios", action="append",
+ help=_("Configure SMBIOS System Information. Ex:\n"
+ "--smbios emulate\n"
+ "--smbios host\n"
+ "--smbios type=0,vendor=Vendor_Inc.,version=1.2.3-abc,...\n"
+ "--smbios type=1,manufacturer=System_Corp.,product=codename,...\n"
+ "--smbios type=2,manufacturer=Baseboard_Corp.,product=codename,...\n"))
def add_boot_options(insg):
@@ -1541,6 +1549,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 val.startswith("type="):
+ 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 +1599,8 @@ ParserBoot.add_arg("os.kernel_args", "kernel_args",
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 +1719,58 @@ ParserPM.add_arg("suspend_to_mem", "suspend_to_mem", is_onoff=True)
ParserPM.add_arg("suspend_to_disk", "suspend_to_disk", is_onoff=True)
+####################
+# --smbios parsing #
+####################
+
+class ParserSYSInfo(VirtCLIParser):
+ cli_arg_name = "smbios"
+ 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.startswith(SYSInfo.SMBIOS_TYPE_BIOS) or \
+ val.startswith(SYSInfo.SMBIOS_TYPE_SYSTEM) or \
+ val.startswith(SYSInfo.SMBIOS_TYPE_BASEBOARD):
+ self.guest.os.smbios_mode = "sysinfo"
+ inst.parse(self.guest, "type=" + val)
+ else:
+ fail(_("Unknown smbios flag '%s'") % val)
+
+ def _parse(self, inst):
+ if self.optstr == "none":
+ self.guest.skip_default_sysinfo = True
+ return
+
+ 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")
+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")
+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 #
##########################
More information about the virt-tools-list
mailing list