mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 02:51:16 +00:00
Allow storage driver to handle daemon restarts
This commit is contained in:
parent
23a090ab92
commit
e3672d9695
@ -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>
|
||||
|
||||
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,6 +590,7 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((session = virStorageBackendISCSISession(conn, pool, 1)) == NULL) {
|
||||
if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL)
|
||||
return -1;
|
||||
if (virStorageBackendISCSILogin(conn, pool, portal) < 0) {
|
||||
@ -594,6 +598,9 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
|
||||
return -1;
|
||||
}
|
||||
VIR_FREE(portal);
|
||||
} else {
|
||||
VIR_FREE(session);
|
||||
}
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user