]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Use enum of virDomainNetType
authorStefan Berger <stefanb@us.ibm.com>
Fri, 26 Mar 2010 16:01:35 +0000 (17:01 +0100)
committerDaniel Veillard <veillard@redhat.com>
Fri, 26 Mar 2010 16:01:35 +0000 (17:01 +0100)
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

src/conf/domain_conf.c
src/conf/domain_conf.h
src/lxc/lxc_driver.c
src/qemu/qemu_conf.c
src/uml/uml_conf.c

index ffbb26fbd440c7bcece71a0a3f3a4db6ebb3e009..651dd04630f4e672d99d0d8584f891048ad7e547 100644 (file)
@@ -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)
index efd5db625d72c47ab39944a8ffdb9a64bb1756f8..218e0a79d2b93664c97429baed80d7bce5a26b4f 100644 (file)
@@ -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 {
index e0e60c9a281c631f7145b96bb2df96e1a5d79cef..532cf8b27a1da098c0fd99f3e457c11d88b44812 100644 (file)
@@ -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);
index 902eecb0d591a702c7c0b354d4b0aa748f50dc2f..b1cc8349cebe8bca67fc78e0381b95aff3eae789 100644 (file)
@@ -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;
index 6e7bc59a024234b395642da48ccb4d9854c80518..876e16be262f46c831ee6c9a1b4457aab72ad5e6 100644 (file)
@@ -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",