[libvirt] [PATCH 34/34] qemu: cgroup: Don't use priv->ncpupids to iterate domain vCPUs
Peter Krempa
pkrempa at redhat.com
Tue Nov 24 13:57:26 UTC 2015
On Tue, Nov 24, 2015 at 08:41:53 -0500, John Ferlan wrote:
>
>
> On 11/20/2015 10:22 AM, Peter Krempa wrote:
> > Use the proper data structures for the iteration since ncpupids will be
> > made private later.
> > ---
> > src/qemu/qemu_cgroup.c | 14 ++++++++++++--
> > 1 file changed, 12 insertions(+), 2 deletions(-)
> >
> > diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> > index d8a2b03..06c20c1 100644
> > --- a/src/qemu/qemu_cgroup.c
> > +++ b/src/qemu/qemu_cgroup.c
> > @@ -800,7 +800,12 @@ qemuRestoreCgroupState(virDomainObjPtr vm)
> > if (virCgroupSetCpusetMems(priv->cgroup, mem_mask) < 0)
> > goto error;
> >
> > - for (i = 0; i < priv->nvcpupids; i++) {
> > + for (i = 0; i < virDomainDefGetVCpusMax(vm->def); i++) {
> > + virDomainVCpuInfoPtr vcpu = virDomainDefGetVCpu(vm->def, i);
> > +
>
> What if !vcpu? Shouldn't happen, but not checked - trying to consider
> future too.
Actually it really can't and should not ever happen. The setters will
always allocate the array fully so iterating to virDomainDefGetVCpusMax
should always be valid.
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20151124/7cc1ba3e/attachment-0001.sig>
More information about the libvir-list
mailing list