[libvirt] [PATCH] esx: Add support for storage volume wiping

--- src/esx/esx_storage_driver.c | 50 +++++++++++++++++++++++++++++++++++++++- src/esx/esx_vi_generator.input | 7 +++++ 2 files changed, 56 insertions(+), 1 deletions(-) diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index 544551c..12c8f5e 100644 --- a/src/esx/esx_storage_driver.c +++ b/src/esx/esx_storage_driver.c @@ -1425,6 +1425,54 @@ esxStorageVolumeDelete(virStorageVolPtr volume, unsigned int flags) static int +esxStorageVolumeWipe(virStorageVolPtr volume, unsigned int flags) +{ + int result = -1; + esxPrivate *priv = volume->conn->storagePrivateData; + char *datastorePath = NULL; + esxVI_ManagedObjectReference *task = NULL; + esxVI_TaskInfoState taskInfoState; + char *taskInfoErrorMessage = NULL; + + virCheckFlags(0, -1); + + if (esxVI_EnsureSession(priv->primary) < 0) { + return -1; + } + + if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) { + virReportOOMError(); + goto cleanup; + } + + if (esxVI_ZeroFillVirtualDisk_Task(priv->primary, datastorePath, + priv->primary->datacenter->_reference, + &task) < 0 || + esxVI_WaitForTaskCompletion(priv->primary, task, NULL, + esxVI_Occurrence_None, priv->autoAnswer, + &taskInfoState, &taskInfoErrorMessage) < 0) { + goto cleanup; + } + + if (taskInfoState != esxVI_TaskInfoState_Success) { + ESX_ERROR(VIR_ERR_INTERNAL_ERROR, _("Could not wipe volume: %s"), + taskInfoErrorMessage); + goto cleanup; + } + + result = 0; + + cleanup: + VIR_FREE(datastorePath); + esxVI_ManagedObjectReference_Free(&task); + VIR_FREE(taskInfoErrorMessage); + + return result; +} + + + +static int esxStorageVolumeGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info) { int result = -1; @@ -1623,7 +1671,7 @@ static virStorageDriver esxStorageDriver = { esxStorageVolumeCreateXML, /* volCreateXML */ esxStorageVolumeCreateXMLFrom, /* volCreateXMLFrom */ esxStorageVolumeDelete, /* volDelete */ - NULL, /* volWipe */ + esxStorageVolumeWipe, /* volWipe */ esxStorageVolumeGetInfo, /* volGetInfo */ esxStorageVolumeDumpXML, /* volGetXMLDesc */ esxStorageVolumeGetPath, /* volGetPath */ diff --git a/src/esx/esx_vi_generator.input b/src/esx/esx_vi_generator.input index bd2da11..2d903e4 100644 --- a/src/esx/esx_vi_generator.input +++ b/src/esx/esx_vi_generator.input @@ -916,3 +916,10 @@ method WaitForUpdates returns UpdateSet r ManagedObjectReference _this:PropertyCollector r String version o end + + +method ZeroFillVirtualDisk_Task returns ManagedObjectReference r + ManagedObjectReference _this:VirtualDiskManager r + String name r + ManagedObjectReference datacenter o +end -- 1.7.0.4

On 12/22/2010 10:05 AM, Matthias Bolte wrote:
--- src/esx/esx_storage_driver.c | 50 +++++++++++++++++++++++++++++++++++++++- src/esx/esx_vi_generator.input | 7 +++++ 2 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index 544551c..12c8f5e 100644
Another easy ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

2010/12/22 Eric Blake <eblake@redhat.com>:
On 12/22/2010 10:05 AM, Matthias Bolte wrote:
--- src/esx/esx_storage_driver.c | 50 +++++++++++++++++++++++++++++++++++++++- src/esx/esx_vi_generator.input | 7 +++++ 2 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index 544551c..12c8f5e 100644
Another easy ACK.
Thanks, pushed. Matthias
participants (2)
-
Eric Blake
-
Matthias Bolte