VERIFY10/12/16 If BYTCHK is false we dont need to transfer any blocks to the target

If BYTCHK is false the target will perform a medium check of the indicated
LBAs only and not compare with anything out of the DATA-OUT buffers.
As such we dont need to/should not transfer any DAT-OUT to the target.
TESTS: Update the VERIFY10/12/16 tests for BYTCHK==0
LOGGING add target name to log output
LOGGING log target_name and not initator_name
INIT check iscsi==NULL in iscsi_get_error()

qemu-kvm calls iscsi_get_error(NULL) if we specify an invalid URL
tiny style change
CONNECT fixed memleak in case iscsi_connect_async fails directly
Revert "CONNECT only read/write from sockets when connection is established"

Fixed the login process in qemu-kvm. This makes this fix obsolete.

This reverts commit a9257d52a7577b607e237e209b9868c5ce78a927.
RECONNECT exit from sync event_loop in case of an error

If there is an error during reconnect we should not loop in event_loop
as this will cause a deadlock in case there is actually an error like
connection drop etc. If this reconnect fails the reconnect routine
will retry itself.
SYNC set status to -1 on error in event_loop

If there is an error in iscsi_service or on poll we
exit the event_loop. But in this case scsi_sync_cb is
never reached and the status is 0. This will make
the caller think that the sync task has been completed
successfully.
MEMORY further remove memory reallocations

added a few tweaks to further remove the need to memory
allocation resizing by preallocating the right buffer size.

Signed-off-by: Peter Lieven <pl@kamp.de>
CONNECT add further debug output regardint login and reconnect
RECONNECT avoid deadlock on reconnect retry timeout

If there is a clock jump e.g. due to daylight saving time
the wait can be almost infinite
Returned buffers from poptGetArgs() are free()ed in poptFreeContext()

Calling "free(url);" causes a core dump in glibc-2.15.

Signed-off-by: Bernhard Kohl <bernhard.kohl@gmx.net>
Merge pull request #38 from aredlich/master

Remove scsi_task->params
Add support for SCSI Sense formats 0x72/0x73
ISCSI-DD: Remove some compiler warnings
Add support to unmarshall a CDB into a structure and update iscsi-dd

Add two new helper functions scsi_get_uint32() and scsi_get_uint16()
SCSI: Pass the expected opcode to scsi_cdb_unmarshall()

Pass the opcode we expect to the unmarshalling function so it can do a basic
check that we are trying to unmarshalling the right kind of cdb.
SCSI add support for iovectors

If an application passes buffers to libiscsi for reading they are
currently added to a linked list one by one. This leads to a malloc
for each buffer object plus O(n) walks trough the list to add
the buffer to then end of the list. Additionally the buffer read
routine takes up to O(n) iterations to find the right buffer
for a request.

This patch introduces an scsi_iovector struct to pass buffers to
an scsi task. Adding a new buffer is in O(1) and finding the
right buffer to also. Malloc requirements are in O(log(n)).

Additionally the scsi_iovector struct is itended to be binary
compatible to an QEMUIOVector allowing to pass this structure
directly to the library.

Initial tests have been made booting an Ubuntu LTS 12.04.1
Desktop server up to the login prompt. The following observations
have been made with regards to scsi_malloc calls:

original implementation:	~11.500 mallocs
using iovector instead of list:	~ 7.500 mallocs
passing the iovector directly:        0 mallocs

To enable this feature in qemu for testing the following patch might
be used:

diff --git a/block/iscsi.c b/block/iscsi.c
index a6a819d..2809c15 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -390,11 +390,16 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num,
         return NULL;
     }

+#if defined(LIBISCSI_FEATURE_IOVECTOR)
+    assert(sizeof(struct QEMUIOVector) == sizeof(struct scsi_iovector));
+    scsi_iovector_assign(acb->task, (struct scsi_iovector*) acb->qiov);
+#else
     for (i = 0; i < acb->qiov->niov; i++) {
         scsi_task_add_data_in_buffer(acb->task,
                 acb->qiov->iov[i].iov_len,
                 acb->qiov->iov[i].iov_base);
     }
+#endif

     iscsi_set_events(iscsilun);

---
Signed-off-by: Peter Lieven <pl@kamp.de>