Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Last active December 3, 2022 03:17
Show Gist options
  • Save rpavlik/a34cd474772d666132f12c5c459ad622 to your computer and use it in GitHub Desktop.
Save rpavlik/a34cd474772d666132f12c5c459ad622 to your computer and use it in GitHub Desktop.
Windows Dev VM in libvirt

One time

  • Build rhsrvany using a windows toolchain like i686-w64-mingw32, and put the resulting rhsrvany.exe and pnp_wait.exe in /usr/share/virt-tools (or see https://salsa.debian.org/rpavlik/rhsrvany for a debian package of it)
    • git clone https://github.com/rwmjones/rhsrvany.git
    • cd rhsrvany
    • autoreconf -i -f
    • ./configure --host=i686-w64-mingw32
    • make
    • sudo mkdir -p /usr/share/virt-tools
    • sudo cp RHSrvAny/rhsrvany.exe pnp_wait/pnp_wait.exe /usr/share/virt-tools
  • Download https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso and place in /usr/share/virtio-win/virtio-win.iso
    • sudo mkdir -p /usr/share/virtio-win
    • sudo wget -O /usr/share/virtio-win/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/latest-virtio/virtio-win.iso

Each time

  • Download the dev VM for VMware - do not unzip it. (Makes the next step take a lot longer but work better.) https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
  • virt-v2v -i ova WinDev2204Eval.VMware.zip -of qcow2 -oa sparse -os gnome-boxes -on DesiredVMName
    • This looks in the two directories mentioned above by default to find stuff to install on the VM.
    • -i ova says we import a vmware OVA archive
    • -of qcow2 says output disk format is qcow2
    • -oa sparse says sparse
    • -oo compressed says make it compressed.
    • -os gnome-boxes says use the gnome-boxes storage pool
    • -on DesiredVMName explicitly sets the output VM name - leave this off if you are fine having a name auto-assigned based on the VM content.
  • In virt-manager, ideally before starting the first time:
    • change network to usermode networking
    • Add a Spice guest channel.
    • Add a QEMU guest agent channel (target org.qemu.guest_agent.0 )
    • If, like me, you stored your actual data on a separate disk image: Add a virtio disk mount for the data disk image.
      • Otherwise, add a placeholder image, with nothing on it but set to use virtio, to pull in those drivers.
    • Add a new SATA (not scsi!) CD-ROM, removing the SCSI one, and point it at /usr/share/virtio-win/virtio-win.iso
  • In VM, once logged in:
    • install "E:\virtio-win-guest-tools.exe" from CD
      • you will have to accept installing a driver signed by Red Hat.
      • If you get an error about starting a service, you missed the "add a spice channel" step.
      • Think this might include the "install the qemu guest agent msi (guest_agent/x86_64/...)" step for you
  • Shut down the vm
  • In virt-manager:
    • Adjust CPU topology as desired - keep as one socket!
    • Increate amount of memory
    • Maybe? This appeared to make it less responsive the first time I did this.
      • remove existing tablet
      • add virtio keyboard
      • add virtio tablet
    • Optional: Change USB controller to USB 2
    • Change display to Spice server
    • Recommend connecting to an additional disk image, if you haven't already, that can be shared between VMs or used after this VM expires.
  • Start up VM, and check that it's all working as desired.
  • refs:
@jlaine
Copy link

jlaine commented Apr 19, 2022

Hi! Shouldn't the command to configure rhsrvany be:

./configure --host=i686-w64-mingw32

@rpavlik
Copy link
Author

rpavlik commented Apr 19, 2022

I'm pretty sure this is the command I used, but according to my package of this you're right: https://salsa.debian.org/rpavlik/rhsrvany/-/blob/debian/devel/debian/rules Autoconf cross compiling is so weird.

@jlaine
Copy link

jlaine commented Apr 19, 2022

Ah good to know there's an RFP for this tool, I'm indeed building on Debian/unstable :)

FYI I followed most of your instructions to get a WinDev2022 image running. No joy getting KVM support though, so I've had to stick with plain QEMU. The virtio-win ISO doesn't work either, the installer bombs without any useful details. The two issues might be linked.

The command I used to convert the image and create a VM was:

sudo apt install libnbd-bin nbdkit virt-v2v
sudo virt-v2v -v -i ova WinDev2202Eval.VMware.zip -os default -of qcow2 -on WinDev2022

@rpavlik
Copy link
Author

rpavlik commented Apr 19, 2022

hmm, what a drag! I just did this again the other day, though I did update which virtio-win iso I used. Think I'm using virt-v2v from backports, since i'm on Bullseye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment