[libvirt] [PATCH] fix two bugs in bridge_driver.c

Daniel P. Berrange berrange at redhat.com
Fri Nov 11 10:45:55 UTC 2011


On Fri, Nov 11, 2011 at 04:20:19PM +0800, Hu Tao wrote:
> steps to reproduce:
> 
> 1. having a network xml file(named default.xml) like this one:
> 
> <network>
>   <name>default</name>
>   <uuid>c5322c4c-81d0-4985-a363-ad6389780d89</uuid>
>   <bridge name="virbr0" />
>   <forward/>
>   <ip address="192.168.122.1" netmask="255.255.255.0">
>     <dhcp>
>       <range start="192.168.122.2" end="192.168.122.254" />
>     </dhcp>
>   </ip>
> </network>
> 
> in /etc/libvirt/qemu/networks/, and mark it as autostart:
> 
> $ ls -l /etc/libvirt/qemu/networks/autostart
> total 0
> lrwxrwxrwx 1 root root 14 Oct 12 14:02 default.xml -> ../default.xml
> 
> 2. start libvirtd and the device virbr0 is not automatically up.
> 
> The reason is that the function virNetDevExists is now returns 1 if
> the device exists, comparing to the former one returns 0 if the device
> exists. But with only this fix will cause a segmentation fault(the same
> steps as above)  that is fixed by the second chunk of code.
> ---
>  src/network/bridge_driver.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> index 32cceb0..951b5aa 100644
> --- a/src/network/bridge_driver.c
> +++ b/src/network/bridge_driver.c
> @@ -214,7 +214,7 @@ networkFindActiveConfigs(struct network_driver *driver) {
>  
>          /* If bridge exists, then mark it active */
>          if (obj->def->bridge &&
> -            virNetDevExists(obj->def->bridge) == 0) {
> +            virNetDevExists(obj->def->bridge) == 1) {
>              obj->active = 1;
>  
>              /* Try and read dnsmasq/radvd pids if any */
> @@ -1815,8 +1815,10 @@ networkStartNetworkVirtual(struct network_driver *driver,
>      if (!save_err)
>          save_err = virSaveLastError();
>  
> -    ignore_value(virNetDevTapDelete(macTapIfName));
> -    VIR_FREE(macTapIfName);
> +    if (macTapIfName) {
> +        ignore_value(virNetDevTapDelete(macTapIfName));
> +        VIR_FREE(macTapIfName);
> +    }
>  
>   err0:
>      if (!save_err)

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list