Skip to content

Commit aa39501

Browse files
philmdbonzini
authored andcommitted
target/i386/sev: Move qmp_query_sev() & hmp_info_sev() to sev.c
Move qmp_query_sev() & hmp_info_sev()() from monitor.c to sev.c and make sev_get_info() static. We don't need the stub anymore, remove it. Add a stub for hmp_info_sev(). Reviewed-by: Paolo Bonzini <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0875a70 commit aa39501

File tree

4 files changed

+45
-40
lines changed

4 files changed

+45
-40
lines changed

target/i386/monitor.c

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include "qapi/qmp/qerror.h"
3232
#include "sysemu/kvm.h"
3333
#include "qapi/error.h"
34-
#include "sev.h"
3534
#include "qapi/qapi-commands-misc-target.h"
3635
#include "qapi/qapi-commands-misc.h"
3736
#include "hw/i386/pc.h"
@@ -676,40 +675,6 @@ void hmp_info_io_apic(Monitor *mon, const QDict *qdict)
676675
"removed soon. Please use 'info pic' instead.\n");
677676
}
678677

679-
SevInfo *qmp_query_sev(Error **errp)
680-
{
681-
SevInfo *info;
682-
683-
info = sev_get_info();
684-
if (!info) {
685-
error_setg(errp, "SEV feature is not available");
686-
return NULL;
687-
}
688-
689-
return info;
690-
}
691-
692-
void hmp_info_sev(Monitor *mon, const QDict *qdict)
693-
{
694-
SevInfo *info = sev_get_info();
695-
696-
if (info && info->enabled) {
697-
monitor_printf(mon, "handle: %d\n", info->handle);
698-
monitor_printf(mon, "state: %s\n", SevState_str(info->state));
699-
monitor_printf(mon, "build: %d\n", info->build_id);
700-
monitor_printf(mon, "api version: %d.%d\n",
701-
info->api_major, info->api_minor);
702-
monitor_printf(mon, "debug: %s\n",
703-
info->policy & SEV_POLICY_NODBG ? "off" : "on");
704-
monitor_printf(mon, "key-sharing: %s\n",
705-
info->policy & SEV_POLICY_NOKS ? "off" : "on");
706-
} else {
707-
monitor_printf(mon, "SEV is not enabled\n");
708-
}
709-
710-
qapi_free_SevInfo(info);
711-
}
712-
713678
SGXInfo *qmp_query_sgx(Error **errp)
714679
{
715680
return sgx_get_info(errp);

target/i386/sev-sysemu-stub.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
*/
1313

1414
#include "qemu/osdep.h"
15+
#include "monitor/monitor.h"
16+
#include "monitor/hmp.h"
1517
#include "qapi/qapi-commands-misc-target.h"
1618
#include "qapi/qmp/qerror.h"
1719
#include "qapi/error.h"
1820
#include "sev.h"
1921

20-
SevInfo *sev_get_info(void)
22+
SevInfo *qmp_query_sev(Error **errp)
2123
{
24+
error_setg(errp, "SEV is not available in this QEMU");
2225
return NULL;
2326
}
2427

@@ -60,3 +63,8 @@ SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
6063
error_setg(errp, "SEV is not available in this QEMU");
6164
return NULL;
6265
}
66+
67+
void hmp_info_sev(Monitor *mon, const QDict *qdict)
68+
{
69+
monitor_printf(mon, "SEV is not available in this QEMU\n");
70+
}

target/i386/sev.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "migration/blocker.h"
3333
#include "qom/object.h"
3434
#include "monitor/monitor.h"
35+
#include "monitor/hmp.h"
3536
#include "qapi/qapi-commands-misc-target.h"
3637
#include "qapi/qmp/qerror.h"
3738
#include "exec/confidential-guest-support.h"
@@ -402,8 +403,7 @@ sev_get_reduced_phys_bits(void)
402403
return sev_guest ? sev_guest->reduced_phys_bits : 0;
403404
}
404405

405-
SevInfo *
406-
sev_get_info(void)
406+
static SevInfo *sev_get_info(void)
407407
{
408408
SevInfo *info;
409409

@@ -422,6 +422,40 @@ sev_get_info(void)
422422
return info;
423423
}
424424

425+
SevInfo *qmp_query_sev(Error **errp)
426+
{
427+
SevInfo *info;
428+
429+
info = sev_get_info();
430+
if (!info) {
431+
error_setg(errp, "SEV feature is not available");
432+
return NULL;
433+
}
434+
435+
return info;
436+
}
437+
438+
void hmp_info_sev(Monitor *mon, const QDict *qdict)
439+
{
440+
SevInfo *info = sev_get_info();
441+
442+
if (info && info->enabled) {
443+
monitor_printf(mon, "handle: %d\n", info->handle);
444+
monitor_printf(mon, "state: %s\n", SevState_str(info->state));
445+
monitor_printf(mon, "build: %d\n", info->build_id);
446+
monitor_printf(mon, "api version: %d.%d\n",
447+
info->api_major, info->api_minor);
448+
monitor_printf(mon, "debug: %s\n",
449+
info->policy & SEV_POLICY_NODBG ? "off" : "on");
450+
monitor_printf(mon, "key-sharing: %s\n",
451+
info->policy & SEV_POLICY_NOKS ? "off" : "on");
452+
} else {
453+
monitor_printf(mon, "SEV is not enabled\n");
454+
}
455+
456+
qapi_free_SevInfo(info);
457+
}
458+
425459
static int
426460
sev_get_pdh_info(int fd, guchar **pdh, size_t *pdh_len, guchar **cert_chain,
427461
size_t *cert_chain_len, Error **errp)

target/i386/sev.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#endif
2020

2121
#include "exec/confidential-guest-support.h"
22-
#include "qapi/qapi-types-misc-target.h"
2322

2423
#define SEV_POLICY_NODBG 0x1
2524
#define SEV_POLICY_NOKS 0x2
@@ -47,7 +46,6 @@ bool sev_es_enabled(void);
4746
#define sev_es_enabled() 0
4847
#endif
4948

50-
extern SevInfo *sev_get_info(void);
5149
extern uint32_t sev_get_cbit_position(void);
5250
extern uint32_t sev_get_reduced_phys_bits(void);
5351
extern bool sev_add_kernel_loader_hashes(SevKernelLoaderContext *ctx, Error **errp);

0 commit comments

Comments
 (0)