mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-05 19:29:33 +00:00
interface: don't error out if a bond has no interfaces
It's not a problem at all and causes virt-manager to break down. Note: netcf 0.2.8 and earlier generates invalid XML for a bond with no interfaces anyway, so in that case this error in libvirt is never reached since we fail earlier. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk> (cherry picked from commit efc68de5cd70d62b1941a707d22299422f1962f9)
This commit is contained in:
parent
361f5244ca
commit
cc2add9681
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* interface_conf.c: interfaces XML handling
|
* interface_conf.c: interfaces XML handling
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2010, 2013, 2014 Red Hat, Inc.
|
* Copyright (C) 2006-2010, 2013-2015 Red Hat, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -548,39 +548,34 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
|
|||||||
virInterfaceDefPtr itf;
|
virInterfaceDefPtr itf;
|
||||||
int nbItf;
|
int nbItf;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = 0;
|
int ret = -1;
|
||||||
|
|
||||||
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
|
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
|
||||||
if (nbItf < 0) {
|
if (nbItf < 0)
|
||||||
ret = -1;
|
goto cleanup;
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nbItf == 0) {
|
if (nbItf == 0) {
|
||||||
virReportError(VIR_ERR_XML_ERROR,
|
ret = 0;
|
||||||
"%s", _("bond has no interfaces"));
|
goto cleanup;
|
||||||
ret = -1;
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) {
|
if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0)
|
||||||
ret = -1;
|
goto cleanup;
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
def->data.bond.nbItf = nbItf;
|
def->data.bond.nbItf = nbItf;
|
||||||
|
|
||||||
for (i = 0; i < nbItf; i++) {
|
for (i = 0; i < nbItf; i++) {
|
||||||
ctxt->node = interfaces[i];
|
ctxt->node = interfaces[i];
|
||||||
itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BOND);
|
itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BOND);
|
||||||
if (itf == NULL) {
|
if (itf == NULL) {
|
||||||
ret = -1;
|
|
||||||
def->data.bond.nbItf = i;
|
def->data.bond.nbItf = i;
|
||||||
goto error;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
def->data.bond.itf[i] = itf;
|
def->data.bond.itf[i] = itf;
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
VIR_FREE(interfaces);
|
VIR_FREE(interfaces);
|
||||||
ctxt->node = bond;
|
ctxt->node = bond;
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user