From: Vineeth Pillai <viremana@xxxxxxxxxxxxxxxxxxx> Add domainGetVcpuPinInfo and nodeGetCPUMap callbacks to ch driver Signed-off-by: Vineeth Pillai <viremana@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Praveen K Paladugu <prapal@xxxxxxxxxxxxxxxxxxx> --- src/ch/ch_domain.h | 12 +++++++++-- src/ch/ch_driver.c | 54 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_domain.h b/src/ch/ch_domain.h index d9c9d34a19..e35777a9ec 100644 --- a/src/ch/ch_domain.h +++ b/src/ch/ch_domain.h @@ -23,6 +23,7 @@ #include "ch_conf.h" #include "ch_monitor.h" #include "virchrdev.h" +#include "vircgroup.h" /* Give up waiting for mutex after 30 seconds */ #define CH_JOB_WAIT_TIME (1000ull * 30) @@ -52,9 +53,16 @@ typedef struct _virCHDomainObjPrivate virCHDomainObjPrivate; struct _virCHDomainObjPrivate { struct virCHDomainJobObj job; - virCHMonitor *monitor; + virChrdevs *chrdevs; + + virCgroup *cgroup; - virChrdevs *chrdevs; + virCHDriver *driver; + virCHMonitor *monitor; + char *machineName; + virBitmap *autoNodeset; + virBitmap *autoCpuset; + virChrdevs *devs; }; #define CH_DOMAIN_PRIVATE(vm) \ diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 52c88571af..86d2776354 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -984,7 +984,56 @@ chDomainGetMaxVcpus(virDomainPtr dom) } static int -chDomainHelperGetVcpus(virDomainObj * vm, +chDomainGetVcpuPinInfo(virDomain * dom, + int ncpumaps, + unsigned char *cpumaps, int maplen, unsigned int flags) +{ + virDomainObj *vm = NULL; + virDomainDef *def; + bool live; + int ret = -1; + + g_autoptr(virBitmap) hostcpus = NULL; + virBitmap *autoCpuset = NULL; + + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); + + if (!(vm = chDomObjFromDomain(dom))) + goto cleanup; + + if (virDomainGetVcpuPinInfoEnsureACL(dom->conn, vm->def) < 0) + goto cleanup; + + if (!(def = virDomainObjGetOneDefState(vm, flags, &live))) + goto cleanup; + + if (!(hostcpus = virHostCPUGetAvailableCPUsBitmap())) + goto cleanup; + + if (live) + autoCpuset = CH_DOMAIN_PRIVATE(vm)->autoCpuset; + + ret = virDomainDefGetVcpuPinInfoHelper(def, maplen, ncpumaps, cpumaps, + hostcpus, autoCpuset); + cleanup: + virDomainObjEndAPI(&vm); + return ret; +} + +static int +chNodeGetCPUMap(virConnectPtr conn, + unsigned char **cpumap, + unsigned int *online, unsigned int flags) +{ + if (virNodeGetCPUMapEnsureACL(conn) < 0) + return -1; + + return virHostCPUGetMap(cpumap, online, flags); +} + + +static int +chDomainHelperGetVcpus(virDomainObj *vm, virVcpuInfoPtr info, unsigned long long *cpuwait, int maxinfo, unsigned char *cpumaps, int maplen) @@ -1030,6 +1079,7 @@ chDomainHelperGetVcpus(virDomainObj * vm, if (cpumaps) { unsigned char *cpumap = VIR_GET_CPUMAP(cpumaps, maplen, ncpuinfo); + g_autoptr(virBitmap) map = NULL; if (!(map = virProcessGetAffinity(vcpupid))) @@ -1117,6 +1167,8 @@ static virHypervisorDriver chHypervisorDriver = { .domainGetVcpus = chDomainGetVcpus, /* 7.11.0 */ .domainGetVcpusFlags = chDomainGetVcpusFlags, /* 7.11.0 */ .domainGetMaxVcpus = chDomainGetMaxVcpus, /* 7.11.0 */ + .domainGetVcpuPinInfo = chDomainGetVcpuPinInfo, /* 7.11.0 */ + .nodeGetCPUMap = chNodeGetCPUMap, /* 7.11.0 */ }; static virConnectDriver chConnectDriver = { -- 2.27.0