Correct no libvirt involved as such, will post this on qemu mailing list. 

Regards
Tanmoy Sinha


On Thu, Jun 27, 2019 at 5:09 PM Peter Krempa <pkrempa@redhat.com> wrote:
On Thu, Jun 27, 2019 at 16:22:27 +0530, Tanmoy Sinha wrote:
> Hi All,
>
> I am unable to figure out the issue here, when I try to create a filesystem
> (ext4) on a virtual disk using qemu-nbd. This happens intermittently.
>
> Following is the sequence of commands:-
>
> $> qemu-img create -f qcow2 test.qcow2 30G
>
>
> $> qemu-nbd --connect=/dev/nbd0 test.qcow2

I think you forgot to use -f  qcow2 in this command line.

Also the qemu mailing list will probably be better target for this
question since your examples are not using libvirt.