mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-28 08:35:22 +00:00
conf: refactor 'virDomainResctrlVcpuMatch' and some code cleanup
Let 'virDomainResctrlVcpuMatch' to retrieve a pointer of virDomainResctrlDefPtr in its third parameter instead of virResctrlAllocPtr, if @vcpus is matched with the vcpus of some resctrl allocation in list of @def->resctrls. Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
4f380977fe
commit
df471f4188
@ -19045,7 +19045,7 @@ virDomainResctrlParseVcpus(virDomainDefPtr def,
|
|||||||
static int
|
static int
|
||||||
virDomainResctrlVcpuMatch(virDomainDefPtr def,
|
virDomainResctrlVcpuMatch(virDomainDefPtr def,
|
||||||
virBitmapPtr vcpus,
|
virBitmapPtr vcpus,
|
||||||
virResctrlAllocPtr *alloc)
|
virDomainResctrlDefPtr *resctrl)
|
||||||
{
|
{
|
||||||
ssize_t i = 0;
|
ssize_t i = 0;
|
||||||
|
|
||||||
@ -19054,7 +19054,7 @@ virDomainResctrlVcpuMatch(virDomainDefPtr def,
|
|||||||
* Just updating memory allocation information of that group
|
* Just updating memory allocation information of that group
|
||||||
*/
|
*/
|
||||||
if (virBitmapEqual(def->resctrls[i]->vcpus, vcpus)) {
|
if (virBitmapEqual(def->resctrls[i]->vcpus, vcpus)) {
|
||||||
*alloc = virObjectRef(def->resctrls[i]->alloc);
|
*resctrl = def->resctrls[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (virBitmapOverlaps(def->resctrls[i]->vcpus, vcpus)) {
|
if (virBitmapOverlaps(def->resctrls[i]->vcpus, vcpus)) {
|
||||||
@ -19385,18 +19385,18 @@ virDomainCachetuneDefParse(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0)
|
if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!alloc) {
|
if (resctrl) {
|
||||||
if (!(alloc = virResctrlAllocNew()))
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||||
_("Identical vcpus in cachetunes found"));
|
_("Identical vcpus in cachetunes found"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(alloc = virResctrlAllocNew()))
|
||||||
|
return -1;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
if (virDomainCachetuneDefParseCache(ctxt, nodes[i], alloc) < 0)
|
if (virDomainCachetuneDefParseCache(ctxt, nodes[i], alloc) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -19571,7 +19571,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
|
|||||||
ssize_t i = 0;
|
ssize_t i = 0;
|
||||||
int n;
|
int n;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool new_alloc = false;
|
|
||||||
|
|
||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
|
|
||||||
@ -19587,13 +19586,14 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainResctrlVcpuMatch(def, vcpus, &alloc) < 0)
|
if (virDomainResctrlVcpuMatch(def, vcpus, &resctrl) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!alloc) {
|
if (resctrl) {
|
||||||
|
alloc = virObjectRef(resctrl->alloc);
|
||||||
|
} else {
|
||||||
if (!(alloc = virResctrlAllocNew()))
|
if (!(alloc = virResctrlAllocNew()))
|
||||||
return -1;
|
return -1;
|
||||||
new_alloc = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
@ -19608,7 +19608,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
|
|||||||
* If this is a new allocation, format ID and append to resctrl, otherwise
|
* If this is a new allocation, format ID and append to resctrl, otherwise
|
||||||
* just update the existing alloc information, which is done in above
|
* just update the existing alloc information, which is done in above
|
||||||
* virDomainMemorytuneDefParseMemory */
|
* virDomainMemorytuneDefParseMemory */
|
||||||
if (new_alloc) {
|
if (!resctrl) {
|
||||||
if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
|
if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user