/*
 * Perform actual discovery against the target
 */
void iSCSILibWrapper::iSCSIPerformDiscovery(void)
{
    // Remove us from the background thread
    iSCSIBackGround::GetInstance().RemoveConnection(*this);

    mClient.finished = 0;

    // Clean up those pairs ... from any previous discovery
    if (mDiscoveryPairs.size())
    {
       while (mDiscoveryPairs.size())
           mDiscoveryPairs.erase(mDiscoveryPairs.begin());
    }

    if (iscsi_discovery_async(mIscsi, discovery_cb, this))
    {
	mError = true;
        mErrorString.Format("%s: Failed to send discovery for target %s: %s",
                          __func__,
                          mTarget.c_str(),
                          iscsi_get_error(mIscsi));
        throw CException(mErrorString);
    }

    ServiceISCSIEvents();

    // Add to the background task
    iSCSIBackGround::GetInstance().AddConnection(*this);

}
示例#2
0
void discoverylogin_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data)
{
	if (status != 0) {
		printf("Failed to log in to target. status :0x%04x\n", status);
		exit(10);
	}

	printf("Logged in to target, send discovery command\n");
	if (iscsi_discovery_async(iscsi, discovery_cb, private_data) != 0) {
		printf("failed to send discovery command\n");
		exit(10);
	}

}