[PATCH 49/66] vbox: Add API for vboxDomainSnapshotCreateXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/vbox/vbox_common.h        |    1 +
 src/vbox/vbox_tmpl.c          |  171 ++++++++++++++++++++++++++++++++++++++++-
 src/vbox/vbox_uniformed_api.h |   17 ++++
 3 files changed, 187 insertions(+), 2 deletions(-)

diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index 434689b..a093481 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -269,5 +269,6 @@ typedef nsISupports IMedium;
 typedef nsISupports IMediumAttachment;
 typedef nsISupports IStorageController;
 typedef nsISupports ISharedFolder;
+typedef nsISupports ISnapshot;
 
 #endif /* VBOX_COMMON_H */
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index eeebd6f..2d5ea5c 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -665,7 +665,6 @@ _vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu,
     vboxIIDFromArrayItem_v3_x(data, &iidu->vboxIID_v3_x, array, idx);
 }
 
-
 # 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)
@@ -676,7 +675,6 @@ _vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu,
 
 #endif /* !(VBOX_API_VERSION == 2002000) */
 
-
 /**
  * function to generate the name for medium,
  * for e.g: hda, sda, etc
@@ -7785,6 +7783,18 @@ static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu)
 
 #endif /* VBOX_API_VERSION != 2002000 */
 
+static void
+_vboxIIDToUtf8(vboxGlobalData *data ATTRIBUTE_UNUSED,
+               vboxIIDUnion *iidu ATTRIBUTE_UNUSED,
+               char **utf8 ATTRIBUTE_UNUSED)
+{
+#if VBOX_API_VERSION == 2002000
+    vboxUnsupported();
+#else /* !(VBOX_API_VERSION == 2002000) */
+    data->pFuncs->pfnUtf16ToUtf8(IID_MEMBER(value), utf8);
+#endif /* !(VBOX_API_VERSION == 2002000) */
+}
+
 static void* _handleGetMachines(IVirtualBox *vboxObj)
 {
     return vboxObj->vtbl->GetMachines;
@@ -7839,6 +7849,12 @@ _virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machi
 #endif /* VBOX_API_VERSION >= 4000000 */
 
 static nsresult
+_virtualboxOpenMachine(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine)
+{
+    return vboxObj->vtbl->OpenMachine(vboxObj, settingsFile, machine);
+}
+
+static nsresult
 _virtualboxGetSystemProperties(IVirtualBox *vboxObj, ISystemProperties **systemProperties)
 {
     return vboxObj->vtbl->GetSystemProperties(vboxObj, systemProperties);
@@ -7909,6 +7925,20 @@ _virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **m
 }
 
 static nsresult
+_virtualboxCreateHardDiskMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED,
+                                PRUnichar *format ATTRIBUTE_UNUSED,
+                                PRUnichar *location ATTRIBUTE_UNUSED,
+                                IMedium **medium ATTRIBUTE_UNUSED)
+{
+#if VBOX_API_VERSION < 3001000
+    vboxUnsupported();
+    return 0;
+#else /* VBOX_API_VERSION >= 3001000 */
+    return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, medium);
+#endif /* VBOX_API_VERSION >= 3001000 */
+}
+
+static nsresult
 _virtualboxRegisterMachine(IVirtualBox *vboxObj, IMachine *machine)
 {
     return vboxObj->vtbl->RegisterMachine(vboxObj, machine);
@@ -8032,6 +8062,20 @@ _machineLaunchVMProcess(vboxGlobalData *data,
 }
 
 static nsresult
+_machineUnregister(IMachine *machine ATTRIBUTE_UNUSED,
+                   PRUint32 cleanupMode ATTRIBUTE_UNUSED,
+                   PRUint32 *aMediaSize ATTRIBUTE_UNUSED,
+                   IMedium ***aMedia ATTRIBUTE_UNUSED)
+{
+#if VBOX_API_VERSION < 4000000
+    vboxUnsupported();
+    return 0;
+#else /* VBOX_API_VERSION >= 4000000 */
+    return machine->vtbl->Unregister(machine, cleanupMode, aMediaSize, aMedia);
+#endif /* VBOX_API_VERSION >= 4000000 */
+}
+
+static nsresult
 _machineGetAccessible(IMachine *machine, PRBool *isAccessible)
 {
     return machine->vtbl->GetAccessible(machine, isAccessible);
@@ -8117,6 +8161,18 @@ _machineGetUSBCommon(IMachine *machine, IUSBCommon **USBCommon)
 }
 
 static nsresult
+_machineGetCurrentSnapshot(IMachine *machine, ISnapshot **currentSnapshot)
+{
+    return machine->vtbl->GetCurrentSnapshot(machine, currentSnapshot);
+}
+
+static nsresult
+_machineGetSettingsFilePath(IMachine *machine, PRUnichar **settingsFilePath)
+{
+    return machine->vtbl->GetSettingsFilePath(machine, settingsFilePath);
+}
+
+static nsresult
 _machineGetCPUCount(IMachine *machine, PRUint32 *CPUCount)
 {
     return machine->vtbl->GetCPUCount(machine, CPUCount);
@@ -8356,6 +8412,13 @@ _consoleReset(IConsole *console)
 }
 
 static nsresult
+_consoleTakeSnapshot(IConsole *console, PRUnichar *name,
+                     PRUnichar *description, IProgress **progress)
+{
+    return console->vtbl->TakeSnapshot(console, name, description, progress);
+}
+
+static nsresult
 _progressWaitForCompletion(IProgress *progress, PRInt32 timeout)
 {
     return progress->vtbl->WaitForCompletion(progress, timeout);
@@ -9011,10 +9074,74 @@ static nsresult _mediumGetReadOnly(IMedium *medium ATTRIBUTE_UNUSED,
 #endif /* VBOX_API_VERSION >= 3001000 */
 }
 
+#if VBOX_API_VERSION < 3001000
+
+static nsresult _mediumGetParent(IMedium *medium ATTRIBUTE_UNUSED,
+                                 IMedium **parent ATTRIBUTE_UNUSED)
+{
+    vboxUnsupported();
+    return 0;
+}
+
+static nsresult _mediumGetChildren(IMedium *medium ATTRIBUTE_UNUSED,
+                                   PRUint32 *childrenSize ATTRIBUTE_UNUSED,
+                                   IMedium ***children ATTRIBUTE_UNUSED)
+{
+    vboxUnsupported();
+    return 0;
+}
+
+static nsresult _mediumGetFormat(IMedium *medium ATTRIBUTE_UNUSED,
+                                 PRUnichar **format ATTRIBUTE_UNUSED)
+{
+    vboxUnsupported();
+    return 0;
+}
+
+static nsresult _mediumDeleteStorage(IMedium *medium ATTRIBUTE_UNUSED,
+                                     IProgress **progress ATTRIBUTE_UNUSED)
+{
+    vboxUnsupported();
+    return 0;
+}
+
+#else /* VBOX_API_VERSION >= 3001000 */
+
+static nsresult _mediumGetParent(IMedium *medium,
+                                 IMedium **parent)
+{
+    return medium->vtbl->GetParent(medium, parent);
+}
+
+static nsresult _mediumGetChildren(IMedium *medium,
+                                   PRUint32 *childrenSize,
+                                   IMedium ***children)
+{
+    return medium->vtbl->GetChildren(medium, childrenSize, children);
+}
+
+static nsresult _mediumGetFormat(IMedium *medium,
+                                 PRUnichar **format)
+{
+    return medium->vtbl->GetFormat(medium, format);
+}
+
+static nsresult _mediumDeleteStorage(IMedium *medium,
+                                     IProgress **progress)
+{
+    return medium->vtbl->DeleteStorage(medium, progress);
+}
+
+#endif /* VBOX_API_VERSION >= 3001000 */
+
 static nsresult _mediumRelease(IMedium *medium)
 {
     return medium->vtbl->nsisupports.Release((nsISupports *)medium);
 }
+static nsresult _mediumClose(IMedium *medium)
+{
+    return medium->vtbl->Close(medium);
+}
 
 static nsresult _mediumSetType(IMedium *medium ATTRIBUTE_UNUSED,
                                PRUint32 type ATTRIBUTE_UNUSED)
@@ -9028,6 +9155,27 @@ static nsresult _mediumSetType(IMedium *medium ATTRIBUTE_UNUSED,
 }
 
 static nsresult
+_mediumCreateDiffStorage(IMedium *medium ATTRIBUTE_UNUSED,
+                         IMedium *target ATTRIBUTE_UNUSED,
+                         PRUint32 variantSize ATTRIBUTE_UNUSED,
+                         PRUint32 *variant ATTRIBUTE_UNUSED,
+                         IProgress **progress ATTRIBUTE_UNUSED)
+{
+#if VBOX_API_VERSION < 3001000
+    vboxUnsupported();
+    return 0;
+#elif VBOX_API_VERSION < 4003000
+    if (variantSize == 0)
+        return 0;
+    if (variantSize > 1)
+        VIR_WARN("Only one variant is avaible in current version");
+    return medium->vtbl->CreateDiffStorage(medium, target, variant[0], progress);
+#else /* VBOX_API_VERSION >= 4003000 */
+    return medium->vtbl->CreateDiffStorage(medium, target, variantSize, variant, progress);
+#endif /* VBOX_API_VERSION >= 4003000 */
+}
+
+static nsresult
 _mediumAttachmentGetMedium(IMediumAttachment *mediumAttachment ATTRIBUTE_UNUSED,
                            IMedium **medium ATTRIBUTE_UNUSED)
 {
@@ -9145,6 +9293,7 @@ static vboxUniformedIID _UIID = {
     .vboxIIDFromUUID = _vboxIIDFromUUID,
     .vboxIIDIsEqual = _vboxIIDIsEqual,
     .vboxIIDFromArrayItem = _vboxIIDFromArrayItem,
+    .vboxIIDToUtf8 = _vboxIIDToUtf8,
     .DEBUGIID = _DEBUGIID,
 };
 
@@ -9164,8 +9313,10 @@ static vboxUniformednsISupports _nsUISupports = {
 static vboxUniformedIVirtualBox _UIVirtualBox = {
     .GetVersion = _virtualboxGetVersion,
     .GetMachine = _virtualboxGetMachine,
+    .OpenMachine = _virtualboxOpenMachine,
     .GetSystemProperties = _virtualboxGetSystemProperties,
     .CreateMachine = _virtualboxCreateMachine,
+    .CreateHardDiskMedium = _virtualboxCreateHardDiskMedium,
     .RegisterMachine = _virtualboxRegisterMachine,
     .FindMedium = _virtualboxFindMedium,
     .OpenMedium = _virtualboxOpenMedium,
@@ -9178,6 +9329,7 @@ static vboxUniformedIMachine _UIMachine = {
     .CreateSharedFolder = _machineCreateSharedFolder,
     .RemoveSharedFolder = _machineRemoveSharedFolder,
     .LaunchVMProcess = _machineLaunchVMProcess,
+    .Unregister = _machineUnregister,
     .GetAccessible = _machineGetAccessible,
     .GetState = _machineGetState,
     .GetName = _machineGetName,
@@ -9190,6 +9342,8 @@ static vboxUniformedIMachine _UIMachine = {
     .GetParallelPort = _machineGetParallelPort,
     .GetVRDxServer = _machineGetVRDxServer,
     .GetUSBCommon = _machineGetUSBCommon,
+    .GetCurrentSnapshot = _machineGetCurrentSnapshot,
+    .GetSettingsFilePath = _machineGetSettingsFilePath,
     .GetCPUCount = _machineGetCPUCount,
     .SetCPUCount = _machineSetCPUCount,
     .GetMemorySize = _machineGetMemorySize,
@@ -9226,6 +9380,7 @@ static vboxUniformedIConsole _UIConsole = {
     .PowerButton = _consolePowerButton,
     .PowerDown = _consolePowerDown,
     .Reset = _consoleReset,
+    .TakeSnapshot = _consoleTakeSnapshot,
 };
 
 static vboxUniformedIProgress _UIProgress = {
@@ -9336,8 +9491,14 @@ static vboxUniformedIMedium _UIMedium = {
     .GetId = _mediumGetId,
     .GetLocation = _mediumGetLocation,
     .GetReadOnly = _mediumGetReadOnly,
+    .GetParent = _mediumGetParent,
+    .GetChildren = _mediumGetChildren,
+    .GetFormat = _mediumGetFormat,
+    .DeleteStorage = _mediumDeleteStorage,
     .Release = _mediumRelease,
+    .Close = _mediumClose,
     .SetType = _mediumSetType,
+    .CreateDiffStorage = _mediumCreateDiffStorage,
 };
 
 static vboxUniformedIMediumAttachment _UIMediumAttachment = {
@@ -9445,6 +9606,12 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
     pVBoxAPI->accelerate2DVideo = 0;
     pVBoxAPI->oldMediumInterface = 1;
 #endif /* VBOX_API_VERSION < 3001000 */
+
+#if VBOX_API_VERSION >= 4002000
+    pVBoxAPI->vboxSnapshotRedefine = 1;
+#else /* VBOX_API_VERSION < 4002000 */
+    pVBoxAPI->vboxSnapshotRedefine = 0;
+#endif /* VBOX_API_VERSION < 4002000 */
 }
 
 /**
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 48c2973..b36e154 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -159,6 +159,7 @@ typedef struct {
     void (*vboxIIDFromUUID)(vboxGlobalData *data, vboxIIDUnion *iidu, const unsigned char *uuid);
     bool (*vboxIIDIsEqual)(vboxGlobalData *data, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2);
     void (*vboxIIDFromArrayItem)(vboxGlobalData *data, vboxIIDUnion *iidu, vboxArray *array, int idx);
+    void (*vboxIIDToUtf8)(vboxGlobalData *data, vboxIIDUnion *iidu, char **utf8);
     void (*DEBUGIID)(const char *msg, vboxIIDUnion *iidu);
 } vboxUniformedIID;
 
@@ -182,8 +183,10 @@ typedef struct {
 typedef struct {
     nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16);
     nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine);
+    nsresult (*OpenMachine)(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine);
     nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties);
     nsresult (*CreateMachine)(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr);
+    nsresult (*CreateHardDiskMedium)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar *location, IMedium **medium);
     nsresult (*RegisterMachine)(IVirtualBox *vboxObj, IMachine *machine);
     nsresult (*FindMedium)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium);
     nsresult (*OpenMedium)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium);
@@ -206,6 +209,8 @@ typedef struct {
                                 vboxIIDUnion *iidu,
                                 PRUnichar *sessionType, PRUnichar *env,
                                 IProgress **progress);
+    nsresult (*Unregister)(IMachine *machine, PRUint32 cleanupMode,
+                           PRUint32 *aMediaSize, IMedium ***aMedia);
     nsresult (*GetAccessible)(IMachine *machine, PRBool *isAccessible);
     nsresult (*GetState)(IMachine *machine, PRUint32 *state);
     nsresult (*GetName)(IMachine *machine, PRUnichar **name);
@@ -218,6 +223,8 @@ typedef struct {
     nsresult (*GetParallelPort)(IMachine *machine, PRUint32 slot, IParallelPort **port);
     nsresult (*GetVRDxServer)(IMachine *machine, IVRDxServer **VRDxServer);
     nsresult (*GetUSBCommon)(IMachine *machine, IUSBCommon **USBCommon);
+    nsresult (*GetCurrentSnapshot)(IMachine *machine, ISnapshot **currentSnapshot);
+    nsresult (*GetSettingsFilePath)(IMachine *machine, PRUnichar **settingsFilePath);
     nsresult (*GetCPUCount)(IMachine *machine, PRUint32 *CPUCount);
     nsresult (*SetCPUCount)(IMachine *machine, PRUint32 CPUCount);
     nsresult (*GetMemorySize)(IMachine *machine, PRUint32 *memorySize);
@@ -256,6 +263,8 @@ typedef struct {
     nsresult (*PowerButton)(IConsole *console);
     nsresult (*PowerDown)(IConsole *console);
     nsresult (*Reset)(IConsole *console);
+    nsresult (*TakeSnapshot)(IConsole *console, PRUnichar *name,
+                             PRUnichar *description, IProgress **progress);
 } vboxUniformedIConsole;
 
 /* Functions for IProgress */
@@ -385,8 +394,15 @@ typedef struct {
     nsresult (*GetId)(IMedium *medium, vboxIIDUnion *iidu);
     nsresult (*GetLocation)(IMedium *medium, PRUnichar **location);
     nsresult (*GetReadOnly)(IMedium *medium, PRBool *readOnly);
+    nsresult (*GetParent)(IMedium *medium, IMedium **parent);
+    nsresult (*GetChildren)(IMedium *medium, PRUint32 *childrenSize, IMedium ***children);
+    nsresult (*GetFormat)(IMedium *medium, PRUnichar **format);
+    nsresult (*DeleteStorage)(IMedium *medium, IProgress **progress);
     nsresult (*Release)(IMedium *medium);
+    nsresult (*Close)(IMedium *medium);
     nsresult (*SetType)(IMedium *medium, PRUint32 type);
+    nsresult (*CreateDiffStorage)(IMedium *medium, IMedium *target, PRUint32 variantSize,
+                                  PRUint32 *variant, IProgress **progress);
 } vboxUniformedIMedium;
 
 /* Functions for IMediumAttachment */
@@ -471,6 +487,7 @@ typedef struct {
     bool accelerate2DVideo;
     bool vboxAttachDrivesUseOld;
     bool oldMediumInterface;
+    bool vboxSnapshotRedefine;
 } vboxUniformedAPI;
 
 /* libvirt API
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]