Signed-off-by: Pavel Hrdina <phrd...@redhat.com>
---
 docs/manpages/virsh.rst | 14 +++++++++
 tools/virsh-domain.c    | 65 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 2204bed3bb..5875b523a4 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -4515,6 +4515,20 @@ Output the IP address and port number for the VNC 
display. If the information
 is not available the processes will provide an exit code of 1.
 
 
+setappid
+--------
+
+**Syntax:**
+
+::
+
+   setappid domain appid
+
+Set the Fibre Channel appid string for domain that is used to create VMID to
+tag the traffic. Accepts only printable characters and maximal length is 128
+characters. To remove the appid from VM don't pass any appid.
+
+
 DEVICE COMMANDS
 ===============
 
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index e5bd1fdd75..07d9c7f954 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -14070,6 +14070,65 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd)
 }
 
 
+/*
+ * "setappid" command
+ */
+static const vshCmdInfo info_setappid[] = {
+    {.name = "help",
+     .data = N_("Set domain Fibre Channel appid")
+    },
+    {.name = "desc",
+     .data = N_("Set the Fibre Channel appid string for domain that is "
+                "used to create VMID to tag the traffic. Accepts only "
+                "printable characters and maximal length is 128 characters. "
+                "To remove the appid from VM don't pass any appid.")
+    },
+    {.name = NULL}
+};
+
+static const vshCmdOptDef opts_setappid[] = {
+    VIRSH_COMMON_OPT_DOMAIN_FULL(0),
+    VIRSH_COMMON_OPT_DOMAIN_CONFIG,
+    VIRSH_COMMON_OPT_DOMAIN_LIVE,
+    VIRSH_COMMON_OPT_DOMAIN_CURRENT,
+    {.name = "appid",
+     .type = VSH_OT_STRING,
+     .help = N_("User provided appid string"),
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdSetAppid(vshControl *ctl, const vshCmd *cmd)
+{
+    g_autoptr(virshDomain) dom = NULL;
+    bool config = vshCommandOptBool(cmd, "config");
+    bool live = vshCommandOptBool(cmd, "live");
+    bool current = vshCommandOptBool(cmd, "current");
+    const char *appid = NULL;
+    unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
+
+    VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+    VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
+    if (config)
+        flags |= VIR_DOMAIN_AFFECT_CONFIG;
+    if (live)
+        flags |= VIR_DOMAIN_AFFECT_LIVE;
+
+    if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
+        return false;
+
+    if (vshCommandOptStringReq(ctl, cmd, "appid", &appid) < 0)
+        return false;
+
+    if (virDomainSetFibreChannelAppid(dom, (char *)appid, flags) < 0)
+        return false;
+
+    return true;
+}
+
+
 const vshCmdDef domManagementCmds[] = {
     {.name = "attach-device",
      .handler = cmdAttachDevice,
@@ -14715,5 +14774,11 @@ const vshCmdDef domManagementCmds[] = {
      .info = info_domdirtyrate_calc,
      .flags = 0
     },
+    {.name = "setappid",
+     .handler = cmdSetAppid,
+     .opts = opts_setappid,
+     .info = info_setappid,
+     .flags = 0
+    },
     {.name = NULL}
 };
-- 
2.31.1

Reply via email to