Richard W.M. Jones
2019-Apr-01 11:53 UTC
[Libguestfs] [PATCH nbdkit] log: Decode the extent type in output.
Instead of printing something like ‘type=0’ or ‘type=3’, this changes the output to show the hole and zero flags separately. For example: $ ./nbdkit -U - --filter=log sh - logfile=/dev/stdout \ --run 'qemu-img map $nbd' <<'EOF' case "$1" in get_size) echo 1M ;; pread) dd if=/dev/zero count=$3 iflag=count_bytes ;; can_extents) exit 0 ;; extents) echo "0 32K zero" echo "32K 32K hole,zero" echo "64K 983040 " ;; *) exit 2 ;; esac EOF [...] 2019-04-01 11:49:40.818357 connection=1 Extents id=2 offset=0x0 count=0x100000 req_one=1 ... 2019-04-01 11:49:40.819848 connection=1 ...Extents id=2 extents=[{ offset=0x0, length=0x8000, hole=0, zero=1 }, { offset=0x8000, length=0x8000, hole=1, zero=1 }, { offset=0x10000, length=0xf0000, hole=0, zero=0 }] return=0 Updates commit ed868b00f192cd72e91265e4fcdf3c3fbe8b7613. Thanks: Martin Kletzander --- filters/log/log.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/filters/log/log.c b/filters/log/log.c index 4878db2..02a2522 100644 --- a/filters/log/log.c +++ b/filters/log/log.c @@ -382,8 +382,10 @@ log_extents (struct nbdkit_next_ops *next_ops, void *nxdata, if (i > 0) fprintf (fp, ", "); fprintf (fp, "{ offset=0x%" PRIx64 ", length=0x%" PRIx64 ", " - "type=%" PRIu32 " }", - e.offset, e.length, e.type); + "hole=%d, zero=%d }", + e.offset, e.length, + !!(e.type & NBDKIT_EXTENT_HOLE), + !!(e.type & NBDKIT_EXTENT_ZERO)); } fclose (fp); -- 2.20.1
Eric Blake
2019-Apr-01 12:40 UTC
Re: [Libguestfs] [PATCH nbdkit] log: Decode the extent type in output.
On 4/1/19 6:53 AM, Richard W.M. Jones wrote:> Instead of printing something like ‘type=0’ or ‘type=3’, this changes > the output to show the hole and zero flags separately. For example: > > $ ./nbdkit -U - --filter=log sh - logfile=/dev/stdout \ > --run 'qemu-img map $nbd' <<'EOF' > case "$1" in > get_size) echo 1M ;; > pread) dd if=/dev/zero count=$3 iflag=count_bytes ;; > can_extents) exit 0 ;; > extents) > echo "0 32K zero" > echo "32K 32K hole,zero" > echo "64K 983040 " > ;; > *) exit 2 ;; > esac > EOF > [...] > 2019-04-01 11:49:40.818357 connection=1 Extents id=2 offset=0x0 count=0x100000 req_one=1 ... > 2019-04-01 11:49:40.819848 connection=1 ...Extents id=2 extents=[{ offset=0x0, length=0x8000, hole=0, zero=1 }, { offset=0x8000, length=0x8000, hole=1, zero=1 }, { offset=0x10000, length=0xf0000, hole=0, zero=0 }] return=0 > > Updates commit ed868b00f192cd72e91265e4fcdf3c3fbe8b7613.Yes, that's nicer.> > Thanks: Martin Kletzander > --- > filters/log/log.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-)-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Martin Kletzander
2019-Apr-01 13:03 UTC
Re: [Libguestfs] [PATCH nbdkit] log: Decode the extent type in output.
On Mon, Apr 01, 2019 at 07:40:14AM -0500, Eric Blake wrote:>On 4/1/19 6:53 AM, Richard W.M. Jones wrote: >> Instead of printing something like ‘type=0’ or ‘type=3’, this changes >> the output to show the hole and zero flags separately. For example: >> >> $ ./nbdkit -U - --filter=log sh - logfile=/dev/stdout \ >> --run 'qemu-img map $nbd' <<'EOF' >> case "$1" in >> get_size) echo 1M ;; >> pread) dd if=/dev/zero count=$3 iflag=count_bytes ;; >> can_extents) exit 0 ;; >> extents) >> echo "0 32K zero" >> echo "32K 32K hole,zero" >> echo "64K 983040 " >> ;; >> *) exit 2 ;; >> esac >> EOF >> [...] >> 2019-04-01 11:49:40.818357 connection=1 Extents id=2 offset=0x0 count=0x100000 req_one=1 ... >> 2019-04-01 11:49:40.819848 connection=1 ...Extents id=2 extents=[{ offset=0x0, length=0x8000, hole=0, zero=1 }, { offset=0x8000, length=0x8000, hole=1, zero=1 }, { offset=0x10000, length=0xf0000, hole=0, zero=0 }] return=0 >> >> Updates commit ed868b00f192cd72e91265e4fcdf3c3fbe8b7613. > >Yes, that's nicer. >Even nicer than what I thought of.>> >> Thanks: Martin Kletzander >> --- >> filters/log/log.c | 6 ++++-- >> 1 file changed, 4 insertions(+), 2 deletions(-) > > >-- >Eric Blake, Principal Software Engineer >Red Hat, Inc. +1-919-301-3226 >Virtualization: qemu.org | libvirt.org >>_______________________________________________ >Libguestfs mailing list >Libguestfs@redhat.com >https://www.redhat.com/mailman/listinfo/libguestfs
Possibly Parallel Threads
- Re: [PATCH nbdkit] log: Decode the extent type in output.
- [nbdkit PATCH v2] Introduce cacheextents filter
- Re: [PATCH nbdkit 1/3] sh: Implement inline scripts.
- [nbdkit PATCH] sh: Prefer dd bs=1 over iflag=count_bytes
- [nbdkit PATCH] extents: Cap maximum reply length