Re: [libvirt] [PATCH libvirt] interface: don't error out if a bond has no interfaces

2015-05-27 Thread Laine Stump
On 05/27/2015 01:30 PM, Lubomir Rintel wrote:
> It's not a problem at all and causes virt-manager to break down.
>
> Note: netcf 0.2.8 generates invalid XML for a bond with no interfaces anyway,
> so this error is in fact not reached as we fail earlier. Fix submitted 
> upstream.

ACK.

This patch also makes bonds more consistent with bridges, which also
require the  element, but allow it to be empty.

Since this is a bugfix and straightforward, I'm pushing it now (after
adding a small bit to the commit log, and changing "ret" initialization
from 0 to -1, so that it's more in line with the rest of libvirt's
code), and will be looking at the netcf patch momentarily.

Thanks for taking the time to report this error with a patch :-)

>
> Signed-off-by: Lubomir Rintel 
> ---
>  src/conf/interface_conf.c | 16 ++--
>  1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
> index c2eb945..29769ac 100644
> --- a/src/conf/interface_conf.c
> +++ b/src/conf/interface_conf.c
> @@ -553,19 +553,15 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
>  nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
>  if (nbItf < 0) {
>  ret = -1;
> -goto error;
> +goto cleanup;
>  }
>  
> -if (nbItf == 0) {
> -virReportError(VIR_ERR_XML_ERROR,
> -   "%s", _("bond has no interfaces"));
> -ret = -1;
> -goto error;
> -}
> +if (nbItf == 0)
> +goto cleanup;
>  
>  if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) {
>  ret = -1;
> -goto error;
> +goto cleanup;
>  }
>  def->data.bond.nbItf = nbItf;
>  
> @@ -575,12 +571,12 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
>  if (itf == NULL) {
>  ret = -1;
>  def->data.bond.nbItf = i;
> -goto error;
> +goto cleanup;
>  }
>  def->data.bond.itf[i] = itf;
>  }
>  
> - error:
> + cleanup:
>  VIR_FREE(interfaces);
>  ctxt->node = bond;
>  return ret;

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


[libvirt] [PATCH libvirt] interface: don't error out if a bond has no interfaces

2015-05-27 Thread Lubomir Rintel
It's not a problem at all and causes virt-manager to break down.

Note: netcf 0.2.8 generates invalid XML for a bond with no interfaces anyway,
so this error is in fact not reached as we fail earlier. Fix submitted upstream.

Signed-off-by: Lubomir Rintel 
---
 src/conf/interface_conf.c | 16 ++--
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index c2eb945..29769ac 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -553,19 +553,15 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
 nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
 if (nbItf < 0) {
 ret = -1;
-goto error;
+goto cleanup;
 }
 
-if (nbItf == 0) {
-virReportError(VIR_ERR_XML_ERROR,
-   "%s", _("bond has no interfaces"));
-ret = -1;
-goto error;
-}
+if (nbItf == 0)
+goto cleanup;
 
 if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) {
 ret = -1;
-goto error;
+goto cleanup;
 }
 def->data.bond.nbItf = nbItf;
 
@@ -575,12 +571,12 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
 if (itf == NULL) {
 ret = -1;
 def->data.bond.nbItf = i;
-goto error;
+goto cleanup;
 }
 def->data.bond.itf[i] = itf;
 }
 
- error:
+ cleanup:
 VIR_FREE(interfaces);
 ctxt->node = bond;
 return ret;
-- 
2.4.1

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