[PATCH 0/4] libxl: blktap/tapback support

Jason Andryuk posted 4 patches 3 months ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20240201183024.145424-1-jandryuk@gmail.com
There is a newer version of this series
docs/man/xl-disk-configuration.5.pod.in   |   4 +-
tools/hotplug/Linux/block-common.sh       |   8 +-
tools/hotplug/Linux/block-tap             | 162 ++++++++++++++++++++--
tools/libs/light/libxl_device.c           |  14 +-
tools/libs/light/libxl_disk.c             |  37 +++--
tools/libs/light/libxl_dm.c               |   1 -
tools/libs/light/libxl_linux.c            |   1 +
tools/libs/light/libxl_types_internal.idl |   1 +
tools/libs/light/libxl_utils.c            |   2 +
9 files changed, 201 insertions(+), 29 deletions(-)
[PATCH 0/4] libxl: blktap/tapback support
Posted by Jason Andryuk 3 months ago
This patch re-introduces blktap support to libxl.  Unlike earlier
versions, it does not link against any blktap library.  libxl changes
are needed to write to the vbd3 backend XenStore nodes.

blktap has three components.  tapdisk is a daemon implementing the disk
IO, NBD (Network Block Device), and Xen PV interfaces.  tap-ctl is a
tool to control tapdisks - creating, starting, stopping and freeing.
tapback manages the XenStore operations and instructs tapdisk to
connect.

It is notable that tapdisk performs the grant and event channel ops, but
doesn't interact with XenStore.  tapback performs XenStore operations
and notifies tapdisks of values and changes.

The flow is: libxl writes to the "vbd3" XenStore nodes and runs the
block-tap script.  The block-tap script runs tap-ctl to create a tapdisk
instance as the physical device.  tapback then sees the tapdisk and
instructs the tapdisk to connect up the PV blkif interface.

This is expected to work without the kernel blktap driver, so the
block-tap script is modified accordingly to write the UNIX NBD path.
(It works with the kernel blktap driver as well - upstream blktap hasn't
removed the blktap driver requirement yet -
https://github.com/xapi-project/blktap/pull/364)

An example command to attach a vhd:
xl block-attach vm 'vdev=xvdf,backendtype=tap,format=vhd,target=/srv/target.vhd'

VHD support is important for OpenXT since there are lots of existing
VHDs which still need supporting.  tapdisk also supports encrypted VHDs
which is not available in QEMU.

blktap's tapback needs minimal changes to work with libxl:
https://github.com/xapi-project/blktap/pull/394

Jason Andryuk (4):
  block-common: Fix same_vm for no targets
  libxl: Add support for blktap vbd3
  hotplug: Update block-tap
  libxl: Support blktap with HVM device model

 docs/man/xl-disk-configuration.5.pod.in   |   4 +-
 tools/hotplug/Linux/block-common.sh       |   8 +-
 tools/hotplug/Linux/block-tap             | 162 ++++++++++++++++++++--
 tools/libs/light/libxl_device.c           |  14 +-
 tools/libs/light/libxl_disk.c             |  37 +++--
 tools/libs/light/libxl_dm.c               |   1 -
 tools/libs/light/libxl_linux.c            |   1 +
 tools/libs/light/libxl_types_internal.idl |   1 +
 tools/libs/light/libxl_utils.c            |   2 +
 9 files changed, 201 insertions(+), 29 deletions(-)

-- 
2.43.0
Re: [PATCH 0/4] libxl: blktap/tapback support
Posted by Anthony PERARD 2 months, 3 weeks ago
On Thu, Feb 01, 2024 at 01:30:20PM -0500, Jason Andryuk wrote:
> This patch re-introduces blktap support to libxl.  Unlike earlier
> versions, it does not link against any blktap library.  libxl changes
> are needed to write to the vbd3 backend XenStore nodes.
> 
> blktap has three components.  tapdisk is a daemon implementing the disk
> IO, NBD (Network Block Device), and Xen PV interfaces.  tap-ctl is a
> tool to control tapdisks - creating, starting, stopping and freeing.
> tapback manages the XenStore operations and instructs tapdisk to
> connect.
> 
> It is notable that tapdisk performs the grant and event channel ops, but
> doesn't interact with XenStore.  tapback performs XenStore operations
> and notifies tapdisks of values and changes.
> 
> The flow is: libxl writes to the "vbd3" XenStore nodes and runs the
> block-tap script.  The block-tap script runs tap-ctl to create a tapdisk
> instance as the physical device.  tapback then sees the tapdisk and
> instructs the tapdisk to connect up the PV blkif interface.
> 
> This is expected to work without the kernel blktap driver, so the
> block-tap script is modified accordingly to write the UNIX NBD path.
> (It works with the kernel blktap driver as well - upstream blktap hasn't
> removed the blktap driver requirement yet -
> https://github.com/xapi-project/blktap/pull/364)
> 
> An example command to attach a vhd:
> xl block-attach vm 'vdev=xvdf,backendtype=tap,format=vhd,target=/srv/target.vhd'
> 
> VHD support is important for OpenXT since there are lots of existing
> VHDs which still need supporting.  tapdisk also supports encrypted VHDs
> which is not available in QEMU.
> 
> blktap's tapback needs minimal changes to work with libxl:
> https://github.com/xapi-project/blktap/pull/394

It might be nice to have an entry in the ChangeLog. But it's looks like
the blktap project isn't ready yet, so we might need to point that out.

Cheers,

-- 
Anthony PERARD
Re: [PATCH 5/4] libxl: blktap/tapback support
Posted by Andrew Cooper 3 months ago
On 01/02/2024 6:30 pm, Jason Andryuk wrote:
> Jason Andryuk (4):
>   block-common: Fix same_vm for no targets
>   libxl: Add support for blktap vbd3
>   hotplug: Update block-tap
>   libxl: Support blktap with HVM device model

If libxl is learning how to drive tapdisk, then it's time for:

https://github.com/xenserver/xen.pg/blob/XS-8/patches/xentop-vbd3.patch

to make it's way upstream.  Otherwise, there's an absence of disk info
in xentop.

I previously kept it back because vbd3 was specific to XenServer.

~Andrew