]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add --print-xml option for 'domif-setlink'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 30 Nov 2022 15:04:03 +0000 (16:04 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Dec 2022 15:49:25 +0000 (16:49 +0100)
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/manpages/virsh.rst
tools/virsh-domain.c

index 09fc1f67ad207d5ccfeecbb83ee5a9acb2853a73..14ed9cd5a06f44cb70da2dd3f56405f17a67e7b9 100644 (file)
@@ -1890,7 +1890,7 @@ domif-setlink
 
 ::
 
-   domif-setlink domain interface-device state [--config]
+   domif-setlink domain interface-device state [--config] [--print-xml]
 
 Modify link state of the domain's virtual interface. Possible values for
 state are "up" and "down". If *--config* is specified, only the persistent
@@ -1898,6 +1898,9 @@ configuration of the domain is modified, for compatibility purposes,
 *--persistent* is alias of *--config*.
 *interface-device* can be the interface's target name or the MAC address.
 
+If *--print-xml* is specified, then the XML used to update the interface is
+printed instead.
+
 
 domifaddr
 ---------
index f7bf2f96c43d5bb355ff9322dfcc972d7e5a9c4c..0095f254ee8821e9788e48ac69d9e35b7da38356 100644 (file)
@@ -3120,6 +3120,10 @@ static const vshCmdOptDef opts_domif_setlink[] = {
      .help = "config"
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
+    {.name = "print-xml",
+     .type = VSH_OT_BOOL,
+     .help = N_("print XML document rather than set the interface link state")
+    },
     {.name = NULL}
 };
 
@@ -3238,6 +3242,11 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
         return false;
     }
 
+    if (vshCommandOptBool(cmd, "print-xml")) {
+        vshPrint(ctl, "%s", xml_buf);
+        return true;
+    }
+
     if (virDomainUpdateDeviceFlags(dom, xml_buf, flags) < 0) {
         vshError(ctl, _("Failed to update interface link state"));
         return false;