Skip to contentSkip to conversation

Add iSCSI support for QEMU

PATCH In review Ronnie Sahlberg 11 participants 45 messages Sep 10, 2011 – Sep 23, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add iSCSI support for QEMU

List,

Please find a patch that adds built-in iSCSI support to QEMU when built and linked against the multiplatform iscsi initiator library at git://github.com/sahlberg/libiscsi.git

All previous comments and suggestions have been addressed in this patch.

I and others have done extensive testing and used this patch extensively over the last ~6 months with great result.

In some situations, using a built-in iscsi inititator has benefits against mounting the LUNs on the host.

* Privacy: The iSCSI LUNs are private to the guest and are not visible either to the host, nor to any processes running on the host.
* Ease of managment : If you have very many guests and very many, thousands of, iSCSI LUNs. It is inconvenient to have to expose all LUNs to the underlying host.
* No root requirement. Since the iSCSI LUNs are not mounted as devices on the host, ordinary users can set up and use iSCSI resources without the need for root privilege on the host to map the devices to local scsi devices.

Please merge this patch to master or explain how I should change the patch so that it becomes acceptable for inclusion into QEMU.

regards
ronnie sahlberg

#1 lore raw

PATCH 1/1 This patch adds a new block driver : iSCSI

This provides built-in support for iSCSI to QEMU.
This has the advantage that the iSCSI devices need not be made visible to the host, which is useful if you have very many virtual machines and very many iscsi devices. It also has the benefit that non-root users of QEMU can access iSCSI devices across the network without requiring root privilege on the host.

This driver interfaces with the multiplatform posix library for iscsi initiator/client access to iscsi devices hosted at
git://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> When using authentication, the password can optionally be set with LIBISCSI_CHAP_PASSWORD="password" to avoid it showing up in the process list

Example:
./x86_64-softmmu/qemu-system-x86_64 -m 1024 -cdrom iscsi://127.0.0.1/iqn.ronnie.test/2 --drive file=iscsi://127.0.0.1/iqn.ronnie.test/1 -boot d -enable-kvm

---
 Makefile.objs |    1 +
 block/iscsi.c |  594 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure     |   31 +++
 trace-events  |    7 +
 4 files changed, 633 insertions(+), 0 deletions(-)
 create mode 100644 block/iscsi.c
Makefile.objs +1 -0
index a529a11..8c8e420 100644
@@ -36,6 +36,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 +594 -0

594 lines not on this page · raw message

configure +31 -0
index 348f36a..a2c30e1 100755
@@ -182,6 +182,7 @@ usb_redir=""
 opengl=""
 zlib="yes"
 guest_agent="yes"
+libiscsi=""
 
 # parse CC options first
 for opt do
@@ -651,6 +652,10 @@ for opt do
   ;;
   --enable-spice) spice="yes"
   ;;
+  --disable-libiscsi) libiscsi="no"
+  ;;
+  --enable-libiscsi) libiscsi="yes"
+  ;;
   --enable-profiler) profiler="yes"
   ;;
   --enable-cocoa)
@@ -1037,6 +1042,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 "  --disable-smartcard      disable smartcard support"
 echo "  --enable-smartcard       enable smartcard support"
 echo "  --disable-smartcard-nss  disable smartcard nss support"
@@ -2326,6 +2333,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>
@@ -2727,6 +2753,7 @@ echo "xfsctl support    $xfs"
 echo "nss used          $smartcard_nss"
 echo "usb net redir     $usb_redir"
 echo "OpenGL support    $opengl"
+echo "libiscsi support  $libiscsi"
 echo "build guest agent $guest_agent"
 
 if test "$sdl_too_old" = "yes"; then
@@ -3028,6 +3055,10 @@ if test "$opengl" = "yes" ; then
   echo "CONFIG_OPENGL=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
trace-events +7 -0
index 3fdd60f..4e461e5 100644
@@ -494,3 +494,10 @@ escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x"
 escc_sunkbd_event_out(int ch) "Translated keycode %2.2x"
 escc_kbd_command(int val) "Command %d"
 escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x"
+
+# block/iscsi.c
+disable iscsi_aio_write10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_writev(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+disable iscsi_aio_read10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_readv(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+
Signature · 1 line
1.7.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

On Sat, Sep 10, 2011 at 02:23:30PM +1000, Ronnie Sahlberg wrote:

Looking good. I think this is worth merging because it does offer benefits over host iSCSI.

Quoted 9 lines
block/iscsi.c new file +9 -0
+static void
+iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
+                    void *private_data)
+{
+}
+
+static void
+iscsi_aio_cancel(BlockDriverAIOCB *blockacb)
+{

block/iscsi.c line 82

Quoted 10 lines
block/iscsi.c new file +10 -0
+    IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
+    IscsiLun *iscsilun = acb->iscsilun;
+
+    acb->status = -ECANCELED;
+    acb->common.cb(acb->common.opaque, acb->status);
+    acb->canceled = 1;
+
+    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                     iscsi_abort_task_cb, NULL);
+}

The asynchronous abort task call looks odd. If a caller allocates a buffer and issues a read request, then we need to make sure that the request is really aborted by the time .bdrv_aio_cancel() returns.

If I understand the code correctly, iscsi_aio_cancel() returns immediately but the read request will still be in progress. That means the caller could now free their data buffer and the read request will overwrite that unallocated memory.

block/iscsi.c line 170

Quoted 11 lines
block/iscsi.c new file +11 -0
+static void
+iscsi_aio_write10_cb(struct iscsi_context *iscsi, int status,
+                     void *command_data, void *opaque)
+{
+    IscsiAIOCB *acb = opaque;
+
+    trace_iscsi_aio_write10_cb(iscsi, status, acb, acb->canceled);
+
+    if (acb->buf != NULL) {
+        free(acb->buf);
+    }

Please just use g_free(acb->buf). g_free(NULL) is defined as a nop so the check isn't necessary. Also, this code uses free(3) when it should use g_free(3).

Quoted 31 lines
block/iscsi.c new file +31 -0
+
+    if (acb->canceled != 0) {
+        qemu_aio_release(acb);
+        scsi_free_scsi_task(acb->task);
+        acb->task = NULL;
+        return;
+    }
+
+    acb->status = 0;
+    if (status < 0) {
+        error_report("Failed to write10 data to iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        acb->status = -EIO;
+    }
+
+    iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+    scsi_free_scsi_task(acb->task);
+    acb->task = NULL;
+}
+
+static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun)
+{
+    return sector * BDRV_SECTOR_SIZE / iscsilun->block_size;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
+                 QEMUIOVector *qiov, int nb_sectors,
+                 BlockDriverCompletionFunc *cb,
+                 void *opaque)
+{

block/iscsi.c line 211

Quoted 10 lines
block/iscsi.c new file +10 -0
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+    IscsiAIOCB *acb;
+    size_t size;
+    int fua = 0;
+
+    /* set FUA on writes when cache mode is write through */
+    if (!(bs->open_flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))) {
+        fua = 1;
+    }

FUA needs to reflect the guest semantics - does this disk have an enabled write cache? When bs->open_flags has BDRV_O_CACHE_WB, then the guest knows it needs to send flushes because there is a write cache:

if (!(bs->open_flags & BDRV_O_CACHE_WB)) {
    fua = 1;
}

BDRV_O_NOCACHE is just for local files and sets the O_DIRECT hint. It doesn't affect the cache semantics that the guest sees.

Quoted 8 lines
block/iscsi.c new file +8 -0
+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */
+static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = NULL;

block/iscsi.c line 481

Quoted 10 lines
block/iscsi.c new file +10 -0
+    struct iscsi_url *iscsi_url = NULL;
+    struct IscsiTask task;
+    int ret;
+
+    if ((BDRV_SECTOR_SIZE % 512) != 0) {
+        error_report("iSCSI: Invalid BDRV_SECTOR_SIZE. "
+                     "BDRV_SECTOR_SIZE(%lld) is not a multiple "
+                     "of 512", BDRV_SECTOR_SIZE);
+        return -EINVAL;
+    }

Another way of saying this is:
QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE % 512 != 0);

The advantage is that the build fails instead of waiting until iscsi is used at runtime until the failure is detected.

What will happen if BDRV_SECTOR_SIZE is not a multiple of 512?

Quoted 6 lines
block/iscsi.c new file +6 -0
+
+    memset(iscsilun, 0, sizeof(IscsiLun));
+
+    /* Should really append the KVM name after the ':' here */
+    iscsi = iscsi_create_context("iqn.2008-11.org.linux-kvm:");
+    if (iscsi == NULL) {

block/iscsi.c line 497

Quoted 10 lines
block/iscsi.c new file +10 -0
+        error_report("iSCSI: Failed to create iSCSI context.");
+        ret = -ENOMEM;
+        goto failed;
+    }
+
+    iscsi_url = iscsi_parse_full_url(iscsi, filename);
+    if (iscsi_url == NULL) {
+        error_report("Failed to parse URL : %s %s", filename,
+                     iscsi_get_error(iscsi));
+        ret = -ENOMEM;

-EINVAL?

block/iscsi.c line 585

Quoted 13 lines
block/iscsi.c new file +13 -0
+static BlockDriver bdrv_iscsi = {
+    .format_name     = "iscsi",
+    .protocol_name   = "iscsi",
+
+    .instance_size   = sizeof(IscsiLun),
+    .bdrv_file_open  = iscsi_open,
+    .bdrv_close      = iscsi_close,
+
+    .bdrv_getlength  = iscsi_getlength,
+
+    .bdrv_aio_readv  = iscsi_aio_readv,
+    .bdrv_aio_writev = iscsi_aio_writev,
+    .bdrv_aio_flush  = iscsi_aio_flush,

block.c does not emulate .bdrv_flush() using your .bdrv_aio_flush() implementation. I have sent a patch to add this emulation. This will turn bdrv_flush(iscsi_bs) into an actual operation instead of a nop :).

Quoted 5 lines
trace-events +0 -0
index 3fdd60f..4e461e5 100644

trace-events escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x" · line 502

Quoted 9 lines
trace-events +6 -0
@@ -494,3 +494,10 @@ escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x"
 escc_sunkbd_event_out(int ch) "Translated keycode %2.2x"
 escc_kbd_command(int val) "Command %d"
 escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x"
+
+# block/iscsi.c
+disable iscsi_aio_write10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_writev(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+disable iscsi_aio_read10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_readv(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"

It is no longer necessary to prefix trace event definitions with "disable".

The stderr and simple backends now start up with all events disabled by default. The set of events can be set using the -trace events=<events-file> option or on the QEMU monitor using set trace-event <name> on.

Stefan

#3 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 9 lines · Stefan Hajnoczi
Quoted 9 lines
block/iscsi.c new file +9 -0
+static void
+iscsi_aio_cancel(BlockDriverAIOCB *blockacb)
+{
+    IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
+    IscsiLun *iscsilun = acb->iscsilun;
+
+    acb->status = -ECANCELED;
+    acb->common.cb(acb->common.opaque, acb->status);
+    acb->canceled = 1;
Quoted 8 lines

block/iscsi.c line 82

Quoted 4 lines
block/iscsi.c new file +4 -0
+
+    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                     iscsi_abort_task_cb, NULL);
+}

The asynchronous abort task call looks odd. If a caller allocates a buffer and issues a read request, then we need to make sure that the request is really aborted by the time .bdrv_aio_cancel() returns.

Shouldn't new drivers use coroutines instead of aio instead?

(just poking around, I don't fully understand the new scheme myself yet
either)

Quoted 2 lines

BDRV_O_NOCACHE is just for local files and sets the O_DIRECT hint. It doesn't affect the cache semantics that the guest sees.

Now that I fixed it it doesn't. But that's been a fairly recent change, which isn't always easy to pick up people having external patches.

Quoted 5 lines
Quoted 5 lines

+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */

Is having username + password on the command line really a that good idea? Also what about the more complicated iSCSI authentification schemes?

Quoted 1 line

What will happen if BDRV_SECTOR_SIZE is not a multiple of 512?

hell will break lose for all of qemu.

#4 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 19 lines · Christoph Hellwig
Quoted 9 lines · Stefan Hajnoczi
Quoted 9 lines
block/iscsi.c new file +9 -0
+static void
+iscsi_aio_cancel(BlockDriverAIOCB *blockacb)
+{
+    IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
+    IscsiLun *iscsilun = acb->iscsilun;
+
+    acb->status = -ECANCELED;
+    acb->common.cb(acb->common.opaque, acb->status);
+    acb->canceled = 1;
Quoted 8 lines

block/iscsi.c line 82

Quoted 4 lines
block/iscsi.c new file +4 -0
+
+    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                     iscsi_abort_task_cb, NULL);
+}

The asynchronous abort task call looks odd.  If a caller allocates a buffer and issues a read request, then we need to make sure that the request is really aborted by the time .bdrv_aio_cancel() returns.

Quoted 4 lines

Shouldn't new drivers use coroutines instead of aio instead?

(just poking around, I don't fully understand the new scheme myself yet either)

I think in this case it will not make the code nicer. Since the external iSCSI library is based on callbacks it would be necessary to write the coroutines<->callbacks adapter functions. So for example, the READ10 command would need a function that can be called in coroutine context and yields while libiscsi does the I/O. When the callback is invoked it will re-enter the coroutine.

The area where coroutines are useful in the block layer is for image formats. We already have common coroutines<->callback adapter functions in block.c so it's possible to write sequential code for image formats. They only need access to block layer functions which have already been adapted. But as soon as you interact with a callback-based API from the coroutine, then you need to write an adapter yourself.

Stefan

#5 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 7 lines · Stefan Hajnoczi

I think in this case it will not make the code nicer. Since the external iSCSI library is based on callbacks it would be necessary to write the coroutines<->callbacks adapter functions. So for example, the READ10 command would need a function that can be called in coroutine context and yields while libiscsi does the I/O. When the callback is invoked it will re-enter the coroutine.

Quoted 7 lines

The area where coroutines are useful in the block layer is for image formats. We already have common coroutines<->callback adapter functions in block.c so it's possible to write sequential code for image formats. They only need access to block layer functions which have already been adapted. But as soon as you interact with a callback-based API from the coroutine, then you need to write an adapter yourself.

So you plan on keeping the aio interface around forever? Qemu with two different I/O pathes was already more than painful enough, I don't think keeping three, and two of them beeing fairly complex is a good idea.

#6 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 16 lines · Christoph Hellwig
Quoted 7 lines · Stefan Hajnoczi

I think in this case it will not make the code nicer. Since the external iSCSI library is based on callbacks it would be necessary to write the coroutines<->callbacks adapter functions. So for example, the READ10 command would need a function that can be called in coroutine context and yields while libiscsi does the I/O. When the callback is invoked it will re-enter the coroutine.

Quoted 7 lines

The area where coroutines are useful in the block layer is for image formats. We already have common coroutines<->callback adapter functions in block.c so it's possible to write sequential code for image formats. They only need access to block layer functions which have already been adapted. But as soon as you interact with a callback-based API from the coroutine, then you need to write an adapter yourself.

Quoted 4 lines

So you plan on keeping the aio interface around forever? Qemu with two different I/O pathes was already more than painful enough, I don't think keeping three, and two of them beeing fairly complex is a good idea.

The synchronous interfaces can be converted to the coroutine interfaces.

The block layer needs a public aio interface because device emulation is asynchronous/callback-based. That doesn't mean that BlockDriver needs aio functions since block.c could transparently set up coroutines. So in theory BlockDriver could have only coroutine interfaces.

Doing the aio to coroutine conversion is pretty mechanical, that's why I'm not afraid of doing it with this iSCSI code later.

Stefan

#7 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Christoph Hellwig

On Thu, Sep 15, 2011 at 12:36 AM, Christoph Hellwig <[email protected]> wrote:
...

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */

Is having username + password on the command line really a that good idea? Also what about the more complicated iSCSI authentification schemes?

In general it is a very bad idea. For local use on a private box it is convenient to be able to use "<username>%<password>@" syntax. For use on a shared box, libiscsi supports an alternative method too by setting the username and/or password via environment variables :
LIBISCSI_CHAP_USERNAME=... LIBISCSI_CHAP_PASSWORD=...

I will document this better in the next patch.

Libiscsi only support CHAP at this stage. Which other authentication schemes do you have in mind? Perhaps I can add them.

regards
ronnie sahlberg

#8 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 7 lines · ronnie sahlberg

On Thu, Sep 15, 2011 at 12:36 AM, Christoph Hellwig <[email protected]> wrote:
...

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */

Quoted 8 lines
Quoted 2 lines

Is having username + password on the command line really a that good idea? Also what about the more complicated iSCSI authentification schemes?

In general it is a very bad idea. For local use on a private box it is convenient to be able to use "<username>%<password>@" syntax. For use on a shared box, libiscsi supports an alternative method too by setting the username and/or password via environment variables :
LIBISCSI_CHAP_USERNAME=... LIBISCSI_CHAP_PASSWORD=...

Environement variables are only a tiny bit better, since this still allows the password to leak to any processes which can read /proc/$PID/environ. It is also undesirable wrt many distro trouble shooting tools (eg Fedora/ RHEL's sosreport) which capture the contents of /proc/$PID/environ as part of their data collection process. This means your passwords will end up in attachments to bugzilla / issue tracker tickets.

For block devs with encrypted QCow2 disks (and VNC/SPICE) QEMU requires the password to be set via the monitor. Since this iscsi: protocol is part of the block layer, IMHO, the password should be settable the same way via the monitor

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#9 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to ronnie sahlberg

Am 15.09.2011 00:51, schrieb ronnie sahlberg:

Quoted 7 lines · Christoph Hellwig

...

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */

Quoted 8 lines
Quoted 2 lines

Is having username + password on the command line really a that good idea? Also what about the more complicated iSCSI authentification schemes?

In general it is a very bad idea. For local use on a private box it is convenient to be able to use "<username>%<password>@" syntax. For use on a shared box, libiscsi supports an alternative method too by setting the username and/or password via environment variables :
LIBISCSI_CHAP_USERNAME=... LIBISCSI_CHAP_PASSWORD=...

I wonder if we could make it look like an encrypted image. qemu already has functionality to deal with passwords for block devices, so it seems to make sense to reuse that for iscsi passwords.

Kevin

#10 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Stefan Hajnoczi

Stefan,

Thanks for your review.
I will do the changes you recommend and send an updated patch over the weekend.

Could you advice the best path for handling the .bdrv_flush and the blocksize questions?

I think it is reasonable to just not support iscsi at all for blocksize that is not multiple of 512 bytes
since a read-modify-write cycle across a network would probably be prohibitively expensive.

.bdrv_flush() I can easily add a synchronous implementation of this unless your patch is expected to be merged
in the near future.

regards
ronnie sahlberg

Quoted 29 lines · Stefan Hajnoczi

On Sat, Sep 10, 2011 at 02:23:30PM +1000, Ronnie Sahlberg wrote:

Looking good.  I think this is worth merging because it does offer benefits over host iSCSI.

Quoted 9 lines
block/iscsi.c new file +9 -0
+static void
+iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
+                    void *private_data)
+{
+}
+
+static void
+iscsi_aio_cancel(BlockDriverAIOCB *blockacb)
+{

block/iscsi.c line 82

Quoted 10 lines
block/iscsi.c new file +10 -0
+    IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
+    IscsiLun *iscsilun = acb->iscsilun;
+
+    acb->status = -ECANCELED;
+    acb->common.cb(acb->common.opaque, acb->status);
+    acb->canceled = 1;
+
+    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                     iscsi_abort_task_cb, NULL);
+}

The asynchronous abort task call looks odd.  If a caller allocates a buffer and issues a read request, then we need to make sure that the request is really aborted by the time .bdrv_aio_cancel() returns.

Quoted 5 lines

If I understand the code correctly, iscsi_aio_cancel() returns immediately but the read request will still be in progress.  That means the caller could now free their data buffer and the read request will overwrite that unallocated memory.

Right.
I will need to remove the read pdu from the local initiator side too so that if the read is in flight and we receive data for it, that this data is discarded
and not written into the possibly no longer valid buffers. I will do this change in the next version of the patch.

Quoted 7 lines
Quoted 7 lines
block/iscsi.c new file +7 -0
+static void
+iscsi_aio_write10_cb(struct iscsi_context *iscsi, int status,
+                     void *command_data, void *opaque)
+{
+    IscsiAIOCB *acb = opaque;
+
+    trace_iscsi_aio_write10_cb(iscsi, status, acb, acb->canceled);
Quoted 8 lines
Quoted 4 lines

+
+    if (acb->buf != NULL) {
+        free(acb->buf);
+    }

Please just use g_free(acb->buf).  g_free(NULL) is defined as a nop so the check isn't necessary.  Also, this code uses free(3) when it should use g_free(3).

Will do.

Quoted 47 lines
Quoted 32 lines
block/iscsi.c new file +31 -0
+
+    if (acb->canceled != 0) {
+        qemu_aio_release(acb);
+        scsi_free_scsi_task(acb->task);
+        acb->task = NULL;
+        return;
+    }
+
+    acb->status = 0;
+    if (status < 0) {
+        error_report("Failed to write10 data to iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        acb->status = -EIO;
+    }
+
+    iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+    scsi_free_scsi_task(acb->task);
+    acb->task = NULL;
+}
+
+static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun)
+{
+    return sector * BDRV_SECTOR_SIZE / iscsilun->block_size;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
+                 QEMUIOVector *qiov, int nb_sectors,
+                 BlockDriverCompletionFunc *cb,
+                 void *opaque)
+{

block/iscsi.c line 211

Quoted 10 lines
block/iscsi.c new file +10 -0
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+    IscsiAIOCB *acb;
+    size_t size;
+    int fua = 0;
+
+    /* set FUA on writes when cache mode is write through */
+    if (!(bs->open_flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))) {
+        fua = 1;
+    }

FUA needs to reflect the guest semantics - does this disk have an enabled write cache?  When bs->open_flags has BDRV_O_CACHE_WB, then the guest knows it needs to send flushes because there is a write cache:

Quoted 6 lines

if (!(bs->open_flags & BDRV_O_CACHE_WB)) {
   fua = 1;
}

BDRV_O_NOCACHE is just for local files and sets the O_DIRECT hint.  It doesn't affect the cache semantics that the guest sees.

Thanks. I'll do this change.

Quoted 23 lines
Quoted 9 lines
block/iscsi.c new file +8 -0
+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */
+static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = NULL;

block/iscsi.c line 481

Quoted 10 lines
block/iscsi.c new file +10 -0
+    struct iscsi_url *iscsi_url = NULL;
+    struct IscsiTask task;
+    int ret;
+
+    if ((BDRV_SECTOR_SIZE % 512) != 0) {
+        error_report("iSCSI: Invalid BDRV_SECTOR_SIZE. "
+                     "BDRV_SECTOR_SIZE(%lld) is not a multiple "
+                     "of 512", BDRV_SECTOR_SIZE);
+        return -EINVAL;
+    }

Another way of saying this is:
QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE % 512 != 0);

Quoted 2 lines

The advantage is that the build fails instead of waiting until iscsi is used at runtime until the failure is detected.

I can add this. But is it better to fail the whole build than to return an error at runtime if/when iscsi is used?

Quoted 2 lines

What will happen if BDRV_SECTOR_SIZE is not a multiple of 512?

iscsi will not work.
I dont think it is worth implementing a read-modify-write cycle for iscsi. Performance would be so poor for this case that I think it is better to just not support it at all.

Quoted 11 lines
Quoted 11 lines
block/iscsi.c new file +10 -0
+
+    memset(iscsilun, 0, sizeof(IscsiLun));
+
+    /* Should really append the KVM name after the ':' here */
+    iscsi = iscsi_create_context("iqn.2008-11.org.linux-kvm:");
+    if (iscsi == NULL) {
+        error_report("iSCSI: Failed to create iSCSI context.");
+        ret = -ENOMEM;
+        goto failed;
+    }
Quoted 8 lines
Quoted 6 lines

+
+    iscsi_url = iscsi_parse_full_url(iscsi, filename);
+    if (iscsi_url == NULL) {
+        error_report("Failed to parse URL : %s %s", filename,
+                     iscsi_get_error(iscsi));
+        ret = -ENOMEM;

-EINVAL?

Will do.

Quoted 10 lines
Quoted 10 lines
block/iscsi.c new file +9 -0
+static BlockDriver bdrv_iscsi = {
+    .format_name     = "iscsi",
+    .protocol_name   = "iscsi",
+
+    .instance_size   = sizeof(IscsiLun),
+    .bdrv_file_open  = iscsi_open,
+    .bdrv_close      = iscsi_close,
+
+    .bdrv_getlength  = iscsi_getlength,
Quoted 8 lines
Quoted 4 lines

+
+    .bdrv_aio_readv  = iscsi_aio_readv,
+    .bdrv_aio_writev = iscsi_aio_writev,
+    .bdrv_aio_flush  = iscsi_aio_flush,

block.c does not emulate .bdrv_flush() using your .bdrv_aio_flush() implementation.  I have sent a patch to add this emulation.  This will turn bdrv_flush(iscsi_bs) into an actual operation instead of a nop :).

Should I add a synchronous .bdrv_flush ? That is very easy for me to add. Or should I just wait for your patch to be merged ?

Quoted 10 lines
Quoted 10 lines
trace-events +0 -0
index 3fdd60f..4e461e5 100644
@@ -494,3 +494,10 @@ escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x"

 escc_sunkbd_event_out(int ch) "Translated keycode %2.2x" escc_kbd_command(int val) "Command %d"
 escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x" +

Quoted 8 lines

trace-events escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x" · line 502

Quoted 5 lines
trace-events +5 -0
+# block/iscsi.c
+disable iscsi_aio_write10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_writev(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+disable iscsi_aio_read10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_readv(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"

It is no longer necessary to prefix trace event definitions with "disable".

Will fix this.

Quoted 8 lines

The stderr and simple backends now start up with all events disabled by default.  The set of events can be set using the -trace events=<events-file> option or on the QEMU monitor using set trace-event <name> on.

Stefan

#11 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 4 lines · ronnie sahlberg

I think it is reasonable to just not support iscsi at all for blocksize that is not multiple of 512 bytes
since a read-modify-write cycle across a network would probably be prohibitively expensive.

Agreed.

Quoted 3 lines

.bdrv_flush() I can easily add a synchronous implementation of this unless your patch is expected to be merged
in the near future.

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

Paolo

#12 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 8 lines · Paolo Bonzini
Quoted 4 lines · ronnie sahlberg

I think it is reasonable to just not support iscsi at all for blocksize that is not multiple of 512 bytes
since a read-modify-write cycle across a network would probably be prohibitively expensive.

Agreed.

Quoted 10 lines
Quoted 3 lines

.bdrv_flush() I can easily add a synchronous implementation of this unless your patch is expected to be merged
in the near future.

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

Paolo

It seems to me that using a qemu external initiator/target pairs like Orit's original design in http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage would be a simpler (in terms of qemu code..) and flexible solution.

I agree that embedding the iscsi initiation in qemu can simplify the end user life but since this scenario is expected to be used by higher level software it's not relevant here. The risk is to have to maintain more code that won't be as general as the tgtd/lio solutions out there.

#13 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 7 lines · Dor Laor
Quoted 2 lines

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

It seems to me that using a qemu external initiator/target pairs like Orit's original design in
http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage
would be a simpler (in terms of qemu code..) and flexible solution.

Yes, it would be simpler for QEMU because everything is done outside.

However, iSCSI is a complex protocol and a complex suite of tools. With a simpler set of tools such as qemu-nbd/nbd, you can for example tunnel data over the libvirt connection. Possibly with encryption. Also, with iSCSI you're tied to raw, while qemu-nbd lets you use qcow2.

iSCSI could be a better choice if everything in the QEMU block layer was done in terms of SCSI. However, we're a far cry from that.

Quoted 4 lines

I agree that embedding the iscsi initiation in qemu can simplify the end user life but since this scenario is expected to be used by higher level software it's not relevant here. The risk is to have to maintain more code that won't be as general as the tgtd/lio solutions out there.

I'm not sure I understand. You say "embedding the iSCSI initiator in qemu can simplify the end user life" but "the risk is to have to maintain [another iSCSI target]". I don't think anybody proposed adding an iSCSI target to QEMU (in fact tcm_vhost would even let you use lio instead of QEMU's SCSI target code!). Only an iSCSI initiator which is not much code because it's just a wrapper for libiscsi.

In general, I'm not sure that libiscsi (instead of the in-kernel iSCSI initiator) is by definition a bad choice in high-end set-ups. If you want to do SCSI passthrough, it's likely better to use libiscsi rather than using the in-kernel initiator together with scsi-generic (scsi-generic sucks; bsg is better but also a useless level of indirection IMO).

Perhaps Ronnie has rough performance numbers comparing in-kernel iSCSI with libiscsi?

Paolo

#14 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

On Thu, Sep 15, 2011 at 7:11 PM, Paolo Bonzini <[email protected]> wrote:
...

Quoted 2 lines

Perhaps Ronnie has rough performance numbers comparing in-kernel iSCSI with libiscsi?

I did some tests some time ago just doing things like 'dd if=/dev/sda of=/dev/null' on the root disk from within a RHEL guest itself and performace was comparable.
In some tests libiscsi was a few percent faster, in other tests it was a few percent slower.
But overall, very unscientifically performed test, performance was not much different.

Now, I am not an expert on tuning cache or tuning the kernel scsi and iscsi layer, so I would not really want to make too many statements in the area other than in some tests I performed, performance was good enough for my use.

I would be very happy if someone competent in tuning qemu/scsi/open-iscsi (==that means, not me) would do a real comparasion.

regards
ronnie sahlberg

#15 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Paolo Bonzini
Quoted 8 lines · Paolo Bonzini
Quoted 7 lines · Dor Laor
Quoted 2 lines

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

It seems to me that using a qemu external initiator/target pairs like Orit's original design in
http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage

Quoted 8 lines
Quoted 1 line

would be a simpler (in terms of qemu code..) and flexible solution.

Yes, it would be simpler for QEMU because everything is done outside.

However, iSCSI is a complex protocol and a complex suite of tools. With a simpler set of tools such as qemu-nbd/nbd, you can for example tunnel data over the libvirt connection. Possibly with encryption. Also, with iSCSI you're tied to raw, while qemu-nbd lets you use qcow2.

My main motivation for external iScsi is to provide qemu operations w/ non shared storage. Things like streaming an image w/o shared storage or block live migration can be done where the src host exposes iscsi target and the destination is the initiator. In case of qcow2, every snapshot in the chain should be exposed as a separate LUN. The idea is to ignore the data in the guest image and treat it as opaque.

Quoted 27 lines

iSCSI could be a better choice if everything in the QEMU block layer was done in terms of SCSI. However, we're a far cry from that.

Quoted 4 lines

I agree that embedding the iscsi initiation in qemu can simplify the end user life but since this scenario is expected to be used by higher level software it's not relevant here. The risk is to have to maintain more code that won't be as general as the tgtd/lio solutions out there.

I'm not sure I understand. You say "embedding the iSCSI initiator in qemu can simplify the end user life" but "the risk is to have to maintain [another iSCSI target]". I don't think anybody proposed adding an iSCSI target to QEMU (in fact tcm_vhost would even let you use lio instead of QEMU's SCSI target code!). Only an iSCSI initiator which is not much code because it's just a wrapper for libiscsi.

In general, I'm not sure that libiscsi (instead of the in-kernel iSCSI initiator) is by definition a bad choice in high-end set-ups. If you want to do SCSI passthrough, it's likely better to use libiscsi rather than using the in-kernel initiator together with scsi-generic (scsi-generic sucks; bsg is better but also a useless level of indirection IMO).

Perhaps Ronnie has rough performance numbers comparing in-kernel iSCSI with libiscsi?

Paolo

#16 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 2 lines · Dor Laor

My main motivation for external iScsi is to provide qemu operations w/ non shared storage.

iSCSI with multiple initiator is shared storage.

#17 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 5 lines · Christoph Hellwig
Quoted 2 lines · Dor Laor

My main motivation for external iScsi is to provide qemu operations w/ non shared storage.

iSCSI with multiple initiator is shared storage.

Exactly :) that's the magic.

#18 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 6 lines · Dor Laor
Quoted 4 lines
Quoted 2 lines

My main motivation for external iScsi is to provide qemu operations w/ non shared storage.

iSCSI with multiple initiator is shared storage.

Exactly :) that's the magic.

I think we're on the same page, it's just a difference in terms. iSCSI or NBD would provide the sharing of the storage instead of NFS, basically, so the underlying storage is not shared -- right?

Paolo

#19 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Dor Laor
Quoted 6 lines · Dor Laor
Quoted 5 lines

However, iSCSI is a complex protocol and a complex suite of tools. With a simpler set of tools such as qemu-nbd/nbd, you can for example tunnel data over the libvirt connection. Possibly with encryption. Also, with iSCSI you're tied to raw, while qemu-nbd lets you use qcow2.

Quoted 6 lines

My main motivation for external iScsi is to provide qemu operations w/ non shared storage. Things like streaming an image w/o shared storage or block live migration can be done where the src host exposes iscsi target and the destination is the initiator. In case of qcow2, every snapshot in the chain should be exposed as a separate LUN. The idea is to ignore the data in the guest image and treat it as opaque.

Then you need an iSCSI *target* that understands qcow2, like qemu-nbd but for iSCSI... that's exactly the thing you were worried about implementing.

(Of course you could use qemu-nbd and expose /dev/nbd* via iSCSI, but it starts looking like an exercise in adding layers of indirections! :)).

Paolo

#20 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 14 lines · Paolo Bonzini
Quoted 6 lines · Dor Laor
Quoted 5 lines

However, iSCSI is a complex protocol and a complex suite of tools. With a simpler set of tools such as qemu-nbd/nbd, you can for example tunnel data over the libvirt connection. Possibly with encryption. Also, with iSCSI you're tied to raw, while qemu-nbd lets you use qcow2.

Quoted 6 lines

My main motivation for external iScsi is to provide qemu operations w/ non shared storage. Things like streaming an image w/o shared storage or block live migration can be done where the src host exposes iscsi target and the destination is the initiator. In case of qcow2, every snapshot in the chain should be exposed as a separate LUN. The idea is to ignore the data in the guest image and treat it as opaque.

Quoted 3 lines

Then you need an iSCSI *target* that understands qcow2, like qemu-nbd but for iSCSI... that's exactly the thing you were worried about implementing.

Not really , this is just part of the target configuration. For each file in the chain we create a lun in the target that is backed by the file and we number the luns in chronological order (base is lun
1) . you can look at a tgtd configuration here
http://wiki.qemu.org/Features/LiveBlockMigration#Example_single_base_master_image.
Orit

Quoted 6 lines

(Of course you could use qemu-nbd and expose /dev/nbd* via iSCSI, but it starts looking like an exercise in adding layers of indirections! :)).

Paolo

#21 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 9 lines · Orit Wasserman
Quoted 3 lines
Quoted 3 lines

Then you need an iSCSI*target* that understands qcow2, like qemu-nbd but for iSCSI... that's exactly the thing you were worried about implementing.

Not really , this is just part of the target configuration. For each file in the chain we create a lun in the target that is backed by the file and we number the luns in chronological order (base is lun
1) . you can look at a tgtd configuration here
http://wiki.qemu.org/Features/LiveBlockMigration#Example_single_base_master_image.

That's surely a weird way to use iSCSI. :)

It's clever, but I would call that shared storage, since you need to share the details of the snapshot chain between the source and destination, down to the file names. We need a more precise nomenclature.

Paolo

#22 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 5 lines · Paolo Bonzini
Quoted 4 lines · Orit Wasserman
Quoted 3 lines
Quoted 3 lines

Then you need an iSCSI*target* that understands qcow2, like qemu-nbd but for iSCSI... that's exactly the thing you were worried about implementing.

Quoted 7 lines
Quoted 5 lines

Not really , this is just part of the target configuration. For each file in the chain we create a lun in the target that is backed by the file and we number the luns in chronological order (base is lun
1) . you can look at a tgtd configuration here
http://wiki.qemu.org/Features/LiveBlockMigration#Example_single_base_master_image.

That's surely a weird way to use iSCSI. :)

:)

Quoted 3 lines

It's clever, but I would call that shared storage, since you need to share the details of the snapshot chain between the source and destination, down to the file names. We need a more precise nomenclature.

We store the parent base image inside the image (relative path). We can reverse engineer it in the destination , start at the highest lun ,read it's parent name , create a symbolic link to the parent (previous lun) and so on ...

Orit

Quoted 1 line

Paolo

#23 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Dor Laor
Quoted 24 lines · Dor Laor
Quoted 8 lines · Paolo Bonzini
Quoted 4 lines · ronnie sahlberg

I think it is reasonable to just not support iscsi at all for blocksize that is not multiple of 512 bytes
since a read-modify-write cycle across a network would probably be prohibitively expensive.

Agreed.

Quoted 10 lines
Quoted 3 lines

.bdrv_flush() I can easily add a synchronous implementation of this unless your patch is expected to be merged
in the near future.

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

Paolo

It seems to me that using a qemu external initiator/target pairs
like Orit's original design in http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage
would be a simpler (in terms of qemu code..) and flexible solution.

Quoted 5 lines

I agree that embedding the iscsi initiation in qemu can simplify the end user life but since this scenario is expected to be used by higher level software it's not relevant here. The risk is to have to maintain more code that won't be as general as the tgtd/lio solutions out there.

This should not be considered an either/or decision really. There are compelling benefits for having a iSCSI initiator inside QEMU which Ronnie outlined in the first mail in this thread. The enablement for non-root users is, on its own, enough justification IMHO.

* Privacy: The iSCSI LUNs are private to the guest and are not visible either to the host, nor to any processes running on the host.

* Ease of managment : If you have very many guests and very many, thousands of, iSCSI LUNs. It is inconvenient to have to expose all LUNs to the underlying host.

* No root requirement. Since the iSCSI LUNs are not mounted as devices on the host, ordinary users can set up and use iSCSI resources without the need for root privilege on the host to map the devices to local scsi devices.

There are several other benefits too

* Since the network I/O for the iSCSI LUN is now done by the QEMU process instead of the kernel, each VM's iSCSI I/O traffic can be insolated & controlled via the cgroups network contorller / tc network classifier.

* Portable across OS. Each OS has different tools for setting up iSCSI usage. A native driver lets QEMU users setup iSCSI in the same way regardless of the level of OS support for iSCSI.

Finally experiance integrating with the Linux iscsiadm command line tools in libvirt, has shown that they can be quite a PITA to integrate with if your mgmt app wants reliable/predictable results from their usage regardless of what an admin may have previously setup on the host.

So, IMHO, from a QEMU POV it makes perfect sense to have a builtin iSCSI initiator, as an alternative to using the OS' iSCSI tools externally. Vendors of applications managing KVM/QEMU are then free to decide which of the approaches they wish to support in their own products.

Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#24 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Paolo Bonzini

Am 15.09.2011 08:04, schrieb Paolo Bonzini:

Quoted 6 lines · ronnie sahlberg
Quoted 4 lines

I think it is reasonable to just not support iscsi at all for blocksize that is not multiple of 512 bytes
since a read-modify-write cycle across a network would probably be prohibitively expensive.

Quoted 8 lines

Agreed.

Quoted 3 lines

.bdrv_flush() I can easily add a synchronous implementation of this unless your patch is expected to be merged
in the near future.

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

Doesn't Stefan's patch conflict with your bdrv_co_flush patch?

Long term I think we should get rid of bdrv_flush and bdrv_aio_flush and make all drivers use bdrv_co_flush. Having three different interfaces for flush and emulation functions that do mappings for all missing implementations is just insane.

Kevin

#25 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 3 lines · Kevin Wolf
Quoted 2 lines
Quoted 2 lines

We need the same patch for NBD, so I wouldn't bother with the synchronous flush.

Doesn't Stefan's patch conflict with your bdrv_co_flush patch?

Yes. I'll include it myself in my NBD v2.

Paolo

#26 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Stefan Hajnoczi

Stefan,
Thanks for your review.
I feel that iscsi would be beneficial for several usecases.

I have implemented all changes you pointed out, except two, and resent an updated patch to the list.
Please see below.

regards
ronnie sahlberg

Quoted 29 lines · Stefan Hajnoczi

On Sat, Sep 10, 2011 at 02:23:30PM +1000, Ronnie Sahlberg wrote:

Looking good.  I think this is worth merging because it does offer benefits over host iSCSI.

Quoted 9 lines
block/iscsi.c new file +9 -0
+static void
+iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data,
+                    void *private_data)
+{
+}
+
+static void
+iscsi_aio_cancel(BlockDriverAIOCB *blockacb)
+{

block/iscsi.c line 82

Quoted 10 lines
block/iscsi.c new file +10 -0
+    IscsiAIOCB *acb = (IscsiAIOCB *)blockacb;
+    IscsiLun *iscsilun = acb->iscsilun;
+
+    acb->status = -ECANCELED;
+    acb->common.cb(acb->common.opaque, acb->status);
+    acb->canceled = 1;
+
+    iscsi_task_mgmt_abort_task_async(iscsilun->iscsi, acb->task,
+                                     iscsi_abort_task_cb, NULL);
+}

The asynchronous abort task call looks odd.  If a caller allocates a buffer and issues a read request, then we need to make sure that the request is really aborted by the time .bdrv_aio_cancel() returns.

Quoted 4 lines

If I understand the code correctly, iscsi_aio_cancel() returns immediately but the read request will still be in progress.  That means the caller could now free their data buffer and the read request will overwrite that unallocated memory.

You are right.
I have added a new function to libiscsi that will also release the task structure from libiscsi as well.
So we should no longer have a window where we might have a cancelled task in flight writing the data to an already released buffer once the cancelled data buffers start arriving on the socket.

Quoted 17 lines

block/iscsi.c line 170

Quoted 12 lines
block/iscsi.c new file +11 -0
+static void
+iscsi_aio_write10_cb(struct iscsi_context *iscsi, int status,
+                     void *command_data, void *opaque)
+{
+    IscsiAIOCB *acb = opaque;
+
+    trace_iscsi_aio_write10_cb(iscsi, status, acb, acb->canceled);
+
+    if (acb->buf != NULL) {
+        free(acb->buf);
+    }

Please just use g_free(acb->buf).  g_free(NULL) is defined as a nop so the check isn't necessary.  Also, this code uses free(3) when it shoulde. use g_free(3).

Done.

Quoted 46 lines
Quoted 31 lines
block/iscsi.c new file +31 -0
+
+    if (acb->canceled != 0) {
+        qemu_aio_release(acb);
+        scsi_free_scsi_task(acb->task);
+        acb->task = NULL;
+        return;
+    }
+
+    acb->status = 0;
+    if (status < 0) {
+        error_report("Failed to write10 data to iSCSI lun. %s",
+                     iscsi_get_error(iscsi));
+        acb->status = -EIO;
+    }
+
+    iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb);
+    scsi_free_scsi_task(acb->task);
+    acb->task = NULL;
+}
+
+static int64_t sector_qemu2lun(int64_t sector, IscsiLun *iscsilun)
+{
+    return sector * BDRV_SECTOR_SIZE / iscsilun->block_size;
+}
+
+static BlockDriverAIOCB *
+iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
+                 QEMUIOVector *qiov, int nb_sectors,
+                 BlockDriverCompletionFunc *cb,
+                 void *opaque)
+{

block/iscsi.c line 211

Quoted 10 lines
block/iscsi.c new file +10 -0
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = iscsilun->iscsi;
+    IscsiAIOCB *acb;
+    size_t size;
+    int fua = 0;
+
+    /* set FUA on writes when cache mode is write through */
+    if (!(bs->open_flags & (BDRV_O_CACHE_WB|BDRV_O_NOCACHE))) {
+        fua = 1;
+    }

FUA needs to reflect the guest semantics - does this disk have an enabled write cache?  When bs->open_flags has BDRV_O_CACHE_WB, then the guest knows it needs to send flushes because there is a write cache:

Quoted 7 lines

if (!(bs->open_flags & BDRV_O_CACHE_WB)) {
   fua = 1;
}

BDRV_O_NOCACHE is just for local files and sets the O_DIRECT hint.  It doesn't affect the cache semantics that the guest sees.

Done. When I first started building the patch a while ago, both flags were needed. I missed when the second flag became obsolete upstream.

Quoted 22 lines
Quoted 8 lines
block/iscsi.c new file +8 -0
+/*
+ * We support iscsi url's on the form
+ * iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>
+ */
+static int iscsi_open(BlockDriverState *bs, const char *filename, int flags)
+{
+    IscsiLun *iscsilun = bs->opaque;
+    struct iscsi_context *iscsi = NULL;

block/iscsi.c line 481

Quoted 10 lines
block/iscsi.c new file +10 -0
+    struct iscsi_url *iscsi_url = NULL;
+    struct IscsiTask task;
+    int ret;
+
+    if ((BDRV_SECTOR_SIZE % 512) != 0) {
+        error_report("iSCSI: Invalid BDRV_SECTOR_SIZE. "
+                     "BDRV_SECTOR_SIZE(%lld) is not a multiple "
+                     "of 512", BDRV_SECTOR_SIZE);
+        return -EINVAL;
+    }

Another way of saying this is:
QEMU_BUILD_BUG_ON(BDRV_SECTOR_SIZE % 512 != 0);

Quoted 5 lines

The advantage is that the build fails instead of waiting until iscsi is used at runtime until the failure is detected.

What will happen if BDRV_SECTOR_SIZE is not a multiple of 512?

I did not do this change.
If blocksize is not multiple of 512, the iscsi backend will just refuse to work since having a read-modify-write cycle across the network would be extremely costly.
I dont think iscsi should cause the entire build to fail.

While it is difficult to imagine a different blocksize, it is not impossible I guess.
If someone comes up with a non-512-multiple blocksize and a good reason for one, I dont want to be the guy that broke the build.

Quoted 10 lines
Quoted 10 lines
block/iscsi.c new file +10 -0
+
+    memset(iscsilun, 0, sizeof(IscsiLun));
+
+    /* Should really append the KVM name after the ':' here */
+    iscsi = iscsi_create_context("iqn.2008-11.org.linux-kvm:");
+    if (iscsi == NULL) {
+        error_report("iSCSI: Failed to create iSCSI context.");
+        ret = -ENOMEM;
+        goto failed;
+    }
Quoted 8 lines
Quoted 6 lines

+
+    iscsi_url = iscsi_parse_full_url(iscsi, filename);
+    if (iscsi_url == NULL) {
+        error_report("Failed to parse URL : %s %s", filename,
+                     iscsi_get_error(iscsi));
+        ret = -ENOMEM;

-EINVAL?

Done.

Quoted 10 lines
Quoted 10 lines
block/iscsi.c new file +9 -0
+static BlockDriver bdrv_iscsi = {
+    .format_name     = "iscsi",
+    .protocol_name   = "iscsi",
+
+    .instance_size   = sizeof(IscsiLun),
+    .bdrv_file_open  = iscsi_open,
+    .bdrv_close      = iscsi_close,
+
+    .bdrv_getlength  = iscsi_getlength,
Quoted 8 lines
Quoted 4 lines

+
+    .bdrv_aio_readv  = iscsi_aio_readv,
+    .bdrv_aio_writev = iscsi_aio_writev,
+    .bdrv_aio_flush  = iscsi_aio_flush,

block.c does not emulate .bdrv_flush() using your .bdrv_aio_flush() implementation.  I have sent a patch to add this emulation.  This will turn bdrv_flush(iscsi_bs) into an actual operation instead of a nop :).

I did not implement this since I understood from the discussion that a patch is imminent and it is required for existing backend(s?) anyway.

Quoted 10 lines
Quoted 10 lines
trace-events +0 -0
index 3fdd60f..4e461e5 100644
@@ -494,3 +494,10 @@ escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x"

 escc_sunkbd_event_out(int ch) "Translated keycode %2.2x" escc_kbd_command(int val) "Command %d"
 escc_sunmouse_event(int dx, int dy, int buttons_state) "dx=%d dy=%d buttons=%01x" +

Quoted 8 lines

trace-events escc_sunkbd_event_in(int ch) "Untranslated keycode %2.2x" · line 502

Quoted 5 lines
trace-events +5 -0
+# block/iscsi.c
+disable iscsi_aio_write10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_writev(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"
+disable iscsi_aio_read10_cb(void *iscsi, int status, void *acb, int canceled) "iscsi %p status %d acb %p canceled %d"
+disable iscsi_aio_readv(void *iscsi, int64_t sector_num, int nb_sectors, void *opaque, void *acb) "iscsi %p sector_num %"PRId64" nb_sectors %d opaque %p acb %p"

It is no longer necessary to prefix trace event definitions with "disable".

Done.

Quoted 8 lines

The stderr and simple backends now start up with all events disabled by default.  The set of events can be set using the -trace events=<events-file> option or on the QEMU monitor using set trace-event <name> on.

Stefan

#27 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

In reply to Ronnie Sahlberg

I tested this patch with the following command:
x86_64-softmmu/qemu-system-x86_64 --enable-kvm rhel54_1.img -m 1024 -net tap,ifname=tap0,script=no -net nic,model=virtio -sdl -drive file=iscsi://127.0.0.1/iqn.2011-09.com.example:server.target1/
And I found that the whole qemu process would get freezed, not reachable via ping and no response on desktop if there's I/O targeted to the iscsi drive and the iscsi target was forcefully stopped. After checking the backtrace with gdb, I found the I/O thread got stuck on the mutex qemu_global_mutex , which was hold by the vcpu thread. It should be released before re-entering guest. But the vcpu thread was waiting for the completion of iscsi aio request endlessly, and therefore couldn't get chance to release the mutex. So the whole qemu process became unresponsive. But this problem doesn't exist with the combination of virtio and iscsi. Only the I/O process got hung on guest in this case. It's more acceptable. I am not sure how to fix this problem.

gdb backtrace:

(gdb) info threads
2 Thread 0x7fa0fdd4c700 (LWP 5086) 0x0000003a868de383 in select ()
from /lib64/libc.so.6
* 1 Thread 0x7fa0fdd4d740 (LWP 5085) 0x0000003a8700dfe4 in __lll_lock_wait () from /lib64/libpthread.so.0 (gdb) bt

#0  0x0000003a8700dfe4 in __lll_lock_wait () from /lib64/libpthread.so.0
#1  0x0000003a87009318 in _L_lock_854 () from /lib64/libpthread.so.0
#2  0x0000003a870091e7 in pthread_mutex_lock () from /lib64/libpthread.so.0
#3  0x00000000004c9819 in qemu_mutex_lock (mutex=<value optimized out>) at qemu-thread-posix.c:54
#4  0x00000000004a46c6 in main_loop_wait (nonblocking=<value optimized out>) at /home/mark/Work/source/qemu/vl.c:1545
#5  0x00000000004a60d6 in main_loop (argc=<value optimized out>, argv=<value optimized out>, envp=<value optimized out>) at /home/mark/Work/source/qemu/vl.c:1579
#6  main (argc=<value optimized out>, argv=<value optimized out>, envp=<value optimized out>) at /home/mark/Work/source/qemu/vl.c:3574
(gdb) t 2
[Switching to thread 2 (Thread 0x7fa0fdd4c700 (LWP 5086))]#0  0x0000003a868de383 in select () from /lib64/libc.so.6
(gdb) bt
#0  0x0000003a868de383 in select () from /lib64/libc.so.6
#1  0x00000000004096aa in qemu_aio_wait () at aio.c:193
#2  0x0000000000409815 in qemu_aio_flush () at aio.c:113
#3  0x00000000004761ea in bmdma_cmd_writeb (bm=0x1db2230, val=8) at /home/mark/Work/source/qemu/hw/ide/pci.c:311
#4  0x0000000000555900 in access_with_adjusted_size (addr=0, value=0x7fa0fdd4bdb8, size=1, access_size_min=<value optimized out>, access_size_max=<value optimized out>, access=
    0x555820 <memory_region_write_accessor>, opaque=0x1db2370) at 
/home/mark/Work/source/qemu/memory.c:284
#5  0x0000000000555ae1 in memory_region_iorange_write (iorange=<value optimized out>, offset=<value optimized out>, width=<value optimized out>, data=8) at /home/mark/Work/source/qemu/memory.c:425
#6  0x000000000054eda1 in kvm_handle_io (env=0x192e080) at /home/mark/Work/source/qemu/kvm-all.c:834
#7  kvm_cpu_exec (env=0x192e080) at /home/mark/Work/source/qemu/kvm-all.c:976
#8  0x000000000052cc1a in qemu_kvm_cpu_thread_fn (arg=0x192e080) at /home/mark/Work/source/qemu/cpus.c:656
#9  0x0000003a870077e1 in start_thread () from /lib64/libpthread.so.0

#10 0x0000003a868e577d in clone () from /lib64/libc.so.6

#28 lore raw

Re: [Qemu-devel] [PATCH] This patch adds a new block driver : iSCSI

Quoted 7 lines · Mark Wu

I tested this patch with the following command:
x86_64-softmmu/qemu-system-x86_64 --enable-kvm rhel54_1.img -m 1024 -net tap,ifname=tap0,script=no -net nic,model=virtio -sdl -drive file=iscsi://127.0.0.1/iqn.2011-09.com.example:server.target1/ And I found that the whole qemu process would get freezed, not reachable via ping and no response on desktop if there's I/O targeted to the iscsi drive and the iscsi target was forcefully stopped. After checking the

Quoted 8 lines

backtrace with gdb, I found the I/O thread got stuck on the mutex qemu_global_mutex , which was hold by the vcpu thread. It should be released before re-entering guest. But the vcpu thread was waiting for the completion of iscsi aio request endlessly, and therefore couldn't get chance to release the mutex. So the whole qemu process became unresponsive. But this problem doesn't exist with the combination of virtio and iscsi. Only the I/O process got hung on guest in this case. It's more acceptable. I am not sure how to fix this problem.

You don't. :( It's a problem in IDE emulation and anything else that uses qemu_aio_flush; luckily it's only called in a few places.

It would be the same with NFS instead of iSCSI, for example.

Otherwise, you could implement some kind of timeout+reconnect logic in the iSCSI driver or in libiscsi.

Paolo

#29 lore raw
In reply to Ronnie Sahlberg

Am 10.09.2011 06:23, schrieb Ronnie Sahlberg:

Quoted 9 lines

List,

Please find a patch that adds built-in iSCSI support to QEMU when built and linked against the multiplatform iscsi initiator library at git://github.com/sahlberg/libiscsi.git

All previous comments and suggestions have been addressed in this patch.

I and others have done extensive testing and used this patch extensively over the last ~6 months with great result.

Quoted 8 lines

In some situations, using a built-in iscsi inititator has benefits against mounting the LUNs on the host.

* Privacy: The iSCSI LUNs are private to the guest and are not visible either to the host, nor to any processes running on the host.
* Ease of managment : If you have very many guests and very many, thousands of, iSCSI LUNs. It is inconvenient to have to expose all LUNs to the underlying host.
* No root requirement. Since the iSCSI LUNs are not mounted as devices on the host, ordinary users can set up and use iSCSI resources without the need for root privilege on the host to map the devices to local scsi devices.

Please merge this patch to master or explain how I should change the patch so that it becomes acceptable for inclusion into QEMU.

Orit, I think you could be interested in reviewing this patch?

Kevin

#30 lore raw

Looks quite good, didn't have any more comments.
We can use it for streaming with non shared storage with minor changes
(http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage)
Ronnie , are you looking into ISCSI target too?

Orit

Quoted 23 lines · Kevin Wolf

Am 10.09.2011 06:23, schrieb Ronnie Sahlberg:

Quoted 9 lines

List,

Please find a patch that adds built-in iSCSI support to QEMU when built and linked against the multiplatform iscsi initiator library at git://github.com/sahlberg/libiscsi.git

All previous comments and suggestions have been addressed in this patch.

I and others have done extensive testing and used this patch extensively over the last ~6 months with great result.

Quoted 8 lines

In some situations, using a built-in iscsi inititator has benefits against mounting the LUNs on the host.

* Privacy: The iSCSI LUNs are private to the guest and are not visible either to the host, nor to any processes running on the host.
* Ease of managment : If you have very many guests and very many, thousands of, iSCSI LUNs. It is inconvenient to have to expose all LUNs to the underlying host.
* No root requirement. Since the iSCSI LUNs are not mounted as devices on the host, ordinary users can set up and use iSCSI resources without the need for root privilege on the host to map the devices to local scsi devices.

Please merge this patch to master or explain how I should change the patch so that it becomes acceptable for inclusion into QEMU.

Orit, I think you could be interested in reviewing this patch?

Kevin

#32 lore raw
In reply to Orit Wasserman
Quoted 3 lines · Orit Wasserman

Looks quite good, didn't have any more comments.
We can use it for streaming with non shared storage with minor changes
(http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage)

That whole section makes little sense to me. An iSCSI target with multiple initiator talking to it is by defintion shared storage. Having the target on the same physical box as on of the initiators doesn't really change that.

#33 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Orit Wasserman

Looks quite good, didn't have any more comments.
We can use it for streaming with non shared storage with minor changes
(http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage)

That whole section makes little sense to me.  An iSCSI target with multiple initiator talking to it is by defintion shared storage.  Having the target on the same physical box as on of the initiators doesn't really change that.

I think the motivation for iSCSI target support in QEMU is exactly what you mentioned - providing shared storage. In migration scenarios it is necessary temporarily make shared storage possible with an image that is on a local disk.

Stefan

#34 lore raw
Quoted 4 lines · Stefan Hajnoczi

I think the motivation for iSCSI target support in QEMU is exactly what you mentioned - providing shared storage. In migration scenarios it is necessary temporarily make shared storage possible with an image that is on a local disk.

Why do we need to use the complex iSCSI protocol for that instead of simply using NBD?

#35 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Stefan Hajnoczi

I think the motivation for iSCSI target support in QEMU is exactly what you mentioned - providing shared storage.  In migration scenarios it is necessary temporarily make shared storage possible with an image that is on a local disk.

Why do we need to use the complex iSCSI protocol for that instead of simply using NBD?

I think NBD would be fine, especially with a flush command.

Stefan

#36 lore raw
Quoted 4 lines · Stefan Hajnoczi
Quoted 2 lines

Why do we need to use the complex iSCSI protocol for that instead of simply using NBD?

I think NBD would be fine, especially with a flush command.

Indeed: http://permalink.gmane.org/gmane.comp.emulators.qemu/113639

iSCSI is still very useful to easily deploy remote storage, and more long term for passthrough to an HBA provided by QEMU (as an alternative to scsi-generic).

Paolo

#37 lore raw
In reply to Stefan Hajnoczi
Quoted 11 lines · Stefan Hajnoczi
Quoted 8 lines · Christoph Hellwig
Quoted 4 lines · Stefan Hajnoczi

I think the motivation for iSCSI target support in QEMU is exactly what you mentioned - providing shared storage. In migration scenarios it is necessary temporarily make shared storage possible with an image that is on a local disk.

Why do we need to use the complex iSCSI protocol for that instead of simply using NBD?

I think NBD would be fine, especially with a flush command.

If I remember correctly , there is a problem with NBD with an image with a backing file chain . NBD client only displays a single file image. With ISCSI we can use different luns per image file.
Orit

Quoted 2 lines

Stefan

#38 lore raw
Quoted 5 lines · Orit Wasserman
Quoted 1 line

I think NBD would be fine, especially with a flush command.

I think NBD would be fine, especially with a flush command.
If I remember correctly , there is a problem with NBD with an image with a backing file chain . NBD client only displays a single file image. With ISCSI we can use different luns per image file.

The NBD protocol supports multiple named exports, just not QEMU's implementation.

Paolo

#39 lore raw
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Orit Wasserman
Quoted 1 line

I think NBD would be fine, especially with a flush command.

I think NBD would be fine, especially with a flush command.
If I remember correctly , there is a problem with NBD with an image with a backing file chain . NBD client only displays a single file image. With ISCSI we can use different luns per image file.

The NBD protocol supports multiple named exports, just not QEMU's implementation.

I guess we can fix that.
Orit

Quoted 2 lines

Paolo

#40 lore raw
Quoted 3 lines · Orit Wasserman
Quoted 2 lines

The NBD protocol supports multiple named exports, just not QEMU's implementation.

I guess we can fix that.

Yes, or just use Unix sockets and rely on libvirt to tunnel/multiplex the NBD streams.

Paolo

#41 lore raw

Am 15.09.2011 11:55, schrieb Paolo Bonzini:

Quoted 7 lines · Orit Wasserman
Quoted 3 lines
Quoted 2 lines

The NBD protocol supports multiple named exports, just not QEMU's implementation.

I guess we can fix that.

Yes, or just use Unix sockets and rely on libvirt to tunnel/multiplex the NBD streams.

I don't think libvirt should have to deal with this when there is a good solution that can be implemented in qemu.

Kevin

#42 lore raw
In reply to Paolo Bonzini
Quoted 9 lines · Paolo Bonzini
Quoted 5 lines · Orit Wasserman
Quoted 1 line

I think NBD would be fine, especially with a flush command.

I think NBD would be fine, especially with a flush command.
If I remember correctly , there is a problem with NBD with an image with a backing file chain . NBD client only displays a single file image. With ISCSI we can use different luns per image file.

The NBD protocol supports multiple named exports, just not QEMU's implementation.

Named exports are supported since commit
1d45f8b542f6b80b24c44533ef0dd9e1a3b17ea5

Regards,
Laurent

#43 lore raw
Quoted 4 lines · Laurent Vivier
Quoted 2 lines
Quoted 2 lines

The NBD protocol supports multiple named exports, just not QEMU's implementation.

Named exports are supported since commit
1d45f8b542f6b80b24c44533ef0dd9e1a3b17ea5

Yes, not in the qemu-nbd server though.

Paolo

#44 lore raw
In reply to Orit Wasserman
Quoted 4 lines · Orit Wasserman

Looks quite good, didn't have any more comments.
We can use it for streaming with non shared storage with minor changes
(http://wiki.qemu.org/Features/LiveBlockMigration#ISCSI_for_non_shared_storage)
Ronnie , are you looking into ISCSI target too?

No immediate plans. I mainly use real iSCSI targets.
Immediate plans are primarily getting iscsi initiator support into qemu and second to maybe present it as a HBA to the guest, as a second step.

I do have iscsi target code from an old abandoned project of mine that can be used, so yes,
I could build a small simple iscsi target at some stage for qemu for usecases where TGTD or other solutions are inconvenient.

regards
ronnie sahlberg