Oracle VM Virtualbox Programming Guide
Total Page:16
File Type:pdf, Size:1020Kb
Oracle VM VirtualBox R Programming Guide and Reference Version 5.0.0_BETA1 c 2004-2015 Oracle Corporation http://www.virtualbox.org Contents 1 Introduction 20 1.1 Modularity: the building blocks of VirtualBox................... 20 1.2 Two guises of the same “Main API”: the web service or COM/XPCOM...... 21 1.3 About web services in general............................ 22 1.4 Running the web service............................... 23 1.4.1 Command line options of vboxwebsrv................... 23 1.4.2 Authenticating at web service logon.................... 24 2 Environment-specific notes 26 2.1 Using the object-oriented web service (OOWS)................... 26 2.1.1 The object-oriented web service for JAX-WS................ 26 2.1.2 The object-oriented web service for Python................ 28 2.1.3 The object-oriented web service for PHP................. 29 2.2 Using the raw web service with any language................... 29 2.2.1 Raw web service example for Java with Axis............... 29 2.2.2 Raw web service example for Perl..................... 30 2.2.3 Programming considerations for the raw web service.......... 31 2.3 Using COM/XPCOM directly............................. 35 2.3.1 Python COM API.............................. 35 2.3.2 Common Python bindings layer...................... 35 2.3.3 C++ COM API............................... 36 2.3.4 Event queue processing........................... 37 2.3.5 Visual Basic and Visual Basic Script (VBS) on Windows hosts...... 38 2.3.6 C binding to VirtualBox API........................ 38 3 Basic VirtualBox concepts; some examples 46 3.1 Obtaining basic machine information. Reading attributes............. 46 3.2 Changing machine settings: Sessions........................ 46 3.3 Launching virtual machines............................. 47 3.4 VirtualBox events................................... 47 4 The VirtualBox shell 49 5 Classes (interfaces) 51 5.1 IAdditionsFacility................................... 51 5.1.1 Attributes.................................. 51 5.2 IAdditionsStateChangedEvent (IEvent)....................... 51 5.2.1 Attributes.................................. 52 5.3 IAppliance....................................... 52 5.3.1 Attributes.................................. 53 5.3.2 createVFSExplorer.............................. 54 5.3.3 getWarnings................................. 54 5.3.4 importMachines............................... 54 5.3.5 interpret................................... 54 5.3.6 read..................................... 55 5.3.7 write..................................... 55 2 Contents 5.4 IAudioAdapter..................................... 55 5.4.1 Attributes.................................. 55 5.5 IBIOSSettings..................................... 56 5.5.1 Attributes.................................. 56 5.6 IBandwidthControl.................................. 57 5.6.1 Attributes.................................. 57 5.6.2 createBandwidthGroup........................... 57 5.6.3 deleteBandwidthGroup........................... 58 5.6.4 getAllBandwidthGroups........................... 58 5.6.5 getBandwidthGroup............................. 58 5.7 IBandwidthGroup................................... 58 5.7.1 Attributes.................................. 58 5.8 IBandwidthGroupChangedEvent (IEvent)...................... 59 5.8.1 Attributes.................................. 59 5.9 ICPUChangedEvent (IEvent)............................. 59 5.9.1 Attributes.................................. 59 5.10 ICPUExecutionCapChangedEvent (IEvent)..................... 59 5.10.1 Attributes.................................. 59 5.11 ICanShowWindowEvent (IVetoEvent)........................ 60 5.11.1 Attributes.................................. 60 5.12 IClipboardModeChangedEvent (IEvent)....................... 60 5.12.1 Attributes.................................. 60 5.13 IConsole........................................ 60 5.13.1 Attributes.................................. 60 5.13.2 addDiskEncryptionPassword........................ 63 5.13.3 addDiskEncryptionPasswords........................ 63 5.13.4 adoptSavedState............................... 63 5.13.5 attachUSBDevice.............................. 64 5.13.6 clearAllDiskEncryptionPasswords..................... 64 5.13.7 createSharedFolder............................. 64 5.13.8 deleteSnapshot............................... 65 5.13.9 deleteSnapshotAndAllChildren....................... 66 5.13.10 deleteSnapshotRange............................ 66 5.13.11 detachUSBDevice.............................. 67 5.13.12 discardSavedState.............................. 67 5.13.13 findUSBDeviceByAddress.......................... 67 5.13.14 findUSBDeviceById............................. 68 5.13.15 getDeviceActivity.............................. 68 5.13.16 getGuestEnteredACPIMode......................... 68 5.13.17 getPowerButtonHandled.......................... 68 5.13.18 pause..................................... 68 5.13.19 powerButton................................. 69 5.13.20 powerDown................................. 69 5.13.21 powerUp................................... 69 5.13.22 powerUpPaused............................... 70 5.13.23 removeDiskEncryptionPassword...................... 70 5.13.24 removeSharedFolder............................ 70 5.13.25 reset..................................... 70 5.13.26 restoreSnapshot............................... 71 5.13.27 resume.................................... 71 5.13.28 saveState................................... 71 5.13.29 sleepButton................................. 72 5.13.30 takeSnapshot................................ 72 3 Contents 5.13.31 teleport.................................... 72 5.14 IDHCPServer..................................... 73 5.14.1 Attributes.................................. 73 5.14.2 addGlobalOption.............................. 74 5.14.3 addVmSlotOption.............................. 74 5.14.4 getMacOptions................................ 74 5.14.5 getVmSlotOptions.............................. 75 5.14.6 removeVmSlotOptions........................... 75 5.14.7 setConfiguration............................... 75 5.14.8 start..................................... 75 5.14.9 stop...................................... 76 5.15 IDirectory....................................... 76 5.15.1 Attributes.................................. 76 5.15.2 close..................................... 76 5.15.3 read..................................... 76 5.16 IDisplay........................................ 76 5.16.1 attachFramebuffer.............................. 77 5.16.2 completeVHWACommand......................... 77 5.16.3 detachFramebuffer............................. 77 5.16.4 drawToScreen................................ 77 5.16.5 getScreenResolution............................. 78 5.16.6 invalidateAndUpdate............................ 78 5.16.7 invalidateAndUpdateScreen........................ 78 5.16.8 notifyHiDPIOutputPolicyChange...................... 79 5.16.9 notifyScaleFactorChange.......................... 79 5.16.10 queryFramebuffer.............................. 79 5.16.11 querySourceBitmap............................. 79 5.16.12 setSeamlessMode.............................. 79 5.16.13 setVideoModeHint.............................. 80 5.16.14 takeScreenShot............................... 80 5.16.15 takeScreenShotToArray........................... 81 5.16.16 viewportChanged.............................. 81 5.17 IDisplaySourceBitmap................................ 82 5.17.1 Attributes.................................. 82 5.17.2 queryBitmapInfo............................... 82 5.18 IDnDBase....................................... 82 5.18.1 Attributes.................................. 82 5.18.2 addFormats................................. 82 5.18.3 isFormatSupported............................. 83 5.18.4 removeFormats............................... 83 5.19 IDnDModeChangedEvent (IEvent).......................... 83 5.19.1 Attributes.................................. 83 5.20 IDnDSource (IDnDBase)............................... 83 5.20.1 dragIsPending................................ 83 5.20.2 drop..................................... 84 5.20.3 receiveData................................. 84 5.21 IDnDTarget (IDnDBase)............................... 84 5.21.1 drop..................................... 84 5.21.2 enter..................................... 85 5.21.3 leave..................................... 85 5.21.4 move..................................... 85 5.21.5 sendData................................... 86 5.22 IEmulatedUSB..................................... 86 4 Contents 5.22.1 Attributes.................................. 86 5.22.2 webcamAttach................................ 86 5.22.3 webcamDetach............................... 86 5.23 IEvent......................................... 87 5.23.1 Attributes.................................. 88 5.23.2 setProcessed................................. 88 5.23.3 waitProcessed................................ 88 5.24 IEventListener..................................... 88 5.24.1 handleEvent................................. 88 5.25 IEventSource..................................... 89 5.25.1 createAggregator.............................. 89 5.25.2 createListener................................ 89 5.25.3 eventProcessed............................... 89 5.25.4 fireEvent................................... 89 5.25.5 getEvent................................... 90 5.25.6 registerListener............................... 90 5.25.7 unregisterListener.............................