|
|
6ae9ed |
From 26aacc4c603cd5f6bd3e4712e768db62c855b600 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <26aacc4c603cd5f6bd3e4712e768db62c855b600@dist-git>
|
|
|
6ae9ed |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
6ae9ed |
Date: Wed, 24 Aug 2016 16:10:43 -0400
|
|
|
6ae9ed |
Subject: [PATCH] conf: Extract code formatting vCPU info
|
|
|
6ae9ed |
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1097930
|
|
|
6ae9ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1224341
|
|
|
6ae9ed |
|
|
|
6ae9ed |
(cherry picked from commit 54f875dc53057ddbde063b941d44442102e424e1)
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/conf/domain_conf.c | 45 +++++++++++++++++++++++++++++++--------------
|
|
|
6ae9ed |
1 file changed, 31 insertions(+), 14 deletions(-)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
6ae9ed |
index ffafef3..9571ee3 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_conf.c
|
|
|
6ae9ed |
+++ b/src/conf/domain_conf.c
|
|
|
6ae9ed |
@@ -22885,6 +22885,35 @@ virDomainCputuneDefFormat(virBufferPtr buf,
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+static int
|
|
|
6ae9ed |
+virDomainCpuDefFormat(virBufferPtr buf,
|
|
|
6ae9ed |
+ const virDomainDef *def)
|
|
|
6ae9ed |
+{
|
|
|
6ae9ed |
+ char *cpumask = NULL;
|
|
|
6ae9ed |
+ int ret = -1;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ virBufferAddLit(buf, "
|
|
|
6ae9ed |
+ virBufferAsprintf(buf, " placement='%s'",
|
|
|
6ae9ed |
+ virDomainCpuPlacementModeTypeToString(def->placement_mode));
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ if (def->cpumask && !virBitmapIsAllSet(def->cpumask)) {
|
|
|
6ae9ed |
+ if ((cpumask = virBitmapFormat(def->cpumask)) == NULL)
|
|
|
6ae9ed |
+ goto cleanup;
|
|
|
6ae9ed |
+ virBufferAsprintf(buf, " cpuset='%s'", cpumask);
|
|
|
6ae9ed |
+ }
|
|
|
6ae9ed |
+ if (virDomainDefHasVcpusOffline(def))
|
|
|
6ae9ed |
+ virBufferAsprintf(buf, " current='%u'", virDomainDefGetVcpus(def));
|
|
|
6ae9ed |
+ virBufferAsprintf(buf, ">%u</vcpu>\n", virDomainDefGetVcpusMax(def));
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ ret = 0;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ cleanup:
|
|
|
6ae9ed |
+ VIR_FREE(cpumask);
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+ return ret;
|
|
|
6ae9ed |
+}
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
/* This internal version appends to an existing buffer
|
|
|
6ae9ed |
* (possibly with auto-indent), rather than flattening
|
|
|
6ae9ed |
* to string.
|
|
|
6ae9ed |
@@ -23060,20 +23089,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
|
|
|
6ae9ed |
virBufferAddLit(buf, "</memoryBacking>\n");
|
|
|
6ae9ed |
}
|
|
|
6ae9ed |
|
|
|
6ae9ed |
- virBufferAddLit(buf, "
|
|
|
6ae9ed |
- virBufferAsprintf(buf, " placement='%s'",
|
|
|
6ae9ed |
- virDomainCpuPlacementModeTypeToString(def->placement_mode));
|
|
|
6ae9ed |
-
|
|
|
6ae9ed |
- if (def->cpumask && !virBitmapIsAllSet(def->cpumask)) {
|
|
|
6ae9ed |
- char *cpumask = NULL;
|
|
|
6ae9ed |
- if ((cpumask = virBitmapFormat(def->cpumask)) == NULL)
|
|
|
6ae9ed |
- goto error;
|
|
|
6ae9ed |
- virBufferAsprintf(buf, " cpuset='%s'", cpumask);
|
|
|
6ae9ed |
- VIR_FREE(cpumask);
|
|
|
6ae9ed |
- }
|
|
|
6ae9ed |
- if (virDomainDefHasVcpusOffline(def))
|
|
|
6ae9ed |
- virBufferAsprintf(buf, " current='%u'", virDomainDefGetVcpus(def));
|
|
|
6ae9ed |
- virBufferAsprintf(buf, ">%u</vcpu>\n", virDomainDefGetVcpusMax(def));
|
|
|
6ae9ed |
+ if (virDomainCpuDefFormat(buf, def) < 0)
|
|
|
6ae9ed |
+ goto error;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
if (def->niothreadids > 0) {
|
|
|
6ae9ed |
virBufferAsprintf(buf, "<iothreads>%u</iothreads>\n",
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.10.0
|
|
|
6ae9ed |
|