Eric Blake
2022-Feb-21 16:59 UTC
[Libguestfs] [nbdkit PATCH] log: Implement .block_size callback
Enhance the amount of information logged during connection.
---
filters/log/nbdkit-log-filter.pod | 2 +-
filters/log/log.c | 12 ++++++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/filters/log/nbdkit-log-filter.pod
b/filters/log/nbdkit-log-filter.pod
index dd04f1ab..e0a0c209 100644
--- a/filters/log/nbdkit-log-filter.pod
+++ b/filters/log/nbdkit-log-filter.pod
@@ -81,7 +81,7 @@ before performing a single successful read is:
2020-08-06 02:07:23.080415 ListExports id=1 readonly=0 tls=0 ...
2020-08-06 02:07:23.080502 ...ListExports id=1 exports=("") return=0
- 2020-08-06 02:07:23.080712 connection=1 Connect export="" tls=0
size=0x400 write=1 flush=1 rotational=0 trim=1 zero=2 fua=2 extents=1 cache=2
fast_zero=1
+ 2020-08-06 02:07:23.080712 connection=1 Connect export="" tls=0
size=0x400 minsize=0x1 prefsize=0x200 maxsize=0xffffffff write=1 flush=1
rotational=0 trim=1 zero=2 fua=2 extents=1 cache=2 fast_zero=1
2020-08-06 02:07:23.080907 connection=1 Read id=1 offset=0x0 count=0x200 ...
2020-08-06 02:07:23.080927 connection=1 ...Read id=1 return=0
2020-08-06 02:07:23.081255 connection=1 Disconnect transactions=1
diff --git a/filters/log/log.c b/filters/log/log.c
index acc9d77e..4255f85f 100644
--- a/filters/log/log.c
+++ b/filters/log/log.c
@@ -1,5 +1,5 @@
/* nbdkit
- * Copyright (C) 2018-2020 Red Hat Inc.
+ * Copyright (C) 2018-2022 Red Hat Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -251,6 +251,7 @@ log_prepare (nbdkit_next *next, void *handle,
struct handle *h = handle;
const char *exportname = h->exportname;
int64_t size = next->get_size (next);
+ uint32_t minsize, prefsize, maxsize;
int w = next->can_write (next);
int f = next->can_flush (next);
int r = next->is_rotational (next);
@@ -260,9 +261,10 @@ log_prepare (nbdkit_next *next, void *handle,
int e = next->can_extents (next);
int c = next->can_cache (next);
int Z = next->can_fast_zero (next);
+ int s = next->block_size (next, &minsize, &prefsize,
&maxsize);
if (size < 0 || w < 0 || f < 0 || r < 0 || t < 0 || z < 0
|| F < 0 ||
- e < 0 || c < 0 || Z < 0)
+ e < 0 || c < 0 || Z < 0 || s < 0)
return -1;
fp = open_memstream (&str, &len);
@@ -270,10 +272,12 @@ log_prepare (nbdkit_next *next, void *handle,
fprintf (fp, "export=");
shell_quote (exportname, fp);
fprintf (fp,
- " tls=%d size=0x%" PRIx64 " write=%d "
+ " tls=%d size=0x%" PRIx64 " minsize=0x%"
PRIx32 " prefsize=0x%"
+ PRIx32 " maxsize=0x%" PRIx32 " write=%d "
"flush=%d rotational=%d trim=%d zero=%d fua=%d extents=%d
"
"cache=%d fast_zero=%d",
- h->tls, size, w, f, r, t, z, F, e, c, Z);
+ h->tls, size, minsize, prefsize, maxsize,
+ w, f, r, t, z, F, e, c, Z);
fclose (fp);
print (h, "Connect", "%s", str);
}
--
2.35.1
Richard W.M. Jones
2022-Feb-21 19:32 UTC
[Libguestfs] [nbdkit PATCH] log: Implement .block_size callback
On Mon, Feb 21, 2022 at 10:59:39AM -0600, Eric Blake wrote:> Enhance the amount of information logged during connection. > --- > filters/log/nbdkit-log-filter.pod | 2 +- > filters/log/log.c | 12 ++++++++---- > 2 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/filters/log/nbdkit-log-filter.pod b/filters/log/nbdkit-log-filter.pod > index dd04f1ab..e0a0c209 100644 > --- a/filters/log/nbdkit-log-filter.pod > +++ b/filters/log/nbdkit-log-filter.pod > @@ -81,7 +81,7 @@ before performing a single successful read is: > > 2020-08-06 02:07:23.080415 ListExports id=1 readonly=0 tls=0 ... > 2020-08-06 02:07:23.080502 ...ListExports id=1 exports=("") return=0 > - 2020-08-06 02:07:23.080712 connection=1 Connect export="" tls=0 size=0x400 write=1 flush=1 rotational=0 trim=1 zero=2 fua=2 extents=1 cache=2 fast_zero=1 > + 2020-08-06 02:07:23.080712 connection=1 Connect export="" tls=0 size=0x400 minsize=0x1 prefsize=0x200 maxsize=0xffffffff write=1 flush=1 rotational=0 trim=1 zero=2 fua=2 extents=1 cache=2 fast_zero=1 > 2020-08-06 02:07:23.080907 connection=1 Read id=1 offset=0x0 count=0x200 ... > 2020-08-06 02:07:23.080927 connection=1 ...Read id=1 return=0 > 2020-08-06 02:07:23.081255 connection=1 Disconnect transactions=1 > diff --git a/filters/log/log.c b/filters/log/log.c > index acc9d77e..4255f85f 100644 > --- a/filters/log/log.c > +++ b/filters/log/log.c > @@ -1,5 +1,5 @@ > /* nbdkit > - * Copyright (C) 2018-2020 Red Hat Inc. > + * Copyright (C) 2018-2022 Red Hat Inc. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions are > @@ -251,6 +251,7 @@ log_prepare (nbdkit_next *next, void *handle, > struct handle *h = handle; > const char *exportname = h->exportname; > int64_t size = next->get_size (next); > + uint32_t minsize, prefsize, maxsize; > int w = next->can_write (next); > int f = next->can_flush (next); > int r = next->is_rotational (next); > @@ -260,9 +261,10 @@ log_prepare (nbdkit_next *next, void *handle, > int e = next->can_extents (next); > int c = next->can_cache (next); > int Z = next->can_fast_zero (next); > + int s = next->block_size (next, &minsize, &prefsize, &maxsize); > > if (size < 0 || w < 0 || f < 0 || r < 0 || t < 0 || z < 0 || F < 0 || > - e < 0 || c < 0 || Z < 0) > + e < 0 || c < 0 || Z < 0 || s < 0) > return -1; > > fp = open_memstream (&str, &len); > @@ -270,10 +272,12 @@ log_prepare (nbdkit_next *next, void *handle, > fprintf (fp, "export="); > shell_quote (exportname, fp); > fprintf (fp, > - " tls=%d size=0x%" PRIx64 " write=%d " > + " tls=%d size=0x%" PRIx64 " minsize=0x%" PRIx32 " prefsize=0x%" > + PRIx32 " maxsize=0x%" PRIx32 " write=%d " > "flush=%d rotational=%d trim=%d zero=%d fua=%d extents=%d " > "cache=%d fast_zero=%d", > - h->tls, size, w, f, r, t, z, F, e, c, Z); > + h->tls, size, minsize, prefsize, maxsize, > + w, f, r, t, z, F, e, c, Z); > fclose (fp); > print (h, "Connect", "%s", str); > }ACK Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v