2008-02-20 15:34:52 +00:00
|
|
|
/*
|
|
|
|
* storage_driver.c: core driver for storage APIs
|
|
|
|
*
|
2012-01-30 07:40:00 +00:00
|
|
|
* Copyright (C) 2006-2012 Red Hat, Inc.
|
2008-02-20 15:34:52 +00:00
|
|
|
* Copyright (C) 2006-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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/types.h>
|
2010-02-23 03:13:18 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
2008-04-18 08:33:23 +00:00
|
|
|
#if HAVE_PWD_H
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <pwd.h>
|
2008-04-18 08:33:23 +00:00
|
|
|
#endif
|
2008-02-20 15:34:52 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2008-11-04 23:22:06 +00:00
|
|
|
#include "datatypes.h"
|
2008-02-20 15:34:52 +00:00
|
|
|
#include "driver.h"
|
|
|
|
#include "storage_driver.h"
|
|
|
|
#include "storage_conf.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2008-02-20 15:34:52 +00:00
|
|
|
#include "storage_backend.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2011-07-19 18:32:58 +00:00
|
|
|
#include "virfile.h"
|
2009-07-14 15:24:42 +00:00
|
|
|
#include "fdstream.h"
|
2010-11-16 14:54:17 +00:00
|
|
|
#include "configmake.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2009-01-20 17:13:33 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_STORAGE
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
static virStorageDriverStatePtr driverState;
|
|
|
|
|
2013-04-23 12:50:18 +00:00
|
|
|
static int storageStateCleanup(void);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
static void storageDriverLock(virStorageDriverStatePtr driver)
|
|
|
|
{
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexLock(&driver->lock);
|
2008-12-04 21:40:42 +00:00
|
|
|
}
|
|
|
|
static void storageDriverUnlock(virStorageDriverStatePtr driver)
|
|
|
|
{
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexUnlock(&driver->lock);
|
2008-12-04 21:40:42 +00:00
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
storageDriverAutostart(virStorageDriverStatePtr driver) {
|
2008-10-10 15:13:28 +00:00
|
|
|
unsigned int i;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-10-10 15:13:28 +00:00
|
|
|
for (i = 0 ; i < driver->pools.count ; i++) {
|
|
|
|
virStoragePoolObjPtr pool = driver->pools.objs[i];
|
2010-11-11 20:09:20 +00:00
|
|
|
virStorageBackendPtr backend;
|
|
|
|
bool started = false;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjLock(pool);
|
2010-11-11 20:09:20 +00:00
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL) {
|
|
|
|
VIR_ERROR(_("Missing backend %d"), pool->def->type);
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
continue;
|
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-11-11 20:09:20 +00:00
|
|
|
if (backend->checkPool &&
|
|
|
|
backend->checkPool(NULL, pool, &started) < 0) {
|
|
|
|
virErrorPtr err = virGetLastError();
|
|
|
|
VIR_ERROR(_("Failed to initialize storage pool '%s': %s"),
|
|
|
|
pool->def->name, err ? err->message :
|
|
|
|
_("no error message found"));
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!started &&
|
|
|
|
pool->autostart &&
|
|
|
|
!virStoragePoolObjIsActive(pool)) {
|
2008-02-20 15:34:52 +00:00
|
|
|
if (backend->startPool &&
|
|
|
|
backend->startPool(NULL, pool) < 0) {
|
|
|
|
virErrorPtr err = virGetLastError();
|
2010-05-20 06:15:46 +00:00
|
|
|
VIR_ERROR(_("Failed to autostart storage pool '%s': %s"),
|
2010-01-31 17:12:05 +00:00
|
|
|
pool->def->name, err ? err->message :
|
2010-11-11 20:09:20 +00:00
|
|
|
_("no error message found"));
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-02-20 15:34:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-11-11 20:09:20 +00:00
|
|
|
started = true;
|
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-11-11 20:09:20 +00:00
|
|
|
if (started) {
|
2008-02-20 15:34:52 +00:00
|
|
|
if (backend->refreshPool(NULL, pool) < 0) {
|
|
|
|
virErrorPtr err = virGetLastError();
|
|
|
|
if (backend->stopPool)
|
|
|
|
backend->stopPool(NULL, pool);
|
2010-05-20 06:15:46 +00:00
|
|
|
VIR_ERROR(_("Failed to autostart storage pool '%s': %s"),
|
2010-01-31 17:12:05 +00:00
|
|
|
pool->def->name, err ? err->message :
|
2010-11-11 20:09:20 +00:00
|
|
|
_("no error message found"));
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-02-20 15:34:52 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pool->active = 1;
|
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* virStorageStartup:
|
|
|
|
*
|
|
|
|
* Initialization function for the QEmu daemon
|
|
|
|
*/
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageStateInitialize(bool privileged,
|
|
|
|
virStateInhibitCallback callback ATTRIBUTE_UNUSED,
|
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
2011-01-15 16:38:57 +00:00
|
|
|
{
|
2008-02-20 15:34:52 +00:00
|
|
|
char *base = NULL;
|
|
|
|
|
2008-06-06 11:09:57 +00:00
|
|
|
if (VIR_ALLOC(driverState) < 0)
|
2008-02-20 15:34:52 +00:00
|
|
|
return -1;
|
|
|
|
|
2009-01-15 19:56:05 +00:00
|
|
|
if (virMutexInit(&driverState->lock) < 0) {
|
|
|
|
VIR_FREE(driverState);
|
|
|
|
return -1;
|
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driverState);
|
|
|
|
|
2009-06-12 13:20:13 +00:00
|
|
|
if (privileged) {
|
2013-05-03 12:49:08 +00:00
|
|
|
if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
|
|
|
|
goto error;
|
2008-02-20 15:34:52 +00:00
|
|
|
} else {
|
2012-05-24 12:29:42 +00:00
|
|
|
base = virGetUserConfigDirectory();
|
2012-05-03 16:36:27 +00:00
|
|
|
if (!base)
|
2009-01-22 19:41:48 +00:00
|
|
|
goto error;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2012-05-03 16:36:27 +00:00
|
|
|
/* Configuration paths are either $USER_CONFIG_HOME/libvirt/storage/... (session) or
|
2008-02-20 15:34:52 +00:00
|
|
|
* /etc/libvirt/storage/... (system).
|
|
|
|
*/
|
2008-12-23 13:03:29 +00:00
|
|
|
if (virAsprintf(&driverState->configDir,
|
|
|
|
"%s/storage", base) == -1)
|
2008-02-20 15:34:52 +00:00
|
|
|
goto out_of_memory;
|
|
|
|
|
2008-12-23 13:03:29 +00:00
|
|
|
if (virAsprintf(&driverState->autostartDir,
|
|
|
|
"%s/storage/autostart", base) == -1)
|
2008-02-20 15:34:52 +00:00
|
|
|
goto out_of_memory;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
VIR_FREE(base);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
if (virStoragePoolLoadAllConfigs(&driverState->pools,
|
2008-10-10 15:13:28 +00:00
|
|
|
driverState->configDir,
|
2008-12-04 21:40:42 +00:00
|
|
|
driverState->autostartDir) < 0)
|
|
|
|
goto error;
|
2008-02-20 15:34:52 +00:00
|
|
|
storageDriverAutostart(driverState);
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driverState);
|
2008-02-20 15:34:52 +00:00
|
|
|
return 0;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
out_of_memory:
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2008-12-04 21:40:42 +00:00
|
|
|
error:
|
|
|
|
VIR_FREE(base);
|
|
|
|
storageDriverUnlock(driverState);
|
2013-04-23 12:50:18 +00:00
|
|
|
storageStateCleanup();
|
2008-02-20 15:34:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-04-23 12:50:18 +00:00
|
|
|
* storageStateReload:
|
2008-02-20 15:34:52 +00:00
|
|
|
*
|
|
|
|
* Function to restart the storage driver, it will recheck the configuration
|
|
|
|
* files and update its state
|
|
|
|
*/
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageStateReload(void) {
|
2008-10-10 15:13:28 +00:00
|
|
|
if (!driverState)
|
|
|
|
return -1;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driverState);
|
2010-02-10 11:42:56 +00:00
|
|
|
virStoragePoolLoadAllConfigs(&driverState->pools,
|
2008-10-10 15:13:28 +00:00
|
|
|
driverState->configDir,
|
|
|
|
driverState->autostartDir);
|
2008-02-20 15:34:52 +00:00
|
|
|
storageDriverAutostart(driverState);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driverState);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2013-04-23 12:50:18 +00:00
|
|
|
* storageStateCleanup
|
2008-02-20 15:34:52 +00:00
|
|
|
*
|
|
|
|
* Shutdown the storage driver, it will stop all active storage pools
|
|
|
|
*/
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageStateCleanup(void) {
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!driverState)
|
|
|
|
return -1;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driverState);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
/* free inactive pools */
|
2008-10-10 15:13:28 +00:00
|
|
|
virStoragePoolObjListFree(&driverState->pools);
|
|
|
|
|
|
|
|
VIR_FREE(driverState->configDir);
|
|
|
|
VIR_FREE(driverState->autostartDir);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driverState);
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutexDestroy(&driverState->lock);
|
2008-10-10 15:13:28 +00:00
|
|
|
VIR_FREE(driverState);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
storagePoolLookupByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2012-11-10 07:18:07 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
|
|
|
|
NULL, NULL);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-02-20 15:34:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
storagePoolLookupByName(virConnectPtr conn,
|
|
|
|
const char *name) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, name);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"), name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2012-11-10 07:18:07 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
|
|
|
|
NULL, NULL);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-02-20 15:34:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
|
|
|
storagePoolLookupByVolume(virStorageVolPtr vol) {
|
|
|
|
return storagePoolLookupByName(vol->conn, vol->pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
static virDrvOpenStatus
|
|
|
|
storageOpen(virConnectPtr conn,
|
|
|
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
2011-07-06 22:51:23 +00:00
|
|
|
unsigned int flags)
|
|
|
|
{
|
|
|
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!driverState)
|
|
|
|
return VIR_DRV_OPEN_DECLINED;
|
|
|
|
|
|
|
|
conn->storagePrivateData = driverState;
|
|
|
|
return VIR_DRV_OPEN_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storageClose(virConnectPtr conn) {
|
|
|
|
conn->storagePrivateData = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageConnectNumOfStoragePools(virConnectPtr conn) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-10-10 15:13:28 +00:00
|
|
|
unsigned int i, nactive = 0;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
for (i = 0 ; i < driver->pools.count ; i++) {
|
|
|
|
virStoragePoolObjLock(driver->pools.objs[i]);
|
2008-10-10 15:13:28 +00:00
|
|
|
if (virStoragePoolObjIsActive(driver->pools.objs[i]))
|
|
|
|
nactive++;
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
|
|
|
}
|
|
|
|
storageDriverUnlock(driver);
|
2008-10-10 15:13:28 +00:00
|
|
|
|
|
|
|
return nactive;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageConnectListStoragePools(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int nnames) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-02-20 15:34:52 +00:00
|
|
|
int got = 0, i;
|
2008-10-10 15:13:28 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-10-10 15:13:28 +00:00
|
|
|
for (i = 0 ; i < driver->pools.count && got < nnames ; i++) {
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjLock(driver->pools.objs[i]);
|
2008-10-10 15:13:28 +00:00
|
|
|
if (virStoragePoolObjIsActive(driver->pools.objs[i])) {
|
2013-05-03 12:49:08 +00:00
|
|
|
if (VIR_STRDUP(names[got], driver->pools.objs[i]->def->name) < 0) {
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
got++;
|
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
return got;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
for (i = 0 ; i < got ; i++)
|
|
|
|
VIR_FREE(names[i]);
|
2008-12-02 15:59:14 +00:00
|
|
|
memset(names, 0, nnames * sizeof(*names));
|
2008-02-20 15:34:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageConnectNumOfDefinedStoragePools(virConnectPtr conn) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-10-10 15:13:28 +00:00
|
|
|
unsigned int i, nactive = 0;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
for (i = 0 ; i < driver->pools.count ; i++) {
|
|
|
|
virStoragePoolObjLock(driver->pools.objs[i]);
|
2008-10-10 15:13:28 +00:00
|
|
|
if (!virStoragePoolObjIsActive(driver->pools.objs[i]))
|
|
|
|
nactive++;
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
|
|
|
}
|
|
|
|
storageDriverUnlock(driver);
|
2008-10-10 15:13:28 +00:00
|
|
|
|
|
|
|
return nactive;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageConnectListDefinedStoragePools(virConnectPtr conn,
|
|
|
|
char **const names,
|
|
|
|
int nnames) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-02-20 15:34:52 +00:00
|
|
|
int got = 0, i;
|
2008-10-10 15:13:28 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-10-10 15:13:28 +00:00
|
|
|
for (i = 0 ; i < driver->pools.count && got < nnames ; i++) {
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjLock(driver->pools.objs[i]);
|
2008-10-10 15:13:28 +00:00
|
|
|
if (!virStoragePoolObjIsActive(driver->pools.objs[i])) {
|
2013-05-03 12:49:08 +00:00
|
|
|
if (VIR_STRDUP(names[got], driver->pools.objs[i]->def->name) < 0) {
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
got++;
|
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
return got;
|
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
for (i = 0 ; i < got ; i++) {
|
2009-12-09 23:00:50 +00:00
|
|
|
VIR_FREE(names[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-02 15:59:14 +00:00
|
|
|
memset(names, 0, nnames * sizeof(*names));
|
2008-02-20 15:34:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
/* This method is required to be re-entrant / thread safe, so
|
|
|
|
uses no driver lock */
|
2008-08-27 20:05:58 +00:00
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
storageConnectFindStoragePoolSources(virConnectPtr conn,
|
|
|
|
const char *type,
|
|
|
|
const char *srcSpec,
|
|
|
|
unsigned int flags)
|
2008-08-27 20:05:58 +00:00
|
|
|
{
|
|
|
|
int backend_type;
|
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
char *ret = NULL;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2008-11-17 11:19:33 +00:00
|
|
|
backend_type = virStoragePoolTypeFromString(type);
|
2009-10-08 14:24:37 +00:00
|
|
|
if (backend_type < 0) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unknown storage pool type %s"), type);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2009-10-08 14:24:37 +00:00
|
|
|
}
|
2008-08-27 20:05:58 +00:00
|
|
|
|
|
|
|
backend = virStorageBackendForType(backend_type);
|
|
|
|
if (backend == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2009-10-08 14:24:37 +00:00
|
|
|
if (!backend->findPoolSources) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
|
_("pool type '%s' does not support source "
|
|
|
|
"discovery"), type);
|
2009-10-08 14:24:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = backend->findPoolSources(conn, srcSpec, flags);
|
2008-08-27 20:05:58 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
|
|
|
return ret;
|
2008-08-27 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-09 09:38:11 +00:00
|
|
|
static int storagePoolIsActive(virStoragePoolPtr pool)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
{
|
2009-12-09 09:38:11 +00:00
|
|
|
virStorageDriverStatePtr driver = pool->conn->storagePrivateData;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
virStoragePoolObjPtr obj;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
2009-12-09 09:38:11 +00:00
|
|
|
obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
if (!obj) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
ret = virStoragePoolObjIsActive(obj);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (obj)
|
|
|
|
virStoragePoolObjUnlock(obj);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-12-09 09:38:11 +00:00
|
|
|
static int storagePoolIsPersistent(virStoragePoolPtr pool)
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
{
|
2009-12-09 09:38:11 +00:00
|
|
|
virStorageDriverStatePtr driver = pool->conn->storagePrivateData;
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
virStoragePoolObjPtr obj;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
2009-12-09 09:38:11 +00:00
|
|
|
obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
if (!obj) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL, NULL);
|
Implmentation of new APIs to checking state/persistence of objects
This implements the virConnectIsSecure, virConnectIsEncrypted,
virDomainIsPersistent, virDomainIsActive, virNetworkIsActive,
virNetworkIsPersistent, virStoragePoolIsActive,
virStoragePoolIsPersistent, virInterfaceIsActive APIs in
(nearly) all drivers. Exceptions are:
phyp: missing domainIsActive/Persistent
esx: missing domainIsPersistent
opennebula: missing domainIsActive/Persistent
* src/remote/remote_protocol.x: Define remote wire ABI for newly
added APIs.
* daemon/remote_dispatch*.h: Re-generated from remote_protocol.x
* src/esx/esx_driver.c, src/lxc/lxc_driver.c, src/network/bridge_driver.c,
src/opennebula/one_driver.c, src/openvz/openvz_conf.c,
src/openvz/openvz_driver.c, src/phyp/phyp_driver.c,
src/remote/remote_driver.c, src/storage/storage_driver.c,
src/test/test_driver.c, src/uml/uml_driver.c, src/vbox/vbox_tmpl.c,
src/xen/xen_driver.c, src/xen/xen_driver.h, src/xen/xen_inotify.c,
src/xen/xen_inotify.h: Implement all the new APIs where possible
2009-10-20 14:12:03 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
ret = obj->configFile ? 1 : 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (obj)
|
|
|
|
virStoragePoolObjUnlock(obj);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
static virStoragePoolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storagePoolCreateXML(virConnectPtr conn,
|
|
|
|
const char *xml,
|
|
|
|
unsigned int flags)
|
2011-07-06 22:51:23 +00:00
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStoragePoolDefPtr def;
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjPtr pool = NULL;
|
2008-12-04 21:39:45 +00:00
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
|
|
|
|
2011-07-06 22:51:23 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2010-02-10 11:42:56 +00:00
|
|
|
if (!(def = virStoragePoolDefParseString(xml)))
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-05-27 11:41:30 +00:00
|
|
|
if (virStoragePoolObjIsDuplicate(&driver->pools, def, 1) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2011-09-05 07:52:03 +00:00
|
|
|
if (virStoragePoolSourceFindDuplicate(&driver->pools, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if ((backend = virStorageBackendForType(def->type)) == NULL)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
if (!(pool = virStoragePoolObjAssignDef(&driver->pools, def)))
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
def = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-03-17 15:10:48 +00:00
|
|
|
if (backend->startPool &&
|
2009-09-02 13:02:06 +00:00
|
|
|
backend->startPool(conn, pool) < 0) {
|
|
|
|
virStoragePoolObjRemove(&driver->pools, pool);
|
|
|
|
pool = NULL;
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2009-09-02 13:02:06 +00:00
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
|
2008-03-17 15:10:48 +00:00
|
|
|
if (backend->refreshPool(conn, pool) < 0) {
|
|
|
|
if (backend->stopPool)
|
|
|
|
backend->stopPool(conn, pool);
|
2009-09-02 13:02:06 +00:00
|
|
|
virStoragePoolObjRemove(&driver->pools, pool);
|
|
|
|
pool = NULL;
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Creating storage pool '%s'", pool->def->name);
|
2008-02-20 15:34:52 +00:00
|
|
|
pool->active = 1;
|
|
|
|
|
2012-11-10 07:18:07 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
|
|
|
|
NULL, NULL);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
|
|
|
virStoragePoolDefFree(def);
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
2009-09-02 13:02:06 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storagePoolDefineXML(virConnectPtr conn,
|
|
|
|
const char *xml,
|
|
|
|
unsigned int flags)
|
2011-07-06 22:51:23 +00:00
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStoragePoolDefPtr def;
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjPtr pool = NULL;
|
2008-12-04 21:39:45 +00:00
|
|
|
virStoragePoolPtr ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2011-07-06 22:51:23 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2010-02-10 11:42:56 +00:00
|
|
|
if (!(def = virStoragePoolDefParseString(xml)))
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-05-27 11:41:30 +00:00
|
|
|
if (virStoragePoolObjIsDuplicate(&driver->pools, def, 0) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2011-09-05 07:52:03 +00:00
|
|
|
if (virStoragePoolSourceFindDuplicate(&driver->pools, def) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2009-09-04 15:18:29 +00:00
|
|
|
if (virStorageBackendForType(def->type) == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
if (!(pool = virStoragePoolObjAssignDef(&driver->pools, def)))
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
if (virStoragePoolObjSaveDef(driver, pool, def) < 0) {
|
2008-10-10 15:13:28 +00:00
|
|
|
virStoragePoolObjRemove(&driver->pools, pool);
|
2008-12-22 16:30:57 +00:00
|
|
|
def = NULL;
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-22 16:30:57 +00:00
|
|
|
def = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Defining storage pool '%s'", pool->def->name);
|
2012-11-10 07:18:07 +00:00
|
|
|
ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
|
|
|
|
NULL, NULL);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
|
|
|
virStoragePoolDefFree(def);
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolUndefine(virStoragePoolPtr obj) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is still active"),
|
|
|
|
pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (pool->asyncjobs > 0) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("pool '%s' has asynchronous jobs running."),
|
|
|
|
pool->def->name);
|
2009-04-17 19:12:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
if (virStoragePoolObjDeleteDef(pool) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2009-02-05 16:28:30 +00:00
|
|
|
if (unlink(pool->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
|
|
|
|
char ebuf[1024];
|
2010-05-20 06:15:46 +00:00
|
|
|
VIR_ERROR(_("Failed to delete autostart link '%s': %s"),
|
2012-03-29 09:52:04 +00:00
|
|
|
pool->autostartLink, virStrerror(errno, ebuf, sizeof(ebuf)));
|
2009-02-05 16:28:30 +00:00
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-10-10 15:13:28 +00:00
|
|
|
VIR_FREE(pool->configFile);
|
|
|
|
VIR_FREE(pool->autostartLink);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Undefining storage pool '%s'", pool->def->name);
|
2008-10-10 15:13:28 +00:00
|
|
|
virStoragePoolObjRemove(&driver->pools, pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
pool = NULL;
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
storageDriverUnlock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storagePoolCreate(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags)
|
2011-07-06 22:51:23 +00:00
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2011-07-06 22:51:23 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
if (virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is already active"),
|
|
|
|
pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
if (backend->startPool &&
|
|
|
|
backend->startPool(obj->conn, pool) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (backend->refreshPool(obj->conn, pool) < 0) {
|
|
|
|
if (backend->stopPool)
|
|
|
|
backend->stopPool(obj->conn, pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Starting up storage pool '%s'", pool->def->name);
|
2008-02-20 15:34:52 +00:00
|
|
|
pool->active = 1;
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolBuild(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
if (virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is already active"),
|
|
|
|
pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (backend->buildPool &&
|
|
|
|
backend->buildPool(obj->conn, pool, flags) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolDestroy(virStoragePoolPtr obj) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (pool->asyncjobs > 0) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("pool '%s' has asynchronous jobs running."),
|
|
|
|
pool->def->name);
|
2009-04-17 19:12:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (backend->stopPool &&
|
|
|
|
backend->stopPool(obj->conn, pool) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
virStoragePoolObjClearVols(pool);
|
|
|
|
|
|
|
|
pool->active = 0;
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Shutting down storage pool '%s'", pool->def->name);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool->configFile == NULL) {
|
2008-10-10 15:13:28 +00:00
|
|
|
virStoragePoolObjRemove(&driver->pools, pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
pool = NULL;
|
2012-06-25 09:38:17 +00:00
|
|
|
} else if (pool->newDef) {
|
|
|
|
virStoragePoolDefFree(pool->def);
|
|
|
|
pool->def = pool->newDef;
|
|
|
|
pool->newDef = NULL;
|
2008-12-04 21:40:42 +00:00
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
storageDriverUnlock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolDelete(virStoragePoolPtr obj,
|
|
|
|
unsigned int flags) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
if (virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is still active"),
|
|
|
|
pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (pool->asyncjobs > 0) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("pool '%s' has asynchronous jobs running."),
|
2009-04-17 19:12:37 +00:00
|
|
|
pool->def->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!backend->deletePool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
|
"%s", _("pool does not support pool deletion"));
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
if (backend->deletePool(obj->conn, pool, flags) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Deleting storage pool '%s'", pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolRefresh(virStoragePoolPtr obj,
|
2011-07-06 22:51:23 +00:00
|
|
|
unsigned int flags)
|
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2011-07-06 22:51:23 +00:00
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (pool->asyncjobs > 0) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("pool '%s' has asynchronous jobs running."),
|
|
|
|
pool->def->name);
|
2009-04-17 19:12:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
virStoragePoolObjClearVols(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
if (backend->refreshPool(obj->conn, pool) < 0) {
|
2008-02-20 15:34:52 +00:00
|
|
|
if (backend->stopPool)
|
|
|
|
backend->stopPool(obj->conn, pool);
|
|
|
|
|
|
|
|
pool->active = 0;
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool->configFile == NULL) {
|
2008-10-10 15:13:28 +00:00
|
|
|
virStoragePoolObjRemove(&driver->pools, pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
pool = NULL;
|
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2009-05-19 11:06:25 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolGetInfo(virStoragePoolPtr obj,
|
|
|
|
virStoragePoolInfoPtr info) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-09-04 15:18:29 +00:00
|
|
|
if (virStorageBackendForType(pool->def->type) == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
memset(info, 0, sizeof(virStoragePoolInfo));
|
|
|
|
if (pool->active)
|
|
|
|
info->state = VIR_STORAGE_POOL_RUNNING;
|
|
|
|
else
|
|
|
|
info->state = VIR_STORAGE_POOL_INACTIVE;
|
|
|
|
info->capacity = pool->def->capacity;
|
|
|
|
info->allocation = pool->def->allocation;
|
|
|
|
info->available = pool->def->available;
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2011-05-06 19:53:10 +00:00
|
|
|
storagePoolGetXMLDesc(virStoragePoolPtr obj,
|
2011-07-06 22:51:23 +00:00
|
|
|
unsigned int flags)
|
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2012-06-25 10:24:45 +00:00
|
|
|
virStoragePoolDefPtr def;
|
2008-12-04 21:39:45 +00:00
|
|
|
char *ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2012-06-25 10:24:45 +00:00
|
|
|
virCheckFlags(VIR_STORAGE_XML_INACTIVE, NULL);
|
2011-07-06 22:51:23 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2012-06-25 10:24:45 +00:00
|
|
|
if ((flags & VIR_STORAGE_XML_INACTIVE) && pool->newDef)
|
|
|
|
def = pool->newDef;
|
|
|
|
else
|
|
|
|
def = pool->def;
|
|
|
|
|
|
|
|
ret = virStoragePoolDefFormat(def);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolGetAutostart(virStoragePoolPtr obj,
|
|
|
|
int *autostart) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pool->configFile) {
|
|
|
|
*autostart = 0;
|
|
|
|
} else {
|
|
|
|
*autostart = pool->autostart;
|
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-11 15:00:12 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolSetAutostart(virStoragePoolPtr obj,
|
|
|
|
int autostart) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!pool->configFile) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
"%s", _("pool has no config file"));
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
autostart = (autostart != 0);
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if (pool->autostart != autostart) {
|
|
|
|
if (autostart) {
|
2011-07-05 21:02:53 +00:00
|
|
|
if (virFileMakePath(driver->autostartDir) < 0) {
|
|
|
|
virReportSystemError(errno,
|
2009-01-20 17:13:33 +00:00
|
|
|
_("cannot create autostart directory %s"),
|
|
|
|
driver->autostartDir);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if (symlink(pool->configFile, pool->autostartLink) < 0) {
|
2010-02-04 20:02:58 +00:00
|
|
|
virReportSystemError(errno,
|
2009-01-20 17:13:33 +00:00
|
|
|
_("Failed to create symlink '%s' to '%s'"),
|
|
|
|
pool->autostartLink, pool->configFile);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (unlink(pool->autostartLink) < 0 &&
|
|
|
|
errno != ENOENT && errno != ENOTDIR) {
|
2010-02-04 20:02:58 +00:00
|
|
|
virReportSystemError(errno,
|
2009-01-20 17:13:33 +00:00
|
|
|
_("Failed to delete symlink '%s'"),
|
|
|
|
pool->autostartLink);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
pool->autostart = autostart;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2009-05-19 11:06:25 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storagePoolNumOfVolumes(virStoragePoolPtr obj) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = pool->volumes.count;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
storagePoolListVolumes(virStoragePoolPtr obj,
|
|
|
|
char **const names,
|
|
|
|
int maxnames) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-10-10 15:13:28 +00:00
|
|
|
int i, n = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
memset(names, 0, maxnames * sizeof(*names));
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 15:13:28 +00:00
|
|
|
for (i = 0 ; i < pool->volumes.count && n < maxnames ; i++) {
|
2013-05-03 12:49:08 +00:00
|
|
|
if (VIR_STRDUP(names[n++], pool->volumes.objs[i]->name) < 0)
|
2008-02-20 15:34:52 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-10-10 15:13:28 +00:00
|
|
|
return n;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-10-10 15:13:28 +00:00
|
|
|
for (n = 0 ; n < maxnames ; n++)
|
2008-12-04 21:39:45 +00:00
|
|
|
VIR_FREE(names[n]);
|
2008-10-10 15:13:28 +00:00
|
|
|
|
2008-12-02 15:59:14 +00:00
|
|
|
memset(names, 0, maxnames * sizeof(*names));
|
2008-02-20 15:34:52 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:32:55 +00:00
|
|
|
static int
|
|
|
|
storagePoolListAllVolumes(virStoragePoolPtr pool,
|
|
|
|
virStorageVolPtr **vols,
|
|
|
|
unsigned int flags) {
|
|
|
|
virStorageDriverStatePtr driver = pool->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr obj;
|
|
|
|
int i;
|
|
|
|
virStorageVolPtr *tmp_vols = NULL;
|
|
|
|
virStorageVolPtr vol = NULL;
|
|
|
|
int nvols = 0;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
|
|
|
obj = virStoragePoolObjFindByUUID(&driver->pools, pool->uuid);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
if (!obj) {
|
2012-10-08 22:37:22 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
|
|
|
_("no storage pool with matching uuid %s"),
|
|
|
|
pool->uuid);
|
2012-09-04 15:32:55 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(obj)) {
|
2012-10-08 22:37:22 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("storage pool '%s' is not active"), obj->def->name);
|
2012-09-04 15:32:55 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Just returns the volumes count */
|
|
|
|
if (!vols) {
|
|
|
|
ret = obj->volumes.count;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(tmp_vols, obj->volumes.count + 1) < 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0 ; i < obj->volumes.count; i++) {
|
|
|
|
if (!(vol = virGetStorageVol(pool->conn, obj->def->name,
|
|
|
|
obj->volumes.objs[i]->name,
|
2012-11-10 07:18:07 +00:00
|
|
|
obj->volumes.objs[i]->key,
|
|
|
|
NULL, NULL)))
|
2012-09-04 15:32:55 +00:00
|
|
|
goto cleanup;
|
|
|
|
tmp_vols[nvols++] = vol;
|
|
|
|
}
|
|
|
|
|
|
|
|
*vols = tmp_vols;
|
|
|
|
tmp_vols = NULL;
|
|
|
|
ret = nvols;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if (tmp_vols) {
|
|
|
|
for (i = 0; i < nvols; i++) {
|
|
|
|
if (tmp_vols[i])
|
|
|
|
virStorageVolFree(tmp_vols[i]);
|
|
|
|
}
|
2013-01-09 14:54:15 +00:00
|
|
|
VIR_FREE(tmp_vols);
|
2012-09-04 15:32:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (obj)
|
|
|
|
virStoragePoolObjUnlock(obj);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolLookupByName(virStoragePoolPtr obj,
|
|
|
|
const char *name) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageVolDefPtr vol;
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageVolPtr ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, name);
|
|
|
|
|
|
|
|
if (!vol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2012-11-10 07:18:07 +00:00
|
|
|
ret = virGetStorageVol(obj->conn, pool->def->name, vol->name, vol->key,
|
|
|
|
NULL, NULL);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolLookupByKey(virConnectPtr conn,
|
|
|
|
const char *key) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-10-10 15:13:28 +00:00
|
|
|
unsigned int i;
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageVolPtr ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
for (i = 0 ; i < driver->pools.count && !ret ; i++) {
|
|
|
|
virStoragePoolObjLock(driver->pools.objs[i]);
|
2008-10-10 15:13:28 +00:00
|
|
|
if (virStoragePoolObjIsActive(driver->pools.objs[i])) {
|
|
|
|
virStorageVolDefPtr vol =
|
|
|
|
virStorageVolDefFindByKey(driver->pools.objs[i], key);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
if (vol)
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = virGetStorageVol(conn,
|
2008-12-04 21:40:42 +00:00
|
|
|
driver->pools.objs[i]->def->name,
|
|
|
|
vol->name,
|
2012-11-10 07:18:07 +00:00
|
|
|
vol->key,
|
|
|
|
NULL, NULL);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if (!ret)
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage vol with matching key %s"), key);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolLookupByPath(virConnectPtr conn,
|
|
|
|
const char *path) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
2008-10-10 15:13:28 +00:00
|
|
|
unsigned int i;
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageVolPtr ret = NULL;
|
2010-05-20 15:41:31 +00:00
|
|
|
char *cleanpath;
|
|
|
|
|
|
|
|
cleanpath = virFileSanitizePath(path);
|
|
|
|
if (!cleanpath)
|
|
|
|
return NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
for (i = 0 ; i < driver->pools.count && !ret ; i++) {
|
|
|
|
virStoragePoolObjLock(driver->pools.objs[i]);
|
2008-10-10 15:13:28 +00:00
|
|
|
if (virStoragePoolObjIsActive(driver->pools.objs[i])) {
|
2008-11-03 11:37:11 +00:00
|
|
|
virStorageVolDefPtr vol;
|
2008-11-17 11:19:33 +00:00
|
|
|
const char *stable_path;
|
|
|
|
|
2010-02-04 20:02:58 +00:00
|
|
|
stable_path = virStorageBackendStablePath(driver->pools.objs[i],
|
2012-10-21 16:53:20 +00:00
|
|
|
cleanpath,
|
|
|
|
false);
|
2008-12-04 21:40:42 +00:00
|
|
|
if (stable_path == NULL) {
|
2011-09-26 06:30:44 +00:00
|
|
|
/* Don't break the whole lookup process if it fails on
|
|
|
|
* getting the stable path for some of the pools.
|
|
|
|
*/
|
|
|
|
VIR_WARN("Failed to get stable path for pool '%s'",
|
|
|
|
driver->pools.objs[i]->def->name);
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2011-09-26 06:30:44 +00:00
|
|
|
continue;
|
2008-12-04 21:40:42 +00:00
|
|
|
}
|
2008-11-17 11:19:33 +00:00
|
|
|
|
|
|
|
vol = virStorageVolDefFindByPath(driver->pools.objs[i],
|
|
|
|
stable_path);
|
|
|
|
VIR_FREE(stable_path);
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
if (vol)
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = virGetStorageVol(conn,
|
|
|
|
driver->pools.objs[i]->def->name,
|
|
|
|
vol->name,
|
2012-11-10 07:18:07 +00:00
|
|
|
vol->key,
|
|
|
|
NULL, NULL);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjUnlock(driver->pools.objs[i]);
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if (!ret)
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage vol with matching path %s"), path);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
2010-05-20 15:41:31 +00:00
|
|
|
VIR_FREE(cleanpath);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2013-04-23 12:50:18 +00:00
|
|
|
static int storageVolDelete(virStorageVolPtr obj, unsigned int flags);
|
2009-04-17 19:12:37 +00:00
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
static virStorageVolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolCreateXML(virStoragePoolPtr obj,
|
|
|
|
const char *xmldesc,
|
|
|
|
unsigned int flags)
|
2011-07-06 22:51:23 +00:00
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2009-04-17 19:12:37 +00:00
|
|
|
virStorageVolDefPtr voldef = NULL;
|
|
|
|
virStorageVolPtr ret = NULL, volobj = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2012-12-05 10:48:07 +00:00
|
|
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
|
2011-07-06 22:51:23 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
voldef = virStorageVolDefParseString(pool->def, xmldesc);
|
2009-04-17 19:12:37 +00:00
|
|
|
if (voldef == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (virStorageVolDefFindByName(pool, voldef->name)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage vol '%s' already exists"), voldef->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-10-10 15:13:28 +00:00
|
|
|
if (VIR_REALLOC_N(pool->volumes.objs,
|
|
|
|
pool->volumes.count+1) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-10-10 15:13:28 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!backend->createVol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
|
"%s", _("storage pool does not support volume "
|
|
|
|
"creation"));
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (backend->createVol(obj->conn, pool, voldef) < 0) {
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
pool->volumes.objs[pool->volumes.count++] = voldef;
|
|
|
|
volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name,
|
2012-11-10 07:18:07 +00:00
|
|
|
voldef->key, NULL, NULL);
|
2011-05-03 17:44:04 +00:00
|
|
|
if (!volobj) {
|
|
|
|
pool->volumes.count--;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
|
2011-05-03 17:44:04 +00:00
|
|
|
if (backend->buildVol) {
|
2009-04-17 19:12:37 +00:00
|
|
|
int buildret;
|
|
|
|
virStorageVolDefPtr buildvoldef = NULL;
|
|
|
|
|
|
|
|
if (VIR_ALLOC(buildvoldef) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2009-04-17 19:12:37 +00:00
|
|
|
voldef = NULL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make a shallow copy of the 'defined' volume definition, since the
|
|
|
|
* original allocation value will change as the user polls 'info',
|
|
|
|
* but we only need the initial requested values
|
|
|
|
*/
|
|
|
|
memcpy(buildvoldef, voldef, sizeof(*voldef));
|
|
|
|
|
|
|
|
/* Drop the pool lock during volume allocation */
|
|
|
|
pool->asyncjobs++;
|
|
|
|
voldef->building = 1;
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
|
2012-12-05 10:48:07 +00:00
|
|
|
buildret = backend->buildVol(obj->conn, pool, buildvoldef, flags);
|
2009-04-17 19:12:37 +00:00
|
|
|
|
2009-05-19 11:06:25 +00:00
|
|
|
storageDriverLock(driver);
|
2009-04-17 19:12:37 +00:00
|
|
|
virStoragePoolObjLock(pool);
|
2009-05-19 11:06:25 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
voldef->building = 0;
|
|
|
|
pool->asyncjobs--;
|
|
|
|
|
|
|
|
voldef = NULL;
|
|
|
|
VIR_FREE(buildvoldef);
|
|
|
|
|
|
|
|
if (buildret < 0) {
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolDelete(volobj, 0);
|
2009-04-17 19:12:37 +00:00
|
|
|
pool = NULL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Creating volume '%s' in storage pool '%s'",
|
2011-03-30 01:19:47 +00:00
|
|
|
volobj->name, pool->def->name);
|
2009-04-17 19:12:37 +00:00
|
|
|
ret = volobj;
|
|
|
|
volobj = NULL;
|
|
|
|
voldef = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
Convert public datatypes to inherit from virObject
This converts the following public API datatypes to use the
virObject infrastructure:
virConnectPtr
virDomainPtr
virDomainSnapshotPtr
virInterfacePtr
virNetworkPtr
virNodeDevicePtr
virNWFilterPtr
virSecretPtr
virStreamPtr
virStorageVolPtr
virStoragePoolPtr
The code is significantly simplified, since the mutex in the
virConnectPtr object now only needs to be held when accessing
the per-connection virError object instance. All other operations
are completely lock free.
* src/datatypes.c, src/datatypes.h, src/libvirt.c: Convert
public datatypes to use virObject
* src/conf/domain_event.c, src/phyp/phyp_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_migration.c,
src/qemu/qemu_process.c, src/storage/storage_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xend_internal.c,
tests/qemuxml2argvtest.c, tests/qemuxmlnstest.c,
tests/sexpr2xmltest.c, tests/xmconfigtest.c: Convert
to use virObjectUnref/virObjectRef
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-31 16:55:36 +00:00
|
|
|
virObjectUnref(volobj);
|
2009-04-17 19:12:37 +00:00
|
|
|
virStorageVolDefFree(voldef);
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-05-19 13:37:51 +00:00
|
|
|
static virStorageVolPtr
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolCreateXMLFrom(virStoragePoolPtr obj,
|
|
|
|
const char *xmldesc,
|
|
|
|
virStorageVolPtr vobj,
|
|
|
|
unsigned int flags)
|
2011-07-06 22:51:23 +00:00
|
|
|
{
|
2009-05-19 13:37:51 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool, origpool = NULL;
|
|
|
|
virStorageBackendPtr backend;
|
|
|
|
virStorageVolDefPtr origvol = NULL, newvol = NULL;
|
|
|
|
virStorageVolPtr ret = NULL, volobj = NULL;
|
2009-09-02 13:02:06 +00:00
|
|
|
int buildret;
|
2009-05-19 13:37:51 +00:00
|
|
|
|
2012-12-05 10:48:07 +00:00
|
|
|
virCheckFlags(VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA, NULL);
|
2011-07-06 22:51:23 +00:00
|
|
|
|
2009-05-19 13:37:51 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
pool = virStoragePoolObjFindByUUID(&driver->pools, obj->uuid);
|
2009-09-02 13:02:06 +00:00
|
|
|
if (pool && STRNEQ(obj->name, vobj->pool)) {
|
2009-07-10 16:56:12 +00:00
|
|
|
virStoragePoolObjUnlock(pool);
|
2009-05-19 13:37:51 +00:00
|
|
|
origpool = virStoragePoolObjFindByName(&driver->pools, vobj->pool);
|
2009-07-10 16:56:12 +00:00
|
|
|
virStoragePoolObjLock(pool);
|
2009-09-02 13:02:06 +00:00
|
|
|
}
|
2009-05-19 13:37:51 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching uuid %s"), obj->uuid);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2009-09-02 13:02:06 +00:00
|
|
|
if (STRNEQ(obj->name, vobj->pool) && !origpool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
vobj->pool);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2009-09-02 13:02:06 +00:00
|
|
|
if (origpool && !virStoragePoolObjIsActive(origpool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"),
|
|
|
|
origpool->def->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
2009-09-02 13:02:06 +00:00
|
|
|
origvol = virStorageVolDefFindByName(origpool ? origpool : pool, vobj->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
if (!origvol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
vobj->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
newvol = virStorageVolDefParseString(pool->def, xmldesc);
|
2009-05-19 13:37:51 +00:00
|
|
|
if (newvol == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (virStorageVolDefFindByName(pool, newvol->name)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("storage volume name '%s' already in use."),
|
|
|
|
newvol->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is there ever a valid case for this? */
|
|
|
|
if (newvol->capacity < origvol->capacity)
|
|
|
|
newvol->capacity = origvol->capacity;
|
|
|
|
|
2009-06-22 16:33:24 +00:00
|
|
|
/* Make sure allocation is at least as large as the destination cap,
|
|
|
|
* to make absolutely sure we copy all possible contents */
|
|
|
|
if (newvol->allocation < origvol->capacity)
|
|
|
|
newvol->allocation = origvol->capacity;
|
|
|
|
|
2009-05-19 13:37:51 +00:00
|
|
|
if (!backend->buildVolFrom) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
|
"%s", _("storage pool does not support volume creation from an existing volume"));
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (origvol->building) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("volume '%s' is still being allocated."),
|
|
|
|
origvol->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backend->refreshVol &&
|
|
|
|
backend->refreshVol(obj->conn, pool, origvol) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(pool->volumes.objs,
|
|
|
|
pool->volumes.count+1) < 0) {
|
2010-02-04 18:19:08 +00:00
|
|
|
virReportOOMError();
|
2009-05-19 13:37:51 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 'Define' the new volume so we get async progress reporting */
|
|
|
|
if (backend->createVol(obj->conn, pool, newvol) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
pool->volumes.objs[pool->volumes.count++] = newvol;
|
|
|
|
volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name,
|
2012-11-10 07:18:07 +00:00
|
|
|
newvol->key, NULL, NULL);
|
2009-05-19 13:37:51 +00:00
|
|
|
|
|
|
|
/* Drop the pool lock during volume allocation */
|
|
|
|
pool->asyncjobs++;
|
|
|
|
origvol->building = 1;
|
|
|
|
newvol->building = 1;
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
|
2009-09-02 13:02:06 +00:00
|
|
|
if (origpool) {
|
2009-05-19 13:37:51 +00:00
|
|
|
origpool->asyncjobs++;
|
|
|
|
virStoragePoolObjUnlock(origpool);
|
|
|
|
}
|
|
|
|
|
2010-01-20 23:41:52 +00:00
|
|
|
buildret = backend->buildVolFrom(obj->conn, pool, newvol, origvol, flags);
|
2009-05-19 13:37:51 +00:00
|
|
|
|
|
|
|
storageDriverLock(driver);
|
|
|
|
virStoragePoolObjLock(pool);
|
2009-09-02 13:02:06 +00:00
|
|
|
if (origpool)
|
2009-05-19 13:37:51 +00:00
|
|
|
virStoragePoolObjLock(origpool);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
origvol->building = 0;
|
|
|
|
newvol->building = 0;
|
|
|
|
newvol = NULL;
|
|
|
|
pool->asyncjobs--;
|
|
|
|
|
2009-09-02 13:02:06 +00:00
|
|
|
if (origpool) {
|
2009-05-19 13:37:51 +00:00
|
|
|
origpool->asyncjobs--;
|
|
|
|
virStoragePoolObjUnlock(origpool);
|
|
|
|
origpool = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (buildret < 0) {
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolDelete(volobj, 0);
|
2009-05-19 13:37:51 +00:00
|
|
|
pool = NULL;
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Creating volume '%s' in storage pool '%s'",
|
2011-03-30 01:19:47 +00:00
|
|
|
volobj->name, pool->def->name);
|
2009-05-19 13:37:51 +00:00
|
|
|
ret = volobj;
|
|
|
|
volobj = NULL;
|
|
|
|
|
|
|
|
cleanup:
|
Convert public datatypes to inherit from virObject
This converts the following public API datatypes to use the
virObject infrastructure:
virConnectPtr
virDomainPtr
virDomainSnapshotPtr
virInterfacePtr
virNetworkPtr
virNodeDevicePtr
virNWFilterPtr
virSecretPtr
virStreamPtr
virStorageVolPtr
virStoragePoolPtr
The code is significantly simplified, since the mutex in the
virConnectPtr object now only needs to be held when accessing
the per-connection virError object instance. All other operations
are completely lock free.
* src/datatypes.c, src/datatypes.h, src/libvirt.c: Convert
public datatypes to use virObject
* src/conf/domain_event.c, src/phyp/phyp_driver.c,
src/qemu/qemu_command.c, src/qemu/qemu_migration.c,
src/qemu/qemu_process.c, src/storage/storage_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xend_internal.c,
tests/qemuxml2argvtest.c, tests/qemuxmlnstest.c,
tests/sexpr2xmltest.c, tests/xmconfigtest.c: Convert
to use virObjectUnref/virObjectRef
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-31 16:55:36 +00:00
|
|
|
virObjectUnref(volobj);
|
2009-05-19 13:37:51 +00:00
|
|
|
virStorageVolDefFree(newvol);
|
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2009-09-02 13:02:06 +00:00
|
|
|
if (origpool)
|
2009-05-19 13:37:51 +00:00
|
|
|
virStoragePoolObjUnlock(origpool);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-02-23 03:13:18 +00:00
|
|
|
|
2009-07-14 15:24:42 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolDownload(virStorageVolPtr obj,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long length,
|
|
|
|
unsigned int flags)
|
2009-07-14 15:24:42 +00:00
|
|
|
{
|
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool = NULL;
|
|
|
|
virStorageVolDefPtr vol = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (vol == NULL) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vol->building) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("volume '%s' is still being allocated."),
|
|
|
|
vol->name);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (virFDStreamOpenFile(stream,
|
|
|
|
vol->target.path,
|
|
|
|
offset, length,
|
2011-08-02 17:19:53 +00:00
|
|
|
O_RDONLY) < 0)
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolUpload(virStorageVolPtr obj,
|
|
|
|
virStreamPtr stream,
|
|
|
|
unsigned long long offset,
|
|
|
|
unsigned long long length,
|
|
|
|
unsigned int flags)
|
2009-07-14 15:24:42 +00:00
|
|
|
{
|
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool = NULL;
|
|
|
|
virStorageVolDefPtr vol = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (vol == NULL) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vol->building) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("volume '%s' is still being allocated."),
|
|
|
|
vol->name);
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Not using O_CREAT because the file is required to
|
|
|
|
* already exist at this point */
|
|
|
|
if (virFDStreamOpenFile(stream,
|
|
|
|
vol->target.path,
|
|
|
|
offset, length,
|
2011-08-02 17:19:53 +00:00
|
|
|
O_WRONLY) < 0)
|
2009-07-14 15:24:42 +00:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-01-30 07:40:00 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolResize(virStorageVolPtr obj,
|
|
|
|
unsigned long long capacity,
|
|
|
|
unsigned int flags)
|
2012-01-30 07:40:00 +00:00
|
|
|
{
|
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStorageBackendPtr backend;
|
|
|
|
virStoragePoolObjPtr pool = NULL;
|
|
|
|
virStorageVolDefPtr vol = NULL;
|
|
|
|
unsigned long long abs_capacity;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(VIR_STORAGE_VOL_RESIZE_DELTA, -1);
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
if (!pool) {
|
2012-10-08 22:37:22 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-10-08 22:37:22 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (vol == NULL) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vol->building) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("volume '%s' is still being allocated."),
|
|
|
|
vol->name);
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2009-07-14 15:24:42 +00:00
|
|
|
|
2012-01-30 07:40:00 +00:00
|
|
|
if (flags & VIR_STORAGE_VOL_RESIZE_DELTA) {
|
|
|
|
abs_capacity = vol->capacity + capacity;
|
|
|
|
flags &= ~VIR_STORAGE_VOL_RESIZE_DELTA;
|
|
|
|
} else {
|
|
|
|
abs_capacity = capacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (abs_capacity < vol->allocation) {
|
maint: don't permit format strings without %
Any time we have a string with no % passed through gettext, a
translator can inject a % to cause a stack overread. When there
is nothing to format, it's easier to ask for a string that cannot
be used as a formatter, by using a trivial "%s" format instead.
In the past, we have used --disable-nls to catch some of the
offenders, but that doesn't get run very often, and many more
uses have crept in. Syntax check to the rescue!
The syntax check can catch uses such as
virReportError(code,
_("split "
"string"));
by using a sed script to fold context lines into one pattern
space before checking for a string without %.
This patch is just mechanical insertion of %s; there are probably
several messages touched by this patch where we would be better
off giving the user more information than a fixed string.
* cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
* src/datatypes.c (virUnrefConnect, virGetDomain)
(virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
(virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
(virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
(virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
(virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
* src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Likewise.
* src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
(virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
Likewise.
* src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
(virNetworkDefParseXML): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
Likewise.
* src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
(virNWFilterVarAccessParse): Likewise.
* src/libvirt.c (virDomainSave, virDomainSaveFlags)
(virDomainRestore, virDomainRestoreFlags)
(virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
(virDomainCoreDump, virDomainGetXMLDesc)
(virDomainMigrateVersion1, virDomainMigrateVersion2)
(virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
(virStreamSendAll, virStreamRecvAll)
(virDomainSnapshotGetXMLDesc): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
(virNWFilterDHCPSnoopReq): Likewise.
* src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
* src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
(qemuBuildCommandLine): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
Likewise.
* src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
(virNetSocketSendFD, virNetSocketRecvFD): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskBuildPool): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemProbe)
(virStorageBackendFileSystemBuild): Likewise.
* src/storage/storage_backend_rbd.c
(virStorageBackendRBDOpenRADOSConn): Likewise.
* src/storage/storage_driver.c (storageVolumeResize): Likewise.
* src/test/test_driver.c (testInterfaceChangeBegin)
(testInterfaceChangeCommit, testInterfaceChangeRollback):
Likewise.
* src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
Likewise.
* src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
(xenFormatXM): Likewise.
2012-07-23 20:33:08 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
2012-07-18 11:38:29 +00:00
|
|
|
_("can't shrink capacity below "
|
|
|
|
"existing allocation"));
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-03-03 03:18:59 +00:00
|
|
|
if (abs_capacity > vol->capacity + pool->def->available) {
|
maint: don't permit format strings without %
Any time we have a string with no % passed through gettext, a
translator can inject a % to cause a stack overread. When there
is nothing to format, it's easier to ask for a string that cannot
be used as a formatter, by using a trivial "%s" format instead.
In the past, we have used --disable-nls to catch some of the
offenders, but that doesn't get run very often, and many more
uses have crept in. Syntax check to the rescue!
The syntax check can catch uses such as
virReportError(code,
_("split "
"string"));
by using a sed script to fold context lines into one pattern
space before checking for a string without %.
This patch is just mechanical insertion of %s; there are probably
several messages touched by this patch where we would be better
off giving the user more information than a fixed string.
* cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
* src/datatypes.c (virUnrefConnect, virGetDomain)
(virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
(virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
(virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
(virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
(virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
* src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Likewise.
* src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
(virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
Likewise.
* src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
(virNetworkDefParseXML): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
Likewise.
* src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
(virNWFilterVarAccessParse): Likewise.
* src/libvirt.c (virDomainSave, virDomainSaveFlags)
(virDomainRestore, virDomainRestoreFlags)
(virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
(virDomainCoreDump, virDomainGetXMLDesc)
(virDomainMigrateVersion1, virDomainMigrateVersion2)
(virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
(virStreamSendAll, virStreamRecvAll)
(virDomainSnapshotGetXMLDesc): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
(virNWFilterDHCPSnoopReq): Likewise.
* src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
* src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
(qemuBuildCommandLine): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
Likewise.
* src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
(virNetSocketSendFD, virNetSocketRecvFD): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskBuildPool): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemProbe)
(virStorageBackendFileSystemBuild): Likewise.
* src/storage/storage_backend_rbd.c
(virStorageBackendRBDOpenRADOSConn): Likewise.
* src/storage/storage_driver.c (storageVolumeResize): Likewise.
* src/test/test_driver.c (testInterfaceChangeBegin)
(testInterfaceChangeCommit, testInterfaceChangeRollback):
Likewise.
* src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
Likewise.
* src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
(xenFormatXM): Likewise.
2012-07-23 20:33:08 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
2012-07-18 11:38:29 +00:00
|
|
|
_("Not enough space left on storage pool"));
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!backend->resizeVol) {
|
maint: don't permit format strings without %
Any time we have a string with no % passed through gettext, a
translator can inject a % to cause a stack overread. When there
is nothing to format, it's easier to ask for a string that cannot
be used as a formatter, by using a trivial "%s" format instead.
In the past, we have used --disable-nls to catch some of the
offenders, but that doesn't get run very often, and many more
uses have crept in. Syntax check to the rescue!
The syntax check can catch uses such as
virReportError(code,
_("split "
"string"));
by using a sed script to fold context lines into one pattern
space before checking for a string without %.
This patch is just mechanical insertion of %s; there are probably
several messages touched by this patch where we would be better
off giving the user more information than a fixed string.
* cfg.mk (sc_prohibit_diagnostic_without_format): New rule.
* src/datatypes.c (virUnrefConnect, virGetDomain)
(virUnrefDomain, virGetNetwork, virUnrefNetwork, virGetInterface)
(virUnrefInterface, virGetStoragePool, virUnrefStoragePool)
(virGetStorageVol, virUnrefStorageVol, virGetNodeDevice)
(virGetSecret, virUnrefSecret, virGetNWFilter, virUnrefNWFilter)
(virGetDomainSnapshot, virUnrefDomainSnapshot): Add %s wrapper.
* src/lxc/lxc_driver.c (lxcDomainSetBlkioParameters)
(lxcDomainGetBlkioParameters): Likewise.
* src/conf/domain_conf.c (virSecurityDeviceLabelDefParseXML)
(virDomainDiskDefParseXML, virDomainGraphicsDefParseXML):
Likewise.
* src/conf/network_conf.c (virNetworkDNSHostsDefParseXML)
(virNetworkDefParseXML): Likewise.
* src/conf/nwfilter_conf.c (virNWFilterIsValidChainName):
Likewise.
* src/conf/nwfilter_params.c (virNWFilterVarValueCreateSimple)
(virNWFilterVarAccessParse): Likewise.
* src/libvirt.c (virDomainSave, virDomainSaveFlags)
(virDomainRestore, virDomainRestoreFlags)
(virDomainSaveImageGetXMLDesc, virDomainSaveImageDefineXML)
(virDomainCoreDump, virDomainGetXMLDesc)
(virDomainMigrateVersion1, virDomainMigrateVersion2)
(virDomainMigrateVersion3, virDomainMigrate, virDomainMigrate2)
(virStreamSendAll, virStreamRecvAll)
(virDomainSnapshotGetXMLDesc): Likewise.
* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqLeaseDel)
(virNWFilterDHCPSnoopReq): Likewise.
* src/openvz/openvz_driver.c (openvzUpdateDevice): Likewise.
* src/openvz/openvz_util.c (openvzKBPerPages): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupCgroup): Likewise.
* src/qemu/qemu_command.c (qemuBuildHubDevStr, qemuBuildChrChardevStr)
(qemuBuildCommandLine): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainAttachNetDevice): Likewise.
* src/rpc/virnetsaslcontext.c (virNetSASLSessionGetIdentity):
Likewise.
* src/rpc/virnetsocket.c (virNetSocketNewConnectUNIX)
(virNetSocketSendFD, virNetSocketRecvFD): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskBuildPool): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemProbe)
(virStorageBackendFileSystemBuild): Likewise.
* src/storage/storage_backend_rbd.c
(virStorageBackendRBDOpenRADOSConn): Likewise.
* src/storage/storage_driver.c (storageVolumeResize): Likewise.
* src/test/test_driver.c (testInterfaceChangeBegin)
(testInterfaceChangeCommit, testInterfaceChangeRollback):
Likewise.
* src/vbox/vbox_tmpl.c (vboxListAllDomains): Likewise.
* src/xenxs/xen_sxpr.c (xenFormatSxprDisk, xenFormatSxpr):
Likewise.
* src/xenxs/xen_xm.c (xenXMConfigGetUUID, xenFormatXMDisk)
(xenFormatXM): Likewise.
2012-07-23 20:33:08 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
2012-07-18 11:38:29 +00:00
|
|
|
_("storage pool does not support changing of "
|
|
|
|
"volume capacity"));
|
2012-01-30 07:40:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backend->resizeVol(obj->conn, pool, vol, abs_capacity, flags) < 0)
|
|
|
|
goto out;
|
|
|
|
|
2013-04-13 07:22:01 +00:00
|
|
|
vol->capacity = abs_capacity;
|
|
|
|
ret = 0;
|
2012-01-30 07:40:00 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2009-07-14 15:24:42 +00:00
|
|
|
|
2010-02-23 03:13:18 +00:00
|
|
|
/* If the volume we're wiping is already a sparse file, we simply
|
|
|
|
* truncate and extend it to its original size, filling it with
|
|
|
|
* zeroes. This behavior is guaranteed by POSIX:
|
|
|
|
*
|
|
|
|
* http://www.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html
|
|
|
|
*
|
|
|
|
* If fildes refers to a regular file, the ftruncate() function shall
|
|
|
|
* cause the size of the file to be truncated to length. If the size
|
|
|
|
* of the file previously exceeded length, the extra data shall no
|
|
|
|
* longer be available to reads on the file. If the file previously
|
|
|
|
* was smaller than this size, ftruncate() shall increase the size of
|
|
|
|
* the file. If the file size is increased, the extended area shall
|
|
|
|
* appear as if it were zero-filled.
|
|
|
|
*/
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolZeroSparseFile(virStorageVolDefPtr vol,
|
|
|
|
off_t size,
|
|
|
|
int fd)
|
2010-02-23 03:13:18 +00:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
ret = ftruncate(fd, 0);
|
|
|
|
if (ret == -1) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to truncate volume with "
|
|
|
|
"path '%s' to 0 bytes"),
|
|
|
|
vol->target.path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = ftruncate(fd, size);
|
|
|
|
if (ret == -1) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to truncate volume with "
|
2010-04-02 19:44:04 +00:00
|
|
|
"path '%s' to %ju bytes"),
|
2010-12-08 00:31:14 +00:00
|
|
|
vol->target.path, (uintmax_t)size);
|
2010-02-23 03:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
storageWipeExtent(virStorageVolDefPtr vol,
|
|
|
|
int fd,
|
|
|
|
off_t extent_start,
|
|
|
|
off_t extent_length,
|
|
|
|
char *writebuf,
|
|
|
|
size_t writebuf_length,
|
|
|
|
size_t *bytes_wiped)
|
|
|
|
{
|
|
|
|
int ret = -1, written = 0;
|
|
|
|
off_t remaining = 0;
|
|
|
|
size_t write_size = 0;
|
|
|
|
|
|
|
|
VIR_DEBUG("extent logical start: %ju len: %ju",
|
2010-12-08 00:31:14 +00:00
|
|
|
(uintmax_t)extent_start, (uintmax_t)extent_length);
|
2010-02-23 03:13:18 +00:00
|
|
|
|
|
|
|
if ((ret = lseek(fd, extent_start, SEEK_SET)) < 0) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to seek to position %ju in volume "
|
|
|
|
"with path '%s'"),
|
2010-12-08 00:31:14 +00:00
|
|
|
(uintmax_t)extent_start, vol->target.path);
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
remaining = extent_length;
|
|
|
|
while (remaining > 0) {
|
|
|
|
|
|
|
|
write_size = (writebuf_length < remaining) ? writebuf_length : remaining;
|
|
|
|
written = safewrite(fd, writebuf, write_size);
|
|
|
|
if (written < 0) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to write %zu bytes to "
|
|
|
|
"storage volume with path '%s'"),
|
|
|
|
write_size, vol->target.path);
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
*bytes_wiped += written;
|
|
|
|
remaining -= written;
|
|
|
|
}
|
|
|
|
|
2011-08-18 12:40:03 +00:00
|
|
|
if (fdatasync(fd) < 0) {
|
|
|
|
ret = -errno;
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("cannot sync data to volume with path '%s'"),
|
|
|
|
vol->target.path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2010-02-23 03:13:18 +00:00
|
|
|
VIR_DEBUG("Wrote %zu bytes to volume with path '%s'",
|
|
|
|
*bytes_wiped, vol->target.path);
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolWipeInternal(virStorageVolDefPtr def,
|
|
|
|
unsigned int algorithm)
|
2010-02-23 03:13:18 +00:00
|
|
|
{
|
|
|
|
int ret = -1, fd = -1;
|
|
|
|
struct stat st;
|
|
|
|
char *writebuf = NULL;
|
|
|
|
size_t bytes_wiped = 0;
|
2012-01-09 16:05:03 +00:00
|
|
|
virCommandPtr cmd = NULL;
|
2010-02-23 03:13:18 +00:00
|
|
|
|
2012-01-09 16:05:03 +00:00
|
|
|
VIR_DEBUG("Wiping volume with path '%s' and algorithm %u",
|
|
|
|
def->target.path, algorithm);
|
2010-02-23 03:13:18 +00:00
|
|
|
|
|
|
|
fd = open(def->target.path, O_RDWR);
|
|
|
|
if (fd == -1) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to open storage volume with path '%s'"),
|
|
|
|
def->target.path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fstat(fd, &st) == -1) {
|
|
|
|
virReportSystemError(errno,
|
|
|
|
_("Failed to stat storage volume with path '%s'"),
|
|
|
|
def->target.path);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:05:03 +00:00
|
|
|
if (algorithm != VIR_STORAGE_VOL_WIPE_ALG_ZERO) {
|
|
|
|
const char *alg_char ATTRIBUTE_UNUSED = NULL;
|
|
|
|
switch (algorithm) {
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_NNSA:
|
|
|
|
alg_char = "nnsa";
|
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_DOD:
|
|
|
|
alg_char = "dod";
|
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_BSI:
|
|
|
|
alg_char = "bsi";
|
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_GUTMANN:
|
|
|
|
alg_char = "gutmann";
|
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_SCHNEIER:
|
2012-02-29 06:20:32 +00:00
|
|
|
alg_char = "schneier";
|
2012-01-09 16:05:03 +00:00
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_PFITZNER7:
|
|
|
|
alg_char = "pfitzner7";
|
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_PFITZNER33:
|
2012-02-29 10:42:00 +00:00
|
|
|
alg_char = "pfitzner33";
|
2012-01-09 16:05:03 +00:00
|
|
|
break;
|
|
|
|
case VIR_STORAGE_VOL_WIPE_ALG_RANDOM:
|
|
|
|
alg_char = "random";
|
|
|
|
break;
|
|
|
|
default:
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("unsupported algorithm %d"),
|
|
|
|
algorithm);
|
2012-01-09 16:05:03 +00:00
|
|
|
}
|
|
|
|
cmd = virCommandNew(SCRUB);
|
|
|
|
virCommandAddArgList(cmd, "-f", "-p", alg_char,
|
|
|
|
def->target.path, NULL);
|
2010-02-23 03:13:18 +00:00
|
|
|
|
2012-01-09 16:05:03 +00:00
|
|
|
if (virCommandRun(cmd, NULL) < 0)
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
|
2012-01-09 16:05:03 +00:00
|
|
|
ret = 0;
|
|
|
|
goto out;
|
|
|
|
} else {
|
|
|
|
if (S_ISREG(st.st_mode) && st.st_blocks < (st.st_size / DEV_BSIZE)) {
|
2013-04-23 12:50:18 +00:00
|
|
|
ret = storageVolZeroSparseFile(def, st.st_size, fd);
|
2012-01-09 16:05:03 +00:00
|
|
|
} else {
|
|
|
|
|
|
|
|
if (VIR_ALLOC_N(writebuf, st.st_blksize) != 0) {
|
|
|
|
virReportOOMError();
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = storageWipeExtent(def,
|
|
|
|
fd,
|
|
|
|
0,
|
|
|
|
def->allocation,
|
|
|
|
writebuf,
|
|
|
|
st.st_blksize,
|
|
|
|
&bytes_wiped);
|
|
|
|
}
|
2010-02-23 03:13:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2012-01-09 16:05:03 +00:00
|
|
|
virCommandFree(cmd);
|
2010-02-23 03:13:18 +00:00
|
|
|
VIR_FREE(writebuf);
|
2010-11-09 20:48:48 +00:00
|
|
|
VIR_FORCE_CLOSE(fd);
|
2010-02-23 03:13:18 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolWipePattern(virStorageVolPtr obj,
|
|
|
|
unsigned int algorithm,
|
|
|
|
unsigned int flags)
|
2010-02-23 03:13:18 +00:00
|
|
|
{
|
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool = NULL;
|
|
|
|
virStorageVolDefPtr vol = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
|
2010-04-16 12:04:31 +00:00
|
|
|
virCheckFlags(0, -1);
|
2010-02-23 03:13:18 +00:00
|
|
|
|
2012-01-09 16:05:03 +00:00
|
|
|
if (algorithm >= VIR_STORAGE_VOL_WIPE_ALG_LAST) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_INVALID_ARG,
|
|
|
|
_("wiping algorithm %d not supported"),
|
|
|
|
algorithm);
|
2012-01-09 16:05:03 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-02-23 03:13:18 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (vol == NULL) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vol->building) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("volume '%s' is still being allocated."),
|
|
|
|
vol->name);
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2013-04-23 12:50:18 +00:00
|
|
|
if (storageVolWipeInternal(vol, algorithm) == -1) {
|
2010-02-23 03:13:18 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
out:
|
|
|
|
if (pool) {
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:05:03 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolWipe(virStorageVolPtr obj,
|
|
|
|
unsigned int flags)
|
2012-01-09 16:05:03 +00:00
|
|
|
{
|
2013-04-23 12:50:18 +00:00
|
|
|
return storageVolWipePattern(obj, VIR_STORAGE_VOL_WIPE_ALG_ZERO, flags);
|
2012-01-09 16:05:03 +00:00
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolDelete(virStorageVolPtr obj,
|
|
|
|
unsigned int flags) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageVolDefPtr vol = NULL;
|
2008-10-10 15:13:28 +00:00
|
|
|
unsigned int i;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (!vol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-17 19:12:37 +00:00
|
|
|
if (vol->building) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("volume '%s' is still being allocated."),
|
|
|
|
vol->name);
|
2009-04-17 19:12:37 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!backend->deleteVol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_SUPPORT,
|
|
|
|
"%s", _("storage pool does not support vol deletion"));
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
if (backend->deleteVol(obj->conn, pool, vol, flags) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
2008-10-10 15:13:28 +00:00
|
|
|
for (i = 0 ; i < pool->volumes.count ; i++) {
|
|
|
|
if (pool->volumes.objs[i] == vol) {
|
maint: omit translation for all VIR_INFO
We were 31/73 on whether to translate; since less than 50% translated
and since VIR_INFO is less than VIR_WARN which also doesn't translate,
this makes sense.
* cfg.mk (sc_prohibit_gettext_markup): Add VIR_INFO, since it
falls between WARN and DEBUG.
* daemon/libvirtd.c (qemudDispatchSignalEvent, remoteCheckAccess)
(qemudDispatchServer): Adjust offenders.
* daemon/remote.c (remoteDispatchAuthPolkit): Likewise.
* src/network/bridge_driver.c (networkReloadIptablesRules)
(networkStartNetworkDaemon, networkShutdownNetworkDaemon)
(networkCreate, networkDefine, networkUndefine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainDefine)
(qemudDomainUndefine): Likewise.
* src/storage/storage_driver.c (storagePoolCreate)
(storagePoolDefine, storagePoolUndefine, storagePoolStart)
(storagePoolDestroy, storagePoolDelete, storageVolumeCreateXML)
(storageVolumeCreateXMLFrom, storageVolumeDelete): Likewise.
* src/util/bridge.c (brProbeVnetHdr): Likewise.
* po/POTFILES.in: Drop src/util/bridge.c.
2011-05-11 15:08:44 +00:00
|
|
|
VIR_INFO("Deleting volume '%s' from storage pool '%s'",
|
2011-03-30 01:19:47 +00:00
|
|
|
vol->name, pool->def->name);
|
2008-10-10 15:13:28 +00:00
|
|
|
virStorageVolDefFree(vol);
|
2008-12-04 21:39:45 +00:00
|
|
|
vol = NULL;
|
2008-10-10 15:13:28 +00:00
|
|
|
|
|
|
|
if (i < (pool->volumes.count - 1))
|
|
|
|
memmove(pool->volumes.objs + i, pool->volumes.objs + i + 1,
|
|
|
|
sizeof(*(pool->volumes.objs)) * (pool->volumes.count - (i + 1)));
|
|
|
|
|
|
|
|
if (VIR_REALLOC_N(pool->volumes.objs, pool->volumes.count - 1) < 0) {
|
|
|
|
; /* Failure to reduce memory allocation isn't fatal */
|
|
|
|
}
|
|
|
|
pool->volumes.count--;
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolGetInfo(virStorageVolPtr obj,
|
|
|
|
virStorageVolInfoPtr info) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
|
|
|
virStorageVolDefPtr vol;
|
2008-12-04 21:39:45 +00:00
|
|
|
int ret = -1;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (!vol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
if (backend->refreshVol &&
|
|
|
|
backend->refreshVol(obj->conn, pool, vol) < 0)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
|
|
|
memset(info, 0, sizeof(*info));
|
2008-11-17 11:19:33 +00:00
|
|
|
info->type = vol->type;
|
2008-02-20 15:34:52 +00:00
|
|
|
info->capacity = vol->capacity;
|
|
|
|
info->allocation = vol->allocation;
|
2008-12-04 21:39:45 +00:00
|
|
|
ret = 0;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolGetXMLDesc(virStorageVolPtr obj,
|
|
|
|
unsigned int flags)
|
2011-07-06 22:51:23 +00:00
|
|
|
{
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageBackendPtr backend;
|
|
|
|
virStorageVolDefPtr vol;
|
2008-12-04 21:39:45 +00:00
|
|
|
char *ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2011-07-06 22:51:23 +00:00
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
2008-12-04 21:39:45 +00:00
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (!vol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((backend = virStorageBackendForType(pool->def->type)) == NULL)
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2009-04-03 14:15:30 +00:00
|
|
|
|
|
|
|
if (backend->refreshVol &&
|
|
|
|
backend->refreshVol(obj->conn, pool, vol) < 0)
|
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2010-02-10 11:42:56 +00:00
|
|
|
ret = virStorageVolDefFormat(pool->def, vol);
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
|
|
|
|
2008-12-04 21:39:45 +00:00
|
|
|
return ret;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
2013-04-23 12:50:18 +00:00
|
|
|
storageVolGetPath(virStorageVolPtr obj) {
|
2008-12-04 21:39:45 +00:00
|
|
|
virStorageDriverStatePtr driver = obj->conn->storagePrivateData;
|
2008-12-04 21:40:42 +00:00
|
|
|
virStoragePoolObjPtr pool;
|
2008-02-20 15:34:52 +00:00
|
|
|
virStorageVolDefPtr vol;
|
2008-12-04 21:39:45 +00:00
|
|
|
char *ret = NULL;
|
2008-02-20 15:34:52 +00:00
|
|
|
|
2008-12-04 21:40:42 +00:00
|
|
|
storageDriverLock(driver);
|
|
|
|
pool = virStoragePoolObjFindByName(&driver->pools, obj->pool);
|
|
|
|
storageDriverUnlock(driver);
|
2008-02-20 15:34:52 +00:00
|
|
|
if (!pool) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_POOL,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("no storage pool with matching name '%s'"),
|
|
|
|
obj->pool);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!virStoragePoolObjIsActive(pool)) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
2012-10-08 22:37:22 +00:00
|
|
|
_("storage pool '%s' is not active"), pool->def->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vol = virStorageVolDefFindByName(pool, obj->name);
|
|
|
|
|
|
|
|
if (!vol) {
|
2012-07-18 11:38:29 +00:00
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("no storage vol with matching name '%s'"),
|
|
|
|
obj->name);
|
2008-12-04 21:39:45 +00:00
|
|
|
goto cleanup;
|
2008-02-20 15:34:52 +00:00
|
|
|
}
|
|
|
|
|
2013-05-03 12:49:08 +00:00
|
|
|
ignore_value(VIR_STRDUP(ret, vol->target.path));
|
2008-12-04 21:39:45 +00:00
|
|
|
|
|
|
|
cleanup:
|
2008-12-04 21:40:42 +00:00
|
|
|
if (pool)
|
|
|
|
virStoragePoolObjUnlock(pool);
|
2008-02-20 15:34:52 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-09-04 15:16:27 +00:00
|
|
|
static int
|
2013-04-23 12:50:18 +00:00
|
|
|
storageConnectListAllStoragePools(virConnectPtr conn,
|
|
|
|
virStoragePoolPtr **pools,
|
|
|
|
unsigned int flags)
|
2012-09-04 15:16:27 +00:00
|
|
|
{
|
|
|
|
virStorageDriverStatePtr driver = conn->storagePrivateData;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
virCheckFlags(VIR_CONNECT_LIST_STORAGE_POOLS_FILTERS_ALL, -1);
|
|
|
|
|
|
|
|
storageDriverLock(driver);
|
|
|
|
ret = virStoragePoolList(conn, driver->pools, pools, flags);
|
|
|
|
storageDriverUnlock(driver);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-02-20 15:34:52 +00:00
|
|
|
static virStorageDriver storageDriver = {
|
2008-09-22 19:53:42 +00:00
|
|
|
.name = "storage",
|
2013-04-23 12:49:21 +00:00
|
|
|
.storageOpen = storageOpen, /* 0.4.0 */
|
|
|
|
.storageClose = storageClose, /* 0.4.0 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.connectNumOfStoragePools = storageConnectNumOfStoragePools, /* 0.4.0 */
|
|
|
|
.connectListStoragePools = storageConnectListStoragePools, /* 0.4.0 */
|
|
|
|
.connectNumOfDefinedStoragePools = storageConnectNumOfDefinedStoragePools, /* 0.4.0 */
|
|
|
|
.connectListDefinedStoragePools = storageConnectListDefinedStoragePools, /* 0.4.0 */
|
|
|
|
.connectListAllStoragePools = storageConnectListAllStoragePools, /* 0.10.2 */
|
|
|
|
.connectFindStoragePoolSources = storageConnectFindStoragePoolSources, /* 0.4.0 */
|
2013-04-22 17:26:01 +00:00
|
|
|
.storagePoolLookupByName = storagePoolLookupByName, /* 0.4.0 */
|
|
|
|
.storagePoolLookupByUUID = storagePoolLookupByUUID, /* 0.4.0 */
|
|
|
|
.storagePoolLookupByVolume = storagePoolLookupByVolume, /* 0.4.0 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.storagePoolCreateXML = storagePoolCreateXML, /* 0.4.0 */
|
|
|
|
.storagePoolDefineXML = storagePoolDefineXML, /* 0.4.0 */
|
2013-04-22 17:26:01 +00:00
|
|
|
.storagePoolBuild = storagePoolBuild, /* 0.4.0 */
|
|
|
|
.storagePoolUndefine = storagePoolUndefine, /* 0.4.0 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.storagePoolCreate = storagePoolCreate, /* 0.4.0 */
|
2013-04-22 17:26:01 +00:00
|
|
|
.storagePoolDestroy = storagePoolDestroy, /* 0.4.0 */
|
|
|
|
.storagePoolDelete = storagePoolDelete, /* 0.4.0 */
|
|
|
|
.storagePoolRefresh = storagePoolRefresh, /* 0.4.0 */
|
|
|
|
.storagePoolGetInfo = storagePoolGetInfo, /* 0.4.0 */
|
|
|
|
.storagePoolGetXMLDesc = storagePoolGetXMLDesc, /* 0.4.0 */
|
|
|
|
.storagePoolGetAutostart = storagePoolGetAutostart, /* 0.4.0 */
|
|
|
|
.storagePoolSetAutostart = storagePoolSetAutostart, /* 0.4.0 */
|
2013-04-23 12:50:18 +00:00
|
|
|
.storagePoolNumOfVolumes = storagePoolNumOfVolumes, /* 0.4.0 */
|
2013-04-22 17:26:01 +00:00
|
|
|
.storagePoolListVolumes = storagePoolListVolumes, /* 0.4.0 */
|
|
|
|
.storagePoolListAllVolumes = storagePoolListAllVolumes, /* 0.10.2 */
|
|
|
|
|
2013-04-23 12:50:18 +00:00
|
|
|
.storageVolLookupByName = storageVolLookupByName, /* 0.4.0 */
|
|
|
|
.storageVolLookupByKey = storageVolLookupByKey, /* 0.4.0 */
|
|
|
|
.storageVolLookupByPath = storageVolLookupByPath, /* 0.4.0 */
|
|
|
|
.storageVolCreateXML = storageVolCreateXML, /* 0.4.0 */
|
|
|
|
.storageVolCreateXMLFrom = storageVolCreateXMLFrom, /* 0.6.4 */
|
|
|
|
.storageVolDownload = storageVolDownload, /* 0.9.0 */
|
|
|
|
.storageVolUpload = storageVolUpload, /* 0.9.0 */
|
|
|
|
.storageVolDelete = storageVolDelete, /* 0.4.0 */
|
|
|
|
.storageVolWipe = storageVolWipe, /* 0.8.0 */
|
|
|
|
.storageVolWipePattern = storageVolWipePattern, /* 0.9.10 */
|
|
|
|
.storageVolGetInfo = storageVolGetInfo, /* 0.4.0 */
|
|
|
|
.storageVolGetXMLDesc = storageVolGetXMLDesc, /* 0.4.0 */
|
|
|
|
.storageVolGetPath = storageVolGetPath, /* 0.4.0 */
|
|
|
|
.storageVolResize = storageVolResize, /* 0.9.10 */
|
2013-04-22 17:26:01 +00:00
|
|
|
|
|
|
|
.storagePoolIsActive = storagePoolIsActive, /* 0.7.3 */
|
|
|
|
.storagePoolIsPersistent = storagePoolIsPersistent, /* 0.7.3 */
|
2008-02-20 15:34:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static virStateDriver stateDriver = {
|
Fix return value in virStateInitialize impl for LXC
The LXC driver was mistakenly returning -1 for lxcStartup()
in scenarios that are not an error. This caused the libvirtd
to quit for unprivileged users. This fixes the return code
of LXC driver, and also adds a "name" field to the virStateDriver
struct and logging to make it easier to find these problems
in the future
* src/driver.h: Add a 'name' field to state driver to allow
easy identification during failures
* src/libvirt.c: Log name of failed driver for virStateInit
failures
* src/lxc/lxc_driver.c: Don't return a failure code for
lxcStartup() if LXC is not available on this host, simply
disable the driver.
* src/network/bridge_driver.c, src/node_device/node_device_devkit.c,
src/node_device/node_device_hal.c, src/opennebula/one_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/secret/secret_driver.c, src/storage/storage_driver.c,
src/uml/uml_driver.c, src/xen/xen_driver.c: Fill in name
field in virStateDriver struct
2009-11-02 23:18:19 +00:00
|
|
|
.name = "Storage",
|
2013-04-23 12:50:18 +00:00
|
|
|
.stateInitialize = storageStateInitialize,
|
|
|
|
.stateCleanup = storageStateCleanup,
|
|
|
|
.stateReload = storageStateReload,
|
2008-02-20 15:34:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int storageRegister(void) {
|
|
|
|
virRegisterStorageDriver(&storageDriver);
|
|
|
|
virRegisterStateDriver(&stateDriver);
|
|
|
|
return 0;
|
|
|
|
}
|