mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-10-26 17:25:22 +03:00
cli: Have --vcpu cpuset=auto use placement=auto
For many years virt-install has supported a bit of logic that maps --cpuset=auto to a CPU pinning based on host NUMA topology; we look for a NUMA node who's current free memory is closest to the requested memory allocation. This isn't very useful though, since it's a one time allocation, the conditions at VM creation time likely aren't the conditions of the machine in the future. Libvirt has supported a smarter option in vcpu placement=auto for a long while, which will perform a similar operation but at every VM startup. Convert cpuset=auto to use this functionality instead.
This commit is contained in:
parent
492c9c4f28
commit
0d095e22f7
@ -3,7 +3,7 @@
|
||||
<uuid>00000000-1111-2222-3333-444444444444</uuid>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu cpuset="0,1,2,3,4,5,6,7">2</vcpu>
|
||||
<vcpu placement="auto">2</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<boot dev="network"/>
|
||||
@ -43,7 +43,7 @@
|
||||
<uuid>00000000-1111-2222-3333-444444444444</uuid>
|
||||
<memory>65536</memory>
|
||||
<currentMemory>65536</currentMemory>
|
||||
<vcpu cpuset="0,1,2,3,4,5,6,7">2</vcpu>
|
||||
<vcpu placement="auto">2</vcpu>
|
||||
<os>
|
||||
<type arch="i686">hvm</type>
|
||||
<boot dev="network"/>
|
||||
|
@ -530,14 +530,14 @@ c.add_compare(""" \
|
||||
|
||||
c = vinst.add_category("cpuram", "--hvm --nographics --noautoconsole --nodisks --pxe")
|
||||
c.add_valid("--vcpus 4 --cpuset=1,3-5,") # Cpuset with trailing comma
|
||||
c.add_valid("--vcpus 4 --cpuset=auto") # cpuset=auto but caps doesn't support it
|
||||
c.add_valid("--connect %(URI-XEN)s --vcpus 4 --cpuset=auto") # cpuset=auto but xen doesn't support it
|
||||
c.add_valid("--ram 4000000") # Ram overcommit
|
||||
c.add_valid("--vcpus sockets=2,threads=2") # Topology only
|
||||
c.add_valid("--cpu somemodel") # Simple --cpu
|
||||
c.add_valid("--security label=foobar.label,relabel=yes") # --security implicit static
|
||||
c.add_valid("--security label=foobar.label,a1,z2,b3,type=static,relabel=no") # static with commas 1
|
||||
c.add_valid("--security label=foobar.label,a1,z2,b3") # --security static with commas 2
|
||||
c.add_compare("--connect %(URI-TEST-DEFAULT)s --cpuset auto --vcpus 2", "cpuset-auto") # --cpuset=auto actually works
|
||||
c.add_compare("--cpuset auto --vcpus 2", "cpuset-auto") # --cpuset=auto actually works
|
||||
c.add_invalid("--vcpus 32 --cpuset=969-1000") # Bogus cpuset
|
||||
c.add_invalid("--vcpus 32 --cpuset=autofoo") # Bogus cpuset
|
||||
c.add_invalid("--clock foo_tickpolicy=merge") # Unknown timer
|
||||
|
@ -1287,17 +1287,23 @@ class ParserVCPU(VirtCLIParser):
|
||||
setattr(inst, attrname, val)
|
||||
|
||||
def set_cpuset_cb(opts, inst, cliname, val):
|
||||
if val == "auto":
|
||||
try:
|
||||
val = DomainNumatune.generate_cpuset(
|
||||
inst.conn, inst.memory)
|
||||
logging.debug("Auto cpuset is: %s", val)
|
||||
except Exception, e:
|
||||
logging.warning("Not setting cpuset: %s", str(e))
|
||||
val = None
|
||||
|
||||
if val:
|
||||
if not val:
|
||||
return
|
||||
if val != "auto":
|
||||
inst.cpuset = val
|
||||
return
|
||||
|
||||
# Previously we did our own one-time cpuset placement
|
||||
# based on current NUMA memory availability, but that's
|
||||
# pretty dumb unless the conditions on the host never change.
|
||||
# So instead use newer vcpu placement=, but only if it's
|
||||
# supported.
|
||||
if not inst.conn.check_support(
|
||||
inst.conn.SUPPORT_CONN_VCPU_PLACEMENT):
|
||||
logging.warning("vcpu placement=auto not supported, skipping.")
|
||||
return
|
||||
|
||||
inst.vcpu_placement = "auto"
|
||||
|
||||
self.set_param("cpu.sockets", "sockets")
|
||||
self.set_param("cpu.cores", "cores")
|
||||
|
@ -309,6 +309,8 @@ SUPPORT_CONN_DOMAIN_RESET = _make(version="0.9.7", hv_version={"qemu": 0})
|
||||
SUPPORT_CONN_SPICE_COMPRESSION = _make(version="0.9.1")
|
||||
SUPPORT_CONN_VMPORT = _make(
|
||||
version="1.2.16", hv_version={"qemu": "2.2.0", "test": 0})
|
||||
SUPPORT_CONN_VCPU_PLACEMENT = _make(
|
||||
version="0.9.11", hv_version={"qemu": 0, "test": 0})
|
||||
|
||||
# This is for disk <driver name=qemu>. xen supports this, but it's
|
||||
# limited to arbitrary new enough xen, since I know libxl can handle it
|
||||
|
Loading…
Reference in New Issue
Block a user