[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: NVRAM emulation issues in QEMU



On 25/03/2022 07:37, John Paul Adrian Glaubitz wrote:

Hi Mark!

On 3/24/22 16:39, John Paul Adrian Glaubitz wrote:
On 3/24/22 15:40, John Paul Adrian Glaubitz wrote:
Are there any plans to improve the NVRAM emulation in QEMU or is there any alternative
command that we should run on QEMU-based systems?

OK, the solution is actually as simple as skipping the "nvram" command when running inside
a QEMU guest. However, I have no clue how to detect whether it's running on a QEMU-emulated
PowerMac or a real one.

I think the solution is much simpler. We just remove the "nvram" command on Power Macintosh,
it's actually not needed. According to Apple's documentation, OpenFirmware will automatically
search for an operating system on any of the disks in the system, so there is no need to set
the boot-device in NVRAM expliclity [1].

In order to verify that, I just set the "boot-device" on my iBook G4 to NULL and can confirm
that it still boots fine.

root@ibook-g4:~# nvram --print-config=boot-device
/pci@f4000000/ata-6@d/@0:2,\\:txbi
root@ibook-g4:~# nvram --update-config boot-device=""
root@ibook-g4:~# nvram --print-config=boot-device
root@ibook-g4:~# reboot
root@ibook-g4:~# Connection to 192.168.178.175 closed by remote host.
Connection to 192.168.178.175 closed.
glaubitz@suse-laptop:~> ssh root@192.168.178.175
Linux ibook-g4 5.16.0-5-powerpc #1 Debian 5.16.14-1 (2022-03-15) ppc

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Mar 25 08:29:21 2022 from 192.168.178.81
root@ibook-g4:~#

So, I think it should be safe to just remove these two lines required for setting
the boot-device in NVRAM from the grub-installer script [2][3].

Adrian

[1] https://opensource.apple.com/source/bless/bless-37/README.BOOTING
[2] https://salsa.debian.org/installer-team/grub-installer/-/blob/master/grub-installer#L961
[3] https://salsa.debian.org/installer-team/grub-installer/-/blob/master/grub-installer#L968

Hi Adrian,

Thanks for the links. OpenBIOS should work in the same way here in that it scans each volume in order until it finds a HFS/HFS+ partition with a blessed file to load and execute.

However I suspect the reason the NVRAM is changed is for the case of dual-boot machines where the existing MacOS partition is first shrunk and the Linux partitions added at the end. In this case without the OF NVRAM boot-device update I'd expect OF to always locate and boot MacOS first, instead of loading grub to offer a choice of booting either MacOS or Linux.

I should add that my real G4 is set up like this to allow testing various bits of pieces against QEMU. However for QEMU I don't ever dual boot since I can simply boot either a MacOS or Linux image directly ;)


ATB,

Mark.


Reply to: