[libvirt] [PATCH]: Fix allocation of tapfds when starting qemu

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

 



All,
     When doing the conversion to danpb's new memory API, a small bug was
introduced into the qemudNetworkIfaceConnect() function.  In particular, there
is a call:

    if (VIR_ALLOC_N(vm->tapfds, vm->ntapfds+2) < 0)
        goto no_memory;

However, the tapfds structure is used to track *all* of the tap fds, and is
called once for each network that is being attached to the domain.  VIR_ALLOC_N
maps to calloc().  So the first network would work just fine, but if you had
more than one network, subsequent calls to this function would blow away the
stored fd's that were already there and fill them all in with zeros.  This
causes multiple problems, from the qemu domains not starting properly to
improper cleanup on shutdown.  The attached patch just changes the VIR_ALLOC_N()
to a VIR_REALLOC_N(), and everything is happy again.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
Index: src/qemu_conf.c
===================================================================
RCS file: /data/cvs/libvirt/src/qemu_conf.c,v
retrieving revision 1.78
diff -u -r1.78 qemu_conf.c
--- a/src/qemu_conf.c	13 Jun 2008 07:56:59 -0000	1.78
+++ b/src/qemu_conf.c	19 Jun 2008 10:01:53 -0000
@@ -2317,7 +2317,7 @@
     if (!(retval = strdup(tapfdstr)))
         goto no_memory;
 
-    if (VIR_ALLOC_N(vm->tapfds, vm->ntapfds+2) < 0)
+    if (VIR_REALLOC_N(vm->tapfds, vm->ntapfds+2) < 0)
         goto no_memory;
 
     vm->tapfds[vm->ntapfds++] = tapfd;
--
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]