提交 9bcad690 编写于 作者: S Stefan Berger 提交者: Daniel Veillard

Use enum of virDomainNetType

To find out where the net type 'direct' needs to be handled I introduced
the 'enum virDomainNetType' in the virDomainNetDef structure and let the
compiler tell me where the case statement is missing. Then I added the
unhandled device statement to the UML driver.

* src/conf/domain_conf.h: change _virDomainNetDef type from int to
  virDomainNetType enum
* src/conf/domain_conf.c src/lxc/lxc_driver.c src/qemu/qemu_conf.c
  src/uml/uml_conf.c: make sure all enum cases are properly handled
  in switches
上级 67203f67
......@@ -451,6 +451,10 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
case VIR_DOMAIN_NET_TYPE_DIRECT:
VIR_FREE(def->data.direct.linkdev);
break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
VIR_FREE(def->ifname);
......@@ -1743,7 +1747,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
type = virXMLPropString(node, "type");
if (type != NULL) {
if ((def->type = virDomainNetTypeFromString(type)) < 0) {
if ((int)(def->type = virDomainNetTypeFromString(type)) < 0) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown interface type '%s'"), type);
goto error;
......@@ -1952,6 +1956,10 @@ virDomainNetDefParseXML(virCapsPtr caps,
dev = NULL;
break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
if (ifname != NULL) {
......@@ -4868,6 +4876,10 @@ virDomainNetDefFormat(virBufferPtr buf,
virDomainNetdevMacvtapTypeToString(def->data.direct.mode));
virBufferAddLit(buf, "/>\n");
break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
if (def->ifname)
......
......@@ -251,7 +251,7 @@ enum virDomainNetdevMacvtapType {
typedef struct _virDomainNetDef virDomainNetDef;
typedef virDomainNetDef *virDomainNetDefPtr;
struct _virDomainNetDef {
int type;
enum virDomainNetType type;
unsigned char mac[VIR_MAC_BUFLEN];
char *model;
union {
......
......@@ -800,6 +800,16 @@ static int lxcSetupInterfaces(virConnectPtr conn,
case VIR_DOMAIN_NET_TYPE_BRIDGE:
bridge = def->nets[i]->data.bridge.brname;
break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_SERVER:
case VIR_DOMAIN_NET_TYPE_CLIENT:
case VIR_DOMAIN_NET_TYPE_MCAST:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_DIRECT:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
DEBUG("bridge: %s", bridge);
......
......@@ -2686,6 +2686,14 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
net->data.socket.address,
net->data.socket.port);
break;
case VIR_DOMAIN_NET_TYPE_USER:
case VIR_DOMAIN_NET_TYPE_ETHERNET:
case VIR_DOMAIN_NET_TYPE_NETWORK:
case VIR_DOMAIN_NET_TYPE_BRIDGE:
case VIR_DOMAIN_NET_TYPE_INTERNAL:
case VIR_DOMAIN_NET_TYPE_DIRECT:
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
type_sep = ',';
break;
......
......@@ -244,6 +244,14 @@ umlBuildCommandLineNet(virConnectPtr conn,
umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("internal networking type not supported"));
goto error;
case VIR_DOMAIN_NET_TYPE_DIRECT:
umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
_("direct networking type not supported"));
goto error;
case VIR_DOMAIN_NET_TYPE_LAST:
break;
}
virBufferVSprintf(&buf, ",%02x:%02x:%02x:%02x:%02x:%02x",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册