mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 07:36:19 +00:00
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:
parent
1115f975b4
commit
0620bd42ad
@ -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
|
static int
|
||||||
virStorageFileBackendFileUnlink(virStorageSourcePtr src)
|
virStorageFileBackendFileUnlink(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
int ret;
|
return unlink(src->path);
|
||||||
|
|
||||||
ret = unlink(src->path);
|
|
||||||
/* preserve errno */
|
|
||||||
|
|
||||||
VIR_DEBUG("removing storage file %p(%s): ret=%d, errno=%d",
|
|
||||||
src, src->path, ret, errno);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1358,21 +1371,16 @@ static int
|
|||||||
virStorageFileBackendFileStat(virStorageSourcePtr src,
|
virStorageFileBackendFileStat(virStorageSourcePtr src,
|
||||||
struct stat *st)
|
struct stat *st)
|
||||||
{
|
{
|
||||||
int ret;
|
return stat(src->path, st);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virStorageFileBackend virStorageFileBackendFile = {
|
virStorageFileBackend virStorageFileBackendFile = {
|
||||||
.type = VIR_STORAGE_TYPE_FILE,
|
.type = VIR_STORAGE_TYPE_FILE,
|
||||||
|
|
||||||
|
.backendInit = virStorageFileBackendFileInit,
|
||||||
|
.backendDeinit = virStorageFileBackendFileDeinit,
|
||||||
|
|
||||||
.storageFileUnlink = virStorageFileBackendFileUnlink,
|
.storageFileUnlink = virStorageFileBackendFileUnlink,
|
||||||
.storageFileStat = virStorageFileBackendFileStat,
|
.storageFileStat = virStorageFileBackendFileStat,
|
||||||
};
|
};
|
||||||
@ -1381,6 +1389,9 @@ virStorageFileBackend virStorageFileBackendFile = {
|
|||||||
virStorageFileBackend virStorageFileBackendBlock = {
|
virStorageFileBackend virStorageFileBackendBlock = {
|
||||||
.type = VIR_STORAGE_TYPE_BLOCK,
|
.type = VIR_STORAGE_TYPE_BLOCK,
|
||||||
|
|
||||||
|
.backendInit = virStorageFileBackendFileInit,
|
||||||
|
.backendDeinit = virStorageFileBackendFileDeinit,
|
||||||
|
|
||||||
.storageFileStat = virStorageFileBackendFileStat,
|
.storageFileStat = virStorageFileBackendFileStat,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -539,10 +539,12 @@ struct _virStorageFileBackendGlusterPriv {
|
|||||||
static void
|
static void
|
||||||
virStorageFileBackendGlusterDeinit(virStorageSourcePtr src)
|
virStorageFileBackendGlusterDeinit(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
VIR_DEBUG("deinitializing gluster storage file %p(%s/%s)",
|
|
||||||
src, src->hosts[0].name, src->path);
|
|
||||||
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
|
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)
|
if (priv->vol)
|
||||||
glfs_fini(priv->vol);
|
glfs_fini(priv->vol);
|
||||||
|
|
||||||
@ -558,12 +560,14 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src)
|
|||||||
const char *hostname = host->name;
|
const char *hostname = host->name;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
|
||||||
VIR_DEBUG("initializing gluster storage file %p(%s/%s)",
|
VIR_DEBUG("initializing gluster storage file %p (gluster://%s:%s/%s%s)",
|
||||||
src, hostname, src->path);
|
src, hostname, host->port ? host->port : "0",
|
||||||
|
NULLSTR(src->volume), src->path);
|
||||||
|
|
||||||
if (!src->volume) {
|
if (!src->volume) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -619,14 +623,8 @@ static int
|
|||||||
virStorageFileBackendGlusterUnlink(virStorageSourcePtr src)
|
virStorageFileBackendGlusterUnlink(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
|
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = glfs_unlink(priv->vol, src->path);
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -635,14 +633,8 @@ virStorageFileBackendGlusterStat(virStorageSourcePtr src,
|
|||||||
struct stat *st)
|
struct stat *st)
|
||||||
{
|
{
|
||||||
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
|
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = glfs_stat(priv->vol, src->path, st);
|
return 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2835,13 +2835,20 @@ virStorageFileInit(virStorageSourcePtr src)
|
|||||||
int
|
int
|
||||||
virStorageFileCreate(virStorageSourcePtr src)
|
virStorageFileCreate(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!virStorageFileIsInitialized(src) ||
|
if (!virStorageFileIsInitialized(src) ||
|
||||||
!src->drv->backend->storageFileCreate) {
|
!src->drv->backend->storageFileCreate) {
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -2;
|
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
|
int
|
||||||
virStorageFileUnlink(virStorageSourcePtr src)
|
virStorageFileUnlink(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!virStorageFileIsInitialized(src) ||
|
if (!virStorageFileIsInitialized(src) ||
|
||||||
!src->drv->backend->storageFileUnlink) {
|
!src->drv->backend->storageFileUnlink) {
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -2;
|
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,
|
virStorageFileStat(virStorageSourcePtr src,
|
||||||
struct stat *st)
|
struct stat *st)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!virStorageFileIsInitialized(src) ||
|
if (!virStorageFileIsInitialized(src) ||
|
||||||
!src->drv->backend->storageFileStat) {
|
!src->drv->backend->storageFileStat) {
|
||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -2;
|
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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user