diff mbox

[RFC,v1,13/22] hmp: update 'info kvm' to display SEV status

Message ID 147377813927.11859.13242503366595564820.stgit@brijesh-build-machine (mailing list archive)
State New, archived
Headers show

Commit Message

Brijesh Singh Sept. 13, 2016, 2:48 p.m. UTC
Update the 'info kvm' monitor command to display the SEV status.

(qemu) info kvm
kvm support: enabled
sev support: enabled (running)

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
---
 hmp.c            |   14 ++++++++++++++
 qapi-schema.json |    4 +++-
 qmp.c            |    1 +
 3 files changed, 18 insertions(+), 1 deletion(-)

Comments

Eric Blake Sept. 13, 2016, 4:09 p.m. UTC | #1
On 09/13/2016 09:48 AM, Brijesh Singh wrote:
> Update the 'info kvm' monitor command to display the SEV status.
> 
> (qemu) info kvm
> kvm support: enabled
> sev support: enabled (running)
> 
> Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
> ---

> +++ b/qapi-schema.json
> @@ -99,9 +99,11 @@
>  #
>  # @present: true if KVM acceleration is built into this executable
>  #
> +# @sev: true if SEV is active

Worth expanding what the acronym stands for.  Also needs a '(since 2.8)'
designator.

> +#
>  # Since: 0.14.0
>  ##
> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool', 'sev' : 'bool'} }

Long line; please wrap to keep it under 80 columns.
Paolo Bonzini Sept. 13, 2016, 11:01 p.m. UTC | #2
On 13/09/2016 16:48, Brijesh Singh wrote:
>  #
> +# @sev: true if SEV is active

You should add "(Since 2.8.0)" here.

Paolo

>  # Since: 0.14.0
>  ##
> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool', 'sev' : 'bool'} }
>
Brijesh Singh Sept. 14, 2016, 4:16 p.m. UTC | #3
Hi Eric,

Thanks for feedback.

>>  # @present: true if KVM acceleration is built into this executable
>>  #
>> +# @sev: true if SEV is active
>
> Worth expanding what the acronym stands for.  Also needs a '(since 2.8)'
> designator.
>
will fix in v2.

>> +#
>>  # Since: 0.14.0
>>  ##
>> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
>> +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool', 'sev' : 'bool'} }
>
> Long line; please wrap to keep it under 80 columns.
>
will fix in v2.
Michael S. Tsirkin Sept. 15, 2016, 4:13 a.m. UTC | #4
On Wed, Sep 14, 2016 at 11:16:12AM -0500, Brijesh Singh wrote:
> Hi Eric,
> 
> Thanks for feedback.
> 
> > >  # @present: true if KVM acceleration is built into this executable
> > >  #
> > > +# @sev: true if SEV is active
> > 
> > Worth expanding what the acronym stands for.  Also needs a '(since 2.8)'
> > designator.
> > 
> will fix in v2.
> 
> > > +#
> > >  # Since: 0.14.0
> > >  ##
> > > -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> > > +{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool', 'sev' : 'bool'} }
> > 
> > Long line; please wrap to keep it under 80 columns.
> > 
> will fix in v2.

So memory-encryption : bool
Etc everywhere.
diff mbox

Patch

diff --git a/hmp.c b/hmp.c
index cc2056e..068b77d 100644
--- a/hmp.c
+++ b/hmp.c
@@ -18,6 +18,7 @@ 
 #include "net/net.h"
 #include "net/eth.h"
 #include "sysemu/char.h"
+#include "sysemu/sev.h"
 #include "sysemu/block-backend.h"
 #include "qemu/option.h"
 #include "qemu/timer.h"
@@ -76,11 +77,24 @@  void hmp_info_version(Monitor *mon, const QDict *qdict)
 void hmp_info_kvm(Monitor *mon, const QDict *qdict)
 {
     KvmInfo *info;
+    SevState state;
+    char msg[80] = {0};
 
     info = qmp_query_kvm(NULL);
     monitor_printf(mon, "kvm support: ");
     if (info->present) {
         monitor_printf(mon, "%s\n", info->enabled ? "enabled" : "disabled");
+        monitor_printf(mon, "sev support: %s",
+                        info->sev ? "enabled" : "disabled");
+        if (info->sev) {
+            if (kvm_sev_get_status(&state, msg)) {
+                monitor_printf(mon, " (error)\n");
+            } else {
+                monitor_printf(mon, " (%s)\n", msg);
+            }
+        } else {
+            monitor_printf(mon, "\n");
+        }
     } else {
         monitor_printf(mon, "not compiled\n");
     }
diff --git a/qapi-schema.json b/qapi-schema.json
index 5658723..86b5dc9 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -99,9 +99,11 @@ 
 #
 # @present: true if KVM acceleration is built into this executable
 #
+# @sev: true if SEV is active
+#
 # Since: 0.14.0
 ##
-{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
+{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool', 'sev' : 'bool'} }
 
 ##
 # @query-kvm:
diff --git a/qmp.c b/qmp.c
index b6d531e..834edb8 100644
--- a/qmp.c
+++ b/qmp.c
@@ -77,6 +77,7 @@  KvmInfo *qmp_query_kvm(Error **errp)
 
     info->enabled = kvm_enabled();
     info->present = kvm_available();
+    info->sev = kvm_sev_enabled();
 
     return info;
 }