[libvirt] [PATCH] qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify

Peter Krempa posted 1 patch 13 weeks ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/99cdb72be49eb7335474c9a274cac7466dcbc18c.1560340419.git.pkrempa@redhat.com
src/qemu/qemu_domain.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

[libvirt] [PATCH] qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify

Posted by Peter Krempa 13 weeks ago
Log the flags passed to the function in a exploded state so that it's
easily visible what's happening to the image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_domain.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2095191cde..d28cfa4f42 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9339,6 +9339,9 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
     int ret = -1;
     virErrorPtr orig_err = NULL;
     bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
+    bool force_ro = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY;
+    bool force_rw = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE;
+    bool revoke = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE;
     int rc;
     bool was_readonly = src->readonly;
     bool revoke_cgroup = false;
@@ -9346,14 +9349,18 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
     bool revoke_namespace = false;
     bool revoke_lockspace = false;

-    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY)
+    VIR_DEBUG("VM: '%s', src: '%s', readonly: '%d, force_ro: '%d', force_rw: '%d', revoke: '%d', chain: '%d'",
+              vm->def->name, NULLSTR(src->path), src->readonly, force_ro,
+              force_rw, revoke, chain);
+
+    if (force_ro)
         src->readonly = true;

-    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE)
+    if (force_rw)
         src->readonly = false;

     /* just tear down the disk access */
-    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE) {
+    if (revoke) {
         virErrorPreserveLast(&orig_err);
         revoke_cgroup = true;
         revoke_label = true;
-- 
2.21.0

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

Re: [libvirt] [PATCH] qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify

Posted by Bjoern Walk 13 weeks ago
Peter Krempa <pkrempa@redhat.com> [2019-06-12, 01:53PM +0200]:
> Log the flags passed to the function in a exploded state so that it's
> easily visible what's happening to the image.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 2095191cde..d28cfa4f42 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -9339,6 +9339,9 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
>      int ret = -1;
>      virErrorPtr orig_err = NULL;
>      bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
> +    bool force_ro = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY;
> +    bool force_rw = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE;
> +    bool revoke = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE;
>      int rc;
>      bool was_readonly = src->readonly;
>      bool revoke_cgroup = false;
> @@ -9346,14 +9349,18 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
>      bool revoke_namespace = false;
>      bool revoke_lockspace = false;
> 
> -    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY)
> +    VIR_DEBUG("VM: '%s', src: '%s', readonly: '%d, force_ro: '%d', force_rw: '%d', revoke: '%d', chain: '%d'",

Almost everywhere we use the syntax key=value when logging, so I'd
prefer this here as well.

-- 
IBM Systems
Linux on Z & Virtualization Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
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] qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify

Posted by Peter Krempa 13 weeks ago
On Wed, Jun 12, 2019 at 14:17:48 +0200, Bjoern Walk wrote:
> Peter Krempa <pkrempa@redhat.com> [2019-06-12, 01:53PM +0200]:
> > Log the flags passed to the function in a exploded state so that it's
> > easily visible what's happening to the image.
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> >  src/qemu/qemu_domain.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> > index 2095191cde..d28cfa4f42 100644
> > --- a/src/qemu/qemu_domain.c
> > +++ b/src/qemu/qemu_domain.c
> > @@ -9339,6 +9339,9 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
> >      int ret = -1;
> >      virErrorPtr orig_err = NULL;
> >      bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
> > +    bool force_ro = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY;
> > +    bool force_rw = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE;
> > +    bool revoke = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE;
> >      int rc;
> >      bool was_readonly = src->readonly;
> >      bool revoke_cgroup = false;
> > @@ -9346,14 +9349,18 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
> >      bool revoke_namespace = false;
> >      bool revoke_lockspace = false;
> > 
> > -    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY)
> > +    VIR_DEBUG("VM: '%s', src: '%s', readonly: '%d, force_ro: '%d', force_rw: '%d', revoke: '%d', chain: '%d'",
> 
> Almost everywhere we use the syntax key=value when logging, so I'd
> prefer this here as well.

I agree I changed it along with dropping the 'VM' part and fixing the
quote on readonly as suggested by Jano in the other review.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify

Posted by Ján Tomko 13 weeks ago
On Wed, Jun 12, 2019 at 01:53:39PM +0200, Peter Krempa wrote:
>Log the flags passed to the function in a exploded state so that it's

s/a exploded/an exploded/

>easily visible what's happening to the image.
>
>Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>---
> src/qemu/qemu_domain.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
>diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
>index 2095191cde..d28cfa4f42 100644
>--- a/src/qemu/qemu_domain.c
>+++ b/src/qemu/qemu_domain.c
>@@ -9339,6 +9339,9 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
>     int ret = -1;
>     virErrorPtr orig_err = NULL;
>     bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
>+    bool force_ro = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY;
>+    bool force_rw = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE;
>+    bool revoke = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE;
>     int rc;
>     bool was_readonly = src->readonly;
>     bool revoke_cgroup = false;
>@@ -9346,14 +9349,18 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
>     bool revoke_namespace = false;
>     bool revoke_lockspace = false;
>
>-    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY)
>+    VIR_DEBUG("VM: '%s', src: '%s', readonly: '%d, force_ro: '%d', force_rw: '%d', revoke: '%d', chain: '%d'",

We usually use lowercase 'vm' in the logs. Also, the readonly attribue
has a mismatched attribute.

How about the more compact format we use elsewhere:
    VIR_DEBUG("VM='%s', src='%s', readonly=%d force_ro=%d force_rw=%d revoke=%d chain=%d".

>+              vm->def->name, NULLSTR(src->path), src->readonly, force_ro,
>+              force_rw, revoke, chain);
>+

Reviewed-by: Ján Tomko <jtomko@redhat.com>

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

Re: [libvirt] [PATCH] qemu: domain: Log some useful data in qemuDomainStorageSourceAccessModify

Posted by Peter Krempa 13 weeks ago
On Wed, Jun 12, 2019 at 14:15:02 +0200, Ján Tomko wrote:
> On Wed, Jun 12, 2019 at 01:53:39PM +0200, Peter Krempa wrote:
> > Log the flags passed to the function in a exploded state so that it's
> 
> s/a exploded/an exploded/
> 
> > easily visible what's happening to the image.
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> > src/qemu/qemu_domain.c | 13 ++++++++++---
> > 1 file changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> > index 2095191cde..d28cfa4f42 100644
> > --- a/src/qemu/qemu_domain.c
> > +++ b/src/qemu/qemu_domain.c
> > @@ -9339,6 +9339,9 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
> >     int ret = -1;
> >     virErrorPtr orig_err = NULL;
> >     bool chain = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_CHAIN;
> > +    bool force_ro = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY;
> > +    bool force_rw = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_WRITE;
> > +    bool revoke = flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_REVOKE;
> >     int rc;
> >     bool was_readonly = src->readonly;
> >     bool revoke_cgroup = false;
> > @@ -9346,14 +9349,18 @@ qemuDomainStorageSourceAccessModify(virQEMUDriverPtr driver,
> >     bool revoke_namespace = false;
> >     bool revoke_lockspace = false;
> > 
> > -    if (flags & QEMU_DOMAIN_STORAGE_SOURCE_ACCESS_FORCE_READ_ONLY)
> > +    VIR_DEBUG("VM: '%s', src: '%s', readonly: '%d, force_ro: '%d', force_rw: '%d', revoke: '%d', chain: '%d'",
> 
> We usually use lowercase 'vm' in the logs. Also, the readonly attribue
> has a mismatched attribute.
> 
> How about the more compact format we use elsewhere:
>    VIR_DEBUG("VM='%s', src='%s', readonly=%d force_ro=%d force_rw=%d revoke=%d chain=%d".

Okay, I'll also drop the VM since it's not necessary as you can figure
it from the context of the logs quite easily.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list