提交 e3672d96 编写于 作者: D Daniel P. Berrange

Allow storage driver to handle daemon restarts

上级 23a090ab
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
......
......@@ -107,7 +107,8 @@ virStorageBackendISCSIExtractSession(virConnectPtr conn,
static char *
virStorageBackendISCSISession(virConnectPtr conn,
virStoragePoolObjPtr pool)
virStoragePoolObjPtr pool,
int probe)
{
/*
* # iscsiadm --mode session
......@@ -141,7 +142,8 @@ virStorageBackendISCSISession(virConnectPtr conn,
NULL) < 0)
return NULL;
if (session == NULL) {
if (session == NULL &&
!probe) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("cannot find session"));
return NULL;
......@@ -573,6 +575,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
virStoragePoolObjPtr pool)
{
char *portal = NULL;
char *session;
if (pool->def->source.host.name == NULL) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
......@@ -587,13 +590,17 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
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;
}
......@@ -607,7 +614,7 @@ virStorageBackendISCSIRefreshPool(virConnectPtr conn,
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;
......
......@@ -238,32 +238,10 @@ storageDriverActive(void) {
*/
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册