From 431e73660e4aa2aa1ba7db2e3345c12d8e10c4f6 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 14 Feb 2018 15:13:29 +0100 Subject: [PATCH] virsh: detach-disk: Add --print-xml switch Similarly to other commands add an argument which allows to check the XML which would be used to execute the operation instead. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 10 ++++++++++ tools/virsh.pod | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 5a0e0c1b21..c10bf184f9 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12432,6 +12432,10 @@ static const vshCmdOptDef opts_detach_disk[] = { 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 attach the interface") + }, {.name = NULL} }; @@ -12487,6 +12491,12 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) goto cleanup; } + if (vshCommandOptBool(cmd, "print-xml")) { + vshPrint(ctl, "%s", disk_xml); + functionReturn = true; + goto cleanup; + } + if (flags != 0 || current) ret = virDomainDetachDeviceFlags(dom, disk_xml, flags); else diff --git a/tools/virsh.pod b/tools/virsh.pod index 69cc42338d..8f0e8d74b0 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3113,6 +3113,7 @@ I<--persistent>. =item B I I [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] +[I<--print-xml>] Detach a disk device from a domain. The I is the device as seen from the domain. @@ -3130,6 +3131,9 @@ an offline domain, and like I<--live> I<--config> for a running domain. Note that older versions of virsh used I<--config> as an alias for I<--persistent>. +If B<--print-xml> is specified, then the XML which would be used to detach the +disk is printed instead. + =item B I I [I<--mac mac>] [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] -- GitLab