On Mon, Nov 02, 2009 at 03:02:47PM -0500, Cole Robinson wrote: > > Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx> > --- > src/test/test_driver.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 58 insertions(+), 1 deletions(-) > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c > index 5b871aa..6ea4aa9 100644 > --- a/src/test/test_driver.c > +++ b/src/test/test_driver.c > @@ -2093,6 +2093,63 @@ cleanup: > return ret; > } > > +static int testDomainPinVcpu(virDomainPtr domain, > + unsigned int vcpu, > + unsigned char *cpumap, > + int maplen) > +{ > + testConnPtr privconn = domain->conn->privateData; > + testDomainObjPrivatePtr privdomdata; > + virDomainObjPtr privdom; > + unsigned char *privcpumap; > + int i, maxcpu, hostcpus, privmaplen; > + int ret = -1; > + > + testDriverLock(privconn); > + privdom = virDomainFindByName(&privconn->domains, domain->name); > + testDriverUnlock(privconn); > + > + if (privdom == NULL) { > + testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__); > + goto cleanup; > + } > + > + if (!virDomainIsActive(privdom)) { > + testError(domain->conn, VIR_ERR_OPERATION_INVALID, > + "%s",_("cannot pin vcpus on an inactive domain")); > + goto cleanup; > + } > + > + if (vcpu > privdom->def->vcpus) { > + testError(domain->conn, VIR_ERR_INVALID_ARG, "%s", > + _("requested vcpu is higher than allocated vcpus")); > + goto cleanup; > + } > + > + privdomdata = privdom->privateData; > + hostcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo); > + privmaplen = VIR_CPU_MAPLEN(hostcpus); > + > + maxcpu = maplen * 8; > + if (maxcpu > hostcpus) > + maxcpu = hostcpus; > + > + privcpumap = VIR_GET_CPUMAP(privdomdata->cpumaps, privmaplen, vcpu); > + memset(privcpumap, 0, privmaplen); > + > + for (i = 0 ; i < maxcpu ; i++) { > + if (VIR_CPU_USABLE(cpumap, maplen, 0, i)) { > + VIR_USE_CPU(privcpumap, i); > + } > + } > + > + ret = 0; > +cleanup: > + if (privdom) > + virDomainObjUnlock(privdom); > + return ret; > +} > + > static char *testDomainDumpXML(virDomainPtr domain, int flags) > { > testConnPtr privconn = domain->conn->privateData; > @@ -4947,7 +5004,7 @@ static virDriver testDriver = { > testDomainRestore, /* domainRestore */ > testDomainCoreDump, /* domainCoreDump */ > testSetVcpus, /* domainSetVcpus */ > - NULL, /* domainPinVcpu */ > + testDomainPinVcpu, /* domainPinVcpu */ > testDomainGetVcpus, /* domainGetVcpus */ > testDomainGetMaxVcpus, /* domainGetMaxVcpus */ > NULL, /* domainGetSecurityLabel */ > -- ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list