[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCHv5 2/8] qemu: bulk stats: implement CPU stats group



----- Original Message -----
> From: "Peter Krempa" <pkrempa redhat com>
> To: "Francesco Romani" <fromani redhat com>, libvir-list redhat com
> Sent: Monday, September 15, 2014 2:49:50 PM
> Subject: Re: [libvirt] [PATCHv5 2/8] qemu: bulk stats: implement CPU stats group

> > +static int
> > +qemuDomainGetStatsCpu(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
> > +                      virDomainObjPtr dom,
> > +                      virDomainStatsRecordPtr record,
> > +                      int *maxparams,
> > +                      unsigned int privflags ATTRIBUTE_UNUSED)
> > +{
> > +    qemuDomainObjPrivatePtr priv = dom->privateData;
> > +    unsigned long long cpu_time = 0;
> > +    unsigned long long user_time = 0;
> > +    unsigned long long sys_time = 0;
> > +    int err = 0;
> > +
> > +    err = virCgroupGetCpuacctUsage(priv->cgroup, &cpu_time);
> 
> This code doesn't check if priv->cgroup isn't NULL and dereferences it
> unconditionally. This would crash with shutoff machines.

Ouch. Right, of course. I tested on running VMs actually, and that explains
why I haven't catched it :(
 
> I'll add an
> 	if (priv->group)
> 		return 0;
> 
> right at the beginning.

You mean

   if (!priv->cgroup)
       return 0;

I believe

-- 
Francesco Romani
RedHat Engineering Virtualization R & D
Phone: 8261328
IRC: fromani


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]