2012-11-10 07:18:08 +00:00
|
|
|
/*
|
|
|
|
* esx_storage_backend_iscsi.c: ESX storage backend for iSCSI handling
|
|
|
|
*
|
conf: track sizes directly in source struct
One of the features of qcow2 is that a wrapper file can have
more capacity than its backing file from the guest's perspective;
what's more, sparse files make tracking allocation of both
the active and backing file worthwhile. As such, it makes
more sense to show allocation numbers for each file in a chain,
and not just the top-level file. This sets up the fields for
the tracking, although it does not modify XML to display any
new information.
* src/util/virstoragefile.h (_virStorageSource): Add fields.
* src/conf/storage_conf.h (_virStorageVolDef): Drop redundant
fields.
* src/storage/storage_backend.c (virStorageBackendCreateBlockFrom)
(createRawFile, virStorageBackendCreateQemuImgCmd)
(virStorageBackendCreateQcowCreate): Update clients.
* src/storage/storage_driver.c (storageVolDelete)
(storageVolCreateXML, storageVolCreateXMLFrom, storageVolResize)
(storageVolWipeInternal, storageVolGetInfo): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget)
(virStorageBackendFileSystemRefresh)
(virStorageBackendFileSystemVolResize)
(virStorageBackendFileSystemVolRefresh): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol)
(virStorageBackendLogicalCreateVol): Likewise.
* src/storage/storage_backend_scsi.c
(virStorageBackendSCSINewLun): Likewise.
* src/storage/storage_backend_mpath.c
(virStorageBackendMpathNewVol): Likewise.
* src/storage/storage_backend_rbd.c
(volStorageBackendRBDRefreshVolInfo)
(virStorageBackendRBDCreateImage): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol): Likewise.
* src/storage/storage_backend_sheepdog.c
(virStorageBackendSheepdogBuildVol)
(virStorageBackendSheepdogParseVdiList): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.
* src/conf/storage_conf.c (virStorageVolDefFormat)
(virStorageVolDefParseXML): Likewise.
* src/test/test_driver.c (testOpenVolumesForPool)
(testStorageVolCreateXML, testStorageVolCreateXMLFrom)
(testStorageVolDelete, testStorageVolGetInfo): Likewise.
* src/esx/esx_storage_backend_iscsi.c (esxStorageVolGetXMLDesc):
Likewise.
* src/esx/esx_storage_backend_vmfs.c (esxStorageVolGetXMLDesc)
(esxStorageVolCreateXML): Likewise.
* src/parallels/parallels_driver.c (parallelsAddHddByVolume):
Likewise.
* src/parallels/parallels_storage.c (parallelsDiskDescParseNode)
(parallelsStorageVolDefineXML, parallelsStorageVolCreateXMLFrom)
(parallelsStorageVolDefRemove, parallelsStorageVolGetInfo):
Likewise.
* src/vbox/vbox_tmpl.c (vboxStorageVolCreateXML)
(vboxStorageVolGetXMLDesc): Likewise.
* tests/storagebackendsheepdogtest.c (test_vdi_list_parser):
Likewise.
* src/phyp/phyp_driver.c (phypStorageVolCreateXML): Likewise.
2014-04-01 23:43:36 +00:00
|
|
|
* Copyright (C) 2014 Red Hat, Inc.
|
2012-11-10 07:18:08 +00:00
|
|
|
* Copyright (C) 2012 Ata E Husain Bohra <ata.husain@hotmail.com>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "md5.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-13 18:01:25 +00:00
|
|
|
#include "viruuid.h"
|
2012-11-10 07:18:08 +00:00
|
|
|
#include "storage_conf.h"
|
2012-12-13 15:25:48 +00:00
|
|
|
#include "virstoragefile.h"
|
2012-11-10 07:18:08 +00:00
|
|
|
#include "esx_storage_backend_iscsi.h"
|
|
|
|
#include "esx_private.h"
|
|
|
|
#include "esx_vi.h"
|
|
|
|
#include "esx_vi_methods.h"
|
|
|
|
#include "esx_util.h"
|
2013-05-03 12:41:53 +00:00
|
|
|
#include "virstring.h"
|
2012-11-10 07:18:08 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_ESX
|
|
|
|
|
|
|
|
/*
|
2015-06-03 10:10:36 +00:00
|
|
|
* The UUID of a storage pool is the MD5 sum of its mount path. Therefore,
|
2012-11-10 07:18:08 +00:00
|
|
|
* verify that UUID and MD5 sum match in size, because we rely on that.
|
|
|
|
*/
|
|
|
|
verify(MD5_DIGEST_SIZE == VIR_UUID_BUFLEN);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxConnectNumOfStoragePools(virConnectPtr conn)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
int count = 0;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
|
|
|
|
esxVI_HostInternetScsiHbaStaticTarget *target;
|
|
|
|
|
|
|
|
if (esxVI_LookupHostInternetScsiHba(priv->primary,
|
|
|
|
&hostInternetScsiHba) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Unable to obtain iSCSI adapter"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: code looks for software iSCSI adapter only */
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!hostInternetScsiHba) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* iSCSI adapter may not be enabled for this host */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESX has two kind of targets:
|
|
|
|
* 1. staticIscsiTargets
|
|
|
|
* 2. dynamicIscsiTargets
|
|
|
|
* For each dynamic target if its reachable a static target is added.
|
|
|
|
* return iSCSI names for all static targets to avoid duplicate names.
|
|
|
|
*/
|
|
|
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
2013-10-17 17:04:13 +00:00
|
|
|
target; target = target->_next) {
|
2012-11-10 07:18:08 +00:00
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = true;
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
|
|
|
|
|
|
|
|
return success ? count : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxConnectListStoragePools(virConnectPtr conn, char **const names,
|
|
|
|
const int maxnames)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
int count = 0;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
|
|
|
|
esxVI_HostInternetScsiHbaStaticTarget *target;
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2012-11-10 07:18:08 +00:00
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (maxnames == 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (esxVI_LookupHostInternetScsiHba(priv->primary,
|
|
|
|
&hostInternetScsiHba) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Unable to obtain iSCSI adapter"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: code looks for software iSCSI adapter only */
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!hostInternetScsiHba) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* iSCSI adapter may not be enabled for this host */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESX has two kind of targets:
|
|
|
|
* 1. staticIscsiTargets
|
|
|
|
* 2. dynamicIscsiTargets
|
|
|
|
* For each dynamic target if its reachable a static target is added.
|
|
|
|
* return iSCSI names for all static targets to avoid duplicate names.
|
|
|
|
*/
|
|
|
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
2013-10-17 17:04:13 +00:00
|
|
|
target && count < maxnames; target = target->_next) {
|
2013-05-03 12:41:53 +00:00
|
|
|
if (VIR_STRDUP(names[count], target->iScsiName) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
success = true;
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
if (! success) {
|
2014-11-13 14:22:20 +00:00
|
|
|
for (i = 0; i < count; ++i)
|
2012-11-10 07:18:08 +00:00
|
|
|
VIR_FREE(names[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
|
|
|
|
|
|
|
|
return success ? count : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolLookupByName(virConnectPtr conn,
|
|
|
|
const char *name)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHbaStaticTarget *target = NULL;
|
|
|
|
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
|
|
|
|
unsigned char md5[MD5_DIGEST_SIZE];
|
|
|
|
virStoragePoolPtr pool = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup routine are used by the base driver to determine
|
|
|
|
* appropriate backend driver, lookup targetName as optional
|
|
|
|
* parameter
|
|
|
|
*/
|
|
|
|
if (esxVI_LookupHostInternetScsiHbaStaticTargetByName
|
|
|
|
(priv->primary, name, &target, esxVI_Occurrence_OptionalItem) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!target) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* pool not found, error handling done by the base driver */
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HostInternetScsiHbaStaticTarget does not provide a uuid field,
|
|
|
|
* but iScsiName (or widely known as IQN) is unique across the multiple
|
|
|
|
* hosts, using it to compute key
|
|
|
|
*/
|
|
|
|
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
|
|
|
|
|
|
|
|
pool = virGetStoragePool(conn, name, md5, &esxStorageBackendISCSI, NULL);
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHbaStaticTarget_Free(&target);
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStoragePoolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolLookupByUUID(virConnectPtr conn,
|
|
|
|
const unsigned char *uuid)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virStoragePoolPtr pool = NULL;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
|
|
|
|
esxVI_HostInternetScsiHbaStaticTarget *target;
|
|
|
|
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
|
|
|
|
unsigned char md5[MD5_DIGEST_SIZE];
|
|
|
|
|
|
|
|
if (esxVI_LookupHostInternetScsiHba(priv->primary,
|
|
|
|
&hostInternetScsiHba) < 0) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("Unable to obtain iSCSI adapter"));
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: code just looks for software iSCSI adapter */
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!hostInternetScsiHba) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* iSCSI adapter may not be enabled for this host */
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
2013-10-17 17:04:13 +00:00
|
|
|
target; target = target->_next) {
|
2012-11-10 07:18:08 +00:00
|
|
|
md5_buffer(target->iScsiName, strlen(target->iScsiName), md5);
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!target) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* pool not found, error handling done by the base driver */
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
pool = virGetStoragePool(conn, target->iScsiName, md5,
|
|
|
|
&esxStorageBackendISCSI, NULL);
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
|
|
|
|
|
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolRefresh(virStoragePoolPtr pool,
|
|
|
|
unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
int result = -1;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = pool->conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
|
|
|
|
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
if (esxVI_LookupHostInternetScsiHba(priv->primary,
|
|
|
|
&hostInternetScsiHba) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ESX does not allow rescan on a particular target,
|
|
|
|
* rescan all the static targets
|
|
|
|
*/
|
|
|
|
if (esxVI_RescanHba(priv->primary,
|
|
|
|
priv->primary->hostSystem->configManager->storageSystem,
|
|
|
|
hostInternetScsiHba->device) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolGetInfo(virStoragePoolPtr pool ATTRIBUTE_UNUSED,
|
|
|
|
virStoragePoolInfoPtr info)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
/* These fields are not valid for iSCSI pool */
|
|
|
|
info->allocation = info->capacity = info->available = 0;
|
|
|
|
info->state = VIR_STORAGE_POOL_RUNNING;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
char *xml = NULL;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = pool->conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostInternetScsiHba *hostInternetScsiHba = NULL;
|
|
|
|
esxVI_HostInternetScsiHbaStaticTarget *target;
|
|
|
|
virStoragePoolDef def;
|
|
|
|
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
memset(&def, 0, sizeof(def));
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba))
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (target = hostInternetScsiHba->configuredStaticTarget;
|
2013-10-17 17:04:13 +00:00
|
|
|
target; target = target->_next) {
|
2014-11-13 14:22:20 +00:00
|
|
|
if (STREQ(target->iScsiName, pool->name))
|
2012-11-10 07:18:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!target) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* pool not found */
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Could not find storage pool with name '%s'"),
|
|
|
|
pool->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
def.name = pool->name;
|
|
|
|
|
|
|
|
memcpy(def.uuid, pool->uuid, VIR_UUID_BUFLEN);
|
|
|
|
|
|
|
|
def.type = VIR_STORAGE_POOL_ISCSI;
|
|
|
|
|
|
|
|
def.source.initiator.iqn = target->iScsiName;
|
|
|
|
|
|
|
|
def.source.nhost = 1;
|
|
|
|
|
2013-07-04 10:05:43 +00:00
|
|
|
if (VIR_ALLOC_N(def.source.hosts, def.source.nhost) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
def.source.hosts[0].name = target->address;
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (target->port)
|
2012-11-10 07:18:08 +00:00
|
|
|
def.source.hosts[0].port = target->port->value;
|
|
|
|
|
|
|
|
/* TODO: add CHAP authentication params */
|
|
|
|
xml = virStoragePoolDefFormat(&def);
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
VIR_FREE(def.source.hosts);
|
|
|
|
esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba);
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
int count = 0;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = pool->conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostScsiTopologyLun *hostScsiTopologyLunList = NULL;
|
|
|
|
esxVI_HostScsiTopologyLun *hostScsiTopologyLun;
|
|
|
|
|
|
|
|
if (esxVI_LookupHostScsiTopologyLunListByTargetName
|
|
|
|
(priv->primary, pool->name, &hostScsiTopologyLunList) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (hostScsiTopologyLun = hostScsiTopologyLunList;
|
2013-10-17 17:04:13 +00:00
|
|
|
hostScsiTopologyLun;
|
2012-11-10 07:18:08 +00:00
|
|
|
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
esxVI_HostScsiTopologyLun_Free(&hostScsiTopologyLunList);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names,
|
|
|
|
int maxnames)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
bool success = false;
|
|
|
|
int count = 0;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = pool->conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_HostScsiTopologyLun *hostScsiTopologyLunList = NULL;
|
|
|
|
esxVI_HostScsiTopologyLun *hostScsiTopologyLun;
|
|
|
|
esxVI_ScsiLun *scsiLunList = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLun = NULL;
|
Convert 'int i' to 'size_t i' in src/{esx,vmx,vmware} files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2012-11-10 07:18:08 +00:00
|
|
|
|
|
|
|
if (esxVI_LookupHostScsiTopologyLunListByTargetName
|
|
|
|
(priv->primary, pool->name, &hostScsiTopologyLunList) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
if (!hostScsiTopologyLunList) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* iSCSI adapter may not be enabled on ESX host */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
for (scsiLun = scsiLunList; scsiLun && count < maxnames;
|
2012-11-10 07:18:08 +00:00
|
|
|
scsiLun = scsiLun->_next) {
|
|
|
|
for (hostScsiTopologyLun = hostScsiTopologyLunList;
|
2013-10-17 17:04:13 +00:00
|
|
|
hostScsiTopologyLun && count < maxnames;
|
2012-11-10 07:18:08 +00:00
|
|
|
hostScsiTopologyLun = hostScsiTopologyLun->_next) {
|
|
|
|
if (STREQ(hostScsiTopologyLun->scsiLun, scsiLun->key)) {
|
2013-05-03 12:41:53 +00:00
|
|
|
if (VIR_STRDUP(names[count], scsiLun->deviceName) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
success = true;
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
if (! success) {
|
2014-11-13 14:22:20 +00:00
|
|
|
for (i = 0; i < count; ++i)
|
2012-11-10 07:18:08 +00:00
|
|
|
VIR_FREE(names[i]);
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
esxVI_HostScsiTopologyLun_Free(&hostScsiTopologyLunList);
|
|
|
|
esxVI_ScsiLun_Free(&scsiLunList);
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolLookupByName(virStoragePoolPtr pool,
|
|
|
|
const char *name)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virStorageVolPtr volume = NULL;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = pool->conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_ScsiLun *scsiLunList = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLun;
|
|
|
|
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
|
|
|
|
unsigned char md5[MD5_DIGEST_SIZE];
|
|
|
|
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
for (scsiLun = scsiLunList; scsiLun;
|
2012-11-10 07:18:08 +00:00
|
|
|
scsiLun = scsiLun->_next) {
|
|
|
|
if (STREQ(scsiLun->deviceName, name)) {
|
|
|
|
/*
|
2014-04-20 20:07:46 +00:00
|
|
|
* ScsiLun provides a UUID field that is unique across
|
2012-11-10 07:18:08 +00:00
|
|
|
* multiple servers. But this field length is ~55 characters
|
|
|
|
* compute MD5 hash to transform it to an acceptable
|
|
|
|
* libvirt format
|
|
|
|
*/
|
|
|
|
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
|
|
|
|
virUUIDFormat(md5, uuid_string);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ScsiLun provides displayName and canonicalName but both are
|
|
|
|
* optional and its observed that they can be NULL, using
|
|
|
|
* deviceName to create volume.
|
|
|
|
*/
|
|
|
|
volume = virGetStorageVol(pool->conn, pool->name, name, uuid_string,
|
|
|
|
&esxStorageBackendISCSI, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_ScsiLun_Free(&scsiLunList);
|
|
|
|
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolLookupByPath(virConnectPtr conn, const char *path)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virStorageVolPtr volume = NULL;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_ScsiLun *scsiLunList = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLun;
|
|
|
|
esxVI_HostScsiDisk *hostScsiDisk = NULL;
|
|
|
|
char *poolName = NULL;
|
|
|
|
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
|
|
|
|
unsigned char md5[MD5_DIGEST_SIZE];
|
|
|
|
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) {
|
2012-11-10 07:18:08 +00:00
|
|
|
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
if (hostScsiDisk && STREQ(hostScsiDisk->devicePath, path)) {
|
2012-11-10 07:18:08 +00:00
|
|
|
/* Found matching device */
|
|
|
|
VIR_FREE(poolName);
|
|
|
|
|
|
|
|
if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary,
|
|
|
|
hostScsiDisk->key,
|
|
|
|
&poolName) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
|
|
|
|
virUUIDFormat(md5, uuid_string);
|
|
|
|
|
|
|
|
volume = virGetStorageVol(conn, poolName, path, uuid_string,
|
|
|
|
&esxStorageBackendISCSI, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_ScsiLun_Free(&scsiLunList);
|
|
|
|
VIR_FREE(poolName);
|
|
|
|
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolLookupByKey(virConnectPtr conn, const char *key)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virStorageVolPtr volume = NULL;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
char *poolName = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLunList = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLun;
|
|
|
|
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
|
|
|
|
unsigned char md5[MD5_DIGEST_SIZE];
|
|
|
|
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
|
|
|
|
|
|
|
|
/* key may be LUN device path */
|
2014-11-13 14:22:20 +00:00
|
|
|
if (STRPREFIX(key, "/"))
|
2013-04-29 13:37:58 +00:00
|
|
|
return esxStorageVolLookupByPath(conn, key);
|
2012-11-10 07:18:08 +00:00
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
for (scsiLun = scsiLunList; scsiLun;
|
2012-11-10 07:18:08 +00:00
|
|
|
scsiLun = scsiLun->_next) {
|
|
|
|
memset(uuid_string, '\0', sizeof(uuid_string));
|
|
|
|
memset(md5, '\0', sizeof(md5));
|
|
|
|
|
|
|
|
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
|
|
|
|
virUUIDFormat(md5, uuid_string);
|
|
|
|
|
|
|
|
if (STREQ(key, uuid_string)) {
|
|
|
|
/* Found matching UUID */
|
|
|
|
VIR_FREE(poolName);
|
|
|
|
|
|
|
|
if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary,
|
|
|
|
scsiLun->key,
|
|
|
|
&poolName) < 0) {
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
volume = virGetStorageVol(conn, poolName, scsiLun->deviceName,
|
|
|
|
uuid_string, &esxStorageBackendISCSI,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_ScsiLun_Free(&scsiLunList);
|
|
|
|
VIR_FREE(poolName);
|
|
|
|
|
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolCreateXML(virStoragePoolPtr pool ATTRIBUTE_UNUSED,
|
|
|
|
const char *xmldesc ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
|
|
|
_("iSCSI storage pool does not support volume creation"));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static virStorageVolPtr
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolCreateXMLFrom(virStoragePoolPtr pool ATTRIBUTE_UNUSED,
|
|
|
|
const char *xmldesc ATTRIBUTE_UNUSED,
|
|
|
|
virStorageVolPtr sourceVolume ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
|
|
|
_("iSCSI storage pool does not support volume creation"));
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-25 18:20:41 +00:00
|
|
|
static int
|
|
|
|
esxStorageVolGetInfo(virStorageVolPtr volume,
|
|
|
|
virStorageVolInfoPtr info)
|
|
|
|
{
|
|
|
|
int result = -1;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = volume->conn->privateData;
|
2014-04-25 18:20:41 +00:00
|
|
|
esxVI_ScsiLun *scsiLunList = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLun;
|
|
|
|
esxVI_HostScsiDisk *hostScsiDisk = NULL;
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
|
2014-04-25 18:20:41 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
for (scsiLun = scsiLunList; scsiLun;
|
|
|
|
scsiLun = scsiLun->_next) {
|
|
|
|
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
|
|
|
|
|
|
|
if (hostScsiDisk &&
|
|
|
|
STREQ(hostScsiDisk->deviceName, volume->name)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hostScsiDisk) {
|
|
|
|
virReportError(VIR_ERR_NO_STORAGE_VOL,
|
|
|
|
_("Could not find volume with name: %s"),
|
|
|
|
volume->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->type = VIR_STORAGE_VOL_BLOCK;
|
|
|
|
info->capacity = hostScsiDisk->capacity->block->value *
|
|
|
|
hostScsiDisk->capacity->blockSize->value;
|
|
|
|
info->allocation = info->capacity;
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
esxVI_ScsiLun_Free(&scsiLunList);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-10 07:18:08 +00:00
|
|
|
static char *
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolGetXMLDesc(virStorageVolPtr volume,
|
|
|
|
unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
char *xml = NULL;
|
2014-10-23 13:33:11 +00:00
|
|
|
esxPrivate *priv = volume->conn->privateData;
|
2012-11-10 07:18:08 +00:00
|
|
|
virStoragePoolDef pool;
|
|
|
|
esxVI_ScsiLun *scsiLunList = NULL;
|
|
|
|
esxVI_ScsiLun *scsiLun;
|
|
|
|
esxVI_HostScsiDisk *hostScsiDisk = NULL;
|
|
|
|
virStorageVolDef def;
|
|
|
|
/* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
|
|
|
|
unsigned char md5[MD5_DIGEST_SIZE];
|
|
|
|
char uuid_string[VIR_UUID_STRING_BUFLEN] = "";
|
|
|
|
|
|
|
|
virCheckFlags(0, NULL);
|
|
|
|
|
|
|
|
memset(&pool, 0, sizeof(pool));
|
|
|
|
memset(&def, 0, sizeof(def));
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
for (scsiLun = scsiLunList; scsiLun;
|
2012-11-10 07:18:08 +00:00
|
|
|
scsiLun = scsiLun->_next) {
|
|
|
|
hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun);
|
|
|
|
|
2013-10-17 17:04:13 +00:00
|
|
|
if (hostScsiDisk &&
|
2012-11-10 07:18:08 +00:00
|
|
|
STREQ(hostScsiDisk->deviceName, volume->name)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-31 10:12:13 +00:00
|
|
|
if (!scsiLun) {
|
2012-11-10 07:18:08 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Could find volume with name: %s"), volume->name);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
pool.type = VIR_STORAGE_POOL_ISCSI;
|
|
|
|
|
|
|
|
def.name = volume->name;
|
|
|
|
|
2016-05-31 10:12:13 +00:00
|
|
|
md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5);
|
2012-11-10 07:18:08 +00:00
|
|
|
|
|
|
|
virUUIDFormat(md5, uuid_string);
|
|
|
|
|
2014-11-13 14:22:20 +00:00
|
|
|
if (VIR_STRDUP(def.key, uuid_string) < 0)
|
2012-11-10 07:18:08 +00:00
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* iSCSI LUN exposes a block device */
|
|
|
|
def.type = VIR_STORAGE_VOL_BLOCK;
|
|
|
|
|
|
|
|
def.target.path = hostScsiDisk->devicePath;
|
|
|
|
|
conf: track sizes directly in source struct
One of the features of qcow2 is that a wrapper file can have
more capacity than its backing file from the guest's perspective;
what's more, sparse files make tracking allocation of both
the active and backing file worthwhile. As such, it makes
more sense to show allocation numbers for each file in a chain,
and not just the top-level file. This sets up the fields for
the tracking, although it does not modify XML to display any
new information.
* src/util/virstoragefile.h (_virStorageSource): Add fields.
* src/conf/storage_conf.h (_virStorageVolDef): Drop redundant
fields.
* src/storage/storage_backend.c (virStorageBackendCreateBlockFrom)
(createRawFile, virStorageBackendCreateQemuImgCmd)
(virStorageBackendCreateQcowCreate): Update clients.
* src/storage/storage_driver.c (storageVolDelete)
(storageVolCreateXML, storageVolCreateXMLFrom, storageVolResize)
(storageVolWipeInternal, storageVolGetInfo): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget)
(virStorageBackendFileSystemRefresh)
(virStorageBackendFileSystemVolResize)
(virStorageBackendFileSystemVolRefresh): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol)
(virStorageBackendLogicalCreateVol): Likewise.
* src/storage/storage_backend_scsi.c
(virStorageBackendSCSINewLun): Likewise.
* src/storage/storage_backend_mpath.c
(virStorageBackendMpathNewVol): Likewise.
* src/storage/storage_backend_rbd.c
(volStorageBackendRBDRefreshVolInfo)
(virStorageBackendRBDCreateImage): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol): Likewise.
* src/storage/storage_backend_sheepdog.c
(virStorageBackendSheepdogBuildVol)
(virStorageBackendSheepdogParseVdiList): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.
* src/conf/storage_conf.c (virStorageVolDefFormat)
(virStorageVolDefParseXML): Likewise.
* src/test/test_driver.c (testOpenVolumesForPool)
(testStorageVolCreateXML, testStorageVolCreateXMLFrom)
(testStorageVolDelete, testStorageVolGetInfo): Likewise.
* src/esx/esx_storage_backend_iscsi.c (esxStorageVolGetXMLDesc):
Likewise.
* src/esx/esx_storage_backend_vmfs.c (esxStorageVolGetXMLDesc)
(esxStorageVolCreateXML): Likewise.
* src/parallels/parallels_driver.c (parallelsAddHddByVolume):
Likewise.
* src/parallels/parallels_storage.c (parallelsDiskDescParseNode)
(parallelsStorageVolDefineXML, parallelsStorageVolCreateXMLFrom)
(parallelsStorageVolDefRemove, parallelsStorageVolGetInfo):
Likewise.
* src/vbox/vbox_tmpl.c (vboxStorageVolCreateXML)
(vboxStorageVolGetXMLDesc): Likewise.
* tests/storagebackendsheepdogtest.c (test_vdi_list_parser):
Likewise.
* src/phyp/phyp_driver.c (phypStorageVolCreateXML): Likewise.
2014-04-01 23:43:36 +00:00
|
|
|
def.target.capacity = hostScsiDisk->capacity->block->value *
|
2012-11-10 07:18:08 +00:00
|
|
|
hostScsiDisk->capacity->blockSize->value;
|
|
|
|
|
conf: track sizes directly in source struct
One of the features of qcow2 is that a wrapper file can have
more capacity than its backing file from the guest's perspective;
what's more, sparse files make tracking allocation of both
the active and backing file worthwhile. As such, it makes
more sense to show allocation numbers for each file in a chain,
and not just the top-level file. This sets up the fields for
the tracking, although it does not modify XML to display any
new information.
* src/util/virstoragefile.h (_virStorageSource): Add fields.
* src/conf/storage_conf.h (_virStorageVolDef): Drop redundant
fields.
* src/storage/storage_backend.c (virStorageBackendCreateBlockFrom)
(createRawFile, virStorageBackendCreateQemuImgCmd)
(virStorageBackendCreateQcowCreate): Update clients.
* src/storage/storage_driver.c (storageVolDelete)
(storageVolCreateXML, storageVolCreateXMLFrom, storageVolResize)
(storageVolWipeInternal, storageVolGetInfo): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget)
(virStorageBackendFileSystemRefresh)
(virStorageBackendFileSystemVolResize)
(virStorageBackendFileSystemVolRefresh): Likewise.
* src/storage/storage_backend_logical.c
(virStorageBackendLogicalMakeVol)
(virStorageBackendLogicalCreateVol): Likewise.
* src/storage/storage_backend_scsi.c
(virStorageBackendSCSINewLun): Likewise.
* src/storage/storage_backend_mpath.c
(virStorageBackendMpathNewVol): Likewise.
* src/storage/storage_backend_rbd.c
(volStorageBackendRBDRefreshVolInfo)
(virStorageBackendRBDCreateImage): Likewise.
* src/storage/storage_backend_disk.c
(virStorageBackendDiskMakeDataVol)
(virStorageBackendDiskCreateVol): Likewise.
* src/storage/storage_backend_sheepdog.c
(virStorageBackendSheepdogBuildVol)
(virStorageBackendSheepdogParseVdiList): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageBackendGlusterRefreshVol): Likewise.
* src/conf/storage_conf.c (virStorageVolDefFormat)
(virStorageVolDefParseXML): Likewise.
* src/test/test_driver.c (testOpenVolumesForPool)
(testStorageVolCreateXML, testStorageVolCreateXMLFrom)
(testStorageVolDelete, testStorageVolGetInfo): Likewise.
* src/esx/esx_storage_backend_iscsi.c (esxStorageVolGetXMLDesc):
Likewise.
* src/esx/esx_storage_backend_vmfs.c (esxStorageVolGetXMLDesc)
(esxStorageVolCreateXML): Likewise.
* src/parallels/parallels_driver.c (parallelsAddHddByVolume):
Likewise.
* src/parallels/parallels_storage.c (parallelsDiskDescParseNode)
(parallelsStorageVolDefineXML, parallelsStorageVolCreateXMLFrom)
(parallelsStorageVolDefRemove, parallelsStorageVolGetInfo):
Likewise.
* src/vbox/vbox_tmpl.c (vboxStorageVolCreateXML)
(vboxStorageVolGetXMLDesc): Likewise.
* tests/storagebackendsheepdogtest.c (test_vdi_list_parser):
Likewise.
* src/phyp/phyp_driver.c (phypStorageVolCreateXML): Likewise.
2014-04-01 23:43:36 +00:00
|
|
|
def.target.allocation = def.target.capacity;
|
2012-11-10 07:18:08 +00:00
|
|
|
|
|
|
|
/* iSCSI LUN(s) hosting a datastore will be auto-mounted by ESX host */
|
|
|
|
def.target.format = VIR_STORAGE_FILE_RAW;
|
|
|
|
|
|
|
|
xml = virStorageVolDefFormat(&pool, &def);
|
|
|
|
|
2014-03-25 06:48:48 +00:00
|
|
|
cleanup:
|
2012-11-10 07:18:08 +00:00
|
|
|
esxVI_ScsiLun_Free(&scsiLunList);
|
|
|
|
VIR_FREE(def.key);
|
|
|
|
|
|
|
|
return xml;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolDelete(virStorageVolPtr volume ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
|
|
|
_("iSCSI storage pool does not support volume deletion"));
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolWipe(virStorageVolPtr volume ATTRIBUTE_UNUSED,
|
|
|
|
unsigned int flags)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
|
|
|
virCheckFlags(0, -1);
|
|
|
|
|
|
|
|
|
|
|
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
|
|
|
_("iSCSI storage pool does not support volume wiping"));
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *
|
2013-04-29 13:37:58 +00:00
|
|
|
esxStorageVolGetPath(virStorageVolPtr volume)
|
2012-11-10 07:18:08 +00:00
|
|
|
{
|
2013-05-03 12:41:53 +00:00
|
|
|
char *path;
|
2012-11-10 07:18:08 +00:00
|
|
|
|
2013-05-03 12:41:53 +00:00
|
|
|
ignore_value(VIR_STRDUP(path, volume->name));
|
2012-11-10 07:18:08 +00:00
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virStorageDriver esxStorageBackendISCSI = {
|
2013-04-29 13:37:58 +00:00
|
|
|
.connectNumOfStoragePools = esxConnectNumOfStoragePools, /* 1.0.1 */
|
|
|
|
.connectListStoragePools = esxConnectListStoragePools, /* 1.0.1 */
|
|
|
|
.storagePoolLookupByName = esxStoragePoolLookupByName, /* 1.0.1 */
|
|
|
|
.storagePoolLookupByUUID = esxStoragePoolLookupByUUID, /* 1.0.1 */
|
|
|
|
.storagePoolRefresh = esxStoragePoolRefresh, /* 1.0.1 */
|
|
|
|
.storagePoolGetInfo = esxStoragePoolGetInfo, /* 1.0.1 */
|
|
|
|
.storagePoolGetXMLDesc = esxStoragePoolGetXMLDesc, /* 1.0.1 */
|
|
|
|
.storagePoolNumOfVolumes = esxStoragePoolNumOfVolumes, /* 1.0.1 */
|
|
|
|
.storagePoolListVolumes = esxStoragePoolListVolumes, /* 1.0.1 */
|
|
|
|
.storageVolLookupByName = esxStorageVolLookupByName, /* 1.0.1 */
|
|
|
|
.storageVolLookupByPath = esxStorageVolLookupByPath, /* 1.0.1 */
|
|
|
|
.storageVolLookupByKey = esxStorageVolLookupByKey, /* 1.0.1 */
|
|
|
|
.storageVolCreateXML = esxStorageVolCreateXML, /* 1.0.1 */
|
|
|
|
.storageVolCreateXMLFrom = esxStorageVolCreateXMLFrom, /* 1.0.1 */
|
2014-04-25 18:20:41 +00:00
|
|
|
.storageVolGetInfo = esxStorageVolGetInfo, /* 1.2.5 */
|
2013-04-29 13:37:58 +00:00
|
|
|
.storageVolGetXMLDesc = esxStorageVolGetXMLDesc, /* 1.0.1 */
|
|
|
|
.storageVolDelete = esxStorageVolDelete, /* 1.0.1 */
|
|
|
|
.storageVolWipe = esxStorageVolWipe, /* 1.0.1 */
|
|
|
|
.storageVolGetPath = esxStorageVolGetPath, /* 1.0.1 */
|
2012-11-10 07:18:08 +00:00
|
|
|
};
|