mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-09 13:11:36 +00:00
ESX: add virStorageVolGetInfo in iSCSI backend.
Since the ESX storage implements VMFS and iSCSI storage backends and chooses relevant backend dynamically at runtime, there was a segfault when issuing vol-info on iSCSI volume due to unimplemented virStorageGetInfo function. This patch implements that function that was missing in iSCSI backend and returns expected result without a segfault.
This commit is contained in:
parent
e1e4483c90
commit
77e7a75a8b
@ -621,6 +621,52 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
esxStorageVolGetInfo(virStorageVolPtr volume,
|
||||||
|
virStorageVolInfoPtr info)
|
||||||
|
{
|
||||||
|
int result = -1;
|
||||||
|
esxPrivate *priv = volume->conn->storagePrivateData;
|
||||||
|
esxVI_ScsiLun *scsiLunList = NULL;
|
||||||
|
esxVI_ScsiLun *scsiLun;
|
||||||
|
esxVI_HostScsiDisk *hostScsiDisk = NULL;
|
||||||
|
|
||||||
|
if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
esxStorageVolGetXMLDesc(virStorageVolPtr volume,
|
esxStorageVolGetXMLDesc(virStorageVolPtr volume,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -752,6 +798,7 @@ virStorageDriver esxStorageBackendISCSI = {
|
|||||||
.storageVolLookupByKey = esxStorageVolLookupByKey, /* 1.0.1 */
|
.storageVolLookupByKey = esxStorageVolLookupByKey, /* 1.0.1 */
|
||||||
.storageVolCreateXML = esxStorageVolCreateXML, /* 1.0.1 */
|
.storageVolCreateXML = esxStorageVolCreateXML, /* 1.0.1 */
|
||||||
.storageVolCreateXMLFrom = esxStorageVolCreateXMLFrom, /* 1.0.1 */
|
.storageVolCreateXMLFrom = esxStorageVolCreateXMLFrom, /* 1.0.1 */
|
||||||
|
.storageVolGetInfo = esxStorageVolGetInfo, /* 1.2.5 */
|
||||||
.storageVolGetXMLDesc = esxStorageVolGetXMLDesc, /* 1.0.1 */
|
.storageVolGetXMLDesc = esxStorageVolGetXMLDesc, /* 1.0.1 */
|
||||||
.storageVolDelete = esxStorageVolDelete, /* 1.0.1 */
|
.storageVolDelete = esxStorageVolDelete, /* 1.0.1 */
|
||||||
.storageVolWipe = esxStorageVolWipe, /* 1.0.1 */
|
.storageVolWipe = esxStorageVolWipe, /* 1.0.1 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user