---
src/vbox/vbox_common.c | 68 +++++++++++++++++++++++++++++++++++++++++
src/vbox/vbox_tmpl.c | 65 ---------------------------------------
src/vbox/vbox_uniformed_api.h | 2 ++
3 files changed, 70 insertions(+), 65 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 85c4dd0..88ace96 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -8448,6 +8448,74 @@ int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const
names, int n
return ret;
}
+virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
+{
+ VBOX_OBJECT_CHECK(pool->conn, virStorageVolPtr, NULL);
+ vboxArray hardDisks = VBOX_ARRAY_INITIALIZER;
+ nsresult rc;
+ size_t i;
+
+ if (!name)
+ return ret;
+
+ rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj,
+
gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj));
+ if (NS_FAILED(rc))
+ return ret;
+
+ for (i = 0; i < hardDisks.count; ++i) {
+ IHardDisk *hardDisk = hardDisks.items[i];
+ PRUint32 hddstate;
+ char *nameUtf8 = NULL;
+ PRUnichar *nameUtf16 = NULL;
+
+ if (!hardDisk)
+ continue;
+
+ gVBoxAPI.UIMedium.GetState(hardDisk, &hddstate);
+ if (hddstate == MediaState_Inaccessible)
+ continue;
+
+ gVBoxAPI.UIMedium.GetName(hardDisk, &nameUtf16);
+
+ if (nameUtf16) {
+ VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8);
+ VBOX_UTF16_FREE(nameUtf16);
+ }
+
+ if (nameUtf8 && STREQ(nameUtf8, name)) {
+ vboxIIDUnion hddIID;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ char key[VIR_UUID_STRING_BUFLEN] = "";
+
+ VBOX_IID_INITIALIZE(&hddIID);
+ rc = gVBoxAPI.UIMedium.GetId(hardDisk, &hddIID);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
+
+ ret = virGetStorageVol(pool->conn, pool->name, name, key,
+ NULL, NULL);
+
+ VIR_DEBUG("virStorageVolPtr: %p", ret);
+ VIR_DEBUG("Storage Volume Name: %s", name);
+ VIR_DEBUG("Storage Volume key : %s", key);
+ VIR_DEBUG("Storage Volume Pool: %s", pool->name);
+ }
+
+ vboxIIDUnalloc(&hddIID);
+ VBOX_UTF8_FREE(nameUtf8);
+ break;
+ }
+
+ VBOX_UTF8_FREE(nameUtf8);
+ }
+
+ gVBoxAPI.UArray.vboxArrayRelease(&hardDisks);
+
+ return ret;
+}
+
/**
* Function Tables
*/
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index eac0e9c..a6278e2 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2022,71 +2022,6 @@ _registerDomainEvent(virDriverPtr driver)
*/
static virStorageVolPtr
-vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
-{
- VBOX_OBJECT_CHECK(pool->conn, virStorageVolPtr, NULL);
- vboxArray hardDisks = VBOX_ARRAY_INITIALIZER;
- nsresult rc;
- size_t i;
-
- if (!name)
- return ret;
-
- rc = vboxArrayGet(&hardDisks, data->vboxObj,
data->vboxObj->vtbl->GetHardDisks);
- if (NS_SUCCEEDED(rc)) {
- for (i = 0; i < hardDisks.count; ++i) {
- IHardDisk *hardDisk = hardDisks.items[i];
-
- if (hardDisk) {
- PRUint32 hddstate;
- char *nameUtf8 = NULL;
- PRUnichar *nameUtf16 = NULL;
-
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetState, &hddstate);
- if (hddstate != MediaState_Inaccessible) {
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetName, &nameUtf16);
-
- if (nameUtf16) {
- VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8);
- VBOX_UTF16_FREE(nameUtf16);
- }
-
- if (nameUtf8 && STREQ(nameUtf8, name)) {
- vboxIID hddIID = VBOX_IID_INITIALIZER;
- unsigned char uuid[VIR_UUID_BUFLEN];
- char key[VIR_UUID_STRING_BUFLEN] = "";
-
- rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
- if (NS_SUCCEEDED(rc)) {
- vboxIIDToUUID(&hddIID, uuid);
- virUUIDFormat(uuid, key);
-
- ret = virGetStorageVol(pool->conn, pool->name, name,
key,
- NULL, NULL);
-
- VIR_DEBUG("virStorageVolPtr: %p", ret);
- VIR_DEBUG("Storage Volume Name: %s", name);
- VIR_DEBUG("Storage Volume key : %s", key);
- VIR_DEBUG("Storage Volume Pool: %s",
pool->name);
- }
-
- vboxIIDUnalloc(&hddIID);
- VBOX_UTF8_FREE(nameUtf8);
- break;
- }
-
- VBOX_UTF8_FREE(nameUtf8);
- }
- }
- }
-
- vboxArrayRelease(&hardDisks);
- }
-
- return ret;
-}
-
-static virStorageVolPtr
vboxStorageVolLookupByKey(virConnectPtr conn, const char *key)
{
VBOX_OBJECT_CHECK(conn, virStorageVolPtr, NULL);
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index ed72447..595a544 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -597,6 +597,8 @@ int vboxConnectListStoragePools(virConnectPtr conn, char **const
names, int nnam
virStoragePoolPtr vboxStoragePoolLookupByName(virConnectPtr conn, const char *name);
int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool);
int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nnames);
+virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name);
+
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5