render / rpms / libvirt

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