2008-02-20 15:34:52 +00:00
|
|
|
/*
|
|
|
|
* storage_backend.h: internal storage driver backend contract
|
|
|
|
*
|
2014-01-10 10:29:44 +00:00
|
|
|
* Copyright (C) 2007-2010, 2012-2014 Red Hat, Inc.
|
2008-02-20 15:34:52 +00:00
|
|
|
* Copyright (C) 2007-2008 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2008-02-20 15:34:52 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_STORAGE_BACKEND_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_STORAGE_BACKEND_H__
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2013-11-05 15:30:01 +00:00
|
|
|
# include <sys/stat.h>
|
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "storage_conf.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
# include "vircommand.h"
|
2014-02-03 15:12:57 +00:00
|
|
|
# include "storage_driver.h"
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2014-01-10 10:29:44 +00:00
|
|
|
typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn,
|
|
|
|
const char *srcSpec,
|
|
|
|
unsigned int flags);
|
2015-03-09 14:34:35 +00:00
|
|
|
typedef int (*virStorageBackendCheckPool)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
bool *active);
|
|
|
|
typedef int (*virStorageBackendStartPool)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool);
|
|
|
|
typedef int (*virStorageBackendBuildPool)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
unsigned int flags);
|
|
|
|
typedef int (*virStorageBackendRefreshPool)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool);
|
|
|
|
typedef int (*virStorageBackendStopPool)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool);
|
|
|
|
typedef int (*virStorageBackendDeletePool)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
unsigned int flags);
|
storage: On 'buildVol' failure don't delete the volume
https://bugzilla.redhat.com/show_bug.cgi?id=1233003
Commit id 'fdda3760' only managed a symptom where it was possible to
create a file in a pool without libvirt's knowledge, so it was reverted.
The real fix is to have all the createVol API's which actually create
a volume (disk, logical, zfs) and the buildVol API's which handle the
real creation of some volume file (fs, rbd, sheepdog) manage deleting
any volume which they create when there is some sort of error in
processing the volume.
This way the onus isn't left up to the storage_driver to determine whether
the buildVol failure was due to some failure as a result of adjustments
made to the volume after creation such as getting sizes, changing ownership,
changing volume protections, etc. or simple a failure in creation.
Without needing to consider that the volume has to be removed, the
buildVol failure path only needs to remove the volume from the pool.
This way if a creation failed due to duplicate name, libvirt wouldn't
remove a volume that it didn't create in the pool target.
2015-10-08 20:44:02 +00:00
|
|
|
|
|
|
|
/* A 'buildVol' backend must remove any volume created on error since
|
|
|
|
* the storage driver does not distinguish whether the failure is due
|
|
|
|
* to failure to create the volume, to reserve any space necessary for
|
|
|
|
* the volume, to get data about the volume, to change it's accessibility,
|
|
|
|
* etc. This avoids issues arising from a creation failure due to some
|
|
|
|
* external action which created a volume of the same name that libvirt
|
|
|
|
* was not aware of between checking the pool and the create attempt. It
|
|
|
|
* also avoids extra round trips to just delete a file.
|
|
|
|
*/
|
2010-01-20 23:41:52 +00:00
|
|
|
typedef int (*virStorageBackendBuildVol)(virConnectPtr conn,
|
2014-01-10 10:29:44 +00:00
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
2012-12-05 10:48:07 +00:00
|
|
|
unsigned int flags);
|
2014-01-10 10:29:44 +00:00
|
|
|
typedef int (*virStorageBackendCreateVol)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol);
|
|
|
|
typedef int (*virStorageBackendRefreshVol)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol);
|
|
|
|
typedef int (*virStorageBackendDeleteVol)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
unsigned int flags);
|
|
|
|
typedef int (*virStorageBackendBuildVolFrom)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr origvol,
|
|
|
|
virStorageVolDefPtr newvol,
|
2010-01-20 23:41:52 +00:00
|
|
|
unsigned int flags);
|
2012-01-30 07:40:00 +00:00
|
|
|
typedef int (*virStorageBackendVolumeResize)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
unsigned long long capacity,
|
|
|
|
unsigned int flags);
|
2014-07-07 14:50:11 +00:00
|
|
|
typedef int (*virStorageBackendVolumeDownload)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr obj,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long length,
|
|
|
|
unsigned int flags);
|
|
|
|
typedef int (*virStorageBackendVolumeUpload)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr obj,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long len,
|
|
|
|
unsigned int flags);
|
2014-07-07 14:50:11 +00:00
|
|
|
typedef int (*virStorageBackendVolumeWipe)(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
unsigned int algorithm,
|
|
|
|
unsigned int flags);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2009-07-16 16:09:26 +00:00
|
|
|
/* File creation/cloning functions used for cloning between backends */
|
|
|
|
int virStorageBackendCreateRaw(virConnectPtr conn,
|
2010-01-20 23:41:52 +00:00
|
|
|
virStoragePoolObjPtr pool,
|
2009-07-16 16:09:26 +00:00
|
|
|
virStorageVolDefPtr vol,
|
2009-07-16 16:27:07 +00:00
|
|
|
virStorageVolDefPtr inputvol,
|
|
|
|
unsigned int flags);
|
2016-04-11 16:16:20 +00:00
|
|
|
|
2016-04-15 21:07:02 +00:00
|
|
|
int virStorageBackendCreateQemuImg(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStorageVolDefPtr inputvol,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2016-04-11 16:16:20 +00:00
|
|
|
int virStorageBackendCreatePloop(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStorageVolDefPtr inputvol,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2016-04-11 16:16:22 +00:00
|
|
|
int virStoragePloopResize(virStorageVolDefPtr vol,
|
|
|
|
unsigned long long capacity);
|
2016-04-11 16:16:20 +00:00
|
|
|
|
2016-04-11 16:16:24 +00:00
|
|
|
int virStorageBackendRedoPloopUpdate(virStorageSourcePtr target,
|
|
|
|
struct stat *sb, int *fd,
|
|
|
|
unsigned int flags);
|
|
|
|
bool virStorageBackendIsPloopDir(char *path);
|
|
|
|
|
2009-07-16 16:27:07 +00:00
|
|
|
virStorageBackendBuildVolFrom
|
2010-02-10 11:42:56 +00:00
|
|
|
virStorageBackendGetBuildVolFromFunction(virStorageVolDefPtr vol,
|
2009-07-16 16:09:26 +00:00
|
|
|
virStorageVolDefPtr inputvol);
|
|
|
|
|
2014-03-26 18:17:55 +00:00
|
|
|
int virStorageBackendFindGlusterPoolSources(const char *host,
|
|
|
|
int pooltype,
|
|
|
|
virStoragePoolSourceListPtr list);
|
|
|
|
|
2014-07-07 14:50:11 +00:00
|
|
|
int virStorageBackendVolUploadLocal(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long len,
|
|
|
|
unsigned int flags);
|
|
|
|
int virStorageBackendVolDownloadLocal(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long len,
|
|
|
|
unsigned int flags);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2014-07-07 13:41:33 +00:00
|
|
|
int virStorageBackendVolWipeLocal(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
unsigned int algorithm,
|
|
|
|
unsigned int flags);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
typedef struct _virStorageBackend virStorageBackend;
|
|
|
|
typedef virStorageBackend *virStorageBackendPtr;
|
|
|
|
|
2013-11-19 23:26:05 +00:00
|
|
|
/* Callbacks are optional unless documented otherwise; but adding more
|
|
|
|
* callbacks provides better pool support. */
|
2008-02-20 15:34:52 +00:00
|
|
|
struct _virStorageBackend {
|
|
|
|
int type;
|
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
virStorageBackendFindPoolSources findPoolSources;
|
2010-11-11 20:09:20 +00:00
|
|
|
virStorageBackendCheckPool checkPool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendStartPool startPool;
|
|
|
|
virStorageBackendBuildPool buildPool;
|
2013-11-19 23:26:05 +00:00
|
|
|
virStorageBackendRefreshPool refreshPool; /* Must be non-NULL */
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendStopPool stopPool;
|
|
|
|
virStorageBackendDeletePool deletePool;
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
virStorageBackendBuildVol buildVol;
|
2009-05-19 13:37:51 +00:00
|
|
|
virStorageBackendBuildVolFrom buildVolFrom;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendCreateVol createVol;
|
|
|
|
virStorageBackendRefreshVol refreshVol;
|
|
|
|
virStorageBackendDeleteVol deleteVol;
|
2012-01-30 07:40:00 +00:00
|
|
|
virStorageBackendVolumeResize resizeVol;
|
2014-07-07 14:50:11 +00:00
|
|
|
virStorageBackendVolumeUpload uploadVol;
|
|
|
|
virStorageBackendVolumeDownload downloadVol;
|
2014-07-07 14:50:11 +00:00
|
|
|
virStorageBackendVolumeWipe wipeVol;
|
2008-02-20 15:34:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virStorageBackendPtr virStorageBackendForType(int type);
|
2008-11-17 11:19:33 +00:00
|
|
|
|
storage: Check for invalid storage mode before opening
If a directory pool contains pipes or sockets, a pool start can fail or hang:
https://bugzilla.redhat.com/show_bug.cgi?id=589577
We already try to avoid these special files, but only attempt after
opening the path, which is where the problems lie. Unify volume opening
into helper functions, which use the proper open() flags to avoid error,
followed by fstat to validate storage mode.
Previously, virStorageBackendUpdateVolTargetInfoFD attempted to enforce the
storage mode check, but allowed callers to detect this case and silently
continue. In practice, only the FS backend was using this feature, the rest
were treating unknown mode as an error condition. Unfortunately the InfoFD
function wasn't raising an error message here, so error reporting was
busted.
This patch adds 2 functions: virStorageBackendVolOpen, and
virStorageBackendVolOpenModeSkip. The latter retains the original opt out
semantics, the former now throws an explicit error.
This patch maintains the previous volume mode checks: allowing specific
modes for specific pool types requires a bit of surgery, since VolOpen
is called through several different helper functions.
v2: Use ATTRIBUTE_NONNULL. Drop stat check, just open with
O_NONBLOCK|O_NOCTTY.
v3: Move mode check logic back to VolOpen. Use 2 VolOpen functions with
different error semantics.
v4: Make second VolOpen function more extensible. Didn't opt to change
FS backend defaults, this can just be to fix the original bug.
v5: Prefix default flags with VIR_, use ATTRIBUTE_RETURN_CHECK
2010-05-20 18:25:01 +00:00
|
|
|
/* VolOpenCheckMode flags */
|
|
|
|
enum {
|
2014-04-02 15:51:45 +00:00
|
|
|
VIR_STORAGE_VOL_OPEN_NOERROR = 1 << 0, /* don't error if unexpected type
|
|
|
|
* encountered, just warn */
|
|
|
|
VIR_STORAGE_VOL_OPEN_REG = 1 << 1, /* regular files okay */
|
|
|
|
VIR_STORAGE_VOL_OPEN_BLOCK = 1 << 2, /* block files okay */
|
|
|
|
VIR_STORAGE_VOL_OPEN_CHAR = 1 << 3, /* char files okay */
|
|
|
|
VIR_STORAGE_VOL_OPEN_DIR = 1 << 4, /* directories okay */
|
storage: Check for invalid storage mode before opening
If a directory pool contains pipes or sockets, a pool start can fail or hang:
https://bugzilla.redhat.com/show_bug.cgi?id=589577
We already try to avoid these special files, but only attempt after
opening the path, which is where the problems lie. Unify volume opening
into helper functions, which use the proper open() flags to avoid error,
followed by fstat to validate storage mode.
Previously, virStorageBackendUpdateVolTargetInfoFD attempted to enforce the
storage mode check, but allowed callers to detect this case and silently
continue. In practice, only the FS backend was using this feature, the rest
were treating unknown mode as an error condition. Unfortunately the InfoFD
function wasn't raising an error message here, so error reporting was
busted.
This patch adds 2 functions: virStorageBackendVolOpen, and
virStorageBackendVolOpenModeSkip. The latter retains the original opt out
semantics, the former now throws an explicit error.
This patch maintains the previous volume mode checks: allowing specific
modes for specific pool types requires a bit of surgery, since VolOpen
is called through several different helper functions.
v2: Use ATTRIBUTE_NONNULL. Drop stat check, just open with
O_NONBLOCK|O_NOCTTY.
v3: Move mode check logic back to VolOpen. Use 2 VolOpen functions with
different error semantics.
v4: Make second VolOpen function more extensible. Didn't opt to change
FS backend defaults, this can just be to fix the original bug.
v5: Prefix default flags with VIR_, use ATTRIBUTE_RETURN_CHECK
2010-05-20 18:25:01 +00:00
|
|
|
};
|
|
|
|
|
2015-11-24 16:15:53 +00:00
|
|
|
/* VolReadErrorMode flags
|
|
|
|
* If flag is present, then operation won't cause fatal error for
|
|
|
|
* specified operation, rather a VIR_WARN will be issued and a -2 returned
|
|
|
|
* for function call
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
VIR_STORAGE_VOL_READ_NOERROR = 1 << 0, /* ignore *read errors */
|
|
|
|
};
|
|
|
|
|
2014-04-02 15:51:45 +00:00
|
|
|
# define VIR_STORAGE_VOL_OPEN_DEFAULT (VIR_STORAGE_VOL_OPEN_REG |\
|
2010-05-29 07:45:21 +00:00
|
|
|
VIR_STORAGE_VOL_OPEN_BLOCK)
|
storage: Check for invalid storage mode before opening
If a directory pool contains pipes or sockets, a pool start can fail or hang:
https://bugzilla.redhat.com/show_bug.cgi?id=589577
We already try to avoid these special files, but only attempt after
opening the path, which is where the problems lie. Unify volume opening
into helper functions, which use the proper open() flags to avoid error,
followed by fstat to validate storage mode.
Previously, virStorageBackendUpdateVolTargetInfoFD attempted to enforce the
storage mode check, but allowed callers to detect this case and silently
continue. In practice, only the FS backend was using this feature, the rest
were treating unknown mode as an error condition. Unfortunately the InfoFD
function wasn't raising an error message here, so error reporting was
busted.
This patch adds 2 functions: virStorageBackendVolOpen, and
virStorageBackendVolOpenModeSkip. The latter retains the original opt out
semantics, the former now throws an explicit error.
This patch maintains the previous volume mode checks: allowing specific
modes for specific pool types requires a bit of surgery, since VolOpen
is called through several different helper functions.
v2: Use ATTRIBUTE_NONNULL. Drop stat check, just open with
O_NONBLOCK|O_NOCTTY.
v3: Move mode check logic back to VolOpen. Use 2 VolOpen functions with
different error semantics.
v4: Make second VolOpen function more extensible. Didn't opt to change
FS backend defaults, this can just be to fix the original bug.
v5: Prefix default flags with VIR_, use ATTRIBUTE_RETURN_CHECK
2010-05-20 18:25:01 +00:00
|
|
|
|
2014-03-30 23:01:23 +00:00
|
|
|
int virStorageBackendVolOpen(const char *path, struct stat *sb,
|
|
|
|
unsigned int flags)
|
2013-11-05 15:30:01 +00:00
|
|
|
ATTRIBUTE_RETURN_CHECK
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2015-04-27 20:48:05 +00:00
|
|
|
# define VIR_STORAGE_DEFAULT_POOL_PERM_MODE 0755
|
|
|
|
# define VIR_STORAGE_DEFAULT_VOL_PERM_MODE 0600
|
|
|
|
|
2010-02-04 20:02:58 +00:00
|
|
|
int virStorageBackendUpdateVolInfo(virStorageVolDefPtr vol,
|
2014-03-30 22:50:36 +00:00
|
|
|
bool withBlockVolFormat,
|
2015-11-24 15:08:29 +00:00
|
|
|
unsigned int openflags,
|
|
|
|
unsigned int readflags);
|
2014-04-01 21:11:30 +00:00
|
|
|
int virStorageBackendUpdateVolTargetInfo(virStorageSourcePtr target,
|
2014-03-30 22:50:36 +00:00
|
|
|
bool withBlockVolFormat,
|
2015-11-24 15:08:29 +00:00
|
|
|
unsigned int openflags,
|
|
|
|
unsigned int readflags);
|
2014-04-01 21:11:30 +00:00
|
|
|
int virStorageBackendUpdateVolTargetInfoFD(virStorageSourcePtr target,
|
2009-01-27 18:30:03 +00:00
|
|
|
int fd,
|
2015-02-19 12:43:03 +00:00
|
|
|
struct stat *sb);
|
2008-11-28 07:50:20 +00:00
|
|
|
|
2015-04-07 14:53:37 +00:00
|
|
|
bool virStorageBackendPoolPathIsStable(const char *path);
|
2010-02-04 20:02:58 +00:00
|
|
|
char *virStorageBackendStablePath(virStoragePoolObjPtr pool,
|
2012-10-21 16:53:20 +00:00
|
|
|
const char *devpath,
|
2012-10-23 11:33:21 +00:00
|
|
|
bool loop);
|
2008-02-20 15:38:29 +00:00
|
|
|
|
2013-02-18 11:52:58 +00:00
|
|
|
virCommandPtr
|
2014-07-31 16:08:33 +00:00
|
|
|
virStorageBackendCreateQemuImgCmdFromVol(virConnectPtr conn,
|
|
|
|
virStoragePoolObjPtr pool,
|
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStorageVolDefPtr inputvol,
|
|
|
|
unsigned int flags,
|
|
|
|
const char *create_tool,
|
|
|
|
int imgformat);
|
2009-06-17 08:38:17 +00:00
|
|
|
|
2014-02-03 15:12:57 +00:00
|
|
|
/* ------- virStorageFile backends ------------ */
|
2014-04-08 10:07:24 +00:00
|
|
|
typedef struct _virStorageFileBackend virStorageFileBackend;
|
|
|
|
typedef virStorageFileBackend *virStorageFileBackendPtr;
|
|
|
|
|
|
|
|
struct _virStorageDriverData {
|
|
|
|
virStorageFileBackendPtr backend;
|
|
|
|
void *priv;
|
2014-04-25 11:45:48 +00:00
|
|
|
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2014-04-08 10:07:24 +00:00
|
|
|
};
|
|
|
|
|
2014-02-03 15:12:57 +00:00
|
|
|
typedef int
|
2014-04-08 10:07:24 +00:00
|
|
|
(*virStorageFileBackendInit)(virStorageSourcePtr src);
|
2014-02-03 15:12:57 +00:00
|
|
|
|
|
|
|
typedef void
|
2014-04-08 10:07:24 +00:00
|
|
|
(*virStorageFileBackendDeinit)(virStorageSourcePtr src);
|
2014-02-03 15:12:57 +00:00
|
|
|
|
|
|
|
typedef int
|
2014-04-08 10:07:24 +00:00
|
|
|
(*virStorageFileBackendCreate)(virStorageSourcePtr src);
|
2014-02-03 15:12:57 +00:00
|
|
|
|
|
|
|
typedef int
|
2014-04-08 10:07:24 +00:00
|
|
|
(*virStorageFileBackendUnlink)(virStorageSourcePtr src);
|
2014-02-03 15:12:57 +00:00
|
|
|
|
|
|
|
typedef int
|
2014-04-08 10:07:24 +00:00
|
|
|
(*virStorageFileBackendStat)(virStorageSourcePtr src,
|
2014-02-03 15:12:57 +00:00
|
|
|
struct stat *st);
|
|
|
|
|
2014-03-07 10:53:18 +00:00
|
|
|
typedef ssize_t
|
|
|
|
(*virStorageFileBackendReadHeader)(virStorageSourcePtr src,
|
|
|
|
ssize_t max_len,
|
|
|
|
char **buf);
|
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
typedef const char *
|
|
|
|
(*virStorageFileBackendGetUniqueIdentifier)(virStorageSourcePtr src);
|
2014-03-07 10:53:18 +00:00
|
|
|
|
2014-04-26 16:15:41 +00:00
|
|
|
typedef int
|
|
|
|
(*virStorageFileBackendAccess)(virStorageSourcePtr src,
|
|
|
|
int mode);
|
|
|
|
|
2014-07-09 14:42:10 +00:00
|
|
|
typedef int
|
|
|
|
(*virStorageFileBackendChown)(virStorageSourcePtr src,
|
|
|
|
uid_t uid,
|
|
|
|
gid_t gid);
|
|
|
|
|
2014-02-03 15:12:57 +00:00
|
|
|
virStorageFileBackendPtr virStorageFileBackendForType(int type, int protocol);
|
2014-04-24 14:21:20 +00:00
|
|
|
virStorageFileBackendPtr virStorageFileBackendForTypeInternal(int type,
|
|
|
|
int protocol,
|
|
|
|
bool report);
|
2014-04-08 10:07:24 +00:00
|
|
|
|
|
|
|
|
2014-02-03 15:12:57 +00:00
|
|
|
struct _virStorageFileBackend {
|
|
|
|
int type;
|
|
|
|
int protocol;
|
|
|
|
|
|
|
|
/* All storage file callbacks may be omitted if not implemented */
|
|
|
|
|
|
|
|
/* The following group of callbacks is expected to set a libvirt
|
|
|
|
* error on failure. */
|
|
|
|
virStorageFileBackendInit backendInit;
|
|
|
|
virStorageFileBackendDeinit backendDeinit;
|
2014-03-07 10:53:18 +00:00
|
|
|
virStorageFileBackendReadHeader storageFileReadHeader;
|
2014-04-22 14:02:54 +00:00
|
|
|
virStorageFileBackendGetUniqueIdentifier storageFileGetUniqueIdentifier;
|
2014-02-03 15:12:57 +00:00
|
|
|
|
|
|
|
/* The following group of callbacks is expected to set errno
|
|
|
|
* and return -1 on error. No libvirt error shall be reported */
|
|
|
|
virStorageFileBackendCreate storageFileCreate;
|
|
|
|
virStorageFileBackendUnlink storageFileUnlink;
|
|
|
|
virStorageFileBackendStat storageFileStat;
|
2014-04-26 16:15:41 +00:00
|
|
|
virStorageFileBackendAccess storageFileAccess;
|
2014-07-09 14:42:10 +00:00
|
|
|
virStorageFileBackendChown storageFileChown;
|
2014-02-03 15:12:57 +00:00
|
|
|
};
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
#endif /* __VIR_STORAGE_BACKEND_H__ */
|