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'
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user