From 8f75ac4e6e9a90c636397fd15c82cb70996c4a2b Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 9 Oct 2024 10:55:33 -0400 Subject: [PATCH] virt-install: implement `--osinfo require=no` as fallback `name=generic` This is essentially what it has always behaved as, but making it explicit in the code will now trigger the extra warnings when detect=on is also used. Signed-off-by: Cole Robinson --- tests/test_cli.py | 1 + virtinst/cli.py | 8 ++++---- virtinst/virtinstall.py | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 7109fae50..bbcd03211 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1024,6 +1024,7 @@ c.add_compare("--pxe --os-variant detect=yes,name=win7", "os-detect-fail-fallbac c.add_compare("--connect %(URI-KVM-X86)s --install fedora26", "osinfo-url") # getting URL from osinfo c.add_valid("--location https://foobar.com --os-variant detect=yes,name=win7", nogrep="Please file a bug against virt-install") # os detection succeeds, the fallback warning shouldn't be printed c.add_valid("--pxe --os-variant detect=yes,name=win7", grep="Please file a bug against virt-install") # os detection fails, so fallback warning should be printed +c.add_valid("--cdrom http://example.com/path/to/some.iso --os-variant detect=yes,require=no", grep="Please file a bug against virt-install") # detection fails with require=no, we should print the error about using fallback name= c.add_invalid("--pxe --os-variant detect=yes,require=yes", grep="--os-variant/--osinfo OS name is required") # No os-variant detected, but require=yes c.add_invalid("--pxe --osinfo detect=yes", grep="--os-variant/--osinfo OS name is required") # --osinfo detect=on failed, but with implied require=yes c.add_invalid("--pxe --virt-type foobar", grep="Host does not support domain type") diff --git a/virtinst/cli.py b/virtinst/cli.py index a93bfa429..a2cf7ba67 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -1886,7 +1886,6 @@ def parse_location(optstr): class OSVariantData(object): _REQUIRE_ON = 1 - _REQUIRE_OFF = 2 _REQUIRE_AUTO = 3 def __init__(self): @@ -1920,7 +1919,10 @@ class OSVariantData(object): self._name = osobj.name if self._require_from_cli is False: - self._require = self._REQUIRE_OFF + if not self._name: + log.debug( + "Converting `require=off` to fallback `name=generic`") + self._name = "generic" elif self._require_from_cli is True: self._require = self._REQUIRE_ON else: @@ -1930,8 +1932,6 @@ class OSVariantData(object): return self._detect def is_require_on(self): return self._require == self._REQUIRE_ON - def is_require_off(self): - return self._require == self._REQUIRE_OFF def get_name(self): return self._name diff --git a/virtinst/virtinstall.py b/virtinst/virtinstall.py index 07da26089..8df7fc448 100644 --- a/virtinst/virtinstall.py +++ b/virtinst/virtinstall.py @@ -576,8 +576,6 @@ def installer_detect_distro(guest, installer, osdata): return if osdata.is_require_on(): fail(msg) - if osdata.is_require_off(): - return if not _needs_accurate_osinfo(guest): return