mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virsh attach-interface: Use virDomainNetType{From,To}String()
Instead of verbose string to enum conversion (if STREQ() else if STREQ() else if STREQ() ...) lets use virDomainNetType{From,To}String. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
18bcba55cd
commit
dd6668f174
@ -945,11 +945,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* check interface type */
|
/* check interface type */
|
||||||
if (STREQ(type, "network")) {
|
if ((int)(typ = virDomainNetTypeFromString(type)) < 0) {
|
||||||
typ = VIR_DOMAIN_NET_TYPE_NETWORK;
|
|
||||||
} else if (STREQ(type, "bridge")) {
|
|
||||||
typ = VIR_DOMAIN_NET_TYPE_BRIDGE;
|
|
||||||
} else {
|
|
||||||
vshError(ctl, _("No support for %s in command 'attach-interface'"),
|
vshError(ctl, _("No support for %s in command 'attach-interface'"),
|
||||||
type);
|
type);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -982,10 +978,28 @@ 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 == VIR_DOMAIN_NET_TYPE_NETWORK)
|
switch (typ) {
|
||||||
virBufferAsprintf(&buf, "<source network='%s'/>\n", source);
|
case VIR_DOMAIN_NET_TYPE_NETWORK:
|
||||||
else if (typ == VIR_DOMAIN_NET_TYPE_BRIDGE)
|
case VIR_DOMAIN_NET_TYPE_BRIDGE:
|
||||||
virBufferAsprintf(&buf, "<source bridge='%s'/>\n", source);
|
virBufferAsprintf(&buf, "<source %s='%s'/>\n",
|
||||||
|
virDomainNetTypeToString(typ), source);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_NET_TYPE_USER:
|
||||||
|
case VIR_DOMAIN_NET_TYPE_ETHERNET:
|
||||||
|
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
||||||
|
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_HOSTDEV:
|
||||||
|
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||||
|
vshError(ctl, _("No support for %s in command 'attach-interface'"),
|
||||||
|
type);
|
||||||
|
goto cleanup;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (target != NULL)
|
if (target != NULL)
|
||||||
virBufferAsprintf(&buf, "<target dev='%s'/>\n", target);
|
virBufferAsprintf(&buf, "<target dev='%s'/>\n", target);
|
||||||
|
Loading…
Reference in New Issue
Block a user