<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 11/6/2018 3:15 AM, John Ferlan
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:a7ad13f2-8bcf-1586-7b48-05afcd27bb54@redhat.com">
      <pre wrap="">
On 10/22/18 4:01 AM, Wang Huaqiang wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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 <a class="moz-txt-link-rfc2396E" href="mailto:huaqiang.wang@intel.com"><huaqiang.wang@intel.com></a>
---
 src/conf/domain_conf.c | 20 ++++++++------------
 src/conf/domain_conf.h |  1 +
 2 files changed, 9 insertions(+), 12 deletions(-)

</pre>
      </blockquote>
      <pre wrap="">Not sure I see the need to duplicate the alloc->id value especially
since it's "invalid" have "resctrl->alloc == NULL", right?

Can this resctrl->id ever be different?  Not that I can see. I see this
is a desire to reduce an error case in Format processing, but if
virResctrlAllocGetID returned NULL there's other problems...

John</pre>
    </blockquote>
    <br>
    This patch should be removed and will be removed.<br>
    <br>
    It is introduced in series v4, in that series the
    'resctrl->alloc' is allowed<br>
    to be NULL representing a default monitor. <br>
    Now we changed our design and resctrl->alloc is always assigned
    with an<br>
    virResctrlAlloc data structure, then 'resctrl->id' is not
    necessary. We can keep the<br>
    resctrl ID in alloc->id.<br>
    <br>
    Thanks for review.<br>
    Huaqiang<br>
    <br>
    <blockquote type="cite"
      cite="mid:a7ad13f2-8bcf-1586-7b48-05afcd27bb54@redhat.com">
      <pre wrap="">
</pre>
      <blockquote type="cite">
        <pre wrap="">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;
 

</pre>
      </blockquote>
    </blockquote>
    <br>
  </body>
</html>