Bug 1386513

Summary: Using emulatorpin sets machine.slice/cpuset.cpus incorrectly
Product: [Community] Virtualization Tools Reporter: rokupstys
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: NEW --- QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: libvirt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description rokupstys 2016-10-19 07:11:31 UTC
Description of problem:

/sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus on machine.slice creation is always set to cores that emulator is pinned to via <emulatorpin>. This results in following error on VM startup: Unable to write to '/sys/fs/cgroup/cpuset/machine.slice/machine-qemu\x2d2\x2dwin.scope/vcpu0/cpuset.cpus': Permission denied


Compiled against library: libvirt 2.3.0
Using library: libvirt 2.3.0
Using API: QEMU 2.3.0
Running hypervisor: QEMU 2.7.0


Always reproducible.


Steps to Reproduce:
1. Create VM with cpu setup:
  <vcpu placement='static'>4</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='2'/>
    <vcpupin vcpu='1' cpuset='3'/>
    <vcpupin vcpu='2' cpuset='4'/>
    <vcpupin vcpu='3' cpuset='5'/>
    <emulatorpin cpuset='0-1'/>
  </cputune>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='4' threads='1'/>
  </cpu>
2. Start VM via virsh or virt-manager.

Actual results:
Error: Unable to write to '/sys/fs/cgroup/cpuset/machine.slice/machine-qemu\x2d2\x2dwin.scope/vcpu0/cpuset.cpus': Permission denied
~ % cat /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus
0-1

Expected results:
No error, VM should start.
~ % cat /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus
0-5

Additional info:
As a workaround i added following line to /etc/libvirt/hooks/qemu script:
echo 0-5 > /sys/fs/cgroup/cpuset/machine.slice/cpuset.cpus

With this workaround VM always fails starting the first time but starts properly the second time.