[libvirt] [PATCH] vbox: Handle different IID representation in Version 2.2 on Windows
by Matthias Bolte
On Windows IID's are represented as GUID by value, instead of nsID
by reference on non-Windows platforms.
Patch the vbox_CAPI_v2_2.h header to deal with this difference.
Rewrite vboxIID abstraction that deals with the different IID
representations. Add support for the GUID representation. Also unify
the four context dependent free functions for vboxIIDs
vboxIIDUnalloc, vboxIIDFree, vboxIIDUtf8Free, vboxIIDUtf16Free
into vboxIIDUnalloc that is now safe to be called (even multiple
times) on a vboxIID independent of the source and context of the
vboxIID.
The new vboxIID is designed to be used as a stack allocated variable.
It has a value member that represents the actual IID value.
---
src/vbox/vbox_CAPI_v2_2.h | 108 +++--
src/vbox/vbox_tmpl.c | 1143 +++++++++++++++++++++------------------------
2 files changed, 582 insertions(+), 669 deletions(-)
diff --git a/src/vbox/vbox_CAPI_v2_2.h b/src/vbox/vbox_CAPI_v2_2.h
index 0543fdd..a94d2ec 100644
--- a/src/vbox/vbox_CAPI_v2_2.h
+++ b/src/vbox/vbox_CAPI_v2_2.h
@@ -57,8 +57,12 @@
# ifdef WIN32
# define PR_COM_METHOD __stdcall
+# define PR_IID_IN_TYPE GUID
+# define PR_IID_OUT_TYPE GUID *
# else
# define PR_COM_METHOD
+# define PR_IID_IN_TYPE const nsID *
+# define PR_IID_OUT_TYPE nsID **
# endif
# if defined(WIN32)
@@ -355,7 +359,7 @@ struct nsISupports_vtbl {
* instance, NS_NOINTERFACE if it is not.
* NS_ERROR_INVALID_POINTER if aInstancePtr is NULL.
*/
- nsresult PR_COM_METHOD (*QueryInterface)(nsISupports *pThis, const nsID *iid, void **resultp);
+ nsresult PR_COM_METHOD (*QueryInterface)(nsISupports *pThis, PR_IID_IN_TYPE iid, void **resultp);
/**
* Increases the reference count for this interface.
* The associated instance will not be deleted unless
@@ -1396,7 +1400,7 @@ struct IVirtualBoxErrorInfo_vtbl
nsresult PR_COM_METHOD (*GetResultCode)(IVirtualBoxErrorInfo *pThis, nsresult *resultCode);
- nsresult PR_COM_METHOD (*GetInterfaceID)(IVirtualBoxErrorInfo *pThis, nsID * *interfaceID);
+ nsresult PR_COM_METHOD (*GetInterfaceID)(IVirtualBoxErrorInfo *pThis, PR_IID_OUT_TYPE interfaceID);
nsresult PR_COM_METHOD (*GetComponent)(IVirtualBoxErrorInfo *pThis, PRUnichar * *component);
@@ -1425,18 +1429,18 @@ struct IVirtualBoxCallback_vtbl
nsresult PR_COM_METHOD (*OnMachineStateChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUint32 state
);
nsresult PR_COM_METHOD (*OnMachineDataChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId
+ PR_IID_IN_TYPE machineId
);
nsresult PR_COM_METHOD (*OnExtraDataCanChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * key,
PRUnichar * value,
PRUnichar * * error,
@@ -1445,51 +1449,51 @@ struct IVirtualBoxCallback_vtbl
nsresult PR_COM_METHOD (*OnExtraDataChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * key,
PRUnichar * value
);
nsresult PR_COM_METHOD (*OnMediaRegistered)(
IVirtualBoxCallback *pThis,
- const nsID * mediaId,
+ PR_IID_IN_TYPE mediaId,
PRUint32 mediaType,
PRBool registered
);
nsresult PR_COM_METHOD (*OnMachineRegistered)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRBool registered
);
nsresult PR_COM_METHOD (*OnSessionStateChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUint32 state
);
nsresult PR_COM_METHOD (*OnSnapshotTaken)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
- const nsID * snapshotId
+ PR_IID_IN_TYPE machineId,
+ PR_IID_IN_TYPE snapshotId
);
nsresult PR_COM_METHOD (*OnSnapshotDiscarded)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
- const nsID * snapshotId
+ PR_IID_IN_TYPE machineId,
+ PR_IID_IN_TYPE snapshotId
);
nsresult PR_COM_METHOD (*OnSnapshotChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
- const nsID * snapshotId
+ PR_IID_IN_TYPE machineId,
+ PR_IID_IN_TYPE snapshotId
);
nsresult PR_COM_METHOD (*OnGuestPropertyChange)(
IVirtualBoxCallback *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * name,
PRUnichar * value,
PRUnichar * flags
@@ -1614,7 +1618,7 @@ struct IVirtualBox_vtbl
PRUnichar * name,
PRUnichar * osTypeId,
PRUnichar * baseFolder,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1623,7 +1627,7 @@ struct IVirtualBox_vtbl
PRUnichar * name,
PRUnichar * osTypeId,
PRUnichar * settingsFile,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1640,7 +1644,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*GetMachine)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1652,7 +1656,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*UnregisterMachine)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IMachine * * machine
);
@@ -1677,7 +1681,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*GetHardDisk)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IHardDisk * * hardDisk
);
@@ -1690,13 +1694,13 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenDVDImage)(
IVirtualBox *pThis,
PRUnichar * location,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IDVDImage * * image
);
nsresult PR_COM_METHOD (*GetDVDImage)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IDVDImage * * image
);
@@ -1709,13 +1713,13 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenFloppyImage)(
IVirtualBox *pThis,
PRUnichar * location,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IFloppyImage * * image
);
nsresult PR_COM_METHOD (*GetFloppyImage)(
IVirtualBox *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IFloppyImage * * image
);
@@ -1765,13 +1769,13 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenSession)(
IVirtualBox *pThis,
ISession * session,
- const nsID * machineId
+ PR_IID_IN_TYPE machineId
);
nsresult PR_COM_METHOD (*OpenRemoteSession)(
IVirtualBox *pThis,
ISession * session,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUnichar * type,
PRUnichar * environment,
IProgress * * progress
@@ -1780,7 +1784,7 @@ struct IVirtualBox_vtbl
nsresult PR_COM_METHOD (*OpenExistingSession)(
IVirtualBox *pThis,
ISession * session,
- const nsID * machineId
+ PR_IID_IN_TYPE machineId
);
nsresult PR_COM_METHOD (*RegisterCallback)(
@@ -1988,12 +1992,12 @@ struct IInternalMachineControl_vtbl
nsresult PR_COM_METHOD (*CaptureUSBDevice)(
IInternalMachineControl *pThis,
- const nsID * id
+ PR_IID_IN_TYPE id
);
nsresult PR_COM_METHOD (*DetachUSBDevice)(
IInternalMachineControl *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
PRBool done
);
@@ -2044,7 +2048,7 @@ struct IInternalMachineControl_vtbl
nsresult PR_COM_METHOD (*DiscardSnapshot)(
IInternalMachineControl *pThis,
IConsole * initiator,
- const nsID * id,
+ PR_IID_IN_TYPE id,
PRUint32 * machineState,
IProgress * * progress
);
@@ -2174,7 +2178,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*GetDescription)(IMachine *pThis, PRUnichar * *description);
nsresult PR_COM_METHOD (*SetDescription)(IMachine *pThis, PRUnichar * description);
- nsresult PR_COM_METHOD (*GetId)(IMachine *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IMachine *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetOSTypeId)(IMachine *pThis, PRUnichar * *OSTypeId);
nsresult PR_COM_METHOD (*SetOSTypeId)(IMachine *pThis, PRUnichar * OSTypeId);
@@ -2282,7 +2286,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*AttachHardDisk)(
IMachine *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
PRUnichar * name,
PRInt32 controllerPort,
PRInt32 device
@@ -2384,7 +2388,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*GetSnapshot)(
IMachine *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
ISnapshot * * snapshot
);
@@ -2396,7 +2400,7 @@ struct IMachine_vtbl
nsresult PR_COM_METHOD (*SetCurrentSnapshot)(
IMachine *pThis,
- const nsID * id
+ PR_IID_IN_TYPE id
);
nsresult PR_COM_METHOD (*CreateSharedFolder)(
@@ -2716,12 +2720,12 @@ struct IConsole_vtbl
nsresult PR_COM_METHOD (*AttachUSBDevice)(
IConsole *pThis,
- const nsID * id
+ PR_IID_IN_TYPE id
);
nsresult PR_COM_METHOD (*DetachUSBDevice)(
IConsole *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IUSBDevice * * device
);
@@ -2733,7 +2737,7 @@ struct IConsole_vtbl
nsresult PR_COM_METHOD (*FindUSBDeviceById)(
IConsole *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IUSBDevice * * device
);
@@ -2758,7 +2762,7 @@ struct IConsole_vtbl
nsresult PR_COM_METHOD (*DiscardSnapshot)(
IConsole *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IProgress * * progress
);
@@ -2853,7 +2857,7 @@ struct IHostNetworkInterface_vtbl
nsresult PR_COM_METHOD (*GetName)(IHostNetworkInterface *pThis, PRUnichar * *name);
- nsresult PR_COM_METHOD (*GetId)(IHostNetworkInterface *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IHostNetworkInterface *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetNetworkName)(IHostNetworkInterface *pThis, PRUnichar * *networkName);
@@ -2992,7 +2996,7 @@ struct IHost_vtbl
nsresult PR_COM_METHOD (*FindHostNetworkInterfaceById)(
IHost *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IHostNetworkInterface * * networkInterface
);
@@ -3005,7 +3009,7 @@ struct IHost_vtbl
nsresult PR_COM_METHOD (*FindUSBDeviceById)(
IHost *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IHostUSBDevice * * device
);
@@ -3189,7 +3193,7 @@ struct IProgress_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(IProgress *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IProgress *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetDescription)(IProgress *pThis, PRUnichar * *description);
@@ -3249,7 +3253,7 @@ struct ISnapshot_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(ISnapshot *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(ISnapshot *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetName)(ISnapshot *pThis, PRUnichar * *name);
nsresult PR_COM_METHOD (*SetName)(ISnapshot *pThis, PRUnichar * name);
@@ -3286,7 +3290,7 @@ struct IMedium_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(IMedium *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IMedium *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetDescription)(IMedium *pThis, PRUnichar * *description);
nsresult PR_COM_METHOD (*SetDescription)(IMedium *pThis, PRUnichar * description);
@@ -3302,11 +3306,11 @@ struct IMedium_vtbl
nsresult PR_COM_METHOD (*GetLastAccessError)(IMedium *pThis, PRUnichar * *lastAccessError);
- nsresult PR_COM_METHOD (*GetMachineIds)(IMedium *pThis, PRUint32 *machineIdsSize, nsID * **machineIds);
+ nsresult PR_COM_METHOD (*GetMachineIds)(IMedium *pThis, PRUint32 *machineIdsSize, PR_IID_OUT_TYPE *machineIds);
nsresult PR_COM_METHOD (*GetSnapshotIds)(
IMedium *pThis,
- const nsID * machineId,
+ PR_IID_IN_TYPE machineId,
PRUint32 *snapshotIdsSize,
nsID *** snapshotIds
);
@@ -3447,7 +3451,7 @@ struct IHardDisk_vtbl
nsresult PR_COM_METHOD (*MergeTo)(
IHardDisk *pThis,
- const nsID * targetId,
+ PR_IID_IN_TYPE targetId,
IProgress * * progress
);
@@ -3574,7 +3578,7 @@ struct IDVDDrive_vtbl
nsresult PR_COM_METHOD (*MountImage)(
IDVDDrive *pThis,
- const nsID * imageId
+ PR_IID_IN_TYPE imageId
);
nsresult PR_COM_METHOD (*CaptureHostDrive)(
@@ -3620,7 +3624,7 @@ struct IFloppyDrive_vtbl
nsresult PR_COM_METHOD (*MountImage)(
IFloppyDrive *pThis,
- const nsID * imageId
+ PR_IID_IN_TYPE imageId
);
nsresult PR_COM_METHOD (*CaptureHostDrive)(
@@ -4221,7 +4225,7 @@ struct IUSBDevice_vtbl
{
struct nsISupports_vtbl nsisupports;
- nsresult PR_COM_METHOD (*GetId)(IUSBDevice *pThis, nsID * *id);
+ nsresult PR_COM_METHOD (*GetId)(IUSBDevice *pThis, PR_IID_OUT_TYPE id);
nsresult PR_COM_METHOD (*GetVendorId)(IUSBDevice *pThis, PRUint16 *vendorId);
@@ -4523,7 +4527,7 @@ struct IInternalSessionControl_vtbl
nsresult PR_COM_METHOD (*OnUSBDeviceDetach)(
IInternalSessionControl *pThis,
- const nsID * id,
+ PR_IID_IN_TYPE id,
IVirtualBoxErrorInfo * error
);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 728c501..aa1afa9 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -220,14 +220,6 @@ static void vboxDriverUnlock(vboxGlobalData *data) {
#if VBOX_API_VERSION == 2002
-# define vboxIIDFromUUID(uuid, iid) nsIDFromChar((iid), (uuid))
-# define vboxIIDToUUID(uuid, iid) nsIDtoChar((uuid), (iid))
-# define vboxIIDUnalloc(iid) data->pFuncs->pfnComUnallocMem(iid)
-# define vboxIIDFree(iid) VIR_FREE(iid)
-# define vboxIIDUtf8Free(iid) VIR_FREE(iid)
-# define vboxIIDUtf16Free(iid) VIR_FREE(iid)
-# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
-
static void nsIDtoChar(unsigned char *uuid, const nsID *iid) {
char uuidstrsrc[VIR_UUID_STRING_BUFLEN];
char uuidstrdst[VIR_UUID_STRING_BUFLEN];
@@ -308,107 +300,229 @@ static void nsIDFromChar(nsID *iid, const unsigned char *uuid) {
memcpy(iid, uuidinterim, VIR_UUID_BUFLEN);
}
-typedef nsID vboxIID;
+# ifdef WIN32
-static bool vboxIIDEqual(vboxIID *firstIID, vboxIID *secondIID) {
- if (memcmp(firstIID, secondIID, sizeof(firstIID)) == 0)
- return true;
- else
- return false;
+typedef struct _vboxIID_v2_x_WIN32 vboxIID;
+typedef struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32;
+
+struct _vboxIID_v2_x_WIN32 {
+ /* IID is represented by a GUID value. */
+ GUID value;
+};
+
+# define VBOX_IID_INITIALIZER { { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } }
+
+static void
+vboxIIDUnalloc_v2_x_WIN32(vboxGlobalData *data ATTRIBUTE_UNUSED,
+ vboxIID_v2_x_WIN32 *iid ATTRIBUTE_UNUSED)
+{
+ /* Nothing to free */
}
-static void vboxIIDtoUtf8(vboxIID *iid, char **uuidstr) {
- unsigned char hddUUID[VIR_UUID_BUFLEN];
+static void
+vboxIIDToUUID_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid, unsigned char *uuid)
+{
+ nsIDtoChar(uuid, (nsID *)&iid->value);
+}
- if (VIR_ALLOC_N(*uuidstr, VIR_UUID_STRING_BUFLEN) < 0) {
- virReportOOMError();
- return;
- }
+static void
+vboxIIDFromUUID_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid,
+ const unsigned char *uuid)
+{
+ vboxIIDUnalloc_v2_x_WIN32(data, iid);
- vboxIIDToUUID(hddUUID, iid);
- virUUIDFormat(hddUUID, *uuidstr);
+ nsIDFromChar((nsID *)&iid->value, uuid);
}
-static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
- unsigned char hddUUID[VIR_UUID_BUFLEN];
+static bool
+vboxIIDIsEqual_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid1, vboxIID_v2_x_WIN32 *iid2)
+{
+ return memcmp(&iid1->value, &iid2->value, sizeof (GUID)) == 0;
+}
- if (VIR_ALLOC(*iid) < 0) {
- virReportOOMError();
+static void
+vboxIIDFromArrayItem_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid,
+ vboxArray *array, int idx)
+{
+ GUID *items = (GUID *)array->items;
+
+ vboxIIDUnalloc_v2_x_WIN32(data, iid);
+
+ memcpy(&iid->value, &items[idx], sizeof (GUID));
+}
+
+# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x_WIN32(data, iid)
+# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x_WIN32(iid, uuid)
+# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x_WIN32(data, iid, uuid)
+# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x_WIN32(iid1, iid2)
+# define vboxIIDFromArrayItem(iid, array, idx) \
+ vboxIIDFromArrayItem_v2_x_WIN32(data, iid, array, idx)
+# define DEBUGIID(msg, iid) DEBUGUUID(msg, (nsID *)&(iid))
+
+# else /* !WIN32 */
+
+typedef struct _vboxIID_v2_x vboxIID;
+typedef struct _vboxIID_v2_x vboxIID_v2_x;
+
+struct _vboxIID_v2_x {
+ /* IID is represented by a pointer to a nsID. */
+ nsID *value;
+
+ /* backing is used in cases where we need to create or copy an IID.
+ * We cannot allocate memory that can be freed by ComUnallocMem.
+ * Therefore, we use this stack allocated nsID instead. */
+ nsID backing;
+};
+
+# define VBOX_IID_INITIALIZER { NULL, { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } }
+
+static void
+vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid)
+{
+ if (iid->value == NULL) {
return;
}
- virUUIDParse(uuidstr, hddUUID);
- vboxIIDFromUUID(hddUUID, *iid);
+ if (iid->value != &iid->backing) {
+ data->pFuncs->pfnComUnallocMem(iid->value);
+ }
+
+ iid->value = NULL;
}
+static void
+vboxIIDToUUID_v2_x(vboxIID_v2_x *iid, unsigned char *uuid)
+{
+ nsIDtoChar(uuid, iid->value);
+}
+
+static void
+vboxIIDFromUUID_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid,
+ const unsigned char *uuid)
+{
+ vboxIIDUnalloc_v2_x(data, iid);
+
+ iid->value = &iid->backing;
+
+ nsIDFromChar(iid->value, uuid);
+}
+
+static bool
+vboxIIDIsEqual_v2_x(vboxIID_v2_x *iid1, vboxIID_v2_x *iid2)
+{
+ return memcmp(iid1->value, iid2->value, sizeof (nsID)) == 0;
+}
+
+static void
+vboxIIDFromArrayItem_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid,
+ vboxArray *array, int idx)
+{
+ vboxIIDUnalloc_v2_x(data, iid);
+
+ iid->value = &iid->backing;
+
+ memcpy(iid->value, array->items[idx], sizeof (nsID));
+}
+
+# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x(data, iid)
+# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x(iid, uuid)
+# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x(data, iid, uuid)
+# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x(iid1, iid2)
+# define vboxIIDFromArrayItem(iid, array, idx) \
+ vboxIIDFromArrayItem_v2_x(data, iid, array, idx)
+# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
+
+# endif /* !WIN32 */
+
#else /* VBOX_API_VERSION != 2002 */
-# define vboxIIDFromUUID(uuid, iid)\
-{\
- char vboxIIDUtf8[VIR_UUID_STRING_BUFLEN];\
-\
- virUUIDFormat((uuid), vboxIIDUtf8);\
- data->pFuncs->pfnUtf8ToUtf16(vboxIIDUtf8, (&(iid)));\
+typedef struct _vboxIID_v3_x vboxIID;
+typedef struct _vboxIID_v3_x vboxIID_v3_x;
+
+struct _vboxIID_v3_x {
+ /* IID is represented by a UTF-16 encoded UUID in string form. */
+ PRUnichar *value;
+
+ /* owner indicates if we own the value and need to free it. */
+ bool owner;
+};
+
+# define VBOX_IID_INITIALIZER { NULL, true }
+
+static void
+vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid)
+{
+ if (iid->value != NULL && iid->owner) {
+ data->pFuncs->pfnUtf16Free(iid->value);
+ }
+
+ iid->value = NULL;
+ iid->owner = true;
}
-# define vboxIIDToUUID(uuid, iid)\
-{\
- char *vboxIIDUtf8 = NULL;\
- data->pFuncs->pfnUtf16ToUtf8((iid), &vboxIIDUtf8);\
- virUUIDParse(vboxIIDUtf8, (uuid));\
- data->pFuncs->pfnUtf8Free(vboxIIDUtf8);\
+static void
+vboxIIDToUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
+ unsigned char *uuid)
+{
+ char *utf8 = NULL;
+
+ data->pFuncs->pfnUtf16ToUtf8(iid->value, &utf8);
+
+ virUUIDParse(utf8, uuid);
+
+ data->pFuncs->pfnUtf8Free(utf8);
}
-# define vboxIIDFree(iid) data->pFuncs->pfnUtf16Free(iid)
-# define vboxIIDUtf8Free(iid) data->pFuncs->pfnUtf8Free(iid)
-# define vboxIIDUtf16Free(iid) data->pFuncs->pfnUtf16Free(iid)
-# define vboxIIDUnalloc(iid) data->pFuncs->pfnUtf16Free(iid)
-# define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
+static void
+vboxIIDFromUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
+ const unsigned char *uuid)
+{
+ char utf8[VIR_UUID_STRING_BUFLEN];
-typedef PRUnichar vboxIID;
+ vboxIIDUnalloc_v3_x(data, iid);
-static bool vboxIIDEqual(vboxIID *firstIID, vboxIID *secondIID) {
- unsigned char firstUUID[VIR_UUID_BUFLEN];
- unsigned char secondUUID[VIR_UUID_BUFLEN];
- char *firstIIDUtf8 = NULL;
- char *secondIIDUtf8 = NULL;
+ virUUIDFormat(uuid, utf8);
- if (!g_pVBoxGlobalData)
- return false;
+ data->pFuncs->pfnUtf8ToUtf16(utf8, &iid->value);
+}
- g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(firstIID, &firstIIDUtf8);
- g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(secondIID, &secondIIDUtf8);
+static bool
+vboxIIDIsEqual_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid1,
+ vboxIID_v3_x *iid2)
+{
+ unsigned char uuid1[VIR_UUID_BUFLEN];
+ unsigned char uuid2[VIR_UUID_BUFLEN];
/* Note: we can't directly compare the utf8 strings here
* cause the two UUID's may have seperators as space or '-'
* or mixture of both and we don't want to fail here by
* using direct string comparison. Here virUUIDParse() takes
- * care of these cases.
- */
+ * care of these cases. */
+ vboxIIDToUUID_v3_x(data, iid1, uuid1);
+ vboxIIDToUUID_v3_x(data, iid2, uuid2);
- virUUIDParse(firstIIDUtf8, firstUUID);
- virUUIDParse(secondIIDUtf8, secondUUID);
+ return memcmp(uuid1, uuid2, VIR_UUID_BUFLEN) == 0;
+}
- g_pVBoxGlobalData->pFuncs->pfnUtf8Free(firstIIDUtf8);
- g_pVBoxGlobalData->pFuncs->pfnUtf8Free(secondIIDUtf8);
- if (memcmp(firstUUID, secondUUID, sizeof(firstIID)) == 0)
- return true;
- else
- return false;
-}
+static void
+vboxIIDFromArrayItem_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
+ vboxArray *array, int idx)
+{
+ vboxIIDUnalloc_v3_x(data, iid);
-static void vboxIIDtoUtf8(vboxIID *iid, char **uuidstr) {
- g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(iid, uuidstr);
- if (!(*uuidstr))
- virReportOOMError();
+ iid->value = array->items[idx];
+ iid->owner = false;
}
-static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
- g_pVBoxGlobalData->pFuncs->pfnUtf8ToUtf16(uuidstr, iid);
- if (!(*iid))
- virReportOOMError();
-}
+
+# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v3_x(data, iid)
+# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v3_x(data, iid, uuid)
+# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v3_x(data, iid, uuid)
+# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v3_x(data, iid1, iid2)
+# define vboxIIDFromArrayItem(iid, array, idx) \
+ vboxIIDFromArrayItem_v3_x(data, iid, array, idx)
+# define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
# if VBOX_API_VERSION >= 3001
@@ -1044,8 +1158,8 @@ static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ vboxIID iid = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
PRUint32 state;
nsresult rc;
@@ -1081,9 +1195,9 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
machine->vtbl->GetName(machine, &machineNameUtf16);
VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineNameUtf8);
- machine->vtbl->GetId(machine, &iid);
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ machine->vtbl->GetId(machine, &iid.value);
+ vboxIIDToUUID(&iid, uuid);
+ vboxIIDUnalloc(&iid);
/* get a new domain pointer from virGetDomain, if it fails
* then no need to assign the id, else assign the id, cause
@@ -1091,7 +1205,7 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
* itself, so need not worry.
*/
- ret = virGetDomain(conn, machineNameUtf8, iidl);
+ ret = virGetDomain(conn, machineNameUtf8, uuid);
if (ret)
ret->id = id + 1;
@@ -1111,10 +1225,10 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) {
static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
char *machineNameUtf8 = NULL;
PRUnichar *machineNameUtf16 = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ unsigned char iid_as_uuid[VIR_UUID_BUFLEN];
int i, matched = 0;
nsresult rc;
@@ -1135,13 +1249,13 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
machine->vtbl->GetAccessible(machine, &isAccessible);
if (isAccessible) {
- machine->vtbl->GetId(machine, &iid);
- if (!iid)
+ rc = machine->vtbl->GetId(machine, &iid.value);
+ if (NS_FAILED(rc))
continue;
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ vboxIIDToUUID(&iid, iid_as_uuid);
+ vboxIIDUnalloc(&iid);
- if (memcmp(uuid, iidl, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(uuid, iid_as_uuid, VIR_UUID_BUFLEN) == 0) {
PRUint32 state;
@@ -1158,7 +1272,7 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
* itself, so need not worry.
*/
- ret = virGetDomain(conn, machineNameUtf8, iidl);
+ ret = virGetDomain(conn, machineNameUtf8, iid_as_uuid);
if ( ret
&& (state >= MachineState_FirstOnline)
&& (state <= MachineState_LastOnline) )
@@ -1181,10 +1295,10 @@ static virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, const unsigned ch
static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
char *machineNameUtf8 = NULL;
PRUnichar *machineNameUtf16 = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ unsigned char uuid[VIR_UUID_BUFLEN];
int i, matched = 0;
nsresult rc;
@@ -1214,9 +1328,9 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
matched = 1;
- machine->vtbl->GetId(machine, &iid);
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ machine->vtbl->GetId(machine, &iid.value);
+ vboxIIDToUUID(&iid, uuid);
+ vboxIIDUnalloc(&iid);
machine->vtbl->GetState(machine, &state);
@@ -1226,7 +1340,7 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
* itself, so need not worry.
*/
- ret = virGetDomain(conn, machineNameUtf8, iidl);
+ ret = virGetDomain(conn, machineNameUtf8, uuid);
if ( ret
&& (state >= MachineState_FirstOnline)
&& (state <= MachineState_LastOnline) )
@@ -1255,10 +1369,10 @@ static virDomainPtr vboxDomainLookupByName(virConnectPtr conn, const char *name)
static int vboxDomainIsActive(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
char *machineNameUtf8 = NULL;
PRUnichar *machineNameUtf16 = NULL;
- unsigned char iidl[VIR_UUID_BUFLEN];
+ unsigned char uuid[VIR_UUID_BUFLEN];
int i, matched = 0;
nsresult rc;
@@ -1279,13 +1393,13 @@ static int vboxDomainIsActive(virDomainPtr dom) {
machine->vtbl->GetAccessible(machine, &isAccessible);
if (isAccessible) {
- machine->vtbl->GetId(machine, &iid);
- if (!iid)
+ rc = machine->vtbl->GetId(machine, &iid.value);
+ if (NS_FAILED(rc))
continue;
- vboxIIDToUUID(iidl, iid);
- vboxIIDUnalloc(iid);
+ vboxIIDToUUID(&iid, uuid);
+ vboxIIDUnalloc(&iid);
- if (memcmp(dom->uuid, iidl, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(dom->uuid, uuid, VIR_UUID_BUFLEN) == 0) {
PRUint32 state;
@@ -1330,21 +1444,14 @@ static int vboxDomainIsUpdated(virDomainPtr dom ATTRIBUTE_UNUSED) {
static int vboxDomainSuspend(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRBool isAccessible = PR_FALSE;
PRUint32 state;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1360,7 +1467,7 @@ static int vboxDomainSuspend(virDomainPtr dom) {
if (state == MachineState_Running) {
/* set state pause */
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Pause(console);
@@ -1381,29 +1488,22 @@ static int vboxDomainSuspend(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainResume(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
PRBool isAccessible = PR_FALSE;
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1419,7 +1519,7 @@ static int vboxDomainResume(virDomainPtr dom) {
if (state == MachineState_Paused) {
/* resume the machine here */
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Resume(console);
@@ -1440,28 +1540,21 @@ static int vboxDomainResume(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainShutdown(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1485,7 +1578,7 @@ static int vboxDomainShutdown(virDomainPtr dom) {
goto cleanup;
}
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->PowerButton(console);
@@ -1497,28 +1590,21 @@ static int vboxDomainShutdown(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1533,7 +1619,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
machine->vtbl->GetState(machine, &state);
if (state == MachineState_Running) {
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
console->vtbl->Reset(console);
@@ -1550,28 +1636,21 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
static int vboxDomainDestroy(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IConsole *console = NULL;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1591,7 +1670,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
goto cleanup;
}
- data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (console) {
@@ -1614,7 +1693,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1635,20 +1714,13 @@ static char *vboxDomainGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) {
static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 state = MachineState_Null;
PRBool isAccessible = PR_FALSE;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN,
_("no domain with matching id %d"), dom->id);
@@ -1668,7 +1740,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
goto cleanup;
}
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (NS_SUCCEEDED(rc) && machine) {
@@ -1690,7 +1762,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1801,7 +1873,7 @@ cleanup:
static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IConsole *console = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
/* VirtualBox currently doesn't support saving to a file
@@ -1810,16 +1882,10 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
* this behaviour once get the VirtualBox API in right
* shape to do this
*/
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
/* Open a Session for the machine */
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_SUCCEEDED(rc) && console) {
@@ -1846,12 +1912,9 @@ static int vboxDomainSave(virDomainPtr dom, const char *path ATTRIBUTE_UNUSED) {
data->vboxSession->vtbl->Close(data->vboxSession);
}
- DEBUGIID("UUID of machine being saved:", iid);
+ DEBUGIID("UUID of machine being saved:", iid.value);
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1861,7 +1924,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 CPUCount = nvcpus;
nsresult rc;
@@ -1870,16 +1933,8 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
return -1;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
-
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (machine) {
@@ -1904,10 +1959,7 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
data->vboxSession->vtbl->Close(data->vboxSession);
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -1957,26 +2009,19 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
virDomainDefPtr def = NULL;
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
int gotAllABoutDef = -1;
nsresult rc;
char *tmp;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
goto cleanup;
}
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
- if (NS_SUCCEEDED(rc) && machine) {
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ if (NS_SUCCEEDED(rc)) {
PRBool accessible = PR_FALSE;
machine->vtbl->GetAccessible(machine, &accessible);
@@ -3077,7 +3122,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
ret = virDomainDefFormat(def, flags);
cleanup:
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
return ret;
}
@@ -3301,7 +3346,7 @@ vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
rc = data->vboxObj->vtbl->OpenRemoteSession(data->vboxObj,
data->vboxSession,
- iid,
+ iid->value,
sessionType,
env,
&progress );
@@ -3346,7 +3391,7 @@ vboxStartMachine(virDomainPtr dom, int i, IMachine *machine, vboxIID *iid)
static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
vboxArray machines = VBOX_ARRAY_INITIALIZER;
- unsigned char iidl[VIR_UUID_BUFLEN] = {0};
+ unsigned char uuid[VIR_UUID_BUFLEN] = {0};
nsresult rc;
int i = 0;
@@ -3374,21 +3419,21 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
machine->vtbl->GetAccessible(machine, &isAccessible);
if (isAccessible) {
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
- machine->vtbl->GetId(machine, &iid);
- if (!iid)
+ rc = machine->vtbl->GetId(machine, &iid.value);
+ if (NS_FAILED(rc))
continue;
- vboxIIDToUUID(iidl, iid);
+ vboxIIDToUUID(&iid, uuid);
- if (memcmp(dom->uuid, iidl, VIR_UUID_BUFLEN) == 0) {
+ if (memcmp(dom->uuid, uuid, VIR_UUID_BUFLEN) == 0) {
PRUint32 state = MachineState_Null;
machine->vtbl->GetState(machine, &state);
if ( (state == MachineState_PoweredOff) ||
(state == MachineState_Saved) ||
(state == MachineState_Aborted) ) {
- ret = vboxStartMachine(dom, i, machine, iid);
+ ret = vboxStartMachine(dom, i, machine, &iid);
} else {
vboxError(VIR_ERR_OPERATION_FAILED, "%s",
_("machine is not in poweroff|saved|"
@@ -3396,7 +3441,7 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) {
ret = -1;
}
}
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
if (ret != -1)
break;
}
@@ -3506,54 +3551,41 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (dvdDrive) {
IDVDImage *dvdImage = NULL;
PRUnichar *dvdfileUtf16 = NULL;
- vboxIID *dvduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID dvdemptyuuid;
-
- memset(&dvdemptyuuid, 0, sizeof(dvdemptyuuid));
-# else
- PRUnichar *dvdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID dvduuid = VBOX_IID_INITIALIZER;
+ vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(def->disks[i]->src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj,
dvdfileUtf16, &dvdImage);
if (!dvdImage) {
-# if VBOX_API_VERSION == 2002
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
dvdfileUtf16,
- &dvdemptyuuid,
+ dvdemptyuuid.value,
&dvdImage);
-# else
- data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
- dvdfileUtf16,
- dvdemptyuuidUtf16,
- &dvdImage);
-# endif
}
if (dvdImage) {
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage,
- &dvduuid);
+ &dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to "
"be attached to cdrom: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid);
+ rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to cdrom: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- DEBUGIID("CD/DVDImage UUID:", dvduuid);
+ DEBUGIID("CD/DVDImage UUID:", dvduuid.value);
}
}
VBOX_MEDIUM_RELEASE(dvdImage);
}
- vboxIIDUnalloc(dvduuid);
+ vboxIIDUnalloc(&dvduuid);
VBOX_UTF16_FREE(dvdfileUtf16);
VBOX_RELEASE(dvdDrive);
}
@@ -3564,7 +3596,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
def->disks[i]->src != NULL) {
IHardDisk *hardDisk = NULL;
PRUnichar *hddfileUtf16 = NULL;
- vboxIID *hdduuid = NULL;
+ vboxIID hdduuid = VBOX_IID_INITIALIZER;
PRUnichar *hddEmpty = NULL;
/* Current Limitation: Harddisk can't be connected to
* Secondary Master as Secondary Master is always used
@@ -3598,7 +3630,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (hardDisk) {
rc = hardDisk->vtbl->imedium.GetId((IMedium *)hardDisk,
- &hdduuid);
+ &hdduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to be "
@@ -3639,7 +3671,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
}
rc = machine->vtbl->AttachHardDisk(machine,
- hdduuid,
+ hdduuid.value,
hddcnameUtf16,
channel,
device);
@@ -3651,14 +3683,14 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
"harddisk: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- DEBUGIID("Attached HDD with UUID", hdduuid);
+ DEBUGIID("Attached HDD with UUID", hdduuid.value);
}
}
}
}
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUnalloc(hdduuid);
+ vboxIIDUnalloc(&hdduuid);
VBOX_UTF16_FREE(hddEmpty);
VBOX_UTF16_FREE(hddfileUtf16);
} else if (def->disks[i]->type == VIR_DOMAIN_DISK_TYPE_BLOCK) {
@@ -3673,14 +3705,8 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (NS_SUCCEEDED(rc)) {
IFloppyImage *floppyImage = NULL;
PRUnichar *fdfileUtf16 = NULL;
- vboxIID *fduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID fdemptyuuid;
-
- memset(&fdemptyuuid, 0, sizeof(fdemptyuuid));
-# else
- PRUnichar *fdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID fduuid = VBOX_IID_INITIALIZER;
+ vboxIID fdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(def->disks[i]->src, &fdfileUtf16);
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
@@ -3690,17 +3716,13 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (!floppyImage) {
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
fdfileUtf16,
-# if VBOX_API_VERSION == 2002
- &fdemptyuuid,
-# else
- fdemptyuuidUtf16,
-# endif
+ fdemptyuuid.value,
&floppyImage);
}
if (floppyImage) {
rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage,
- &fduuid);
+ &fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to "
@@ -3708,19 +3730,19 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
def->disks[i]->src, (unsigned)rc);
} else {
rc = floppyDrive->vtbl->MountImage(floppyDrive,
- fduuid);
+ fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to "
"floppy drive: %s, rc=%08x"),
def->disks[i]->src, (unsigned)rc);
} else {
- DEBUGIID("floppyImage UUID", fduuid);
+ DEBUGIID("floppyImage UUID", fduuid.value);
}
}
VBOX_MEDIUM_RELEASE(floppyImage);
}
- vboxIIDUnalloc(fduuid);
+ vboxIIDUnalloc(&fduuid);
VBOX_UTF16_FREE(fdfileUtf16);
}
VBOX_RELEASE(floppyDrive);
@@ -4554,8 +4576,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
VBOX_OBJECT_CHECK(conn, virDomainPtr, NULL);
IMachine *machine = NULL;
IBIOSSettings *bios = NULL;
- vboxIID *iid = NULL;
- vboxIID *mchiid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
+ vboxIID mchiid = VBOX_IID_INITIALIZER;
virDomainDefPtr def = NULL;
PRUnichar *machineNameUtf16 = NULL;
#if VBOX_API_VERSION >= 3002
@@ -4568,28 +4590,21 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
goto cleanup;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16);
- vboxIIDFromUUID(def->uuid, iid);
+ vboxIIDFromUUID(&iid, def->uuid);
#if VBOX_API_VERSION < 3002
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
machineNameUtf16,
NULL,
NULL,
- iid,
+ iid.value,
&machine);
#else /* VBOX_API_VERSION >= 3002 */
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
machineNameUtf16,
NULL,
NULL,
- iid,
+ iid.value,
override,
&machine);
#endif /* VBOX_API_VERSION >= 3002 */
@@ -4672,8 +4687,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
* object so open a session to it and get it back, so that
* you can make changes to the machine setting
*/
- machine->vtbl->GetId(machine, &mchiid);
- data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, mchiid);
+ machine->vtbl->GetId(machine, &mchiid.value);
+ data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, mchiid.value);
data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
vboxSetBootDeviceOrder(def, data, machine);
@@ -4691,20 +4706,20 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
*/
rc = machine->vtbl->SaveSettings(machine);
data->vboxSession->vtbl->Close(data->vboxSession);
- vboxIIDUnalloc(mchiid);
+ vboxIIDUnalloc(&mchiid);
ret = virGetDomain(conn, def->name, def->uuid);
VBOX_RELEASE(machine);
machine = NULL;
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
return ret;
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
return NULL;
}
@@ -4712,17 +4727,10 @@ cleanup:
static int vboxDomainUndefine(virDomainPtr dom) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
+ vboxIIDFromUUID(&iid, dom->uuid);
/* Block for checking if HDD's are attched to VM.
* considering just IDE bus for now. Also skipped
@@ -4737,7 +4745,7 @@ static int vboxDomainUndefine(virDomainPtr dom) {
VIR_FREE(hddcname);
/* Open a Session for the machine */
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
if (NS_SUCCEEDED(rc) && machine) {
@@ -4805,8 +4813,8 @@ static int vboxDomainUndefine(virDomainPtr dom) {
VBOX_UTF16_FREE(hddcnameUtf16);
}
- rc = data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, iid, &machine);
- DEBUGIID("UUID of machine being undefined", iid);
+ rc = data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, iid.value, &machine);
+ DEBUGIID("UUID of machine being undefined", iid.value);
if (NS_SUCCEEDED(rc) && machine){
machine->vtbl->DeleteSettings(machine);
@@ -4816,10 +4824,7 @@ static int vboxDomainUndefine(virDomainPtr dom) {
_("could not delete the domain, rc=%08x"), (unsigned)rc);
}
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
VBOX_RELEASE(machine);
return ret;
@@ -4830,7 +4835,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
int mediaChangeOnly ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 state = MachineState_Null;
virDomainDefPtr def = NULL;
virDomainDeviceDefPtr dev = NULL;
@@ -4855,16 +4860,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
goto cleanup;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
-
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching uuid"));
@@ -4876,9 +4873,9 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if ((state == MachineState_Running) ||
(state == MachineState_Paused)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
}
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
@@ -4897,27 +4894,17 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if (dvdDrive) {
IDVDImage *dvdImage = NULL;
PRUnichar *dvdfileUtf16 = NULL;
- vboxIID *dvduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID dvdemptyuuid;
-
- memset(&dvdemptyuuid, 0, sizeof(dvdemptyuuid));
-# else
- PRUnichar *dvdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID dvduuid = VBOX_IID_INITIALIZER;
+ vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(dev->data.disk->src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
if (!dvdImage) {
-# if VBOX_API_VERSION == 2002
- data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, &dvdemptyuuid, &dvdImage);
-# else
- data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuidUtf16, &dvdImage);
-# endif
+ data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage);
}
if (dvdImage) {
- rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid);
+ rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to "
@@ -4926,20 +4913,20 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
} else {
/* unmount the previous mounted image */
dvdDrive->vtbl->Unmount(dvdDrive);
- rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid);
+ rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to cdrom: %s, rc=%08x"),
dev->data.disk->src, (unsigned)rc);
} else {
ret = 0;
- DEBUGIID("CD/DVD Image UUID:", dvduuid);
+ DEBUGIID("CD/DVD Image UUID:", dvduuid.value);
}
}
VBOX_MEDIUM_RELEASE(dvdImage);
}
- vboxIIDUnalloc(dvduuid);
+ vboxIIDUnalloc(&dvduuid);
VBOX_UTF16_FREE(dvdfileUtf16);
VBOX_RELEASE(dvdDrive);
}
@@ -4955,14 +4942,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if (NS_SUCCEEDED(rc)) {
IFloppyImage *floppyImage = NULL;
PRUnichar *fdfileUtf16 = NULL;
- vboxIID *fduuid = NULL;
-# if VBOX_API_VERSION == 2002
- nsID fdemptyuuid;
-
- memset(&fdemptyuuid, 0, sizeof(fdemptyuuid));
-# else
- PRUnichar *fdemptyuuidUtf16 = NULL;
-# endif
+ vboxIID fduuid = VBOX_IID_INITIALIZER;
+ vboxIID fdemptyuuid = VBOX_IID_INITIALIZER;
VBOX_UTF8_TO_UTF16(dev->data.disk->src, &fdfileUtf16);
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
fdfileUtf16,
@@ -4971,35 +4952,31 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
if (!floppyImage) {
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
fdfileUtf16,
-# if VBOX_API_VERSION == 2002
- &fdemptyuuid,
-# else
- fdemptyuuidUtf16,
-# endif
+ fdemptyuuid.value,
&floppyImage);
}
if (floppyImage) {
- rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid);
+ rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("can't get the uuid of the file to be "
"attached to floppy drive: %s, rc=%08x"),
dev->data.disk->src, (unsigned)rc);
} else {
- rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid);
+ rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not attach the file to floppy drive: %s, rc=%08x"),
dev->data.disk->src, (unsigned)rc);
} else {
ret = 0;
- DEBUGIID("attached floppy, UUID:", fduuid);
+ DEBUGIID("attached floppy, UUID:", fduuid.value);
}
}
VBOX_MEDIUM_RELEASE(floppyImage);
}
- vboxIIDUnalloc(fduuid);
+ vboxIIDUnalloc(&fduuid);
VBOX_UTF16_FREE(fdfileUtf16);
}
VBOX_RELEASE(floppyDrive);
@@ -5024,7 +5001,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
}
cleanup:
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
virDomainDeviceDefFree(dev);
return ret;
@@ -5063,7 +5040,7 @@ static int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
PRUint32 state = MachineState_Null;
virDomainDefPtr def = NULL;
virDomainDeviceDefPtr dev = NULL;
@@ -5088,16 +5065,8 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
goto cleanup;
}
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
-
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching uuid"));
@@ -5109,9 +5078,9 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
if ((state == MachineState_Running) ||
(state == MachineState_Paused)) {
- rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, iid.value);
} else {
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid.value);
}
if (NS_SUCCEEDED(rc)) {
@@ -5186,7 +5155,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
}
cleanup:
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
virDomainDefFree(def);
virDomainDeviceDefFree(dev);
return ret;
@@ -5208,6 +5177,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom,
IMachine *machine,
ISnapshot ***snapshots)
{
+ vboxIID empty = VBOX_IID_INITIALIZER;
ISnapshot **list = NULL;
PRUint32 count;
nsresult rc;
@@ -5230,7 +5200,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom,
goto error;
}
- rc = machine->vtbl->GetSnapshot(machine, NULL, list);
+ rc = machine->vtbl->GetSnapshot(machine, empty.value, list);
if (NS_FAILED(rc) || !list[0]) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not get root snapshot for domain %s"),
@@ -5347,7 +5317,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
{
VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
virDomainSnapshotDefPtr def = NULL;
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
IConsole *console = NULL;
IProgress *progress = NULL;
@@ -5367,16 +5337,9 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
if (!(def = virDomainSnapshotDefParseString(xmlDesc, 1)))
goto cleanup;
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
- if (NS_FAILED(rc) || !machine) {
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
@@ -5393,11 +5356,11 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
&& (state <= MachineState_LastOnline)) {
rc = data->vboxObj->vtbl->OpenExistingSession(data->vboxObj,
data->vboxSession,
- domiid);
+ domiid.value);
} else {
rc = data->vboxObj->vtbl->OpenSession(data->vboxObj,
data->vboxSession,
- domiid);
+ domiid.value);
}
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
@@ -5454,7 +5417,7 @@ cleanup:
VBOX_RELEASE(console);
data->vboxSession->vtbl->Close(data->vboxSession);
VBOX_RELEASE(machine);
- vboxIIDFree(domiid);
+ vboxIIDUnalloc(&domiid);
virDomainSnapshotDefFree(def);
return ret;
}
@@ -5465,7 +5428,7 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snap = NULL;
ISnapshot *parent = NULL;
@@ -5479,15 +5442,8 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
virCheckFlags(0, NULL);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5570,7 +5526,7 @@ cleanup:
VBOX_RELEASE(parent);
VBOX_RELEASE(snap);
VBOX_RELEASE(machine);
- vboxIIDFree(domiid);
+ vboxIIDUnalloc(&domiid);
return ret;
no_memory:
@@ -5583,22 +5539,15 @@ vboxDomainSnapshotNum(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
nsresult rc;
PRUint32 snapshotCount;
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5617,7 +5566,7 @@ vboxDomainSnapshotNum(virDomainPtr dom,
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5628,7 +5577,7 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
nsresult rc;
ISnapshot **snapshots = NULL;
@@ -5637,15 +5586,8 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5690,7 +5632,7 @@ cleanup:
}
VIR_FREE(snapshots);
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5700,22 +5642,15 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snapshot = NULL;
nsresult rc;
virCheckFlags(0, NULL);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -5730,7 +5665,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
cleanup:
VBOX_RELEASE(snapshot);
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5739,23 +5674,16 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snapshot = NULL;
nsresult rc;
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
- if (NS_FAILED(rc) || !machine) {
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
@@ -5775,7 +5703,7 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
cleanup:
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5784,7 +5712,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, virDomainSnapshotPtr, NULL);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snapshot = NULL;
PRUnichar *nameUtf16 = NULL;
@@ -5793,16 +5721,9 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
virCheckFlags(0, NULL);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, iid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid, &machine);
- if (NS_FAILED(rc) || !machine) {
+ vboxIIDFromUUID(&iid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
@@ -5841,7 +5762,7 @@ cleanup:
VBOX_UTF16_FREE(nameUtf16);
VBOX_RELEASE(snapshot);
VBOX_RELEASE(machine);
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -5852,17 +5773,17 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
ISnapshot *snapshot)
{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
nsresult rc;
- rc = snapshot->vtbl->GetId(snapshot, &iid);
- if (NS_FAILED(rc) || !iid) {
+ rc = snapshot->vtbl->GetId(snapshot, &iid.value);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot UUID"));
goto cleanup;
}
- rc = machine->vtbl->SetCurrentSnapshot(machine, iid);
+ rc = machine->vtbl->SetCurrentSnapshot(machine, iid.value);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR,
_("could not restore snapshot for domain %s"), dom->name);
@@ -5872,7 +5793,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
ret = 0;
cleanup:
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
#else
@@ -5887,10 +5808,10 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
PRUint32 state;
nsresult rc;
PRInt32 result;
- vboxIID *domiid;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
- rc = machine->vtbl->GetId(machine, &domiid);
- if (NS_FAILED(rc) || !domiid) {
+ rc = machine->vtbl->GetId(machine, &domiid.value);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get domain UUID"));
goto cleanup;
@@ -5911,7 +5832,7 @@ vboxDomainSnapshotRestore(virDomainPtr dom,
}
rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession,
- domiid);
+ domiid.value);
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -5948,6 +5869,7 @@ cleanup:
VBOX_RELEASE(progress);
VBOX_RELEASE(console);
data->vboxSession->vtbl->Close(data->vboxSession);
+ vboxIIDUnalloc(&domiid);
return ret;
}
#endif
@@ -5958,7 +5880,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *newSnapshot = NULL;
ISnapshot *prevSnapshot = NULL;
@@ -5968,15 +5890,8 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virCheckFlags(0, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -6030,7 +5945,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
cleanup:
VBOX_RELEASE(prevSnapshot);
VBOX_RELEASE(newSnapshot);
- vboxIIDUnalloc(domiid);
+ vboxIIDUnalloc(&domiid);
return ret;
}
@@ -6040,7 +5955,7 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data,
ISnapshot *snapshot)
{
IProgress *progress = NULL;
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
int ret = -1;
nsresult rc;
#if VBOX_API_VERSION == 2002
@@ -6049,17 +5964,17 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data,
PRInt32 result;
#endif
- rc = snapshot->vtbl->GetId(snapshot, &iid);
- if (NS_FAILED(rc) || !iid) {
+ rc = snapshot->vtbl->GetId(snapshot, &iid.value);
+ if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INTERNAL_ERROR, "%s",
_("could not get snapshot UUID"));
goto cleanup;
}
#if VBOX_API_VERSION < 3001
- rc = console->vtbl->DiscardSnapshot(console, iid, &progress);
+ rc = console->vtbl->DiscardSnapshot(console, iid.value, &progress);
#else
- rc = console->vtbl->DeleteSnapshot(console, iid, &progress);
+ rc = console->vtbl->DeleteSnapshot(console, iid.value, &progress);
#endif
if (NS_FAILED(rc) || !progress) {
if (rc == VBOX_E_INVALID_VM_STATE) {
@@ -6084,7 +5999,7 @@ vboxDomainSnapshotDeleteSingle(vboxGlobalData *data,
cleanup:
VBOX_RELEASE(progress);
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -6123,7 +6038,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
{
virDomainPtr dom = snapshot->domain;
VBOX_OBJECT_CHECK(dom->conn, int, -1);
- vboxIID *domiid = NULL;
+ vboxIID domiid = VBOX_IID_INITIALIZER;
IMachine *machine = NULL;
ISnapshot *snap = NULL;
IConsole *console = NULL;
@@ -6132,16 +6047,8 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(domiid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
-
- vboxIIDFromUUID(dom->uuid, domiid);
-
- rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid, &machine);
+ vboxIIDFromUUID(&domiid, dom->uuid);
+ rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
_("no domain with matching UUID"));
@@ -6167,7 +6074,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
}
rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession,
- domiid);
+ domiid.value);
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
if (NS_FAILED(rc)) {
@@ -6185,7 +6092,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
cleanup:
VBOX_RELEASE(console);
VBOX_RELEASE(snap);
- vboxIIDUnalloc(domiid);
+ vboxIIDUnalloc(&domiid);
data->vboxSession->vtbl->Close(data->vboxSession);
return ret;
}
@@ -6943,25 +6850,20 @@ static int vboxListDefinedNetworks(virConnectPtr conn, char **const names, int n
return ret;
}
-static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) {
+static virNetworkPtr
+vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
+{
VBOX_OBJECT_HOST_CHECK(conn, virNetworkPtr, NULL);
- vboxIID *iid = NULL;
-
-#if VBOX_API_VERSION == 2002
- if (VIR_ALLOC(iid) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-#endif
+ vboxIID iid = VBOX_IID_INITIALIZER;
- vboxIIDFromUUID(uuid, iid);
+ vboxIIDFromUUID(&iid, uuid);
/* TODO: "internal" networks are just strings and
* thus can't do much with them
*/
IHostNetworkInterface *networkInterface = NULL;
- host->vtbl->FindHostNetworkInterfaceById(host, iid, &networkInterface);
+ host->vtbl->FindHostNetworkInterfaceById(host, iid.value, &networkInterface);
if (networkInterface) {
PRUint32 interfaceType = 0;
@@ -6977,7 +6879,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned
ret = virGetNetwork(conn, nameUtf8, uuid);
DEBUG("Network Name: %s", nameUtf8);
- DEBUGIID("Network UUID", iid);
+ DEBUGIID("Network UUID", iid.value);
VBOX_UTF8_FREE(nameUtf8);
VBOX_UTF16_FREE(nameUtf16);
@@ -6988,10 +6890,7 @@ static virNetworkPtr vboxNetworkLookupByUUID(virConnectPtr conn, const unsigned
VBOX_RELEASE(host);
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif
- vboxIIDFree(iid);
+ vboxIIDUnalloc(&iid);
return ret;
}
@@ -7011,15 +6910,15 @@ static virNetworkPtr vboxNetworkLookupByName(virConnectPtr conn, const char *nam
if (interfaceType == HostNetworkInterfaceType_HostOnly) {
unsigned char uuid[VIR_UUID_BUFLEN];
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
- networkInterface->vtbl->GetId(networkInterface, &iid);
- vboxIIDToUUID(uuid, iid);
+ networkInterface->vtbl->GetId(networkInterface, &iid.value);
+ vboxIIDToUUID(&iid, uuid);
ret = virGetNetwork(conn, name, uuid);
DEBUG("Network Name: %s", name);
- DEBUGIID("Network UUID", iid);
- vboxIIDUnalloc(iid);
+ DEBUGIID("Network UUID", iid.value);
+ vboxIIDUnalloc(&iid);
}
VBOX_RELEASE(networkInterface);
@@ -7036,6 +6935,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
PRUnichar *networkInterfaceNameUtf16 = NULL;
char *networkInterfaceNameUtf8 = NULL;
IHostNetworkInterface *networkInterface = NULL;
+ nsresult rc;
virNetworkDefPtr def = virNetworkDefParseString(xml);
@@ -7051,7 +6951,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
*/
#if VBOX_API_VERSION == 2002
- if STREQ(def->name, "vboxnet0") {
+ if (STREQ(def->name, "vboxnet0")) {
PRUint32 interfaceType = 0;
VBOX_UTF8_TO_UTF16(def->name, &networkInterfaceNameUtf16);
@@ -7077,7 +6977,7 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
unsigned char uuid[VIR_UUID_BUFLEN];
char *networkNameUtf8 = NULL;
PRUnichar *networkNameUtf16 = NULL;
- vboxIID *vboxnetiid = NULL;
+ vboxIID vboxnetiid = VBOX_IID_INITIALIZER;
networkInterface->vtbl->GetName(networkInterface, &networkInterfaceNameUtf16);
if (networkInterfaceNameUtf16) {
@@ -7187,11 +7087,11 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char *
networkInterface->vtbl->DhcpRediscover(networkInterface);
}
- networkInterface->vtbl->GetId(networkInterface, &vboxnetiid);
- if (vboxnetiid) {
- vboxIIDToUUID(uuid, vboxnetiid);
- DEBUGIID("Real Network UUID", vboxnetiid);
- vboxIIDUnalloc(vboxnetiid);
+ rc = networkInterface->vtbl->GetId(networkInterface, &vboxnetiid.value);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&vboxnetiid, uuid);
+ DEBUGIID("Real Network UUID", vboxnetiid.value);
+ vboxIIDUnalloc(&vboxnetiid);
ret = virGetNetwork(conn, networkInterfaceNameUtf8, uuid);
}
@@ -7414,10 +7314,10 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE
if (def->name != NULL) {
PRUnichar *networkNameUtf16 = NULL;
IDHCPServer *dhcpServer = NULL;
- vboxIID *vboxnet0IID = NULL;
+ vboxIID vboxnet0IID = VBOX_IID_INITIALIZER;
- networkInterface->vtbl->GetId(networkInterface, &vboxnet0IID);
- vboxIIDToUUID(def->uuid, vboxnet0IID);
+ networkInterface->vtbl->GetId(networkInterface, &vboxnet0IID.value);
+ vboxIIDToUUID(&vboxnet0IID, def->uuid);
VBOX_UTF8_TO_UTF16(networkNameUtf8 , &networkNameUtf16);
@@ -7523,8 +7423,8 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE
}
}
- DEBUGIID("Network UUID", vboxnet0IID);
- vboxIIDUnalloc(vboxnet0IID);
+ DEBUGIID("Network UUID", vboxnet0IID.value);
+ vboxIIDUnalloc(&vboxnet0IID);
VBOX_UTF16_FREE(networkNameUtf16);
} else {
virReportOOMError();
@@ -7733,28 +7633,24 @@ static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const
}
if (nameUtf8 && STREQ(nameUtf8, name)) {
- vboxIID *hddIID = NULL;
- char *hddIIDUtf8 = NULL;
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ char key[VIR_UUID_STRING_BUFLEN] = "";
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID);
+ rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
- if (hddIID) {
- vboxIIDtoUtf8(hddIID, &hddIIDUtf8);
- vboxIIDUnalloc(hddIID);
- }
-
- if (hddIIDUtf8) {
-
- ret = virGetStorageVol(pool->conn, pool->name, name, hddIIDUtf8);
+ ret = virGetStorageVol(pool->conn, pool->name, name, key);
DEBUG("virStorageVolPtr: %p", ret);
DEBUG("Storage Volume Name: %s", name);
- DEBUG("Storage Volume key : %s", hddIIDUtf8);
+ DEBUG("Storage Volume key : %s", key);
DEBUG("Storage Volume Pool: %s", pool->name);
-
- vboxIIDUtf8Free(hddIIDUtf8);
}
+ vboxIIDUnalloc(&hddIID);
VBOX_UTF8_FREE(nameUtf8);
break;
}
@@ -7773,34 +7669,22 @@ static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const
static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) {
VBOX_OBJECT_CHECK(conn, virStorageVolPtr, NULL);
- vboxIID *hddIID = NULL;
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
IHardDisk *hardDisk = NULL;
nsresult rc;
if (!key)
return ret;
-#if VBOX_API_VERSION == 2002
-
- if (VIR_ALLOC(hddIID) < 0) {
- virReportOOMError();
- goto cleanup;
+ if (virUUIDParse(key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), key);
+ return NULL;
}
- unsigned char hddUUID[VIR_UUID_BUFLEN];
-
- virUUIDParse(key, hddUUID);
- vboxIIDFromUUID(hddUUID, hddIID);
-
-#else /* VBOX_API_VERSION != 2002 */
-
- VBOX_UTF8_TO_UTF16(key, &hddIID);
- if (!hddIID)
- return ret;
-
-#endif /* VBOX_API_VERSION != 2002 */
-
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -7833,10 +7717,7 @@ static virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char
VBOX_MEDIUM_RELEASE(hardDisk);
}
-#if VBOX_API_VERSION == 2002
-cleanup:
-#endif /* VBOX_API_VERSION == 2002 */
- vboxIIDFree(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
@@ -7862,41 +7743,40 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const cha
if (hddstate != MediaState_Inaccessible) {
PRUnichar *hddNameUtf16 = NULL;
char *hddNameUtf8 = NULL;
- vboxIID *hddIID = NULL;
- char *hddIIDUtf8 = NULL;
VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetName, &hddNameUtf16);
- VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID);
if (hddNameUtf16) {
VBOX_UTF16_TO_UTF8(hddNameUtf16, &hddNameUtf8);
VBOX_UTF16_FREE(hddNameUtf16);
}
- if (hddIID) {
- vboxIIDtoUtf8(hddIID, &hddIIDUtf8);
- vboxIIDUnalloc(hddIID);
- }
+ if (hddNameUtf8) {
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ char key[VIR_UUID_STRING_BUFLEN] = "";
- if (hddIIDUtf8 && hddNameUtf8) {
+ rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
+ if (NS_SUCCEEDED(rc)) {
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
- /* TODO: currently only one default pool and thus
- * the check below, change it when pools are supported
- */
- if (vboxStorageNumOfPools(conn) == 1)
- ret = virGetStorageVol(conn, "default-pool", hddNameUtf8, hddIIDUtf8);
+ /* TODO: currently only one default pool and thus
+ * the check below, change it when pools are supported
+ */
+ if (vboxStorageNumOfPools(conn) == 1)
+ ret = virGetStorageVol(conn, "default-pool", hddNameUtf8, key);
- DEBUG("Storage Volume Pool: %s", "default-pool");
- DEBUG("Storage Volume Name: %s", hddNameUtf8);
- DEBUG("Storage Volume key : %s", hddIIDUtf8);
+ DEBUG("Storage Volume Pool: %s", "default-pool");
+ DEBUG("Storage Volume Name: %s", hddNameUtf8);
+ DEBUG("Storage Volume key : %s", key);
+ }
+ vboxIIDUnalloc(&hddIID);
}
if (hddNameUtf8)
VBOX_UTF8_FREE(hddNameUtf8);
-
- if (hddIIDUtf8)
- vboxIIDUtf8Free(hddIIDUtf8);
}
VBOX_MEDIUM_RELEASE(hardDisk);
@@ -7963,7 +7843,6 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
rc = hardDisk->vtbl->CreateBaseStorage(hardDisk, logicalSize, variant, &progress);
if (NS_SUCCEEDED(rc) && progress) {
- vboxIID *hddIID = NULL;
#if VBOX_API_VERSION == 2002
nsresult resultCode;
#else
@@ -7974,24 +7853,23 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
progress->vtbl->GetResultCode(progress, &resultCode);
if (NS_SUCCEEDED(resultCode)) {
+ 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);
+ rc = VBOX_MEDIUM_FUNC_ARG1(hardDisk, GetId, &hddIID.value);
if (NS_SUCCEEDED(rc)) {
- char *hddKey = NULL;
-
- vboxIIDtoUtf8(hddIID, &hddKey);
-
- if (hddKey)
- ret = virGetStorageVol(pool->conn, pool->name, def->name, hddKey);
+ vboxIIDToUUID(&hddIID, uuid);
+ virUUIDFormat(uuid, key);
- vboxIIDUtf8Free(hddKey);
- vboxIIDUnalloc(hddIID);
+ ret = virGetStorageVol(pool->conn, pool->name, def->name, key);
}
+
+ vboxIIDUnalloc(&hddIID);
}
VBOX_RELEASE(progress);
}
-
}
}
@@ -8006,18 +7884,22 @@ cleanup:
static int vboxStorageVolDelete(virStorageVolPtr vol,
unsigned int flags ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(vol->conn, int, -1);
- vboxIID *hddIID = NULL;
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
+ unsigned char uuid[VIR_UUID_BUFLEN];
IHardDisk *hardDisk = NULL;
int deregister = 0;
nsresult rc;
int i = 0;
int j = 0;
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
- return ret;
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
+ return -1;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8032,13 +7914,27 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
vboxArrayGet(&machineIds, hardDisk, hardDisk->vtbl->GetMachineIds);
#endif /* VBOX_API_VERSION >= 3001 */
+#if VBOX_API_VERSION == 2002 && defined WIN32
+ /* VirtualBox 2.2 on Windows represents IIDs as GUIDs and the
+ * machineIds array contains direct instances of the GUID struct
+ * instead of pointers to the actual struct instances. But there
+ * is no 128bit width simple item type for a SafeArray to fit a
+ * GUID in. The largest simple type it 64bit width and VirtualBox
+ * uses two of this 64bit items to represents one GUID. Therefore,
+ * we devide the size of the SafeArray by two, to compensate for
+ * this workaround in VirtualBox */
+ machineIds.count /= 2;
+#endif /* VBOX_API_VERSION >= 2002 */
+
machineIdsSize = machineIds.count;
for (i = 0; i < machineIds.count; i++) {
IMachine *machine = NULL;
- vboxIID *machineId = machineIds.items[i];
+ vboxIID machineId = VBOX_IID_INITIALIZER;
+
+ vboxIIDFromArrayItem(&machineId, &machineIds, i);
- rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, machineId);
+ rc = data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, machineId.value);
if (NS_SUCCEEDED(rc)) {
rc = data->vboxSession->vtbl->GetMachine(data->vboxSession, &machine);
@@ -8064,20 +7960,20 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
rc = hddAttachment->vtbl->GetMedium(hddAttachment, &hdd);
#endif /* VBOX_API_VERSION >= 3001 */
if (NS_SUCCEEDED(rc) && hdd) {
- vboxIID *iid = NULL;
+ vboxIID iid = VBOX_IID_INITIALIZER;
- VBOX_MEDIUM_FUNC_ARG1(hdd, GetId, &iid);
- if (iid) {
+ rc = VBOX_MEDIUM_FUNC_ARG1(hdd, GetId, &iid.value);
+ if (NS_SUCCEEDED(rc)) {
- DEBUGIID("HardDisk (to delete) UUID", hddIID);
- DEBUGIID("HardDisk (currently processing) UUID", iid);
+ DEBUGIID("HardDisk (to delete) UUID", hddIID.value);
+ DEBUGIID("HardDisk (currently processing) UUID", iid.value);
- if (vboxIIDEqual(hddIID, iid)) {
+ if (vboxIIDIsEqual(&hddIID, &iid)) {
PRUnichar *controller = NULL;
PRInt32 port = 0;
PRInt32 device = 0;
- DEBUGIID("Found HardDisk to delete, UUID", hddIID);
+ DEBUGIID("Found HardDisk to delete, UUID", hddIID.value);
hddAttachment->vtbl->GetController(hddAttachment, &controller);
hddAttachment->vtbl->GetPort(hddAttachment, &port);
@@ -8101,7 +7997,7 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
if (controller)
VBOX_UTF16_FREE(controller);
}
- vboxIIDUnalloc(iid);
+ vboxIIDUnalloc(&iid);
}
VBOX_MEDIUM_RELEASE(hdd);
}
@@ -8112,6 +8008,8 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
}
data->vboxSession->vtbl->Close(data->vboxSession);
}
+
+ vboxIIDUnalloc(&machineId);
}
vboxArrayUnalloc(&machineIds);
@@ -8124,17 +8022,16 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
if (NS_SUCCEEDED(rc) && progress) {
progress->vtbl->WaitForCompletion(progress, -1);
VBOX_RELEASE(progress);
- DEBUGIID("HardDisk deleted, UUID", hddIID);
+ DEBUGIID("HardDisk deleted, UUID", hddIID.value);
ret = 0;
}
}
-
}
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
@@ -8142,17 +8039,21 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info) {
VBOX_OBJECT_CHECK(vol->conn, int, -1);
IHardDisk *hardDisk = NULL;
- vboxIID *hddIID = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
nsresult rc;
if (!info)
return ret;
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
return ret;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8180,7 +8081,7 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
@@ -8188,7 +8089,8 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info
static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags ATTRIBUTE_UNUSED) {
VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
IHardDisk *hardDisk = NULL;
- vboxIID *hddIID = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
virStoragePoolDef pool;
virStorageVolDef def;
int defOk = 0;
@@ -8197,11 +8099,14 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
return ret;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8272,7 +8177,7 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
if (defOk)
ret = virStorageVolDefFormat(&pool, &def);
@@ -8283,14 +8188,18 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags A
static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
IHardDisk *hardDisk = NULL;
- vboxIID *hddIID = NULL;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+ vboxIID hddIID = VBOX_IID_INITIALIZER;
nsresult rc;
- vboxUtf8toIID(vol->key, &hddIID);
- if (!hddIID)
+ if (virUUIDParse(vol->key, uuid) < 0) {
+ vboxError(VIR_ERR_INVALID_ARG,
+ _("Could not parse UUID from '%s'"), vol->key);
return ret;
+ }
- rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID, &hardDisk);
+ vboxIIDFromUUID(&hddIID, uuid);
+ rc = data->vboxObj->vtbl->GetHardDisk(data->vboxObj, hddIID.value, &hardDisk);
if (NS_SUCCEEDED(rc)) {
PRUint32 hddstate;
@@ -8321,7 +8230,7 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) {
VBOX_MEDIUM_RELEASE(hardDisk);
}
- vboxIIDUtf16Free(hddIID);
+ vboxIIDUnalloc(&hddIID);
return ret;
}
--
1.7.0.4
13 years, 11 months
[libvirt] [PATCH] Fix misuse of VIR_ERR_INVALID_DOMAIN
by Matthias Bolte
VIR_ERR_INVALID_DOMAIN is meant for invalid domain pointers.
VIR_ERR_NO_DOMAIN is meant for non-existing domains.
---
src/opennebula/one_driver.c | 16 ++++++++--------
src/openvz/openvz_driver.c | 22 +++++++++++-----------
src/uml/uml_driver.c | 26 +++++++++++++-------------
src/vbox/vbox_tmpl.c | 38 +++++++++++++++++++-------------------
4 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/src/opennebula/one_driver.c b/src/opennebula/one_driver.c
index a2d9ab3..b88f44f 100644
--- a/src/opennebula/one_driver.c
+++ b/src/opennebula/one_driver.c
@@ -285,7 +285,7 @@ static int oneDomainUndefine(virDomainPtr dom)
oneDriverLock(driver);
vm =virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN, "%s",
+ oneError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto return_point;
}
@@ -316,7 +316,7 @@ static int oneDomainGetInfo(virDomainPtr dom,
oneDriverUnlock(driver);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN, "%s",
+ oneError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
return -1;
}
@@ -391,7 +391,7 @@ static char *oneGetOSType(virDomainPtr dom)
vm =virDomainFindByUUID(&driver->domains, dom->uuid);
oneDriverUnlock(driver);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN, "%s",
+ oneError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -420,7 +420,7 @@ static int oneDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
vm = virDomainFindByName(&driver->domains, dom->name);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain named %s"), dom->name);
goto return_point;
}
@@ -507,7 +507,7 @@ static int oneDomainShutdown(virDomainPtr dom)
oneDriverLock(driver);
if (!(vm=virDomainFindByID(&driver->domains, dom->id))) {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with id %d"), dom->id);
goto return_point;
}
@@ -542,7 +542,7 @@ static int oneDomainDestroy(virDomainPtr dom)
oneDriverLock(driver);
vm= virDomainFindByID(&driver->domains, dom->id);
if (!vm) {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with id %d"), dom->id);
goto return_point;
}
@@ -591,7 +591,7 @@ static int oneDomainSuspend(virDomainPtr dom)
oneError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not running"));
} else {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
}
@@ -624,7 +624,7 @@ static int oneDomainResume(virDomainPtr dom)
oneError(VIR_ERR_OPERATION_INVALID, "%s",
_("domain is not paused"));
} else {
- oneError(VIR_ERR_INVALID_DOMAIN,
+ oneError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index a959ab6..7728981 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -350,7 +350,7 @@ static int openvzDomainGetInfo(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -437,7 +437,7 @@ static char *openvzDomainDumpXML(virDomainPtr dom, int flags) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -481,7 +481,7 @@ static int openvzDomainSuspend(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -521,7 +521,7 @@ static int openvzDomainResume(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -561,7 +561,7 @@ static int openvzDomainShutdown(virDomainPtr dom) {
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -599,7 +599,7 @@ static int openvzDomainReboot(virDomainPtr dom,
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1026,7 +1026,7 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching id"));
goto cleanup;
}
@@ -1073,7 +1073,7 @@ openvzDomainUndefine(virDomainPtr dom)
openvzDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1117,7 +1117,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1149,7 +1149,7 @@ openvzDomainGetAutostart(virDomainPtr dom, int *autostart)
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1242,7 +1242,7 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
openvzDriverUnlock(driver);
if (!vm) {
- openvzError(VIR_ERR_INVALID_DOMAIN, "%s",
+ openvzError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 325b52b..92b5153 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1310,7 +1310,7 @@ static int umlDomainShutdown(virDomainPtr dom) {
vm = virDomainFindByID(&driver->domains, dom->id);
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1340,7 +1340,7 @@ static int umlDomainDestroy(virDomainPtr dom) {
umlDriverLock(driver);
vm = virDomainFindByID(&driver->domains, dom->id);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1370,7 +1370,7 @@ static char *umlDomainGetOSType(virDomainPtr dom) {
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1398,7 +1398,7 @@ static unsigned long umlDomainGetMaxMemory(virDomainPtr dom) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
@@ -1423,7 +1423,7 @@ static int umlDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
@@ -1456,7 +1456,7 @@ static int umlDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
- umlReportError(VIR_ERR_INVALID_DOMAIN,
+ umlReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
goto cleanup;
}
@@ -1493,7 +1493,7 @@ static int umlDomainGetInfo(virDomainPtr dom,
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1533,7 +1533,7 @@ static char *umlDomainDumpXML(virDomainPtr dom,
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1584,7 +1584,7 @@ static int umlDomainStartWithFlags(virDomainPtr dom, unsigned int flags) {
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1650,7 +1650,7 @@ static int umlDomainUndefine(virDomainPtr dom) {
umlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1922,7 +1922,7 @@ static int umlDomainGetAutostart(virDomainPtr dom,
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -1948,7 +1948,7 @@ static int umlDomainSetAutostart(virDomainPtr dom,
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -2022,7 +2022,7 @@ umlDomainBlockPeek(virDomainPtr dom,
umlDriverUnlock(driver);
if (!vm) {
- umlReportError(VIR_ERR_INVALID_DOMAIN, "%s",
+ umlReportError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index d931055..2b170ec 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -1453,7 +1453,7 @@ static int vboxDomainSuspend(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1505,7 +1505,7 @@ static int vboxDomainResume(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1556,7 +1556,7 @@ static int vboxDomainShutdown(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1606,7 +1606,7 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSE
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1652,7 +1652,7 @@ static int vboxDomainDestroy(virDomainPtr dom) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1722,7 +1722,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
goto cleanup;
}
@@ -1950,11 +1950,11 @@ vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
VBOX_RELEASE(machine);
} else {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("no domain with matching id %d"), dom->id);
}
} else {
- vboxError(VIR_ERR_INVALID_DOMAIN,
+ vboxError(VIR_ERR_NO_DOMAIN,
_("can't open session to the domain with id %d"), dom->id);
}
data->vboxSession->vtbl->Close(data->vboxSession);
@@ -4863,7 +4863,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -5068,7 +5068,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) {
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching uuid"));
goto cleanup;
}
@@ -5340,7 +5340,7 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5445,7 +5445,7 @@ vboxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5549,7 +5549,7 @@ vboxDomainSnapshotNum(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5589,7 +5589,7 @@ vboxDomainSnapshotListNames(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5652,7 +5652,7 @@ vboxDomainSnapshotLookupByName(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5684,7 +5684,7 @@ vboxDomainHasCurrentSnapshot(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5724,7 +5724,7 @@ vboxDomainSnapshotCurrent(virDomainPtr dom,
vboxIIDFromUUID(&iid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, iid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -5893,7 +5893,7 @@ vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
@@ -6050,7 +6050,7 @@ vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
vboxIIDFromUUID(&domiid, dom->uuid);
rc = data->vboxObj->vtbl->GetMachine(data->vboxObj, domiid.value, &machine);
if (NS_FAILED(rc)) {
- vboxError(VIR_ERR_INVALID_DOMAIN, "%s",
+ vboxError(VIR_ERR_NO_DOMAIN, "%s",
_("no domain with matching UUID"));
goto cleanup;
}
--
1.7.0.4
13 years, 11 months
Re: [libvirt] Kvm virtualization vs emulation
by acue@i4p.com
Hello Radek,
what I am proposing is not closely related to libvirt, but solves your problem
configurable choice-by-choice.
I have a OpenSource-Project, which currently just uses commandline calls.
The utility therefore scans during each call either for available executables,
or uses configured pathnames from a configuration file for QEMU
and KVM.
What it does is e.g. the storage of automatically created configuration
files (created by ctys-createConfVM), which contains the actual call of the
executable, including the specific CPU-ARCH.
So you can install KVM support and QEMU with full scope of CPUs, and fix
within the defined ASCII configuration file to use a specific QEMU executable,
in addition the variant of the CPU. A too for the scan and check of actual
operation state for all available QEMU-executables and KVM(ctys-plugins) is
contained too.
The installed online-help is available too at:
http://www.UnifiedSessionsManager.org
http://www.unifiedsessionsmanager.eu/doc/en/html/doc.html
For various configuration Use-Cases related to QEMU/KVM refer to:
http://www.unifiedsessionsmanager.org/doc/en/html/man7/ctys-configuration...
These comprise standard linux examples by KVM and embedded emulation
examples for:
->QEMU-arm-test
->QEMU-coldfire-test
->QNX-6.4.0
->Android
->MeeGo
The virlib is in current version just used by virsh for Xen.
Arno
----------------------------------------------------------------------------
Arno-Can Uestuensoez
www.i4p.com
-----Original Message-----
From: Radek Hladik [mailto:radek@eadresa.cz]
Sent: Monday, December 27, 2010 12:42 PM
To: libvirt-list(a)redhat.com
Subject: [libvirt] Kvm virtualization vs emulation
Wishing Merry Christmas to all.I am preparing new production host for libvirt and I did encounter one issue I am a little confused about. I am using libvirt 0.8.6 with qemu 0.13 (both built for F13 from F14 SRPMS). When I create domain with hvmlibvirt executes qemu-system-x86_64 with -enable-kvm option. The other host where I use libvirt 0.8.2 is running qemu-kvm for similar domain. The problem is that qemu-system with -enable-kvm is subjectively using qemu emulation instead of KVM full virtualization - there is nothing in log or so but the guest is slow and uses a lot of CPU for simple tasks. If I docp /usr/bin/qemu-kvm /usr/bin/qemu-system-x68_64the guest runs faster, uses less CPU on host, etc... Just booting RIPLinux is cca 3 times faster (about 10 secs vs 30).So my questions are:1) what is the logic of choosing which qemu-something to run?2) is there any way how to force libvirt to disable the qemu emulation at all? I'd prefer not to start domain that would not run with full virtualization at all. There is no requirement for emulation on this host and it is a huge waste of resources.3) Is there a way how to check qemu process if it is using the full virtualizaiton? As I understand it then KVM allows processes to use some sort of guest mode process (in addition to user mode and kernel mode) so I should be able to check it but I did not find out how.Radek--libvir-list mailing listlibvir-list@redhat.comhttps://www.redhat.com/mailman/listinfo/libvir-list
13 years, 11 months
[libvirt] Kvm virtualization vs emulation
by Radek Hladik
Wishing Merry Christmas to all.
I am preparing new production host for libvirt and I did encounter one
issue I am a little confused about. I am using libvirt 0.8.6 with qemu
0.13 (both built for F13 from F14 SRPMS). When I create domain with
<type arch='x86_64' machine='pc-0.13'>hvm</type>
libvirt executes qemu-system-x86_64 with -enable-kvm option. The other
host where I use libvirt 0.8.2 is running qemu-kvm for similar domain.
The problem is that qemu-system with -enable-kvm is subjectively using
qemu emulation instead of KVM full virtualization - there is nothing in
log or so but the guest is slow and uses a lot of CPU for simple tasks.
If I do
cp /usr/bin/qemu-kvm /usr/bin/qemu-system-x68_64
the guest runs faster, uses less CPU on host, etc... Just booting
RIPLinux is cca 3 times faster (about 10 secs vs 30).
So my questions are:
1) what is the logic of choosing which qemu-something to run?
2) is there any way how to force libvirt to disable the qemu emulation
at all? I'd prefer not to start domain that would not run with full
virtualization at all. There is no requirement for emulation on this
host and it is a huge waste of resources.
3) Is there a way how to check qemu process if it is using the full
virtualizaiton? As I understand it then KVM allows processes to use some
sort of guest mode process (in addition to user mode and kernel mode) so
I should be able to check it but I did not find out how.
Radek
13 years, 11 months
[libvirt] [PATCH] update docs for network disks
by MORITA Kazutaka
Signed-off-by: MORITA Kazutaka <morita.kazutaka(a)lab.ntt.co.jp>
---
docs/formatdomain.html.in | 49 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 46 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cfd3451..86c2d0d 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -628,23 +628,39 @@
...
</serial>
</disk>
+ ...
+ <disk type='network'>
+ <driver name="qemu" type="raw"/>
+ <source protocol="sheepdog" name="image_name">
+ <host name="hostname" port="7000">
+ </source>
+ <target dev="hdb" bus="ide"/>
+ </disk>
</devices>
...</pre>
<dl>
<dt><code>disk</code></dt>
<dd>The <code>disk</code> element is the main container for describing
- disks. The <code>type</code> attribute is either "file" or "block"
+ disks. The <code>type</code> attribute is either "file", "block", "dir", or "network"
and refers to the underlying source for the disk. The optional
<code>device</code> attribute indicates how the disk is to be exposed
to the guest OS. Possible values for this attribute are "floppy", "disk"
and "cdrom", defaulting to "disk".
- <span class="since">Since 0.0.3; "device" attribute since 0.1.4</span></dd>
+ <span class="since">Since 0.0.3; "device" attribute since 0.1.4;
+ "network" attribute value since after 0.8.6 (QEMU and KVM only)</span></dd>
<dt><code>source</code></dt>
<dd>If the disk <code>type</code> is "file", then the <code>file</code> attribute
specifies the fully-qualified path to the file holding the disk. If the disk
<code>type</code> is "block", then the <code>dev</code> attribute specifies
- the path to the host device to serve as the disk. <span class="since">Since 0.0.3</span></dd>
+ the path to the host device to serve as the disk. If the disk <code>type</code>
+ is "network", then the <code>protocol</code> attribute specifies the protocol
+ to access to the requested image; possible values are "nbd", "rbd", and "sheepdog".
+ If the <code>protocol</code> attribute is "rbd" or "sheepdog", an additional
+ attribute <code>name</code> is mandatory to specify which image to be used.
+ When the disk <code>type</code> is "network", the <code>source</code> may have
+ zero or more <code>host</code> sub-elements used to specify the hosts to connect.
+ <span class="since">Since 0.0.3</span></dd>
<dt><code>target</code></dt>
<dd>The <code>target</code> element controls the bus / device under which the
disk is exposed to the guest OS. The <code>dev</code> attribute indicates
@@ -680,6 +696,33 @@
For example, it may look as <code><serial>WD-WMAP9A966149</serial></code>.
<span class="since">Since 0.7.1</span>
</dd>
+ <dt><code>host</code></dt>
+ <dd>The <code>host</code> element has two attributes "name" and "port",
+ which specify the hostname and the port number. The meaning of this
+ element and the number of the elements depend on the protocol attribute.
+ <table class="top_table">
+ <tr>
+ <th> Protocol </th>
+ <th> Meaning </th>
+ <th> Number of hosts </th>
+ </tr>
+ <tr>
+ <td> nbd </td>
+ <td> a server running nbd-server </td>
+ <td> only one </td>
+ </tr>
+ <tr>
+ <td> rbd </td>
+ <td> monitor servers of RBD </td>
+ <td> one or more </td>
+ </tr>
+ <tr>
+ <td> sheepdog </td>
+ <td> one of the sheepdog servers (default is localhost:7000) </td>
+ <td> zero or one </td>
+ </tr>
+ </table>
+ </dd>
</dl>
<h4><a name="elementsUSB">USB and PCI devices</a></h4>
--
1.7.1
13 years, 11 months
[libvirt] [PATCH] build: fix building error when building without libvirtd
by Wen Congyang
When I build libvirt without libvirtd, I receive some errors:
cp: cannot stat `/home/wency/rpmbuild/BUILDROOT/libvirt-0.8.6-1.el6.x86_64/etc/libvirt/qemu/networks/default.xml': No such file or directory
My build step:
# ./autogen.sh --without-libvirtd
# make dist
# rpmbuild --nodeps --define "_sourcedir `pwd`" --define "_without_libvirtd 1" -ba libvirt.spec
The reason is we disable network when we do not build libvirt daemon in configure.ac.
After fixing this bug, I build libvirt without libvirtd, I receive other errors:
RPM build errors:
Installed (but unpackaged) file(s) found:
/usr/share/doc/libvirt-0.8.6/html/32favicon.png
/usr/share/doc/libvirt-0.8.6/html/api.html
...
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
libvirt.spec.in | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7c60eba..2b50e94 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -188,6 +188,12 @@
%endif
+# there's no use compiling the network driver without
+# the libvirt daemon
+%if ! %{with_libvirtd}
+%define with_network 0
+%endif
+
Summary: Library providing a simple virtualization API
Name: libvirt
Version: @VERSION@
@@ -667,6 +673,8 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version}
%if ! %{with_libvirtd}
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/nwfilter
+mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-%{version}/html \
+ $RPM_BUILD_ROOT%{_datadir}/doc/libvirt-devel-%{version}/
%endif
%if ! %{with_qemu}
--
1.7.1
13 years, 11 months
[libvirt] [Patch v4 0/3] Add new feature into live migration
by Wen Congyang
If the memory of guest OS is changed constantly, the live migration
can not be ended ever for ever.
We can use the command 'virsh migrate-setmaxdowntime' to control the
live migration. But the value of maxdowntime is diffcult to calculate
because it depends on the transfer speed of network and constantly
changing memroy size. We need a easy way to control the live migration.
This patch set add the support of auto cold migration fallback on
timeout. With this patch set, when we migrate the guest OS, we can
specify a timeout. If the live migration timeouts, the migration will
fallback to cold migration.
Test of this patchset on Linux:
Env:
a. The size of guest OS's memory: 1GB
b. The transfer speed of network: about 100Mb/s
c. The size of constantly changing memory: more than 900MB
1. migrate without timeout
# virsh migrate --live RHEL6RC qemu+ssh://<dest IP>/system tcp://<dest IP>:49152
The migration does not end after 12 hours.
2. migrate with timeout(30 minutes):
# virsh -t migrate --live --timeout 1800 RHEL6RC qemu+ssh://<dest IP>/system tcp:<dest IP>:49152
(Time: 1828615.523 ms)
v4:
- move tools/timer.* into src/util/ directory
- use
v3:
- use the existing virEventXXXTimeout() APT to implement timer
- merge Add, Update, Delete into one single interface virSetTimeout()
- start timer thread when initializing timer
v2:
- implement timer for Windows
- implement dynamic timers
Wen Congyang (3):
move daemon/event.* into src/util/ directory
timer impl
force guest to suspend at timeout
cfg.mk | 1 +
daemon/Makefile.am | 1 -
daemon/event.c | 700 ----------------------------------------------
daemon/event.h | 134 ---------
daemon/libvirtd.c | 2 +-
src/Makefile.am | 4 +-
src/libvirt.c | 2 +
src/libvirt_private.syms | 20 ++
src/util/event_impl.c | 700 ++++++++++++++++++++++++++++++++++++++++++++++
src/util/event_impl.h | 134 +++++++++
src/util/timer.c | 159 +++++++++++
src/util/timer.h | 34 +++
tests/Makefile.am | 2 +-
tests/eventtest.c | 2 +-
tools/Makefile.am | 1 -
tools/console.c | 2 +-
tools/virsh.c | 69 +++++-
tools/virsh.pod | 4 +
18 files changed, 1129 insertions(+), 842 deletions(-)
delete mode 100644 daemon/event.c
delete mode 100644 daemon/event.h
create mode 100644 src/util/event_impl.c
create mode 100644 src/util/event_impl.h
create mode 100644 src/util/timer.c
create mode 100644 src/util/timer.h
13 years, 11 months
[libvirt] [PATCH] fix syntax error in configure.ac
by Wen Congyang
When I run configure, I receive some syntax error.
# ./configure --without-xenapi --without-xen
......
checking where to find <rpc/rpc.h>... none
checking for library containing dlopen... -ldl
./configure: line 52500: test: =: unary operator expected
./configure: line 52766: test: =: unary operator expected
checking linux/kvm.h usability... yes
checking linux/kvm.h presence... yes
......
Signed-off-by: Wen Congyang <wency(a)cn.fujitsu.com>
---
configure.ac | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index 51da1b0..377b9c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -430,6 +430,7 @@ old_CFLAGS="$CFLAGS"
LIBXENSERVER_LIBS=""
LIBXENSERVER_CFLAGS=""
dnl search for the XenServer library
+fail=0
if test "$with_xenapi" != "no" ; then
if test "$with_xenapi" != "yes" && test "$with_xenapi" != "check" ; then
LIBXENSERVER_CFLAGS="-I$with_xenapi/include"
--
1.7.1
13 years, 11 months
[libvirt] [PATCH] API: Improve log for domain related APIs
by Osier Yang
Add VM name/UUID in log for domain related APIs.
Format: "param0=%p, param1=%p, (VM: %s)"
* src/libvirt.c
---
src/libvirt.c | 294 +++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 221 insertions(+), 73 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index ee2495a..03dcafc 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1961,7 +1961,9 @@ error:
virConnectPtr
virDomainGetConnect (virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("dom=%p, (VM: %s)", dom, name);
virResetLastError();
@@ -2100,7 +2102,10 @@ error:
virDomainPtr
virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
- DEBUG("conn=%p, uuid=%s", conn, uuid);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(uuid, uuidstr);
+
+ DEBUG("conn=%p, uuid=%s", conn, uuidstr);
virResetLastError();
@@ -2226,8 +2231,9 @@ int
virDomainDestroy(virDomainPtr domain)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p", domain);
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2270,7 +2276,9 @@ error:
int
virDomainFree(virDomainPtr domain)
{
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2306,13 +2314,15 @@ virDomainFree(virDomainPtr domain)
int
virDomainRef(virDomainPtr domain)
{
+ const char *name = virDomainGetName(domain);
+
if ((!VIR_IS_CONNECTED_DOMAIN(domain))) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
virDispatchError(NULL);
return(-1);
}
virMutexLock(&domain->conn->lock);
- DEBUG("domain=%p refs=%d", domain, domain->refs);
+ DEBUG("domain=%p, refs=%d, (VM: %s)", domain, domain->refs, name);
domain->refs++;
virMutexUnlock(&domain->conn->lock);
return 0;
@@ -2335,7 +2345,9 @@ int
virDomainSuspend(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2380,7 +2392,9 @@ int
virDomainResume(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2428,7 +2442,9 @@ virDomainSave(virDomainPtr domain, const char *to)
{
char filepath[4096];
virConnectPtr conn;
- DEBUG("domain=%p, to=%s", domain, to);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, to=%s, (VM: %s)", domain, to, name);
virResetLastError();
@@ -2570,7 +2586,9 @@ virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
{
char filepath[4096];
virConnectPtr conn;
- DEBUG("domain=%p, to=%s, flags=%d", domain, to, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, to=%s, flags=%d, (VM: %s)", domain, to, flags, name);
virResetLastError();
@@ -2647,7 +2665,9 @@ int
virDomainShutdown(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2693,7 +2713,9 @@ int
virDomainReboot(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -2760,7 +2782,9 @@ virDomainGetName(virDomainPtr domain)
int
virDomainGetUUID(virDomainPtr domain, unsigned char *uuid)
{
- DEBUG("domain=%p, uuid=%p", domain, uuid);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, uuid=%p, (VM: %s)", domain, uuid, name);
virResetLastError();
@@ -2794,7 +2818,9 @@ int
virDomainGetUUIDString(virDomainPtr domain, char *buf)
{
unsigned char uuid[VIR_UUID_BUFLEN];
- DEBUG("domain=%p, buf=%p", domain, buf);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, buf=%p, (VM: %s)", domain, buf, name);
virResetLastError();
@@ -2830,7 +2856,9 @@ error:
unsigned int
virDomainGetID(virDomainPtr domain)
{
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2855,7 +2883,9 @@ char *
virDomainGetOSType(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2896,7 +2926,9 @@ unsigned long
virDomainGetMaxMemory(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -2942,7 +2974,9 @@ int
virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
{
virConnectPtr conn;
- DEBUG("domain=%p, memory=%lu", domain, memory);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, name);
virResetLastError();
@@ -2995,7 +3029,9 @@ int
virDomainSetMemory(virDomainPtr domain, unsigned long memory)
{
virConnectPtr conn;
- DEBUG("domain=%p, memory=%lu", domain, memory);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, memory=%lu, (VM: %s)", domain, memory, name);
virResetLastError();
@@ -3049,7 +3085,10 @@ virDomainSetMemoryParameters(virDomainPtr domain,
int nparams, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, nparams, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)",
+ domain, params, nparams, flags, name);
virResetLastError();
@@ -3123,7 +3162,11 @@ virDomainGetMemoryParameters(virDomainPtr domain,
int *nparams, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d, flags=%u", domain, params, (nparams)?*nparams:-1, flags);
+
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, flags=%u, (VM: %s)",
+ domain, params, (nparams)?*nparams:-1, flags, name);
virResetLastError();
@@ -3167,7 +3210,9 @@ int
virDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p", domain, info);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, name);
virResetLastError();
@@ -3215,7 +3260,9 @@ char *
virDomainGetXMLDesc(virDomainPtr domain, int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%d", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -3662,8 +3709,10 @@ virDomainMigrate (virDomainPtr domain,
unsigned long bandwidth)
{
virDomainPtr ddomain = NULL;
- DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu",
- domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, dconn=%p, flags=%lu, dname=%s, uri=%s, bandwidth=%lu, (VM: %s)",
+ domain, dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth, name);
virResetLastError();
@@ -3811,8 +3860,10 @@ virDomainMigrateToURI (virDomainPtr domain,
const char *dname,
unsigned long bandwidth)
{
- DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu",
- domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, duri=%p, flags=%lu, dname=%s, bandwidth=%lu, (VM: %s)",
+ domain, NULLSTR(duri), flags, NULLSTR(dname), bandwidth, name);
virResetLastError();
@@ -3924,9 +3975,11 @@ virDomainMigratePerform (virDomainPtr domain,
unsigned long bandwidth)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
+
VIR_DEBUG("domain=%p, cookie=%p, cookielen=%d, uri=%s, flags=%lu, "
- "dname=%s, bandwidth=%lu", domain, cookie, cookielen, uri, flags,
- NULLSTR(dname), bandwidth);
+ "dname=%s, bandwidth=%lu, (VM: %s)", domain, cookie,
+ cookielen, uri, flags, NULLSTR(dname), bandwidth, name);
virResetLastError();
@@ -4290,7 +4343,9 @@ virDomainGetSchedulerType(virDomainPtr domain, int *nparams)
{
virConnectPtr conn;
char *schedtype;
- DEBUG("domain=%p, nparams=%p", domain, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nparams=%p, (VM: %s)", domain, nparams, name);
virResetLastError();
@@ -4335,7 +4390,10 @@ virDomainGetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int *nparams)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%p", domain, params, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%p, (VM: %s)", domain,
+ params, nparams, name);
virResetLastError();
@@ -4378,7 +4436,10 @@ virDomainSetSchedulerParameters(virDomainPtr domain,
virSchedParameterPtr params, int nparams)
{
virConnectPtr conn;
- DEBUG("domain=%p, params=%p, nparams=%d", domain, params, nparams);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, params=%p, nparams=%d, (VM: %s)", domain,
+ params, nparams, name);
virResetLastError();
@@ -4438,7 +4499,10 @@ virDomainBlockStats (virDomainPtr dom, const char *path,
{
virConnectPtr conn;
struct _virDomainBlockStats stats2 = { -1, -1, -1, -1, -1 };
- DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom,
+ path, stats, size, name);
virResetLastError();
@@ -4496,7 +4560,10 @@ virDomainInterfaceStats (virDomainPtr dom, const char *path,
virConnectPtr conn;
struct _virDomainInterfaceStats stats2 = { -1, -1, -1, -1,
-1, -1, -1, -1 };
- DEBUG("domain=%p, path=%s, stats=%p, size=%zi", dom, path, stats, size);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, stats=%p, size=%zi, (VM: %s)", dom,
+ path, stats, size, name);
virResetLastError();
@@ -4561,7 +4628,9 @@ int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats,
{
virConnectPtr conn;
unsigned long nr_stats_ret = 0;
- DEBUG("domain=%p, stats=%p, nr_stats=%u", dom, stats, nr_stats);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, stats=%p, nr_stats=%u, (VM: %s)", dom, stats, nr_stats, name);
if (flags != 0) {
virLibDomainError (dom, VIR_ERR_INVALID_ARG,
@@ -4645,8 +4714,10 @@ virDomainBlockPeek (virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p",
- dom, path, offset, size, buffer);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, path=%s, offset=%lld, size=%zi, buffer=%p, (VM: %s)",
+ dom, path, offset, size, buffer, name);
virResetLastError();
@@ -4736,8 +4807,10 @@ virDomainMemoryPeek (virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d",
- dom, start, size, buffer, flags);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG ("domain=%p, start=%lld, size=%zi, buffer=%p, flags=%d, (VM: %s)",
+ dom, start, size, buffer, flags, name);
virResetLastError();
@@ -4821,7 +4894,9 @@ int
virDomainGetBlockInfo(virDomainPtr domain, const char *path, virDomainBlockInfoPtr info, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p flags=%u", domain, info, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p flags=%u, (VM: %s)", domain, info, flags, name);
virResetLastError();
@@ -4919,7 +4994,11 @@ error:
int
virDomainUndefine(virDomainPtr domain) {
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name;
+
+ name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -5041,7 +5120,9 @@ error:
int
virDomainCreate(virDomainPtr domain) {
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM :%s)", domain, name);
virResetLastError();
@@ -5084,7 +5165,9 @@ error:
int
virDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) {
virConnectPtr conn;
- DEBUG("domain=%p, flags=%d", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%d, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -5130,7 +5213,9 @@ virDomainGetAutostart(virDomainPtr domain,
int *autostart)
{
virConnectPtr conn;
- DEBUG("domain=%p, autostart=%p", domain, autostart);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, autostart=%p, (VM: %s)", domain, autostart, name);
virResetLastError();
@@ -5176,7 +5261,9 @@ virDomainSetAutostart(virDomainPtr domain,
int autostart)
{
virConnectPtr conn;
- DEBUG("domain=%p, autostart=%d", domain, autostart);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, autostart=%d, (VM: %s)", domain, autostart, name);
virResetLastError();
@@ -5230,7 +5317,9 @@ int
virDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
{
virConnectPtr conn;
- DEBUG("domain=%p, nvcpus=%u", domain, nvcpus);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nvcpus=%u, (VM: %s)", domain, nvcpus, name);
virResetLastError();
@@ -5296,7 +5385,10 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, nvcpus=%u, flags=%u", domain, nvcpus, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, nvcpus=%u, flags=%u, (VM: %s)", domain,
+ nvcpus, flags, name);
virResetLastError();
@@ -5359,7 +5451,9 @@ int
virDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -5417,7 +5511,10 @@ virDomainPinVcpu(virDomainPtr domain, unsigned int vcpu,
unsigned char *cpumap, int maplen)
{
virConnectPtr conn;
- DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d", domain, vcpu, cpumap, maplen);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, vcpu=%u, cpumap=%p, maplen=%d, (VM: %s)",
+ domain, vcpu, cpumap, maplen, name);
virResetLastError();
@@ -5480,7 +5577,10 @@ virDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d", domain, info, maxinfo, cpumaps, maplen);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, maxinfo=%d, cpumaps=%p, maplen=%d, (VM: %s)",
+ domain, info, maxinfo, cpumaps, maplen, name);
virResetLastError();
@@ -5536,7 +5636,9 @@ int
virDomainGetMaxVcpus(virDomainPtr domain)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -5665,7 +5767,9 @@ int
virDomainAttachDevice(virDomainPtr domain, const char *xml)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s", domain, xml);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, name);
virResetLastError();
@@ -5724,7 +5828,9 @@ virDomainAttachDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name);
virResetLastError();
@@ -5767,7 +5873,9 @@ int
virDomainDetachDevice(virDomainPtr domain, const char *xml)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s", domain, xml);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, (VM: %s)", domain, xml, name);
virResetLastError();
@@ -5822,7 +5930,11 @@ virDomainDetachDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name;
+
+ name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name);
virResetLastError();
@@ -5880,7 +5992,9 @@ virDomainUpdateDeviceFlags(virDomainPtr domain,
const char *xml, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, xml=%s, flags=%d", domain, xml, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, xml=%s, flags=%d, (VM: %s)", domain, xml, flags, name);
virResetLastError();
@@ -6206,7 +6320,10 @@ error:
virNetworkPtr
virNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
{
- DEBUG("conn=%p, uuid=%s", conn, uuid);
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(uuid, uuidstr);
+
+ DEBUG("conn=%p, uuid=%s", conn, uuidstr);
virResetLastError();
@@ -11431,7 +11548,9 @@ error:
*/
int virDomainIsPersistent(virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, (VM: %s)", dom, name);
virResetLastError();
@@ -11464,7 +11583,9 @@ error:
*/
int virDomainIsUpdated(virDomainPtr dom)
{
- DEBUG("dom=%p", dom);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("domain=%p, (VM: %s)", dom, name);
virResetLastError();
@@ -12353,7 +12474,9 @@ int
virDomainGetJobInfo(virDomainPtr domain, virDomainJobInfoPtr info)
{
virConnectPtr conn;
- DEBUG("domain=%p, info=%p", domain, info);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, info=%p, (VM: %s)", domain, info, name);
virResetLastError();
@@ -12401,8 +12524,9 @@ int
virDomainAbortJob(virDomainPtr domain)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p", domain);
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -12452,8 +12576,10 @@ virDomainMigrateSetMaxDowntime(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, downtime=%llu, flags=%u", domain, downtime, flags);
+ DEBUG("domain=%p, downtime=%llu, flags=%u, (VM: %s)", domain,
+ downtime, flags, name);
virResetLastError();
@@ -12522,7 +12648,12 @@ virConnectDomainEventRegisterAny(virConnectPtr conn,
void *opaque,
virFreeCallback freecb)
{
- DEBUG("conn=%p dom=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p", conn, dom, eventID, cb, opaque, freecb);
+ const char *name;
+
+ name = virDomainGetName(dom);
+
+ DEBUG("conn=%p, domain=%p, eventID=%d, cb=%p, opaque=%p, freecb=%p, (VM: %s)",
+ conn, dom, eventID, cb, opaque, freecb, name);
virResetLastError();
if (!VIR_IS_CONNECT(conn)) {
@@ -12614,8 +12745,9 @@ error:
int virDomainManagedSave(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom%p, flags=%u, (VM: %s)", dom, flags, name);
virResetLastError();
@@ -12662,8 +12794,9 @@ error:
int virDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, name);
virResetLastError();
@@ -12703,8 +12836,9 @@ error:
int virDomainManagedSaveRemove(virDomainPtr dom, unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(dom);
- VIR_DEBUG("dom=%p, flags=%u", dom, flags);
+ VIR_DEBUG("dom=%p, flags=%u, (VM: %s)", dom, flags, name);
virResetLastError();
@@ -12753,8 +12887,9 @@ virDomainSnapshotCreateXML(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, xmlDesc=%s, flags=%u", domain, xmlDesc, flags);
+ DEBUG("domain=%p, xmlDesc=%s, flags=%u, (VM: %s)", domain, xmlDesc, flags, name);
virResetLastError();
@@ -12845,7 +12980,9 @@ int
virDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p", domain);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, (VM: %s)", domain, name);
virResetLastError();
@@ -12887,9 +13024,10 @@ virDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
unsigned int flags)
{
virConnectPtr conn;
+ const char *name = virDomainGetName(domain);
- DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u",
- domain, names, nameslen, flags);
+ DEBUG("domain=%p, names=%p, nameslen=%d, flags=%u, (VM: %s)",
+ domain, names, nameslen, flags, name);
virResetLastError();
@@ -12938,7 +13076,10 @@ virDomainSnapshotLookupByName(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, name=%s, flags=%u", domain, name, flags);
+ const char *domname = virDomainGetName(domain);
+
+ DEBUG("domain=%p, name=%s, flags=%u, (VM: %s)", domain, name,
+ flags, domname);
virResetLastError();
@@ -12982,7 +13123,9 @@ int
virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -13023,7 +13166,9 @@ virDomainSnapshotCurrent(virDomainPtr domain,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("domain=%p, flags=%u", domain, flags);
+ const char *name = virDomainGetName(domain);
+
+ DEBUG("domain=%p, flags=%u, (VM: %s)", domain, flags, name);
virResetLastError();
@@ -13187,7 +13332,10 @@ int virDomainOpenConsole(virDomainPtr dom,
unsigned int flags)
{
virConnectPtr conn;
- DEBUG("dom=%p devname=%s, st=%p flags=%u", dom, NULLSTR(devname), st, flags);
+ const char *name = virDomainGetName(dom);
+
+ DEBUG("dom=%p, devname=%s, st=%p, flags=%u, (VM: %s)", dom,
+ NULLSTR(devname), st, flags, name);
virResetLastError();
--
1.7.3.2
13 years, 11 months
[libvirt] Back and suggested release schedule
by Daniel Veillard
Hello all,
as some of you may have noticed, I'm back online, just in a very
different timezone now !
I'm still behind on reading the list emails but a lot of the changes
in the last month have been refactoring and cleanups, and maybe we ought
to make a new release at the end of the month to try to catch possible
regressions introduced as early as possible. What do people think of a new
release for the new year, which would mean entering freeze over the
week-end. My own testing will probably be limited as most of my machines
are in boxes in a container somewhere, but I should be able to make
a release :-)
Also on the release name, should we go 0.9.0 considering the refactorings
(i.e. indicating future patches will be harder to apply to earlier branches)
or stick to 0.8.7 (considering that there isn't major feature improvement
... unless I missed them !),
Opinions ?
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
13 years, 11 months