So I wanted to dive back into old BSD, and I wanted to use the new native Qemu on OS X. That means having to “learn” the new crazy syntax that has drifted a LOT over the last 10+ years.
I want to run NetBSD 1.0 and tear into the GCC 2.x patches required back in the day
In the old days, I was using Qemu 0.13 and had it working using the following:
qemu.exe -L pc-bios -hda netbsd-1.0.vmdk -net nic,model=ne2k_isa -net user -redir tcp:42323::23 -m 64 -no-reboot -rtc base=localtime -k en-us
Thankfully I was using VMDK containers, probably as I’m sure I installed it under VMware, with it’s better floppy support, but pulled it back to Qemu to have NE2000 support. Now let’s look at the dmesg to where the source of the problem is, the network card:
NetBSD 1.0 (QEMU) #0: Thu Sep 22 06:45:37 PDT 2016   [email protected]:/usr/src/sys/arch/i386/compile/QEMU CPU: Pentium (GenuineIntel 586-class CPU) real mem = 67764224 avail mem = 62312448 using 852 buffers containing 3489792 bytes of memory pc0 at isa0 port 0x60-0x6f irq 1: color com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo lpt0 at isa0 port 0x378-0x37f irq 7 wdc0 at isa0 port 0x1f0-0x1f7 irq 14 wd0 at wdc0 drive 0: 1023MB 2080 cyl, 16 head, 63 sec <QEMU HARDDISK> fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2 fd0 at fdc0 drive 1: density unknown pci0 at isa0 port 0x0-0x665: configuration mode 1 pci0 bus 0 device 0: identifier 12378086 class 06000002 not configured pci0 bus 0 device 1: identifier 70008086 class 06010000 not configured pci0 bus 0 device 2: identifier 11111234 class 03000002 not configured ed0 at isa0 port 0x320-0x33f irq 10: address 52:54:00:12:34:56, type NE2000 (16-bit) npx0 at isa0 port 0xf0-0xff: using exception 16 biomask 4040 netmask 412 ttymask 12 changing root device to wd0a
So the important thing here is that the NE2000 is the ed0 device using an IO of 0x320 and IRQ 10. I’m pretty sure back then I cheated, and just recompiled Qemu to remove the default definition that doesn’t work properly with trying to share IRQ 9.
Keeping this in mind, let’s build this for the new Qemu:
qemu-system-i386 -net none -device ne2k_isa,iobase=0x320,irq=10,netdev=ne -netdev user,id=ne,hostfwd=tcp::42323-:23 -drive file=netbsd-1.0.vmdk,if=ide,index=0,media=disk,cache=writeback,format=vmdk -rtc base=localtime -k en-us
So the first important thing is to disable any/all defualt NIC’s with the ‘net none’ flag. Next to add in the NE2K_ISA type device manually so I can specify the iobase & irq manually. Note the netdev as this is used to tie in the emulated device, to the backend that will process the packets. The next part is the redirect to have the host listen on port 42323 and redirect them into port 23 of the VM. Again the syntax to redirect ports has drifted significantly. The hostfwd now is bound directly to the netdev user, in this new syntax it allows for multiple NIC’s to be bound to multiple user NAT’s if needed.
-device ne2k_isa,iobase=0x320,irq=10,netdev=ne -netdev user,id=ne,hostfwd=tcp::42323-:23
The next ting is the hard disk, before ‘hda’ worked fine, although like everything else that is subject to change in the future, so dealing with it now, use the drive flag:
-drive file=netbsd-1.0.vmdk,if=ide,index=0,media=disk,cache=writeback,format=vmdk
It could be my personal opinion but the drive syntax, although much longer is easier to work with. The key parts being what interface to use (IDE), and what port/index to plug the device in (0), along with the media type, the cache strategy, along with the encoded format, which is more so important when dealign with RAW devices, as unidentified media will be tagged as raw, however it’ll be mounted read-only unless it is directly specified as above.
For additional fun, the serial port can be set to a MS Mouse port, although I haven’t tested it as of yet.
-serial msmouse
Have fun QEMU’ing!