Add backends for this frontend function so that we can use it in the
snapshot creation code.
---
src/storage/storage_backend_fs.c | 17 +++++++++++++++++
src/storage/storage_backend_gluster.c | 15 +++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 693ebd3..1705a5a 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1367,6 +1367,22 @@ virStorageFileBackendFileInit(virStorageSourcePtr src)
static int
+virStorageFileBackendFileCreate(virStorageSourcePtr src)
+{
+ int fd = -1;
+
+ if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, 0,
+ src->drv->uid, src->drv->gid, 0)) < 0) {
+ errno = -fd;
+ return -1;
+ }
+
+ VIR_FORCE_CLOSE(fd);
+ return 0;
+}
+
+
+static int
virStorageFileBackendFileUnlink(virStorageSourcePtr src)
{
return unlink(src->path);
@@ -1450,6 +1466,7 @@ virStorageFileBackend virStorageFileBackendFile = {
.backendInit = virStorageFileBackendFileInit,
.backendDeinit = virStorageFileBackendFileDeinit,
+ .storageFileCreate = virStorageFileBackendFileCreate,
.storageFileUnlink = virStorageFileBackendFileUnlink,
.storageFileStat = virStorageFileBackendFileStat,
.storageFileReadHeader = virStorageFileBackendFileReadHeader,
diff --git a/src/storage/storage_backend_gluster.c
b/src/storage/storage_backend_gluster.c
index edb0511..c2eafd4 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -626,6 +626,20 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr src)
static int
+virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
+{
+ virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
+ glfs_fd_t *fd = NULL;
+
+ if (!(fd = glfs_open(priv->vol, src->path, O_CREAT | O_TRUNC | O_WRONLY)))
+ return -1;
+
+ ignore_value(glfs_close(fd));
+ return 0;
+}
+
+
+static int
virStorageFileBackendGlusterUnlink(virStorageSourcePtr src)
{
virStorageFileBackendGlusterPrivPtr priv = src->drv->priv;
@@ -772,6 +786,7 @@ virStorageFileBackend virStorageFileBackendGluster = {
.backendInit = virStorageFileBackendGlusterInit,
.backendDeinit = virStorageFileBackendGlusterDeinit,
+ .storageFileCreate = virStorageFileBackendGlusterCreate,
.storageFileUnlink = virStorageFileBackendGlusterUnlink,
.storageFileStat = virStorageFileBackendGlusterStat,
.storageFileReadHeader = virStorageFileBackendGlusterReadHeader,
--
2.0.0