[libvirt] [PATCH] util: audit: Fix the error code when kernel lacks audit support

Erik Skultety posted 1 patch 5 years, 2 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/b67f855553ba861893342a80365970947356ba8a.1547564886.git.eskultet@redhat.com
src/util/viraudit.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] util: audit: Fix the error code when kernel lacks audit support
Posted by Erik Skultety 5 years, 2 months ago
When commit 4199c2f221c tweaked the error path of virAuditOpen it used
VIR_FROM_THIS as the error code to virReportError.

https://bugzilla.redhat.com/show_bug.cgi?id=1596119

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 src/util/viraudit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/viraudit.c b/src/util/viraudit.c
index a02e5b36fd..d04343a542 100644
--- a/src/util/viraudit.c
+++ b/src/util/viraudit.c
@@ -66,7 +66,8 @@ int virAuditOpen(unsigned int audit_level ATTRIBUTE_UNUSED)
             if (audit_level < 2)
                 VIR_INFO("Audit is not supported by the kernel");
             else
-                virReportError(VIR_FROM_THIS, "%s", _("Audit is not supported by the kernel"));
+                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                               _("Audit is not supported by the kernel"));
         } else {
             virReportSystemError(errno, "%s", _("Unable to initialize audit layer"));
         }
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: audit: Fix the error code when kernel lacks audit support
Posted by Marc Hartmayer 5 years, 2 months ago
On Tue, Jan 15, 2019 at 04:08 PM +0100, Erik Skultety <eskultet@redhat.com> wrote:
> When commit 4199c2f221c tweaked the error path of virAuditOpen it used
> VIR_FROM_THIS as the error code to virReportError.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1596119
>
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  src/util/viraudit.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/util/viraudit.c b/src/util/viraudit.c
> index a02e5b36fd..d04343a542 100644
> --- a/src/util/viraudit.c
> +++ b/src/util/viraudit.c
> @@ -66,7 +66,8 @@ int virAuditOpen(unsigned int audit_level ATTRIBUTE_UNUSED)
>              if (audit_level < 2)
>                  VIR_INFO("Audit is not supported by the kernel");
>              else
> -                virReportError(VIR_FROM_THIS, "%s", _("Audit is not supported by the kernel"));
> +                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                               _("Audit is not supported by the kernel"));
>          } else {
>              virReportSystemError(errno, "%s", _("Unable to initialize audit layer"));
>          }
> --
> 2.20.1
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>

Thanks for fixing!

Reviewed-by: Marc Hartmayer <mhartmay@linux.ibm.com>

--
Kind regards / Beste Grüße
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: audit: Fix the error code when kernel lacks audit support
Posted by Peter Krempa 5 years, 2 months ago
On Tue, Jan 15, 2019 at 16:08:24 +0100, Erik Skultety wrote:
> When commit 4199c2f221c tweaked the error path of virAuditOpen it used
> VIR_FROM_THIS as the error code to virReportError.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1596119
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  src/util/viraudit.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/viraudit.c b/src/util/viraudit.c
> index a02e5b36fd..d04343a542 100644
> --- a/src/util/viraudit.c
> +++ b/src/util/viraudit.c
> @@ -66,7 +66,8 @@ int virAuditOpen(unsigned int audit_level ATTRIBUTE_UNUSED)
>              if (audit_level < 2)
>                  VIR_INFO("Audit is not supported by the kernel");
>              else
> -                virReportError(VIR_FROM_THIS, "%s", _("Audit is not supported by the kernel"));
> +                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                               _("Audit is not supported by the kernel"));

Isn't "VIR_ERR_CONFIG_UNSUPPORTED" more appropriate as it's an option
which is set by libvirtd.conf?
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: audit: Fix the error code when kernel lacks audit support
Posted by Erik Skultety 5 years, 2 months ago
On Tue, Jan 15, 2019 at 04:25:51PM +0100, Peter Krempa wrote:
> On Tue, Jan 15, 2019 at 16:08:24 +0100, Erik Skultety wrote:
> > When commit 4199c2f221c tweaked the error path of virAuditOpen it used
> > VIR_FROM_THIS as the error code to virReportError.
> >
> > https://bugzilla.redhat.com/show_bug.cgi?id=1596119
> >
> > Signed-off-by: Erik Skultety <eskultet@redhat.com>
> > ---
> >  src/util/viraudit.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/util/viraudit.c b/src/util/viraudit.c
> > index a02e5b36fd..d04343a542 100644
> > --- a/src/util/viraudit.c
> > +++ b/src/util/viraudit.c
> > @@ -66,7 +66,8 @@ int virAuditOpen(unsigned int audit_level ATTRIBUTE_UNUSED)
> >              if (audit_level < 2)
> >                  VIR_INFO("Audit is not supported by the kernel");
> >              else
> > -                virReportError(VIR_FROM_THIS, "%s", _("Audit is not supported by the kernel"));
> > +                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > +                               _("Audit is not supported by the kernel"));
>
> Isn't "VIR_ERR_CONFIG_UNSUPPORTED" more appropriate as it's an option
> which is set by libvirtd.conf?

But the audit_log=2 is a supported configuration.

Erik


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] util: audit: Fix the error code when kernel lacks audit support
Posted by Daniel P. Berrangé 5 years, 2 months ago
On Tue, Jan 15, 2019 at 04:51:59PM +0100, Erik Skultety wrote:
> On Tue, Jan 15, 2019 at 04:25:51PM +0100, Peter Krempa wrote:
> > On Tue, Jan 15, 2019 at 16:08:24 +0100, Erik Skultety wrote:
> > > When commit 4199c2f221c tweaked the error path of virAuditOpen it used
> > > VIR_FROM_THIS as the error code to virReportError.
> > >
> > > https://bugzilla.redhat.com/show_bug.cgi?id=1596119
> > >
> > > Signed-off-by: Erik Skultety <eskultet@redhat.com>
> > > ---
> > >  src/util/viraudit.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/src/util/viraudit.c b/src/util/viraudit.c
> > > index a02e5b36fd..d04343a542 100644
> > > --- a/src/util/viraudit.c
> > > +++ b/src/util/viraudit.c
> > > @@ -66,7 +66,8 @@ int virAuditOpen(unsigned int audit_level ATTRIBUTE_UNUSED)
> > >              if (audit_level < 2)
> > >                  VIR_INFO("Audit is not supported by the kernel");
> > >              else
> > > -                virReportError(VIR_FROM_THIS, "%s", _("Audit is not supported by the kernel"));
> > > +                virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > > +                               _("Audit is not supported by the kernel"));
> >
> > Isn't "VIR_ERR_CONFIG_UNSUPPORTED" more appropriate as it's an option
> > which is set by libvirtd.conf?
> 
> But the audit_log=2 is a supported configuration.

The original code reported a system error - I'm inclinde to say
we should use that again, since errno is relevant for telling the
user why it was not supported


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