::
- detach-interface domain type [--mac mac]
+ detach-interface domain [type] [--mac mac]
[[[--live] [--config] | [--current]] | [--persistent]] [--print-xml]
Detach a network interface from a domain.
-*type* can be either *network* to indicate a physical network device or
-*bridge* to indicate a bridge to a device. It is recommended to use the
-*mac* option to distinguish between the interfaces if more than one are
-present on the domain.
+
+In case when multiple interfaces are present in the *type* and/or
+*--mac* must be used to narrow down the selection to 1 interface.
+
+*type* can be either *network* to indicate a physical network device
+*bridge* to indicate a bridge to a device.
+
+*--mac* can select the interface based on the configured MAC address.
If *--live* is specified, affect a running domain.
If *--config* is specified, affect the next startup of a persistent guest.
{.name = "type",
.type = VSH_OT_STRING,
.positional = true,
- .required = true,
.help = N_("network interface type")
},
{.name = "mac",
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathContext) ctxt = NULL;
g_autofree char *detach_xml = NULL;
- g_autofree char *xpath = g_strdup_printf("/domain/devices/interface[@type='%s']", type);
+ g_autofree char *xpath = NULL;
g_autofree xmlNodePtr *nodes = NULL;
ssize_t nnodes;
xmlNodePtr matchNode = NULL;
return false;
}
+ if (type)
+ xpath = g_strdup_printf("/domain/devices/interface[@type='%s']", type);
+ else
+ xpath = g_strdup("/domain/devices/interface");
+
if ((nnodes = virXPathNodeSet(xpath, ctxt, &nodes)) <= 0) {
- vshError(ctl, _("No interface found whose type is %1$s"), type);
+ if (type)
+ vshError(ctl, _("No interface found whose type is %1$s"), type);
+ else
+ vshError(ctl, "%s", _("Domain has no interfaces"));
return false;
}