mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
util: Initialize virResctrlInfo struct right away
There is no need to have virResctrlGetInfo() when it must be called after virResctrlInfoNew() anyway, otherwise it's just an unusable object. When we wrap the logic inside the New() function we'll save some calls later as well. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
089c81b0e1
commit
c95b9557b5
@ -1604,7 +1604,7 @@ virCapabilitiesInitResctrl(virCapsPtr caps)
|
||||
if (!caps->host.resctrl)
|
||||
return -1;
|
||||
|
||||
return virResctrlGetInfo(caps->host.resctrl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -2632,7 +2632,6 @@ virResctrlAllocNew;
|
||||
virResctrlAllocRemove;
|
||||
virResctrlAllocSetID;
|
||||
virResctrlAllocSetSize;
|
||||
virResctrlGetInfo;
|
||||
virResctrlInfoGetCache;
|
||||
virResctrlInfoNew;
|
||||
|
||||
|
@ -314,7 +314,7 @@ virResctrlUnlock(int fd)
|
||||
|
||||
|
||||
/* virResctrlInfo-related definitions */
|
||||
int
|
||||
static int
|
||||
virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
||||
{
|
||||
DIR *dirp = NULL;
|
||||
@ -448,10 +448,21 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
||||
virResctrlInfoPtr
|
||||
virResctrlInfoNew(void)
|
||||
{
|
||||
virResctrlInfoPtr ret = NULL;
|
||||
|
||||
if (virResctrlInitialize() < 0)
|
||||
return NULL;
|
||||
|
||||
return virObjectNew(virResctrlInfoClass);
|
||||
ret = virObjectNew(virResctrlInfoClass);
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
if (virResctrlGetInfo(ret) < 0) {
|
||||
virObjectUnref(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,9 +55,6 @@ typedef virResctrlInfo *virResctrlInfoPtr;
|
||||
virResctrlInfoPtr
|
||||
virResctrlInfoNew(void);
|
||||
|
||||
int
|
||||
virResctrlGetInfo(virResctrlInfoPtr resctrl);
|
||||
|
||||
int
|
||||
virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
|
||||
unsigned int level,
|
||||
|
Loading…
Reference in New Issue
Block a user