[libvirt] [PATCH] qemu: ignore query-sev-capabilities errors

Ján Tomko posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/42a835982286d48dde1c69417b2245bb56783f5f.1528962001.git.jtomko@redhat.com
Test syntax-check passed
src/qemu/qemu_monitor_json.c | 6 ++++++
1 file changed, 6 insertions(+)
[libvirt] [PATCH] qemu: ignore query-sev-capabilities errors
Posted by Ján Tomko 5 years, 10 months ago
The query-sev-capabilities command fails if SEV is not compiled in,
even though both the command and -object sev-guest are present
in that case :/

Ignore the errors to avoid spamming the logs:
internal error: unable to execute QEMU command 'query-sev-capabilities': SEV feature is not available

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_monitor_json.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c5480a2d0e..aa89ea7056 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6423,6 +6423,12 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
     if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
         goto cleanup;
 
+    /* Both -object sev-guest and query-sev-capabilities can be present
+     * even if SEV is not available */
+    if (qemuMonitorJSONHasError(reply, "GenericError")) {
+        ret = 0;
+        goto cleanup;
+    }
 
     if (qemuMonitorJSONCheckError(cmd, reply) < 0)
         goto cleanup;
-- 
2.16.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: ignore query-sev-capabilities errors
Posted by Daniel P. Berrangé 5 years, 10 months ago
On Thu, Jun 14, 2018 at 09:40:04AM +0200, Ján Tomko wrote:
> The query-sev-capabilities command fails if SEV is not compiled in,
> even though both the command and -object sev-guest are present
> in that case :/
> 
> Ignore the errors to avoid spamming the logs:
> internal error: unable to execute QEMU command 'query-sev-capabilities': SEV feature is not available
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_monitor_json.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index c5480a2d0e..aa89ea7056 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -6423,6 +6423,12 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
>      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
>          goto cleanup;
>  
> +    /* Both -object sev-guest and query-sev-capabilities can be present
> +     * even if SEV is not available */
> +    if (qemuMonitorJSONHasError(reply, "GenericError")) {

I wish QEMU has a nice "NotAvailable" error so we could distinguish it
from genuine errors :-(

> +        ret = 0;
> +        goto cleanup;
> +    }
>  
>      if (qemuMonitorJSONCheckError(cmd, reply) < 0)
>          goto cleanup;

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: ignore query-sev-capabilities errors
Posted by Peter Krempa 5 years, 10 months ago
On Thu, Jun 14, 2018 at 09:04:09 +0100, Daniel Berrange wrote:
> On Thu, Jun 14, 2018 at 09:40:04AM +0200, Ján Tomko wrote:
> > The query-sev-capabilities command fails if SEV is not compiled in,
> > even though both the command and -object sev-guest are present
> > in that case :/
> > 
> > Ignore the errors to avoid spamming the logs:
> > internal error: unable to execute QEMU command 'query-sev-capabilities': SEV feature is not available
> > 
> > Signed-off-by: Ján Tomko <jtomko@redhat.com>
> > ---
> >  src/qemu/qemu_monitor_json.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> 
> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> 
> > diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> > index c5480a2d0e..aa89ea7056 100644
> > --- a/src/qemu/qemu_monitor_json.c
> > +++ b/src/qemu/qemu_monitor_json.c
> > @@ -6423,6 +6423,12 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
> >      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
> >          goto cleanup;
> >  
> > +    /* Both -object sev-guest and query-sev-capabilities can be present
> > +     * even if SEV is not available */
> > +    if (qemuMonitorJSONHasError(reply, "GenericError")) {
> 
> I wish QEMU has a nice "NotAvailable" error so we could distinguish it
> from genuine errors :-(

Well, in this case it seems like not advertising the command at all if
SEV is not compiled in would be a better option.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: ignore query-sev-capabilities errors
Posted by Andrea Bolognani 5 years, 10 months ago
On Thu, 2018-06-14 at 09:40 +0200, Ján Tomko wrote:
> The query-sev-capabilities command fails if SEV is not compiled in,
> even though both the command and -object sev-guest are present
> in that case :/
> 
> Ignore the errors to avoid spamming the logs:
> internal error: unable to execute QEMU command 'query-sev-capabilities': SEV feature is not available
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  src/qemu/qemu_monitor_json.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index c5480a2d0e..aa89ea7056 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -6423,6 +6423,12 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
>      if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
>          goto cleanup;
>  
> +    /* Both -object sev-guest and query-sev-capabilities can be present
> +     * even if SEV is not available */
> +    if (qemuMonitorJSONHasError(reply, "GenericError")) {
> +        ret = 0;
> +        goto cleanup;
> +    }
>  
>      if (qemuMonitorJSONCheckError(cmd, reply) < 0)
>          goto cleanup;

Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list