How libvirt cputune config goes to qemu-kvm

kvm-virtualizationlibvirtnumaqemuvcpu

I am porting xml libvirt config to qemu executable arguments. Simply I have .xml vm config from virsh edit vm-name and I want to run the same vm machine by executing qemu-system-x86_64 with special command line parameters. Die to my specific needs I cannot use libvirt. The problem is that .xml vm config uses special cpu mapping from host machine:

<cputune>
    <vcpupin vcpu='1' cpuset='3'/>
    <vcpupin vcpu='0' cpuset='0-2'/>
    <emulatorpin cpuset='0-2'/>
</cputune>

and then uses these vcpus in cpu numa config:

<cpu>
    <numa>
        <cell cpus='0' memory='2097152'/>
        <cell cpus='1' memory='2097152'/>
    </numa>
</cpu>

I map numa config this way: /usr/bin/qemu-system-x86_64 -numa node,nodeid=0,cpus=0,mem=2048 -numa node,nodeid=1,cpus=1,mem=2048 but I do not know how to specify vcpu config for /usr/bin/qemu-system-x86_64. That is the problem. Any ideas?

PS My specific task is to run specific vm with vcpu tuning under Kata-containers runtime because I want to run such vm under Docker or Kubernetes. So I need to patch kata-runtime. Kata-runtime runs qemu-kvm vms using Intel GoVmm which can only run qemu binary with command line parameters. At the moment I am patching govmm for my specific needs. Intel govmm does not use libvirt.

Best Answer

These settings are set up using cgroups and not qemu options. You can achieve it using cpuset cgroup subsystem. You can get cgroup settings from running qemu process by running cat /proc/<qemu pid>/cgroups.

See also: http://man7.org/linux/man-pages/man7/cpuset.7.html