提交 18bcba55 编写于 作者: M Michal Privoznik

virsh attach-interface: Use enum instead of arbitrary integers

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: NMichal Privoznik <mprivozn@redhat.com>
上级 9993736f
...@@ -906,7 +906,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) ...@@ -906,7 +906,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
*type = NULL, *source = NULL, *model = NULL, *type = NULL, *source = NULL, *model = NULL,
*inboundStr = NULL, *outboundStr = NULL; *inboundStr = NULL, *outboundStr = NULL;
virNetDevBandwidthRate inbound, outbound; virNetDevBandwidthRate inbound, outbound;
int typ; virDomainNetType typ;
int ret; int ret;
bool functionReturn = false; bool functionReturn = false;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
...@@ -946,9 +946,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) ...@@ -946,9 +946,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
/* check interface type */ /* check interface type */
if (STREQ(type, "network")) { if (STREQ(type, "network")) {
typ = 1; typ = VIR_DOMAIN_NET_TYPE_NETWORK;
} else if (STREQ(type, "bridge")) { } else if (STREQ(type, "bridge")) {
typ = 2; typ = VIR_DOMAIN_NET_TYPE_BRIDGE;
} else { } else {
vshError(ctl, _("No support for %s in command 'attach-interface'"), vshError(ctl, _("No support for %s in command 'attach-interface'"),
type); type);
...@@ -982,9 +982,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) ...@@ -982,9 +982,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
virBufferAsprintf(&buf, "<interface type='%s'>\n", type); virBufferAsprintf(&buf, "<interface type='%s'>\n", type);
virBufferAdjustIndent(&buf, 2); virBufferAdjustIndent(&buf, 2);
if (typ == 1) if (typ == VIR_DOMAIN_NET_TYPE_NETWORK)
virBufferAsprintf(&buf, "<source network='%s'/>\n", source); 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); virBufferAsprintf(&buf, "<source bridge='%s'/>\n", source);
if (target != NULL) if (target != NULL)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册