+Tue Jan 20 22:39:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
+
+ Properly handle daemon restarts with storage driver
+ * src/storage_backend_iscsi.c: Detect if already logged into
+ an iSCSI target
+ * src/storage_driver.c: Don't shutdown storage when daemon
+ shuts down
+
Tue Jan 20 22:25:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Allow virtual networks to survive a daemon restart
static char *
virStorageBackendISCSISession(virConnectPtr conn,
- virStoragePoolObjPtr pool)
+ virStoragePoolObjPtr pool,
+ int probe)
{
/*
* # iscsiadm --mode session
NULL) < 0)
return NULL;
- if (session == NULL) {
+ if (session == NULL &&
+ !probe) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot find session"));
return NULL;
virStoragePoolObjPtr pool)
{
char *portal = NULL;
+ char *session;
if (pool->def->source.host.name == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
return -1;
}
- if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL)
- return -1;
- if (virStorageBackendISCSILogin(conn, pool, portal) < 0) {
+ if ((session = virStorageBackendISCSISession(conn, pool, 1)) == NULL) {
+ if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL)
+ return -1;
+ if (virStorageBackendISCSILogin(conn, pool, portal) < 0) {
+ VIR_FREE(portal);
+ return -1;
+ }
VIR_FREE(portal);
- return -1;
+ } else {
+ VIR_FREE(session);
}
- VIR_FREE(portal);
return 0;
}
virStorageBackendWaitForDevices(conn);
- if ((session = virStorageBackendISCSISession(conn, pool)) == NULL)
+ if ((session = virStorageBackendISCSISession(conn, pool, 0)) == NULL)
goto cleanup;
if (virStorageBackendISCSIRescanLUNs(conn, pool, session) < 0)
goto cleanup;
*/
static int
storageDriverShutdown(void) {
- unsigned int i;
-
if (!driverState)
return -1;
storageDriverLock(driverState);
- /* shutdown active pools */
- for (i = 0 ; i < driverState->pools.count ; i++) {
- virStoragePoolObjPtr pool = driverState->pools.objs[i];
-
- if (virStoragePoolObjIsActive(pool)) {
- virStorageBackendPtr backend;
- if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
- storageLog("Missing backend");
- continue;
- }
-
- if (backend->stopPool &&
- backend->stopPool(NULL, pool) < 0) {
- virErrorPtr err = virGetLastError();
- storageLog("Failed to stop storage pool '%s': %s",
- pool->def->name, err ? err->message : NULL);
- }
- virStoragePoolObjClearVols(pool);
- }
- }
/* free inactive pools */
virStoragePoolObjListFree(&driverState->pools);