---
src/vbox/vbox_storage.c | 55 +++++++++++++++++++++++++++++++++++++
src/vbox/vbox_tmpl.c | 61 -----------------------------------------
src/vbox/vbox_uniformed_api.h | 1 +
3 files changed, 56 insertions(+), 61 deletions(-)
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 8a3b5a0..2211630 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -839,3 +839,58 @@ char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int
flags)
vboxIIDUnalloc(&hddIID);
return ret;
}
+
+char *vboxStorageVolGetPath(virStorageVolPtr vol)
+{
+ vboxGlobalData *data = vol->conn->privateData;
+ IHardDisk *hardDisk = NULL;
+ PRUnichar *hddLocationUtf16 = NULL;
+ char *hddLocationUtf8 = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIIDUnion hddIID;
+ PRUint32 hddstate;
+ nsresult rc;
+ char *ret = NULL;
+
+ if (!data->vboxObj) {
+ return ret;
+ }
+
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"),
vol->key);
+ return ret;
+ }
+
+ VBOX_IID_INITIALIZE(&hddIID);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = gVBoxAPI.UIVirtualBox.GetHardDiskByIID(data->vboxObj, &hddIID,
&hardDisk);
+ if (NS_FAILED(rc))
+ goto cleanup;
+
+ gVBoxAPI.UIMedium.GetState(hardDisk, &hddstate);
+ if (hddstate == MediaState_Inaccessible)
+ goto cleanup;
+
+ gVBoxAPI.UIMedium.GetLocation(hardDisk, &hddLocationUtf16);
+ if (!hddLocationUtf16)
+ goto cleanup;
+
+ VBOX_UTF16_TO_UTF8(hddLocationUtf16, &hddLocationUtf8);
+ if (!hddLocationUtf8)
+ goto cleanup;
+
+ ignore_value(VIR_STRDUP(ret, hddLocationUtf8));
+
+ VIR_DEBUG("Storage Volume Name: %s", vol->name);
+ VIR_DEBUG("Storage Volume Path: %s", hddLocationUtf8);
+ VIR_DEBUG("Storage Volume Pool: %s", vol->pool);
+
+ VBOX_UTF8_FREE(hddLocationUtf8);
+
+ cleanup:
+ VBOX_UTF16_FREE(hddLocationUtf16);
+ VBOX_MEDIUM_RELEASE(hardDisk);
+ vboxIIDUnalloc(&hddIID);
+ return ret;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 3c8490a..e74c3c4 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2029,67 +2029,6 @@ _registerDomainEvent(virHypervisorDriverPtr driver)
#endif /* !(VBOX_API_VERSION == 2002000 || VBOX_API_VERSION >= 4000000) */
-/**
- * The Storage Functions here on
- */
-
-static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
- VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
- IHardDisk *hardDisk = NULL;
- unsigned char uuid[VIR_UUID_BUFLEN];
- vboxIID hddIID = VBOX_IID_INITIALIZER;
- nsresult rc;
-
- if (virUUIDParse(vol->key, uuid) < 0) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("Could not parse UUID from '%s'"),
vol->key);
- return ret;
- }
-
- vboxIIDFromUUID(&hddIID, uuid);
-#if VBOX_API_VERSION < 4000000
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value,
&hardDisk);
-#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000
- rc = data->vboxObj->vtbl->FindMedium(data->vboxObj, hddIID.value,
- DeviceType_HardDisk, &hardDisk);
-#else
- rc = data->vboxObj->vtbl->OpenMedium(data->vboxObj, hddIID.value,
- DeviceType_HardDisk, AccessMode_ReadWrite,
- PR_FALSE, &hardDisk);
-#endif /* VBOX_API_VERSION >= 4000000 */
- if (NS_SUCCEEDED(rc)) {
- PRUint32 hddstate;
-
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetState, &hddstate);
- if (hddstate != MediaState_Inaccessible) {
- PRUnichar *hddLocationUtf16 = NULL;
- char *hddLocationUtf8 = NULL;
-
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetLocation, &hddLocationUtf16);
-
- VBOX_UTF16_TO_UTF8(hddLocationUtf16, &hddLocationUtf8);
- if (hddLocationUtf8) {
-
- ignore_value(VIR_STRDUP(ret, hddLocationUtf8));
-
- VIR_DEBUG("Storage Volume Name: %s", vol->name);
- VIR_DEBUG("Storage Volume Path: %s", hddLocationUtf8);
- VIR_DEBUG("Storage Volume Pool: %s", vol->pool);
-
- VBOX_UTF8_FREE(hddLocationUtf8);
- }
-
- VBOX_UTF16_FREE(hddLocationUtf16);
- }
-
- VBOX_MEDIUM_RELEASE(hardDisk);
- }
-
- vboxIIDUnalloc(&hddIID);
-
- return ret;
-}
-
static int _pfnInitialize(vboxGlobalData *data)
{
data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION);
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 70deb33..c426f8a 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -624,6 +624,7 @@ virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags);
int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info);
char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags);
+char *vboxStorageVolGetPath(virStorageVolPtr vol);
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5