Skip to contentSkip to conversation

Report any problems with loading the VGA driver for PPC Macintosh targets

PATCH Superseded John Arbuckle 5 participants 17 messages Aug 27, 2021 – Sep 1, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Report any problems with loading the VGA driver for PPC Macintosh targets

I was having a problem with missing video resolutions in my Mac OS 9 VM. When I ran QEMU it gave no indication as to why these resolutions were missing. I found out that the OpenFirmware VGA driver was not being loaded. To prevent anyone from going thru the same trouble I went thru I added messages that the user can see when a problem takes place with loading this driver in the future.

---
 hw/ppc/mac_newworld.c | 6 ++++++
 hw/ppc/mac_oldworld.c | 6 ++++++
 2 files changed, 12 insertions(+)
hw/ppc/mac_newworld.c +6 -0
index 7bb7ac3997..c1960452b8 100644
@@ -526,8 +526,14 @@ static void ppc_core99_init(MachineState *machine)
 
         if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
             fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");
         }
         g_free(filename);
+    } else {
+        printf("Warning: driver %s not found. This may cause video problems.\n",
+               NDRV_VGA_FILENAME);
     }
 
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
hw/ppc/mac_oldworld.c +6 -0
index de2be960e6..96603fe9cf 100644
@@ -367,8 +367,14 @@ static void ppc_heathrow_init(MachineState *machine)
 
         if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
             fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");
         }
         g_free(filename);
+    } else {
+        printf("Warning: driver %s not found. This may cause video problems.\n",
+               NDRV_VGA_FILENAME);
     }
 
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
Signature · 1 line
2.24.3 (Apple Git-128)
#1 lore raw
Quoted 17 lines · John Arbuckle

I was having a problem with missing video resolutions in my Mac OS 9 VM. When I ran QEMU it gave no indication as to why these resolutions were missing. I found out that the OpenFirmware VGA driver was not being loaded. To prevent anyone from going thru the same trouble I went thru I added messages that the user can see when a problem takes place with loading this driver in the future.

---
hw/ppc/mac_newworld.c | 6 ++++++
hw/ppc/mac_oldworld.c | 6 ++++++

2 files changed, 12 insertions(+)
hw/ppc/mac_newworld.c +0 -0
index 7bb7ac3997..c1960452b8 100644

hw/ppc/mac_newworld.c static void ppc_core99_init(MachineState *machine) · line 531

Quoted 6 lines
hw/ppc/mac_newworld.c +3 -0
@@ -526,8 +526,14 @@ static void ppc_core99_init(MachineState *machine)
 
        if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
            fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");

I think you should use warn_report for these instead of printf and watch out if that needs \n or not (some functions add \n while some others may not and I always forget which is which but checkpatch should warn for it so you should get nofified if you leave \n there but it's not needed).

Regards,
BALATON Zoltan

Quoted 28 lines
hw/ppc/mac_newworld.c +3 -0
        }
        g_free(filename);
+    } else {
+        printf("Warning: driver %s not found. This may cause video problems.\n",
+               NDRV_VGA_FILENAME);
    }
 
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
hw/ppc/mac_oldworld.c +6 -0
index de2be960e6..96603fe9cf 100644
@@ -367,8 +367,14 @@ static void ppc_heathrow_init(MachineState *machine)
 
        if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
            fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");
        }
        g_free(filename);
+    } else {
+        printf("Warning: driver %s not found. This may cause video problems.\n",
+               NDRV_VGA_FILENAME);
    }
 
    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
#2 lore raw
Quoted 19 lines · BALATON Zoltan
Quoted 18 lines · John Arbuckle

I was having a problem with missing video resolutions in my Mac OS 9 VM. When I ran QEMU it gave no indication as to why these resolutions were missing. I found out that the OpenFirmware VGA driver was not being loaded. To prevent anyone from going thru the same trouble I went thru I added messages that the user can see when a problem takes place with loading this driver in the future.

---
hw/ppc/mac_newworld.c | 6 ++++++
hw/ppc/mac_oldworld.c | 6 ++++++

2 files changed, 12 insertions(+)
hw/ppc/mac_newworld.c +0 -0
index 7bb7ac3997..c1960452b8 100644
@@ -526,8 +526,14 @@ static void ppc_core99_init(MachineState *machine)
 
Quoted 10 lines

hw/ppc/mac_newworld.c static void ppc_core99_init(MachineState *machine) · line 531

Quoted 5 lines
hw/ppc/mac_newworld.c +3 -0
        if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
            fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");

I think you should use warn_report for these instead of printf and watch out if that needs \n or not (some functions add \n while some others may not and I always forget which is which but checkpatch should warn for it so you should get nofified if you leave \n there but it's not needed).

Yes, it definitely should be warn_report() rather than a raw printf. Patches for Macintosh should also go to the relevant maintainer Mark Cave-Ayland <[email protected]>.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
In reply to John Arbuckle
Quoted 40 lines · John Arbuckle

I was having a problem with missing video resolutions in my Mac OS 9 VM. When I ran QEMU it gave no indication as to why these resolutions were missing. I found out that the OpenFirmware VGA driver was not being loaded. To prevent anyone from going thru the same trouble I went thru I added messages that the user can see when a problem takes place with loading this driver in the future.

---
  hw/ppc/mac_newworld.c | 6 ++++++
  hw/ppc/mac_oldworld.c | 6 ++++++
  2 files changed, 12 insertions(+)
hw/ppc/mac_newworld.c +6 -0
index 7bb7ac3997..c1960452b8 100644
@@ -526,8 +526,14 @@ static void ppc_core99_init(MachineState *machine)
 
          if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
              fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");
          }
          g_free(filename);
+    } else {
+        printf("Warning: driver %s not found. This may cause video problems.\n",
+               NDRV_VGA_FILENAME);
      }
 
      qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
hw/ppc/mac_oldworld.c +1 -0
index de2be960e6..96603fe9cf 100644
@@ -367,8 +367,14 @@ static void ppc_heathrow_init(MachineState *machine)
 
          if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
              fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
+        } else {

hw/ppc/mac_oldworld.c static void ppc_heathrow_init(MachineState *machine) · line 380

Quoted 10 lines
hw/ppc/mac_oldworld.c +5 -0
+            printf("Warning: failed to load driver %s. This may cause video"
+                   " problems.\n");
          }
          g_free(filename);
+    } else {
+        printf("Warning: driver %s not found. This may cause video problems.\n",
+               NDRV_VGA_FILENAME);
      }
 
      qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);

This is by design: it's not the OpenFirmware VGA driver that's not being loaded here (that is already embedded in OpenBIOS), it's a optional MacOS client driver which just so happens to read the EDID to generate its list of available resolutions.

What I don't understand is that the binary is installed by default in QEMU's sharedir so everything works out of the box with "make install". Do you have some kind of custom installer which is doing something different?

ATB,

Mark.

#4 lore raw
Quoted 3 lines · Mark Cave-Ayland

What I don't understand is that the binary is installed by default in QEMU's sharedir so everything works out of the box with "make install". Do you have some kind of custom installer which is doing something different?

John has had problems before with the QEMU binary not being able to find files at runtime (the previous example was the QEMU logo file). I suspect we have a common underlying bug there. John -- do you run QEMU from the build directory, or by installing it first and running the installed binary, or in some other way ?

thanks
-- PMM

#5 lore raw
Quoted 10 lines · Peter Maydell
Quoted 3 lines · Mark Cave-Ayland

What I don't understand is that the binary is installed by default in QEMU's sharedir so everything works out of the box with "make install". Do you have some kind of custom installer which is doing something different?

Quoted 8 lines

John has had problems before with the QEMU binary not being able to find files at runtime (the previous example was the QEMU logo file). I suspect we have a common underlying bug there. John -- do you run QEMU from the build directory, or by installing it first and running the installed binary, or in some other way ?

thanks
-- PMM

I run QEMU from the build directory.

#6 lore raw
In reply to Peter Maydell
Quoted 10 lines · Peter Maydell
Quoted 3 lines · Mark Cave-Ayland

What I don't understand is that the binary is installed by default in QEMU's sharedir so everything works out of the box with "make install". Do you have some kind of custom installer which is doing something different?

Quoted 8 lines

John has had problems before with the QEMU binary not being able to find files at runtime (the previous example was the QEMU logo file). I suspect we have a common underlying bug there. John -- do you run QEMU from the build directory, or by installing it first and running the installed binary, or in some other way ?

thanks
-- PMM

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does. Anyone else see this?

#7 lore raw
Quoted 6 lines · Programmingkid

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does.

Having two pc-bios folders is expected. The one in the source tree is the one which has the files we actually carry around in git. The one in the build tree is created by 'configure' and populated with symbolic links back to the files in the source tree. We need this one because the QEMU executable doesn't (and shouldn't) know where the source tree is:
when it is looking for files it will look in places relative to the location of the executable itself (ie relative to the build tree) as well as places set by configure (used when you install QEMU and its various supporting files).

The reason qemu_vga.ndrv is not in the pc-bios folder in the build tree is because when that file was added we forgot to add handling for it in configure. I'm not sure why nobody else has fallen over this in the intervening 3 years: running QEMU from the build tree will never find the file, and it will not be installed via 'make install' either.

(The pc-bios symlink stuff is a bit of a mess, as the comment about it in configure notes. Perhaps meson now offers a cleaner way to handle this? In particular pc-bios/meson.build already has to carry around a complete list of all the bios blobs, so it could probably create the symlink farm itself.)

thanks
-- PMM

#8 lore raw
Quoted 18 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does.

Having two pc-bios folders is expected. The one in the source tree is the one which has the files we actually carry around in git. The one in the build tree is created by 'configure' and populated with symbolic links back to the files in the source tree. We need this one because the QEMU executable doesn't (and shouldn't) know where the source tree is:
when it is looking for files it will look in places relative to the location of the executable itself (ie relative to the build tree) as well as places set by configure (used when you install QEMU and its various supporting files).

Quoted 6 lines

The reason qemu_vga.ndrv is not in the pc-bios folder in the build tree is because when that file was added we forgot to add handling for it in configure. I'm not sure why nobody else has fallen over this in the intervening 3 years: running QEMU from the build tree will never find the file, and it will not be installed via 'make install' either.

This file is a driver for MacOS and not many people run that old OS. Those who do probably use Howard's binaries and follow his guides that tell you to use -L pc-bios on command line. I always wondered why that's needed when it should find it by default but this explains it and probably also your question why nobody complained.

Regards,
BALATON Zoltan

#14 lore raw
In reply to Peter Maydell
Quoted 29 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does.

Having two pc-bios folders is expected. The one in the source tree is the one which has the files we actually carry around in git. The one in the build tree is created by 'configure' and populated with symbolic links back to the files in the source tree. We need this one because the QEMU executable doesn't (and shouldn't) know where the source tree is:
when it is looking for files it will look in places relative to the location of the executable itself (ie relative to the build tree) as well as places set by configure (used when you install QEMU and its various supporting files).

The reason qemu_vga.ndrv is not in the pc-bios folder in the build tree is because when that file was added we forgot to add handling for it in configure. I'm not sure why nobody else has fallen over this in the intervening 3 years: running QEMU from the build tree will never find the file, and it will not be installed via 'make install' either.

Quoted 8 lines

(The pc-bios symlink stuff is a bit of a mess, as the comment about it in configure notes. Perhaps meson now offers a cleaner way to handle this? In particular pc-bios/meson.build already has to carry around a complete list of all the bios blobs, so it could probably create the symlink farm itself.)

thanks
-- PMM

I did try working on the pc-bios/meson.build file. I deleted all the entries in the 'blobs' list. Then I ran './configure --target-list=ppc-softmmu && make -j 9'. The pc-bios folder in the build directory was still populated with all the files (except for qemu_vga.ndrv). Anyone knows what exactly populates the pc-bios folder in the build folder?

#9 lore raw
In reply to BALATON Zoltan
Quoted 30 lines · BALATON Zoltan
Quoted 18 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does.

Having two pc-bios folders is expected. The one in the source tree is the one which has the files we actually carry around in git. The one in the build tree is created by 'configure' and populated with symbolic links back to the files in the source tree. We need this one because the QEMU executable doesn't (and shouldn't) know where the source tree is:
when it is looking for files it will look in places relative to the location of the executable itself (ie relative to the build tree) as well as places set by configure (used when you install QEMU and its various supporting files).

Quoted 6 lines

The reason qemu_vga.ndrv is not in the pc-bios folder in the build tree is because when that file was added we forgot to add handling for it in configure. I'm not sure why nobody else has fallen over this in the intervening 3 years: running QEMU from the build tree will never find the file, and it will not be installed via 'make install' either.

Quoted 4 lines

This file is a driver for MacOS and not many people run that old OS. Those who do probably use Howard's binaries and follow his guides that tell you to use -L pc-bios on command line. I always wondered why that's needed when it should find it by default but this explains it and probably also your question why nobody complained.

Regards,
BALATON Zoltan

This does sound like a good explanation. I am pretty sure I was able to use my Mac OS 9 VM without the -L option in the past and still have many video resolutions available.

#15 lore raw
In reply to Programmingkid
Quoted 4 lines · Programmingkid

Then I ran './configure --target-list=ppc-softmmu && make -j 9'. The pc-bios folder in the build directory was still populated with all the files (except for qemu_vga.ndrv). Anyone knows what exactly populates the pc-bios folder in the build folder?

As I said above, it is the configure script, which needs a fix to add qemu_vga.ndrv to the list of symlinks it creates.

-- PMM

#16 lore raw
Quoted 10 lines · Peter Maydell
Quoted 4 lines · Programmingkid

Then I ran './configure --target-list=ppc-softmmu && make -j 9'. The pc-bios folder in the build directory was still populated with all the files (except for qemu_vga.ndrv). Anyone knows what exactly populates the pc-bios folder in the build folder?

Quoted 4 lines

As I said above, it is the configure script, which needs a fix to add qemu_vga.ndrv to the list of symlinks it creates.

-- PMM

Thank you for the information. I created a new patch that should solve this problem.

#10 lore raw
In reply to Programmingkid
Quoted 28 lines · Programmingkid
Quoted 28 lines · BALATON Zoltan
Quoted 24 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does.

Having two pc-bios folders is expected. The one in the source tree is the one which has the files we actually carry around in git. The one in the build tree is created by 'configure' and populated with symbolic links back to the files in the source tree. We need this one because the QEMU executable doesn't (and shouldn't) know where the source tree is:
when it is looking for files it will look in places relative to the location of the executable itself (ie relative to the build tree) as well as places set by configure (used when you install QEMU and its various supporting files).

The reason qemu_vga.ndrv is not in the pc-bios folder in the build tree is because when that file was added we forgot to add handling for it in configure. I'm not sure why nobody else has fallen over this in the intervening 3 years: running QEMU from the build tree will never find the file, and it will not be installed via 'make install' either.

Quoted 6 lines
Quoted 4 lines

This file is a driver for MacOS and not many people run that old OS. Those who do probably use Howard's binaries and follow his guides that tell you to use -L pc-bios on command line. I always wondered why that's needed when it should find it by default but this explains it and probably also your question why nobody complained.

Regards,
BALATON Zoltan

This does sound like a good explanation. I am pretty sure I was able to use my Mac OS 9 VM without the -L option in the past and still have many video resolutions available.

Depends how far back in the past was that. If before the meson conversion that introduced the build dir maybe you run it from the source dir (if used in-tree build) and it found the file. I'm not sure if it still works if you run from source dir such as build/qemu-system-ppc that is without changing current dir to build dir. If it works that way then maybe you ran it like that before. (Or maybe had an installed version and it picked up the file from there.)

Regards,
BALATON Zoltan

#11 lore raw
Quoted 38 lines · BALATON Zoltan
Quoted 33 lines · Programmingkid
Quoted 32 lines · BALATON Zoltan
Quoted 18 lines · Peter Maydell
Quoted 6 lines · Programmingkid

I found out that there are two pc-bios folders. One in the root directory and one in the build directory. QEMU is looking in the pc-bios folder located inside the build folder. The qemu_vga.ndrv file is only located in the root directory pc-bios folder. I think a good solution to this issue is to first remove one of the pc-bios folders. I'm not sure if it is just me who has two pc-bios folders or if everyone does.

Having two pc-bios folders is expected. The one in the source tree is the one which has the files we actually carry around in git. The one in the build tree is created by 'configure' and populated with symbolic links back to the files in the source tree. We need this one because the QEMU executable doesn't (and shouldn't) know where the source tree is:
when it is looking for files it will look in places relative to the location of the executable itself (ie relative to the build tree) as well as places set by configure (used when you install QEMU and its various supporting files).

Quoted 6 lines

The reason qemu_vga.ndrv is not in the pc-bios folder in the build tree is because when that file was added we forgot to add handling for it in configure. I'm not sure why nobody else has fallen over this in the intervening 3 years: running QEMU from the build tree will never find the file, and it will not be installed via 'make install' either.

This file is a driver for MacOS and not many people run that old OS. Those who do probably use Howard's binaries and follow his guides that tell you to use -L pc-bios on command line. I always wondered why that's needed when it should find it by default but this explains it and probably also your question why nobody complained.

Regards,
BALATON Zoltan

Quoted 6 lines
Quoted 1 line

This does sound like a good explanation. I am pretty sure I was able to use my Mac OS 9 VM without the -L option in the past and still have many video resolutions available.

Depends how far back in the past was that. If before the meson conversion that introduced the build dir maybe you run it from the source dir (if used in-tree build) and it found the file. I'm not sure if it still works if you run from source dir such as build/qemu-system-ppc that is without changing current dir to build dir. If it works that way then maybe you ran it like that before. (Or maybe had an installed version and it picked up the file from there.)

Regards,
BALATON Zoltan

That was around version 2.10 so a while back.

I just realized, I sent a patch to the developer list that fixes the missing qemu_vga.ndrv problem, but I do not know which maintainer to send it to. Who maintains the configure script? A search of the maintainers page was not clear as to who this is.

#12 lore raw
Quoted 1 line · Programmingkid

I just realized, I sent a patch to the developer list that fixes the missing qemu_vga.ndrv problem, but I do not know which maintainer to send it to. Who maintains the configure script? A search of the maintainers page was not clear as to who this is.

That's what the get_maintainer script is for, try
scripts/get_maintainer.pl -f configure
Interestingly there's no maintainer listed for configure, in that case probably pick the contributor with highest percentage and since it's a very simple patch you can also cc qemu-trivial list. See:
https://wiki.qemu.org/Contribute/SubmitAPatch
where all this should be explained.

Regards,
BALATON Zoltan

#13 lore raw
Quoted 7 lines · BALATON Zoltan
Quoted 1 line · Programmingkid

I just realized, I sent a patch to the developer list that fixes the missing qemu_vga.ndrv problem, but I do not know which maintainer to send it to. Who maintains the configure script? A search of the maintainers page was not clear as to who this is.

Quoted 8 lines

That's what the get_maintainer script is for, try
scripts/get_maintainer.pl -f configure
Interestingly there's no maintainer listed for configure, in that case probably pick the contributor with highest percentage and since it's a very simple patch you can also cc qemu-trivial list. See:
https://wiki.qemu.org/Contribute/SubmitAPatch
where all this should be explained.

Regards,
BALATON Zoltan

Thank you for the advice. I have sent the patch to the trivial list and its maintainers.