[libvirt] [PATCH v5] Add functions for handling exponential backoff loops.
Richard W.M. Jones
rjones at redhat.com
Fri Apr 15 16:09:08 UTC 2016
On Fri, Apr 15, 2016 at 04:59:03PM +0200, Peter Krempa wrote:
> On Fri, Apr 15, 2016 at 16:45:07 +0200, Michal Privoznik wrote:
> > On 15.04.2016 13:53, Richard W.M. Jones wrote:
> > > In a few places in libvirt we busy-wait for events, for example qemu
> > > creating a monitor socket. This is problematic because:
> > >
> > > - We need to choose a sufficiently small polling period so that
> > > libvirt doesn't add unnecessary delays.
> > >
> > > - We need to choose a sufficiently large polling period so that
> > > the effect of busy-waiting doesn't affect the system.
> > >
> > > The solution to this conflict is to use an exponential backoff.
> > >
> > > This patch adds two functions to hide the details, and modifies a few
> > > places where we currently busy-wait.
> > > ---
> > > src/fdstream.c | 10 +++---
> > > src/libvirt_private.syms | 2 ++
> > > src/qemu/qemu_agent.c | 9 +++---
> > > src/qemu/qemu_monitor.c | 10 +++---
> > > src/util/virtime.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++
> > > src/util/virtime.h | 11 +++++++
> > > 6 files changed, 111 insertions(+), 12 deletions(-)
> >
> > ACK. Sorry for making you send v5 to such simple patch.
>
> GCC 5.3.0 doesn't like this very much:
>
> qemu/qemu_agent.c:238:8: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> if (ret != 0) {
>
> qemu/qemu_monitor.c:369:8: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> if (ret != 0) {
>
> The static analyzer considers the possibility that the while loop will
> never execute, which would be possible in a very strange lockup of the
> host.
GCC 6 doesn't warn, which doesn't seem right to me, unless GCC is
doing some incredibly clever dataflow analysis.
> Please initialize ret to -1 before pushing in those two functions.
Done, thanks.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
More information about the libvir-list
mailing list