Move qmp_query_sev_attestation_report() from monitor.c to sev.c
and make sev_get_attestation_report() static. We don't need the
stub anymore, remove it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
target/i386/sev_i386.h | 2 --
target/i386/monitor.c | 6 ------
target/i386/sev-sysemu-stub.c | 7 ++++---
target/i386/sev.c | 12 ++++++++++--
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h
index 2d9a1a0112e..5f367f78eb7 100644
--- a/target/i386/sev_i386.h
+++ b/target/i386/sev_i386.h
@@ -27,8 +27,6 @@
extern SevInfo *sev_get_info(void);
extern char *sev_get_launch_measurement(void);
extern SevCapability *sev_get_capabilities(Error **errp);
-extern SevAttestationReport *
-sev_get_attestation_report(const char *mnonce, Error **errp);
int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp);
int sev_inject_launch_secret(const char *hdr, const char *secret,
diff --git a/target/i386/monitor.c b/target/i386/monitor.c
index a9f85acd473..c05d70252a2 100644
--- a/target/i386/monitor.c
+++ b/target/i386/monitor.c
@@ -764,12 +764,6 @@ void qmp_sev_inject_launch_secret(const char *packet_hdr,
sev_inject_launch_secret(packet_hdr, secret, gpa, errp);
}
-SevAttestationReport *
-qmp_query_sev_attestation_report(const char *mnonce, Error **errp)
-{
- return sev_get_attestation_report(mnonce, errp);
-}
-
SGXInfo *qmp_query_sgx(Error **errp)
{
return sgx_get_info(errp);
diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c
index d556b4f091f..813b9a6a03b 100644
--- a/target/i386/sev-sysemu-stub.c
+++ b/target/i386/sev-sysemu-stub.c
@@ -13,6 +13,7 @@
#include "qemu/osdep.h"
#include "qapi/qapi-commands-misc-target.h"
+#include "qapi/qmp/qerror.h"
#include "qapi/error.h"
#include "sev_i386.h"
@@ -52,9 +53,9 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size)
g_assert_not_reached();
}
-SevAttestationReport *sev_get_attestation_report(const char *mnonce,
- Error **errp)
+SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
+ Error **errp)
{
- error_setg(errp, "SEV is not available in this QEMU");
+ error_setg(errp, QERR_UNSUPPORTED);
return NULL;
}
diff --git a/target/i386/sev.c b/target/i386/sev.c
index aefbef4bb63..91a217bbb85 100644
--- a/target/i386/sev.c
+++ b/target/i386/sev.c
@@ -31,6 +31,8 @@
#include "migration/blocker.h"
#include "qom/object.h"
#include "monitor/monitor.h"
+#include "qapi/qapi-commands-misc-target.h"
+#include "qapi/qmp/qerror.h"
#include "exec/confidential-guest-support.h"
#include "hw/i386/pc.h"
@@ -487,8 +489,8 @@ out:
return cap;
}
-SevAttestationReport *
-sev_get_attestation_report(const char *mnonce, Error **errp)
+static SevAttestationReport *sev_get_attestation_report(const char *mnonce,
+ Error **errp)
{
struct kvm_sev_attestation_report input = {};
SevAttestationReport *report = NULL;
@@ -549,6 +551,12 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
return report;
}
+SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
+ Error **errp)
+{
+ return sev_get_attestation_report(mnonce, errp);
+}
+
static int
sev_read_file_base64(const char *filename, guchar **data, gsize *len)
{
--
2.31.1
On 02/10/21 14:53, Philippe Mathieu-Daudé wrote:
> Move qmp_query_sev_attestation_report() from monitor.c to sev.c
> and make sev_get_attestation_report() static. We don't need the
> stub anymore, remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This was done on purpose, but I have no objection to changing it this
way. We might in fact remove the indirection for SGX as well, and/or
even move the implementation of the monitor commands from target/i386 to
hw/i386 (the monitor is sysemu-specific).
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks,
Paolo
> target/i386/sev_i386.h | 2 --
> target/i386/monitor.c | 6 ------
> target/i386/sev-sysemu-stub.c | 7 ++++---
> target/i386/sev.c | 12 ++++++++++--
> 4 files changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h
> index 2d9a1a0112e..5f367f78eb7 100644
> --- a/target/i386/sev_i386.h
> +++ b/target/i386/sev_i386.h
> @@ -27,8 +27,6 @@
> extern SevInfo *sev_get_info(void);
> extern char *sev_get_launch_measurement(void);
> extern SevCapability *sev_get_capabilities(Error **errp);
> -extern SevAttestationReport *
> -sev_get_attestation_report(const char *mnonce, Error **errp);
>
> int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp);
> int sev_inject_launch_secret(const char *hdr, const char *secret,
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index a9f85acd473..c05d70252a2 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -764,12 +764,6 @@ void qmp_sev_inject_launch_secret(const char *packet_hdr,
> sev_inject_launch_secret(packet_hdr, secret, gpa, errp);
> }
>
> -SevAttestationReport *
> -qmp_query_sev_attestation_report(const char *mnonce, Error **errp)
> -{
> - return sev_get_attestation_report(mnonce, errp);
> -}
> -
> SGXInfo *qmp_query_sgx(Error **errp)
> {
> return sgx_get_info(errp);
> diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c
> index d556b4f091f..813b9a6a03b 100644
> --- a/target/i386/sev-sysemu-stub.c
> +++ b/target/i386/sev-sysemu-stub.c
> @@ -13,6 +13,7 @@
>
> #include "qemu/osdep.h"
> #include "qapi/qapi-commands-misc-target.h"
> +#include "qapi/qmp/qerror.h"
> #include "qapi/error.h"
> #include "sev_i386.h"
>
> @@ -52,9 +53,9 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size)
> g_assert_not_reached();
> }
>
> -SevAttestationReport *sev_get_attestation_report(const char *mnonce,
> - Error **errp)
> +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
> + Error **errp)
> {
> - error_setg(errp, "SEV is not available in this QEMU");
> + error_setg(errp, QERR_UNSUPPORTED);
> return NULL;
> }
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index aefbef4bb63..91a217bbb85 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -31,6 +31,8 @@
> #include "migration/blocker.h"
> #include "qom/object.h"
> #include "monitor/monitor.h"
> +#include "qapi/qapi-commands-misc-target.h"
> +#include "qapi/qmp/qerror.h"
> #include "exec/confidential-guest-support.h"
> #include "hw/i386/pc.h"
>
> @@ -487,8 +489,8 @@ out:
> return cap;
> }
>
> -SevAttestationReport *
> -sev_get_attestation_report(const char *mnonce, Error **errp)
> +static SevAttestationReport *sev_get_attestation_report(const char *mnonce,
> + Error **errp)
> {
> struct kvm_sev_attestation_report input = {};
> SevAttestationReport *report = NULL;
> @@ -549,6 +551,12 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
> return report;
> }
>
> +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
> + Error **errp)
> +{
> + return sev_get_attestation_report(mnonce, errp);
> +}
> +
> static int
> sev_read_file_base64(const char *filename, guchar **data, gsize *len)
> {
>
On 10/4/21 10:23, Paolo Bonzini wrote: > On 02/10/21 14:53, Philippe Mathieu-Daudé wrote: >> Move qmp_query_sev_attestation_report() from monitor.c to sev.c >> and make sev_get_attestation_report() static. We don't need the >> stub anymore, remove it. >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > > This was done on purpose, but I have no objection to changing it this > way. We might in fact remove the indirection for SGX as well, and/or > even move the implementation of the monitor commands from target/i386 to > hw/i386 (the monitor is sysemu-specific). OK about SGX, but in another series, this one is already painful enough. Not sure about moving monitor to hw/, some commands expose hw info (like info pic) but some others expose architectural features (like info sev). > > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> > > Thanks, > > Paolo
* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> Move qmp_query_sev_attestation_report() from monitor.c to sev.c
> and make sev_get_attestation_report() static. We don't need the
> stub anymore, remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> target/i386/sev_i386.h | 2 --
> target/i386/monitor.c | 6 ------
> target/i386/sev-sysemu-stub.c | 7 ++++---
> target/i386/sev.c | 12 ++++++++++--
> 4 files changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h
> index 2d9a1a0112e..5f367f78eb7 100644
> --- a/target/i386/sev_i386.h
> +++ b/target/i386/sev_i386.h
> @@ -27,8 +27,6 @@
> extern SevInfo *sev_get_info(void);
> extern char *sev_get_launch_measurement(void);
> extern SevCapability *sev_get_capabilities(Error **errp);
> -extern SevAttestationReport *
> -sev_get_attestation_report(const char *mnonce, Error **errp);
>
> int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp);
> int sev_inject_launch_secret(const char *hdr, const char *secret,
> diff --git a/target/i386/monitor.c b/target/i386/monitor.c
> index a9f85acd473..c05d70252a2 100644
> --- a/target/i386/monitor.c
> +++ b/target/i386/monitor.c
> @@ -764,12 +764,6 @@ void qmp_sev_inject_launch_secret(const char *packet_hdr,
> sev_inject_launch_secret(packet_hdr, secret, gpa, errp);
> }
>
> -SevAttestationReport *
> -qmp_query_sev_attestation_report(const char *mnonce, Error **errp)
> -{
> - return sev_get_attestation_report(mnonce, errp);
> -}
> -
> SGXInfo *qmp_query_sgx(Error **errp)
> {
> return sgx_get_info(errp);
> diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c
> index d556b4f091f..813b9a6a03b 100644
> --- a/target/i386/sev-sysemu-stub.c
> +++ b/target/i386/sev-sysemu-stub.c
> @@ -13,6 +13,7 @@
>
> #include "qemu/osdep.h"
> #include "qapi/qapi-commands-misc-target.h"
> +#include "qapi/qmp/qerror.h"
> #include "qapi/error.h"
> #include "sev_i386.h"
>
> @@ -52,9 +53,9 @@ int sev_es_save_reset_vector(void *flash_ptr, uint64_t flash_size)
> g_assert_not_reached();
> }
>
> -SevAttestationReport *sev_get_attestation_report(const char *mnonce,
> - Error **errp)
> +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
> + Error **errp)
> {
> - error_setg(errp, "SEV is not available in this QEMU");
> + error_setg(errp, QERR_UNSUPPORTED);
I did like that message making it clear the reason it was unsupported
was this build, rather than lack of host support or not enabling it.
Dave
> return NULL;
> }
> diff --git a/target/i386/sev.c b/target/i386/sev.c
> index aefbef4bb63..91a217bbb85 100644
> --- a/target/i386/sev.c
> +++ b/target/i386/sev.c
> @@ -31,6 +31,8 @@
> #include "migration/blocker.h"
> #include "qom/object.h"
> #include "monitor/monitor.h"
> +#include "qapi/qapi-commands-misc-target.h"
> +#include "qapi/qmp/qerror.h"
> #include "exec/confidential-guest-support.h"
> #include "hw/i386/pc.h"
>
> @@ -487,8 +489,8 @@ out:
> return cap;
> }
>
> -SevAttestationReport *
> -sev_get_attestation_report(const char *mnonce, Error **errp)
> +static SevAttestationReport *sev_get_attestation_report(const char *mnonce,
> + Error **errp)
> {
> struct kvm_sev_attestation_report input = {};
> SevAttestationReport *report = NULL;
> @@ -549,6 +551,12 @@ sev_get_attestation_report(const char *mnonce, Error **errp)
> return report;
> }
>
> +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
> + Error **errp)
> +{
> + return sev_get_attestation_report(mnonce, errp);
> +}
> +
> static int
> sev_read_file_base64(const char *filename, guchar **data, gsize *len)
> {
> --
> 2.31.1
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
On 10/4/21 11:57, Dr. David Alan Gilbert wrote:
> * Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
>> Move qmp_query_sev_attestation_report() from monitor.c to sev.c
>> and make sev_get_attestation_report() static. We don't need the
>> stub anymore, remove it.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> target/i386/sev_i386.h | 2 --
>> target/i386/monitor.c | 6 ------
>> target/i386/sev-sysemu-stub.c | 7 ++++---
>> target/i386/sev.c | 12 ++++++++++--
>> 4 files changed, 14 insertions(+), 13 deletions(-)
>> -SevAttestationReport *sev_get_attestation_report(const char *mnonce,
>> - Error **errp)
>> +SevAttestationReport *qmp_query_sev_attestation_report(const char *mnonce,
>> + Error **errp)
>> {
>> - error_setg(errp, "SEV is not available in this QEMU");
>> + error_setg(errp, QERR_UNSUPPORTED);
>
> I did like that message making it clear the reason it was unsupported
> was this build, rather than lack of host support or not enabling it.
Yep, no reason to change it, besides, QERR_UNSUPPORTED is deprecated
since 2015! (commit 4629ed1e989):
/*
* These macros will go away, please don't use in new code, and do not
* add new ones!
*/
I suppose this is a rebase mistake, thanks for catching it!
Phil.
© 2016 - 2026 Red Hat, Inc.