[Libguestfs] nbdkit: Could not read L1 table when reading exported qcow2

Richard W.M. Jones rjones at redhat.com
Wed Nov 21 10:39:30 UTC 2018

On Wed, Nov 21, 2018 at 09:25:05AM +0000, Richard W.M. Jones wrote:
> nbdkit: file.2: error: invalid request: offset and count are out of range: offset=196608 count=512

Actually what happens even more precisely is that the underlying file
is not a multiple of 512 bytes (196624 ≡ 16 mod 512).

qemu-img (the client) issues a request for the final "sector" of the
file which goes beyond the end of the file.

You can "fix" this by using the truncate filter
telling it to round up the size to the next multiple of 512 bytes:

$ nbdkit --filter=truncate file file=disk -f -v round-up=512

and this allows qemu-img to work:

$ qemu-img info nbd://localhost
image: nbd://localhost:10809
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: unavailable
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

However the fundamental problem remains that you're exporting qcow2
bytes over the NBD connection which is not really what you wanted to

You should use qemu-nbd instead since it understands qcow2 natively,
or use raw format disks if you want to use nbdkit for its other


Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org

More information about the Libguestfs mailing list