startPool creates the vHBA if it's not existed yet, stopPool destroys
the vHBA. Also to support autostart, checkPool will creates the vHBA
if it's not existed yet.
---
src/storage/storage_backend_scsi.c | 64 ++++++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c
index 8166311..a9b96a3 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -634,6 +634,36 @@ getAdapterName(virStoragePoolSourceAdapter adapter)
}
static int
+createVport(virStoragePoolSourceAdapter adapter)
+{
+ int parent_host;
+
+ if (adapter.type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)
+ return 0;
+
+ /* This filters either HBA or already created vHBA */
+ if (virGetFCHostNameByWWN(NULL, adapter.data.fchost.wwnn,
+ adapter.data.fchost.wwpn))
+ return 0;
+
+ if (!adapter.data.fchost.parent) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("'parent' for vHBA must be specified"));
+ return -1;
+ }
+
+ if ((parent_host = getHostNumber(adapter.data.fchost.parent)) < 0)
+ return -1;
+
+ if (virManageVport(parent_host, adapter.data.fchost.wwnn,
+ adapter.data.fchost.wwpn, VPORT_CREATE) < 0)
+ return -1;
+
+ virFileWaitForDevices();
+ return 0;
+}
+
+static int
virStorageBackendSCSICheckPool(virConnectPtr conn ATTRIBUTE_UNUSED,
virStoragePoolObjPtr pool,
bool *isActive)
@@ -695,10 +725,44 @@ out:
return ret;
}
+static int
+virStorageBackendSCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool)
+{
+ virStoragePoolSourceAdapter adapter = pool->def->source.adapter;
+
+ return createVport(adapter);
+}
+
+static int
+virStorageBackendSCSIStopPool(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virStoragePoolObjPtr pool)
+{
+ virStoragePoolSourceAdapter adapter = pool->def->source.adapter;
+ int parent_host;
+
+ if (adapter.type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)
+ return 0;
+
+ if (!(virGetFCHostNameByWWN(NULL, adapter.data.fchost.wwnn,
+ adapter.data.fchost.wwpn)))
+ return -1;
+
+ if ((parent_host = getHostNumber(adapter.data.fchost.parent)) < 0)
+ return -1;
+
+ if (virManageVport(parent_host, adapter.data.fchost.wwnn,
+ adapter.data.fchost.wwpn, VPORT_DELETE) < 0)
+ return -1;
+
+ return 0;
+}
virStorageBackend virStorageBackendSCSI = {
.type = VIR_STORAGE_POOL_SCSI,
.checkPool = virStorageBackendSCSICheckPool,
.refreshPool = virStorageBackendSCSIRefreshPool,
+ .startPool = virStorageBackendSCSIStartPool,
+ .stopPool = virStorageBackendSCSIStopPool,
};
--
1.7.7.6