Re: [PATCH] virtinst: Add NUMA distance support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've attached an updated patch that applies to master. Has the updated
cli format, drops the validation stuff, and the man page bits too since
I intended that to just be an example of the numbered cellX selection
stuff, hopefully people can figure out sibling format based on that and
'--cpu help' output

The new format is very wordy but I'd rather start here and come up with
an additive shortcut method if we think it's necessary. The new format
is like;

cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10,\

If you are fine with this patch I'll push it. Otherwise feel free to
change and resubmit

Thanks,
Cole
>From c9071e00eb0bb0f95e5ab867daecb88a6ecf6ddb Mon Sep 17 00:00:00 2001
Message-Id: <c9071e00eb0bb0f95e5ab867daecb88a6ecf6ddb.1516995333.git.crobinso@xxxxxxxxxx>
From: Menno Lageman <menno.lageman@xxxxxxxxxx>
Date: Mon, 22 Jan 2018 13:36:00 +0100
Subject: [PATCH virt-manager] virtinst: Add NUMA distance support

Now that libvirt has support for administration of distances between NUMA cells
it would be nice to be able to set those with virt-install directly instead of
having to 'virsh edit' the domain XML manually after installation.

NUMA distances can be specified when configuring NUMA cells by adding one or
more <cell:distance> pairs for each NUMA cell, defining the distance from
the cell to itself and to the other NUMA cells.

For example

--cpu cell0.memory=1234,cell0.cpus=0-3,cell1.memory=5678,cell1.cpus=4-7,\
      cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
      cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
      cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
      cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10

would generate the following XML:

     <cpu>
       <numa>
         <cell cpus="0-3" memory="1234">
           <distances>
             <sibling id="0" value="10"/>
             <sibling id="1" value="21"/>
           </distances>
         </cell>
         <cell cpus="4-7" memory="5678">
           <distances>
             <sibling id="0" value="21"/>
             <sibling id="1" value="10"/>
           </distances>
         </cell>
       </numa>
     </cpu>

Signed-off-by: Menno Lageman <menno.lageman@xxxxxxxxxx>

(crobinso: rework cli format, drop some validation, drop man changes)

Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
---
 .../compare/virt-install-singleton-config-2.xml    | 28 ++++++++++++++++++----
 tests/clitest.py                                   |  9 ++++++-
 virtinst/cli.py                                    | 14 +++++++++++
 virtinst/cpu.py                                    | 17 +++++++++++++
 4 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
index c2c641e4..3b9210f5 100644
--- a/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
+++ b/tests/cli-test-xml/compare/virt-install-singleton-config-2.xml
@@ -92,8 +92,18 @@
     <feature policy="forbid" name="foo"/>
     <feature policy="forbid" name="bar"/>
     <numa>
-      <cell id="0" cpus="1,2,3" memory="1024"/>
-      <cell id="1" cpus="5-8" memory="256"/>
+      <cell id="0" cpus="1,2,3" memory="1024">
+        <distances>
+          <sibling id="0" value="10"/>
+          <sibling id="1" value="21"/>
+        </distances>
+      </cell>
+      <cell id="1" cpus="5-8" memory="256">
+        <distances>
+          <sibling id="0" value="21"/>
+          <sibling id="1" value="10"/>
+        </distances>
+      </cell>
     </numa>
     <cache mode="emulate" level="3"/>
   </cpu>
@@ -247,8 +257,18 @@
     <feature policy="forbid" name="foo"/>
     <feature policy="forbid" name="bar"/>
     <numa>
-      <cell id="0" cpus="1,2,3" memory="1024"/>
-      <cell id="1" cpus="5-8" memory="256"/>
+      <cell id="0" cpus="1,2,3" memory="1024">
+        <distances>
+          <sibling id="0" value="10"/>
+          <sibling id="1" value="21"/>
+        </distances>
+      </cell>
+      <cell id="1" cpus="5-8" memory="256">
+        <distances>
+          <sibling id="0" value="21"/>
+          <sibling id="1" value="10"/>
+        </distances>
+      </cell>
     </numa>
     <cache mode="emulate" level="3"/>
   </cpu>
diff --git a/tests/clitest.py b/tests/clitest.py
index 94b6cbb4..a7d38b6d 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -422,7 +422,14 @@ c.add_compare(""" \
 c.add_compare("""--pxe \
 --memory 512,maxmemory=1024 \
 --vcpus 4,cores=2,threads=2,sockets=2 \
---cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,disable=distest2,optional=opttest,require=reqtest,match=strict,vendor=meee,cell.id=0,cell.cpus=1,2,3,cell.memory=1024,cell1.id=1,cell1.memory=256,cell1.cpus=5-8,cache.mode=emulate,cache.level=3 \
+--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,disable=distest2,optional=opttest,require=reqtest,match=strict,vendor=meee,\
+cell.id=0,cell.cpus=1,2,3,cell.memory=1024,\
+cell1.id=1,cell1.memory=256,cell1.cpus=5-8,\
+cell0.distances.sibling0.id=0,cell0.distances.sibling0.value=10,\
+cell0.distances.sibling1.id=1,cell0.distances.sibling1.value=21,\
+cell1.distances.sibling0.id=0,cell1.distances.sibling0.value=21,\
+cell1.distances.sibling1.id=1,cell1.distances.sibling1.value=10,\
+cache.mode=emulate,cache.level=3 \
 --metadata title=my-title,description=my-description,uuid=00000000-1111-2222-3333-444444444444 \
 --boot cdrom,fd,hd,network,menu=off,loader=/foo/bar \
 --idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10 \
diff --git a/virtinst/cli.py b/virtinst/cli.py
index ba74d6bc..09b59f5a 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1464,6 +1464,16 @@ class ParserCPU(VirtCLIParser):
         cb = self._make_find_inst_cb(cliarg, objpropname, objaddfn)
         return cb(*args, **kwargs)
 
+    def sibling_find_inst_cb(self, inst, *args, **kwargs):
+        cell = self.cell_find_inst_cb(inst, *args, **kwargs)
+        inst = cell
+
+        cliarg = "sibling"  # cell[0-9]*.distances.sibling[0-9]*
+        objpropname = "siblings"  # cell.siblings
+        objaddfn = "add_sibling"  # cell.add_sibling
+        cb = self._make_find_inst_cb(cliarg, objpropname, objaddfn)
+        return cb(inst, *args, **kwargs)
+
     def set_model_cb(self, inst, val, virtarg):
         if val == "host":
             val = inst.SPECIAL_MODE_HOST_MODEL
@@ -1542,6 +1552,10 @@ ParserCPU.add_arg("cpus", "cell[0-9]*.cpus", can_comma=True,
                   find_inst_cb=ParserCPU.cell_find_inst_cb)
 ParserCPU.add_arg("memory", "cell[0-9]*.memory",
                   find_inst_cb=ParserCPU.cell_find_inst_cb)
+ParserCPU.add_arg("id", "cell[0-9]*.distances.sibling[0-9]*.id",
+                  find_inst_cb=ParserCPU.sibling_find_inst_cb)
+ParserCPU.add_arg("value", "cell[0-9]*.distances.sibling[0-9]*.value",
+                  find_inst_cb=ParserCPU.sibling_find_inst_cb)
 
 # Options for CPU.cache
 ParserCPU.add_arg("mode", "cache.mode", find_inst_cb=ParserCPU.set_l3_cache_cb)
diff --git a/virtinst/cpu.py b/virtinst/cpu.py
index 3925106c..9a7d5b58 100644
--- a/virtinst/cpu.py
+++ b/virtinst/cpu.py
@@ -20,6 +20,17 @@
 from .xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty
 
 
+class _CPUCellSibling(XMLBuilder):
+    """
+    Class for generating <distances> <sibling> nodes
+    """
+    _XML_ROOT_NAME = "sibling"
+    _XML_PROP_ORDER = ["id", "value"]
+
+    id = XMLProperty("./@id", is_int=True)
+    value = XMLProperty("./@value", is_int=True)
+
+
 class _CPUCell(XMLBuilder):
     """
     Class for generating <cpu><numa> child <cell> XML
@@ -30,6 +41,12 @@ class _CPUCell(XMLBuilder):
     id = XMLProperty("./@id", is_int=True)
     cpus = XMLProperty("./@cpus")
     memory = XMLProperty("./@memory", is_int=True)
+    siblings = XMLChildProperty(_CPUCellSibling, relative_xpath="./distances")
+
+    def add_sibling(self):
+        obj = _CPUCellSibling(self.conn)
+        self.add_child(obj)
+        return obj
 
 
 class CPUCache(XMLBuilder):
-- 
2.14.3

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux