Qemu virtio drivers for Mac OS 9.x

About Qemu-system-ppc, a PPC Mac emulator for Windows, macOS and Linux that can run Mac OS 9.0 up to Mac OS X 10.5

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
elliotnunn
Student Driver
Posts: 17
Joined: Sun Sep 11, 2016 6:35 am

Qemu virtio drivers for Mac OS 9.x

Post by elliotnunn »

Hello all,

I am working on Mac OS 9 drivers for Qemu's suite of Virtio devices (video, file sharing, sound, input etc). The driver for guest-host file sharing is ready for a demonstration.

Note: To use any of this functionality in Windows, you need a specific Qemu build. Download it here: https://surfdrive.surf.nl/files/index.p ... Z/download
Note: macOS/Linux users can use a standard Qemu build.

FILE SHARING:
To enable file sharing you need to install a "9p" driver in your System/Extensions folder. Download the latest version here: https://surfdrive.surf.nl/files/index.p ... l/download

Note: Updated on 30-09-2023: The 9p driver has new functionality. It supports:
-Rudimentary write support
-File renaming
-The mount_tag on the command line shows up as the name of the disk in Mac OS

Issues:
-You cannot move files between folders on the shared folder. You cannot trash a file, you cannot put a file on the desktop from the shared folder (as these are actually moves),
-On windows hosts, files are written as separate data and resource files
-Folders that would be invisible on a Mac show up
-Typical Mac characters show up garbled on the host side (windows only)
-Only some file types are recognised directly and can be opened/edited directly from the shared folder
-Might need a few tries to boot successfully

Add the following to your qemu arguments and adjust the path to the folder you want to share:

macOS:

Code: Select all

 -virtfs local,security_model=none,mount_tag=qemushare,path=path to folder on host 
Windows:

Code: Select all

 -virtfs local,security_model=none,mount_tag=qemushare,path=path to folder on host 

TABLET DRIVER
To enable an absolute input device (Tablet driver), you can download this driver: https://surfdrive.surf.nl/files/index.p ... 4/download

Note: updated on 06-10-2023.
-The driver now supports scrolling

Put the driver in your System/Extensions folder.
Add the following to your command line:

macOS:

Code: Select all

-device virtio-tablet-pci
Windows:

Code: Select all

-device virtio-tablet-pci

BOOTING MAC OS 9.2 FROM A LOCAL FOLDER:
You can boot Mac OS 9 from a local folder on your host.
Note: this is best seen as a proof-of-concept as it boots a very limited version of Mac OS 9.2

The biggest bugs are:
  • Booting from a local folder is slow
  • Weird custom format for resource forks and Finder info (bootable folder attached)
  • Needs a minimal "bootstrap" disk image (attached)
Download and expand the attachments. There is a tiny bootable disk image (bootstrap.img) and a folder (os9test) with a cut-down copy of Mac OS 9.2.2. The disk image loads the Virtio driver then continues booting from the folder.
https://surfdrive.surf.nl/files/index.p ... j/download
https://surfdrive.surf.nl/files/index.p ... P/download

macOS:
Add the following to your qemu arguments and adjust the paths as needed.

Code: Select all

-drive format=raw,media=disk,file=bootstrap.img
-virtfs local,security_model=none,mount_tag=doesntmatter,path=os9test
Windows:
Note: Expanding the os9test file might give you some errors related to characters in the file names.
Add the following to your qemu arguments and adjust the paths as needed.

Code: Select all

-drive format=raw,media=disk,file=bootstrap.img
-virtfs local,security_model=none,mount_tag=doesntmatter,path=os9test
I am very grateful to my friends at #mac68k on Libera for their help and support. Help is very welcome: the code is at https://github.com/elliotnunn/QemuMacDrivers.

2023-08-12
Debug output is available, but slow because there is a page fault per character.

Code: Select all

-serial stdio -prom-env 'nvramrc=dev /pci/pci1af4,1009 1 encode-int " debug" property'
– Elliot/edited by Cat_7
Last edited by elliotnunn on Sat Aug 12, 2023 7:17 am, edited 1 time in total.
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Virtio drivers

Post by adespoton »

Thanks, Elliot! Can't wait to try this out!
User avatar
robin-fo
Space Cadet
Posts: 5
Joined: Fri Mar 31, 2023 6:07 pm

Re: Qemu virtio drivers for Mac OS 9.x

Post by robin-fo »

This is just... WOW! It even works with UTM! Tested with UTM 4.1.6 running on Mac OS 12.6. I Just had to install the extension and choose VirtFS in directory share mode. Not even some additional command-line parameters were required!
User avatar
robin-fo
Space Cadet
Posts: 5
Joined: Fri Mar 31, 2023 6:07 pm

Re: Qemu virtio drivers for Mac OS 9.x

Post by robin-fo »

Do you have any plans for an 68k version?
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Qemu virtio drivers for Mac OS 9.x

Post by adespoton »

I've got another request: any chance it could be hosted somewhere with http:// ? I've been having a bit of a headache shoehorning it into one of my existing images (eventually I'll have to convert my qcow2 image back to raw, mount it on the host and copy over -- attempts to use smb, afp, ftp and ssh between guest and host have all been failing since macOS 13 and I haven't had the time to figure out why).
User avatar
Cat_7
Expert User
Posts: 6014
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Qemu virtio drivers for Mac OS 9.x

Post by Cat_7 »

I'm sorry, I have no other option.

You say you can no longer get Qemu to forward the ftp port to your host?

Best,
Cat_7
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Qemu virtio drivers for Mac OS 9.x

Post by adespoton »

Cat_7 wrote: Fri Sep 15, 2023 9:21 pm I'm sorry, I have no other option.

You say you can no longer get Qemu to forward the ftp port to your host?

Best,
Cat_7
Yes; not sure what's going on; it's either a UTM thing or a macOS 13 thing or a combination. I've done the "convert qcow2 to raw, mount, write the driver, unmount, convert to qcow2, launch emulator" dance now, and it's all working, other than being read-only.

I haven't attempted doing a raw qemu-x86_64 run to see if that works; I expect it would, but I'm specifically attempting to test UTM 4.4.1 right now :)
User avatar
Cat_7
Expert User
Posts: 6014
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Qemu virtio drivers for Mac OS 9.x

Post by Cat_7 »

A new version of the 9p driver was posted in the first post. It now has basic write support.

Best,
Cat_7
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Qemu virtio drivers for Mac OS 9.x

Post by adespoton »

Thanks, Elliot and Cat_7!

Anyone mind if I mirror the driver to somewhere like Macintosh Garden so it's available over HTTP to OS 9 browsers?
User avatar
Cat_7
Expert User
Posts: 6014
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Qemu virtio drivers for Mac OS 9.x

Post by Cat_7 »

It's open source.

Isn't it only an issue to get the first driver going? After that you can use it to import from your host.
I guess if you post any version on a http-enabled site, the post should stress to immediately update.

Does Classilla not do https?

BTW: I just posted the 30-09-2023 version.

Best,
Cat_7
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Qemu virtio drivers for Mac OS 9.x

Post by adespoton »

Cat_7 wrote: Sat Sep 30, 2023 10:39 am It's open source.

Isn't it only an issue to get the first driver going? After that you can use it to import from your host.
I guess if you post any version on a http-enabled site, the post should stress to immediately update.

Does Classilla not do https?

BTW: I just posted the 30-09-2023 version.

Best,
Cat_7
Yeah; my plan was to put the version somewhere http-accessible with a note to use it ONLY to bootstrap the process of downloading the latest version. I don't want to get caught up in the update cycle :) Still figuring out the best place to do this; MG may end up with it being buried or considered "latest version".
User avatar
Cat_7
Expert User
Posts: 6014
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Qemu virtio drivers for Mac OS 9.x

Post by Cat_7 »

I've added a 9p tablet driver to the downloads in the first post. It only works in Mac OS 9.2

Best,
Cat_7
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Qemu virtio drivers for Mac OS 9.x

Post by adespoton »

Here's a question: someone (I believe it was Elliot?) previously came up with a way of injecting a tablet driver into OpenFirmware directly via a QEMU command line parameter, without having to mess with the host OS directly. Would that be possible for the current batch of Virtio drivers? And would it work for all guests loading OpenFirmware (so the drivers would be available for both OS 9 and OS X prior to OS initialization?)

Just thinking that if this is possible, they could be rolled directly into QEMU in this manner with no need to add extensions and automatic support for 10.1-10.5 (and booting from a shared folder) without needing a special boot floppy.
User avatar
Cat_7
Expert User
Posts: 6014
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Qemu virtio drivers for Mac OS 9.x

Post by Cat_7 »

10.2 (later versions) up to 10.5 have their own tablet driver (-device usb-tablet).

I might be mistaken, but I guess these 9p drivers use functionality exposed on the host.

Best,
Cat_7
User avatar
adespoton
Forum All-Star
Posts: 4076
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Qemu virtio drivers for Mac OS 9.x

Post by adespoton »

Cat_7 wrote: Wed Oct 04, 2023 10:57 am 10.2 (later versions) up to 10.5 have their own tablet driver (-device usb-tablet).

I might be mistaken, but I guess these 9p drivers use functionality exposed on the host.

Best,
Cat_7
The initial implementation of a tablet driver for Mac OS 9 involved pushing a driver via OpenFirmware that enabled OS 9 to use -device usb-tablet. This works for 9.1 and later. I never really thought about how it was pulling the functionality from the host; we may need someone like Elliot or Mark to weigh in on that.

The more interesting bit to me is whether the 9p file sharing driver could be implemented in a similar manner, as QEMU already supports the file system hook on the host side. Because then the emulated hardware would support file sharing by default and the OS would pick it up as a regular filesystem during initialization. This could be useful for display drivers and for clipboard management as well; if all these things are done in OF init and loaded from QEMU, then we don't need to modify the disk images themselves to pick up the features, unless I'm missing something.
Post Reply