summaryrefslogtreecommitdiff
path: root/virtinst
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2022-08-03 11:44:46 -0400
committerCole Robinson <crobinso@redhat.com>2022-08-03 12:34:47 -0400
commit5e48307e9d9d3c811ccbdb6463b6ccb79a029c4d (patch)
tree0ce9b018bd05d1e7f358136165131495727e664c /virtinst
parent02e6abad48400c8a6106c47ff4c20587ca9f41bd (diff)
downloadvirt-manager-5e48307e9d9d3c811ccbdb6463b6ccb79a029c4d.tar.gz
virtinstall: Set VM name earlier so disks are named correctly
We need to change the flow from * parse all the strings * set capabilities defaults * build installer * fill in all guest defaults To * parse boot and metadata strings * set capabilities defaults * build installer * set --name default * parse all the remaining strings * fill in all guest defaults Because --disk parsing depends on --name for some path generation. So this fixes --disk names when --name is implicitly specified by --install or --osinfo Signed-off-by: Cole Robinson <crobinso@redhat.com>
Diffstat (limited to 'virtinst')
-rw-r--r--virtinst/virtinstall.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/virtinst/virtinstall.py b/virtinst/virtinstall.py
index 35261148..6d7f56b8 100644
--- a/virtinst/virtinstall.py
+++ b/virtinst/virtinstall.py
@@ -463,13 +463,15 @@ def build_installer(options, guest, installdata):
return installer
-def set_cli_defaults(options, guest):
+def set_cli_default_name(guest):
if not guest.name:
default_name = virtinst.Guest.generate_name(guest)
cli.print_stdout(_("Using default --name {vm_name}").format(
vm_name=default_name))
guest.name = default_name
+
+def set_cli_defaults(options, guest):
if guest.os.is_container():
if not memory_specified(guest):
mbram = 1024
@@ -618,8 +620,14 @@ def _build_options_guest(conn, options):
# Fill in guest from the command line content
set_explicit_guest_options(options, guest)
- cli.run_all_parsers(options, guest)
- cli.parse_xmlcli(guest, options)
+
+ # We do these two parser bit early, since Installer setup will
+ # depend on them, but delay the rest to later, since things like
+ # disk naming can depend on Installer operations
+ cli.run_parser(options, guest, cli.ParserBoot)
+ options.boot = None
+ cli.run_parser(options, guest, cli.ParserMetadata)
+ options.metadata = None
# Call set_capabilities_defaults explicitly here rather than depend
# on set_defaults calling it. Installer setup needs filled in values.
@@ -646,6 +654,11 @@ def build_guest_instance(conn, options):
installer_detect_distro(guest, installer, osdata)
if not options.reinstall:
+ # We want to fill in --name before we do disk parsing, since
+ # default disk paths are generated based on VM name
+ set_cli_default_name(guest)
+ cli.run_all_parsers(options, guest)
+ cli.parse_xmlcli(guest, options)
set_cli_defaults(options, guest)
installer.set_install_defaults(guest)