提交 4e54c4b2 编写于 作者: W Wang Huaqiang 提交者: John Ferlan

util: Refactor virResctrlAllocSetID to set allocation ID

Refactor virResctrlAllocSetID generating an error if an attempt
is made to overwrite the existing value.
Signed-off-by: NWang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 2f223646
...@@ -1361,17 +1361,32 @@ virResctrlAllocForeachMemory(virResctrlAllocPtr alloc, ...@@ -1361,17 +1361,32 @@ virResctrlAllocForeachMemory(virResctrlAllocPtr alloc,
} }
int static int
virResctrlAllocSetID(virResctrlAllocPtr alloc, virResctrlSetID(char **resctrlid,
const char *id) const char *id)
{ {
if (!id) { if (!id) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Resctrl allocation 'id' cannot be NULL")); _("New resctrl 'id' cannot be NULL"));
return -1;
}
if (*resctrlid) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Attempt to overwrite resctrlid='%s' with id='%s'"),
*resctrlid, id);
return -1; return -1;
} }
return VIR_STRDUP(alloc->id, id); return VIR_STRDUP(*resctrlid, id);
}
int
virResctrlAllocSetID(virResctrlAllocPtr alloc,
const char *id)
{
return virResctrlSetID(&alloc->id, id);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册