MEMORY add compatibility for qemu-kvm

qemu-kvm iscsi block driver calls iscsi_parse_full_url without
a valid iscsi_context. The driver also creates its own scsi_task
objects.
This commit is contained in:
Peter Lieven
2012-11-03 02:05:16 +01:00
parent 7f98233169
commit 871c56ce7a
4 changed files with 35 additions and 14 deletions

View File

@@ -424,11 +424,15 @@ iscsi_parse_url(struct iscsi_context *iscsi, const char *url, int full)
if (tmp) *tmp=0;
}
iscsi_url = iscsi_zmalloc(iscsi, sizeof(struct iscsi_url));
if (iscsi != NULL)
iscsi_url = iscsi_malloc(iscsi, sizeof(struct iscsi_url));
else
iscsi_url = malloc(sizeof(struct iscsi_url));
if (iscsi_url == NULL) {
iscsi_set_error(iscsi, "Out-of-memory: Failed to allocate iscsi_url structure");
return NULL;
}
memset(iscsi_url, 0, sizeof(struct iscsi_url));
iscsi_url->iscsi= iscsi;
strncpy(iscsi_url->portal,portal,MAX_STRING_SIZE);
@@ -461,7 +465,10 @@ iscsi_parse_portal_url(struct iscsi_context *iscsi, const char *url)
void
iscsi_destroy_url(struct iscsi_url *iscsi_url)
{
iscsi_free(iscsi_url->iscsi, iscsi_url);
if (iscsi_url->iscsi != NULL)
iscsi_free(iscsi_url->iscsi, iscsi_url);
else
free(iscsi_url);
}