2008-02-20 15:45:59 +00:00
|
|
|
/*
|
|
|
|
* storage_backend_fs.c: storage backend for FS and directory handling
|
|
|
|
*
|
2015-12-09 00:46:31 +00:00
|
|
|
* Copyright (C) 2007-2015 Red Hat, Inc.
|
2008-02-20 15:45:59 +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:45:59 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/tree.h>
|
|
|
|
#include <libxml/xpath.h>
|
|
|
|
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2008-02-20 15:45:59 +00:00
|
|
|
#include "storage_backend_fs.h"
|
2017-01-11 17:04:15 +00:00
|
|
|
#include "storage_util.h"
|
2008-02-20 15:45:59 +00:00
|
|
|
#include "storage_conf.h"
|
2012-12-13 15:25:48 +00:00
|
|
|
#include "virstoragefile.h"
|
2012-12-12 16:27:01 +00:00
|
|
|
#include "vircommand.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-13 18:13:21 +00:00
|
|
|
#include "virxml.h"
|
2011-07-19 18:32:58 +00:00
|
|
|
#include "virfile.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_STORAGE
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("storage.storage_backend_fs");
|
|
|
|
|
2008-02-20 15:45:59 +00:00
|
|
|
#if WITH_STORAGE_FS
|
2009-01-06 08:43:44 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <mntent.h>
|
2009-01-06 08:43:44 +00:00
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
struct _virNetfsDiscoverState {
|
|
|
|
const char *host;
|
2008-11-04 21:54:21 +00:00
|
|
|
virStoragePoolSourceList list;
|
2008-08-27 20:05:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virNetfsDiscoverState virNetfsDiscoverState;
|
|
|
|
|
|
|
|
static int
|
2014-03-18 14:35:01 +00:00
|
|
|
virStorageBackendFileSystemNetFindPoolSourcesFunc(char **const groups,
|
2008-08-27 20:05:58 +00:00
|
|
|
void *data)
|
|
|
|
{
|
|
|
|
virNetfsDiscoverState *state = data;
|
|
|
|
const char *name, *path;
|
2009-10-15 15:41:53 +00:00
|
|
|
virStoragePoolSource *src = NULL;
|
|
|
|
int ret = -1;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
|
|
|
path = groups[0];
|
|
|
|
|
2012-07-09 12:08:00 +00:00
|
|
|
if (!(name = strrchr(path, '/'))) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("invalid netfs path (no /): %s"), path);
|
2009-10-15 15:41:53 +00:00
|
|
|
goto cleanup;
|
2008-08-27 20:05:58 +00:00
|
|
|
}
|
|
|
|
name += 1;
|
|
|
|
if (*name == '\0') {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("invalid netfs path (ends in /): %s"), path);
|
2009-10-15 15:41:53 +00:00
|
|
|
goto cleanup;
|
2008-08-27 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
if (!(src = virStoragePoolSourceListNewSource(&state->list)))
|
2009-10-15 15:41:53 +00:00
|
|
|
goto cleanup;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2013-07-04 10:16:29 +00:00
|
|
|
if (VIR_ALLOC_N(src->hosts, 1) < 0)
|
2012-04-25 10:43:09 +00:00
|
|
|
goto cleanup;
|
2012-07-09 12:37:01 +00:00
|
|
|
src->nhost = 1;
|
2012-04-25 10:43:09 +00:00
|
|
|
|
2013-05-03 12:49:08 +00:00
|
|
|
if (VIR_STRDUP(src->hosts[0].name, state->host) < 0 ||
|
|
|
|
VIR_STRDUP(src->dir, path) < 0)
|
2009-10-15 15:41:53 +00:00
|
|
|
goto cleanup;
|
2008-11-04 21:54:21 +00:00
|
|
|
src->format = VIR_STORAGE_POOL_NETFS_NFS;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2009-10-15 15:41:53 +00:00
|
|
|
ret = 0;
|
2014-03-25 06:52:40 +00:00
|
|
|
cleanup:
|
2009-10-15 15:41:53 +00:00
|
|
|
return ret;
|
2008-08-27 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
2009-10-15 15:41:53 +00:00
|
|
|
|
2014-04-09 16:17:39 +00:00
|
|
|
static int
|
2014-03-26 16:25:40 +00:00
|
|
|
virStorageBackendFileSystemNetFindNFSPoolSources(virNetfsDiscoverState *state)
|
2008-08-27 20:05:58 +00:00
|
|
|
{
|
2014-04-09 16:17:39 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
2008-08-27 20:05:58 +00:00
|
|
|
/*
|
|
|
|
* # showmount --no-headers -e HOSTNAME
|
|
|
|
* /tmp *
|
|
|
|
* /A dir demo1.foo.bar,demo2.foo.bar
|
|
|
|
*
|
|
|
|
* Extract directory name (including possible interior spaces ...).
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char *regexes[] = {
|
|
|
|
"^(/.*\\S) +\\S+$"
|
|
|
|
};
|
|
|
|
int vars[] = {
|
|
|
|
1
|
|
|
|
};
|
2014-03-26 16:25:40 +00:00
|
|
|
|
|
|
|
virCommandPtr cmd = NULL;
|
|
|
|
|
|
|
|
cmd = virCommandNewArgList(SHOWMOUNT,
|
|
|
|
"--no-headers",
|
|
|
|
"--exports",
|
|
|
|
state->host,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (virCommandRunRegex(cmd, 1, regexes, vars,
|
|
|
|
virStorageBackendFileSystemNetFindPoolSourcesFunc,
|
2016-05-13 16:36:39 +00:00
|
|
|
state, NULL, NULL) < 0)
|
2014-04-09 16:17:39 +00:00
|
|
|
goto cleanup;
|
2014-03-26 16:25:40 +00:00
|
|
|
|
2014-04-09 16:17:39 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2014-03-26 16:25:40 +00:00
|
|
|
virCommandFree(cmd);
|
2014-04-09 16:17:39 +00:00
|
|
|
return ret;
|
2014-03-26 16:25:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
virStorageBackendFileSystemNetFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
const char *srcSpec,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
2008-11-04 21:54:21 +00:00
|
|
|
virNetfsDiscoverState state = {
|
|
|
|
.host = NULL,
|
|
|
|
.list = {
|
|
|
|
.type = VIR_STORAGE_POOL_NETFS,
|
|
|
|
.nsources = 0,
|
|
|
|
.sources = NULL
|
|
|
|
}
|
|
|
|
};
|
2009-10-15 15:58:35 +00:00
|
|
|
virStoragePoolSourcePtr source = NULL;
|
2014-03-26 16:25:40 +00:00
|
|
|
char *ret = NULL;
|
Convert 'int i' to 'size_t i' in src/storage/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2017-01-10 17:29:54 +00:00
|
|
|
int retNFS = -1;
|
|
|
|
int retGluster = 0;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2011-07-06 22:51:23 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2012-07-31 08:56:41 +00:00
|
|
|
if (!srcSpec) {
|
2014-03-26 16:25:40 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
|
|
_("hostname must be specified for netfs sources"));
|
2012-07-31 08:56:41 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(source = virStoragePoolDefParseSourceString(srcSpec,
|
|
|
|
VIR_STORAGE_POOL_NETFS)))
|
|
|
|
return NULL;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2012-04-25 10:43:09 +00:00
|
|
|
if (source->nhost != 1) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("Expected exactly 1 host for the storage pool"));
|
2012-04-25 10:43:09 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
state.host = source->hosts[0].name;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2014-04-09 16:17:39 +00:00
|
|
|
retNFS = virStorageBackendFileSystemNetFindNFSPoolSources(&state);
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2017-01-10 17:29:54 +00:00
|
|
|
retGluster = virStorageBackendFindGlusterPoolSources(state.host,
|
|
|
|
VIR_STORAGE_POOL_NETFS_GLUSTERFS,
|
2017-01-09 14:56:12 +00:00
|
|
|
&state.list, false);
|
2017-01-10 17:29:54 +00:00
|
|
|
|
|
|
|
if (retGluster < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2014-04-09 16:17:39 +00:00
|
|
|
/* If both fail, then we won't return an empty list - return an error */
|
2017-01-10 17:29:54 +00:00
|
|
|
if (retNFS < 0 && retGluster == 0) {
|
|
|
|
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
|
_("no storage pools were found on host '%s'"),
|
|
|
|
state.host);
|
2014-03-26 18:17:55 +00:00
|
|
|
goto cleanup;
|
2017-01-10 17:29:54 +00:00
|
|
|
}
|
2014-03-26 18:17:55 +00:00
|
|
|
|
2014-03-26 16:25:40 +00:00
|
|
|
if (!(ret = virStoragePoolSourceListFormat(&state.list)))
|
2008-08-27 20:05:58 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
cleanup:
|
2008-11-04 21:54:21 +00:00
|
|
|
for (i = 0; i < state.list.nsources; i++)
|
2011-10-21 22:44:52 +00:00
|
|
|
virStoragePoolSourceClear(&state.list.sources[i]);
|
|
|
|
VIR_FREE(state.list.sources);
|
2008-11-04 21:54:21 +00:00
|
|
|
|
2010-02-05 16:09:43 +00:00
|
|
|
virStoragePoolSourceFree(source);
|
2014-03-26 16:25:40 +00:00
|
|
|
return ret;
|
2008-08-27 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
2015-06-02 23:35:35 +00:00
|
|
|
/**
|
|
|
|
* @pool storage pool to check FS types
|
|
|
|
*
|
|
|
|
* Determine if storage pool FS types are properly set up
|
|
|
|
*
|
|
|
|
* Return 0 if everything's OK, -1 on error
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virStorageBackendFileSystemIsValid(virStoragePoolObjPtr pool)
|
|
|
|
{
|
|
|
|
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
|
|
|
|
if (pool->def->source.nhost != 1) {
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("expected exactly 1 host for the storage pool"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (pool->def->source.hosts[0].name == NULL) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("missing source host"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (pool->def->source.dir == NULL) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("missing source path"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (pool->def->source.ndevice != 1) {
|
2015-06-02 20:25:58 +00:00
|
|
|
if (pool->def->source.ndevice == 0)
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("missing source device"));
|
|
|
|
else
|
|
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
|
|
|
_("expected exactly 1 device for the "
|
|
|
|
"storage pool"));
|
2015-06-02 23:35:35 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2015-12-07 13:19:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* virStorageBackendFileSystemGetPoolSource
|
|
|
|
* @pool: storage pool object pointer
|
|
|
|
*
|
|
|
|
* Allocate/return a string representing the FS storage pool source.
|
|
|
|
* It is up to the caller to VIR_FREE the allocated string
|
|
|
|
*/
|
|
|
|
static char *
|
|
|
|
virStorageBackendFileSystemGetPoolSource(virStoragePoolObjPtr pool)
|
|
|
|
{
|
|
|
|
char *src = NULL;
|
|
|
|
|
|
|
|
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
|
|
|
|
if (pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS) {
|
|
|
|
if (virAsprintf(&src, "//%s/%s",
|
|
|
|
pool->def->source.hosts[0].name,
|
|
|
|
pool->def->source.dir) < 0)
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
if (virAsprintf(&src, "%s:%s",
|
|
|
|
pool->def->source.hosts[0].name,
|
|
|
|
pool->def->source.dir) < 0)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (VIR_STRDUP(src, pool->def->source.devices[0].path) < 0)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return src;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 15:45:59 +00:00
|
|
|
/**
|
|
|
|
* @pool storage pool to check for status
|
|
|
|
*
|
|
|
|
* Determine if a storage pool is already mounted
|
|
|
|
*
|
|
|
|
* Return 0 if not mounted, 1 if mounted, -1 on error
|
|
|
|
*/
|
|
|
|
static int
|
2014-03-18 08:15:36 +00:00
|
|
|
virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool)
|
|
|
|
{
|
2015-12-07 13:26:42 +00:00
|
|
|
int ret = -1;
|
2015-12-07 13:35:57 +00:00
|
|
|
char *src = NULL;
|
2008-02-20 15:45:59 +00:00
|
|
|
FILE *mtab;
|
2009-01-22 19:41:48 +00:00
|
|
|
struct mntent ent;
|
|
|
|
char buf[1024];
|
2017-02-07 09:19:21 +00:00
|
|
|
int rc1, rc2;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
|
|
|
if ((mtab = fopen(_PATH_MOUNTED, "r")) == NULL) {
|
2010-02-04 20:02:58 +00:00
|
|
|
virReportSystemError(errno,
|
2009-01-20 17:13:33 +00:00
|
|
|
_("cannot read mount list '%s'"),
|
|
|
|
_PATH_MOUNTED);
|
2015-12-07 13:26:42 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
|
|
|
|
2009-01-22 19:41:48 +00:00
|
|
|
while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) != NULL) {
|
2015-12-07 13:35:57 +00:00
|
|
|
if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
|
|
|
|
goto cleanup;
|
|
|
|
|
2017-02-07 09:19:21 +00:00
|
|
|
/* compare both mount destinations and sources to be sure the mounted
|
|
|
|
* FS pool is really the one we're looking for
|
|
|
|
*/
|
|
|
|
if ((rc1 = virFileComparePaths(ent.mnt_dir,
|
|
|
|
pool->def->target.path)) < 0 ||
|
|
|
|
(rc2 = virFileComparePaths(ent.mnt_fsname, src)) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (rc1 && rc2) {
|
2015-12-07 13:26:42 +00:00
|
|
|
ret = 1;
|
|
|
|
goto cleanup;
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
2015-12-07 13:35:57 +00:00
|
|
|
|
|
|
|
VIR_FREE(src);
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 13:26:42 +00:00
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
cleanup:
|
2010-11-17 02:13:29 +00:00
|
|
|
VIR_FORCE_FCLOSE(mtab);
|
2015-12-07 13:35:57 +00:00
|
|
|
VIR_FREE(src);
|
2015-12-07 13:26:42 +00:00
|
|
|
return ret;
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @pool storage pool to mount
|
|
|
|
*
|
|
|
|
* Ensure that a FS storage pool is mounted on its target location.
|
|
|
|
* If already mounted, this is a no-op
|
|
|
|
*
|
|
|
|
* Returns 0 if successfully mounted, -1 on error
|
|
|
|
*/
|
|
|
|
static int
|
2014-03-18 08:15:36 +00:00
|
|
|
virStorageBackendFileSystemMount(virStoragePoolObjPtr pool)
|
|
|
|
{
|
2012-07-11 14:56:55 +00:00
|
|
|
char *src = NULL;
|
2008-07-17 15:20:28 +00:00
|
|
|
/* 'mount -t auto' doesn't seem to auto determine nfs (or cifs),
|
|
|
|
* while plain 'mount' does. We have to craft separate argvs to
|
|
|
|
* accommodate this */
|
2012-07-11 14:56:55 +00:00
|
|
|
bool netauto = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
|
|
|
|
pool->def->source.format == VIR_STORAGE_POOL_NETFS_AUTO);
|
|
|
|
bool glusterfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
|
|
|
|
pool->def->source.format == VIR_STORAGE_POOL_NETFS_GLUSTERFS);
|
2015-06-03 14:20:56 +00:00
|
|
|
bool cifsfs = (pool->def->type == VIR_STORAGE_POOL_NETFS &&
|
|
|
|
pool->def->source.format == VIR_STORAGE_POOL_NETFS_CIFS);
|
2012-07-11 14:56:55 +00:00
|
|
|
virCommandPtr cmd = NULL;
|
|
|
|
int ret = -1;
|
2013-07-11 10:36:59 +00:00
|
|
|
int rc;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2015-06-02 23:35:35 +00:00
|
|
|
if (virStorageBackendFileSystemIsValid(pool) < 0)
|
|
|
|
return -1;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2017-02-06 14:03:52 +00:00
|
|
|
if ((rc = virStorageBackendFileSystemIsMounted(pool)) < 0)
|
2012-06-27 14:02:23 +00:00
|
|
|
return -1;
|
2017-02-06 14:03:52 +00:00
|
|
|
|
|
|
|
/* Short-circuit if already mounted */
|
|
|
|
if (rc == 1) {
|
|
|
|
VIR_INFO("Target '%s' is already mounted", pool->def->target.path);
|
|
|
|
return 0;
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
|
|
|
|
2015-12-07 13:19:34 +00:00
|
|
|
if (!(src = virStorageBackendFileSystemGetPoolSource(pool)))
|
|
|
|
return -1;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2012-07-11 14:56:55 +00:00
|
|
|
if (netauto)
|
|
|
|
cmd = virCommandNewArgList(MOUNT,
|
|
|
|
src,
|
|
|
|
pool->def->target.path,
|
|
|
|
NULL);
|
|
|
|
else if (glusterfs)
|
2012-10-17 09:23:12 +00:00
|
|
|
cmd = virCommandNewArgList(MOUNT,
|
|
|
|
"-t",
|
2015-06-15 21:20:32 +00:00
|
|
|
virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format),
|
2012-10-17 09:23:12 +00:00
|
|
|
src,
|
|
|
|
"-o",
|
|
|
|
"direct-io-mode=1",
|
|
|
|
pool->def->target.path,
|
|
|
|
NULL);
|
2015-06-03 14:20:56 +00:00
|
|
|
else if (cifsfs)
|
|
|
|
cmd = virCommandNewArgList(MOUNT,
|
|
|
|
"-t",
|
|
|
|
virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format),
|
|
|
|
src,
|
|
|
|
pool->def->target.path,
|
|
|
|
"-o",
|
|
|
|
"guest",
|
|
|
|
NULL);
|
2012-07-11 14:56:55 +00:00
|
|
|
else
|
|
|
|
cmd = virCommandNewArgList(MOUNT,
|
|
|
|
"-t",
|
|
|
|
(pool->def->type == VIR_STORAGE_POOL_FS ?
|
|
|
|
virStoragePoolFormatFileSystemTypeToString(pool->def->source.format) :
|
|
|
|
virStoragePoolFormatFileSystemNetTypeToString(pool->def->source.format)),
|
|
|
|
src,
|
|
|
|
pool->def->target.path,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
2014-03-25 06:52:40 +00:00
|
|
|
cleanup:
|
2012-07-11 14:56:55 +00:00
|
|
|
virCommandFree(cmd);
|
2008-06-06 11:09:57 +00:00
|
|
|
VIR_FREE(src);
|
2012-07-11 14:56:55 +00:00
|
|
|
return ret;
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
|
|
|
|
2017-01-21 16:47:23 +00:00
|
|
|
|
2008-02-20 15:45:59 +00:00
|
|
|
/**
|
2017-01-21 16:47:23 +00:00
|
|
|
* @conn connection to report errors against
|
|
|
|
* @pool storage pool to start
|
|
|
|
*
|
|
|
|
* Starts a directory or FS based storage pool. The underlying source
|
|
|
|
* device will be mounted for FS based pools.
|
|
|
|
*
|
|
|
|
* Returns 0 on success, -1 on error
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
virStorageBackendFileSystemStart(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virStoragePoolObjPtr pool)
|
|
|
|
{
|
|
|
|
if (pool->def->type != VIR_STORAGE_POOL_DIR &&
|
|
|
|
virStorageBackendFileSystemMount(pool) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @conn connection to report errors against
|
2008-02-20 15:45:59 +00:00
|
|
|
* @pool storage pool to unmount
|
|
|
|
*
|
2017-01-21 16:47:23 +00:00
|
|
|
* Stops a file storage pool. The underlying source device is unmounted
|
|
|
|
* for FS based pools. Any cached data about volumes is released.
|
|
|
|
*
|
2008-02-20 15:45:59 +00:00
|
|
|
* Ensure that a FS storage pool is not mounted on its target location.
|
2014-01-10 10:51:04 +00:00
|
|
|
* If already unmounted, this is a no-op.
|
2008-02-20 15:45:59 +00:00
|
|
|
*
|
|
|
|
* Returns 0 if successfully unmounted, -1 on error
|
|
|
|
*/
|
|
|
|
static int
|
2017-01-21 16:47:23 +00:00
|
|
|
virStorageBackendFileSystemStop(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virStoragePoolObjPtr pool)
|
2014-03-18 08:15:36 +00:00
|
|
|
{
|
2017-01-26 16:43:30 +00:00
|
|
|
virCommandPtr cmd = NULL;
|
|
|
|
int ret = -1;
|
2012-11-21 03:22:39 +00:00
|
|
|
int rc;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2015-06-02 23:35:35 +00:00
|
|
|
if (virStorageBackendFileSystemIsValid(pool) < 0)
|
|
|
|
return -1;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
|
|
|
/* Short-circuit if already unmounted */
|
2012-11-21 03:22:39 +00:00
|
|
|
if ((rc = virStorageBackendFileSystemIsMounted(pool)) != 1)
|
|
|
|
return rc;
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2017-01-26 16:43:30 +00:00
|
|
|
cmd = virCommandNewArgList(UMOUNT, pool->def->target.path, NULL);
|
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
|
|
virCommandFree(cmd);
|
|
|
|
return ret;
|
2008-02-20 15:45:59 +00:00
|
|
|
}
|
|
|
|
#endif /* WITH_STORAGE_FS */
|
|
|
|
|
|
|
|
|
2010-11-11 20:09:20 +00:00
|
|
|
static int
|
2015-03-09 14:34:35 +00:00
|
|
|
virStorageBackendFileSystemCheck(virStoragePoolObjPtr pool,
|
2010-11-11 20:09:20 +00:00
|
|
|
bool *isActive)
|
|
|
|
{
|
|
|
|
if (pool->def->type == VIR_STORAGE_POOL_DIR) {
|
2013-09-13 13:32:43 +00:00
|
|
|
*isActive = virFileExists(pool->def->target.path);
|
2010-11-11 20:09:20 +00:00
|
|
|
#if WITH_STORAGE_FS
|
|
|
|
} else {
|
|
|
|
int ret;
|
2013-09-13 13:32:43 +00:00
|
|
|
*isActive = false;
|
2015-06-02 23:48:56 +00:00
|
|
|
|
|
|
|
if (virStorageBackendFileSystemIsValid(pool) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2010-11-11 20:09:20 +00:00
|
|
|
if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) {
|
|
|
|
if (ret < 0)
|
|
|
|
return -1;
|
|
|
|
*isActive = true;
|
|
|
|
}
|
|
|
|
#endif /* WITH_STORAGE_FS */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-16 12:14:16 +00:00
|
|
|
/* some platforms don't support mkfs */
|
|
|
|
#ifdef MKFS
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
static int
|
|
|
|
virStorageBackendExecuteMKFS(const char *device,
|
|
|
|
const char *format)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
virCommandPtr cmd = NULL;
|
|
|
|
|
2014-04-03 09:09:14 +00:00
|
|
|
cmd = virCommandNewArgList(MKFS, "-t", format, NULL);
|
|
|
|
|
2016-11-15 20:29:47 +00:00
|
|
|
/* use the force, otherwise mkfs.xfs won't overwrite existing fs.
|
|
|
|
* Similarly mkfs.ext2, mkfs.ext3, and mkfs.ext4 require supplying -F
|
|
|
|
* and mkfs.vfat uses -I */
|
2014-04-03 09:09:14 +00:00
|
|
|
if (STREQ(format, "xfs"))
|
|
|
|
virCommandAddArg(cmd, "-f");
|
2016-11-15 20:29:47 +00:00
|
|
|
else if (STREQ(format, "ext2") ||
|
|
|
|
STREQ(format, "ext3") ||
|
|
|
|
STREQ(format, "ext4"))
|
|
|
|
virCommandAddArg(cmd, "-F");
|
|
|
|
else if (STREQ(format, "vfat"))
|
|
|
|
virCommandAddArg(cmd, "-I");
|
2014-04-03 09:09:14 +00:00
|
|
|
|
|
|
|
virCommandAddArg(cmd, device);
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
|
|
|
|
if (virCommandRun(cmd, NULL) < 0) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to make filesystem of "
|
|
|
|
"type '%s' on device '%s'"),
|
|
|
|
format, device);
|
|
|
|
ret = -1;
|
|
|
|
}
|
2013-01-23 22:04:46 +00:00
|
|
|
|
|
|
|
virCommandFree(cmd);
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2011-09-16 12:14:16 +00:00
|
|
|
#else /* #ifdef MKFS */
|
|
|
|
static int
|
|
|
|
virStorageBackendExecuteMKFS(const char *device ATTRIBUTE_UNUSED,
|
|
|
|
const char *format ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("mkfs is not supported on this platform: "
|
|
|
|
"Failed to make filesystem of "
|
|
|
|
"type '%s' on device '%s'"),
|
|
|
|
format, device);
|
2011-09-16 12:14:16 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* #ifdef MKFS */
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool,
|
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
const char *device = NULL, *format = NULL;
|
|
|
|
bool ok_to_mkfs = false;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (pool->def->source.devices == NULL) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("No source device specified when formatting pool '%s'"),
|
|
|
|
pool->def->name);
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
device = pool->def->source.devices[0].path;
|
|
|
|
format = virStoragePoolFormatFileSystemTypeToString(pool->def->source.format);
|
|
|
|
VIR_DEBUG("source device: '%s' format: '%s'", device, format);
|
|
|
|
|
|
|
|
if (!virFileExists(device)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("Source device does not exist when formatting pool '%s'"),
|
|
|
|
pool->def->name);
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & VIR_STORAGE_POOL_BUILD_OVERWRITE) {
|
|
|
|
ok_to_mkfs = true;
|
|
|
|
} else if (flags & VIR_STORAGE_POOL_BUILD_NO_OVERWRITE &&
|
2016-12-14 23:03:20 +00:00
|
|
|
virStorageBackendDeviceIsEmpty(device, format, true)) {
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
ok_to_mkfs = true;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:25:27 +00:00
|
|
|
if (ok_to_mkfs)
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
ret = virStorageBackendExecuteMKFS(device, format);
|
|
|
|
|
2014-03-25 06:52:40 +00:00
|
|
|
error:
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:45:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @conn connection to report errors against
|
|
|
|
* @pool storage pool to build
|
2011-12-01 23:08:34 +00:00
|
|
|
* @flags controls the pool formatting behaviour
|
2008-02-20 15:45:59 +00:00
|
|
|
*
|
|
|
|
* Build a directory or FS based storage pool.
|
|
|
|
*
|
storage: Fix implementation of no-overwrite for file system backend
https://bugzilla.redhat.com/show_bug.cgi?id=1363586
Commit id '27758859' introduced the "NO_OVERWRITE" flag check for
file system backends; however, the implementation, documentation,
and algorithm was inconsistent. For the "flag" description for the
API the flag was described as "Do not overwrite existing pool";
however, within the storage backend code the flag is described
as "it probes to determine if filesystem already exists on the
target device, renurning an error if exists".
The code itself was implemented using the paradigm to set up the
superblock probe by creating a filter that would cause the code
to only search for the provided format type. If that type wasn't
found, then the algorithm would return success allowing the caller
to format the device. If the format type already existed on the
device, then the code would fail indicating that the a filesystem
of the same type existed on the device.
The result is that if someone had a file system of one type on the
device, it was possible to overwrite it if a different format type
was specified in updated XML effectively trashing whatever was on
the device already.
This patch alters what NO_OVERWRITE does for a file system backend
to be more realistic and consistent with what should be expected when
the caller requests to not overwrite the data on the disk.
Rather than filter results based on the expected format type, the
code will allow success/failure be determined solely on whether the
blkid_do_probe calls finds some known format on the device. This
adjustment also allows removal of the virStoragePoolProbeResult
enum that was under utilized.
If it does find a formatted file system different errors will be
generated indicating a file system of a specific type already exists
or a file system of some other type already exists.
In the original virsh support commit id 'ddcd5674', the description
for '--no-overwrite' within the 'pool-build' command help output
has an ambiguous "of this type" included in the short description.
Compared to the longer description within the "Build a given pool."
section of the virsh.pod file it's more apparent that the meaning
of this flag would cause failure if a probe of the target already
has a filesystem.
So this patch also modifies the short description to just be the
antecedent of the 'overwrite' flag, which matches the API description.
This patch also modifies the grammar in virsh.pod for no-overwrite
as well as reworking the paragraph formats to make it easier to read.
Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-12-14 20:14:19 +00:00
|
|
|
* If no flag is set, it only makes the directory.
|
|
|
|
*
|
|
|
|
* If VIR_STORAGE_POOL_BUILD_NO_OVERWRITE set, it probes to determine if
|
|
|
|
* any filesystem already exists on the target device, returning an error
|
|
|
|
* if one exists. If no filesystem already exists, use mkfs to format the
|
|
|
|
* target device.
|
|
|
|
*
|
|
|
|
* If VIR_STORAGE_POOL_BUILD_OVERWRITE is set, mkfs is always executed and
|
|
|
|
* any existing data on the target device is overwritten unconditionally.
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
*
|
2014-01-10 10:51:04 +00:00
|
|
|
* The underlying source device is mounted for FS based pools.
|
2008-02-20 15:45:59 +00:00
|
|
|
*
|
|
|
|
* Returns 0 on success, -1 on error
|
|
|
|
*/
|
|
|
|
static int
|
2010-02-10 11:42:56 +00:00
|
|
|
virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
|
2008-02-20 15:45:59 +00:00
|
|
|
virStoragePoolObjPtr pool,
|
2011-07-06 22:51:23 +00:00
|
|
|
unsigned int flags)
|
2008-02-20 15:45:59 +00:00
|
|
|
{
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
virCheckFlags(VIR_STORAGE_POOL_BUILD_OVERWRITE |
|
2017-01-18 19:17:21 +00:00
|
|
|
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE, -1);
|
storage: Add fs pool formatting
This patch adds the ability to make the filesystem for a filesystem
pool during a pool build.
The patch adds two new flags, no overwrite and overwrite, to control
when mkfs gets executed. By default, the patch preserves the
current behavior, i.e., if no flags are specified, pool build on a
filesystem pool only makes the directory on which the filesystem
will be mounted.
If the no overwrite flag is specified, the target device is checked
to determine if a filesystem of the type specified in the pool is
present. If a filesystem of that type is already present, mkfs is
not executed and the build call returns an error. Otherwise, mkfs
is executed and any data present on the device is overwritten.
If the overwrite flag is specified, mkfs is always executed, and any
existing data on the target device is overwritten unconditionally.
2011-08-31 13:54:07 +00:00
|
|
|
|
2017-01-18 19:17:21 +00:00
|
|
|
VIR_EXCLUSIVE_FLAGS_RET(VIR_STORAGE_POOL_BUILD_OVERWRITE,
|
|
|
|
VIR_STORAGE_POOL_BUILD_NO_OVERWRITE,
|
|
|
|
-1);
|
2008-02-20 15:45:59 +00:00
|
|
|
|
2017-01-18 19:17:21 +00:00
|
|
|
if (virStorageBackendBuildLocal(pool) < 0)
|
2008-02-20 15:45:59 +00:00
|
|
|
return -1;
|
2017-01-18 19:17:21 +00:00
|
|
|
|
|
|
|
if (flags != 0)
|
|
|
|
return virStorageBackendMakeFileSystem(pool, flags);
|
2008-02-20 15:45:59 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virStorageBackend virStorageBackendDirectory = {
|
|
|
|
.type = VIR_STORAGE_POOL_DIR,
|
|
|
|
|
|
|
|
.buildPool = virStorageBackendFileSystemBuild,
|
2010-11-11 20:09:20 +00:00
|
|
|
.checkPool = virStorageBackendFileSystemCheck,
|
2017-01-18 19:17:21 +00:00
|
|
|
.refreshPool = virStorageBackendRefreshLocal,
|
|
|
|
.deletePool = virStorageBackendDeleteLocal,
|
2017-01-21 14:05:41 +00:00
|
|
|
.buildVol = virStorageBackendVolBuildLocal,
|
|
|
|
.buildVolFrom = virStorageBackendVolBuildFromLocal,
|
|
|
|
.createVol = virStorageBackendVolCreateLocal,
|
|
|
|
.refreshVol = virStorageBackendVolRefreshLocal,
|
|
|
|
.deleteVol = virStorageBackendVolDeleteLocal,
|
|
|
|
.resizeVol = virStorageBackendVolResizeLocal,
|
2014-07-07 14:50:11 +00:00
|
|
|
.uploadVol = virStorageBackendVolUploadLocal,
|
|
|
|
.downloadVol = virStorageBackendVolDownloadLocal,
|
2014-07-07 14:50:11 +00:00
|
|
|
.wipeVol = virStorageBackendVolWipeLocal,
|
2008-02-20 15:45:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if WITH_STORAGE_FS
|
|
|
|
virStorageBackend virStorageBackendFileSystem = {
|
|
|
|
.type = VIR_STORAGE_POOL_FS,
|
|
|
|
|
|
|
|
.buildPool = virStorageBackendFileSystemBuild,
|
2010-11-11 20:09:20 +00:00
|
|
|
.checkPool = virStorageBackendFileSystemCheck,
|
2008-02-20 15:45:59 +00:00
|
|
|
.startPool = virStorageBackendFileSystemStart,
|
2017-01-18 19:17:21 +00:00
|
|
|
.refreshPool = virStorageBackendRefreshLocal,
|
2008-02-20 15:45:59 +00:00
|
|
|
.stopPool = virStorageBackendFileSystemStop,
|
2017-01-18 19:17:21 +00:00
|
|
|
.deletePool = virStorageBackendDeleteLocal,
|
2017-01-21 14:05:41 +00:00
|
|
|
.buildVol = virStorageBackendVolBuildLocal,
|
|
|
|
.buildVolFrom = virStorageBackendVolBuildFromLocal,
|
|
|
|
.createVol = virStorageBackendVolCreateLocal,
|
|
|
|
.refreshVol = virStorageBackendVolRefreshLocal,
|
|
|
|
.deleteVol = virStorageBackendVolDeleteLocal,
|
|
|
|
.resizeVol = virStorageBackendVolResizeLocal,
|
2014-07-07 14:50:11 +00:00
|
|
|
.uploadVol = virStorageBackendVolUploadLocal,
|
|
|
|
.downloadVol = virStorageBackendVolDownloadLocal,
|
2014-07-07 14:50:11 +00:00
|
|
|
.wipeVol = virStorageBackendVolWipeLocal,
|
2008-02-20 15:45:59 +00:00
|
|
|
};
|
|
|
|
virStorageBackend virStorageBackendNetFileSystem = {
|
|
|
|
.type = VIR_STORAGE_POOL_NETFS,
|
|
|
|
|
|
|
|
.buildPool = virStorageBackendFileSystemBuild,
|
2010-11-11 20:09:20 +00:00
|
|
|
.checkPool = virStorageBackendFileSystemCheck,
|
2008-02-20 15:45:59 +00:00
|
|
|
.startPool = virStorageBackendFileSystemStart,
|
2008-08-27 20:05:58 +00:00
|
|
|
.findPoolSources = virStorageBackendFileSystemNetFindPoolSources,
|
2017-01-18 19:17:21 +00:00
|
|
|
.refreshPool = virStorageBackendRefreshLocal,
|
2008-02-20 15:45:59 +00:00
|
|
|
.stopPool = virStorageBackendFileSystemStop,
|
2017-01-18 19:17:21 +00:00
|
|
|
.deletePool = virStorageBackendDeleteLocal,
|
2017-01-21 14:05:41 +00:00
|
|
|
.buildVol = virStorageBackendVolBuildLocal,
|
|
|
|
.buildVolFrom = virStorageBackendVolBuildFromLocal,
|
|
|
|
.createVol = virStorageBackendVolCreateLocal,
|
|
|
|
.refreshVol = virStorageBackendVolRefreshLocal,
|
|
|
|
.deleteVol = virStorageBackendVolDeleteLocal,
|
|
|
|
.resizeVol = virStorageBackendVolResizeLocal,
|
2014-07-07 14:50:11 +00:00
|
|
|
.uploadVol = virStorageBackendVolUploadLocal,
|
|
|
|
.downloadVol = virStorageBackendVolDownloadLocal,
|
2014-07-07 14:50:11 +00:00
|
|
|
.wipeVol = virStorageBackendVolWipeLocal,
|
2008-02-20 15:45:59 +00:00
|
|
|
};
|
2017-01-13 15:59:30 +00:00
|
|
|
#endif /* WITH_STORAGE_FS */
|
2014-02-03 15:41:49 +00:00
|
|
|
|
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
typedef struct _virStorageFileBackendFsPriv virStorageFileBackendFsPriv;
|
|
|
|
typedef virStorageFileBackendFsPriv *virStorageFileBackendFsPrivPtr;
|
|
|
|
|
|
|
|
struct _virStorageFileBackendFsPriv {
|
|
|
|
char *canonpath; /* unique file identifier (canonical path) */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-05-02 14:51:48 +00:00
|
|
|
static void
|
|
|
|
virStorageFileBackendFileDeinit(virStorageSourcePtr src)
|
|
|
|
{
|
|
|
|
VIR_DEBUG("deinitializing FS storage file %p (%s:%s)", src,
|
|
|
|
virStorageTypeToString(virStorageSourceGetActualType(src)),
|
|
|
|
src->path);
|
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
virStorageFileBackendFsPrivPtr priv = src->drv->priv;
|
|
|
|
|
|
|
|
VIR_FREE(priv->canonpath);
|
|
|
|
VIR_FREE(priv);
|
2014-05-02 14:51:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-03 15:41:49 +00:00
|
|
|
static int
|
2014-05-02 14:51:48 +00:00
|
|
|
virStorageFileBackendFileInit(virStorageSourcePtr src)
|
2014-02-03 15:41:49 +00:00
|
|
|
{
|
2014-04-22 14:02:54 +00:00
|
|
|
virStorageFileBackendFsPrivPtr priv = NULL;
|
|
|
|
|
2014-10-14 13:55:09 +00:00
|
|
|
VIR_DEBUG("initializing FS storage file %p (%s:%s)[%u:%u]", src,
|
2014-05-02 14:51:48 +00:00
|
|
|
virStorageTypeToString(virStorageSourceGetActualType(src)),
|
2014-10-14 13:55:09 +00:00
|
|
|
src->path,
|
|
|
|
(unsigned int)src->drv->uid, (unsigned int)src->drv->gid);
|
2014-02-03 15:41:49 +00:00
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
if (VIR_ALLOC(priv) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
src->drv->priv = priv;
|
|
|
|
|
2014-05-02 14:51:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-02-03 15:41:49 +00:00
|
|
|
|
|
|
|
|
2014-06-30 13:05:07 +00:00
|
|
|
static int
|
|
|
|
virStorageFileBackendFileCreate(virStorageSourcePtr src)
|
|
|
|
{
|
|
|
|
int fd = -1;
|
2014-07-28 14:09:39 +00:00
|
|
|
mode_t mode = S_IRUSR;
|
2014-06-30 13:05:07 +00:00
|
|
|
|
2014-07-28 14:09:39 +00:00
|
|
|
if (!src->readonly)
|
|
|
|
mode |= S_IWUSR;
|
|
|
|
|
|
|
|
if ((fd = virFileOpenAs(src->path, O_WRONLY | O_TRUNC | O_CREAT, mode,
|
2014-06-30 13:05:07 +00:00
|
|
|
src->drv->uid, src->drv->gid, 0)) < 0) {
|
|
|
|
errno = -fd;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIR_FORCE_CLOSE(fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-02 14:51:48 +00:00
|
|
|
static int
|
|
|
|
virStorageFileBackendFileUnlink(virStorageSourcePtr src)
|
|
|
|
{
|
|
|
|
return unlink(src->path);
|
2014-02-03 15:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2014-04-08 10:07:24 +00:00
|
|
|
virStorageFileBackendFileStat(virStorageSourcePtr src,
|
2014-02-03 15:41:49 +00:00
|
|
|
struct stat *st)
|
|
|
|
{
|
2014-05-02 14:51:48 +00:00
|
|
|
return stat(src->path, st);
|
2014-02-03 15:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-07 10:53:18 +00:00
|
|
|
static ssize_t
|
|
|
|
virStorageFileBackendFileReadHeader(virStorageSourcePtr src,
|
|
|
|
ssize_t max_len,
|
|
|
|
char **buf)
|
|
|
|
{
|
|
|
|
int fd = -1;
|
|
|
|
ssize_t ret = -1;
|
|
|
|
|
|
|
|
if ((fd = virFileOpenAs(src->path, O_RDONLY, 0,
|
|
|
|
src->drv->uid, src->drv->gid, 0)) < 0) {
|
|
|
|
virReportSystemError(-fd, _("Failed to open file '%s'"),
|
|
|
|
src->path);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ret = virFileReadHeaderFD(fd, max_len, buf)) < 0) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("cannot read header '%s'"), src->path);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VIR_FORCE_CLOSE(fd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
static const char *
|
|
|
|
virStorageFileBackendFileGetUniqueIdentifier(virStorageSourcePtr src)
|
|
|
|
{
|
|
|
|
virStorageFileBackendFsPrivPtr priv = src->drv->priv;
|
|
|
|
|
|
|
|
if (!priv->canonpath) {
|
|
|
|
if (!(priv->canonpath = canonicalize_file_name(src->path))) {
|
|
|
|
virReportSystemError(errno, _("can't canonicalize path '%s'"),
|
|
|
|
src->path);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return priv->canonpath;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-26 16:15:41 +00:00
|
|
|
static int
|
|
|
|
virStorageFileBackendFileAccess(virStorageSourcePtr src,
|
|
|
|
int mode)
|
|
|
|
{
|
|
|
|
return virFileAccessibleAs(src->path, mode,
|
|
|
|
src->drv->uid, src->drv->gid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 14:42:10 +00:00
|
|
|
static int
|
2016-12-14 14:25:22 +00:00
|
|
|
virStorageFileBackendFileChown(const virStorageSource *src,
|
2014-07-09 14:42:10 +00:00
|
|
|
uid_t uid,
|
|
|
|
gid_t gid)
|
|
|
|
{
|
|
|
|
return chown(src->path, uid, gid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-02-03 15:41:49 +00:00
|
|
|
virStorageFileBackend virStorageFileBackendFile = {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
.type = VIR_STORAGE_TYPE_FILE,
|
2014-02-03 15:41:49 +00:00
|
|
|
|
2014-05-02 14:51:48 +00:00
|
|
|
.backendInit = virStorageFileBackendFileInit,
|
|
|
|
.backendDeinit = virStorageFileBackendFileDeinit,
|
|
|
|
|
2014-06-30 13:05:07 +00:00
|
|
|
.storageFileCreate = virStorageFileBackendFileCreate,
|
2014-02-03 15:41:49 +00:00
|
|
|
.storageFileUnlink = virStorageFileBackendFileUnlink,
|
|
|
|
.storageFileStat = virStorageFileBackendFileStat,
|
2014-03-07 10:53:18 +00:00
|
|
|
.storageFileReadHeader = virStorageFileBackendFileReadHeader,
|
2014-04-26 16:15:41 +00:00
|
|
|
.storageFileAccess = virStorageFileBackendFileAccess,
|
2014-07-09 14:42:10 +00:00
|
|
|
.storageFileChown = virStorageFileBackendFileChown,
|
2014-04-22 14:02:54 +00:00
|
|
|
|
|
|
|
.storageFileGetUniqueIdentifier = virStorageFileBackendFileGetUniqueIdentifier,
|
2014-02-03 15:41:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
virStorageFileBackend virStorageFileBackendBlock = {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
.type = VIR_STORAGE_TYPE_BLOCK,
|
2014-02-03 15:41:49 +00:00
|
|
|
|
2014-05-02 14:51:48 +00:00
|
|
|
.backendInit = virStorageFileBackendFileInit,
|
|
|
|
.backendDeinit = virStorageFileBackendFileDeinit,
|
|
|
|
|
2014-02-03 15:41:49 +00:00
|
|
|
.storageFileStat = virStorageFileBackendFileStat,
|
2014-03-07 10:53:18 +00:00
|
|
|
.storageFileReadHeader = virStorageFileBackendFileReadHeader,
|
2014-04-26 16:15:41 +00:00
|
|
|
.storageFileAccess = virStorageFileBackendFileAccess,
|
2014-07-09 14:42:10 +00:00
|
|
|
.storageFileChown = virStorageFileBackendFileChown,
|
2014-04-22 14:02:54 +00:00
|
|
|
|
|
|
|
.storageFileGetUniqueIdentifier = virStorageFileBackendFileGetUniqueIdentifier,
|
2014-02-03 15:41:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
virStorageFileBackend virStorageFileBackendDir = {
|
|
|
|
.type = VIR_STORAGE_TYPE_DIR,
|
|
|
|
|
|
|
|
.backendInit = virStorageFileBackendFileInit,
|
|
|
|
.backendDeinit = virStorageFileBackendFileDeinit,
|
|
|
|
|
2014-04-26 16:15:41 +00:00
|
|
|
.storageFileAccess = virStorageFileBackendFileAccess,
|
2014-07-09 14:42:10 +00:00
|
|
|
.storageFileChown = virStorageFileBackendFileChown,
|
2014-04-26 16:15:41 +00:00
|
|
|
|
2014-04-22 14:02:54 +00:00
|
|
|
.storageFileGetUniqueIdentifier = virStorageFileBackendFileGetUniqueIdentifier,
|
|
|
|
};
|
2017-01-13 15:50:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
virStorageBackendFsRegister(void)
|
|
|
|
{
|
|
|
|
if (virStorageBackendRegister(&virStorageBackendDirectory) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
#if WITH_STORAGE_FS
|
|
|
|
if (virStorageBackendRegister(&virStorageBackendFileSystem) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (virStorageBackendRegister(&virStorageBackendNetFileSystem) < 0)
|
|
|
|
return -1;
|
|
|
|
#endif /* WITH_STORAGE_FS */
|
|
|
|
|
|
|
|
if (virStorageBackendFileRegister(&virStorageFileBackendFile) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (virStorageBackendFileRegister(&virStorageFileBackendBlock) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (virStorageBackendFileRegister(&virStorageFileBackendDir) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|