util: Add interface for creating monitor group

Add interface for creating the resource monitoring group according
to '@virResctrlMonitor->path'.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Wang Huaqiang 2018-11-12 21:31:39 +08:00 committed by John Ferlan
parent 4f5bc6cc10
commit 2f22364688
3 changed files with 29 additions and 0 deletions

View File

@ -2682,6 +2682,7 @@ virResctrlInfoGetMonitorPrefix;
virResctrlInfoMonFree; virResctrlInfoMonFree;
virResctrlInfoNew; virResctrlInfoNew;
virResctrlMonitorAddPID; virResctrlMonitorAddPID;
virResctrlMonitorCreate;
virResctrlMonitorDeterminePath; virResctrlMonitorDeterminePath;
virResctrlMonitorNew; virResctrlMonitorNew;

View File

@ -2546,3 +2546,27 @@ virResctrlMonitorAddPID(virResctrlMonitorPtr monitor,
{ {
return virResctrlAddPID(monitor->path, pid); return virResctrlAddPID(monitor->path, pid);
} }
int
virResctrlMonitorCreate(virResctrlMonitorPtr monitor,
const char *machinename)
{
int lockfd = -1;
int ret = -1;
if (!monitor)
return 0;
if (virResctrlMonitorDeterminePath(monitor, machinename) < 0)
return -1;
lockfd = virResctrlLockWrite();
if (lockfd < 0)
return -1;
ret = virResctrlCreateGroupPath(monitor->path);
virResctrlUnlock(lockfd);
return ret;
}

View File

@ -201,4 +201,8 @@ virResctrlMonitorDeterminePath(virResctrlMonitorPtr monitor,
int int
virResctrlMonitorAddPID(virResctrlMonitorPtr monitor, virResctrlMonitorAddPID(virResctrlMonitorPtr monitor,
pid_t pid); pid_t pid);
int
virResctrlMonitorCreate(virResctrlMonitorPtr monitor,
const char *machinename);
#endif /* __VIR_RESCTRL_H__ */ #endif /* __VIR_RESCTRL_H__ */