[virt-tools-list] [virt-manager PATCH 1/2] cli: fix sysinfo type parsing

Pavel Hrdina phrdina at redhat.com
Tue May 14 17:57:37 UTC 2019


If the optstr is "host" or "emulate" the optdict['type'] was already set
to the proper value so that condition is useless and we should set the
default optdict['type'] only if there was no type specified by user,
otherwise it is overwrite by our 'smbios' default.

In addition if invalid type is specified let libvirt to do the error
checking.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1707379

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 virtinst/cli.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/virtinst/cli.py b/virtinst/cli.py
index 4ebdf84d..76de1367 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -2336,9 +2336,7 @@ class ParserSysinfo(VirtCLIParser):
     }
 
     def _parse(self, inst):
-        if self.optstr == "host" or self.optstr == "emulate":
-            self.optdict['type'] = self.optstr
-        elif self.optstr:
+        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'
@@ -2357,7 +2355,7 @@ class ParserSysinfo(VirtCLIParser):
             self.guest.os.smbios_mode = "sysinfo"
             inst.type = val
         else:
-            fail(_("Unknown sysinfo flag '%s'") % val)
+            inst.type = val
 
     def set_uuid_cb(self, inst, val, virtarg):
         # If a uuid is supplied it must match the guest UUID. This would be
-- 
2.21.0




More information about the virt-tools-list mailing list