diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index eea95174efd031ff4cc88ce4c188f81e4aeb0066..ac1606be071c25dce3baab29c66873035c9c068a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12274,6 +12274,10 @@ static const vshCmdOptDef opts_change_media[] = { .type = VSH_OT_BOOL, .help = N_("force media changing") }, + {.name = "print-xml", + .type = VSH_OT_BOOL, + .help = N_("print XML document rather than change media") + }, {.name = NULL} }; @@ -12354,12 +12358,17 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) if (!(disk_xml = vshPrepareDiskXML(disk_node, source, path, prepare_type))) goto cleanup; - if (virDomainUpdateDeviceFlags(dom, disk_xml, flags) != 0) { - vshError(ctl, _("Failed to complete action %s on media"), action); - goto cleanup; + if (vshCommandOptBool(cmd, "print-xml")) { + vshPrint(ctl, "%s", disk_xml); + } else { + if (virDomainUpdateDeviceFlags(dom, disk_xml, flags) != 0) { + vshError(ctl, _("Failed to complete action %s on media"), action); + goto cleanup; + } + + vshPrint(ctl, _("succeeded to complete action %s on media\n"), action); } - vshPrint(ctl, _("succeeded to complete action %s on media\n"), action); ret = true; cleanup: diff --git a/tools/virsh.pod b/tools/virsh.pod index dfbee545dee8a98d97753e2e16cf6244bdeadfc7..8e4b413b20a519a3841b8364e95a7786b52dca50 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -2597,6 +2597,7 @@ expected. =item B I I [I<--eject>] [I<--insert>] [I<--update>] [I] [I<--force>] [[I<--live>] [I<--config>] | [I<--current>]] +[I<--print-xml>] Change media of CDROM or floppy drive. I can be the fully-qualified path or the unique target name () of the disk device. I @@ -2620,6 +2621,8 @@ the hypervisor's implementation. Both I<--live> and I<--config> flags may be given, but I<--current> is exclusive. If no flag is specified, behavior is different depending on hypervisor. +If I<--print-xml> is specified, the XML that would be used to change media is +printed instead of changing the media. =back