|
|
99cbc7 |
From 7551c4a8b453278e7a27a8e7a722851af1f23efc Mon Sep 17 00:00:00 2001
|
|
|
99cbc7 |
Message-Id: <7551c4a8b453278e7a27a8e7a722851af1f23efc@dist-git>
|
|
|
99cbc7 |
From: Bing Niu <bing.niu@intel.com>
|
|
|
99cbc7 |
Date: Mon, 15 Apr 2019 17:32:57 +0200
|
|
|
99cbc7 |
Subject: [PATCH] conf: Factor out virDomainResctrlDef update from
|
|
|
99cbc7 |
virDomainCachetuneDefParse
|
|
|
99cbc7 |
MIME-Version: 1.0
|
|
|
99cbc7 |
Content-Type: text/plain; charset=UTF-8
|
|
|
99cbc7 |
Content-Transfer-Encoding: 8bit
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Factor out vcpus virDomainResctrlDef update from
|
|
|
99cbc7 |
virDomainCachetuneDefParse and introduce virDomainResctrlAppend.
|
|
|
99cbc7 |
virDomainResctrlAppend will format vcpus string and append a new
|
|
|
99cbc7 |
virDomainResctrlDef to virDomainDefPtr. So that this logic can
|
|
|
99cbc7 |
be reusable.
|
|
|
99cbc7 |
|
|
|
99cbc7 |
Signed-off-by: Bing Niu <bing.niu@intel.com>
|
|
|
99cbc7 |
Reviewed-by: John Ferlan <jferlan@redhat.com>
|
|
|
99cbc7 |
(cherry picked from commit 72824f67cdb9c474034539e81fb03fb1bc94495f)
|
|
|
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: <b3da60a6b3ca4eea6712bbbdfba03b6037e41239.1555342313.git.phrdina@redhat.com>
|
|
|
99cbc7 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
99cbc7 |
---
|
|
|
99cbc7 |
src/conf/domain_conf.c | 93 +++++++++++++++++++++++++-----------------
|
|
|
99cbc7 |
1 file changed, 55 insertions(+), 38 deletions(-)
|
|
|
99cbc7 |
|
|
|
99cbc7 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
99cbc7 |
index fb5adbcd10..44bfd75b72 100644
|
|
|
99cbc7 |
--- a/src/conf/domain_conf.c
|
|
|
99cbc7 |
+++ b/src/conf/domain_conf.c
|
|
|
99cbc7 |
@@ -19176,6 +19176,58 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr ctxt,
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
|
|
|
99cbc7 |
+static int
|
|
|
99cbc7 |
+virDomainResctrlAppend(virDomainDefPtr def,
|
|
|
99cbc7 |
+ xmlNodePtr node,
|
|
|
99cbc7 |
+ virResctrlAllocPtr alloc,
|
|
|
99cbc7 |
+ virBitmapPtr vcpus,
|
|
|
99cbc7 |
+ unsigned int flags)
|
|
|
99cbc7 |
+{
|
|
|
99cbc7 |
+ char *vcpus_str = NULL;
|
|
|
99cbc7 |
+ char *alloc_id = NULL;
|
|
|
99cbc7 |
+ virDomainResctrlDefPtr tmp_resctrl = NULL;
|
|
|
99cbc7 |
+ int ret = -1;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (VIR_ALLOC(tmp_resctrl) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ /* We need to format it back because we need to be consistent in the naming
|
|
|
99cbc7 |
+ * even when users specify some "sub-optimal" string there. */
|
|
|
99cbc7 |
+ vcpus_str = virBitmapFormat(vcpus);
|
|
|
99cbc7 |
+ if (!vcpus_str)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
|
|
99cbc7 |
+ alloc_id = virXMLPropString(node, "id");
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (!alloc_id) {
|
|
|
99cbc7 |
+ /* The number of allocations is limited and the directory structure is flat,
|
|
|
99cbc7 |
+ * not hierarchical, so we need to have all same allocations in one
|
|
|
99cbc7 |
+ * directory, so it's nice to have it named appropriately. For now it's
|
|
|
99cbc7 |
+ * 'vcpus_...' but it's designed in order for it to be changeable in the
|
|
|
99cbc7 |
+ * future (it's part of the status XML). */
|
|
|
99cbc7 |
+ if (virAsprintf(&alloc_id, "vcpus_%s", vcpus_str) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+ }
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (virResctrlAllocSetID(alloc, alloc_id) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ tmp_resctrl->vcpus = vcpus;
|
|
|
99cbc7 |
+ tmp_resctrl->alloc = alloc;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, tmp_resctrl) < 0)
|
|
|
99cbc7 |
+ goto cleanup;
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+ ret = 0;
|
|
|
99cbc7 |
+ cleanup:
|
|
|
99cbc7 |
+ virDomainResctrlDefFree(tmp_resctrl);
|
|
|
99cbc7 |
+ VIR_FREE(alloc_id);
|
|
|
99cbc7 |
+ VIR_FREE(vcpus_str);
|
|
|
99cbc7 |
+ return ret;
|
|
|
99cbc7 |
+}
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
+
|
|
|
99cbc7 |
static int
|
|
|
99cbc7 |
virDomainCachetuneDefParse(virDomainDefPtr def,
|
|
|
99cbc7 |
xmlXPathContextPtr ctxt,
|
|
|
99cbc7 |
@@ -19186,19 +19238,12 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
|
|
|
99cbc7 |
xmlNodePtr *nodes = NULL;
|
|
|
99cbc7 |
virBitmapPtr vcpus = NULL;
|
|
|
99cbc7 |
virResctrlAllocPtr alloc = NULL;
|
|
|
99cbc7 |
- virDomainResctrlDefPtr tmp_resctrl = NULL;
|
|
|
99cbc7 |
- char *tmp = NULL;
|
|
|
99cbc7 |
- char *vcpus_str = NULL;
|
|
|
99cbc7 |
- char *alloc_id = NULL;
|
|
|
99cbc7 |
ssize_t i = 0;
|
|
|
99cbc7 |
int n;
|
|
|
99cbc7 |
int ret = -1;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
ctxt->node = node;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
- if (VIR_ALLOC(tmp_resctrl) < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
if (virDomainResctrlParseVcpus(def, node, &vcpus) < 0)
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
@@ -19236,45 +19281,17 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
- /* We need to format it back because we need to be consistent in the naming
|
|
|
99cbc7 |
- * even when users specify some "sub-optimal" string there. */
|
|
|
99cbc7 |
- VIR_FREE(vcpus_str);
|
|
|
99cbc7 |
- vcpus_str = virBitmapFormat(vcpus);
|
|
|
99cbc7 |
- if (!vcpus_str)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE))
|
|
|
99cbc7 |
- alloc_id = virXMLPropString(node, "id");
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (!alloc_id) {
|
|
|
99cbc7 |
- /* The number of allocations is limited and the directory structure is flat,
|
|
|
99cbc7 |
- * not hierarchical, so we need to have all same allocations in one
|
|
|
99cbc7 |
- * directory, so it's nice to have it named appropriately. For now it's
|
|
|
99cbc7 |
- * 'vcpus_...' but it's designed in order for it to be changeable in the
|
|
|
99cbc7 |
- * future (it's part of the status XML). */
|
|
|
99cbc7 |
- if (virAsprintf(&alloc_id, "vcpus_%s", vcpus_str) < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
- }
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (virResctrlAllocSetID(alloc, alloc_id) < 0)
|
|
|
99cbc7 |
- goto cleanup;
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- VIR_STEAL_PTR(tmp_resctrl->vcpus, vcpus);
|
|
|
99cbc7 |
- VIR_STEAL_PTR(tmp_resctrl->alloc, alloc);
|
|
|
99cbc7 |
-
|
|
|
99cbc7 |
- if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, tmp_resctrl) < 0)
|
|
|
99cbc7 |
+ if (virDomainResctrlAppend(def, node, alloc, vcpus, flags) < 0)
|
|
|
99cbc7 |
goto cleanup;
|
|
|
99cbc7 |
+ vcpus = NULL;
|
|
|
99cbc7 |
+ alloc = NULL;
|
|
|
99cbc7 |
|
|
|
99cbc7 |
ret = 0;
|
|
|
99cbc7 |
cleanup:
|
|
|
99cbc7 |
ctxt->node = oldnode;
|
|
|
99cbc7 |
- virDomainResctrlDefFree(tmp_resctrl);
|
|
|
99cbc7 |
virObjectUnref(alloc);
|
|
|
99cbc7 |
virBitmapFree(vcpus);
|
|
|
99cbc7 |
- VIR_FREE(alloc_id);
|
|
|
99cbc7 |
- VIR_FREE(vcpus_str);
|
|
|
99cbc7 |
VIR_FREE(nodes);
|
|
|
99cbc7 |
- VIR_FREE(tmp);
|
|
|
99cbc7 |
return ret;
|
|
|
99cbc7 |
}
|
|
|
99cbc7 |
|
|
|
99cbc7 |
--
|
|
|
99cbc7 |
2.21.0
|
|
|
99cbc7 |
|