iSCSI support
Subsystems (2)
cover iSCSI support
List,
This is the second version of the patch to add iSCSI support to QEMU/KVM.
This patch uses the libiscsi clientside library for iscsi atgit://github.com/sahlberg/libiscsi.git
When this library is installed/available QEMU will build with support to attach directly to a iSCSI LUN without the need to expose these LUNs to the host.
The patch has been updated based on input from review of the initial patch as well as had CHAP authentication added.
Please review and/or apply
Ronnie Sahlberg
PATCH 1/1 iSCSI support
This patch adds a new block driver : block.iscsi.c This driver interfaces with the multiplatform posix library for iscsi initiator/client access to iscsi devices hosted atgit://github.com/sahlberg/libiscsi.git
The patch adds the driver to interface with the iscsi library. It also updated the configure script to
* by default, probe is libiscsi is available and if so, build qemu against libiscsi.
* --enable-libiscsi
Force a build against libiscsi. If libiscsi is not available the build will fail.
* --disable-libiscsi
Do not link against libiscsi, even if it is available.
When linked with libiscsi, qemu gains support to access iscsi resources such as disks and cdrom directly, without having to make the devices visible to the host.
You can specify devices using a iscsi url of the form :
iscsi://[<username>%<password>@]<host>[:<port]/<target-iqn-name>/<lun>
Example:
-drive file=iscsi://10.1.1.1:3260/iqn.ronnie.test/1
-cdrom iscsi://10.1.1.1:3260/iqn.ronnie.test/2
Version 2:
Changes from Blue Swirl's suggestions
- Change naming of structures and typedefs to match coding style
- Use CONFIG_ISCSI in the makefile to conditionally compile iscsi.c
- Missing spaces added around operators
- Use uint8_t instead of unsigned char for buffer pointer
- Use a temporary variable for the result of long functions, to move them out from the if(...) expressions. Making the code easier to read.
- Create a function sector_qemu2lun() and use it instead of performing the same conversion explicitely at several palces in the code.
- Use the name opaque instead of private_data
- Use memset() instead of bzero()
Other changes
- Use the common library function to parse the iSCSI URL
- Add support for CHAP authentication
--- Makefile.objs | 1 + block/iscsi.c | 518 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 31 ++++ 3 files changed, 550 insertions(+), 0 deletions(-) create mode 100644 block/iscsi.c
Makefile.objs +1 -0
@@ -25,6 +25,7 @@ block-nested-y += qed-check.o block-nested-y += parallels.o nbd.o blkdebug.o sheepdog.o blkverify.o block-nested-$(CONFIG_WIN32) += raw-win32.o block-nested-$(CONFIG_POSIX) += raw-posix.o +block-nested-$(CONFIG_LIBISCSI) += iscsi.o block-nested-$(CONFIG_CURL) += curl.o block-nested-$(CONFIG_RBD) += rbd.o
block/iscsi.c new file +518 -0
518 lines not on this page · raw message
configure +31 -0
@@ -334,6 +334,7 @@ trace_backend="nop" trace_file="trace" spice="" rbd="" +libiscsi="" # OS specific if check_define __linux__ ; then
@@ -650,6 +651,10 @@ for opt do ;; --enable-spice) spice="yes" ;; + --disable-libiscsi) libiscsi="no" + ;; + --enable-libiscsi) libiscsi="yes" + ;; --enable-profiler) profiler="yes" ;; --enable-cocoa)
@@ -941,6 +946,8 @@ echo " Default:trace-<pid>" echo " --disable-spice disable spice" echo " --enable-spice enable spice" echo " --enable-rbd enable building the rados block device (rbd)" +echo " --disable-libiscsi disable iscsi support" +echo " --enable-libiscsi enable iscsi support" echo "" echo "NOTE: The object files are built at the place where configure is launched" exit 1
@@ -2125,6 +2132,25 @@ if compile_prog "" "" ; then fi ########################################## +# Do we have libiscsi +if test "$libiscsi" != "no" ; then + cat > $TMPC << EOF +#include <iscsi/iscsi.h> +int main(void) { iscsi_create_context(""); return 0; } +EOF + if compile_prog "-Werror" "-liscsi" ; then + libiscsi="yes" + LIBS="$LIBS -liscsi" + else + if test "$libiscsi" = "yes" ; then + feature_not_found "libiscsi" + fi + libiscsi="no" + fi +fi + + +########################################## # Do we need librt cat > $TMPC <<EOF #include <signal.h>
@@ -2426,6 +2452,7 @@ echo "Trace output file $trace_file-<pid>" echo "spice support $spice" echo "rbd support $rbd" echo "xfsctl support $xfs" +echo "libiscsi support $libiscsi" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -2692,6 +2719,10 @@ if test "$spice" = "yes" ; then echo "CONFIG_SPICE=y" >> $config_host_mak fi +if test "$libiscsi" = "yes" ; then + echo "CONFIG_LIBISCSI=y" >> $config_host_mak +fi + # XXX: suppress that if [ "$bsd" = "yes" ] ; then echo "CONFIG_BSD=y" >> $config_host_mak
Signature · 1 line
1.7.3.1
Quoted 44 lines · Ronnie Sahlberg
This patch adds a new block driver :
block.iscsi.cThis driver interfaces with the multiplatform posix library for iscsi initiator/client access to iscsi devices hosted atgit://github.com/sahlberg/libiscsi.gitThe patch adds the driver to interface with the iscsi library. It also updated the configure script to
* by default, probe is libiscsi is available and if so, build qemu against libiscsi.
* --enable-libiscsi
Force a build against libiscsi. If libiscsi is not available the build will fail.
* --disable-libiscsi
Do not link against libiscsi, even if it is available.When linked with libiscsi, qemu gains support to access iscsi resources such as disks and cdrom directly, without having to make the devices visible to the host.
You can specify devices using a iscsi url of the form :
iscsi://[<username>%<password>@]<host>[:<port]/<target-iqn-name>/<lun>Example:
(quoted diff) +0
-2-drive file=iscsi://10.1.1.1:3260/iqn.ronnie.test/1 -cdrom iscsi://10.1.1.1:3260/iqn.ronnie.test/2Version 2:
Changes from Blue Swirl's suggestions
- Change naming of structures and typedefs to match coding style
- UseCONFIG_ISCSIin the makefile to conditionally compileiscsi.c
- Missing spaces added around operators
- Useuint8_tinstead of unsigned char for buffer pointer
- Use a temporary variable for the result of long functions, to move them out from the if(...) expressions. Making the code easier to read.
- Create a functionsector_qemu2lun()and use it instead of performing the same conversion explicitely at several palces in the code.
- Use the name opaque instead ofprivate_data
- Usememset()instead ofbzero()Other changes
- Use the common library function to parse the iSCSI URL
- Add support for CHAP authentication
Quoted 7 lines
Signed-off-by Ronnie Sahlberg <[email protected]>---
Makefile.objs | 1 +
block/iscsi.c | 518 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 31 ++++3 files changed, 550 insertions(+), 0 deletions(-)create mode 100644
block/iscsi.c
Mixed tabs and spaces. QEMU uses spaces only with 4-space indentation.
Hopefully real feedback soon, I'm playing with this patch, libiscsi, and tgtd :).
Stefan