On 09/22/2010 03:51 PM, Stanley, Jon [Tech] wrote: > Looking at the python API, once I have a domain object I can call domain.pinVcpu to pin a specific vcpu to a physical CPU. I found http://www.mail-archive.com/libvir-list@xxxxxxxxxx/msg04562.html which mentioned some changes to the C API in the Python implementation, and was wondering if my understanding is correct. > > Say that I have a host system with 16 logical CPU's, 0-15. If I wanted to pin vcpu1 of a domain to CPUs 2 and 4, I would pass: > > domain.pinVcpu(1, (False, False, True, False, True, False....[and so on til I have 16 things])) > > In other words, pinVcpu accepts as arguments the vCPU that I wish to act on, and a 16 (or however many CPU's are present on the host) item tuple of True/False values, in the same order as the CPU's I wish to mask (for example, item 0 of the tuple represents CPU0), True meaning that the vCPU thread is allowed to run there, and False meaning that it is not. > > Just looking to confirm that my understanding of this call is correct. > Yes that's correct, we implement this in virt-manager/virtinst. Here's a function for turning a libvirt cpuset= str into a tuple to pass to pinVcpu: http://hg.fedorahosted.org/hg/python-virtinst/file/f82c5fcb966a/virtinst/Guest.py#l102 which uses http://hg.fedorahosted.org/hg/python-virtinst/file/f82c5fcb966a/virtinst/util.py#l264 - Cole