How to fake physical HW in KVM

Funny story……

Imagine – you have brand new physical server… And you don’t want to use HyperV (I understand this), but still you want to use the Windows licence that is bundled with the machine on OEM DVD.

You start booting…….. And then – you end with message that you can install this image only on the machine that it belongs to. Luckily in KVM we can “fake” the machine. 😉

OK let’s start with preparing the ISO image and put it somewhere where we can access it with libvirt. Let’s say /tmp

2nd step is to get information from BIOS with dmidecode and again copy it somewhere where it can be read by libvirt. Because we need it for later use – this time /etc is better than /tmp

If you want to use virtio drivers in Windows we need to get also the virtio-win CD.
We have multiple choices – the easiest one is to download ISO.
In case you want to have the always the latest fresh version – you can add the repository. In our case we are using CentOS 7, but there’s no official repo for CentOS. But still we can use the Fedora repo without any problem.
With the following part we will get the latest images (CDrom/floppy/etc) stored in /usr/share/virtio-win/

Then just update the xml (define the machine the way you like… for example with virt-install and then just do the virsh edit).
Few tricky thingy….

* put  xmlns:qemu='' in domain definition. Otherwise the parser will cream with additional commandline options
* in case of Lenovo some of the values from BIOS were in format blablabla -[xyz]-  In this moment parser was stopping. No idea if it was because of XSLT/my typo/or because it was Saturday…… But it was pretty late and I was lazy and it is working perfectly fine just with part without brackets

Now cross your fingers, start the machine and your KVM environment should pretend to be nice Lenovo piece of hardware.