]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tools: add 'nodesevinfo' virsh command
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 8 Dec 2021 13:28:48 +0000 (08:28 -0500)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 14 Dec 2021 16:04:17 +0000 (16:04 +0000)
While some SEV info is reported in the domain capabilities,
for reasons of size, this excludes the certificates. The
nodesevinfo command provides the full set of information.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
docs/manpages/virsh.rst
tools/virsh-host.c

index 1a7421762527bb4c5cb0d8c7203b3ea1bf2fb367..e828f7ef683d68f12109e34de0ec2bc2fa136572 100644 (file)
@@ -479,6 +479,20 @@ Returns memory stats of the node.
 If *cell* is specified, this will print the specified cell statistics only.
 
 
+nodesevinfo
+-----------
+
+**Syntax:**
+
+::
+
+   nodesevinfo
+
+Reports information about the AMD SEV launch security features for
+the node, if any. Some of this information is also reported in the
+domain capabilities XML document.
+
+
 nodesuspend
 -----------
 
index 5da1346a9c01678769d4dfa65890f0a051fe4622..5ee3834de2c80c333daf2b860defacb29c129d93 100644 (file)
@@ -888,6 +888,45 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
     return true;
 }
 
+/*
+ * "nodesevinfo" command
+ */
+static const vshCmdInfo info_nodesevinfo[] = {
+    {.name = "help",
+     .data = N_("node SEV information")
+    },
+    {.name = "desc",
+     .data = N_("Returns basic SEV information about the node.")
+    },
+    {.name = NULL}
+};
+
+static bool
+cmdNodeSEVInfo(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED)
+{
+    virshControl *priv = ctl->privData;
+    size_t i;
+    int nparams = 0;
+    virTypedParameterPtr params = NULL;
+    bool ret = false;
+
+    if (virNodeGetSEVInfo(priv->conn, &params, &nparams, 0) != 0) {
+        vshError(ctl, "%s", _("Unable to get host SEV information"));
+        goto cleanup;
+    }
+
+    for (i = 0; i < nparams; i++) {
+        g_autofree char *str = vshGetTypedParamValue(ctl, &params[i]);
+        vshPrint(ctl, "%-18s: %s\n", params[i].field, str);
+    }
+
+    ret = true;
+
+ cleanup:
+    virTypedParamsFree(params, nparams);
+    return ret;
+}
+
 /*
  * "nodesuspend" command
  */
@@ -1828,6 +1867,12 @@ const vshCmdDef hostAndHypervisorCmds[] = {
      .info = info_nodememstats,
      .flags = 0
     },
+    {.name = "nodesevinfo",
+     .handler = cmdNodeSEVInfo,
+     .opts = NULL,
+     .info = info_nodesevinfo,
+     .flags = 0
+    },
     {.name = "nodesuspend",
      .handler = cmdNodeSuspend,
      .opts = opts_node_suspend,