Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CONNECT only read/write from sockets when connection is established
qemu-kvm/qemu-img starts in+out polls from the socket before the connection is
established. This leads to a hang if the connection cant be established
(i.e. the target is down when qemu-kvm is started).

before:
LIBISCSI_DEBUG=2 qemu-img convert -f iscsi -O raw iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0 /dev/null
libiscsi: connecting to portal 127.0.0.1 [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
libiscsi: read from socket failed, errno:111 [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
libiscsi: connection to 127.0.0.1 established [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
->success!!

after:
LIBISCSI_DEBUG=1 qemu-img convert -f iscsi -O raw iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0 /dev/null
libiscsi: iscsi_service: socket error Connection refused(111) while connecting. [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
libiscsi: Failed to connect to iSCSI socket. iscsi_service: socket error Connection refused(111) while connecting. [iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac]
qemu-img: iSCSI: Failed to connect to LUN : Failed to connect to iSCSI socket. iscsi_service: socket error Connection refused(111) while connecting.
qemu-img: Could not open 'iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0': Invalid argument
qemu-img: Could not open 'iscsi://127.0.0.1/iqn.2004-04.com.qnap:ts-809u:iscsi.lieven20.c53dac/0'
  • Loading branch information
plieven committed Oct 30, 2012
1 parent a0fb2d1 commit a9257d5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/socket.c
Expand Up @@ -508,12 +508,12 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
return 0;
}

if (revents & POLLOUT && iscsi->outqueue != NULL) {
if (iscsi->is_connected && revents & POLLOUT && iscsi->outqueue != NULL) {
if (iscsi_write_to_socket(iscsi) != 0) {
return iscsi_service_reconnect_if_loggedin(iscsi);
}
}
if (revents & POLLIN) {
if (iscsi->is_connected && revents & POLLIN) {
if (iscsi_read_from_socket(iscsi) != 0) {
return iscsi_service_reconnect_if_loggedin(iscsi);
}
Expand Down

0 comments on commit a9257d5

Please sign in to comment.