render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From 8e87a5625a571d05177c6766405db814b6e8e7b3 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <8e87a5625a571d05177c6766405db814b6e8e7b3@dist-git>
99cbc7
From: Bing Niu <bing.niu@intel.com>
99cbc7
Date: Mon, 15 Apr 2019 17:32:54 +0200
99cbc7
Subject: [PATCH] conf: Rename cachetune to resctrl
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
Resctrl not only supports cache tuning, but also memory bandwidth
99cbc7
tuning. Renaming cachetune to resctrl to reflect that. With resctrl,
99cbc7
all allocation for different resources (cache, memory bandwidth) are
99cbc7
aggregated and represented by a virResctrlAllocPtr inside
99cbc7
virDomainResctrlDef.
99cbc7
99cbc7
Signed-off-by: Bing Niu <bing.niu@intel.com>
99cbc7
Reviewed-by: John Ferlan <jferlan@redhat.com>
99cbc7
(cherry picked from commit acc288d655237a22a95c5a1ae7207916fb9efac9)
99cbc7
99cbc7
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1468650
99cbc7
99cbc7
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
99cbc7
Message-Id: <9ee9c0993a62ddf084968b211ca82c9e6b62ef0d.1555342313.git.phrdina@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/conf/domain_conf.c  | 44 ++++++++++++++++++++---------------------
99cbc7
 src/conf/domain_conf.h  | 10 +++++-----
99cbc7
 src/qemu/qemu_domain.c  |  2 +-
99cbc7
 src/qemu/qemu_process.c | 18 ++++++++---------
99cbc7
 4 files changed, 37 insertions(+), 37 deletions(-)
99cbc7
99cbc7
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
99cbc7
index e04edd97dc..0c8afe78c6 100644
99cbc7
--- a/src/conf/domain_conf.c
99cbc7
+++ b/src/conf/domain_conf.c
99cbc7
@@ -2966,14 +2966,14 @@ virDomainLoaderDefFree(virDomainLoaderDefPtr loader)
99cbc7
 
99cbc7
 
99cbc7
 static void
99cbc7
-virDomainCachetuneDefFree(virDomainCachetuneDefPtr cachetune)
99cbc7
+virDomainResctrlDefFree(virDomainResctrlDefPtr resctrl)
99cbc7
 {
99cbc7
-    if (!cachetune)
99cbc7
+    if (!resctrl)
99cbc7
         return;
99cbc7
 
99cbc7
-    virObjectUnref(cachetune->alloc);
99cbc7
-    virBitmapFree(cachetune->vcpus);
99cbc7
-    VIR_FREE(cachetune);
99cbc7
+    virObjectUnref(resctrl->alloc);
99cbc7
+    virBitmapFree(resctrl->vcpus);
99cbc7
+    VIR_FREE(resctrl);
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
@@ -3163,9 +3163,9 @@ void virDomainDefFree(virDomainDefPtr def)
99cbc7
         virDomainShmemDefFree(def->shmems[i]);
99cbc7
     VIR_FREE(def->shmems);
99cbc7
 
99cbc7
-    for (i = 0; i < def->ncachetunes; i++)
99cbc7
-        virDomainCachetuneDefFree(def->cachetunes[i]);
99cbc7
-    VIR_FREE(def->cachetunes);
99cbc7
+    for (i = 0; i < def->nresctrls; i++)
99cbc7
+        virDomainResctrlDefFree(def->resctrls[i]);
99cbc7
+    VIR_FREE(def->resctrls);
99cbc7
 
99cbc7
     VIR_FREE(def->keywrap);
99cbc7
 
99cbc7
@@ -19129,7 +19129,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
99cbc7
     xmlNodePtr *nodes = NULL;
99cbc7
     virBitmapPtr vcpus = NULL;
99cbc7
     virResctrlAllocPtr alloc = virResctrlAllocNew();
99cbc7
-    virDomainCachetuneDefPtr tmp_cachetune = NULL;
99cbc7
+    virDomainResctrlDefPtr tmp_resctrl = NULL;
99cbc7
     char *tmp = NULL;
99cbc7
     char *vcpus_str = NULL;
99cbc7
     char *alloc_id = NULL;
99cbc7
@@ -19142,7 +19142,7 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
99cbc7
     if (!alloc)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    if (VIR_ALLOC(tmp_cachetune) < 0)
99cbc7
+    if (VIR_ALLOC(tmp_resctrl) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     vcpus_str = virXMLPropString(node, "vcpus");
99cbc7
@@ -19183,8 +19183,8 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
99cbc7
         goto cleanup;
99cbc7
     }
99cbc7
 
99cbc7
-    for (i = 0; i < def->ncachetunes; i++) {
99cbc7
-        if (virBitmapOverlaps(def->cachetunes[i]->vcpus, vcpus)) {
99cbc7
+    for (i = 0; i < def->nresctrls; i++) {
99cbc7
+        if (virBitmapOverlaps(def->resctrls[i]->vcpus, vcpus)) {
99cbc7
             virReportError(VIR_ERR_XML_ERROR, "%s",
99cbc7
                            _("Overlapping vcpus in cachetunes"));
99cbc7
             goto cleanup;
99cbc7
@@ -19214,16 +19214,16 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
99cbc7
     if (virResctrlAllocSetID(alloc, alloc_id) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
-    VIR_STEAL_PTR(tmp_cachetune->vcpus, vcpus);
99cbc7
-    VIR_STEAL_PTR(tmp_cachetune->alloc, alloc);
99cbc7
+    VIR_STEAL_PTR(tmp_resctrl->vcpus, vcpus);
99cbc7
+    VIR_STEAL_PTR(tmp_resctrl->alloc, alloc);
99cbc7
 
99cbc7
-    if (VIR_APPEND_ELEMENT(def->cachetunes, def->ncachetunes, tmp_cachetune) < 0)
99cbc7
+    if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, tmp_resctrl) < 0)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     ret = 0;
99cbc7
  cleanup:
99cbc7
     ctxt->node = oldnode;
99cbc7
-    virDomainCachetuneDefFree(tmp_cachetune);
99cbc7
+    virDomainResctrlDefFree(tmp_resctrl);
99cbc7
     virObjectUnref(alloc);
99cbc7
     virBitmapFree(vcpus);
99cbc7
     VIR_FREE(alloc_id);
99cbc7
@@ -27053,7 +27053,7 @@ virDomainCachetuneDefFormatHelper(unsigned int level,
99cbc7
 
99cbc7
 static int
99cbc7
 virDomainCachetuneDefFormat(virBufferPtr buf,
99cbc7
-                            virDomainCachetuneDefPtr cachetune,
99cbc7
+                            virDomainResctrlDefPtr resctrl,
99cbc7
                             unsigned int flags)
99cbc7
 {
99cbc7
     virBuffer childrenBuf = VIR_BUFFER_INITIALIZER;
99cbc7
@@ -27061,7 +27061,7 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
99cbc7
     int ret = -1;
99cbc7
 
99cbc7
     virBufferSetChildIndent(&childrenBuf, buf);
99cbc7
-    virResctrlAllocForeachCache(cachetune->alloc,
99cbc7
+    virResctrlAllocForeachCache(resctrl->alloc,
99cbc7
                                 virDomainCachetuneDefFormatHelper,
99cbc7
                                 &childrenBuf);
99cbc7
 
99cbc7
@@ -27074,14 +27074,14 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
99cbc7
         goto cleanup;
99cbc7
     }
99cbc7
 
99cbc7
-    vcpus = virBitmapFormat(cachetune->vcpus);
99cbc7
+    vcpus = virBitmapFormat(resctrl->vcpus);
99cbc7
     if (!vcpus)
99cbc7
         goto cleanup;
99cbc7
 
99cbc7
     virBufferAsprintf(buf, "
99cbc7
 
99cbc7
     if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
99cbc7
-        const char *alloc_id = virResctrlAllocGetID(cachetune->alloc);
99cbc7
+        const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
99cbc7
         if (!alloc_id)
99cbc7
             goto cleanup;
99cbc7
 
99cbc7
@@ -27202,8 +27202,8 @@ virDomainCputuneDefFormat(virBufferPtr buf,
99cbc7
                                  def->iothreadids[i]->iothread_id);
99cbc7
     }
99cbc7
 
99cbc7
-    for (i = 0; i < def->ncachetunes; i++)
99cbc7
-        virDomainCachetuneDefFormat(&childrenBuf, def->cachetunes[i], flags);
99cbc7
+    for (i = 0; i < def->nresctrls; i++)
99cbc7
+        virDomainCachetuneDefFormat(&childrenBuf, def->resctrls[i], flags);
99cbc7
 
99cbc7
     if (virBufferCheckError(&childrenBuf) < 0)
99cbc7
         return -1;
99cbc7
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
99cbc7
index 390bd81aa0..65abe9cde6 100644
99cbc7
--- a/src/conf/domain_conf.h
99cbc7
+++ b/src/conf/domain_conf.h
99cbc7
@@ -2232,10 +2232,10 @@ struct _virDomainCputune {
99cbc7
 };
99cbc7
 
99cbc7
 
99cbc7
-typedef struct _virDomainCachetuneDef virDomainCachetuneDef;
99cbc7
-typedef virDomainCachetuneDef *virDomainCachetuneDefPtr;
99cbc7
+typedef struct _virDomainResctrlDef virDomainResctrlDef;
99cbc7
+typedef virDomainResctrlDef *virDomainResctrlDefPtr;
99cbc7
 
99cbc7
-struct _virDomainCachetuneDef {
99cbc7
+struct _virDomainResctrlDef {
99cbc7
     virBitmapPtr vcpus;
99cbc7
     virResctrlAllocPtr alloc;
99cbc7
 };
99cbc7
@@ -2413,8 +2413,8 @@ struct _virDomainDef {
99cbc7
 
99cbc7
     virDomainCputune cputune;
99cbc7
 
99cbc7
-    virDomainCachetuneDefPtr *cachetunes;
99cbc7
-    size_t ncachetunes;
99cbc7
+    virDomainResctrlDefPtr *resctrls;
99cbc7
+    size_t nresctrls;
99cbc7
 
99cbc7
     virDomainNumaPtr numa;
99cbc7
     virDomainResourceDefPtr resource;
99cbc7
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
99cbc7
index d80f9b393e..112958f64a 100644
99cbc7
--- a/src/qemu/qemu_domain.c
99cbc7
+++ b/src/qemu/qemu_domain.c
99cbc7
@@ -3999,7 +3999,7 @@ qemuDomainDefValidate(const virDomainDef *def,
99cbc7
         }
99cbc7
     }
99cbc7
 
99cbc7
-    if (def->ncachetunes &&
99cbc7
+    if (def->nresctrls &&
99cbc7
         def->virtType != VIR_DOMAIN_VIRT_KVM) {
99cbc7
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
99cbc7
                        _("cachetune is only supported for KVM domains"));
99cbc7
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
99cbc7
index 208c64381c..a44f371346 100644
99cbc7
--- a/src/qemu/qemu_process.c
99cbc7
+++ b/src/qemu/qemu_process.c
99cbc7
@@ -2584,7 +2584,7 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
99cbc7
     virCapsPtr caps = NULL;
99cbc7
     qemuDomainObjPrivatePtr priv = vm->privateData;
99cbc7
 
99cbc7
-    if (!vm->def->ncachetunes)
99cbc7
+    if (!vm->def->nresctrls)
99cbc7
         return 0;
99cbc7
 
99cbc7
     /* Force capability refresh since resctrl info can change
99cbc7
@@ -2593,9 +2593,9 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
99cbc7
     if (!caps)
99cbc7
         return -1;
99cbc7
 
99cbc7
-    for (i = 0; i < vm->def->ncachetunes; i++) {
99cbc7
+    for (i = 0; i < vm->def->nresctrls; i++) {
99cbc7
         if (virResctrlAllocCreate(caps->host.resctrl,
99cbc7
-                                  vm->def->cachetunes[i]->alloc,
99cbc7
+                                  vm->def->resctrls[i]->alloc,
99cbc7
                                   priv->machineName) < 0)
99cbc7
             goto cleanup;
99cbc7
     }
99cbc7
@@ -5411,8 +5411,8 @@ qemuProcessSetupVcpu(virDomainObjPtr vm,
99cbc7
                             &vcpu->sched) < 0)
99cbc7
         return -1;
99cbc7
 
99cbc7
-    for (i = 0; i < vm->def->ncachetunes; i++) {
99cbc7
-        virDomainCachetuneDefPtr ct = vm->def->cachetunes[i];
99cbc7
+    for (i = 0; i < vm->def->nresctrls; i++) {
99cbc7
+        virDomainResctrlDefPtr ct = vm->def->resctrls[i];
99cbc7
 
99cbc7
         if (virBitmapIsBitSet(ct->vcpus, vcpuid)) {
99cbc7
             if (virResctrlAllocAddPID(ct->alloc, vcpupid) < 0)
99cbc7
@@ -7108,8 +7108,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
99cbc7
     /* Remove resctrl allocation after cgroups are cleaned up which makes it
99cbc7
      * kind of safer (although removing the allocation should work even with
99cbc7
      * pids in tasks file */
99cbc7
-    for (i = 0; i < vm->def->ncachetunes; i++)
99cbc7
-        virResctrlAllocRemove(vm->def->cachetunes[i]->alloc);
99cbc7
+    for (i = 0; i < vm->def->nresctrls; i++)
99cbc7
+        virResctrlAllocRemove(vm->def->resctrls[i]->alloc);
99cbc7
 
99cbc7
     qemuProcessRemoveDomainStatus(driver, vm);
99cbc7
 
99cbc7
@@ -7835,8 +7835,8 @@ qemuProcessReconnect(void *opaque)
99cbc7
     if (qemuConnectAgent(driver, obj) < 0)
99cbc7
         goto error;
99cbc7
 
99cbc7
-    for (i = 0; i < obj->def->ncachetunes; i++) {
99cbc7
-        if (virResctrlAllocDeterminePath(obj->def->cachetunes[i]->alloc,
99cbc7
+    for (i = 0; i < obj->def->nresctrls; i++) {
99cbc7
+        if (virResctrlAllocDeterminePath(obj->def->resctrls[i]->alloc,
99cbc7
                                          priv->machineName) < 0)
99cbc7
             goto error;
99cbc7
     }
99cbc7
-- 
99cbc7
2.21.0
99cbc7