From 6d7d8d2b3e3791c2005589bad0d608c9025a4bc4 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Tue, 13 Feb 2024 09:28:58 +0100 Subject: [PATCH] libxl: Add support for blktap vbd3 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. backendtype=tap was not fully removed previously, but it would never succeed since it would hit the hardcoded error in disk_try_backend(). It is reused now. An example command to attach a vhd: xl block-attach vm 'vdev=xvdf,backendtype=tap,format=vhd,target=/srv/target.vhd' Format raw also works to run an "aio:" tapdisk. Signed-off-by: Jason Andryuk Reviewed-by: Anthony PERARD --- docs/man/xl-disk-configuration.5.pod.in | 4 +++- tools/libs/light/libxl_device.c | 14 ++++++++++---- tools/libs/light/libxl_disk.c | 20 +++++++++++++++----- tools/libs/light/libxl_linux.c | 1 + tools/libs/light/libxl_types_internal.idl | 1 + tools/libs/light/libxl_utils.c | 2 ++ 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/docs/man/xl-disk-configuration.5.pod.in b/docs/man/xl-disk-configuration.5.pod.in index bc945cc517..cb442bd5b4 100644 --- a/docs/man/xl-disk-configuration.5.pod.in +++ b/docs/man/xl-disk-configuration.5.pod.in @@ -232,7 +232,7 @@ Specifies the backend implementation to use =item Supported values -phy, qdisk, standalone +phy, qdisk, standalone, tap =item Mandatory @@ -254,6 +254,8 @@ and "standalone" does not support specifications other than "virtio". Normally this option should not be specified, in which case libxl will automatically determine the most suitable backend. +"tap" needs blktap's tapback to be running. + =item B