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

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

 



----- Original Message -----
> From: "Peter Krempa" <pkrempa@xxxxxxxxxx>
> To: "Francesco Romani" <fromani@xxxxxxxxxx>, libvir-list@xxxxxxxxxx
> Sent: Monday, September 15, 2014 2:49:50 PM
> Subject: Re:  [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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]