]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Append 'resctrl' object according to number of monitor group directly
authorWang Huaqiang <huaqiang.wang@intel.com>
Tue, 11 Jun 2019 03:31:11 +0000 (11:31 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 5 Aug 2019 17:41:12 +0000 (19:41 +0200)
'virResctrlAllocIsEmpty' checks if cache allocation or memory
bandwidth allocation settings are specified in configuration
file. It is not proper to be used in checking memory bandwidth
allocation is specified in XML settings because this function
could not distinguish memory bandwidth allocations from cache
allocations.

Here using the local variable @n, which indicates the cache
allocation groups or memory bandwidth groups depending on the
context it is in, to decide if append a new @resctrl object.

If @n is zero and no monitors groups specified in XML, then
we should not append a new @resctrl object to @def->resctrls.

This kind of replacement is also more efficient and avoiding
a long function calling path.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index b9ce01cbbb912f96ef72e032aff79c1d64b65d05..d37af9b3bb3ebfc2afc4ce49ab0b27abc3425fc6 100644 (file)
@@ -19412,7 +19412,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
 
     /* If no <cache> element or <monitor> element in <cachetune>, do not
      * append any resctrl element */
-    if (!resctrl->nmonitors && virResctrlAllocIsEmpty(alloc)) {
+    if (!resctrl->nmonitors && n == 0) {
         ret = 0;
         goto cleanup;
     }
@@ -19601,7 +19601,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
             return -1;
     }
 
-    if (virResctrlAllocIsEmpty(alloc))
+    if (n == 0)
         return 0;
 
     /*