2008-02-20 15:34:52 +00:00
|
|
|
/*
|
|
|
|
* storage_backend.h: internal storage driver backend contract
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:42 +00:00
|
|
|
#pragma once
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2019-06-18 16:12:42 +00:00
|
|
|
#include <sys/stat.h>
|
2013-11-05 15:30:01 +00:00
|
|
|
|
2019-06-18 16:12:42 +00:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virstorageobj.h"
|
|
|
|
#include "storage_driver.h"
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef char * (*virStorageBackendFindPoolSources)(const char *srcSpec,
|
2014-01-10 10:29:44 +00:00
|
|
|
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);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendStartPool)(virStoragePoolObjPtr pool);
|
|
|
|
typedef int (*virStorageBackendBuildPool)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
unsigned int flags);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendRefreshPool)(virStoragePoolObjPtr pool);
|
|
|
|
typedef int (*virStorageBackendStopPool)(virStoragePoolObjPtr pool);
|
|
|
|
typedef int (*virStorageBackendDeletePool)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
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.
|
|
|
|
*/
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendBuildVol)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
virStorageVolDefPtr vol,
|
2012-12-05 10:48:07 +00:00
|
|
|
unsigned int flags);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendCreateVol)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
virStorageVolDefPtr vol);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendRefreshVol)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
virStorageVolDefPtr vol);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendDeleteVol)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
unsigned int flags);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendBuildVolFrom)(virStoragePoolObjPtr pool,
|
2014-01-10 10:29:44 +00:00
|
|
|
virStorageVolDefPtr origvol,
|
|
|
|
virStorageVolDefPtr newvol,
|
2010-01-20 23:41:52 +00:00
|
|
|
unsigned int flags);
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendVolumeResize)(virStoragePoolObjPtr pool,
|
2012-01-30 07:40:00 +00:00
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
unsigned long long capacity,
|
|
|
|
unsigned int flags);
|
2018-08-19 06:26:04 +00:00
|
|
|
|
|
|
|
/* Upon entering this callback passed @obj is unlocked. However,
|
|
|
|
* the pool's asyncjobs counter has been incremented and volume's
|
|
|
|
* in_use has been adjusted to ensure singular usage. */
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendVolumeDownload)(virStoragePoolObjPtr obj,
|
2014-07-07 14:50:11 +00:00
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long length,
|
|
|
|
unsigned int flags);
|
2018-08-19 06:26:04 +00:00
|
|
|
|
|
|
|
/* Upon entering this callback passed @obj is unlocked. However,
|
|
|
|
* the pool's asyncjobs counter has been incremented and volume's
|
|
|
|
* in_use has been adjusted to ensure singular usage. */
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendVolumeUpload)(virStoragePoolObjPtr obj,
|
2014-07-07 14:50:11 +00:00
|
|
|
virStorageVolDefPtr vol,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long len,
|
|
|
|
unsigned int flags);
|
2018-08-19 06:26:04 +00:00
|
|
|
|
|
|
|
/* Upon entering this callback passed @obj is unlocked. However,
|
|
|
|
* the pool's asyncjobs counter has been incremented and volume's
|
|
|
|
* in_use has been adjusted to ensure singular usage. */
|
2018-01-26 13:31:58 +00:00
|
|
|
typedef int (*virStorageBackendVolumeWipe)(virStoragePoolObjPtr pool,
|
2014-07-07 14:50:11 +00:00
|
|
|
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
|
|
|
|
2017-02-07 17:58:39 +00:00
|
|
|
int virStorageBackendDriversRegister(bool allmodules);
|
2017-01-13 15:50:11 +00:00
|
|
|
|
|
|
|
int virStorageBackendRegister(virStorageBackendPtr backend);
|
|
|
|
|
2019-01-10 12:23:26 +00:00
|
|
|
virCapsPtr
|
|
|
|
virStorageBackendGetCapabilities(void);
|