Allow storage driver to handle daemon restarts

This commit is contained in:
Daniel P. Berrange 2009-01-20 22:43:07 +00:00
parent 23a090ab92
commit e3672d9695
3 changed files with 23 additions and 30 deletions

View File

@ -1,3 +1,11 @@
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> Tue Jan 20 22:25:53 GMT 2009 Daniel P. Berrange <berrange@redhat.com>
Allow virtual networks to survive a daemon restart Allow virtual networks to survive a daemon restart

View File

@ -107,7 +107,8 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn,
static char * static char *
virStorageBackendISCSISession(virConnectPtr conn, virStorageBackendISCSISession(virConnectPtr conn,
virStoragePoolObjPtr pool) virStoragePoolObjPtr pool,
int probe)
{ {
/* /*
* # iscsiadm --mode session * # iscsiadm --mode session
@ -141,7 +142,8 @@ virStorageBackendISCSISession(virConnectPtr conn,
NULL) < 0) NULL) < 0)
return NULL; return NULL;
if (session == NULL) { if (session == NULL &&
!probe) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot find session")); "%s", _("cannot find session"));
return NULL; return NULL;
@ -573,6 +575,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
virStoragePoolObjPtr pool) virStoragePoolObjPtr pool)
{ {
char *portal = NULL; char *portal = NULL;
char *session;
if (pool->def->source.host.name == NULL) { if (pool->def->source.host.name == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR, virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
@ -587,6 +590,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
return -1; return -1;
} }
if ((session = virStorageBackendISCSISession(conn, pool, 1)) == NULL) {
if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL) if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL)
return -1; return -1;
if (virStorageBackendISCSILogin(conn, pool, portal) < 0) { if (virStorageBackendISCSILogin(conn, pool, portal) < 0) {
@ -594,6 +598,9 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
return -1; return -1;
} }
VIR_FREE(portal); VIR_FREE(portal);
} else {
VIR_FREE(session);
}
return 0; return 0;
} }
@ -607,7 +614,7 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn,
virStorageBackendWaitForDevices(conn); virStorageBackendWaitForDevices(conn);
if ((session = virStorageBackendISCSISession(conn, pool)) == NULL) if ((session = virStorageBackendISCSISession(conn, pool, 0)) == NULL)
goto cleanup; goto cleanup;
if (virStorageBackendISCSIRescanLUNs(conn, pool, session) < 0) if (virStorageBackendISCSIRescanLUNs(conn, pool, session) < 0)
goto cleanup; goto cleanup;

View File

@ -238,32 +238,10 @@ storageDriverActive(void) {
*/ */
static int static int
storageDriverShutdown(void) { storageDriverShutdown(void) {
unsigned int i;
if (!driverState) if (!driverState)
return -1; return -1;
storageDriverLock(driverState); 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 */ /* free inactive pools */
virStoragePoolObjListFree(&driverState->pools); virStoragePoolObjListFree(&driverState->pools);