storage: Rework debugging of storage file access through storage driver

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.
This commit is contained in:
Peter Krempa 2014-05-02 16:51:48 +02:00
parent 1115f975b4
commit 0620bd42ad
3 changed files with 64 additions and 40 deletions

View File

@ -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
virStorageFileBackendFileInit(virStorageSourcePtr src)
{
VIR_DEBUG("initializing FS storage file %p (%s:%s)", src,
virStorageTypeToString(virStorageSourceGetActualType(src)),
src->path);
return 0;
}
static int
virStorageFileBackendFileUnlink(virStorageSourcePtr src)
{
int ret;
ret = unlink(src->path);
/* preserve errno */
VIR_DEBUG("removing storage file %p(%s): ret=%d, errno=%d",
src, src->path, ret, errno);
return ret;
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,
};

View File

@ -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);
}

View File

@ -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;
}