Virtual Machine tuning? KSM and QEMU

Okay so I have finally setup a virtual machine for Windows, Its running a bit choppy though, And I am unsure on how to edit stuff.

I remember Zoltan saying alter KSM and QEMU to make the system faster, But how do I do this? Is is a CPU setting or something? Also how do I alter my VRAM? its at 9MB lol.

Ideas people?



By default, kvm will assume that you're going to run a bunch of specific purpose containers, so it'll probably set the container to use only one core and a minimum of RAM. You can boost that up all the way (it will reserve about 700-800 MB of RAM for the host system automatically), you can safely set your core count to the maximum number of cores on your CPU, it doesn't matter, since KVM is kernel-based virtual machine, the host system can actually make all cores work in the virtual container.

QEMU is basically architecture emulation. It allows you to emulate another CPU than the one in your system. It does this in a pretty clever way, but within reason. If you stick to the same architecture, but for instance you have a four core i5 and your application in your guest system requires a 6 core CPU, you can keep the same architecture of your CPU, but enhance the number of cores. QEMU will then "emulate" extra cores, and it will barely slow down the system, but the guest will think that you're running on a 6-core system. In general though, it's best not to emulate anything, because emulation in itself will always cost extra resources. If you emulate other CPU architectures, like ARM for instance, which you can perfectly do (for instance if you want to run an Android container on your system like I do, and don't want to use android-x86 because it sucks), this will be noticeably slower than when you stick to x86-architectures.

As to the graphics, you can't reserve more than about 128 MB of RAM with the open source graphics profiles. Even in VirtualBox you can't go over 512 MB or so using proprietary profiles. What you need to do to get good graphics performance in your guest, is do a PCI passthrough. That way, your guest can directly access the real graphics card, not a virtual one, and use the full VRAM of your GPU. For PCI passthrough, you need two graphics adapters on your system, and set your host to use one, and bind the PCI slot with the other one to the guest. If you only have one graphics card, you can still bind the card to the guest by using a VGA passthrough, but that's not easy, it only works with AMD cards, and it's generally a bitch to keep running with updates and stuff, and sometimes you have to script a few things to prevent X from crashing. It's not that complicated as such, but it's different for every system I have come across, so there is no way to write a howto about this in a general way, it's a hands-on experience on every system.

Okay well I managed to turn up the topology of my CPU to 8C/16T and it ran as a Xeon sandy, All I want is so it is not choppy as hell, I don't think games at the moment will run well, I also have my system set to 7443MB RAM as I have 8GB.

I have just dropped it back to emulate my CPU exactly though, see if anything decent happens, Wouldnt mind it based off AMD 8350 though.

And I have just setup a PCI passthrough, but it says host cant passthrough, I believe that is a driver issue that will be sorted in a few mins, But all I want to do is play games on it, but be able to snap back to a time if it gets damaged, Although it is not hard really to remove malware.

Anyway as said, Just want it to be smooth enough, Its choppy no matter the setting of CPU/RAM although I hope the AMD driver will fix it.

All this is on Mageia, Had issues with Arch and this.

Okay actually I have the driver already, The control centre already has BARTS set to default. Hmm why cant I passthrough and alter the VRAM then :S

You guest has configured itself to the situation before you added the PCI binding. Disable the regular virtual graphics adapter, and only let the guest see the PCI passthrough one. It's more a guest problem than a host problem I think. You do need to make sure that you have selected the right PCI slot and that it is bound. That means, that while your guest is running, if you do "lspci" in the host, that PCI slot doesn't show up in the list.

I tried that, I added PCI device, but presented with the following error

 Error starting domain: unsupported configuration: host doesn't support passthrough of host PCI devices<br /><br />Traceback (most recent call last):<br />&nbsp; File "/usr/share/virt-manager/virtManager/", line 91, in cb_wrapper<br />&nbsp;&nbsp;&nbsp; callback(asyncjob, *args, **kwargs)<br />&nbsp; File "/usr/share/virt-manager/virtManager/", line 127, in tmpcb<br />&nbsp;&nbsp;&nbsp; callback(*args, **kwargs)<br />&nbsp; File "/usr/share/virt-manager/virtManager/", line 1260, in startup<br />&nbsp;&nbsp;&nbsp; self._backend.create()<br />&nbsp; File "/usr/lib64/python2.7/site-packages/", line 866, in create<br />&nbsp;&nbsp;&nbsp; if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)<br />libvirtError: unsupported configuration: host doesn't support passthrough of host PCI devices

I cant boot the VM if a PCI passthrough device is enabled, no matter the device, due to this I cant use networking also.

Do i have to unbind from host and then rebind to guest, if so what is the command to do this?, I also cant get rid of the virtual GPU driver (Video - Cirrus do you mean?)

I am sorry to trouble you so much, but I really cant find the information, As you said, its system dependant, each can produce its own errors.

Yes you have to unbind from the host first, that's why you have to check lspci.

I actually bind and unbind in the command line, and I bash script it, just to make sure that I get everything just right and fast, and that I can revert easily. But doing it in Virt-manager should amount to the same result.

Make sure that you're running KMS drivers on your main adapter (the host adapter), because otherwise you'll crash X.

The error you're getting means that your host remains bound to the PCI slot you're trying to pass through. Disable the passthrough adapter in the host, not just the video card, the entire PCI slot. Again, check with lspci.

Don't worry dude, it'll work. I can't really give you the exact lines to enter because obviously I don't see your PCI ID's etc, but you'll probably want to figure this out by yourself anyway. Just post what you're getting, and I'll try to respond until you nail it lol.

You don't even have to get rid of the virtual GPU, you can switch it of in your guest anyway, it takes no resources, it's just a pain in Windows to swicth primary graphics adapters if you don't have the drivers installed yet.

Just checking the basics, you do have the correct BIOS settings for virtualization right?

You also have to enable passthrough in your kernel, you have to load pci_stub module and I think there was a boot line to add (for iommu).. Most of the guides you will find online for passthrough will be using XEN instead of KVM, but the KVM website has a small article in their guide as well

This might also help

One more thing, if you're experimenting maybe also try XEN for virtualization as it has more documentations as I saw..

got vt-d and everything, and passthrough should already be enabled, And I believe you need to pay for Xen dont you? but thanks for the links, I will check them

Xen is free and opensource as well

Okay this is my lspci output

[[email protected] xdroidie626]# lspci
00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200/2nd Generation Core Processor Family PCI Express Root Port (rev 09)
00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04)
00:16.0 Communication controller: Intel Corporation 7 Series/C210 Series Chipset Family MEI Controller #1 (rev 04)
00:19.0 Ethernet controller: Intel Corporation 82579V Gigabit Network Connection (rev 04)
00:1a.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 7 Series/C210 Series Chipset Family High Definition Audio Controller (rev 04)
00:1d.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB Enhanced Host Controller #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Z77 Express Chipset LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation 7 Series/C210 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation 7 Series/C210 Series Chipset Family SMBus Controller (rev 04)
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Barts XT [Radeon HD 6870]
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Barts HDMI Audio [Radeon HD 6800 Series]

I know I need to have multiple things running, such as my Ethernet controller and GPU, So how do I unbind the devices? Is it possible to build a script to swap all these devices at once so their plugged into the VM.

(Update 1)

Okay so I have tinkered with my viewer settings a bit (Where the connections are started) I managed to set the device to hotplug from my PC to the guests, using bridged so I believe this has sorted my networking issues, but still stuck with the GPU.

(Update 2)

I used virsh to attempt to remove the GPU and hotplug, this maybe just because the VM is not running, but the log is here for any addition information, provided is the output from virsh with my PCI ID

[[email protected] xdroidie626]# virsh nodedev-dumpxml pci_0000_01_00_0
  <capability type='pci'>
    <product id='0x6738'>Barts XT [Radeon HD 6870]</product>
    <vendor id='0x1002'>Advanced Micro Devices, Inc. [AMD/ATI]</vendor>

[[email protected] xdroidie626]# virsh nodedev-dettach pci_0000_01_00_0
error: Failed to detach device pci_0000_01_00_0
error: invalid argument: neither VFIO nor kvm device assignment is currently supported on this system

Did you check your perms? Are you in the kvm/virtual/iommu/whatever it is called on your system group as a user, because it's really strange that it would say that there is no IO virtualization function on your system. Do you have virtio installed?


As far as I know they are fine, I am in as root on virtual manager so should be okay no? how do I check the groups? and I cant find virtio in the packages.

Is there a distro with KVM works well? Seems mageia does not, Although more than likely I have missed something lol

Adding to that virsh gave me this

[[email protected] xdroidie626]# virsh nodedev-dettach pci_0000_01_00_0
error: Failed to detach device pci_0000_01_00_0
error: invalid argument: neither VFIO nor kvm device assignment is currently supported on this system

Tempted to bare metal windows on 2nd drive, Just dont want to, Rather not have a closed source system on the other side


Mageia and Fedora are very similar, they even share maintainers and developers, it should work just fine. You might want to check your kernel headers to make sure though, maybe IOMMU and stub are not flagged, but that would really surprise me.

search your kernel modules

for instance:

lsmod | grep "your kernel module that is required here"

modprobe the ones that you need but are missing

if everything is there, and it doesn't work, check if you don't have oracle virtualbox modules loaded ("vboxdrv") because that will bork kvm.

if that's not the case either, check if the adapter is not occupied by a driver, for instance pci_stub. If it is, manually unbind that and remove it's ID.


You understand that it is very hard to guess what your problem is exactly. Focus on diagnosing what step of the process fails. Just follow the logic of the process, from the kernel modules to the kvm-qemu bindings. I normally don't use virsh to bind-unbind though, I edit the binding directly and set up the container with kvm-qemu. Virsh is a CLI shell the likes of virt-manager being a GUI shell.

Okay so guides written for fedora should work on mageia? Also reinstalled so I can trace my steps more carefully :)

Um may be stupid but sometimes you have to enable vt-d in the bios it doesn't work by default

yes and double yes :(, checked again this afternoon to be sure it was not a noob mistake, if only though lol

Did you check all the parameters mentioned above? Did you find anything that was out of place?

As I said I reinstalled, so far nada, I am still checking though, I will get this dam thing working if it kills me lol, but im going xen this time, I have KVM etc already on, I asked on Stack exchange and they said one of the readouts said my card was not supported :S

I also experienced choppiness, until passing through one entire USB controller (2 ports on the rear of the motherboard) for the mouse and keyboard that I use in Windows.