[libvirt] [PATCH 13/19] storage: Move autostartLink deletion to virstorageobj
Pavel Hrdina
phrdina at redhat.com
Tue Jul 11 16:17:18 UTC 2017
On Tue, May 09, 2017 at 11:30:20AM -0400, John Ferlan wrote:
> The virStoragePoolObjDeleteDef already dealt with the configFile - just
> add in the autostartLink as well. If there is no autostartLink defined,
> then no need to attempt unlink - which also allows removal of one errno
> check in moved function.
>
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
> src/conf/virstorageobj.c | 11 +++++++++++
> src/storage/storage_driver.c | 11 -----------
> 2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/src/conf/virstorageobj.c b/src/conf/virstorageobj.c
> index 9ce3840..69ed66d 100644
> --- a/src/conf/virstorageobj.c
> +++ b/src/conf/virstorageobj.c
> @@ -696,6 +696,17 @@ virStoragePoolObjDeleteDef(virStoragePoolObjPtr obj)
> obj->def->name);
> return -1;
> }
> + VIR_FREE(obj->configFile);
> +
> + if (!obj->autostartLink)
> + return 0;
> +
> + if (unlink(obj->autostartLink) < 0 && errno != ENOTDIR) {
> + char ebuf[1024];
> + VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
> + obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
> + }
> + VIR_FREE(obj->autostartLink);
>
> return 0;
> }
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index c4e4e7b..c4650cd 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -841,17 +841,6 @@ storagePoolUndefine(virStoragePoolPtr pool)
> if (virStoragePoolObjDeleteDef(obj) < 0)
> goto cleanup;
>
> - if (unlink(obj->autostartLink) < 0 &&
> - errno != ENOENT &&
> - errno != ENOTDIR) {
> - char ebuf[1024];
> - VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
> - obj->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
> - }
The same as for the previous patch, keep the unlink in storage driver
and use the new virStoragePoolObjGetAutostartLink().
> -
> - VIR_FREE(obj->configFile);
> - VIR_FREE(obj->autostartLink);
> -
This can be safely removed since it's handled by virStoragePoolObjFree()
which is called in virStoragePoolObjRemove().
> event = virStoragePoolEventLifecycleNew(obj->def->name,
> obj->def->uuid,
> VIR_STORAGE_POOL_EVENT_UNDEFINED,
> --
> 2.9.3
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170711/301f2654/attachment-0001.sig>
More information about the libvir-list
mailing list