Apple M1 Macbook host with qemu Windows XP guest

Page 1 of 1 [ 7 posts ] 

Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,458
Location: Pennsylvania

28 Dec 2022, 9:10 pm

I recently tripped over this old WP post:

Arch Linux Qemu Not Booting WinXP With PCI Passthrough

So I thought I would post here with my problem and see what I get. Any replies or suggestions welcome.

Problem: I had a Windows 7 laptop. I could run software that worked with USB2Serial adapter and talk to the old Lego Mindstorms RCX via IR.

I now have an Apple M1 Macbook. I am trying to install Windows XP as a guest under QEMU. There is a port of QEMU for mac called UTM. I don't have the Windows 7 laptop any more.

I tried to use the UTM "easy" interface to create the VM but I could not even get it to boot the iso.

Anyone QEMU experience?

I could use some guidance.

I just downloaded a copy of the seabios as a RPM and used p7z to unroll it into a cpio (then used cpio to unroll that).


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,458
Location: Pennsylvania

04 Jan 2023, 1:38 pm

Stumbling forward.

I have read a bunch of web pages. (Did I mention that I feel like I don't know ANYTHING about a subject until I know EVERYTHING about a subject).

Qemu can emulate a number of different CPUs.
Each CPU is represented by a different executable.

on my machine I currently have two x86 type CPUs

/opt/homebrew/bin/qemu-system-i386

/opt/homebrew/bin/qemu-system-x86_64

I guess the first fakes up a 32bit x86 cpu and the second fakes up a 64bit x86 cpu.
I am leaning towards the 32bit cpu because my software that I want to run is so old.
If I cannot get the 32bit cpu to work I will try the 64bit.

Next the CPU needs a bios. A number came with the Mac OS homebrew qemu installation. One web page suggested that XP wouldn't like the "standard" one, and I should use seabios. Not available as part of the homebrew qemu installation. Managed to find it in a rpm "noarch" - unrolled it with 7zip (p7z - the linux-friendly command line version of 7zip) which is able to treat the RPM like an archive format with no RPM executable or RPM libraries installed. This gave me a cpio archive which I was able to unroll with the cpio executable. Homebrew had a rpm2cpio but it didn't work. 7zip did.

I also need some disk images. This one I am still working on. There are a number of different "disk as a file" file formats that qemu supports. I also need a "install XP" iso image. There are a number of XP iso images available for download in line, but it is unclear to me which one(s) are bootable install CDs. Another method would be to buy an XP install CD on ebay and rip it to a CPU. qemu command line arguments can be used to ask the "cpu" to boot from "disk c" (the emulated hard disk) or from "disk d" (the emulated CD-ROM). The "cpu" actually boots up with the bios instructions in "ROM" which then bootstraps from the disk. The bios needs to be "qemu compatible" in order for the qemu commend line to correctly influence it (e.g. boot device order) otherwise I need to somehow get to a bios screen/menu and configure it by hand.

Open issue: I don't know which bios's are "qemu compatible" and which are not, nor how to tell.

Open issue: The "hard disk" image could be "blank" (filled with zeros) OR I could initialize it with a FAT32 filesystem - not 100 percent clear on how to do this - does the "disk image" represent a raw disk with partitions and sectors? Does it have a Master Boot sector like a real disk? I know mtools can be used to format a disk image and qemu-img can be used to create some kinds of disk images - I am still fuzzy on the details. And I really DON'T LIKE to be fuzzy on the details. I think seabios is "qemu compatible" because it is FOSS (free open source software) but so far that is just a guess.

Also since I am not sure which of my XP iso images is the bootable installer, it is hard to see if I am getting hung up with bios issues or OS boot issues.

So: I am going to try to install a qemu with Freedos from the Freedos iso (which seems to be better documented). I could then put grub4dos on the freedos "hard disk" image and try to use it to bootstrap the XP install from iso. I might getter better error messages and results that way. I could also try putting something like damnsmall linux on the "hard disk" image, then try to chain boot with grub2. But that brings me back to my questions about which disk-image formats can handle more than one partition and which are really a "filesystem image". Some formats are only supported readonly, others readwrite but I am still a bit fuzzy on which, and how to mount read/write as apposed to readonly.

And then there is video card emulation - which I haven't read up on at all.

Stay tuned.

(any tips gratefully received)


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


Mikah
Veteran
Veteran

User avatar

Joined: 23 Oct 2015
Age: 36
Posts: 3,201
Location: England

04 Jan 2023, 3:28 pm

I've only ever played around with VirtualBox which is pretty easy and intuitive and supports M1 as of a few months ago apparently, I can't offer any tips for QEMU.

Fenn wrote:
does the "disk image" represent a raw disk with partitions and sectors?


Probably yes, that's certainly how it works using the default virtual disk image type in VirtualBox, although there were other options that I didn't properly investigate.


_________________
Behold! we are not bound for ever to the circles of the world, and beyond them is more than memory, Farewell!


Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,458
Location: Pennsylvania

04 Jan 2023, 3:43 pm

Mikah,
Thanks for the tip!

I think VirtualBox only does "same CPU" virtual machines. qemu can do x86 CPUs on an M1 chip (which is why I chose it). But qemu can use some of the VirtualBox file formats.

VirtualBox compatible disk image formats are listed here:

docs.oracle.com - Virtualization - VirtualBox - Disk Image Files (VDI, VMDK, VHD, HDD)

QEmu compatable disk image formats are listed here:
( raw, qcow2, bochs, cloop, cow, dmg, nbd, parallels, qed, vdi, vmdk, vvfat )

access.redhat.com - documentation - Supported qemu-img formats

Looks like both QEmu and VirtualBox support vdi and vmdk. The QEmu "parallels" and the VirtualBox "HDD" may be the same (or compatible).


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie


Mikah
Veteran
Veteran

User avatar

Joined: 23 Oct 2015
Age: 36
Posts: 3,201
Location: England

04 Jan 2023, 3:53 pm

Fenn wrote:
I think VirtualBox only does "same CPU" virtual machines. qemu can do x86 CPUs on an M1 chip (which is why I chose it). But qemu can use some of the VirtualBox file formats.


I see the problem, yeah. QEMU might be the only free option.

VDI is the format I remember using. Edit: I also remember installing grub and multibooting on a .vdi image.


_________________
Behold! we are not bound for ever to the circles of the world, and beyond them is more than memory, Farewell!


elbowgrease
Veteran
Veteran

User avatar

Joined: 1 Aug 2017
Age: 38
Gender: Male
Posts: 1,505
Location: Arcata,CA

05 Jan 2023, 1:07 am

I only have experience using qemu on linux, with virt-manager as the gui. Never attempted to install anything windows and basically haven't ever used anything mac.
So,
the gui shouldn't matter, but sometimes it does. If nothing else seems to be working, you may check it out. I have no idea what the install process for that is like on mac, but it shouldn't interfere with UTM (you should be able to have both installed on the system and just pick one or the other at any given time to act as your gui for qemu. You might even be able to start a VM with one gui, close the gui without shutting down the vm and then open the other gui and reconnect to the still running vm.) The gui really shouldn't matter, though.
As far as SeaBIOS, their website says they are the default BIOS for qemu and kvm. So you shouldn't need to change anything in order to have seaBIOS available. If for some reason you do need to manually install a new BIOS, you should be able to find source for it without looking too hard (it's gpl, so the source IS available). You may even be able to find binaries. Maybe even just in the downloads section of their site.
I had issues for a while trying to get VM's to boot uefi rather than BIOS, although I think it was directly related to using virtualbox on a linux distro that doesn't use systemd. Some issue with ovmf not being available without a hard dependency on systemd. I figured out some kind of workaround for it but it was long enough ago that I don't remember what it was I did or even really what exactly the problem was. Since I switched from virtualbox to kvm/qemu/virt-manager, I have not run into that problem again. I have made the mistake of configuring the virtual hardware one way and then installing the system another and ending up with something that wouldn't boot without an "external" boot disk, though. (BIOS machine+UEFI system=doesn't boot).

I've had a few problems with users/groups/permissions, finding the right lines in the right configs to edit, finding out an update replaced those configs at some point and needing to go in and edit them again, getting the right services and daemons running, etc. Any of those things not being passably configured throws any number of errors. Sometimes makes it appear that all my VM's have disappeared. None of that is really difficult, just tedious to do the first time. And things won't work until it's done.
I haven't tried to emulate architecture yet. I know there are a lot of options, I just haven't worked on that yet. I think it's probably a good idea to try to emulate the ideal setup for whatever you're installing, or try to acquire an iso built for the hardware you're emulating. If you're trying to run windows xp, probably good to set up your emulated hardware the way xp needs it to be.

The VM's hard disk should be "blank" before you format it (like an ssd/hdd would be if you bought it brand new). I've always formatted them during installation, whether that's fdisk, cfdisk, some "auto-magical" behind the scenes operation preformed by the installer of an os if the os I'm installing has a fancy installer. Once you've set up the VM's parameters (CPU (cores), architecture, ram, network, hard disk size), then it's like you've got a computer sitting there with no operating system on it. You could download a linux boot disk and boot the machine from that and use the live environment to format the hard drive and install whatever operating system you want from there. I've only ever installed or attempted to install linux distros or *BSD's. For that, unless a person is trying to do something specific, it doesn't matter what boot disk you use. As long as it's got some basic tools and network access it's possible to boot the machine, format the hard disk and then download/build/install some entirely different system onto the newly formatted disk. It's even possible to run one system on another running system without using a proper VM, just using chroot or jails (precursors to containers?).

Anyway, I don't know what to look for in a bootable xp disk, I'd probably search "windows xp iso" or "windows xp installer", etc. and look for someplace reputable to download from and be willing to try a few until I found one that works, if I were going to try to install xp.

You might look for tutorials specific to the install you're trying to do. I've watched a lot of install videos, and set up videos. Sometimes it helps.

Sorry if this post rambles a lot without being helpful at all. VM's are really fun, and they're a good way to try things and learn things and break things without crashing your system (make a clone of you're fresh install, then crash the clone).



Fenn
Veteran
Veteran

User avatar

Joined: 1 Sep 2014
Gender: Male
Posts: 2,458
Location: Pennsylvania

05 Jan 2023, 11:09 am

elbowgrease,
Thanks for you feedback and experience. It all helps.
Mikah,
Thanks again.

I dug in and read a whole slew of web pages. Analysis paralysis and rabbit-holes some of it, but it helped fill in the context for things and made other pages make more sense.

Both Mikah and Elbowgrease were right: the disk image can be created "blank" and the iso installer will go ahead and format it, add a MBR and make it bootable, and install the OS to it. Also: A blank qemu compatible disk can be created with "/opt/homebrew/bin/qemu-img create -f qcow2 /dira/dirb/dirc/filename_of_new_disk_image.qcow2 ${disk_size_in_gigabytes)G". The whole disk can be loopback mounted with "qemu-nbd" and then partitioned (from linux) with "sfdisk" or "parted". Or it can just be handed to the qemu VM and let the VM iso install do the partitioning and formatting. Since I don't have linux, I could use a bootable linux iso as a guest in a QEmu VM, and use that to partition and format the virtual hard disk. (I think I am repeating myself - or things that others have said).

For example:

gparted.org - livecd

I managed to get a 32bit x86 xp to install in a qemu guest last night. The xp iso booted and I let it format the qcow2 disk image by following the dummy prompts.

More specifically I found the link to the xp ISO here:

how2shout.com - windows xp iso on virtualbox

Which linked to a mirror of a no-longer-existing web page

archive.org - WinXPProSP3x86

Which contained both the XP install Serial Number and the iso (here):

archive.org - en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso

I created the empty disk image:

Code:
/opt/homebrew/bin/qemu-img create -f qcow2 /Users/fenn/xp-virt-disk.qcow2 40G


. . . and booted the VM with the Virtual Hard Disk from the Virtual CD-ROM

Code:
/opt/homebrew/bin/qemu-system-i386 -bios /opt/homebrew/Cellar/qemu/7.1.0/share/qemu/bios.bin -vga cirrus -display cocoa -drive file=/Users/myname/xp-virt-disk.qcow2,readonly=off -k en-us -cdrom '/Users/fenn/./Downloads/en_windows_xp_professional_with_service_pack_3_x86_cd_vl_x14-73974.iso' -boot d


This specifies:
Code:
-bios       uses seabios and not UEFI
-vga        read someplace that cirrus works with XP and std doesn't
-display    the version of qemu I have (from homebrew)
                  doesn't support sdl or vnc, just cocoa, curses and none
-k          en-us keyboard emulation - XP install uses the keyboard to let user respond to prompts
-drive      the virtual hard drive
-cdrom      the bootable cdrom image as an iso file
-boot       specifies to boot from the first configured cdrom (called "d")


Did I specify RAM? No. Should probably do that.

Did I specify multicore CPU? No. Read someplace that XP could use this if I gave it a chance. Worth a try.

Did even try to specify emulate network card or USB passthrough? No. TO DO

The qcow2 format uses compression, and doesn't take up room for unused disk space

Size after install:

Code:
$ du -h xp-virt-disk.qcow2
1.5G    xp-virt-disk.qcow2


I verified I could boot from the virtual hard drive after the XP install

Code:
### Boot from Hard Disk Image (qcow2)
/opt/homebrew/bin/qemu-system-i386 -bios /opt/homebrew/Cellar/qemu/7.1.0/share/qemu/bios.bin -vga cirrus -display cocoa -drive file=/Users/fenn/xp-virt-disk.qcow2,readonly=off -k en-us -boot c




Next step: I need to enable networking, or create a "sneaker-net" virtual hard-disk or iso to copy the software I need to the Guest XP.

I also need to try to get it working with the USB pass-through.

And . . .

superuser.com - questions - 1132000 - is it still possible to get cygwin for xp


_________________
ADHD-I(diagnosed) ASD-HF(diagnosed)
RDOS scores - Aspie score 131/200 - neurotypical score 69/200 - very likely Aspie