Print the debug statements of individual file access functions from the main API functions instead of the individual backend functions. Also enhance initialization debug messages on a per-backend basis. --- Notes: Version 2: - no change, v1 already ACKed by Eric src/storage/storage_backend_fs.c | 43 ++++++++++++++++++++++------------- src/storage/storage_backend_gluster.c | 30 +++++++++--------------- src/storage/storage_driver.c | 27 +++++++++++++++++++--- 3 files changed, 62 insertions(+), 38 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index de27890..3d088ba 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -1339,18 +1339,31 @@ virStorageBackend virStorageBackendNetFileSystem = { }; +static void +virStorageFileBackendFileDeinit(virStorageSourcePtr src) +{ + VIR_DEBUG("deinitializing FS storage file %p (%s:%s)", src, + virStorageTypeToString(virStorageSourceGetActualType(src)), + src->path); + +} + + static int -virStorageFileBackendFileUnlink(virStorageSourcePtr src) +virStorageFileBackendFileInit(virStorageSourcePtr src) { - int ret; + VIR_DEBUG("initializing FS storage file %p (%s:%s)", src, + virStorageTypeToString(virStorageSourceGetActualType(src)), + src->path); - ret = unlink(src->path); - /* preserve errno */ + return 0; +} - VIR_DEBUG("removing storage file %p(%s): ret=%d, errno=%d", - src, src->path, ret, errno); - return ret; +static int +virStorageFileBackendFileUnlink(virStorageSourcePtr src) +{ + return unlink(src->path); } @@ -1358,21 +1371,16 @@ static int virStorageFileBackendFileStat(virStorageSourcePtr src, struct stat *st) { - int ret; - - ret = stat(src->path, st); - /* preserve errno */ - - VIR_DEBUG("stat of storage file %p(%s): ret=%d, errno=%d", - src, src->path, ret, errno); - - return ret; + return stat(src->path, st); } virStorageFileBackend virStorageFileBackendFile = { .type = VIR_STORAGE_TYPE_FILE, + .backendInit = virStorageFileBackendFileInit, + .backendDeinit = virStorageFileBackendFileDeinit, + .storageFileUnlink = virStorageFileBackendFileUnlink, .storageFileStat = virStorageFileBackendFileStat, }; @@ -1381,6 +1389,9 @@ virStorageFileBackend virStorageFileBackendFile = { virStorageFileBackend virStorageFileBackendBlock = { .type = VIR_STORAGE_TYPE_BLOCK, + .backendInit = virStorageFileBackendFileInit, + .backendDeinit = virStorageFileBackendFileDeinit, + .storageFileStat = virStorageFileBackendFileStat, }; diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c index 8679d96..e578e73 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -539,10 +539,12 @@ struct _virStorageFileBackendGlusterPriv { static void virStorageFileBackendGlusterDeinit(virStorageSourcePtr src) { - VIR_DEBUG("deinitializing gluster storage file %p(%s/%s)", - src, src->hosts[0].name, src->path); virStorageFileBackendGlusterPrivPtr priv = src->drv->priv; + VIR_DEBUG("deinitializing gluster storage file %p (gluster://%s:%s/%s%s)", + src, src->hosts->name, src->hosts->port ? src->hosts->port : "0", + src->volume, src->path); + if (priv->vol) glfs_fini(priv->vol); @@ -558,12 +560,14 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src) const char *hostname = host->name; int port = 0; - VIR_DEBUG("initializing gluster storage file %p(%s/%s)", - src, hostname, src->path); + VIR_DEBUG("initializing gluster storage file %p (gluster://%s:%s/%s%s)", + src, hostname, host->port ? host->port : "0", + NULLSTR(src->volume), src->path); if (!src->volume) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing gluster volume name for path '%s'"), src->path); + _("missing gluster volume name for path '%s'"), + src->path); return -1; } @@ -619,14 +623,8 @@ static int virStorageFileBackendGlusterUnlink(virStorageSourcePtr src) { virStorageFileBackendGlusterPrivPtr priv = src->drv->priv; - int ret; - - ret = glfs_unlink(priv->vol, src->path); - /* preserve errno */ - VIR_DEBUG("removing storage file %p(%s/%s): ret=%d, errno=%d", - src, src->hosts[0].name, src->path, ret, errno); - return ret; + return glfs_unlink(priv->vol, src->path); } @@ -635,14 +633,8 @@ virStorageFileBackendGlusterStat(virStorageSourcePtr src, struct stat *st) { virStorageFileBackendGlusterPrivPtr priv = src->drv->priv; - int ret; - ret = glfs_stat(priv->vol, src->path, st); - /* preserve errno */ - - VIR_DEBUG("stat of storage file %p(%s/%s): ret=%d, errno=%d", - src, src->hosts[0].name, src->path, ret, errno); - return ret; + return glfs_stat(priv->vol, src->path, st); } diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index f58e0a4..455a2ef 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2835,13 +2835,20 @@ virStorageFileInit(virStorageSourcePtr src) int virStorageFileCreate(virStorageSourcePtr src) { + int ret; + if (!virStorageFileIsInitialized(src) || !src->drv->backend->storageFileCreate) { errno = ENOSYS; return -2; } - return src->drv->backend->storageFileCreate(src); + ret = src->drv->backend->storageFileCreate(src); + + VIR_DEBUG("created storage file %p: ret=%d, errno=%d", + src, ret, errno); + + return ret; } @@ -2858,13 +2865,20 @@ virStorageFileCreate(virStorageSourcePtr src) int virStorageFileUnlink(virStorageSourcePtr src) { + int ret; + if (!virStorageFileIsInitialized(src) || !src->drv->backend->storageFileUnlink) { errno = ENOSYS; return -2; } - return src->drv->backend->storageFileUnlink(src); + ret = src->drv->backend->storageFileUnlink(src); + + VIR_DEBUG("unlinked storage file %p: ret=%d, errno=%d", + src, ret, errno); + + return ret; } @@ -2881,11 +2895,18 @@ int virStorageFileStat(virStorageSourcePtr src, struct stat *st) { + int ret; + if (!virStorageFileIsInitialized(src) || !src->drv->backend->storageFileStat) { errno = ENOSYS; return -2; } - return src->drv->backend->storageFileStat(src, st); + ret = src->drv->backend->storageFileStat(src, st); + + VIR_DEBUG("stat of storage file %p: ret=%d, errno=%d", + src, ret, errno); + + return ret; } -- 1.9.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list