Kyle Pericak

"It works in my environment."

Tue 17 December 2019

Injecting KVM Drivers to Windows 10 for OpenStack

Posted by Kyle Pericak in cloud   

This post is linked to from the OpenStack Deep Dive Project

Note: While these steps were tested against Windows 10, they should also work against Windows 7 and the various Windows Servers. Be sure to run a newer Windows OS than the one you're importing though - Don't try and import Windows 10 from a Windows 8 workstation, for instance.

Prepare the image in-guest

From VMWare or HyperV, launch your template Windows VM and log in as an administrative user. Make any firewall changes you need, install any packages, and ensure that RDP is enabled.

Remove VMWare Tools

If the guest has VMWare tools installed, remove them. They won't be needed where we're going.

Install cloudbase-init & sysprep (if needed)

This isn't so much for KVM as it is for OpenStack, but cloudbase-init is the Windows version of cloud-init. This will set your hostname and such when the VM is created.

  1. Download the Cloudbase-init installer
  2. Run through the installer.
    1. Don't run as Local System.
    2. Don't name your user Administrator, the named user is made by this service to run the startup tasks.
  3. At the end of the installation, you'll be prompted to sysprep. If this VM will be re-used as a template and not just a one-off VM, then sysprep it.

Shut down the VM & Export the drive

Shut down the VM and grab the VMDK or VHDX file it booted from. Copy that file to a directory on your computer, such as C:\Temp.

Inject the KVM Drivers

  1. Download the VirtIO ISO
  2. Mount the ISO to your workstation. In these examples, it's E:
  3. Open PowerShell as admin and verify that the file is where you put it. You can show some basic info about it like this: get-vhd C:\Temp\Win10.vhdx
  4. Create a mount-point for Dism: mkdir C:\mount
  5. Mount the volume with Dism: Dism /mount-image /ImageFile:C:\Temp\Win10.vhdx /Index:1 /MountDir:C:\mount
  6. Inject the viostor driver: Dism /image:C:\mount /Add-Driver /Driver:E:\viostor\w10\amd64 /Recurse
  7. Inject the Baloon driver: Dism /image:C:\mount /Add-Driver /Driver:E:\Balloon\w10\amd64 /Recurse
  8. Inject the NetKVM driver: Dism /image:C:\mount /Add-Driver /Driver:E:\NetKVM\w10\amd64 /Recurse
  9. Confirm the drivers injected: Dism /image:C:\mount /Get-Drivers
  10. Unmount the image: Dism /Unmount-image /MountDir:c:\mount /commit

Now the image is ready to be converted to raw/qcow2 and uploaded to OpenStack.

Note: CloudBase has released a Windows version of qemu-img so you can do the conversions on Windows now without VirtualBox tools. You can download it here

Javascript appears to be disabled. Comments can't load.