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

Re: Requirements for an NBD client library in userspace



On Sat, May 11, 2019 at 03:28:28PM +0300, Nir Soffer wrote:
> On Sat, May 11, 2019, 14:03 Richard W.M. Jones <rjones@redhat.com> wrote:
> 
> > On Tue, Apr 30, 2019 at 04:43:03PM +0300, Nir Soffer wrote:
> > > On Tue, Apr 30, 2019, 15:46 Richard W.M. Jones <rjones@redhat.com>
> > wrote:
> > >
> > > > I believe there is no simple NBD client library.  Am I wrong about
> > > > this?  Let's assume I'm not for the sake of the rest of this email ...
> > > >
> > > > We do however have at least 4 places this could be consumed if it
> > existed:
> > > >
> > > >  - fio's proposed NBD engine
> > > >    https://www.spinics.net/lists/fio/msg07831.html
> > > >
> > > >  - nbdkit-nbd-plugin
> > > >    https://github.com/libguestfs/nbdkit/tree/master/plugins/nbd
> > > >
> > > >  - Martin K's forthcoming VMware liberation tool
> > > >
> > > >  - qemu, maybe?
> > > >    https://github.com/qemu/qemu/blob/master/block/nbd-client.c
> > >
> > >
> > > oVirt imageio, replacing pure python client, used to implement nbd-http
> > > proxy
> > >
> > https://github.com/oVirt/ovirt-imageio/blob/master/common/ovirt_imageio_common/nbd.py
> >
> > It looks like imageio is Python 2.  I'm trying to write libnbd
> > bindings for Python now, but TBH supporting Python 2 is turning out to
> > be painful, because there are plenty of Python 3 features it would be
> > nice to use ("b" boolean conversions, proper bytes handling and
> > PyUnicode_FSConverter are three particular features).  Do you really
> > need Python 2?  What is the roadmap for using Python 3 with imageio?
> >
> 
> We plan to drop python 2 for 4.4. I don't that anyone care about python 2
> now.

I wrote some initial, very preliminary bindings, see top commit(s) here:

  https://github.com/rwmjones/libnbd

Simple synchronous calls appear to work.  However they don't work for
asynchronous calls because the idiom of:

  char buf[512];

  conn = nbd_get_connection (nbd, 0);
  hid = nbd_aio_pread (conn, buf, sizeof buf, 0);
  /* ... various calls to poll/wait here ... */
  if (nbd_aio_command_completed (conn, hid)) {
    /* now we can use the data in buf ... */
  }

doesn't translate well into Python and passing buffers in and out of C
code.  That's TBD.

The imageio code goes appear to be doing anything asynch if I'm
understanding the code correctly.

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


Reply to: