[libvirt] [PATCH 1/3] libxl: implement virDomainGetVcpuPinInfo
Dario Faggioli
dario.faggioli at citrix.com
Fri Dec 20 14:03:53 UTC 2013
On gio, 2013-12-19 at 21:32 -0700, Jim Fehlig wrote:
> > Signed-off-by: Dario Faggioli <dario.faggioli at citrix.com>
> > Cc: Jim Fehlig <jfehlig at suse.com>
> > Cc: Ian Jackson <Ian.Jackson at eu.citrix.com>
> > ---
> > src/libxl/libxl_driver.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 83 insertions(+)
> > +static int
> > +libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps,
> > + unsigned char *cpumaps, int maplen,
> > + unsigned int flags)
> > +{
> > + libxlDriverPrivatePtr driver = dom->conn->privateData;
> > + libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
> > + virDomainObjPtr vm = NULL;
> > + virDomainDefPtr targetDef = NULL;
> > + virDomainVcpuPinDefPtr *vcpupin_list;
> > + virBitmapPtr cpumask = NULL;
> > + int maxcpu, hostcpus, vcpu, pcpu, n, ret = -1;
> > + unsigned char *cpumap;
> > + bool pinned;
> > +
> > + virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
> > + VIR_DOMAIN_AFFECT_CONFIG, -1);
> > +
> > + if (!(vm = libxlDomObjFromDomain(dom)))
> > + goto cleanup;
> > +
> > + if (virDomainGetVcpuPinInfoEnsureACL(dom->conn, vm->def) < 0)
> > + goto cleanup;
> > +
> > + if (virDomainLiveConfigHelperMethod(cfg->caps, driver->xmlopt, vm,
> > + &flags, &targetDef) < 0)
> > + goto cleanup;
> > +
> > + if (flags & VIR_DOMAIN_AFFECT_LIVE) {
> > + targetDef = vm->def;
> > + }
> > +
> > + sa_assert(targetDef);
> >
>
> I think we should add a comment stating this is needed to silence
> Coverity, similar to the qemu driver.
>
Ok, I'll do.
> > +
> > + /* Clamp to actual number of vcpus */
> > + if (ncpumaps > targetDef->vcpus)
> > + ncpumaps = targetDef->vcpus;
> > +
> > + if (!cpumaps || ncpumaps < 1) {
> > + virReportError(VIR_ERR_INVALID_ARG, "%s",
> > + _("cannot return affinity via a NULL pointer"));
> > + goto cleanup;
> > + }
> >
>
> cpumaps is guaranteed to be non-NULL on entry and ncpumaps is guaranteed
> to be > 0 on entry, so the above check can be removed.
>
Right! I actually did saw that, but then forgot when going down to code
the thing. :-)
I'll get rid of this in v2.
Thanks and Regards,
Dario
--
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131220/61f72d9e/attachment-0001.sig>
More information about the libvir-list
mailing list