diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index afd6cd4652..52656e59f4 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -343,15 +343,15 @@ virStorageVolDefFree(virStorageVolDefPtr def) } static void -virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapter adapter) +virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter) { - if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { - VIR_FREE(adapter.data.fchost.wwnn); - VIR_FREE(adapter.data.fchost.wwpn); - VIR_FREE(adapter.data.fchost.parent); - } else if (adapter.type == + if (adapter->type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) { + VIR_FREE(adapter->data.fchost.wwnn); + VIR_FREE(adapter->data.fchost.wwpn); + VIR_FREE(adapter->data.fchost.parent); + } else if (adapter->type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) { - VIR_FREE(adapter.data.scsi_host.name); + VIR_FREE(adapter->data.scsi_host.name); } } @@ -380,7 +380,7 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr source) VIR_FREE(source->devices); VIR_FREE(source->dir); VIR_FREE(source->name); - virStoragePoolSourceAdapterClear(source->adapter); + virStoragePoolSourceAdapterClear(&source->adapter); VIR_FREE(source->initiator.iqn); virStorageAuthDefFree(source->auth); VIR_FREE(source->vendor); diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h index 1276ac2726..a9b5bdb9b6 100644 --- a/src/conf/storage_conf.h +++ b/src/conf/storage_conf.h @@ -177,6 +177,7 @@ typedef enum { VIR_ENUM_DECL(virStoragePoolSourceAdapter) typedef struct _virStoragePoolSourceAdapter virStoragePoolSourceAdapter; +typedef virStoragePoolSourceAdapter *virStoragePoolSourceAdapterPtr; struct _virStoragePoolSourceAdapter { int type; /* virStoragePoolSourceAdapterType */ diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index bfef219674..a5bb85f5fc 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -644,24 +644,25 @@ checkVhbaSCSIHostParent(virConnectPtr conn, static int createVport(virConnectPtr conn, - virStoragePoolSourceAdapter adapter) + virStoragePoolDefPtr def) { + virStoragePoolSourceAdapterPtr adapter = &def->source.adapter; unsigned int parent_host; char *name = NULL; - if (adapter.type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) + if (adapter->type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) return 0; /* If a parent was provided, then let's make sure it's vhost capable */ - if (adapter.data.fchost.parent) { - if (virGetSCSIHostNumber(adapter.data.fchost.parent, &parent_host) < 0) + if (adapter->data.fchost.parent) { + if (virGetSCSIHostNumber(adapter->data.fchost.parent, &parent_host) < 0) return -1; if (!virIsCapableFCHost(NULL, parent_host)) { virReportError(VIR_ERR_XML_ERROR, _("parent '%s' specified for vHBA " "is not vport capable"), - adapter.data.fchost.parent); + adapter->data.fchost.parent); return -1; } } @@ -670,35 +671,35 @@ createVport(virConnectPtr conn, * using the wwnn/wwpn, then a nodedev is already created for * this pool and we don't have to create the vHBA */ - if ((name = virGetFCHostNameByWWN(NULL, adapter.data.fchost.wwnn, - adapter.data.fchost.wwpn))) { + if ((name = virGetFCHostNameByWWN(NULL, adapter->data.fchost.wwnn, + adapter->data.fchost.wwpn))) { int retval = 0; /* If a parent was provided, let's make sure the 'name' we've * retrieved has the same parent */ - if (adapter.data.fchost.parent && - !checkVhbaSCSIHostParent(conn, name, adapter.data.fchost.parent)) + if (adapter->data.fchost.parent && + !checkVhbaSCSIHostParent(conn, name, adapter->data.fchost.parent)) retval = -1; VIR_FREE(name); return retval; } - if (!adapter.data.fchost.parent) { - if (!(adapter.data.fchost.parent = virFindFCHostCapableVport(NULL))) { + if (!adapter->data.fchost.parent) { + if (!(adapter->data.fchost.parent = virFindFCHostCapableVport(NULL))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("'parent' for vHBA not specified, and " "cannot find one on this host")); return -1; } - if (virGetSCSIHostNumber(adapter.data.fchost.parent, &parent_host) < 0) + if (virGetSCSIHostNumber(adapter->data.fchost.parent, &parent_host) < 0) return -1; } - if (virManageVport(parent_host, adapter.data.fchost.wwpn, - adapter.data.fchost.wwnn, VPORT_CREATE) < 0) + if (virManageVport(parent_host, adapter->data.fchost.wwpn, + adapter->data.fchost.wwnn, VPORT_CREATE) < 0) return -1; virFileWaitForDevices(); @@ -816,8 +817,7 @@ static int virStorageBackendSCSIStartPool(virConnectPtr conn, virStoragePoolObjPtr pool) { - virStoragePoolSourceAdapter adapter = pool->def->source.adapter; - return createVport(conn, adapter); + return createVport(conn, pool->def); } static int