[libvirt] [PATCH 4/9] conf: Replace 'virResctrlAllocIsEmpty' with @n==0 for indicating no resctrl allocation in configuration file

Wang Huaqiang huaqiang.wang at intel.com
Thu May 23 09:34:15 UTC 2019


@n denotes the number of <cache> element under <cputune/cachetune>
element in function 'virDomainCachetuneDefParse'  or the number of
<node> element under <cputune/memorytune> element in function
virDomainMemorytuneDefParse'.
Originally it is using 'virResctrlAllocIsEmpty' function to judge
if no resctrl allocation defined in <cputune/cachetune> or
<cputune/memorytune> element, this role could be replaced with
checking if @n is zero or not.

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

Signed-off-by: Wang Huaqiang <huaqiang.wang at 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 9c95467..dcfd2dd 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19360,7 +19360,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;
     }
@@ -19550,7 +19550,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
             return -1;
     }
 
-    if (virResctrlAllocIsEmpty(alloc))
+    if (n == 0)
         return 0;
 
     /*
-- 
2.7.4




More information about the libvir-list mailing list