]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh attach-interface: Use enum instead of arbitrary integers
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 9 Feb 2015 14:53:54 +0000 (15:53 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 13 Feb 2015 08:33:12 +0000 (09:33 +0100)
The type of interface to attach is held in the variable 'typ'.
Depending on interface type selected by user, the variable is set
either to 1 (network), or 2 (bridge). Lets use already existing
enum from domain_conf.h instead: virDomainNetType.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain.c

index 20bafbeb81eec4f5745b97fc80edca8e3eed645c..da8eb0f5069f48210d7e3b58a0d984fdd7dc8499 100644 (file)
@@ -906,7 +906,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
                 *type = NULL, *source = NULL, *model = NULL,
                 *inboundStr = NULL, *outboundStr = NULL;
     virNetDevBandwidthRate inbound, outbound;
-    int typ;
+    virDomainNetType typ;
     int ret;
     bool functionReturn = false;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -946,9 +946,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
 
     /* check interface type */
     if (STREQ(type, "network")) {
-        typ = 1;
+        typ = VIR_DOMAIN_NET_TYPE_NETWORK;
     } else if (STREQ(type, "bridge")) {
-        typ = 2;
+        typ = VIR_DOMAIN_NET_TYPE_BRIDGE;
     } else {
         vshError(ctl, _("No support for %s in command 'attach-interface'"),
                  type);
@@ -982,9 +982,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
     virBufferAsprintf(&buf, "<interface type='%s'>\n", type);
     virBufferAdjustIndent(&buf, 2);
 
-    if (typ == 1)
+    if (typ == VIR_DOMAIN_NET_TYPE_NETWORK)
         virBufferAsprintf(&buf, "<source network='%s'/>\n", source);
-    else if (typ == 2)
+    else if (typ == VIR_DOMAIN_NET_TYPE_BRIDGE)
         virBufferAsprintf(&buf, "<source bridge='%s'/>\n", source);
 
     if (target != NULL)