qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] Python NBD client library


From: Nir Soffer
Subject: Re: [Qemu-block] Python NBD client library
Date: Fri, 3 Aug 2018 23:12:38 +0300

On Tue, Jul 31, 2018 at 6:17 PM Richard W.M. Jones <address@hidden> wrote:
... 
> If you like to check the prototype, see:
> https://gerrit.ovirt.org/c/93384/
>
> qemu's nbd/client.c was very helpful so far, since NBD doc
> https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md
> is not very clear.

I agree the protocol spec has evolved by accretion so that it no
longer has a coherent narrative.  Anyway some general comments on your
client in no particular order:

- Be nice if it was a separate Python library.

- It should support TCP sockets too.  In fact those are probably more
  important than Unix sockets in the bigger picture.  Is there not a
  Python "socket client" class you can subclass from which does all
  the socket machinery?

This should be easy to support. We probably need to separate the transport
from the client. Will also make it easy to inject errors.

I'm not sure yet about the high level interface, maybe somehting
like:

    nbd.open("nbd://host:port/export")

And for unix:

    nbd.open("nbd+unix:///export?socket=tmp/nbd.sock")

We need a better url systax.

... 
I would test against ‘qemu-nbd -x’ primarily, then secondarily against
nbd-server and nbdkit.  Once it interoperates with all 3 then you're
good to go :-)

nbdkit is not supported now because it does not implement NBD_OPT_GO:
https://www.redhat.com/archives/libguestfs/2018-August/msg00023.html

I'll look at it again when qemu-nbd and qemu are fully supported for 
incremental backup and virt-v2v.
 
> Not sure that imageio is the best place for this. Do you have a better idea
> about a better home for this library?

A separate Python library in PyPi or wherever would be my preference.
I don't know what the policy is in imageio about dependencies though.

This seems like the best way, but we need to package it for RHEL and Fedora
to use it in oVirt. Including it in imageio avoid the packaging effort.

In the meantime we can read write and flush, here is an example:

$ qemu-nbd --fork -k /tmp/nbd.sock -t -f qcow2 test.qcow2 -x export -n $ python3 ... >>> from ovirt_imageio_common import nbd >>> c = nbd.Client("/tmp/nbd.sock", "export") >>> c.write(1073741824, b"NBD is awesome!") >>> c.flush() >>> print(c.read(1073741824, 15)) NBD is awesome!
As is this is very useful for vdsm tests - we currently qemu-io to generate 
images with known data, and verify images after operations (e.g. commit).
Using nbd client will be simpler and more powerful.

Nir


reply via email to

[Prev in Thread] Current Thread [Next in Thread]