storage: Use virStoragePoolObjGetAutostartLink

Use the new accessor API for storage_driver.
This commit is contained in:
John Ferlan 2017-07-26 12:06:58 -04:00
parent 8603d848a3
commit 1bd4349671

View File

@ -814,6 +814,7 @@ static int
storagePoolUndefine(virStoragePoolPtr pool) storagePoolUndefine(virStoragePoolPtr pool)
{ {
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
const char *autostartLink;
virObjectEventPtr event = NULL; virObjectEventPtr event = NULL;
int ret = -1; int ret = -1;
@ -838,18 +839,17 @@ storagePoolUndefine(virStoragePoolPtr pool)
goto cleanup; goto cleanup;
} }
autostartLink = virStoragePoolObjGetAutostartLink(obj);
if (virStoragePoolObjDeleteDef(obj) < 0) if (virStoragePoolObjDeleteDef(obj) < 0)
goto cleanup; goto cleanup;
if (unlink(obj->autostartLink) < 0 && if (autostartLink && unlink(autostartLink) < 0 &&
errno != ENOENT && errno != ENOENT && errno != ENOTDIR) {
errno != ENOTDIR) {
char ebuf[1024]; char ebuf[1024];
VIR_ERROR(_("Failed to delete autostart link '%s': %s"), VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf))); autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
} }
VIR_FREE(obj->autostartLink);
event = virStoragePoolEventLifecycleNew(obj->def->name, event = virStoragePoolEventLifecycleNew(obj->def->name,
obj->def->uuid, obj->def->uuid,
@ -1268,6 +1268,7 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
{ {
virStoragePoolObjPtr obj; virStoragePoolObjPtr obj;
const char *configFile; const char *configFile;
const char *autostartLink;
int ret = -1; int ret = -1;
storageDriverLock(); storageDriverLock();
@ -1283,6 +1284,8 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
} }
autostartLink = virStoragePoolObjGetAutostartLink(obj);
autostart = (autostart != 0); autostart = (autostart != 0);
if (obj->autostart != autostart) { if (obj->autostart != autostart) {
@ -1294,18 +1297,18 @@ storagePoolSetAutostart(virStoragePoolPtr pool,
goto cleanup; goto cleanup;
} }
if (symlink(configFile, obj->autostartLink) < 0) { if (symlink(configFile, autostartLink) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Failed to create symlink '%s' to '%s'"), _("Failed to create symlink '%s' to '%s'"),
obj->autostartLink, configFile); autostartLink, configFile);
goto cleanup; goto cleanup;
} }
} else { } else {
if (unlink(obj->autostartLink) < 0 && if (autostartLink && unlink(autostartLink) < 0 &&
errno != ENOENT && errno != ENOTDIR) { errno != ENOENT && errno != ENOTDIR) {
virReportSystemError(errno, virReportSystemError(errno,
_("Failed to delete symlink '%s'"), _("Failed to delete symlink '%s'"),
obj->autostartLink); autostartLink);
goto cleanup; goto cleanup;
} }
} }