Other virsh domifXXX commands can accept target name as a parameter to specify interface. From viewpoint of consistency, virsh domif-setlink command should accept target name as a parameter. This patch achieves this. Signd-off-by: Taku Izumi <izumi.taku@xxxxxxxxxxxxxx> --- tools/virsh.c | 25 ++++++++++++++++++------- tools/virsh.pod | 3 ++- 2 files changed, 20 insertions(+), 8 deletions(-) Index: libvirt/tools/virsh.c =================================================================== --- libvirt.orig/tools/virsh.c +++ libvirt/tools/virsh.c @@ -1344,8 +1344,11 @@ cmdDomIfSetLink (vshControl *ctl, const virDomainPtr dom; const char *iface; const char *state; - const char *mac; + const char *value; const char *desc; + unsigned char macaddr[VIR_MAC_BUFLEN]; + const char *element; + const char *attribute; bool persistent; bool ret = false; unsigned int flags = 0; @@ -1405,26 +1408,34 @@ cmdDomIfSetLink (vshControl *ctl, const goto cleanup; } + if (virParseMacAddr(iface, macaddr) == 0) { + element = "mac"; + attribute = "address"; + } else { + element = "target"; + attribute = "dev"; + } + /* find interface with matching mac addr */ for (i = 0; i < obj->nodesetval->nodeNr; i++) { cur = obj->nodesetval->nodeTab[i]->children; while (cur) { if (cur->type == XML_ELEMENT_NODE && - xmlStrEqual(cur->name, BAD_CAST "mac")) { - mac = virXMLPropString(cur, "address"); + xmlStrEqual(cur->name, BAD_CAST element)) { + value = virXMLPropString(cur, attribute); - if (STRCASEEQ(mac, iface)) { - VIR_FREE(mac); + if (STRCASEEQ(value, iface)) { + VIR_FREE(value); goto hit; } - VIR_FREE(mac); + VIR_FREE(value); } cur = cur->next; } } - vshError(ctl, _("interface with address '%s' not found"), iface); + vshError(ctl, _("interface (%s: %s) not found"), element, iface); goto cleanup; hit: Index: libvirt/tools/virsh.pod =================================================================== --- libvirt.orig/tools/virsh.pod +++ libvirt/tools/virsh.pod @@ -469,11 +469,12 @@ B<Explanation of fields> (fields appear Get network interface stats for a running domain. -=item B<domif-setlink> I<domain> I<interface-MAC> I<state> I<--persistent> +=item B<domif-setlink> I<domain> I<interface-device> I<state> I<--persistent> Modify link state of the domain's virtual interface. Possible values for state are "up" and "down. If --persistent is specified, only the persistent configuration of the domain is modified. +I<interface-device> can be the interface's target name or the MAC address. =item B<domif-getlink> I<domain> I<interface-device> I<--persistent> -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list