]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
docs,util: Refactor schemas and virresctrl to support optional cache
authorWang Huaqiang <huaqiang.wang@intel.com>
Mon, 12 Nov 2018 13:31:32 +0000 (21:31 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 14 Nov 2018 17:18:46 +0000 (12:18 -0500)
Refactor schemas and virresctrl to support optional <cache> element
in <cachetune>.

Later, the monitor entry will be introduced and to be placed
under <cachetune>. Either cache entry or monitor entry is
an optional element of <cachetune>.

An cachetune has no <cache> element is taking the default resource
allocating policy defined in '/sys/fs/resctrl/schemata'.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/util/virresctrl.c

index 269741a690c6a0db8f795c4ba69bbcd18e6627e1..8850a71d94c00d081ebfb366763ebf2162ec7794 100644 (file)
         <dl>
           <dt><code>cache</code></dt>
           <dd>
-            This element controls the allocation of CPU cache and has the
-            following attributes:
+            This optional element controls the allocation of CPU cache and has
+            the following attributes:
             <dl>
               <dt><code>level</code></dt>
               <dd>
index b9ac5df47906a563f32f45fddfa90d9d501e3f4e..2b465be01d07a8fe20e61573c16fc0d0a9453a5b 100644 (file)
             <attribute name="vcpus">
               <ref name='cpuset'/>
             </attribute>
-            <oneOrMore>
+            <zeroOrMore>
               <element name="cache">
                 <attribute name="id">
                   <ref name='unsignedInt'/>
                   </attribute>
                 </optional>
               </element>
-            </oneOrMore>
+            </zeroOrMore>
           </element>
         </zeroOrMore>
         <zeroOrMore>
index 5d811a23c8f269b0a348b76eb409d553db47f775..7d9c6974ef2b5d42b063f991b7a10cca30eba532 100644 (file)
@@ -234,6 +234,11 @@ virResctrlInfoMonFree(virResctrlInfoMonPtr mon)
  * in case there is no allocation for that particular cache allocation (level,
  * cache, ...) or memory allocation for particular node).
  *
+ * Allocation corresponding to root directory, /sys/fs/sysctrl/, defines the
+ * default resource allocating policy, which is created immediately after
+ * mounting, and owns all the tasks and cpus in the system. Cache or memory
+ * bandwidth resource will be shared for tasks in this allocation.
+ *
  * =====Cache allocation technology (CAT)=====
  *
  * Since one allocation can be made for caches on different levels, the first
@@ -2215,6 +2220,15 @@ virResctrlAllocDeterminePath(virResctrlAllocPtr alloc,
         return -1;
     }
 
+    /* If the allocation is empty, then the path will be SYSFS_RESCTRL_PATH */
+    if (virResctrlAllocIsEmpty(alloc)) {
+        if (!alloc->path &&
+            VIR_STRDUP(alloc->path, SYSFS_RESCTRL_PATH) < 0)
+            return -1;
+
+        return 0;
+    }
+
     if (!alloc->path &&
         virAsprintf(&alloc->path, "%s/%s-%s",
                     SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
@@ -2248,6 +2262,10 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
     if (virResctrlAllocDeterminePath(alloc, machinename) < 0)
         return -1;
 
+    /* If using the system/default path for the allocation, then we're done */
+    if (STREQ(alloc->path, SYSFS_RESCTRL_PATH))
+        return 0;
+
     if (virFileExists(alloc->path)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Path '%s' for resctrl allocation exists"),
@@ -2302,6 +2320,11 @@ virResctrlAllocAddPID(virResctrlAllocPtr alloc,
     char *pidstr = NULL;
     int ret = 0;
 
+    /* If the allocation is empty, then it is impossible to add a PID to
+     * allocation due to lacking of its 'tasks' file so just return */
+    if (virResctrlAllocIsEmpty(alloc))
+        return 0;
+
     if (!alloc->path) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("Cannot add pid to non-existing resctrl allocation"));
@@ -2337,6 +2360,10 @@ virResctrlAllocRemove(virResctrlAllocPtr alloc)
     if (!alloc->path)
         return 0;
 
+    /* Do not destroy if path is the system/default path for the allocation */
+    if (STREQ(alloc->path, SYSFS_RESCTRL_PATH))
+        return 0;
+
     VIR_DEBUG("Removing resctrl allocation %s", alloc->path);
     if (rmdir(alloc->path) != 0 && errno != ENOENT) {
         ret = -errno;