]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: Fix completion logic to guestvcpus command
authorLin Ma <lma@suse.com>
Thu, 22 Apr 2021 10:38:19 +0000 (18:38 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 22 Apr 2021 11:46:48 +0000 (13:46 +0200)
commit093eed7360101a607ba024ccdbe54098322ce0f3
tree1d8fc3d391a8f06d0253a9ceb48d8c340ce9ad13
parent14c36b107d4b14fb4b7bcd9d9c500ecc2dcb97a4
virsh: Fix completion logic to guestvcpus command

In case of non-continuous vCPU topology, We can't infer the bitmap size
from the combination of onlineVcpuStr and nvcpus.
We should use virBitmapParseUnlimited here instead of virBitmapParse due
to the bitmap size is unknown.

e.g.:

  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='2' enabled='yes' hotpluggable='yes' order='3'/>
    <vcpu id='3' enabled='yes' hotpluggable='yes' order='4'/>
    <vcpu id='4' enabled='yes' hotpluggable='yes' order='5'/>
    <vcpu id='5' enabled='yes' hotpluggable='yes' order='6'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

 # virsh guestvcpus --domain VM
vcpus          : 0-5
online         : 0-5
offlinable     : 1-5

 # virsh setvcpu --domain VM --disable --vcpulist 2

 # virsh guestvcpus --domain VM --disable --cpulist 4,5

 # virsh guestvcpus --domain VM
vcpus          : 0-1,3-5
online         : 0-1,3
offlinable     : 1,3-5

Before:
 # virsh guestvcpus --domain VM --enable --cpulist <TAB><TAB>
2  4

After:
 # virsh guestvcpus --domain VM --enable --cpulist <TAB><TAB>
4  5

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-domain.c