virt-install: Respect --os-variant

When the user explicitly passes --os-variant via command line, its value
must be respected, always.

By setting the os name earlier, we force the os-variant to be respected
when the installer creates the Distro Store.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2019-11-18 11:00:45 +01:00 committed by Cole Robinson
parent 54edd0a0a6
commit b78b8a96cf
1 changed files with 8 additions and 5 deletions

View File

@ -531,13 +531,16 @@ def set_explicit_guest_options(options, guest):
def installer_detect_distro(guest, installer, osdata):
try:
# OS name has to be set firstly whenever --os-variant is passed,
# otherwise it won't be respected when the installer creates the
# Distro Store.
if osdata.name:
guest.set_os_name(osdata.name)
# This also validates the install location
autodistro = installer.detect_distro(guest)
name = osdata.name
if osdata.is_auto:
name = autodistro
if name:
guest.set_os_name(name)
if osdata.is_auto and autodistro:
guest.set_os_name(autodistro)
except ValueError as e:
fail(_("Error validating install location: %s") % str(e))