[libvirt] [PATCHv2 06/11] conf: Append 'resctrl' object according to number of monitor group directly

Wang Huaqiang posted 11 patches 23 weeks ago

[libvirt] [PATCHv2 06/11] conf: Append 'resctrl' object according to number of monitor group directly

Posted by Wang Huaqiang 23 weeks ago
'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

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>
 src/conf/domain_conf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ca2dba9..676a2ac 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19359,7 +19359,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;
@@ -19548,7 +19548,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
             return -1;
-    if (virResctrlAllocIsEmpty(alloc))
+    if (n == 0)
         return 0;

libvir-list mailing list