From bb15e65af20a7f968beb71746ccb8f8f3855a55d Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Wed, 26 Jul 2017 12:23:11 -0400 Subject: [PATCH] storage: Use virStoragePoolObj{Is|Set}Autostart Use the new accessor APIs for storage_driver and test_driver. --- src/storage/storage_driver.c | 20 +++++++++----------- src/test/test_driver.c | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 37e9981b5b..4b7bad82df 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -196,7 +196,7 @@ storageDriverAutostart(void) continue; } - if (obj->autostart && + if (virStoragePoolObjIsAutostart(obj) && !virStoragePoolObjIsActive(obj)) { if (backend->startPool && backend->startPool(conn, obj) < 0) { @@ -1249,11 +1249,7 @@ storagePoolGetAutostart(virStoragePoolPtr pool, if (virStoragePoolGetAutostartEnsureACL(pool->conn, obj->def) < 0) goto cleanup; - if (!virStoragePoolObjGetConfigFile(obj)) { - *autostart = 0; - } else { - *autostart = obj->autostart; - } + *autostart = virStoragePoolObjIsAutostart(obj) ? 1 : 0; ret = 0; @@ -1269,6 +1265,8 @@ storagePoolSetAutostart(virStoragePoolPtr pool, virStoragePoolObjPtr obj; const char *configFile; const char *autostartLink; + bool new_autostart; + bool cur_autostart; int ret = -1; storageDriverLock(); @@ -1286,10 +1284,10 @@ storagePoolSetAutostart(virStoragePoolPtr pool, autostartLink = virStoragePoolObjGetAutostartLink(obj); - autostart = (autostart != 0); - - if (obj->autostart != autostart) { - if (autostart) { + new_autostart = (autostart != 0); + cur_autostart = virStoragePoolObjIsAutostart(obj); + if (cur_autostart != new_autostart) { + if (new_autostart) { if (virFileMakePath(driver->autostartDir) < 0) { virReportSystemError(errno, _("cannot create autostart directory %s"), @@ -1312,7 +1310,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool, goto cleanup; } } - obj->autostart = autostart; + virStoragePoolObjSetAutostart(obj, autostart); } ret = 0; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index d8ae2dea43..e28ad6d964 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -4764,7 +4764,7 @@ testStoragePoolGetAutostart(virStoragePoolPtr pool, if (!virStoragePoolObjGetConfigFile(obj)) *autostart = 0; else - *autostart = obj->autostart; + *autostart = virStoragePoolObjIsAutostart(obj) ? 1 : 0; virStoragePoolObjUnlock(obj); return 0; @@ -4789,7 +4789,7 @@ testStoragePoolSetAutostart(virStoragePoolPtr pool, } autostart = (autostart != 0); - obj->autostart = autostart; + virStoragePoolObjSetAutostart(obj, autostart); ret = 0; cleanup: -- GitLab