virStoragePoolSourceAdapter: Refine the SCSI_HOST adapter name

Preparation for future patches by creating a scsi_host union. For now,
just the 'name' will be present.
This commit is contained in:
Osier Yang 2014-03-03 15:04:17 -05:00 committed by John Ferlan
parent 8d854e5b5b
commit 53f620568e
4 changed files with 16 additions and 13 deletions

View File

@ -343,7 +343,7 @@ virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapter adapter)
VIR_FREE(adapter.data.fchost.parent);
} else if (adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
VIR_FREE(adapter.data.name);
VIR_FREE(adapter.data.scsi_host.name);
}
}
@ -576,7 +576,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
virXPathString("string(./adapter/@wwpn)", ctxt);
} else if (source->adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
source->adapter.data.name =
source->adapter.data.scsi_host.name =
virXPathString("string(./adapter/@name)", ctxt);
}
} else {
@ -601,7 +601,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
/* To keep back-compat, 'type' is not required to specify
* for scsi_host adapter.
*/
if ((source->adapter.data.name =
if ((source->adapter.data.scsi_host.name =
virXPathString("string(./adapter/@name)", ctxt)))
source->adapter.type =
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST;
@ -854,7 +854,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
goto error;
} else if (ret->source.adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
if (!ret->source.adapter.data.name) {
if (!ret->source.adapter.data.scsi_host.name) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing storage pool source adapter name"));
goto error;
@ -1021,7 +1021,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
src->adapter.data.fchost.wwpn);
} else if (src->adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
virBufferAsprintf(buf, " name='%s'/>\n", src->adapter.data.name);
virBufferAsprintf(buf, " name='%s'/>\n",
src->adapter.data.scsi_host.name);
}
}
@ -2028,8 +2029,8 @@ virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools,
matchpool = pool;
} else if (pool->def->source.adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST){
if (STREQ(pool->def->source.adapter.data.name,
def->source.adapter.data.name))
if (STREQ(pool->def->source.adapter.data.scsi_host.name,
def->source.adapter.data.scsi_host.name))
matchpool = pool;
}
break;

View File

@ -179,7 +179,9 @@ struct _virStoragePoolSourceAdapter {
int type; /* virStoragePoolSourceAdapterType */
union {
char *name;
struct {
char *name;
} scsi_host;
struct {
char *parent;
char *wwnn;

View File

@ -1975,7 +1975,7 @@ phypStorageVolCreateXML(virStoragePoolPtr pool,
spdef->source.ndevice = 1;
/*XXX source adapter not working properly, should show hdiskX */
if ((spdef->source.adapter.data.name =
if ((spdef->source.adapter.data.scsi_host.name =
phypGetStoragePoolDevice(pool->conn, pool->name)) == NULL) {
VIR_ERROR(_("Unable to determine storage pools's source adapter."));
goto err;
@ -2197,7 +2197,7 @@ phypStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
pool.source.ndevice = 1;
if ((pool.source.adapter.data.name =
if ((pool.source.adapter.data.scsi_host.name =
phypGetStoragePoolDevice(sp->conn, sp->name)) == NULL) {
VIR_ERROR(_("Unable to determine storage sps's source adapter."));
goto cleanup;
@ -2436,7 +2436,7 @@ phypBuildStoragePool(virConnectPtr conn, virStoragePoolDefPtr def)
managed_system, vios_id);
virBufferAsprintf(&buf, "mksp -f %schild %s", def->name,
source.adapter.data.name);
source.adapter.data.scsi_host.name);
if (system_type == HMC)
virBufferAddChar(&buf, '\'');
@ -2667,7 +2667,7 @@ phypStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
def.source.ndevice = 1;
/*XXX source adapter not working properly, should show hdiskX */
if ((def.source.adapter.data.name =
if ((def.source.adapter.data.scsi_host.name =
phypGetStoragePoolDevice(pool->conn, pool->name)) == NULL) {
VIR_ERROR(_("Unable to determine storage pools's source adapter."));
goto err;

View File

@ -548,7 +548,7 @@ getAdapterName(virStoragePoolSourceAdapter adapter)
char *name = NULL;
if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
ignore_value(VIR_STRDUP(name, adapter.data.name));
ignore_value(VIR_STRDUP(name, adapter.data.scsi_host.name));
} else if (adapter.type == VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST) {
if (!(name = virGetFCHostNameByWWN(NULL,
adapter.data.fchost.wwnn,