From ae2163f852448fafce3bfcb2814e823d18e394ea Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 4 Dec 2012 12:12:51 +0000 Subject: [PATCH] Only let VM drivers block libvirtd timed shutdown The only important state that should prevent libvirtd shutdown is from running VMs. Networks, host devices, network filters and storage pools are all long lived resources that have no significant in-memory state. They should not block shutdown. --- src/network/bridge_driver.c | 28 ---------------------------- src/node_device/node_device_hal.c | 8 -------- src/node_device/node_device_udev.c | 8 -------- src/nwfilter/nwfilter_driver.c | 22 ---------------------- src/storage/storage_driver.c | 28 ---------------------------- 5 files changed, 94 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 75f3c3a398..03ba4c61b2 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -468,33 +468,6 @@ networkReload(void) { return 0; } -/** - * networkActive: - * - * Checks if the QEmu daemon is active, i.e. has an active domain or - * an active network - * - * Returns 1 if active, 0 otherwise - */ -static int -networkActive(void) { - unsigned int i; - int active = 0; - - if (!driverState) - return 0; - - networkDriverLock(driverState); - for (i = 0 ; i < driverState->networks.count ; i++) { - virNetworkObjPtr net = driverState->networks.objs[i]; - virNetworkObjLock(net); - if (virNetworkObjIsActive(net)) - active = 1; - virNetworkObjUnlock(net); - } - networkDriverUnlock(driverState); - return active; -} /** * networkShutdown: @@ -3357,7 +3330,6 @@ static virStateDriver networkStateDriver = { .initialize = networkStartup, .cleanup = networkShutdown, .reload = networkReload, - .active = networkActive, }; int networkRegister(void) { diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index 953e1d3d3c..96d23a4e8c 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -736,13 +736,6 @@ static int halDeviceMonitorReload(void) } -static int halDeviceMonitorActive(void) -{ - /* Always ready to deal with a shutdown */ - return 0; -} - - static virDrvOpenStatus halNodeDrvOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, unsigned int flags) @@ -786,7 +779,6 @@ static virStateDriver halStateDriver = { .initialize = halDeviceMonitorStartup, /* 0.5.0 */ .cleanup = halDeviceMonitorShutdown, /* 0.5.0 */ .reload = halDeviceMonitorReload, /* 0.5.0 */ - .active = halDeviceMonitorActive, /* 0.5.0 */ }; int halNodeRegister(void) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index bc4e2e937c..393fe20b82 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -1723,13 +1723,6 @@ static int udevDeviceMonitorReload(void) } -static int udevDeviceMonitorActive(void) -{ - /* Always ready to deal with a shutdown */ - return 0; -} - - static virDrvOpenStatus udevNodeDrvOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, unsigned int flags) @@ -1772,7 +1765,6 @@ static virStateDriver udevStateDriver = { .initialize = udevDeviceMonitorStartup, /* 0.7.3 */ .cleanup = udevDeviceMonitorShutdown, /* 0.7.3 */ .reload = udevDeviceMonitorReload, /* 0.7.3 */ - .active = udevDeviceMonitorActive, /* 0.7.3 */ }; int udevNodeRegister(void) diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index cff384e3be..ddf0bbd98d 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -304,27 +304,6 @@ nwfilterDriverReload(void) { return 0; } -/** - * virNWFilterActive: - * - * Checks if the nwfilter driver is active, i.e. has an active nwfilter - * - * Returns 1 if active, 0 otherwise - */ -static int -nwfilterDriverActive(void) { - int ret; - - if (!driverState) - return 0; - - nwfilterDriverLock(driverState); - ret = driverState->nwfilters.count ? 1 : 0; - ret |= driverState->watchingFirewallD; - nwfilterDriverUnlock(driverState); - - return ret; -} /** * virNWFilterIsWatchingFirewallD: @@ -695,7 +674,6 @@ static virStateDriver stateDriver = { .initialize = nwfilterDriverStartup, .cleanup = nwfilterDriverShutdown, .reload = nwfilterDriverReload, - .active = nwfilterDriverActive, }; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index d27bb41278..55177337d2 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -202,33 +202,6 @@ storageDriverReload(void) { return 0; } -/** - * virStorageActive: - * - * Checks if the storage driver is active, i.e. has an active pool - * - * Returns 1 if active, 0 otherwise - */ -static int -storageDriverActive(void) { - unsigned int i; - int active = 0; - - if (!driverState) - return 0; - - storageDriverLock(driverState); - - for (i = 0 ; i < driverState->pools.count ; i++) { - virStoragePoolObjLock(driverState->pools.objs[i]); - if (virStoragePoolObjIsActive(driverState->pools.objs[i])) - active = 1; - virStoragePoolObjUnlock(driverState->pools.objs[i]); - } - - storageDriverUnlock(driverState); - return active; -} /** * virStorageShutdown: @@ -2445,7 +2418,6 @@ static virStateDriver stateDriver = { .initialize = storageDriverStartup, .cleanup = storageDriverShutdown, .reload = storageDriverReload, - .active = storageDriverActive, }; int storageRegister(void) {