Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2128413

Summary: virt-install installation with UEFI network boot doesn't finish with a shutdown
Product: Red Hat Enterprise Linux 9 Reporter: Jiri Kortus <jikortus>
Component: virt-managerAssignee: Virtualization Maintenance <virt-maint>
virt-manager sub component: Common QA Contact: Virtualization Bugs <virt-bugs>
Status: CLOSED NOTABUG Docs Contact:
Severity: unspecified    
Priority: unspecified CC: crobinso, hongzliu, jjongsma, juzhou, tyan, tzheng, virt-maint
Version: 9.1Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-10-26 18:42:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jiri Kortus 2022-09-20 13:27:09 UTC
Description of problem:
Installations performed by virt-install in UEFI mode with boot from network don't finish with a machine shutdown as expected, but reboots.

It's used in our automated tests for bare metal image installations via Anaconda, and the whole virt-install command looks like this (stripped from apparently unnecessary parts):
virt-install --os-variant rhel9.1 --arch x86_64 --boot hd,network,uefi,loader=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd,loader_ro=yes,loader_type=pflash,nvram_template=/usr/share/edk2/ovmf/OVMF_VARS.fd --name rtttest --memory 4983 --disk size=10 --network network=netboot,mac=00:11:22:33:44:55 --serial file,path=/tmp/serial_output.log --noautoconsole

The '--boot network' part seems to be problematic, removing 'hd' didn't change anything for me.

In contrast, the same configuration, but with different --boot configuration and --cdrom works as expected and shuts the machine down after installation:

virt-install --os-variant rhel9.1 --arch x86_64  --cdrom /tmp/cdimage.iso --boot uefi,loader=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd,loader_ro=yes,loader_type=pflash,nvram_template=/usr/share/edk2/ovmf/OVMF_VARS.fd --name rtttest --memory 4983 --disk size=10 --network network=netboot,mac=00:11:22:33:44:55 --serial file,path=/tmp/serial_output.log
--noautoconsole

Version-Release number of selected component (if applicable):
virt-manager-4.0.0-1.el9

How reproducible:
100%

Steps to Reproduce:
1. Prepare an HTTP server with installation ISO (boot.iso works just fine), configure a libvirt network with DHCP server and HTTP boot configuration (I used
  <dnsmasq:options>
    <dnsmasq:option value='dhcp-vendorclass=set:efi-http,HTTPClient:Arch:00016'/>
    <dnsmasq:option value='dhcp-option-force=tag:efi-http,60,HTTPClient'/>
    <dnsmasq:option value='dhcp-boot=tag:efi-http,&quot;http://192.168.200.1/cdimage.iso&quot;'/>
  </dnsmasq:options>
for this purpose in network configuration).
2. Start virt-install RHEL-9.1 installation in UEFI mode with boot from network, as described above, connect to its graphical console.
3. Configure the necessary parts in Anaconda finish installation.

Actual results:
The VM reboots after the installation is complete.

Expected results:
The VM shuts down after the installation is complete.

Comment 1 Hongzhou Liu 2022-09-21 03:21:10 UTC
(In reply to Jiri Kortus from comment #0)
> Description of problem:
> Installations performed by virt-install in UEFI mode with boot from network
> don't finish with a machine shutdown as expected, but reboots.
> 
> It's used in our automated tests for bare metal image installations via
> Anaconda, and the whole virt-install command looks like this (stripped from
> apparently unnecessary parts):
> virt-install --os-variant rhel9.1 --arch x86_64 --boot
> hd,network,uefi,loader=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd,
> loader_ro=yes,loader_type=pflash,nvram_template=/usr/share/edk2/ovmf/
> OVMF_VARS.fd --name rtttest --memory 4983 --disk size=10 --network
> network=netboot,mac=00:11:22:33:44:55 --serial
> file,path=/tmp/serial_output.log --noautoconsole
> 
> The '--boot network' part seems to be problematic, removing 'hd' didn't
> change anything for me.
> 
> In contrast, the same configuration, but with different --boot configuration
> and --cdrom works as expected and shuts the machine down after installation:
> 
> virt-install --os-variant rhel9.1 --arch x86_64  --cdrom /tmp/cdimage.iso
> --boot
> uefi,loader=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd,loader_ro=yes,
> loader_type=pflash,nvram_template=/usr/share/edk2/ovmf/OVMF_VARS.fd --name
> rtttest --memory 4983 --disk size=10 --network
> network=netboot,mac=00:11:22:33:44:55 --serial
> file,path=/tmp/serial_output.log
> --noautoconsole
> 
> Version-Release number of selected component (if applicable):
> virt-manager-4.0.0-1.el9
> 
> How reproducible:
> 100%
> 
> Steps to Reproduce:
> 1. Prepare an HTTP server with installation ISO (boot.iso works just fine),
> configure a libvirt network with DHCP server and HTTP boot configuration (I
> used
>   <dnsmasq:options>
>     <dnsmasq:option
> value='dhcp-vendorclass=set:efi-http,HTTPClient:Arch:00016'/>
>     <dnsmasq:option value='dhcp-option-force=tag:efi-http,60,HTTPClient'/>
>     <dnsmasq:option
> value='dhcp-boot=tag:efi-http,&quot;http://192.168.200.1/cdimage.iso&quot;'/>
>   </dnsmasq:options>
> for this purpose in network configuration).
> 2. Start virt-install RHEL-9.1 installation in UEFI mode with boot from
> network, as described above, connect to its graphical console.
> 3. Configure the necessary parts in Anaconda finish installation.
> 
> Actual results:
> The VM reboots after the installation is complete.
> 
> Expected results:
> The VM shuts down after the installation is complete.

Hello, Kortus:

After reading your description, I think add --noreboot to your cmd should do what you want.

Here is the description for --noreboot from virt-install man page

   --noreboot
       Prevent the domain from automatically rebooting after the install has completed.

Comment 2 Jiri Kortus 2022-09-21 07:50:03 UTC
Hello Hongzhou,

thank you for the suggestion, I somehow missed this option. Unfortunately, when I add '--noreboot', the VM gets created in a shut down state for some reason.

I noticed one interesting thing in the man page for virt-install in the '--autoconsole' section:
... If your command requested a multistep install, like --cdrom or --location, after the install phase is complete the VM will be shutoff, regardless of whether a reboot was requested in the VM. ...

This might mean that the shutdown really shouldn't take place when the machine is booted from network (but it's not stated explicitly and there's no definition of what 'multistep' means). Nevertheless, even if it were the case and I was supposed to use the '--noreboot' option, it doesn't work for me as expected :(.

Thank you,
Jirka

Comment 3 Hongzhou Liu 2022-09-21 09:55:35 UTC
Hello Robinson and Jongsma:

Based on comment 2, is --boot network a multistep install method? 

(In reply to Jiri Kortus from comment #2)
> Hello Hongzhou,
> 
> thank you for the suggestion, I somehow missed this option. Unfortunately,
> when I add '--noreboot', the VM gets created in a shut down state for some
> reason.
>
I think this might be another problem

> I noticed one interesting thing in the man page for virt-install in the
> '--autoconsole' section:
> ... If your command requested a multistep install, like --cdrom or
> --location, after the install phase is complete the VM will be shutoff,
> regardless of whether a reboot was requested in the VM. ...
> 
> This might mean that the shutdown really shouldn't take place when the
> machine is booted from network (but it's not stated explicitly and there's
> no definition of what 'multistep' means). Nevertheless, even if it were the
> case and I was supposed to use the '--noreboot' option, it doesn't work for
> me as expected :(.
> 
Hello Robinson and Jongsma:

Based on comment 2, is --boot network a multistep install method? 

> Thank you,
> Jirka

Comment 4 Cole Robinson 2022-10-11 16:52:11 UTC
I think the behavior is expected, but it is subtle. TLDR what you want is to remove `--boot hd,network` and use `--pxe` instead.

When you request `--boot hd,network`, this is implicitly `--import --boot hd,network`. `--import` means you are saying 'there is no install phase', like importing an existing disk image. When there's no install phase, the VM is just started and virt-install exits. If you use --noreboot here, the initial startup is not even invoked.

To request virt-install to install off PXE but then for remaining boots just boot off hd, use `--pxe` or `--install bootdev=network`. In this case, when the install completes and the VM requests reboot, virt-install will reboot the VM, then exit. If --noreboot is requested, the VM reboot request is turned into a shutdown, and the VM stays offline.

In your initial case, the VM was installing off network, and then likely requesting a reboot from inside the VM (what anaconda does after install). Since virt-install wasn't expecting a multistage install, it does not intercept the reboot, and the VM reboots as normal, and ends in booted state.

Comment 5 Jonathon Jongsma 2022-10-26 18:42:12 UTC
Closing the bug based on Cole's response.