提交 69db5f92 编写于 作者: L Laine Stump

interface: report link state for bonds and vlans too

The interface state for bonds and vlans does seem to reflect the state
of the underlying physical devices, at least in some cases, so it
makes sense to allow reporting it (netcf now does).

The link state/speed for bridge devices is meaningless though, so we
don't even look for it.
上级 c8e42205
......@@ -78,6 +78,7 @@
of the form DEVICE.VLAN
-->
<optional><ref name="name-attr"/></optional>
<ref name="link-speed-state"/>
</define>
<define name="vlan-device">
......@@ -156,6 +157,7 @@
<value>bond</value>
</attribute>
<ref name="name-attr"/>
<ref name="link-speed-state"/>
</define>
<define name="bond-element">
......
......@@ -669,6 +669,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType)
int type;
char *tmp;
xmlNodePtr cur = ctxt->node;
xmlNodePtr lnk;
/* check @type */
tmp = virXPathString("string(./@type)", ctxt);
......@@ -704,20 +706,22 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType)
goto error;
}
def->type = type;
if (type != VIR_INTERFACE_TYPE_BRIDGE) {
/* link status makes no sense for a bridge */
lnk = virXPathNode("./link", ctxt);
if (lnk && virInterfaceLinkParseXML(lnk, &def->lnk) < 0)
goto error;
}
switch (type) {
case VIR_INTERFACE_TYPE_ETHERNET: {
xmlNodePtr lnk;
if (virInterfaceDefParseName(def, ctxt) < 0)
goto error;
tmp = virXPathString("string(./mac/@address)", ctxt);
if (tmp != NULL)
def->mac = tmp;
lnk = virXPathNode("./link", ctxt);
if (lnk && virInterfaceLinkParseXML(lnk, &def->lnk) < 0)
goto error;
if (parentIfType == VIR_INTERFACE_TYPE_LAST) {
/* only recognize these in toplevel bond interfaces */
if (virInterfaceDefParseStartMode(def, ctxt) < 0)
......@@ -1110,6 +1114,7 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def)
break;
case VIR_INTERFACE_TYPE_BOND:
virInterfaceStartmodeDefFormat(buf, def->startmode);
virInterfaceLinkFormat(buf, &def->lnk);
if (def->mtu != 0)
virBufferAsprintf(buf, "<mtu size='%d'/>\n", def->mtu);
virInterfaceProtocolDefFormat(buf, def);
......@@ -1119,6 +1124,7 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def)
virInterfaceStartmodeDefFormat(buf, def->startmode);
if (def->mac != NULL)
virBufferAsprintf(buf, "<mac address='%s'/>\n", def->mac);
virInterfaceLinkFormat(buf, &def->lnk);
if (def->mtu != 0)
virBufferAsprintf(buf, "<mtu size='%d'/>\n", def->mtu);
virInterfaceProtocolDefFormat(buf, def);
......
<interface type='bond' name='bond0'>
<start mode='none'/>
<link speed='1000' state='up'/>
<protocol family='ipv4'>
<ip address='192.168.50.7' prefix='24'/>
<route gateway='192.168.50.1'/>
......
<interface type='vlan' name='eth0.42'>
<start mode='onboot'/>
<link state='lowerlayerdown'/>
<protocol family='ipv4'>
<dhcp peerdns='no'/>
</protocol>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册