TUTORIAL Virtualization setup follow-up Reverse Replies
Basically the Tips section of the previous virtualization post because #threadCharacterLimit strikes again...
You can get special drivers and install them in the guest allowing it to access virtual devices using the virtualization-optimized VirtIO protocols. Such devices include disks, network cards and the balloon driver.
VirtIO drivers for Windows can be obtained here, Linux has these drivers built into the kernel.
Download the VirtIO drivers and connect them to the guest through a CD-ROM and switch the NIC to VirtIO. After booting up the guest you won't have internet because Windows doesn't know how to talk to the network card, go to Device Manager and find an unknown network device (or something along the lines of that), click on update driver and navigate to the CD-ROM, under the folder NetKVM find your Windows version (for Windows 10 just use 8.1 drivers), select your architecture (x86 for 32 bit, amd64 for 64 bit) and install the driver.
While emulating one of the built-in network cards I managed to get a maximum of 180 Mbit/s which is reasonable for a network connection, but remember, I have localhost samba drives that need a lot of bandwidth. After installing the VirtIO NIC drivers I've managed to get nearly 800 Mbit/s.
Weird disk speed
By simply using the SATA driver for disk emulation of my raw SSD access I was able to get 500 MBps sequential read and write speeds but only 15 MBps random read/write. After installing the VirtIO drivers and switching it over to VirtIO the sequential speed actually dropped down to 400 MBps, random read/write both went up to almost 50 MBps though.
To install VirtIO disk drivers you have two options, either install them during Windows install or afterwards with a little hack.
During Windows installation
If you set your OS disk to VirtIO straight away before you even install anything on it, you will have to provide drivers during install time. To do that add another CD-ROM (SATA or IDE) device to the guest and connect the driver .iso to it. During installation Windows will tell you it can't find any disks to install on, simply tell it to load drivers, browse to the CD-ROM and under viostor find your Windows version (for Windows 10 it's okay to use 8.1 drivers), select your architecture, x86 for 32 bit and amd64 for 64 bit, and install.
After Windows has been installed
You will also add a CD-ROM device (or re-use the one you used to install the OS with) and connect the driver .iso to it. You will also create a temporary virtual disk and add it to the guest, switch it to the VirtIO protocol but keep your boot disk on the old (SATA/IDE) protocol, otherwise you won't be able to boot. After you've booted up with the .iso in the CD-ROM and an unformatted VirtIO disk, go to Device Manager and under Drives you should see unknown disks, simply update the driver and select the appropriate driver from CD-ROM/viostor/... (again, it's okay to use Windows 8.1 drivers for Windows 10). After you've installed the drivers, shutdown the guest, delete the temporary disk and switch the main boot disk to VirtIO.
If you want to set up guest ports to listen for incoming data, for example I had to set this up for SSH to the guest, you have to manually edit the virtual machine definition files and switch the network type to user-mode networking.
Achieving this is not as straight-forward as installing drivers or switching a setting, mainly because virt-manager doesn't have a graphical way to do this. Firstly open a terminal and execute the command
virsh edit <name of your guest>, this will open up the guest definition file, we will edit a few things here.
Change the very first line (at least for me)
<domain type='kvm'> and change it to
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>, this is telling virt-manager that we will be using some custom XML definitions from there.
Now about half-way through the file you should stumble upon
<interface type='network'>, change that to
<interface type='user'>, this will switch the network routing mode to user-mode, effectively routing everything through the host.
Now at the end of the file, but still inside of the
<domain> scope; so between
</domain> insert these few lines of XML
the third line specifies which port and protocol to pass-through, in my case (SSH on guest port 1337), the line looked like this
<qemu:arg value='tcp:::'/>. This routed all TCP traffic going to the host's port 1339 into the guest's port 1337.
Please Log in to post a reply.