::
detach-interface domain type [--mac mac]
- [[[--live] [--config] | [--current]] | [--persistent]]
+ [[[--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
Note that older versions of virsh used *--config* as an alias for
*--persistent*.
+If *--print-xml* is specified, then the XML used to detach the interface
+is printed instead.
+
Please see documentation for ``detach-device`` for known quirks.
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
VIRSH_COMMON_OPT_DOMAIN_LIVE,
VIRSH_COMMON_OPT_DOMAIN_CURRENT,
+ {.name = "print-xml",
+ .type = VSH_OT_BOOL,
+ .help = N_("print XML document rather than detach the interface")
+ },
{.name = NULL}
};
vshControl *ctl,
bool current,
const char *type,
- const char *mac)
+ const char *mac,
+ bool printxml)
{
g_autoptr(xmlDoc) xml = NULL;
g_autoptr(xmlXPathObject) obj = NULL;
return false;
}
+ if (printxml) {
+ vshPrint(ctl, "%s", detach_xml);
+ return true;
+ }
+
if (flags != 0 || current)
return virDomainDetachDeviceFlags(dom, detach_xml, flags) == 0;
return virDomainDetachDevice(dom, detach_xml) == 0;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool persistent = vshCommandOptBool(cmd, "persistent");
+ bool printxml = vshCommandOptBool(cmd, "print-xml");
VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
goto cleanup;
if (!(ret = virshDomainDetachInterface(doc_config,
flags | VIR_DOMAIN_AFFECT_CONFIG,
- dom, ctl, current, type, mac)))
+ dom, ctl, current, type, mac,
+ printxml)))
goto cleanup;
}
goto cleanup;
ret = virshDomainDetachInterface(doc_live, flags,
- dom, ctl, current, type, mac);
+ dom, ctl, current, type, mac, printxml);
}
+ if (printxml)
+ return ret;
+
cleanup:
if (!ret) {
vshError(ctl, "%s", _("Failed to detach interface"));