mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Remove virConnectPtr from interface XML APIs
The virConnectPtr is no longer required for error reporting since that is recorded in a thread local. Remove use of virConnectPtr from all APIs in interface_conf.{h,c} and update all callers to match
This commit is contained in:
parent
f430ddb624
commit
a70e599d80
@ -40,15 +40,14 @@ VIR_ENUM_IMPL(virInterface,
|
|||||||
"ethernet", "bridge", "bond", "vlan" )
|
"ethernet", "bridge", "bond", "vlan" )
|
||||||
|
|
||||||
static virInterfaceDefPtr
|
static virInterfaceDefPtr
|
||||||
virInterfaceDefParseXML(virConnectPtr conn,
|
virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType);
|
||||||
xmlXPathContextPtr ctxt, int parentIfType);
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefDevFormat(virConnectPtr conn, virBufferPtr buf,
|
virInterfaceDefDevFormat(virBufferPtr buf,
|
||||||
const virInterfaceDefPtr def, int level);
|
const virInterfaceDefPtr def, int level);
|
||||||
|
|
||||||
#define virInterfaceReportError(conn, code, fmt...) \
|
#define virInterfaceReportError(code, fmt...) \
|
||||||
virReportErrorHelper(conn, VIR_FROM_INTERFACE, code, __FILE__, \
|
virReportErrorHelper(NULL, VIR_FROM_INTERFACE, code, __FILE__, \
|
||||||
__FUNCTION__, __LINE__, fmt)
|
__FUNCTION__, __LINE__, fmt)
|
||||||
|
|
||||||
static
|
static
|
||||||
void virInterfaceIpDefFree(virInterfaceIpDefPtr def) {
|
void virInterfaceIpDefFree(virInterfaceIpDefPtr def) {
|
||||||
@ -118,14 +117,14 @@ void virInterfaceDefFree(virInterfaceDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseName(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseName(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
tmp = virXPathString("string(./@name)", ctxt);
|
tmp = virXPathString("string(./@name)", ctxt);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("interface has no name"));
|
"%s", _("interface has no name"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
def->name = tmp;
|
def->name = tmp;
|
||||||
@ -133,14 +132,14 @@ virInterfaceDefParseName(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseMtu(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseMtu(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
unsigned long mtu;
|
unsigned long mtu;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu);
|
ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu);
|
||||||
if ((ret == -2) || ((ret == 0) && (mtu > 100000))) {
|
if ((ret == -2) || ((ret == 0) && (mtu > 100000))) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("interface mtu value is improper"));
|
"%s", _("interface mtu value is improper"));
|
||||||
return(-1);
|
return(-1);
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
@ -150,7 +149,7 @@ virInterfaceDefParseMtu(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseStartMode(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseStartMode(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
@ -164,7 +163,7 @@ virInterfaceDefParseStartMode(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
else if (STREQ(tmp, "none"))
|
else if (STREQ(tmp, "none"))
|
||||||
def->startmode = VIR_INTERFACE_START_NONE;
|
def->startmode = VIR_INTERFACE_START_NONE;
|
||||||
else {
|
else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unknown interface startmode %s"), tmp);
|
_("unknown interface startmode %s"), tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
return(-1);
|
return(-1);
|
||||||
@ -174,7 +173,7 @@ virInterfaceDefParseStartMode(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseBondMode(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -196,7 +195,7 @@ virInterfaceDefParseBondMode(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
|||||||
else if (STREQ(tmp, "balance-alb"))
|
else if (STREQ(tmp, "balance-alb"))
|
||||||
ret = VIR_INTERFACE_BOND_BALALB;
|
ret = VIR_INTERFACE_BOND_BALALB;
|
||||||
else {
|
else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unknown bonding mode %s"), tmp);
|
_("unknown bonding mode %s"), tmp);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -205,7 +204,7 @@ virInterfaceDefParseBondMode(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseBondMiiCarrier(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -217,7 +216,7 @@ virInterfaceDefParseBondMiiCarrier(virConnectPtr conn, xmlXPathContextPtr ctxt)
|
|||||||
else if (STREQ(tmp, "netif"))
|
else if (STREQ(tmp, "netif"))
|
||||||
ret = VIR_INTERFACE_BOND_MII_NETIF;
|
ret = VIR_INTERFACE_BOND_MII_NETIF;
|
||||||
else {
|
else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unknown mii bonding carrier %s"), tmp);
|
_("unknown mii bonding carrier %s"), tmp);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -226,7 +225,7 @@ virInterfaceDefParseBondMiiCarrier(virConnectPtr conn, xmlXPathContextPtr ctxt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) {
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -240,7 +239,7 @@ virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
|||||||
else if (STREQ(tmp, "all"))
|
else if (STREQ(tmp, "all"))
|
||||||
ret = VIR_INTERFACE_BOND_ARP_ALL;
|
ret = VIR_INTERFACE_BOND_ARP_ALL;
|
||||||
else {
|
else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unknown arp bonding validate %s"), tmp);
|
_("unknown arp bonding validate %s"), tmp);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -249,7 +248,7 @@ virInterfaceDefParseBondArpValid(virConnectPtr conn, xmlXPathContextPtr ctxt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceProtocolDefPtr def,
|
virInterfaceDefParseDhcp(virInterfaceProtocolDefPtr def,
|
||||||
xmlNodePtr dhcp, xmlXPathContextPtr ctxt) {
|
xmlNodePtr dhcp, xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr save;
|
xmlNodePtr save;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@ -266,7 +265,7 @@ virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceProtocolDefPtr def,
|
|||||||
else if (STREQ(tmp, "no"))
|
else if (STREQ(tmp, "no"))
|
||||||
def->peerdns = 0;
|
def->peerdns = 0;
|
||||||
else {
|
else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unknown dhcp peerdns value %s"), tmp);
|
_("unknown dhcp peerdns value %s"), tmp);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -279,7 +278,7 @@ virInterfaceDefParseDhcp(virConnectPtr conn, virInterfaceProtocolDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseIp(virConnectPtr conn, virInterfaceIpDefPtr def,
|
virInterfaceDefParseIp(virInterfaceIpDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@ -292,7 +291,7 @@ virInterfaceDefParseIp(virConnectPtr conn, virInterfaceIpDefPtr def,
|
|||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
def->prefix = (int) l;
|
def->prefix = (int) l;
|
||||||
else if (ret == -2) {
|
else if (ret == -2) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("Invalid ip address prefix value"));
|
"%s", _("Invalid ip address prefix value"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -302,7 +301,7 @@ virInterfaceDefParseIp(virConnectPtr conn, virInterfaceIpDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def,
|
virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr dhcp;
|
xmlNodePtr dhcp;
|
||||||
xmlNodePtr *ipNodes = NULL;
|
xmlNodePtr *ipNodes = NULL;
|
||||||
@ -314,7 +313,7 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def
|
|||||||
|
|
||||||
dhcp = virXPathNode("./dhcp", ctxt);
|
dhcp = virXPathNode("./dhcp", ctxt);
|
||||||
if (dhcp != NULL) {
|
if (dhcp != NULL) {
|
||||||
ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt);
|
ret = virInterfaceDefParseDhcp(def, dhcp, ctxt);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@ -341,7 +340,7 @@ virInterfaceDefParseProtoIPv4(virConnectPtr conn, virInterfaceProtocolDefPtr def
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = ipNodes[ii];
|
ctxt->node = ipNodes[ii];
|
||||||
ret = virInterfaceDefParseIp(conn, ip, ctxt);
|
ret = virInterfaceDefParseIp(ip, ctxt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
virInterfaceIpDefFree(ip);
|
virInterfaceIpDefFree(ip);
|
||||||
goto error;
|
goto error;
|
||||||
@ -357,7 +356,7 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def,
|
virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr dhcp, autoconf;
|
xmlNodePtr dhcp, autoconf;
|
||||||
xmlNodePtr *ipNodes = NULL;
|
xmlNodePtr *ipNodes = NULL;
|
||||||
@ -373,7 +372,7 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def
|
|||||||
|
|
||||||
dhcp = virXPathNode("./dhcp", ctxt);
|
dhcp = virXPathNode("./dhcp", ctxt);
|
||||||
if (dhcp != NULL) {
|
if (dhcp != NULL) {
|
||||||
ret = virInterfaceDefParseDhcp(conn, def, dhcp, ctxt);
|
ret = virInterfaceDefParseDhcp(def, dhcp, ctxt);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
@ -400,7 +399,7 @@ virInterfaceDefParseProtoIPv6(virConnectPtr conn, virInterfaceProtocolDefPtr def
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = ipNodes[ii];
|
ctxt->node = ipNodes[ii];
|
||||||
ret = virInterfaceDefParseIp(conn, ip, ctxt);
|
ret = virInterfaceDefParseIp(ip, ctxt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
virInterfaceIpDefFree(ip);
|
virInterfaceIpDefFree(ip);
|
||||||
goto error;
|
goto error;
|
||||||
@ -416,7 +415,7 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseIfAdressing(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr save;
|
xmlNodePtr save;
|
||||||
xmlNodePtr *protoNodes = NULL;
|
xmlNodePtr *protoNodes = NULL;
|
||||||
@ -449,26 +448,26 @@ virInterfaceDefParseIfAdressing(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
ctxt->node = protoNodes[pp];
|
ctxt->node = protoNodes[pp];
|
||||||
tmp = virXPathString("string(./@family)", ctxt);
|
tmp = virXPathString("string(./@family)", ctxt);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("protocol misses the family attribute"));
|
"%s", _("protocol misses the family attribute"));
|
||||||
virInterfaceProtocolDefFree(proto);
|
virInterfaceProtocolDefFree(proto);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
proto->family = tmp;
|
proto->family = tmp;
|
||||||
if (STREQ(tmp, "ipv4")) {
|
if (STREQ(tmp, "ipv4")) {
|
||||||
ret = virInterfaceDefParseProtoIPv4(conn, proto, ctxt);
|
ret = virInterfaceDefParseProtoIPv4(proto, ctxt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
virInterfaceProtocolDefFree(proto);
|
virInterfaceProtocolDefFree(proto);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else if (STREQ(tmp, "ipv6")) {
|
} else if (STREQ(tmp, "ipv6")) {
|
||||||
ret = virInterfaceDefParseProtoIPv6(conn, proto, ctxt);
|
ret = virInterfaceDefParseProtoIPv6(proto, ctxt);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
virInterfaceProtocolDefFree(proto);
|
virInterfaceProtocolDefFree(proto);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unsupported protocol family '%s'"), tmp);
|
_("unsupported protocol family '%s'"), tmp);
|
||||||
virInterfaceProtocolDefFree(proto);
|
virInterfaceProtocolDefFree(proto);
|
||||||
goto error;
|
goto error;
|
||||||
@ -486,7 +485,7 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseBridge(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr *interfaces = NULL;
|
xmlNodePtr *interfaces = NULL;
|
||||||
xmlNodePtr bridge;
|
xmlNodePtr bridge;
|
||||||
@ -497,7 +496,7 @@ virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
bridge = ctxt->node;
|
bridge = ctxt->node;
|
||||||
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
|
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
|
||||||
if (nbItf < 0) {
|
if (nbItf < 0) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bridge interfaces"));
|
"%s", _("bridge interfaces"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
@ -512,7 +511,7 @@ virInterfaceDefParseBridge(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
for (i = 0; i < nbItf;i++) {
|
for (i = 0; i < nbItf;i++) {
|
||||||
ctxt->node = interfaces[i];
|
ctxt->node = interfaces[i];
|
||||||
itf = virInterfaceDefParseXML(conn, ctxt, VIR_INTERFACE_TYPE_BRIDGE);
|
itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BRIDGE);
|
||||||
if (itf == NULL) {
|
if (itf == NULL) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
def->data.bridge.nbItf = i;
|
def->data.bridge.nbItf = i;
|
||||||
@ -529,7 +528,7 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseBondItfs(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseBondItfs(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr *interfaces = NULL;
|
xmlNodePtr *interfaces = NULL;
|
||||||
xmlNodePtr bond = ctxt->node;
|
xmlNodePtr bond = ctxt->node;
|
||||||
@ -539,7 +538,7 @@ virInterfaceDefParseBondItfs(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
|
nbItf = virXPathNodeSet("./interface", ctxt, &interfaces);
|
||||||
if (nbItf <= 0) {
|
if (nbItf <= 0) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond has no interfaces"));
|
"%s", _("bond has no interfaces"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
@ -553,7 +552,7 @@ virInterfaceDefParseBondItfs(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
for (i = 0; i < nbItf;i++) {
|
for (i = 0; i < nbItf;i++) {
|
||||||
ctxt->node = interfaces[i];
|
ctxt->node = interfaces[i];
|
||||||
itf = virInterfaceDefParseXML(conn, ctxt, VIR_INTERFACE_TYPE_BOND);
|
itf = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BOND);
|
||||||
if (itf == NULL) {
|
if (itf == NULL) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
def->data.bond.nbItf = i;
|
def->data.bond.nbItf = i;
|
||||||
@ -569,17 +568,17 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseBond(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
|
|
||||||
def->data.bond.mode = virInterfaceDefParseBondMode(conn, ctxt);
|
def->data.bond.mode = virInterfaceDefParseBondMode(ctxt);
|
||||||
if (def->data.bond.mode < 0)
|
if (def->data.bond.mode < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ret = virInterfaceDefParseBondItfs(conn, def, ctxt);
|
ret = virInterfaceDefParseBondItfs(def, ctxt);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -589,7 +588,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp);
|
ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp);
|
||||||
if ((ret == -2) || (ret == -1)) {
|
if ((ret == -2) || (ret == -1)) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond interface miimon freq missing or invalid"));
|
"%s", _("bond interface miimon freq missing or invalid"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -597,7 +596,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp);
|
ret = virXPathULong("string(./miimon/@downdelay)", ctxt, &tmp);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond interface miimon downdelay invalid"));
|
"%s", _("bond interface miimon downdelay invalid"));
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
@ -606,14 +605,14 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp);
|
ret = virXPathULong("string(./miimon/@updelay)", ctxt, &tmp);
|
||||||
if (ret == -2) {
|
if (ret == -2) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond interface miimon updelay invalid"));
|
"%s", _("bond interface miimon updelay invalid"));
|
||||||
goto error;
|
goto error;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
def->data.bond.updelay = (int) tmp;
|
def->data.bond.updelay = (int) tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->data.bond.carrier = virInterfaceDefParseBondMiiCarrier(conn, ctxt);
|
def->data.bond.carrier = virInterfaceDefParseBondMiiCarrier(ctxt);
|
||||||
if (def->data.bond.carrier < 0) {
|
if (def->data.bond.carrier < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
@ -625,7 +624,7 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
|
|
||||||
ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp);
|
ret = virXPathULong("string(./arpmon/@interval)", ctxt, &tmp);
|
||||||
if ((ret == -2) || (ret == -1)) {
|
if ((ret == -2) || (ret == -1)) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond interface arpmon interval missing or invalid"));
|
"%s", _("bond interface arpmon interval missing or invalid"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -634,13 +633,13 @@ virInterfaceDefParseBond(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
def->data.bond.target =
|
def->data.bond.target =
|
||||||
virXPathString("string(./arpmon/@target)", ctxt);
|
virXPathString("string(./arpmon/@target)", ctxt);
|
||||||
if (def->data.bond.target == NULL) {
|
if (def->data.bond.target == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond interface arpmon target missing"));
|
"%s", _("bond interface arpmon target missing"));
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
def->data.bond.validate = virInterfaceDefParseBondArpValid(conn, ctxt);
|
def->data.bond.validate = virInterfaceDefParseBondArpValid(ctxt);
|
||||||
if (def->data.bond.validate < 0) {
|
if (def->data.bond.validate < 0) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
@ -651,11 +650,11 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def,
|
virInterfaceDefParseVlan(virInterfaceDefPtr def,
|
||||||
xmlXPathContextPtr ctxt) {
|
xmlXPathContextPtr ctxt) {
|
||||||
def->data.vlan.tag = virXPathString("string(./@tag)", ctxt);
|
def->data.vlan.tag = virXPathString("string(./@tag)", ctxt);
|
||||||
if (def->data.vlan.tag == NULL) {
|
if (def->data.vlan.tag == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("vlan interface misses the tag attribute"));
|
"%s", _("vlan interface misses the tag attribute"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -663,7 +662,7 @@ virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
def->data.vlan.devname =
|
def->data.vlan.devname =
|
||||||
virXPathString("string(./interface/@name)", ctxt);
|
virXPathString("string(./interface/@name)", ctxt);
|
||||||
if (def->data.vlan.devname == NULL) {
|
if (def->data.vlan.devname == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("vlan interface misses name attribute"));
|
"%s", _("vlan interface misses name attribute"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -671,8 +670,7 @@ virInterfaceDefParseVlan(virConnectPtr conn, virInterfaceDefPtr def,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static virInterfaceDefPtr
|
static virInterfaceDefPtr
|
||||||
virInterfaceDefParseXML(virConnectPtr conn,
|
virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) {
|
||||||
xmlXPathContextPtr ctxt, int parentIfType) {
|
|
||||||
virInterfaceDefPtr def;
|
virInterfaceDefPtr def;
|
||||||
int type;
|
int type;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@ -681,13 +679,13 @@ virInterfaceDefParseXML(virConnectPtr conn,
|
|||||||
/* check @type */
|
/* check @type */
|
||||||
tmp = virXPathString("string(./@type)", ctxt);
|
tmp = virXPathString("string(./@type)", ctxt);
|
||||||
if (tmp == NULL) {
|
if (tmp == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("interface misses the type attribute"));
|
"%s", _("interface misses the type attribute"));
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
type = virInterfaceTypeFromString(tmp);
|
type = virInterfaceTypeFromString(tmp);
|
||||||
if (type == -1) {
|
if (type == -1) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("unknown interface type %s"), tmp);
|
_("unknown interface type %s"), tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
@ -708,7 +706,7 @@ virInterfaceDefParseXML(virConnectPtr conn,
|
|||||||
|| (parentIfType == VIR_INTERFACE_TYPE_ETHERNET)
|
|| (parentIfType == VIR_INTERFACE_TYPE_ETHERNET)
|
||||||
|| (parentIfType == VIR_INTERFACE_TYPE_VLAN))
|
|| (parentIfType == VIR_INTERFACE_TYPE_VLAN))
|
||||||
{
|
{
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("interface has unsupported type '%s'"),
|
_("interface has unsupported type '%s'"),
|
||||||
virInterfaceTypeToString(type));
|
virInterfaceTypeToString(type));
|
||||||
goto error;
|
goto error;
|
||||||
@ -716,36 +714,36 @@ virInterfaceDefParseXML(virConnectPtr conn,
|
|||||||
def->type = type;
|
def->type = type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VIR_INTERFACE_TYPE_ETHERNET:
|
case VIR_INTERFACE_TYPE_ETHERNET:
|
||||||
if (virInterfaceDefParseName(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseName(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
tmp = virXPathString("string(./mac/@address)", ctxt);
|
tmp = virXPathString("string(./mac/@address)", ctxt);
|
||||||
if (tmp != NULL)
|
if (tmp != NULL)
|
||||||
def->mac = tmp;
|
def->mac = tmp;
|
||||||
if (parentIfType == VIR_INTERFACE_TYPE_LAST) {
|
if (parentIfType == VIR_INTERFACE_TYPE_LAST) {
|
||||||
/* only recognize these in toplevel bond interfaces */
|
/* only recognize these in toplevel bond interfaces */
|
||||||
if (virInterfaceDefParseStartMode(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseStartMode(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseMtu(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseMtu(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseIfAdressing(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_BRIDGE: {
|
case VIR_INTERFACE_TYPE_BRIDGE: {
|
||||||
xmlNodePtr bridge;
|
xmlNodePtr bridge;
|
||||||
|
|
||||||
if (virInterfaceDefParseName(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseName(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseStartMode(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseStartMode(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseMtu(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseMtu(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseIfAdressing(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
bridge = virXPathNode("./bridge[1]", ctxt);
|
bridge = virXPathNode("./bridge[1]", ctxt);
|
||||||
if (bridge == NULL) {
|
if (bridge == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bridge interface misses the bridge element"));
|
"%s", _("bridge interface misses the bridge element"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -757,7 +755,7 @@ virInterfaceDefParseXML(virConnectPtr conn,
|
|||||||
} else if (STREQ(tmp, "off")) {
|
} else if (STREQ(tmp, "off")) {
|
||||||
def->data.bridge.stp = 0;
|
def->data.bridge.stp = 0;
|
||||||
} else {
|
} else {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
_("bridge interface stp should be on or off got %s"),
|
_("bridge interface stp should be on or off got %s"),
|
||||||
tmp);
|
tmp);
|
||||||
VIR_FREE(tmp);
|
VIR_FREE(tmp);
|
||||||
@ -767,32 +765,32 @@ virInterfaceDefParseXML(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
def->data.bridge.delay = virXMLPropString(bridge, "delay");
|
def->data.bridge.delay = virXMLPropString(bridge, "delay");
|
||||||
ctxt->node = bridge;
|
ctxt->node = bridge;
|
||||||
virInterfaceDefParseBridge(conn, def, ctxt);
|
virInterfaceDefParseBridge(def, ctxt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VIR_INTERFACE_TYPE_BOND: {
|
case VIR_INTERFACE_TYPE_BOND: {
|
||||||
xmlNodePtr bond;
|
xmlNodePtr bond;
|
||||||
|
|
||||||
if (virInterfaceDefParseName(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseName(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (parentIfType == VIR_INTERFACE_TYPE_LAST) {
|
if (parentIfType == VIR_INTERFACE_TYPE_LAST) {
|
||||||
/* only recognize these in toplevel bond interfaces */
|
/* only recognize these in toplevel bond interfaces */
|
||||||
if (virInterfaceDefParseStartMode(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseStartMode(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseMtu(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseMtu(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseIfAdressing(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
bond = virXPathNode("./bond[1]", ctxt);
|
bond = virXPathNode("./bond[1]", ctxt);
|
||||||
if (bond == NULL) {
|
if (bond == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("bond interface misses the bond element"));
|
"%s", _("bond interface misses the bond element"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
ctxt->node = bond;
|
ctxt->node = bond;
|
||||||
if (virInterfaceDefParseBond(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseBond(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -802,18 +800,18 @@ virInterfaceDefParseXML(virConnectPtr conn,
|
|||||||
tmp = virXPathString("string(./@name)", ctxt);
|
tmp = virXPathString("string(./@name)", ctxt);
|
||||||
if (tmp != NULL)
|
if (tmp != NULL)
|
||||||
def->name = tmp;
|
def->name = tmp;
|
||||||
if (virInterfaceDefParseStartMode(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseStartMode(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
if (virInterfaceDefParseIfAdressing(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseIfAdressing(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
vlan = virXPathNode("./vlan[1]", ctxt);
|
vlan = virXPathNode("./vlan[1]", ctxt);
|
||||||
if (vlan == NULL) {
|
if (vlan == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("vlan interface misses the vlan element"));
|
"%s", _("vlan interface misses the vlan element"));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
ctxt->node = vlan;
|
ctxt->node = vlan;
|
||||||
if (virInterfaceDefParseVlan(conn, def, ctxt) < 0)
|
if (virInterfaceDefParseVlan(def, ctxt) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -829,15 +827,14 @@ error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virInterfaceDefPtr virInterfaceDefParseNode(virConnectPtr conn,
|
virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml,
|
||||||
xmlDocPtr xml,
|
xmlNodePtr root)
|
||||||
xmlNodePtr root)
|
|
||||||
{
|
{
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
virInterfaceDefPtr def = NULL;
|
virInterfaceDefPtr def = NULL;
|
||||||
|
|
||||||
if (!xmlStrEqual(root->name, BAD_CAST "interface")) {
|
if (!xmlStrEqual(root->name, BAD_CAST "interface")) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("incorrect root element"));
|
"%s", _("incorrect root element"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -849,7 +846,7 @@ virInterfaceDefPtr virInterfaceDefParseNode(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctxt->node = root;
|
ctxt->node = root;
|
||||||
def = virInterfaceDefParseXML(conn, ctxt, VIR_INTERFACE_TYPE_LAST);
|
def = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_LAST);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
xmlXPathFreeContext(ctxt);
|
xmlXPathFreeContext(ctxt);
|
||||||
@ -863,13 +860,10 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
|
|||||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||||
|
|
||||||
if (ctxt) {
|
if (ctxt) {
|
||||||
virConnectPtr conn = ctxt->_private;
|
if (virGetLastError() == NULL &&
|
||||||
|
|
||||||
if (conn &&
|
|
||||||
conn->err.code == VIR_ERR_NONE &&
|
|
||||||
ctxt->lastError.level == XML_ERR_FATAL &&
|
ctxt->lastError.level == XML_ERR_FATAL &&
|
||||||
ctxt->lastError.message != NULL) {
|
ctxt->lastError.message != NULL) {
|
||||||
virInterfaceReportError (conn, VIR_ERR_XML_DETAIL,
|
virInterfaceReportError (VIR_ERR_XML_DETAIL,
|
||||||
_("at line %d: %s"),
|
_("at line %d: %s"),
|
||||||
ctxt->lastError.line,
|
ctxt->lastError.line,
|
||||||
ctxt->lastError.message);
|
ctxt->lastError.message);
|
||||||
@ -877,8 +871,7 @@ catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virInterfaceDefPtr virInterfaceDefParseString(virConnectPtr conn,
|
virInterfaceDefPtr virInterfaceDefParseString(const char *xmlStr)
|
||||||
const char *xmlStr)
|
|
||||||
{
|
{
|
||||||
xmlParserCtxtPtr pctxt;
|
xmlParserCtxtPtr pctxt;
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
@ -890,26 +883,24 @@ virInterfaceDefPtr virInterfaceDefParseString(virConnectPtr conn,
|
|||||||
if (!pctxt || !pctxt->sax)
|
if (!pctxt || !pctxt->sax)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
pctxt->sax->error = catchXMLError;
|
pctxt->sax->error = catchXMLError;
|
||||||
pctxt->_private = conn;
|
|
||||||
|
|
||||||
if (conn) virResetError (&conn->err);
|
|
||||||
xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr, "interface.xml", NULL,
|
xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr, "interface.xml", NULL,
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
XML_PARSE_NOENT | XML_PARSE_NONET |
|
||||||
XML_PARSE_NOWARNING);
|
XML_PARSE_NOWARNING);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
if (conn && conn->err.code == VIR_ERR_NONE)
|
if (virGetLastError() == NULL)
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("failed to parse xml document"));
|
"%s", _("failed to parse xml document"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((root = xmlDocGetRootElement(xml)) == NULL) {
|
if ((root = xmlDocGetRootElement(xml)) == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("missing root element"));
|
"%s", _("missing root element"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
def = virInterfaceDefParseNode(conn, xml, root);
|
def = virInterfaceDefParseNode(xml, root);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
xmlFreeParserCtxt (pctxt);
|
xmlFreeParserCtxt (pctxt);
|
||||||
@ -917,8 +908,7 @@ cleanup:
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
virInterfaceDefPtr virInterfaceDefParseFile(virConnectPtr conn,
|
virInterfaceDefPtr virInterfaceDefParseFile(const char *filename)
|
||||||
const char *filename)
|
|
||||||
{
|
{
|
||||||
xmlParserCtxtPtr pctxt;
|
xmlParserCtxtPtr pctxt;
|
||||||
xmlDocPtr xml = NULL;
|
xmlDocPtr xml = NULL;
|
||||||
@ -930,26 +920,24 @@ virInterfaceDefPtr virInterfaceDefParseFile(virConnectPtr conn,
|
|||||||
if (!pctxt || !pctxt->sax)
|
if (!pctxt || !pctxt->sax)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
pctxt->sax->error = catchXMLError;
|
pctxt->sax->error = catchXMLError;
|
||||||
pctxt->_private = conn;
|
|
||||||
|
|
||||||
if (conn) virResetError (&conn->err);
|
|
||||||
xml = xmlCtxtReadFile (pctxt, filename, NULL,
|
xml = xmlCtxtReadFile (pctxt, filename, NULL,
|
||||||
XML_PARSE_NOENT | XML_PARSE_NONET |
|
XML_PARSE_NOENT | XML_PARSE_NONET |
|
||||||
XML_PARSE_NOWARNING);
|
XML_PARSE_NOWARNING);
|
||||||
if (!xml) {
|
if (!xml) {
|
||||||
if (conn && conn->err.code == VIR_ERR_NONE)
|
if (virGetLastError() == NULL)
|
||||||
virInterfaceReportError(conn, VIR_ERR_XML_ERROR,
|
virInterfaceReportError(VIR_ERR_XML_ERROR,
|
||||||
"%s", _("failed to parse xml document"));
|
"%s", _("failed to parse xml document"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((root = xmlDocGetRootElement(xml)) == NULL) {
|
if ((root = xmlDocGetRootElement(xml)) == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("missing root element"));
|
"%s", _("missing root element"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
def = virInterfaceDefParseNode(conn, xml, root);
|
def = virInterfaceDefParseNode(xml, root);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
xmlFreeParserCtxt (pctxt);
|
xmlFreeParserCtxt (pctxt);
|
||||||
@ -958,7 +946,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceBridgeDefFormat(virConnectPtr conn, virBufferPtr buf,
|
virInterfaceBridgeDefFormat(virBufferPtr buf,
|
||||||
const virInterfaceDefPtr def, int level) {
|
const virInterfaceDefPtr def, int level) {
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -973,7 +961,7 @@ virInterfaceBridgeDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
virBufferAddLit(buf, ">\n");
|
virBufferAddLit(buf, ">\n");
|
||||||
|
|
||||||
for (i = 0;i < def->data.bridge.nbItf;i++) {
|
for (i = 0;i < def->data.bridge.nbItf;i++) {
|
||||||
if (virInterfaceDefDevFormat(conn, buf,
|
if (virInterfaceDefDevFormat(buf,
|
||||||
def->data.bridge.itf[i], level+2) < 0)
|
def->data.bridge.itf[i], level+2) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
@ -983,7 +971,7 @@ virInterfaceBridgeDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceBondDefFormat(virConnectPtr conn, virBufferPtr buf,
|
virInterfaceBondDefFormat(virBufferPtr buf,
|
||||||
const virInterfaceDefPtr def, int level) {
|
const virInterfaceDefPtr def, int level) {
|
||||||
int i;
|
int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -1019,7 +1007,7 @@ virInterfaceBondDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
} else if (def->data.bond.monit == VIR_INTERFACE_BOND_MONIT_ARP) {
|
} else if (def->data.bond.monit == VIR_INTERFACE_BOND_MONIT_ARP) {
|
||||||
if (def->data.bond.target == NULL) {
|
if (def->data.bond.target == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("bond arp monitoring has no target"));
|
"%s", _("bond arp monitoring has no target"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -1035,7 +1023,7 @@ virInterfaceBondDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
for (i = 0;i < def->data.bond.nbItf;i++) {
|
for (i = 0;i < def->data.bond.nbItf;i++) {
|
||||||
if (virInterfaceDefDevFormat(conn, buf, def->data.bond.itf[i], level+2) < 0)
|
if (virInterfaceDefDevFormat(buf, def->data.bond.itf[i], level+2) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1044,10 +1032,10 @@ virInterfaceBondDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceVlanDefFormat(virConnectPtr conn, virBufferPtr buf,
|
virInterfaceVlanDefFormat(virBufferPtr buf,
|
||||||
const virInterfaceDefPtr def, int level) {
|
const virInterfaceDefPtr def, int level) {
|
||||||
if (def->data.vlan.tag == NULL) {
|
if (def->data.vlan.tag == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("vlan misses the tag name"));
|
"%s", _("vlan misses the tag name"));
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -1065,8 +1053,7 @@ virInterfaceVlanDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceProtocolDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED,
|
virInterfaceProtocolDefFormat(virBufferPtr buf, const virInterfaceDefPtr def,
|
||||||
virBufferPtr buf, const virInterfaceDefPtr def,
|
|
||||||
int level) {
|
int level) {
|
||||||
int pp, ii;
|
int pp, ii;
|
||||||
|
|
||||||
@ -1113,7 +1100,7 @@ virInterfaceProtocolDefFormat(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceStartmodeDefFormat(virConnectPtr conn, virBufferPtr buf,
|
virInterfaceStartmodeDefFormat(virBufferPtr buf,
|
||||||
enum virInterfaceStartMode startmode,
|
enum virInterfaceStartMode startmode,
|
||||||
int level) {
|
int level) {
|
||||||
const char *mode;
|
const char *mode;
|
||||||
@ -1130,7 +1117,7 @@ virInterfaceStartmodeDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
mode = "hotplug";
|
mode = "hotplug";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("virInterfaceDefFormat unknown startmode"));
|
"%s", _("virInterfaceDefFormat unknown startmode"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1139,24 +1126,24 @@ virInterfaceStartmodeDefFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
virInterfaceDefDevFormat(virConnectPtr conn, virBufferPtr buf,
|
virInterfaceDefDevFormat(virBufferPtr buf,
|
||||||
const virInterfaceDefPtr def, int level) {
|
const virInterfaceDefPtr def, int level) {
|
||||||
const char *type = NULL;
|
const char *type = NULL;
|
||||||
|
|
||||||
if (def == NULL) {
|
if (def == NULL) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("virInterfaceDefFormat NULL def"));
|
"%s", _("virInterfaceDefFormat NULL def"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((def->name == NULL) && (def->type != VIR_INTERFACE_TYPE_VLAN)) {
|
if ((def->name == NULL) && (def->type != VIR_INTERFACE_TYPE_VLAN)) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("virInterfaceDefFormat missing interface name"));
|
"%s", _("virInterfaceDefFormat missing interface name"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(type = virInterfaceTypeToString(def->type))) {
|
if (!(type = virInterfaceTypeToString(def->type))) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected interface type %d"), def->type);
|
_("unexpected interface type %d"), def->type);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1168,41 +1155,41 @@ virInterfaceDefDevFormat(virConnectPtr conn, virBufferPtr buf,
|
|||||||
|
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_INTERFACE_TYPE_ETHERNET:
|
case VIR_INTERFACE_TYPE_ETHERNET:
|
||||||
virInterfaceStartmodeDefFormat(conn, buf, def->startmode, level);
|
virInterfaceStartmodeDefFormat(buf, def->startmode, level);
|
||||||
if (def->mac != NULL)
|
if (def->mac != NULL)
|
||||||
virBufferVSprintf(buf, "%*s <mac address='%s'/>\n",
|
virBufferVSprintf(buf, "%*s <mac address='%s'/>\n",
|
||||||
level*2, "", def->mac);
|
level*2, "", def->mac);
|
||||||
if (def->mtu != 0)
|
if (def->mtu != 0)
|
||||||
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
||||||
level*2, "", def->mtu);
|
level*2, "", def->mtu);
|
||||||
virInterfaceProtocolDefFormat(conn, buf, def, level);
|
virInterfaceProtocolDefFormat(buf, def, level);
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_BRIDGE:
|
case VIR_INTERFACE_TYPE_BRIDGE:
|
||||||
virInterfaceStartmodeDefFormat(conn, buf, def->startmode, level);
|
virInterfaceStartmodeDefFormat(buf, def->startmode, level);
|
||||||
if (def->mtu != 0)
|
if (def->mtu != 0)
|
||||||
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
||||||
level*2, "", def->mtu);
|
level*2, "", def->mtu);
|
||||||
virInterfaceProtocolDefFormat(conn, buf, def, level);
|
virInterfaceProtocolDefFormat(buf, def, level);
|
||||||
virInterfaceBridgeDefFormat(conn, buf, def, level);
|
virInterfaceBridgeDefFormat(buf, def, level);
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_BOND:
|
case VIR_INTERFACE_TYPE_BOND:
|
||||||
virInterfaceStartmodeDefFormat(conn, buf, def->startmode, level);
|
virInterfaceStartmodeDefFormat(buf, def->startmode, level);
|
||||||
if (def->mtu != 0)
|
if (def->mtu != 0)
|
||||||
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
||||||
level*2, "", def->mtu);
|
level*2, "", def->mtu);
|
||||||
virInterfaceProtocolDefFormat(conn, buf, def, level);
|
virInterfaceProtocolDefFormat(buf, def, level);
|
||||||
virInterfaceBondDefFormat(conn, buf, def, level);
|
virInterfaceBondDefFormat(buf, def, level);
|
||||||
break;
|
break;
|
||||||
case VIR_INTERFACE_TYPE_VLAN:
|
case VIR_INTERFACE_TYPE_VLAN:
|
||||||
virInterfaceStartmodeDefFormat(conn, buf, def->startmode, level);
|
virInterfaceStartmodeDefFormat(buf, def->startmode, level);
|
||||||
if (def->mac != NULL)
|
if (def->mac != NULL)
|
||||||
virBufferVSprintf(buf, "%*s <mac address='%s'/>\n",
|
virBufferVSprintf(buf, "%*s <mac address='%s'/>\n",
|
||||||
level*2, "", def->mac);
|
level*2, "", def->mac);
|
||||||
if (def->mtu != 0)
|
if (def->mtu != 0)
|
||||||
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
virBufferVSprintf(buf, "%*s <mtu size='%d'/>\n",
|
||||||
level*2, "", def->mtu);
|
level*2, "", def->mtu);
|
||||||
virInterfaceProtocolDefFormat(conn, buf, def, level);
|
virInterfaceProtocolDefFormat(buf, def, level);
|
||||||
virInterfaceVlanDefFormat(conn, buf, def, level);
|
virInterfaceVlanDefFormat(buf, def, level);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,12 +1204,11 @@ cleanup:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *virInterfaceDefFormat(virConnectPtr conn,
|
char *virInterfaceDefFormat(const virInterfaceDefPtr def)
|
||||||
const virInterfaceDefPtr def)
|
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (virInterfaceDefDevFormat(conn, &buf, def, 0) < 0) {
|
if (virInterfaceDefDevFormat(&buf, def, 0) < 0) {
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1304,8 +1290,7 @@ void virInterfaceObjListFree(virInterfaceObjListPtr interfaces)
|
|||||||
interfaces->count = 0;
|
interfaces->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virInterfaceObjPtr virInterfaceAssignDef(virConnectPtr conn,
|
virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces,
|
||||||
virInterfaceObjListPtr interfaces,
|
|
||||||
const virInterfaceDefPtr def)
|
const virInterfaceDefPtr def)
|
||||||
{
|
{
|
||||||
virInterfaceObjPtr iface;
|
virInterfaceObjPtr iface;
|
||||||
@ -1323,7 +1308,7 @@ virInterfaceObjPtr virInterfaceAssignDef(virConnectPtr conn,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (virMutexInit(&iface->lock) < 0) {
|
if (virMutexInit(&iface->lock) < 0) {
|
||||||
virInterfaceReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
virInterfaceReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("cannot initialize mutex"));
|
"%s", _("cannot initialize mutex"));
|
||||||
VIR_FREE(iface);
|
VIR_FREE(iface);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -193,22 +193,17 @@ void virInterfaceDefFree(virInterfaceDefPtr def);
|
|||||||
void virInterfaceObjFree(virInterfaceObjPtr iface);
|
void virInterfaceObjFree(virInterfaceObjPtr iface);
|
||||||
void virInterfaceObjListFree(virInterfaceObjListPtr vms);
|
void virInterfaceObjListFree(virInterfaceObjListPtr vms);
|
||||||
|
|
||||||
virInterfaceObjPtr virInterfaceAssignDef(virConnectPtr conn,
|
virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces,
|
||||||
virInterfaceObjListPtr interfaces,
|
|
||||||
const virInterfaceDefPtr def);
|
const virInterfaceDefPtr def);
|
||||||
void virInterfaceRemove(virInterfaceObjListPtr interfaces,
|
void virInterfaceRemove(virInterfaceObjListPtr interfaces,
|
||||||
const virInterfaceObjPtr iface);
|
const virInterfaceObjPtr iface);
|
||||||
|
|
||||||
virInterfaceDefPtr virInterfaceDefParseString(virConnectPtr conn,
|
virInterfaceDefPtr virInterfaceDefParseString(const char *xmlStr);
|
||||||
const char *xmlStr);
|
virInterfaceDefPtr virInterfaceDefParseFile(const char *filename);
|
||||||
virInterfaceDefPtr virInterfaceDefParseFile(virConnectPtr conn,
|
virInterfaceDefPtr virInterfaceDefParseNode(xmlDocPtr xml,
|
||||||
const char *filename);
|
|
||||||
virInterfaceDefPtr virInterfaceDefParseNode(virConnectPtr conn,
|
|
||||||
xmlDocPtr xml,
|
|
||||||
xmlNodePtr root);
|
xmlNodePtr root);
|
||||||
|
|
||||||
char *virInterfaceDefFormat(virConnectPtr conn,
|
char *virInterfaceDefFormat(const virInterfaceDefPtr def);
|
||||||
const virInterfaceDefPtr def);
|
|
||||||
|
|
||||||
void virInterfaceObjLock(virInterfaceObjPtr obj);
|
void virInterfaceObjLock(virInterfaceObjPtr obj);
|
||||||
void virInterfaceObjUnlock(virInterfaceObjPtr obj);
|
void virInterfaceObjUnlock(virInterfaceObjPtr obj);
|
||||||
|
@ -356,13 +356,13 @@ static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifacedef = virInterfaceDefParseString(ifinfo->conn, xmlstr);
|
ifacedef = virInterfaceDefParseString(xmlstr);
|
||||||
if (!ifacedef) {
|
if (!ifacedef) {
|
||||||
/* error was already reported */
|
/* error was already reported */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virInterfaceDefFormat(ifinfo->conn, ifacedef);
|
ret = virInterfaceDefFormat(ifacedef);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
/* error was already reported */
|
/* error was already reported */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -388,13 +388,13 @@ static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
|
|||||||
|
|
||||||
interfaceDriverLock(driver);
|
interfaceDriverLock(driver);
|
||||||
|
|
||||||
ifacedef = virInterfaceDefParseString(conn, xml);
|
ifacedef = virInterfaceDefParseString(xml);
|
||||||
if (!ifacedef) {
|
if (!ifacedef) {
|
||||||
/* error was already reported */
|
/* error was already reported */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
xmlstr = virInterfaceDefFormat(conn, ifacedef);
|
xmlstr = virInterfaceDefFormat(ifacedef);
|
||||||
if (!xmlstr) {
|
if (!xmlstr) {
|
||||||
/* error was already reported */
|
/* error was already reported */
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -568,9 +568,9 @@ static int testOpenDefault(virConnectPtr conn) {
|
|||||||
netobj->persistent = 1;
|
netobj->persistent = 1;
|
||||||
virNetworkObjUnlock(netobj);
|
virNetworkObjUnlock(netobj);
|
||||||
|
|
||||||
if (!(interfacedef = virInterfaceDefParseString(conn, defaultInterfaceXML)))
|
if (!(interfacedef = virInterfaceDefParseString(defaultInterfaceXML)))
|
||||||
goto error;
|
goto error;
|
||||||
if (!(interfaceobj = virInterfaceAssignDef(conn, &privconn->ifaces, interfacedef))) {
|
if (!(interfaceobj = virInterfaceAssignDef(&privconn->ifaces, interfacedef))) {
|
||||||
virInterfaceDefFree(interfacedef);
|
virInterfaceDefFree(interfacedef);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -969,16 +969,16 @@ static int testOpenFromFile(virConnectPtr conn,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
def = virInterfaceDefParseFile(conn, absFile);
|
def = virInterfaceDefParseFile(absFile);
|
||||||
VIR_FREE(absFile);
|
VIR_FREE(absFile);
|
||||||
if (!def)
|
if (!def)
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
if ((def = virInterfaceDefParseNode(conn, xml, ifaces[i])) == NULL)
|
if ((def = virInterfaceDefParseNode(xml, ifaces[i])) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(iface = virInterfaceAssignDef(conn, &privconn->ifaces, def))) {
|
if (!(iface = virInterfaceAssignDef(&privconn->ifaces, def))) {
|
||||||
virInterfaceDefFree(def);
|
virInterfaceDefFree(def);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -3328,7 +3328,7 @@ static char *testInterfaceGetXMLDesc(virInterfacePtr iface,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = virInterfaceDefFormat(iface->conn, privinterface->def);
|
ret = virInterfaceDefFormat(privinterface->def);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (privinterface)
|
if (privinterface)
|
||||||
@ -3346,10 +3346,10 @@ static virInterfacePtr testInterfaceDefineXML(virConnectPtr conn, const char *xm
|
|||||||
virInterfacePtr ret = NULL;
|
virInterfacePtr ret = NULL;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
if ((def = virInterfaceDefParseString(conn, xmlStr)) == NULL)
|
if ((def = virInterfaceDefParseString(xmlStr)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((iface = virInterfaceAssignDef(conn, &privconn->ifaces, def)) == NULL)
|
if ((iface = virInterfaceAssignDef(&privconn->ifaces, def)) == NULL)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
def = NULL;
|
def = NULL;
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ static int testCompareXMLToXMLFiles(const char *xml) {
|
|||||||
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
|
if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(dev = virInterfaceDefParseString(NULL, xmlData)))
|
if (!(dev = virInterfaceDefParseString(xmlData)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(actual = virInterfaceDefFormat(NULL, dev)))
|
if (!(actual = virInterfaceDefFormat(dev)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (STRNEQ(xmlData, actual)) {
|
if (STRNEQ(xmlData, actual)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user