Adding element 'id' to virDomainResctrlDef tracking resource group
id, it reflects the attribute 'id' of of element <cachetune> in XML.
virResctrlAlloc.id is a copy from virDomanResctrlDef.id.
Signed-off-by: Wang Huaqiang <huaqiang.wang(a)intel.com>
---
src/conf/domain_conf.c | 20 ++++++++------------
src/conf/domain_conf.h | 1 +
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 01f795f..1aecd8c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2980,6 +2980,7 @@ virDomainResctrlDefFree(virDomainResctrlDefPtr resctrl)
virObjectUnref(resctrl->alloc);
virBitmapFree(resctrl->vcpus);
VIR_FREE(resctrl->monitors);
+ VIR_FREE(resctrl->id);
VIR_FREE(resctrl);
}
@@ -19145,6 +19146,9 @@ virDomainResctrlNew(xmlNodePtr node,
if (VIR_ALLOC(resctrl) < 0)
goto cleanup;
+ if (VIR_STRDUP(resctrl->id, alloc_id) < 0)
+ goto cleanup;
+
if (!(resctrl->vcpus = virBitmapNewCopy(*vcpus))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to copy 'vcpus'"));
@@ -27323,13 +27327,9 @@ virDomainCachetuneDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<cachetune vcpus='%s'", vcpus);
- if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
- const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
- if (!alloc_id)
- goto cleanup;
+ if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
+ virBufferAsprintf(buf, " id='%s'", resctrl->id);
- virBufferAsprintf(buf, " id='%s'", alloc_id);
- }
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
@@ -27386,13 +27386,9 @@ virDomainMemorytuneDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "<memorytune vcpus='%s'", vcpus);
- if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) {
- const char *alloc_id = virResctrlAllocGetID(resctrl->alloc);
- if (!alloc_id)
- goto cleanup;
+ if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
+ virBufferAsprintf(buf, " id='%s'", resctrl->id);
- virBufferAsprintf(buf, " id='%s'", alloc_id);
- }
virBufferAddLit(buf, ">\n");
virBufferAddBuffer(buf, &childrenBuf);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 60f6464..e190aa2 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2248,6 +2248,7 @@ typedef struct _virDomainResctrlDef virDomainResctrlDef;
typedef virDomainResctrlDef *virDomainResctrlDefPtr;
struct _virDomainResctrlDef {
+ char *id;
virBitmapPtr vcpus;
virResctrlAllocPtr alloc;
--
2.7.4