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>
|
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
|
||||||
|
@ -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,13 +590,17 @@ virStorageBackendISCSIStartPool(virConnectPtr conn,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL)
|
if ((session = virStorageBackendISCSISession(conn, pool, 1)) == NULL) {
|
||||||
return -1;
|
if ((portal = virStorageBackendISCSIPortal(conn, pool)) == NULL)
|
||||||
if (virStorageBackendISCSILogin(conn, pool, portal) < 0) {
|
return -1;
|
||||||
|
if (virStorageBackendISCSILogin(conn, pool, portal) < 0) {
|
||||||
|
VIR_FREE(portal);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
VIR_FREE(portal);
|
VIR_FREE(portal);
|
||||||
return -1;
|
} else {
|
||||||
|
VIR_FREE(session);
|
||||||
}
|
}
|
||||||
VIR_FREE(portal);
|
|
||||||
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;
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user