Re: [libvirt] [PATCH 3/3] qemu: Explicitly error if guest virtual network is inactive

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

 



On Tue, Feb 16, 2010 at 02:37:02PM -0500, Cole Robinson wrote:
> Currently we just error with ex. 'virbr0: No such device'.
> 
> Since we are using public API calls here, we need to ensure that any
> raised error is properly saved and restored, since API entry points
> always reset messages.
> 
> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
> ---
>  src/qemu/qemu_conf.c |   28 +++++++++++++++++++++++++---
>  1 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index c9fe55b..6c64deb 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -1482,17 +1482,39 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
>      int template_ifname = 0;
>  
>      if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
> +        int active, fail = 0;
> +        virErrorPtr errobj;
>          virNetworkPtr network = virNetworkLookupByName(conn,
> -                                                      net->data.network.name);
> +                                                       net->data.network.name);
>          if (!network)
>              return -1;
>  
> -        brname = virNetworkGetBridgeName(network);
> +        active = virNetworkIsActive(network);
> +        if (active != 1) {
> +            fail = 1;
>  
> +            if (active == 0)
> +                qemuReportError(VIR_ERR_INTERNAL_ERROR,
> +                                _("Network '%s' is not active."),
> +                                net->data.network.name);
> +        }
> +
> +        if (!fail) {
> +            brname = virNetworkGetBridgeName(network);
> +            if (brname == NULL)
> +                fail = 1;
> +        }
> +
> +        /* Make sure any above failure is preserved */
> +        errobj = virSaveLastError();
>          virNetworkFree(network);
> +        virSetError(errobj);
> +        virFreeError(errobj);
>  
> -        if (brname == NULL)
> +        errobj = virSaveLastError();
> +        if (fail)
>              return -1;
> +
>      } else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
>          if (!(brname = strdup(net->data.bridge.brname))) {
>              virReportOOMError();
> -- 

ACK


Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]