Fix the $SUBJ "s/geting/getting" On 09/04/2014 03:52 AM, Wang Rui wrote: > From: Yue Wenyuan <yuewenyuan@xxxxxxxxxx> > > Implement the lxc driver method for virDomainGetEmulatorPinInfo > to get container's cpuset. > > Signed-off-by: Wang Rui <moon.wangrui@xxxxxxxxxx> > Signed-off-by: Yue Wenyuan <yuewenyuan@xxxxxxxxxx> > --- > src/lxc/lxc_driver.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 75 insertions(+) > > diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c > index 9e3a877..6694cf3 100644 > --- a/src/lxc/lxc_driver.c > +++ b/src/lxc/lxc_driver.c > @@ -1395,6 +1395,80 @@ lxcDomainPinEmulator(virDomainPtr dom, > return ret; > } > Since the following is essentially a copy of the qemu function with the only changes being "LXC" for "QEMU" or "lxc" for "qemu" - it seems that it should be possible to create some sort of common vir/util function especially for all the lines between [1] and [2] below. Of course that's probably true in other areas, but since I was comparing here I guess it > +static int > +lxcDomainGetEmulatorPinInfo(virDomainPtr dom, > + unsigned char *cpumaps, > + int maplen, > + unsigned int flags) > +{ > + virLXCDriverPtr driver = dom->conn->privateData; > + virDomainObjPtr vm = NULL; > + virDomainDefPtr targetDef = NULL; > + int ret = -1; > + int maxcpu, hostcpus, pcpu; > + virBitmapPtr cpumask = NULL; > + bool pinned; > + virCapsPtr caps = NULL; > + > + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | > + VIR_DOMAIN_AFFECT_CONFIG, -1); > + > + if (!(vm = lxcDomObjFromDomain(dom))) > + goto cleanup; > + > + if (virDomainGetEmulatorPinInfoEnsureACL(dom->conn, vm->def) < 0) > + goto cleanup; > + > + if (!(caps = virLXCDriverGetCapabilities(driver, false))) > + goto cleanup; > + > + if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, > + vm, &flags, &targetDef) < 0) > + goto cleanup; > + [1] > + if (flags & VIR_DOMAIN_AFFECT_LIVE) > + targetDef = vm->def; > + > + sa_assert(targetDef); > + > + if ((hostcpus = nodeGetCPUCount()) < 0) > + goto cleanup; > + > + maxcpu = maplen * 8; > + if (maxcpu > hostcpus) > + maxcpu = hostcpus; > + > + /* initialize cpumaps */ > + memset(cpumaps, 0xff, maplen); > + if (maxcpu % 8) { > + cpumaps[maplen - 1] &= (1 << maxcpu % 8) - 1; > + } > + > + if (targetDef->cputune.emulatorpin) { > + cpumask = targetDef->cputune.emulatorpin->cpumask; > + } else if (targetDef->cpumask) { > + cpumask = targetDef->cpumask; > + } else { > + ret = 0; > + goto cleanup; > + } > + > + for (pcpu = 0; pcpu < maxcpu; pcpu++) { > + if (virBitmapGetBit(cpumask, pcpu, &pinned) < 0) > + goto cleanup; > + if (!pinned) > + VIR_UNUSE_CPU(cpumaps, pcpu); > + } [2] > + > + ret = 1; > + > + cleanup: > + if (vm) > + virObjectUnlock(vm); > + virObjectUnref(caps); > + return ret; > +} > + > static int lxcDomainGetSecurityLabel(virDomainPtr dom, virSecurityLabelPtr seclabel) > { > virLXCDriverPtr driver = dom->conn->privateData; > @@ -5831,6 +5905,7 @@ static virDriver lxcDriver = { > .domainCreateXML = lxcDomainCreateXML, /* 0.4.4 */ > .domainCreateXMLWithFiles = lxcDomainCreateXMLWithFiles, /* 1.1.1 */ > .domainPinEmulator = lxcDomainPinEmulator, /*1.2.9*/ > + .domainGetEmulatorPinInfo = lxcDomainGetEmulatorPinInfo, /*1.2.9*/ Comment spacing is off, will now be at least /* 1.2.10 */ John > .domainLookupByID = lxcDomainLookupByID, /* 0.4.2 */ > .domainLookupByUUID = lxcDomainLookupByUUID, /* 0.4.2 */ > .domainLookupByName = lxcDomainLookupByName, /* 0.4.2 */ > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list