mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
util: Extract path formatting into virResctrlAllocDeterminePath
We can use this from more places later, so just a future code de-duplication. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
272649a1d7
commit
b9ceacba7c
@ -2560,6 +2560,7 @@ virCacheTypeFromString;
|
||||
virCacheTypeToString;
|
||||
virResctrlAllocAddPID;
|
||||
virResctrlAllocCreate;
|
||||
virResctrlAllocDeterminePath;
|
||||
virResctrlAllocForeachSize;
|
||||
virResctrlAllocFormat;
|
||||
virResctrlAllocGetID;
|
||||
|
@ -1501,6 +1501,25 @@ virResctrlAllocMasksAssign(virResctrlInfoPtr resctrl,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virResctrlAllocDeterminePath(virResctrlAllocPtr alloc,
|
||||
const char *machinename)
|
||||
{
|
||||
if (!alloc->id) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Resctrl Allocation ID must be set before creation"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!alloc->path &&
|
||||
virAsprintf(&alloc->path, "%s/%s-%s",
|
||||
SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* This checks if the directory for the alloc exists. If not it tries to create
|
||||
* it and apply appropriate alloc settings. */
|
||||
int
|
||||
@ -1522,15 +1541,7 @@ virResctrlAllocCreate(virResctrlInfoPtr resctrl,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!alloc->id) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Resctrl Allocation ID must be set before creation"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!alloc->path &&
|
||||
virAsprintf(&alloc->path, "%s/%s-%s",
|
||||
SYSFS_RESCTRL_PATH, machinename, alloc->id) < 0)
|
||||
if (virResctrlAllocDeterminePath(alloc, machinename) < 0)
|
||||
return -1;
|
||||
|
||||
if (virFileExists(alloc->path)) {
|
||||
|
@ -102,6 +102,10 @@ virResctrlAllocGetID(virResctrlAllocPtr alloc);
|
||||
char *
|
||||
virResctrlAllocFormat(virResctrlAllocPtr alloc);
|
||||
|
||||
int
|
||||
virResctrlAllocDeterminePath(virResctrlAllocPtr alloc,
|
||||
const char *machinename);
|
||||
|
||||
int
|
||||
virResctrlAllocCreate(virResctrlInfoPtr r_info,
|
||||
virResctrlAllocPtr alloc,
|
||||
|
Loading…
Reference in New Issue
Block a user