Oracle VM Virtualbox Programming Guide and Reference
Total Page:16
File Type:pdf, Size:1020Kb
Oracle VM VirtualBox R Programming Guide and Reference Version 5.2.4 c 2004-2017 Oracle Corporation http://www.virtualbox.org Contents 1 Introduction 21 1.1 Modularity: the building blocks of VirtualBox................... 21 1.2 Two guises of the same “Main API”: the web service or COM/XPCOM...... 22 1.3 About web services in general............................ 23 1.4 Running the web service............................... 24 1.4.1 Command line options of vboxwebsrv................... 24 1.4.2 Authenticating at web service logon.................... 25 2 Environment-specific notes 27 2.1 Using the object-oriented web service (OOWS)................... 27 2.1.1 The object-oriented web service for JAX-WS................ 27 2.1.2 The object-oriented web service for Python................ 29 2.1.3 The object-oriented web service for PHP................. 30 2.2 Using the raw web service with any language................... 30 2.2.1 Raw web service example for Java with Axis............... 30 2.2.2 Raw web service example for Perl..................... 31 2.2.3 Programming considerations for the raw web service.......... 32 2.3 Using COM/XPCOM directly............................. 36 2.3.1 Python COM API.............................. 36 2.3.2 Common Python bindings layer...................... 36 2.3.3 C++ COM API............................... 38 2.3.4 Event queue processing........................... 38 2.3.5 Visual Basic and Visual Basic Script (VBS) on Windows hosts...... 39 2.3.6 C binding to VirtualBox API........................ 39 3 Basic VirtualBox concepts; some examples 47 3.1 Obtaining basic machine information. Reading attributes............. 47 3.2 Changing machine settings: Sessions........................ 47 3.3 Launching virtual machines............................. 48 3.4 VirtualBox events................................... 48 4 The VirtualBox shell 50 5 Classes (interfaces) 52 5.1 IAdditionsFacility................................... 52 5.1.1 Attributes.................................. 52 5.2 IAdditionsStateChangedEvent (IEvent)....................... 52 5.2.1 Attributes.................................. 53 5.3 IAppliance....................................... 53 5.3.1 Attributes.................................. 54 5.3.2 addPasswords................................ 55 5.3.3 createVFSExplorer.............................. 55 5.3.4 getMediumIdsForPasswordId........................ 55 5.3.5 getPasswordIds............................... 55 5.3.6 getWarnings................................. 55 5.3.7 importMachines............................... 56 2 Contents 5.3.8 interpret................................... 56 5.3.9 read..................................... 56 5.3.10 write..................................... 56 5.4 IAudioAdapter..................................... 57 5.4.1 Attributes.................................. 57 5.4.2 getProperty................................. 58 5.4.3 setProperty.................................. 58 5.5 IAudioAdapterChangedEvent (IEvent)........................ 58 5.5.1 Attributes.................................. 58 5.6 IBIOSSettings..................................... 59 5.6.1 Attributes.................................. 59 5.7 IBandwidthControl.................................. 60 5.7.1 Attributes.................................. 60 5.7.2 createBandwidthGroup........................... 60 5.7.3 deleteBandwidthGroup........................... 61 5.7.4 getAllBandwidthGroups........................... 61 5.7.5 getBandwidthGroup............................. 61 5.8 IBandwidthGroup................................... 61 5.8.1 Attributes.................................. 61 5.9 IBandwidthGroupChangedEvent (IEvent)...................... 62 5.9.1 Attributes.................................. 62 5.10 ICPUChangedEvent (IEvent)............................. 62 5.10.1 Attributes.................................. 62 5.11 ICPUExecutionCapChangedEvent (IEvent)..................... 62 5.11.1 Attributes.................................. 62 5.12 ICanShowWindowEvent (IVetoEvent)........................ 63 5.12.1 Attributes.................................. 63 5.13 ICertificate....................................... 63 5.13.1 Attributes.................................. 63 5.13.2 isCurrentlyExpired............................. 65 5.13.3 queryInfo................................... 65 5.14 IClipboardModeChangedEvent (IEvent)....................... 65 5.14.1 Attributes.................................. 66 5.15 IConsole........................................ 66 5.15.1 Attributes.................................. 66 5.15.2 addDiskEncryptionPassword........................ 68 5.15.3 addDiskEncryptionPasswords........................ 69 5.15.4 attachUSBDevice.............................. 69 5.15.5 clearAllDiskEncryptionPasswords..................... 69 5.15.6 createSharedFolder............................. 69 5.15.7 detachUSBDevice.............................. 70 5.15.8 findUSBDeviceByAddress.......................... 70 5.15.9 findUSBDeviceById............................. 70 5.15.10 getDeviceActivity.............................. 71 5.15.11 getGuestEnteredACPIMode......................... 71 5.15.12 getPowerButtonHandled.......................... 71 5.15.13 pause..................................... 71 5.15.14 powerButton................................. 71 5.15.15 powerDown................................. 72 5.15.16 powerUp................................... 72 5.15.17 powerUpPaused............................... 72 5.15.18 removeDiskEncryptionPassword...................... 73 5.15.19 removeSharedFolder............................ 73 3 Contents 5.15.20 reset..................................... 73 5.15.21 resume.................................... 73 5.15.22 sleepButton................................. 73 5.15.23 teleport.................................... 74 5.16 IDHCPServer..................................... 74 5.16.1 Attributes.................................. 74 5.16.2 addGlobalOption.............................. 75 5.16.3 addVmSlotOption.............................. 75 5.16.4 getMacOptions................................ 75 5.16.5 getVmSlotOptions.............................. 76 5.16.6 removeVmSlotOptions........................... 76 5.16.7 setConfiguration............................... 76 5.16.8 start..................................... 76 5.16.9 stop...................................... 77 5.17 IDirectory....................................... 77 5.17.1 Attributes.................................. 77 5.17.2 close..................................... 77 5.17.3 read..................................... 77 5.18 IDisplay........................................ 77 5.18.1 Attributes.................................. 78 5.18.2 attachFramebuffer.............................. 78 5.18.3 completeVHWACommand......................... 78 5.18.4 detachFramebuffer............................. 78 5.18.5 detachScreens................................ 78 5.18.6 drawToScreen................................ 79 5.18.7 getScreenResolution............................. 79 5.18.8 invalidateAndUpdate............................ 80 5.18.9 invalidateAndUpdateScreen........................ 80 5.18.10 notifyHiDPIOutputPolicyChange...................... 80 5.18.11 notifyScaleFactorChange.......................... 80 5.18.12 queryFramebuffer.............................. 80 5.18.13 querySourceBitmap............................. 81 5.18.14 setScreenLayout............................... 81 5.18.15 setSeamlessMode.............................. 81 5.18.16 setVideoModeHint.............................. 81 5.18.17 takeScreenShot............................... 82 5.18.18 takeScreenShotToArray........................... 83 5.18.19 viewportChanged.............................. 83 5.19 IDisplaySourceBitmap................................ 83 5.19.1 Attributes.................................. 83 5.19.2 queryBitmapInfo............................... 84 5.20 IDnDBase....................................... 84 5.20.1 Attributes.................................. 84 5.20.2 addFormats................................. 84 5.20.3 isFormatSupported............................. 85 5.20.4 removeFormats............................... 85 5.21 IDnDModeChangedEvent (IEvent).......................... 85 5.21.1 Attributes.................................. 85 5.22 IDnDSource (IDnDBase)............................... 85 5.22.1 dragIsPending................................ 85 5.22.2 drop..................................... 86 5.22.3 receiveData................................. 86 5.23 IDnDTarget (IDnDBase)............................... 86 4 Contents 5.23.1 cancel.................................... 86 5.23.2 drop..................................... 86 5.23.3 enter..................................... 87 5.23.4 leave..................................... 87 5.23.5 move..................................... 88 5.23.6 sendData................................... 88 5.24 IEmulatedUSB..................................... 88 5.24.1 Attributes.................................. 88 5.24.2 webcamAttach................................ 89 5.24.3 webcamDetach............................... 89 5.25 IEvent......................................... 89 5.25.1 Attributes.................................. 90 5.25.2 setProcessed................................. 90 5.25.3 waitProcessed................................ 90 5.26 IEventListener..................................... 91 5.26.1 handleEvent................................. 91 5.27 IEventSource....................................