SDKRef
SDKRef
VirtualBox
R
Version 3.2.8
c 2004-2010 Oracle Corporation
http://www.virtualbox.org
Contents
1 Introduction 14
1.1 Modularity: the building blocks of VirtualBox . . . . . . . . . . . . . . . 14
1.2 Two guises of the same “Main API”: the web service or COM/XPCOM . . 15
1.3 About web services in general . . . . . . . . . . . . . . . . . . . . . . . . 17
1.4 Running the web service . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
1.4.1 Command line options of vboxwebsrv . . . . . . . . . . . . . . . 18
1.4.2 Authenticating at web service logon . . . . . . . . . . . . . . . . 19
1.4.3 Solaris host: starting the web service via SMF . . . . . . . . . . 20
2
Contents
5.5 Visual Basic and Visual Basic Script (VBS) on Windows hosts . . . . . . 40
5.6 C binding to XPCOM API . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.6.1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.6.2 XPCOM initialization . . . . . . . . . . . . . . . . . . . . . . . . 41
5.6.3 XPCOM method invocation . . . . . . . . . . . . . . . . . . . . . 41
5.6.4 XPCOM attribute access . . . . . . . . . . . . . . . . . . . . . . . 42
5.6.5 String handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.6.6 XPCOM uninitialization . . . . . . . . . . . . . . . . . . . . . . . 43
5.6.7 Compiling and linking . . . . . . . . . . . . . . . . . . . . . . . . 44
8 License information 54
9 Classes (interfaces) 55
9.1 IAppliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
9.1.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
9.1.2 createVFSExplorer . . . . . . . . . . . . . . . . . . . . . . . . . . 57
9.1.3 getWarnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
9.1.4 importMachines . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
9.1.5 interpret . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.1.6 read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.1.7 write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
9.2 IAudioAdapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.2.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.3 IBIOSSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.3.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
9.4 IConsole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
9.4.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
9.4.2 adoptSavedState . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
9.4.3 attachUSBDevice . . . . . . . . . . . . . . . . . . . . . . . . . . 64
9.4.4 createSharedFolder . . . . . . . . . . . . . . . . . . . . . . . . . 64
9.4.5 deleteSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9.4.6 detachUSBDevice . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.4.7 findUSBDeviceByAddress . . . . . . . . . . . . . . . . . . . . . . 66
9.4.8 findUSBDeviceById . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.4.9 forgetSavedState . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9.4.10 getDeviceActivity . . . . . . . . . . . . . . . . . . . . . . . . . . 67
3
Contents
9.4.11 getGuestEnteredACPIMode . . . . . . . . . . . . . . . . . . . . . 67
9.4.12 getPowerButtonHandled . . . . . . . . . . . . . . . . . . . . . . 67
9.4.13 pause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
9.4.14 powerButton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
9.4.15 powerDown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
9.4.16 powerUp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
9.4.17 powerUpPaused . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
9.4.18 registerCallback . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
9.4.19 removeSharedFolder . . . . . . . . . . . . . . . . . . . . . . . . 70
9.4.20 reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
9.4.21 restoreSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
9.4.22 resume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
9.4.23 saveState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
9.4.24 sleepButton . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
9.4.25 takeSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
9.4.26 teleport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
9.4.27 unregisterCallback . . . . . . . . . . . . . . . . . . . . . . . . . . 73
9.5 IConsoleCallback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
9.5.1 onAdditionsStateChange . . . . . . . . . . . . . . . . . . . . . . 74
9.5.2 onCPUChange . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
9.5.3 onCanShowWindow . . . . . . . . . . . . . . . . . . . . . . . . . 74
9.5.4 onKeyboardLedsChange . . . . . . . . . . . . . . . . . . . . . . . 75
9.5.5 onMediumChange . . . . . . . . . . . . . . . . . . . . . . . . . . 75
9.5.6 onMouseCapabilityChange . . . . . . . . . . . . . . . . . . . . . 75
9.5.7 onMousePointerShapeChange . . . . . . . . . . . . . . . . . . . 76
9.5.8 onNetworkAdapterChange . . . . . . . . . . . . . . . . . . . . . 77
9.5.9 onParallelPortChange . . . . . . . . . . . . . . . . . . . . . . . . 77
9.5.10 onRemoteDisplayInfoChange . . . . . . . . . . . . . . . . . . . . 77
9.5.11 onRuntimeError . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
9.5.12 onSerialPortChange . . . . . . . . . . . . . . . . . . . . . . . . . 79
9.5.13 onSharedFolderChange . . . . . . . . . . . . . . . . . . . . . . . 79
9.5.14 onShowWindow . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.5.15 onStateChange . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.5.16 onStorageControllerChange . . . . . . . . . . . . . . . . . . . . 81
9.5.17 onUSBControllerChange . . . . . . . . . . . . . . . . . . . . . . 81
9.5.18 onUSBDeviceStateChange . . . . . . . . . . . . . . . . . . . . . 81
9.5.19 onVRDPServerChange . . . . . . . . . . . . . . . . . . . . . . . . 82
9.6 IDHCPServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
9.6.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
9.6.2 setConfiguration . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.6.3 start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.6.4 stop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.7 IDisplay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
9.7.1 completeVHWACommand . . . . . . . . . . . . . . . . . . . . . 84
9.7.2 drawToScreen . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
4
Contents
9.7.3 getFramebuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.7.4 getScreenResolution . . . . . . . . . . . . . . . . . . . . . . . . . 85
9.7.5 invalidateAndUpdate . . . . . . . . . . . . . . . . . . . . . . . . 86
9.7.6 resizeCompleted . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.7.7 setFramebuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.7.8 setSeamlessMode . . . . . . . . . . . . . . . . . . . . . . . . . . 86
9.7.9 setVideoModeHint . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9.7.10 takeScreenShot . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9.7.11 takeScreenShotToArray . . . . . . . . . . . . . . . . . . . . . . . 88
9.8 IFramebuffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
9.8.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
9.8.2 getVisibleRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
9.8.3 lock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
9.8.4 notifyUpdate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
9.8.5 processVHWACommand . . . . . . . . . . . . . . . . . . . . . . 92
9.8.6 requestResize . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
9.8.7 setVisibleRegion . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
9.8.8 unlock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.8.9 videoModeSupported . . . . . . . . . . . . . . . . . . . . . . . . 95
9.9 IFramebufferOverlay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.9.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.9.2 move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
9.10 IGuest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
9.10.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
9.10.2 executeProcess . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
9.10.3 getProcessOutput . . . . . . . . . . . . . . . . . . . . . . . . . . 99
9.10.4 getProcessStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
9.10.5 internalGetStatistics . . . . . . . . . . . . . . . . . . . . . . . . . 99
9.10.6 setCredentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.11 IGuestOSType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
9.11.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
9.12 IHost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.12.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.12.2 createHostOnlyNetworkInterface . . . . . . . . . . . . . . . . . . 106
9.12.3 createUSBDeviceFilter . . . . . . . . . . . . . . . . . . . . . . . . 107
9.12.4 findHostDVDDrive . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.12.5 findHostFloppyDrive . . . . . . . . . . . . . . . . . . . . . . . . 107
9.12.6 findHostNetworkInterfaceById . . . . . . . . . . . . . . . . . . . 107
9.12.7 findHostNetworkInterfaceByName . . . . . . . . . . . . . . . . . 108
9.12.8 findHostNetworkInterfacesOfType . . . . . . . . . . . . . . . . . 108
9.12.9 findUSBDeviceByAddress . . . . . . . . . . . . . . . . . . . . . . 108
9.12.10findUSBDeviceById . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.12.11getProcessorCPUIDLeaf . . . . . . . . . . . . . . . . . . . . . . . 109
9.12.12getProcessorDescription . . . . . . . . . . . . . . . . . . . . . . . 109
9.12.13getProcessorFeature . . . . . . . . . . . . . . . . . . . . . . . . . 110
5
Contents
9.12.14getProcessorSpeed . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.12.15insertUSBDeviceFilter . . . . . . . . . . . . . . . . . . . . . . . . 110
9.12.16removeHostOnlyNetworkInterface . . . . . . . . . . . . . . . . . 111
9.12.17removeUSBDeviceFilter . . . . . . . . . . . . . . . . . . . . . . . 111
9.13 IHostNetworkInterface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
9.13.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
9.13.2 dhcpRediscover . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
9.13.3 enableDynamicIpConfig . . . . . . . . . . . . . . . . . . . . . . . 113
9.13.4 enableStaticIpConfig . . . . . . . . . . . . . . . . . . . . . . . . 113
9.13.5 enableStaticIpConfigV6 . . . . . . . . . . . . . . . . . . . . . . . 114
9.14 IHostUSBDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.14.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.15 IHostUSBDeviceFilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.15.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
9.16 IInternalMachineControl . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
9.16.1 adoptSavedState . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
9.16.2 autoCaptureUSBDevices . . . . . . . . . . . . . . . . . . . . . . 115
9.16.3 beginPowerUp . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
9.16.4 beginSavingState . . . . . . . . . . . . . . . . . . . . . . . . . . 115
9.16.5 beginTakingSnapshot . . . . . . . . . . . . . . . . . . . . . . . . 116
9.16.6 captureUSBDevice . . . . . . . . . . . . . . . . . . . . . . . . . . 116
9.16.7 deleteSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
9.16.8 detachAllUSBDevices . . . . . . . . . . . . . . . . . . . . . . . . 117
9.16.9 detachUSBDevice . . . . . . . . . . . . . . . . . . . . . . . . . . 117
9.16.10endPowerUp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.16.11endSavingState . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.16.12endTakingSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.16.13finishOnlineMergeMedium . . . . . . . . . . . . . . . . . . . . . 119
9.16.14getIPCId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
9.16.15lockMedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
9.16.16onSessionEnd . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
9.16.17pullGuestProperties . . . . . . . . . . . . . . . . . . . . . . . . . 120
9.16.18pushGuestProperty . . . . . . . . . . . . . . . . . . . . . . . . . 120
9.16.19restoreSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
9.16.20runUSBDeviceFilters . . . . . . . . . . . . . . . . . . . . . . . . 121
9.16.21setRemoveSavedState . . . . . . . . . . . . . . . . . . . . . . . . 121
9.16.22unlockMedia . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.16.23updateState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
9.17 IInternalSessionControl . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.17.1 accessGuestProperty . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.17.2 assignMachine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
9.17.3 assignRemoteMachine . . . . . . . . . . . . . . . . . . . . . . . . 123
9.17.4 enumerateGuestProperties . . . . . . . . . . . . . . . . . . . . . 123
9.17.5 getPID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.17.6 getRemoteConsole . . . . . . . . . . . . . . . . . . . . . . . . . . 124
6
Contents
7
Contents
9.20.24getMediumAttachmentsOfController . . . . . . . . . . . . . . . . 152
9.20.25getNetworkAdapter . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.20.26getParallelPort . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
9.20.27getSerialPort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.20.28getSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
9.20.29getStorageControllerByInstance . . . . . . . . . . . . . . . . . . 153
9.20.30getStorageControllerByName . . . . . . . . . . . . . . . . . . . . 154
9.20.31hotPlugCPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
9.20.32hotUnplugCPU . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
9.20.33mountMedium . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
9.20.34passthroughDevice . . . . . . . . . . . . . . . . . . . . . . . . . 155
9.20.35queryLogFilename . . . . . . . . . . . . . . . . . . . . . . . . . . 156
9.20.36querySavedScreenshotPNGSize . . . . . . . . . . . . . . . . . . 156
9.20.37querySavedThumbnailSize . . . . . . . . . . . . . . . . . . . . . 156
9.20.38readLog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
9.20.39readSavedScreenshotPNGToArray . . . . . . . . . . . . . . . . . 157
9.20.40readSavedThumbnailToArray . . . . . . . . . . . . . . . . . . . . 157
9.20.41removeAllCPUIDLeaves . . . . . . . . . . . . . . . . . . . . . . . 158
9.20.42removeCPUIDLeaf . . . . . . . . . . . . . . . . . . . . . . . . . . 158
9.20.43removeSharedFolder . . . . . . . . . . . . . . . . . . . . . . . . 158
9.20.44removeStorageController . . . . . . . . . . . . . . . . . . . . . . 158
9.20.45saveSettings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
9.20.46setBootOrder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
9.20.47setCPUIDLeaf . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.20.48setCPUProperty . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
9.20.49setCurrentSnapshot . . . . . . . . . . . . . . . . . . . . . . . . . 161
9.20.50setExtraData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
9.20.51setGuestProperty . . . . . . . . . . . . . . . . . . . . . . . . . . 162
9.20.52setGuestPropertyValue . . . . . . . . . . . . . . . . . . . . . . . 162
9.20.53setHWVirtExProperty . . . . . . . . . . . . . . . . . . . . . . . . 163
9.20.54showConsoleWindow . . . . . . . . . . . . . . . . . . . . . . . . 163
9.21 IMachineDebugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
9.21.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
9.21.2 dumpStats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
9.21.3 getStats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
9.21.4 injectNMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
9.21.5 resetStats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
9.22 IManagedObjectRef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
9.22.1 getInterfaceName . . . . . . . . . . . . . . . . . . . . . . . . . . 166
9.22.2 release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
9.23 IMedium . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
9.23.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
9.23.2 cloneTo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
9.23.3 close . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
9.23.4 compact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
8
Contents
9
Contents
10
Contents
9.43.2 cd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
9.43.3 cdUp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.43.4 entryList . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.43.5 exists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.43.6 remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.43.7 update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.44 IVRDPServer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.44.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9.45 IVirtualBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
9.45.1 Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240
9.45.2 checkFirmwarePresent . . . . . . . . . . . . . . . . . . . . . . . 243
9.45.3 createAppliance . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
9.45.4 createDHCPServer . . . . . . . . . . . . . . . . . . . . . . . . . . 243
9.45.5 createHardDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
9.45.6 createLegacyMachine . . . . . . . . . . . . . . . . . . . . . . . . 244
9.45.7 createMachine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
9.45.8 createSharedFolder . . . . . . . . . . . . . . . . . . . . . . . . . 247
9.45.9 findDHCPServerByNetworkName . . . . . . . . . . . . . . . . . 247
9.45.10findDVDImage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
9.45.11findFloppyImage . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
9.45.12findHardDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
9.45.13findMachine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
9.45.14getDVDImage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
9.45.15getExtraData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
9.45.16getExtraDataKeys . . . . . . . . . . . . . . . . . . . . . . . . . . 250
9.45.17getFloppyImage . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
9.45.18getGuestOSType . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
9.45.19getHardDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
9.45.20getMachine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
9.45.21openDVDImage . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
9.45.22openExistingSession . . . . . . . . . . . . . . . . . . . . . . . . . 252
9.45.23openFloppyImage . . . . . . . . . . . . . . . . . . . . . . . . . . 253
9.45.24openHardDisk . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
9.45.25openMachine . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
9.45.26openRemoteSession . . . . . . . . . . . . . . . . . . . . . . . . . 255
9.45.27openSession . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
9.45.28registerCallback . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
9.45.29registerMachine . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.45.30removeDHCPServer . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.45.31removeSharedFolder . . . . . . . . . . . . . . . . . . . . . . . . 259
9.45.32setExtraData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
9.45.33unregisterCallback . . . . . . . . . . . . . . . . . . . . . . . . . . 260
9.45.34unregisterMachine . . . . . . . . . . . . . . . . . . . . . . . . . . 261
9.45.35waitForPropertyChange . . . . . . . . . . . . . . . . . . . . . . . 262
9.46 IVirtualBoxCallback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
11
Contents
12
Contents
10.20MediumState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
10.21MediumType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
10.22MediumVariant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
10.23MouseButtonState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
10.24NATAliasMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
10.25NATProtocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
10.26NetworkAdapterType . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
10.27NetworkAttachmentType . . . . . . . . . . . . . . . . . . . . . . . . . . 286
10.28PointingHidType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
10.29PortMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
10.30ProcessorFeature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
10.31Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
10.32SessionState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287
10.33SessionType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
10.34SettingsVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
10.35StorageBus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
10.36StorageControllerType . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
10.37USBDeviceFilterAction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
10.38USBDeviceState . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
10.39VFSFileType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
10.40VFSType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
10.41VRDPAuthType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
10.42VirtualSystemDescriptionType . . . . . . . . . . . . . . . . . . . . . . . . 291
10.43VirtualSystemDescriptionValueType . . . . . . . . . . . . . . . . . . . . 292
13
1 Introduction
VirtualBox comes with comprehensive support for third-party developers. This Soft-
ware Development Kit (SDK) contains all the documentation and interface files that
are needed to write code that interacts with VirtualBox.
The orange area represents code that runs in kernel mode, the blue area represents
userspace code.
At the bottom of the stack resides the hypervisor – the core of the virtualization
engine, controlling execution of the virtual machines and making sure they do not
conflict with each other or whatever the host computer is doing otherwise.
On top of the hypervisor, additional internal modules provide extra functionality. For
example, the RDP server, which can deliver the graphical output of a VM remotely to
an RDP client, is a separate module that is only loosely tacked into the virtual graphics
14
1 Introduction
device. Live Migration and Resource Monitor are additional modules currently in the
process of being added to VirtualBox.
What is primarily of interest for purposes of the SDK is the API layer block that
sits on top of all the previously mentioned blocks. This API, which we call the “Main
API”, exposes the entire feature set of the virtualization engine below. It is completely
documented in this SDK Reference – see chapter 9, Classes (interfaces), page 55 and
chapter 10, Enumerations (enums), page 275 – and available to anyone who wishes to
control VirtualBox programmatically. We chose the name “Main API” to differentiate
it from other programming interfaces of VirtualBox that may be publicly accessible.
With the Main API, you can create, configure, start, stop and delete virtual machines,
retrieve performance statistics about running VMs, configure the VirtualBox installa-
tion in general, and more. In fact, internally, the front-end programs VirtualBox and
VBoxManage use nothing but this API as well – there are no hidden backdoors into the
virtualization engine for our own front-ends. This ensures the entire Main API is both
well-documented and well-tested. (The same applies to VBoxHeadless, which is not
shown in the image.)
1. VirtualBox comes with a web service that maps nearly the entire Main API. The
web service ships in a stand-alone executable (vboxwebsrv) that, when running,
acts as an HTTP server, accepts SOAP connections and processes them.
Since the entire web service API is publicly described in a web service description
file (in WSDL format), you can write client programs that call the web service in
any language with a toolkit that understands WSDL. These days, that includes
most programming languages that are available: Java, C++, .NET, PHP, Python,
Perl and probably many more.
All of this is explained in detail in subsequent chapters of this book.
There are two ways in which you can write client code that uses the web service:
a) For Java with JAX-WS as well as Python, the SDK contains easy-to-use
classes that allow you to use the web service in an object-oriented, straight-
forward manner. We shall refer to this as the “object-oriented web service
(OOWS)“.
The OO bindings for Java are described in chapter 2.1, The object-oriented
web service for JAX-WS, page 21, those for Python in chapter 2.2, The object-
oriented web service for Python, page 25.
b) Alternatively, you can use the web service directly, without the object-
oriented client layer. We shall refer to this as the “raw web service”.
15
1 Introduction
You will then have neither native object orientation nor full type safety,
since web services are neither object-oriented nor stateful. However, in this
way, you can write client code even in languages for which we do not ship
object-oriented client code; all you need is a programming language with a
toolkit that can parse WSDL and generate client wrapper code from it.
We describe this further in chapter 3, Using the raw web service with any
language, page 27, with samples for Java and Perl.
2. Internally, for portability and easier maintenance, the Main API is implemented
using the Component Object Model (COM), an interprocess mechanism for
software components originally introduced by Microsoft for Microsoft Windows.
On a Windows host, VirtualBox will use Microsoft COM; on other hosts where
COM is not present, it ships with XPCOM, a free software implementation of
COM originally created by the Mozilla project for their browsers.
So, if you are familiar with COM and the C++ programming language (or
with any other programming language that can handle COM/XPCOM objects,
such as Java, Visual Basic or C#), then you can use the COM/XPCOM API di-
rectly. VirtualBox comes with all necessary files and documentation to build
fully functional COM applications. For an introduction, please see chapter 5, The
VirtualBox COM/XPCOM API, page 36 below.
The VirtualBox front-ends (the graphical user interfaces as well as the command
line), which are all written in C++, use COM/XPCOM to call the Main API. Tech-
nically, the web service is another front-end to this COM API, mapping almost all
of it to SOAP clients.
In the following chapters, we will describe the different ways in which to program
VirtualBox, starting with the method that is easiest to use and then increase complexity
as we go along.
16
1 Introduction
1. The VirtualBox web service (the “server”): this is the vboxwebsrv executable
shipped with VirtualBox. Once you start this executable (which acts as a HTTP
server on a specific TCP/IP port), clients can connect to the web service and thus
control a VirtualBox installation.
2. VirtualBox also comes with WSDL files that describe the services provided by
the web service. You can find these files in the sdk/bindings/webservice/
directory. These files are understood by the web service toolkits that are shipped
with most programming languages and enable you to easily access a web service
even if you don’t use our object-oriented client layers. VirtualBox is shipped with
pregenerated web service glue code for several languages (Python, Perl, Java).
3. A client that connects to the web service in order to control the VirtualBox in-
stallation.
Unless you play with some of the samples shipped with VirtualBox, this needs to
be written by you.
1 In some ways, web services promise to deliver the same thing as CORBA and DCOM did years ago.
However, while these previous technologies relied on specific binary protocols and thus proved to be
difficult to use between diverging platforms, web services circumvent these incompatibilities by using
text-only standards like HTTP and XML. On the downside (and, one could say, typical of things related to
XML), a lot of standards are involved before a web service can be implemented. Many of the standards
invented around XML are used one way or another. As a result, web services are slow and verbose,
and the details can be incredibly messy. The relevant standards here are called SOAP and WSDL, where
SOAP describes the format of the messages that are exchanged (an XML document wrapped in an HTTP
header), and WSDL is an XML format that describes a complete API provided by a web service. WSDL
in turn uses XML Schema to describe types, which is not exactly terse either. However, as you will see
from the samples provided in this chapter, the VirtualBox web service shields you from these details and
is easy to use.
17
1 Introduction
Note: The web service executable is not contained with the VirtualBox SDK,
but instead ships with the standard VirtualBox binary package for your specific
platform. Since the SDK contains only platform-independent text files and
documentation, the binaries are instead shipped with the platform-specific
packages.
The vboxwebsrv program, which implements the web service, is a text-mode (con-
sole) program which, after being started, simply runs until it is interrupted with Ctrl-C
or a kill command.
Once the web service is started, it acts as a front-end to the VirtualBox installation of
the user account that it is running under. In other words, if the web service is run under
the user account of user1, it will see and manipulate the virtual machines and other
data represented by the VirtualBox data of that user (e.g., on a Linux machine, under
/home/user1/.VirtualBox; see the VirtualBox User Manual for details on where this
data is stored).
18
1 Introduction
• --check-interval (or -i): This specifies the interval in which the web service
checks for timed-out clients, in seconds, and defaults to 5. This normally does
not need to be changed.
• --verbose (or -v): Normally, the webservice outputs only brief messages to the
console each time a request is served. With this option, the webservice prints
much more detailed data about every request and the COM methods that those
requests are mapped to internally, which can be useful for debugging client pro-
grams.
• --logfile (or -F) <file>: If this is specified, the webservice not only prints its
output to the console, but also writes it to the specified file. The file is created if
it does not exist; if it does exist, new output is appended to it. This is useful if
you run the webservice unattended and need to debug problems after they have
occurred.
Warning: This will cause all logons to succeed, regardless of user name or
password. This should of course not be used in a production environment.
This way you can specify any shared object/dynamic link module that conforms with
the specifications for authentication modules as laid out in section 9.3 of the VirtualBox
User Manual; the web service uses the same kind of modules as the VirtualBox RDP
server.
By default, after installation, the web service uses the VRDPAuth module that ships
with VirtualBox. This module uses PAM on Linux hosts to authenticate users. Any valid
19
1 Introduction
If you made any change, don’t forget to run the following command to put the
changes into effect immediately:
svcadm refresh svc:/application/virtualbox/webservice:default
If you forget the above command then the previous settings will be used when
enabling the service. Check the current property settings with:
svcprop -p config svc:/application/virtualbox/webservice:default
When everything is configured correctly you can start the VirtualBox webservice
with the following command:
svcadm enable svc:/application/virtualbox/webservice:default
For more information about SMF, please refer to the Solaris documentation.
20
2 The object-oriented web service
(OOWS)
As explained in chapter 1.2, Two guises of the same “Main API”: the web service or
COM/XPCOM, page 15, VirtualBox ships with client-side libraries for Java and Python
that allow you to use the VirtualBox web service in an intuitive, object-oriented way.
These libraries shield you from the client-side complications of managed object refer-
ences and other implementation details that come with the VirtualBox web service. (If
you do want to use the web service directly, have a look at chapter 3, Using the raw
web service with any language, page 27).
We recommend that you start your experiments with the VirtualBox web service by
using our object-oriented client libraries for JAX-WS, a web service toolkit for Java,
which enables you to write code to interact with VirtualBox in the simplest manner
possible.
2.1.1 Preparations
Since JAX-WS is already integrated into Java 6, no additional preparations are needed
for Java 6.
If you are using Java 5 (JDK 1.5.x), you will first need to download and install
an external JAX-WS implementation, as Java 5 does not support JAX-WS out of the
box; for example, you can download one from here: https://jax-ws.dev.java.
net/2.1.4/JAXWS2.1.4-20080502.jar. Then perform the installation (java -jar
JAXWS2.1.4-20080502.jar).
21
2 The object-oriented web service (OOWS)
1. Open a terminal and change to the directory where the JAX-WS samples reside.1
Examine the header of Makefile to see if the supplied variables (Java compiler,
Java executable) and a few other details match your system settings.
2. To start the VirtualBox web service, open a second terminal and change to the
directory where the VirtualBox executables are located. Then type:
./vboxwebsrv -v
The web service now waits for connections and will run until you press Ctrl+C
in this second terminal. The -v argument causes it to log all connections to the
terminal. (See chapter 1.4, Running the web service, page 18 for details on how
to run the web service.)
3. Back in the first terminal and still in the samples directory, to start a simple client
example just type:
make run16
The clienttest sample imitates a few typical command line tasks that
VBoxManage, VirtualBox’s regular command-line front-end, would provide (see the
VirtualBox User Manual for details). In particular, you can run:
• java clienttest show vms: show the virtual machines that are registered lo-
cally.
• java clienttest list hostinfo: show various information about the host
this VirtualBox installation runs on.
• java clienttest startvm <vmname|uuid>: start the given virtual machine.
The clienttest.java sample code illustrates common basic practices how to use
the VirtualBox OOWS for JAX-WS, which we will explain in more detail in the following
chapters.
1 In sdk/bindings/webservice/java/jax-ws/samples/.
22
2 The object-oriented web service (OOWS)
23
2 The object-oriented web service (OOWS)
would suffice to call the corresponding “set” method – for example, to set a VM’s mem-
ory to 1024 MB, one would call setMemorySize(1024). Try that, and you will get an
error: “The machine is not mutable.“
So unfortunately, things are not that easy. VirtualBox is a complicated environment
in which multiple processes compete for possibly the same resources, especially ma-
chine settings. As a result, machines must be “locked” before they can either be modi-
fied or started. This is to prevent multiple processes from making conflicting changes
to a machine: it should, for example, not be allowed to change the memory size of a
virtual machine while it is running. (You can’t add more memory to a real computer
while it is running either, at least not to an ordinary PC.) Also, two processes must not
change settings at the same time, or start a machine at the same time.
These requirements are implemented in the Main API by way of “sessions”, in partic-
ular, the ISession interface. Each process has its own instance of ISession. In the web
service, you cannot create such an object, but vboxwebsrv creates one for you when
you log on, which you can obtain by calling IWebsessionManager::getSessionObject().
This session object must then be used like a mutex semaphore in common program-
ming environments; in VirtualBox terminology, one must “open a direct session” on a
machine before it can be modified. This is done by calling IVirtualBox::openSession().
After the direct session has been opened, the ISession::machine attribute contains a
copy of the original IMachine object upon which the session was opened, but this copy
is “mutable”: you can invoke “set” methods on it.
Finally, it is important to never forget to close the session again, by calling ISes-
sion::close(). Otherwise, when the calling process end, the machine will receive the
state “aborted”, which can lead to loss of data.
So the sequence to change a machine’s memory to 1024 MB is something like this:
IWebsessionManager mgr ...;
IVirtualBox vbox = mgr.logon(user, pass);
...
IMachine machine = ...; // read-only machine
ISession session = mgr.getSessionObject();
vbox.openSession(session, machine.getId()); // machine is now locked
IMachine mutable = session.getMachine(); // obtain mutable machine
mutable.setMemorySize(1024);
mutable.saveSettings(); // write settings to XML
session.close();
24
2 The object-oriented web service (OOWS)
Note that no in-process (local) session object is needed here since we instruct
VirtualBox to spawn a new process, which will have its own session object.
2 On On Mac OS X only the Python versions bundled with the OS are officially supported. This means
Python 2.3 for 10.4, Python 2.5 for 10.5 and Python 2.5 and 2.6 for 10.6.
3 See http://sourceforge.net/project/showfiles.php?group_id=78018.
25
2 The object-oriented web service (OOWS)
See chapter 6, The VirtualBox shell, page 45 for more details on the shell’s function-
ality. For you, as a VirtualBox application developer, the vboxshell sample could be
interesting as an example of how to write code targeting both local and remote cases
(COM/XPCOM and SOAP). The common part of the shell is the same – the only dif-
ference is how it interacts with the invocation layer. You can use the connect shell
command to connect to remote VirtualBox servers; in this case you can skip starting
the local webserver.
4 See http://www.php.net/soap.
26
3 Using the raw web service with any
language
The following examples show you how to use the raw web service, without the object-
oriented client-side code that was described in the previous chapter.
Use the directory where the Axis JAR files are located. Mind the quotes so that
your shell passes the “*“ character to the java executable without expanding. Al-
ternatively, add a corresponding -classpath argument to the “java” call above.
If the command executes successfully, you should see an “org” directory with sub-
directories containing Java source files in your working directory. These classes
represent the interfaces that the VirtualBox web service offers, as described by
the WSDL file.
27
3 Using the raw web service with any language
This is the bit that makes using web services so attractive to client developers: if
a language’s toolkit understands WSDL, it can generate large amounts of support
code automatically. Clients can then easily use this support code and can be done
with just a few lines of code.
3. Next, compile the clienttest.java source:
javac clienttest.java
The web service now waits for connections and will run until you press Ctrl+C
in this second terminal. The -v argument causes it to log all connections to the
terminal. (See chapter 1.4, Running the web service, page 18 for details on how
to run the web service.)
5. Back in the original terminal where you compiled the Java source, run the re-
sulting binary, which will then connect to the web service:
java clienttest
The client sample will connect to the web service (on localhost, but the code
could be changed to connect remotely if the web service was running on a dif-
ferent machine) and make a number of method calls. It will output the version
number of your VirtualBox installation and a list of all virtual machines that
are currently registered (with a bit of seemingly random data, which will be
explained later).
1. If SOAP::Lite is not yet installed on your system, you will need to install the pack-
age first. On Debian-based systems, the package is called libsoap-lite-perl;
on Gentoo, it’s dev-perl/SOAP-Lite.
28
3 Using the raw web service with any language
3. To start the VirtualBox web service, open a second terminal and change to the
directory where the VirtualBox executables are located. Then type:
./vboxwebsrv -v
The web service now waits for connections and will run until you press Ctrl+C
in this second terminal. The -v argument causes it to log all connections to the
terminal. (See chapter 1.4, Running the web service, page 18 for details on how
to run the web service.)
4. In the first terminal with the Perl sample, run the clienttest.pl script:
perl -I ../lib clienttest.pl
• Web services, as expressed by WSDL, are not object-oriented. Even worse, they
are normally stateless (or, in web services terminology, “loosely coupled”). Web
service operations are entirely procedural, and one cannot normally make as-
sumptions about the state of a web service between function calls.
In particular, this normally means that you cannot work on objects in one method
call that were created by another call.
For the VirtualBox web service, this results in three fundamental conventions:
1. All function names in the VirtualBox web service consist of an interface name
and a method name, joined together by an underscore. This is because there are
only functions (“operations”) in WSDL, but no classes, interfaces, or methods.
29
3 Using the raw web service with any language
In addition, all calls to the VirtualBox web service (except for logon, see below)
take a managed object reference as the first argument, representing the object
upon which the underlying method is invoked. (Managed object references are
explained in detail below; see chapter 3.3.3, Managed object references, page 31.)
So, when one would normally code, in the pseudo-code of an object-oriented
language, to invoke a method upon an object:
IMachine machine;
result = machine.getName();
In the VirtualBox web service, this looks something like this (again, pseudo-
code):
IMachineRef machine;
result = IMachine_getName(machine);
2. To make the web service stateful, and objects persistent between method calls,
the VirtualBox web service introduces a session manager (by way of the IWeb-
sessionManager interface), which manages object references. Any client wishing
to interact with the web service must first log on to the session manager and in
turn receives a managed object reference to an object that supports the IVirtual-
Box interface (the basic interface in the Main API).
In other words, as opposed to other web services, the VirtualBox web service is
both object-oriented and stateful.
30
3 Using the raw web service with any language
string oVirtualBox;
oVirtualBox = webservice.IWebsessionManager_logon("user", "pass");
print version;
31
3 Using the raw web service with any language
Internally, in the web service process, each managed object reference is simply a
small data structure, containing a COM pointer to the “real” COM object, the web ses-
sion ID and the object ID. This structure is allocated on creation and stored efficiently
in hashes, so that the web service can look up the COM object quickly whenever a web
service client wishes to make a method call. The random session ID also ensures that
one web service client cannot intercept the objects of another.
Managed object references are not destroyed automatically and must be released
by explicitly calling IManagedObjectRef::release(). This is important, as otherwise
hundreds or thousands of managed object references (and corresponding COM objects,
which can consume much more memory!) can pile up in the web service process and
eventually cause it to deny service.
To reiterate: The underlying COM object, which the reference points to, is only freed
if the managed object reference is released. It is therefore vital that web service clients
properly clean up after the managed object references that are returned to them.
When a web service client calls IWebsessionManager::logoff(), all managed object
references created during the session are automatically freed. For short-lived sessions
that do not create a lot of objects, logging off may therefore be sufficient, although it
is certainly not “best practice”.
32
3 Using the raw web service with any language
<test:SayHello>
<name>Peter</name>
</test:SayHello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
A similar message – the “response” message – would be sent back from the web service
to the client, containing the return value “Hello Peter”.
Most programming languages provide automatic support to generate such messages
whenever code in that programming language makes such a request. In other words,
these programming languages allow for writing something like this (in pseudo-C++
code):
webServiceClass service("localhost", 18083); // server and port
string result = service.SayHello("Peter"); // invoke remote procedure
and would, for these two pseudo-lines, automatically perform these steps:
5. decode that response message and put the return value of the remote procedure
into the “result” variable.
33
3 Using the raw web service with any language
So, if it is said that a programming language “supports” web services, this typically
means that a programming language has support for parsing WSDL files and somehow
integrating the remote procedure calls into the native language syntax – for example,
like in the Java sample shown in chapter 3.1, Raw web service example for Java with
Axis, page 27.
For details about how programming languages support web services, please refer to
the documentation that comes with the individual languages. Here are a few pointers:
1. For C++, among many others, the gSOAP toolkit is a good option. Parts of
gSOAP are also used in VirtualBox to implement the VirtualBox web service.
2. For Java, there are several implementations already described in this document
(see chapter 2.1, The object-oriented web service for JAX-WS, page 21 and chapter
3.1, Raw web service example for Java with Axis, page 27).
3. Perl supports WSDL via the SOAP::Lite package. This in turn comes with a tool
called stubmaker.pl that allows you to turn any WSDL file into a Perl package
that you can import. (You can also import any WSDL file “live” by having it
parsed every time the script runs, but that can take a while.) You can then code
(again, assuming the above example):
my $result = servicename->sayHello("Peter");
A sample that uses SOAP::Lite was described in chapter 3.2, Raw web service
example for Perl, page 28.
34
4 Using the Main API documentation
to write web service clients
As “interfaces”, “attributes” and “methods” are COM concepts, please read the doc-
umentation in chapter 9, Classes (interfaces), page 55 and chapter 10, Enumerations
(enums), page 275 with the following notes in mind.
The object-oriented web service for JAX-WS attempts to map the Main API as
closely as possible to the Java and Python languages. In other words, objects are
objects, interfaces become classes, and you can call methods on objects as you would
on local objects.
The main difference remains with attributes: to read an attribute, call a “getXXX”
method, with “XXX” being the attribute name with a capitalized first letter. So when
the Main API Reference says that IMachine has a “name” attribute, call getName()
on an IMachine object to obtain a machine’s name. Unless the attribute is marked as
read-only in the documentation, there will also be a corresponding “set” method.
With the raw webservice, due to the limitations of SOAP and WSDL lined out in
chapter 3.3.1, Fundamental conventions, page 29, things are more complicated:
1. Any COM method call becomes a plain function call in the raw web service,
with the object as an additional first parameter (before the “real” parame-
ters listed in the documentation). So when the documentation says that the
IVirtualBox interface supports the createMachine() method, the web service
operation is IVirtualBox_createMachine(), and a managed object reference
to an IVirtualBox object must be passed as the first argument.
2. For attributes in interfaces, there will be at least one “get” function; there will
also be a “set” function, unless the attribute is “readonly”. The attribute name
will be appended to the “get” or “set” prefix, with a capitalized first letter. So,
the “version” readonly attribute of the IVirtualBox interface can be retrieved
by calling IVirtualBox_getVersion().
3. Whenever the API documentation says that a method (or an attribute getter)
returns an object, it will returned a managed object reference in the web service
instead. As said above, managed object references should be released if the web
service client does not log off again immediately!
35
5 The VirtualBox COM/XPCOM API
If you do not require remote procedure calls such as those offered by the VirtualBox
web service, and if you know Python or C++ as well as COM, you might find it
preferable to program VirtualBox’s Main API directly via COM.
COM stands for “Component Object Model” and is a standard originally introduced
by Microsoft in the 1990s for Microsoft Windows. It allows for organizing software in
an object-oriented way and across processes; code in one process may access objects
that live in another process.
COM has several advantages: it is language-neutral, meaning that even though all
of VirtualBox is internally written in C++, programs written in other languages could
communicate with it. COM also cleanly separates interface from implementation, so
that external programs need not know anything about the messy and complicated
details of VirtualBox internals.
On a Windows host, all parts of VirtualBox will use the COM functionality that is
native to Windows. On other hosts (including Linux), VirtualBox comes with a built-in
implementation of XPCOM, as originally created by the Mozilla project, which we have
enhanced to support interprocess communication on a level comparable to Microsoft
COM. Internally, VirtualBox has an abstraction layer that allows the same VirtualBox
code to work both with native COM as well as our XPCOM implementation.
vbox = win32com.client.Dispatch("VirtualBox.VirtualBox")
session = win32com.client.Dispatch("VirtualBox.Session")
uuid = "uuid of machine to start"
progress = vbox.openRemoteSession(session, uuid, "gui", "")
progress.waitForCompletion(-1)
36
5 The VirtualBox COM/XPCOM API
def machById(id):
mach = None
for m in virtualBoxManager.getArray(vbox, ’machines’):
if m.name == id or mach.id == id:
mach = m
break
return mach
37
5 The VirtualBox COM/XPCOM API
name = "Linux"
mach = machById(name)
if mach is None:
print "cannot find machine",name
else:
session = mgr.getSessionObject(vbox)
# one can also start headless session with "vrdp" instead of "gui"
progress = vb.openRemoteSession(session, mach.id, "gui", "")
progress.waitForCompletion(-1)
session.close()
This code also shows cross-platform access to array properties (certain limita-
tions prevent one from using vbox.machines to access a list of available vir-
tual machines in case of XPCOM), and a mechanism of uniform session creation
(virtualBoxManager.mgr.getSessionObject()).
In case you want to use the glue layer with a different Python installation, use these
steps in a shell to add the necessary files:
# cd VBOX_INSTALL_PATH/sdk/installer
# PYTHON vboxapisetup.py install
1. Attribute getters and setters. COM has the notion of “attributes” in interfaces,
which roughly compare to C++ member variables in classes. The difference
is that for each attribute declared in an interface, COM automatically provides
a “get” method to return the attribute’s value. Unless the attribute has been
marked as “readonly”, a “set” attribute is also provided.
To illustrate, the IVirtualBox interface has a “version” attribute, which is read-
only and of the “wstring” type (the standard string type in COM). As a result,
38
5 The VirtualBox COM/XPCOM API
you can call the “get” method for this attribute to retrieve the version number of
VirtualBox.
Unfortunately, the implementation differs between COM and XPCOM. Microsoft
COM names the “get” method like this: get_Attribute(), whereas XPCOM
uses this syntax: GetAttribute() (and accordingly for “set” methods). To hide
these differences, the VirtualBox glue code provides the COMGETTER(attrib)
and COMSETTER(attrib) macros. So, COMGETTER(version)() (note, two pairs
of brackets) expands to get_Version() on Windows and GetVersion() on
other platforms.
2. Unicode conversions. While the rest of the modern world has pretty much
settled on encoding strings in UTF-8, COM, unfortunately, uses UCS-16 encoding.
This requires a lot of conversions, in particular between the VirtualBox Main API
and the Qt GUI, which, like the rest of Qt, likes to use UTF-8.
To facilitate these conversions, VirtualBox provides the com::Bstr and
com::Utf8Str classes, which support all kinds of conversions back and forth.
3. COM autopointers. Possibly the greatest pain of using COM – reference count-
ing – is alleviated by the ComPtr<> template provided by the ptr.h file in the
glue layer.
can be used for both blocking and non-blocking operations. For the Python bindings,
a common layer provides the method
VirtualBoxManager.waitForEvents(ms)
39
5 The VirtualBox COM/XPCOM API
based on periodical timer events delivered to the main thread, or by using custom plat-
form messages to notify the main thread when events are available. See the VBoxSDL
and Qt (VirtualBox) frontends as examples.
set vb = CreateObject("VirtualBox.VirtualBox")
Wscript.Echo "VirtualBox version " & vb.version
Dim vb As VirtualBox.IVirtualBox
vb = CreateObject("VirtualBox.VirtualBox")
machines = ""
For Each m In vb.Machines
m = m & " " & m.Name
Next
Starting with version 2.2, VirtualBox offers a C binding for the XPCOM API.
The C binding provides a layer enabling object creation, method invocation and
attribute access from C.
1 Thedifference results from the way VBS treats COM safearrays, which are used to keep lists in the
Main API. VBS expects every array element to be a VARIANT, which is too strict a limitation for any
high performance API. We may lift this restriction for interface APIs in a future version, or alternatively
provide conversion APIs.
40
5 The VirtualBox COM/XPCOM API
/*
* VBoxGetXPCOMCFunctions() is the only function exported by
* VBoxXPCOMC.so and the only one needed to make virtualbox
* work with C. This functions gives you the pointer to the
* function table (g_pVBoxFuncs).
*
* Once you get the function table, then how and which functions
* to use is explained below.
*
* g_pVBoxFuncs->pfnComInitialize does all the necessary startup
* action and provides us with pointers to vbox and session handles.
* It should be matched by a call to g_pVBoxFuncs->pfnComUninitialize()
* when done.
*/
g_pVBoxFuncs = VBoxGetXPCOMCFunctions(VBOX_XPCOMC_VERSION);
g_pVBoxFuncs->pfnComInitialize(&vbox, &session);
If either vbox or session is still NULL, initialization failed and the XPCOM API
cannot be used.
41
5 The VirtualBox COM/XPCOM API
Using the C binding, all method invocations return a numeric result code.
If an interface is specified as returning an object, a pointer to a pointer to the ap-
propriate object must be passed as the last argument. The method will then store an
object pointer in that location.
In other words, to call an object’s method what you need is
IObject *object;
nsresult rc;
...
/*
* Calling void IObject::method(arg, ...)
*/
rc = object->vtbl->Method(object, arg, ...);
...
IFoo *foo;
/*
* Calling IFoo IObject::method(arg, ...)
*/
rc = object->vtbl->Method(object, args, ..., &foo);
rc = vbox->vtbl->GetRevision(vbox, &rev);
if (NS_SUCCEEDED(rc))
{
printf("Revision: %u\n", (unsigned)rev);
42
5 The VirtualBox COM/XPCOM API
All objects with their methods and attributes are documented in chapter 9, Classes
(interfaces), page 55.
5.6.5.2 Ownership
The ownership of a string determines who is responsible for releasing resources asso-
ciated with the string. Whenever XPCOM creates a string, ownership is transferred to
the caller. To avoid resource leaks, the caller should release resources once the string
is no longer needed.
#include <stdlib.h>
#include <stdio.h>
...
/*
* Make sure g_pVBoxFuncs->pfnComUninitialize() is called at exit, no
* matter if we return from the initial call to main or call exit()
* somewhere else. Note that atexit registered functions are not
* called upon abnormal termination, i.e. when calling abort() or
* signal(). Separate provisions must be taken for these cases.
*/
if (atexit(g_pVBoxFuncs->pfnComUninitialize()) != 0) {
43
5 The VirtualBox COM/XPCOM API
Another idea would be to write your own void myexit(int status) function,
calling g_pVBoxFuncs->pfnComUninitialize() followed by the real exit(), and
use it instead of exit() throughout your program and at the end of main.
If you expect the program to be terminated by a signal (e.g. user types CTRL-C
sending SIGINT) you might want to install a signal handler setting a flag noting that
a signal was sent and then calling g_pVBoxFuncs->pfnComUninitialize() later on
(usually not from the handler itself .)
That said, if a client program forgets to call g_pVBoxFuncs->pfnComUninitialize()
before it terminates, there is a mechanism in place which will eventually release ref-
erences held by the client. You should not rely on this, however.
# Compile.
program.o: program.c VBoxCAPI_v2_5.h
$(CC) $(CFLAGS) $(INCS_XPCOM) $(GLUE_INC) -o $@ -c $<
# Link.
program: program.o VBoxXPCOMCGlue.o
$(CC) -o $@ $^ -ldl
44
6 The VirtualBox shell
VirtualBox comes with an extensible shell, which allows you to control your virtual
machines from the command line. It is also a nontrivial example of how to use the
VirtualBox APIs from Python, for all three COM/XPCOM/WS styles of the API.
You can easily extend this shell with your own commands. Create a subdirectory
named .VirtualBox/shexts below your home directory and put a Python file imple-
menting your shell extension commands in this directory. This file must contain an
array named commands containing your command definitions:
commands = {
’cmd1’: [’Command cmd1 help’, cmd1],
’cmd2’: [’Command cmd2 help’, cmd2]
}
For example, to create a command for creating hard drive images, the following code
can be used:
def createHdd(ctx,args):
# Show some meaningful error message on wrong input
if (len(args) < 3):
print "usage: createHdd sizeM location type"
return 0
# Get arguments
size = int(args[1])
loc = args[2]
if len(args) > 3:
format = args[3]
else:
# And provide some meaningful defaults
format = "vdi"
# Report errors
if not hdd.id:
print "cannot create disk (file %s exist?)" %(loc)
45
6 The VirtualBox shell
return 0
# 0 means continue execution, other values mean exit from the interpreter
return 0
commands = {
’myCreateHDD’: [’Create virtual HDD, createHdd size location type’, createHdd]
}
Just store the above text in the file createHdd (or any other meaningful name) in
.VirtualBox/shexts/. Start the VirtualBox shell, or just issue the reloadExts com-
mand, if the shell is already running. Your new command will now be available.
46
7 Main API change log
Generally, VirtualBox will maintain API compatibility within a major release; a ma-
jor release occurs when the first or the second of the three version components of
VirtualBox change (that is, in the x.y.z scheme, a major release is one where x or y
change, but not when only z changes).
In other words, updates like those from 2.0.0 to 2.0.2 will not come with API break-
ages.
Migration between major releases most likely will lead to API breakage, so please
make sure you updated code accordingly. The OOWS Java wrappers enforce that
mechanism by putting VirtualBox classes into version-specific packages such as
org.virtualbox_2_2. This approach allows for connecting to multiple VirtualBox
versions simultaneously from the same Java application.
The following sections list incompatible changes that the Main API underwent since
the original release of this SDK Reference with VirtualBox 2.0. A change is deemed
“incompatible” only if it breaks existing client code (e.g. changes in method param-
eter lists, renamed or removed interfaces and similar). In other words, the list does
not contain new interfaces, methods or attributes or other changes that do not affect
existing client code.
47
7 Main API change log
48
7 Main API change log
each storage bus type you can query the device types which can be attached, so
that it is not necessary to hardcode any attachment rules.
This required matching changes e.g. in the callback interfaces (the medium
specific change notification was replaced by a generic medium change notifica-
tion) and removing associated enums (e.g. DriveState). In many places the
incorrect use of the plural form “media” was replaced by “medium”, to improve
consistency.
• Reading the IMedium::state attribute no longer automatically performs an acces-
sibility check; a new method IMedium::refreshState() does this. The attribute
only returns the state any more.
• There were substantial changes related to snapshots, triggered by the “branched
snapshots” functionality introduced with version 3.1. IConsole::discardSnapshot
was renamed to IConsole::deleteSnapshot(). IConsole::discardCurrentState
and IConsole::discardCurrentSnapshotAndState were removed; correspond-
ing new functionality is in IConsole::restoreSnapshot(). Also, when ICon-
sole::takeSnapshot() is called on a running virtual machine, a live snapshot
will be created. The old behavior was to temporarily pause the virtual machine
while creating an online snapshot.
• The IVRDPServer, IRemoteDisplayInfo and IConsoleCallback interfaces were
changed to reflect VRDP server ability to bind to one of available ports from
a list of ports.
The IVRDPServer::port attribute has been replaced with IVRDPServer::ports,
which is a comma-separated list of ports or ranges of ports.
An IRemoteDisplayInfo::port attribute has been added for querying the actual
port VRDP server listens on.
An IConsoleCallback::onRemoteDisplayInfoChange() notification callback has
been added.
• The parameter lists for the following functions were modified:
– IHost::removeHostOnlyNetworkInterface()
– IHost::removeUSBDeviceFilter()
• In the OOWS bindings for JAX-WS, the behavior of structures changed: for
one, we implemented natural structures field access so you can just call a “get”
method to obtain a field. Secondly, setters in structures were disabled as they
have no expected effect and were at best misleading.
49
7 Main API change log
methods from a parent class. In particular, IHardDisk and other classes now
properly derive from IMedium.
• All object identifiers (machines, snapshots, disks, etc) switched from GUIDs to
strings (now still having string representation of GUIDs inside). As a result, no
particular internal structure can be assumed for object identifiers; instead, they
should be treated as opaque unique handles. This change mostly affects Java
and C++ programs; for other languages, GUIDs are transparently converted to
strings.
• The uses of NULL strings have been changed greatly. All out parameters now
use empty strings to signal a null value. For in parameters both the old NULL
and empty string is allowed. This change was necessary to support more client
bindings, especially using the webservice API. Many of them either have no spe-
cial NULL value or have trouble dealing with it correctly in the respective library
code.
• Accidentally, the TSBool interface still appeared in 3.0.0, and was removed in
3.0.2. This is an SDK bug, do not use the SDK for VirtualBox 3.0.0 for developing
clients.
• The type of IVirtualBoxErrorInfo::resultCode changed from result to long.
50
7 Main API change log
51
7 Main API change log
52
7 Main API change log
• Added IMachine::pushGuestProperty().
• New attributes in IMachine: accelerate3DEnabled, HWVirtExVPIDEnabled,
guestPropertyNotificationPatterns, CPUCount.
• Added IConsole::powerUpPaused() and IConsole::getGuestEnteredACPIMode().
53
8 License information
The sample code files shipped with the SDK are generally licensed liberally to make it
easy for anyone to use this code for their own application code.
The Java files under bindings/webservice/java/jax-ws/ (library files for the
object-oriented web service) are, by contrast, licensed under the GNU Lesser General
Public License (LGPL) V2.1.
See sdk/bindings/webservice/java/jax-ws/src/COPYING.LIB for the full text
of the LGPL 2.1.
When in doubt, please refer to the individual source code files shipped with this
SDK.
54
9 Classes (interfaces)
9.1 IAppliance
Represents a platform-independent appliance in OVF format. An instance of this is
returned by IVirtualBox::createAppliance(), which can then be used to import and
export virtual machines within an appliance with VirtualBox.
The OVF standard suggests two different physical file formats:
1. If the appliance is distributed as a set of files, there must be at least one XML
descriptor file that conforms to the OVF standard and carries an .ovf file ex-
tension. If this descriptor file references other files such as disk images, as OVF
appliances typically do, those additional files must be in the same directory as
the descriptor file.
2. If the appliance is distributed as a single file, it must be in TAR format and
have the .ova file extension. This TAR file must then contain at least the OVF
descriptor files and optionally other files.
At this time, VirtualBox does not not yet support the packed (TAR) variant; sup-
port will be added with a later version.
55
9 Classes (interfaces)
Exporting VirtualBox machines into an OVF appliance involves the following steps:
9.1.1 Attributes
9.1.1.1 path (read-only)
wstring IAppliance::path
Path to the main file of the OVF appliance, which is either the .ovf or the .ova file
passed to read() (for import) or write() (for export). This attribute is empty until one
of these methods has been called.
Array of virtual disk definitions. One such description exists for each disk definition
in the OVF; each string array item represents one such piece of disk information, with
the information fields separated by tab (\t) characters.
The caller should be prepared for additional fields being appended to this string in
future versions of VirtualBox and therefore check for the number of tabs in the strings
returned.
In the current version, the following eight fields are returned per string in the array:
3. Populated size (optional unsigned integer indicating the current size of the disk;
can be approximate; -1 if unspecified)
4. Format (string identifying the disk format, typically “http://www.vmware.com/specifications/vmdk.html#s
56
9 Classes (interfaces)
5. Reference (where to find the disk image, typically a file name; if empty, then the
disk should be created on import)
6. Image size (optional unsigned integer indicating the size of the image, which
need not necessarily be the same as the values specified above, since the image
may be compressed or sparse; -1 if not specified)
7. Chunk size (optional unsigned integer if the image is split into chunks; presently
unsupported and always -1)
Array of virtual system descriptions. One such description is created for each virtual
system (machine) found in the OVF. This array is empty until either interpret() (for
import) or IMachine::export() (for export) has been called.
9.1.2 createVFSExplorer
IVFSExplorer IAppliance::createVFSExplorer(
[in] wstring aUri)
9.1.3 getWarnings
wstring[] IAppliance::getWarnings()
9.1.4 importMachines
IProgress IAppliance::importMachines()
Imports the appliance into VirtualBox by creating instances of IMachine and other
interfaces that match the information contained in the appliance as closely as possible,
as represented by the import instructions in the virtualSystemDescriptions[] array.
Calling this method is the final step of importing an appliance into VirtualBox; see
IAppliance for an overview.
Since importing the appliance will most probably involve copying and converting
disk images, which can take a long time, this method operates asynchronously and
returns an IProgress object to allow the caller to monitor the progress.
57
9 Classes (interfaces)
9.1.5 interpret
void IAppliance::interpret()
Interprets the OVF data that was read when the appliance was constructed. After
calling this method, one can inspect the virtualSystemDescriptions[] array attribute,
which will then contain one IVirtualSystemDescription for each virtual machine found
in the appliance.
Calling this method is the second step of importing an appliance into VirtualBox;
see IAppliance for an overview.
After calling this method, one should call getWarnings() to find out if problems were
encountered during the processing which might later lead to errors.
9.1.6 read
IProgress IAppliance::read(
[in] wstring file)
file Name of appliance file to open (either with an .ovf or .ova extension, depend-
ing on whether the appliance is distributed as a set of files or as a single file,
respectively).
9.1.7 write
IProgress IAppliance::write(
[in] wstring format,
[in] wstring path)
format Output format, as a string. Currently supported formats are “ovf-0.9” and
“ovf-1.0”; future versions of VirtualBox may support additional formats.
path Name of appliance file to open (either with an .ovf or .ova extension, depend-
ing on whether the appliance is distributed as a set of files or as a single file,
respectively).
Writes the contents of the appliance exports into a new OVF file.
Calling this method is the final step of exporting an appliance from VirtualBox; see
IAppliance for an overview.
Since exporting the appliance will most probably involve copying and converting
disk images, which can take a long time, this method operates asynchronously and
returns an IProgress object to allow the caller to monitor the progress.
58
9 Classes (interfaces)
9.2 IAudioAdapter
The IAudioAdapter interface represents the virtual audio adapter of the virtual ma-
chine. Used in IMachine::audioAdapter.
9.2.1 Attributes
9.2.1.1 enabled (read/write)
boolean IAudioAdapter::enabled
Flag whether the audio adapter is present in the guest system. If disabled, the virtual
guest hardware will not contain any audio adapter. Can only be changed when the VM
is not running.
Audio driver the adapter is connected to. This setting can only be changed when
the VM is not running.
9.3 IBIOSSettings
The IBIOSSettings interface represents BIOS settings of the virtual machine. This is
used only in the IMachine::BIOSSettings attribute.
9.3.1 Attributes
9.3.1.1 logoFadeIn (read/write)
boolean IBIOSSettings::logoFadeIn
59
9 Classes (interfaces)
Local file system path for external BIOS splash image. Empty string means the
default image is shown on boot.
IO APIC support flag. If set, VirtualBox will provide an IO APIC and support IRQs
above 15.
Offset in milliseconds from the host system time. This allows for guests running
with a different system date/time than the host. It is equivalent to setting the system
date/time in the BIOS except it is not an absolute value but a relative one. Guest
Additions time synchronization honors this offset.
PXE debug logging flag. If set, VirtualBox will write extensive PXE trace information
to the release log.
60
9 Classes (interfaces)
9.4 IConsole
The IConsole interface represents an interface to control virtual machine execution.
The console object that implements the IConsole interface is obtained from a
session object after the session for the given machine has been opened using
one of IVirtualBox::openSession(), IVirtualBox::openRemoteSession() or IVirtual-
Box::openExistingSession() methods.
Methods of the IConsole interface allow the caller to query the current virtual ma-
chine execution state, pause the machine or power it down, save the machine state or
take a snapshot, attach and detach removable media and so on.
See also: ISession
9.4.1 Attributes
9.4.1.1 machine (read-only)
IMachine IConsole::machine
Note: This property always returns the same value as the corresponding prop-
erty of the IMachine object this console is sessioned with. For the process that
owns (executes) the VM, this is the preferable way of querying the VM state,
because no IPC calls are made.
Guest object.
61
9 Classes (interfaces)
Note: If the machine is not running, any attempt to use the returned object
will result in an error.
Note: If the machine is not running, any attempt to use the returned object
will result in an error.
Note: If the machine is not running, any attempt to use the returned object
will result in an error.
Debugging interface.
62
9 Classes (interfaces)
List of USB devices currently attached to the remote VRDP client. Once a new device
is physically attached to the remote host computer, it appears in this list and remains
there until detached.
Collection of shared folders for the current session. These folders are called tran-
sient shared folders because they are available to the guest OS running inside the
associated virtual machine only for the duration of the session (as opposed to IMa-
chine::sharedFolders[] which represent permanent shared folders). When the session
is closed (e.g. the machine is powered down), these folders are automatically dis-
carded.
New shared folders are added to the collection using createSharedFolder(). Existing
shared folders can be removed using removeSharedFolder().
9.4.2 adoptSavedState
void IConsole::adoptSavedState(
[in] wstring savedStateFile)
Note: It’s a caller’s responsibility to make sure the given saved state file is
compatible with the settings of this virtual machine that represent its virtual
hardware (memory size, storage disk configuration etc.). If there is a mis-
match, the behavior of the virtual machine is undefined.
63
9 Classes (interfaces)
9.4.3 attachUSBDevice
void IConsole::attachUSBDevice(
[in] uuid id)
Attaches a host USB device with the given UUID to the USB controller of the virtual
machine.
The device needs to be in one of the following states: Busy, Available or Held,
otherwise an error is immediately returned.
When the device state is Busy, an error may also be returned if the host computer
refuses to release it for some reason.
See also: IUSBController::deviceFilters, USBDeviceState
If this method fails, the following error codes may be reported:
9.4.4 createSharedFolder
void IConsole::createSharedFolder(
[in] wstring name,
[in] wstring hostPath,
[in] boolean writable)
Creates a transient new shared folder by associating the given logical name with the
given host path, adds it to the collection of shared folders and starts sharing it. Refer
to the description of ISharedFolder to read more about logical names.
If this method fails, the following error codes may be reported:
64
9 Classes (interfaces)
9.4.5 deleteSnapshot
IProgress IConsole::deleteSnapshot(
[in] uuid id)
Starts deleting the specified snapshot asynchronously. See ISnapshot for an intro-
duction to snapshots.
The execution state and settings of the associated machine stored in the snapshot
will be deleted. The contents of all differencing media of this snapshot will be merged
with the contents of their dependent child media to keep the medium chain valid (in
other words, all changes represented by media being deleted will be propagated to
their child medium). After that, this snapshot’s differencing medium will be deleted.
The parent of this snapshot will become a new parent for all its child snapshots.
If the deleted snapshot is the current one, its parent snapshot will become a new
current snapshot. The current machine state is not directly affected in this case, except
that currently attached differencing media based on media of the deleted snapshot will
be also merged as described above.
If the deleted snapshot is the first or current snapshot, then the respective IMachine
attributes will be adjusted. Deleting the current snapshot will also implicitly call IMa-
chine::saveSettings() to make all current machine settings permanent.
Deleting a snapshot has the following preconditions:
• Child media of all normal media of the deleted snapshot must be accessible (see
IMedium::state) for this operation to succeed. In particular, this means that all
virtual machines, whose media are directly or indirectly based on the media of
deleted snapshot, must be powered off.
• You cannot delete the snapshot if a medium attached to it has more than once
child medium (differencing images) because otherwise merging would be im-
possible. This might be the case if there is more than one child snapshot or
differencing images were created for other reason (e.g. implicitly because of
multiple machine attachments).
Note: Merging medium contents can be very time and disk space consuming,
if these media are big in size and have many children. However, if the snap-
shot being deleted is the last (head) snapshot on the branch, the operation
will be rather quick.
65
9 Classes (interfaces)
9.4.6 detachUSBDevice
IUSBDevice IConsole::detachUSBDevice(
[in] uuid id)
9.4.7 findUSBDeviceByAddress
IUSBDevice IConsole::findUSBDeviceByAddress(
[in] wstring name)
name Address of the USB device (as assigned by the host) to search for.
Searches for a USB device with the given host address.
See also: IUSBDevice::address
If this method fails, the following error codes may be reported:
• VBOX_E_OBJECT_NOT_FOUND: Given name does not correspond to any USB de-
vice.
9.4.8 findUSBDeviceById
IUSBDevice IConsole::findUSBDeviceById(
[in] uuid id)
66
9 Classes (interfaces)
9.4.9 forgetSavedState
void IConsole::forgetSavedState(
[in] boolean remove)
Forgets the saved state of the virtual machine previously created by saveState().
Next time the machine is powered up, a clean boot will occur. If remove is true the
saved state file is deleted.
9.4.10 getDeviceActivity
DeviceActivity IConsole::getDeviceActivity(
[in] DeviceType type)
type
9.4.11 getGuestEnteredACPIMode
boolean IConsole::getGuestEnteredACPIMode()
Checks if the guest entered the ACPI mode G0 (working) or G1 (sleeping). If this
method returns false, the guest will most likely not respond to external ACPI events.
If this method fails, the following error codes may be reported:
9.4.12 getPowerButtonHandled
boolean IConsole::getPowerButtonHandled()
67
9 Classes (interfaces)
9.4.13 pause
void IConsole::pause()
9.4.14 powerButton
void IConsole::powerButton()
9.4.15 powerDown
IProgress IConsole::powerDown()
Initiates the power down procedure to stop the virtual machine execution.
The completion of the power down procedure is tracked using the returned IProgress
object. After the operation is complete, the machine will go to the PoweredOff state.
If this method fails, the following error codes may be reported:
9.4.16 powerUp
IProgress IConsole::powerUp()
Starts the virtual machine execution using the current machine state (that is, its
current execution state, current settings and current storage devices).
If the machine is powered off or aborted, the execution will start from the beginning
(as if the real hardware were just powered on).
If the machine is in the Saved state, it will continue its execution the point where
the state has been saved.
If the machine IMachine::teleporterEnabled property is enabled on the machine
being powered up, the machine will wait for an incoming teleportation in the Tele-
portingIn state. The returned progress object will have at least three operations where
68
9 Classes (interfaces)
the last three are defined as: (1) powering up and starting TCP server, (2) waiting
for incoming teleportations, and (3) perform teleportation. These operations will be
reflected as the last three operations of the progress objected returned by IVirtual-
Box::openRemoteSession() as well.
Note: Unless you are trying to write a new VirtualBox front-end that per-
forms direct machine execution (like the VirtualBox or VBoxSDL front-ends),
don’t call powerUp() in a direct session opened by IVirtualBox::openSession()
and use this session only to change virtual machine settings. If you sim-
ply want to start virtual machine execution using one of the existing front-
ends (for example the VirtualBox GUI or headless server), simply use IVir-
tualBox::openRemoteSession(); these front-ends will power up the machine
automatically for you.
9.4.17 powerUpPaused
IProgress IConsole::powerUpPaused()
Identical to powerUp except that the VM will enter the Paused state, instead of
Running.
See also: #powerUp
If this method fails, the following error codes may be reported:
9.4.18 registerCallback
void IConsole::registerCallback(
[in] IConsoleCallback callback)
69
9 Classes (interfaces)
callback
Registers a new console callback on this instance. The methods of the callback
interface will be called by this instance when the appropriate event occurs.
9.4.19 removeSharedFolder
void IConsole::removeSharedFolder(
[in] wstring name)
Removes a transient shared folder with the given name previously created by cre-
ateSharedFolder() from the collection of shared folders and stops sharing it.
If this method fails, the following error codes may be reported:
9.4.20 reset
void IConsole::reset()
9.4.21 restoreSnapshot
IProgress IConsole::restoreSnapshot(
[in] ISnapshot snapshot)
Starts resetting the machine’s current state to the state contained in the given snap-
shot, asynchronously. All current settings of the machine will be reset and changes
stored in differencing media will be lost. See ISnapshot for an introduction to snap-
shots.
After this operation is successfully completed, new empty differencing media are
created for all normal media of the machine.
If the given snapshot is an online snapshot, the machine will go to the Saved, so
that the next time it is powered on, the execution state will be restored from the state
of the snapshot.
70
9 Classes (interfaces)
Note: The machine must not be running, otherwise the operation will fail.
Note: If the machine state is Saved prior to this operation, the saved state file
will be implicitly deleted (as if forgetSavedState() were called).
9.4.22 resume
void IConsole::resume()
9.4.23 saveState
IProgress IConsole::saveState()
Saves the current execution state of a running virtual machine and stops its execu-
tion.
After this operation completes, the machine will go to the Saved state. Next time it
is powered up, this state will be restored and the machine will continue its execution
from the place where it was saved.
This operation differs from taking a snapshot to the effect that it doesn’t create new
differencing media. Also, once the machine is powered up from the state saved using
this method, the saved state is deleted, so it will be impossible to return to this state
later.
Note: The machine must be in the Running or Paused state, otherwise the
operation will fail.
71
9 Classes (interfaces)
9.4.24 sleepButton
void IConsole::sleepButton()
9.4.25 takeSnapshot
IProgress IConsole::takeSnapshot(
[in] wstring name,
[in] wstring description)
Saves the current execution state and all settings of the machine and creates differ-
encing images for all normal (non-independent) media. See ISnapshot for an intro-
duction to snapshots.
This method can be called for a PoweredOff, Saved (see saveState()), Running or
Paused virtual machine. When the machine is PoweredOff, an offline snapshot is cre-
ated. When the machine is Running a live snapshot is created, and an online snapshot
is is created when Paused.
The taken snapshot is always based on the current snapshot of the associated virtual
machine and becomes a new current snapshot.
72
9 Classes (interfaces)
9.4.26 teleport
IProgress IConsole::teleport(
[in] wstring hostname,
[in] unsigned long tcpport,
[in] wstring password,
[in] unsigned long maxDowntime)
9.4.27 unregisterCallback
void IConsole::unregisterCallback(
[in] IConsoleCallback callback)
callback
73
9 Classes (interfaces)
9.5 IConsoleCallback
This interface is used by a client of the Main API that need to be notified of events.
For example, a graphical user interface can use this to learn about machine state
changes so they can update the list of virtual machines without having to rely on
polling.
Whenever relevant events occur in VirtualBox, the callbacks in objects of this in-
terface are called. In order for this to be useful, a client needs to create its own
subclass that implements this interface in which the methods for the relevant call-
backs are overridden. An instance of this subclass interface can then be passed to
IConsole::registerCallback().
9.5.1 onAdditionsStateChange
void IConsoleCallback::onAdditionsStateChange()
9.5.2 onCPUChange
void IConsoleCallback::onCPUChange(
[in] unsigned long cpu,
[in] boolean add)
9.5.3 onCanShowWindow
boolean IConsoleCallback::onCanShowWindow()
74
9 Classes (interfaces)
9.5.4 onKeyboardLedsChange
void IConsoleCallback::onKeyboardLedsChange(
[in] boolean numLock,
[in] boolean capsLock,
[in] boolean scrollLock)
numLock
capsLock
scrollLock
9.5.5 onMediumChange
void IConsoleCallback::onMediumChange(
[in] IMediumAttachment mediumAttachment)
9.5.6 onMouseCapabilityChange
void IConsoleCallback::onMouseCapabilityChange(
[in] boolean supportsAbsolute,
[in] boolean supportsRelative,
[in] boolean needsHostCursor)
75
9 Classes (interfaces)
supportsAbsolute
supportsRelative
needsHostCursor
Notification when the mouse capabilities reported by the guest have changed. The
new capabilities are passed.
If this method fails, the following error codes may be reported:
9.5.7 onMousePointerShapeChange
void IConsoleCallback::onMousePointerShapeChange(
[in] boolean visible,
[in] boolean alpha,
[in] unsigned long xHot,
[in] unsigned long yHot,
[in] unsigned long width,
[in] unsigned long height,
[in] octet shape[])
76
9 Classes (interfaces)
The XOR mask follows the AND mask on the next 4-byte aligned offset: uint8_t
*pXor = pAnd + (cbAnd + 3) & 3̃. Bytes in the gap between the AND and
the XOR mask are undefined. The XOR mask scanlines have no gap between
them and the size of the XOR mask is: cXor = width * 4 * height.
Notification when the guest mouse pointer shape has changed. The new shape data
is given.
If this method fails, the following error codes may be reported:
• VBOX_E_DONT_CALL_AGAIN: Do not call again, this method is a NOP.
9.5.8 onNetworkAdapterChange
void IConsoleCallback::onNetworkAdapterChange(
[in] INetworkAdapter networkAdapter)
9.5.9 onParallelPortChange
void IConsoleCallback::onParallelPortChange(
[in] IParallelPort parallelPort)
9.5.10 onRemoteDisplayInfoChange
void IConsoleCallback::onRemoteDisplayInfoChange()
Notification when the status of the VRDP server changes. Interested callees should
use IRemoteDisplayInfo attributes to find out what is the current status.
If this method fails, the following error codes may be reported:
• VBOX_E_DONT_CALL_AGAIN: Do not call again, this method is a NOP.
77
9 Classes (interfaces)
9.5.11 onRuntimeError
void IConsoleCallback::onRuntimeError(
[in] boolean fatal,
[in] wstring id,
[in] wstring message)
• fatal
• non-fatal with retry
• non-fatal warnings
Fatal errors are indicated by the fatal parameter set to true. In case of fatal errors,
the virtual machine execution is always paused before calling this notification, and the
notification handler is supposed either to immediately save the virtual machine state
using IConsole::saveState() or power it off using IConsole::powerDown(). Resuming
the execution can lead to unpredictable results.
Non-fatal errors and warnings are indicated by the fatal parameter set to false.
If the virtual machine is in the Paused state by the time the error notification is re-
ceived, it means that the user can try to resume the machine execution after attempt-
ing to solve the problem that caused the error. In this case, the notification handler
is supposed to show an appropriate message to the user (depending on the value of
the id parameter) that offers several actions such as Retry, Save or Power Off. If the
user wants to retry, the notification handler should continue the machine execution
using the IConsole::resume() call. If the machine execution is not Paused during this
notification, then it means this notification is a warning (for example, about a fatal
condition that can happen very soon); no immediate action is required from the user,
the machine continues its normal execution.
Note that in either case the notification handler must not perform any action di-
rectly on a thread where this notification is called. Everything it is allowed to do
is to post a message to another thread that will then talk to the user and take the
corresponding action.
Currently, the following error identifiers are known:
• "HostMemoryLow"
• "HostAudioNotResponding"
• "VDIStorageFull"
78
9 Classes (interfaces)
• "3DSupportIncompatibleAdditions"
9.5.12 onSerialPortChange
void IConsoleCallback::onSerialPortChange(
[in] ISerialPort serialPort)
Notification when a property of one of the virtual serial ports changes. Interested
callees should use ISerialPort methods and attributes to find out what has changed.
If this method fails, the following error codes may be reported:
9.5.13 onSharedFolderChange
void IConsoleCallback::onSharedFolderChange(
[in] Scope scope)
Notification when a shared folder is added or removed. The scope argument defines
one of three scopes: global shared folders (Global), permanent shared folders of the
machine (Machine) or transient shared folders of the machine (Session). Interested
callees should use query the corresponding collections to find out what has changed.
If this method fails, the following error codes may be reported:
79
9 Classes (interfaces)
9.5.14 onShowWindow
unsigned long long IConsoleCallback::onShowWindow()
9.5.15 onStateChange
void IConsoleCallback::onStateChange(
[in] MachineState state)
state
Notification when the execution state of the machine has changed. The new state
will be given.
If this method fails, the following error codes may be reported:
80
9 Classes (interfaces)
9.5.16 onStorageControllerChange
void IConsoleCallback::onStorageControllerChange()
Notification when a property of one of the virtual storage controllers changes. Inter-
ested callees should query the corresponding collections to find out what has changed.
If this method fails, the following error codes may be reported:
9.5.17 onUSBControllerChange
void IConsoleCallback::onUSBControllerChange()
9.5.18 onUSBDeviceStateChange
void IConsoleCallback::onUSBDeviceStateChange(
[in] IUSBDevice device,
[in] boolean attached,
[in] IVirtualBoxErrorInfo error)
Notification when a USB device is attached to or detached from the virtual USB
controller.
This notification is sent as a result of the indirect request to attach the device because
it matches one of the machine USB filters, or as a result of the direct request issued by
IConsole::attachUSBDevice() or IConsole::detachUSBDevice().
This notification is sent in case of both a succeeded and a failed request completion.
When the request succeeds, the error parameter is null, and the given device has
been already added to (when attached is true) or removed from (when attached is
false) the collection represented by IConsole::USBDevices[]. On failure, the collec-
tion doesn’t change and the error parameter represents the error message describing
the failure.
If this method fails, the following error codes may be reported:
81
9 Classes (interfaces)
9.5.19 onVRDPServerChange
void IConsoleCallback::onVRDPServerChange()
Notification when a property of the VRDP server changes. Interested callees should
use IVRDPServer methods and attributes to find out what has changed.
If this method fails, the following error codes may be reported:
9.6 IDHCPServer
The IDHCPServer interface represents the vbox dhcp server configuration.
To enumerate all the dhcp servers on the host, use the IVirtualBox::DHCPServers[]
attribute.
9.6.1 Attributes
9.6.1.1 enabled (read/write)
boolean IDHCPServer::enabled
specifies server IP
82
9 Classes (interfaces)
9.6.2 setConfiguration
void IDHCPServer::setConfiguration(
[in] wstring IPAddress,
[in] wstring networkMask,
[in] wstring FromIPAddress,
[in] wstring ToIPAddress)
9.6.3 start
void IDHCPServer::start(
[in] wstring networkName,
[in] wstring trunkName,
[in] wstring trunkType)
9.6.4 stop
void IDHCPServer::stop()
83
9 Classes (interfaces)
9.7 IDisplay
The IDisplay interface represents the virtual machine’s display.
The object implementing this interface is contained in each IConsole::display at-
tribute and represents the visual output of the virtual machine.
The virtual display supports pluggable output targets represented by the IFrame-
buffer interface. Examples of the output target are a window on the host computer or
an RDP session’s display on a remote computer.
9.7.1 completeVHWACommand
void IDisplay::completeVHWACommand(
[in] [ptr] octet command)
9.7.2 drawToScreen
void IDisplay::drawToScreen(
[in] unsigned long screenId,
[in] [ptr] octet address,
[in] unsigned long x,
[in] unsigned long y,
[in] unsigned long width,
[in] unsigned long height)
screenId
address
x Relative to the screen top left corner.
84
9 Classes (interfaces)
Draws a 32-bpp image of the specified size from the given buffer to the given point
on the VM display.
If this method fails, the following error codes may be reported:
9.7.3 getFramebuffer
void IDisplay::getFramebuffer(
[in] unsigned long screenId,
[out] IFramebuffer framebuffer,
[out] long xOrigin,
[out] long yOrigin)
screenId
framebuffer
xOrigin
yOrigin
9.7.4 getScreenResolution
void IDisplay::getScreenResolution(
[in] unsigned long screenId,
[out] unsigned long width,
[out] unsigned long height,
[out] unsigned long bitsPerPixel)
screenId
width
height
bitsPerPixel
Queries display width, height and color depth for given screen.
85
9 Classes (interfaces)
9.7.5 invalidateAndUpdate
void IDisplay::invalidateAndUpdate()
Does a full invalidation of the VM display and instructs the VM to update it.
If this method fails, the following error codes may be reported:
• VBOX_E_IPRT_ERROR: Could not invalidate and update screen.
9.7.6 resizeCompleted
void IDisplay::resizeCompleted(
[in] unsigned long screenId)
screenId
Signals that a framebuffer has completed the resize operation.
If this method fails, the following error codes may be reported:
• VBOX_E_NOT_SUPPORTED: Operation only valid for external frame buffers.
9.7.7 setFramebuffer
void IDisplay::setFramebuffer(
[in] unsigned long screenId,
[in] IFramebuffer framebuffer)
screenId
framebuffer
Sets the framebuffer for given screen.
9.7.8 setSeamlessMode
void IDisplay::setSeamlessMode(
[in] boolean enabled)
enabled
Enables or disables seamless guest display rendering (seamless desktop integration)
mode.
86
9 Classes (interfaces)
9.7.9 setVideoModeHint
void IDisplay::setVideoModeHint(
[in] unsigned long width,
[in] unsigned long height,
[in] unsigned long bitsPerPixel,
[in] unsigned long display)
width
height
bitsPerPixel
display
Asks VirtualBox to request the given video mode from the guest. This is just a
hint and it cannot be guaranteed that the requested resolution will be used. Guest
Additions are required for the request to be seen by guests. The caller should issue the
request and wait for a resolution change and after a timeout retry.
Specifying 0 for either width, height or bitsPerPixel parameters means that
the corresponding values should be taken from the current video mode (i.e. left un-
changed).
If the guest OS supports multi-monitor configuration then the display parameter
specifies the number of the guest display to send the hint to: 0 is the primary display,
1 is the first secondary and so on. If the multi-monitor configuration is not supported,
display must be 0.
If this method fails, the following error codes may be reported:
9.7.10 takeScreenShot
void IDisplay::takeScreenShot(
[in] unsigned long screenId,
[in] [ptr] octet address,
[in] unsigned long width,
[in] unsigned long height)
screenId
address
width
87
9 Classes (interfaces)
height
Takes a screen shot of the requested size and copies it to the 32-bpp buffer allocated
by the caller and pointed to by address. A pixel consists of 4 bytes in order: B, G, R,
0.
Note: This API can be used only by the COM/XPCOM C++ API as it requires
pointer support. Use takeScreenShotToArray() with other language bindings.
9.7.11 takeScreenShotToArray
octet[] IDisplay::takeScreenShotToArray(
[in] unsigned long screenId,
[in] unsigned long width,
[in] unsigned long height)
Takes a guest screen shot of the requested size and returns it as an array of bytes in
uncompressed 32-bit RGBA format. A pixel consists of 4 bytes in order: R, G, B, 0xFF.
This API is slow, but could be the only option to get guest screenshot for scriptable
languages not allowed to manipulate with addresses directly.
If this method fails, the following error codes may be reported:
9.8 IFramebuffer
88
9 Classes (interfaces)
9.8.1 Attributes
9.8.1.1 address (read-only)
octet IFramebuffer::address
Color depth, in bits per pixel. When pixelFormat is FOURCC_RGB, valid values are:
8, 15, 16, 24 and 32.
Scan line size, in bytes. When pixelFormat is FOURCC_RGB, the size of the scan line
must be aligned to 32 bits.
Frame buffer pixel format. It’s either one of the values defined by FramebufferPix-
elFormat or a raw FOURCC code.
Note: This attribute must never return Opaque – the format of the buffer
address points to must be always known.
89
9 Classes (interfaces)
Defines whether this frame buffer uses the virtual video card’s memory buffer (guest
VRAM) directly or not. See requestResize() for more information.
Hint from the frame buffer about how much of the standard screen height it wants
to use for itself. This information is exposed to the guest through the VESA BIOS and
VMMDev interface so that it can use it for determining its video mode table. It is not
guaranteed that the guest respects the value.
An alpha-blended overlay which is superposed over the frame buffer. The initial
purpose is to allow the display of icons providing information about the VM state,
including disk activity, in front ends which do not have other means of doing that.
The overlay is designed to controlled exclusively by IDisplay. It has no locking of its
own, and any changes made to it are not guaranteed to be visible until the affected
portion of IFramebuffer is updated. The overlay can be created lazily the first time
it is requested. This attribute can also return null to signal that the overlay is not
implemented.
9.8.2 getVisibleRegion
90
9 Classes (interfaces)
Note: The address of the provided array must be in the process space of this
IFramebuffer object.
9.8.3 lock
void IFramebuffer::lock()
Locks the frame buffer. Gets called by the IDisplay object where this frame buffer is
bound to.
9.8.4 notifyUpdate
void IFramebuffer::notifyUpdate(
[in] unsigned long x,
[in] unsigned long y,
[in] unsigned long width,
[in] unsigned long height)
x
y
width
height
Informs about an update. Gets called by the display object where this buffer is
registered.
91
9 Classes (interfaces)
9.8.5 processVHWACommand
void IFramebuffer::processVHWACommand(
[in] [ptr] octet command)
Posts a Video HW Acceleration Command to the frame buffer for processing. The
commands used for 2D video acceleration (DDraw surface creation/destroying, blit-
ting, scaling, color covnersion, overlaying, etc.) are posted from quest to the host to
be processed by the host hardware.
Note: The address of the provided command must be in the process space of
this IFramebuffer object.
9.8.6 requestResize
boolean IFramebuffer::requestResize(
[in] unsigned long screenId,
[in] unsigned long pixelFormat,
[in] [ptr] octet VRAM,
[in] unsigned long bitsPerPixel,
[in] unsigned long bytesPerLine,
[in] unsigned long width,
[in] unsigned long height)
screenId Logical screen number. Must be used in the corresponding call to IDis-
play::resizeCompleted() if this call is made.
pixelFormat Pixel format of the memory buffer pointed to by VRAM. See also Frame-
bufferPixelFormat.
VRAM Pointer to the virtual video card’s VRAM (may be null).
bitsPerPixel Color depth, bits per pixel.
bytesPerLine Size of one scan line, in bytes.
width Width of the guest display, in pixels.
92
9 Classes (interfaces)
93
9 Classes (interfaces)
as possible. If finished is false, the machine will not call any frame buffer methods
until IDisplay::resizeCompleted() is called.
Note that if the direct mode is chosen, the bitsPerPixel, bytesPerLine and pixelFormat
attributes of this frame buffer must return exactly the same values as specified in the
parameters of this method, after the resize is completed. If the indirect mode is chosen,
these attributes must return values describing the format of the implementation’s own
memory buffer address points to. Note also that the bitsPerPixel value must always
correlate with pixelFormat. Note that the pixelFormat attribute must never return
Opaque regardless of the selected mode.
Note: This method is called by the IDisplay object under the lock() pro-
vided by this IFramebuffer implementation. If this method returns false
in finished, then this lock is not released until IDisplay::resizeCompleted()
is called.
9.8.7 setVisibleRegion
void IFramebuffer::setVisibleRegion(
[in] [ptr] octet rectangles,
[in] unsigned long count)
Note: The address of the provided array must be in the process space of this
IFramebuffer object.
94
9 Classes (interfaces)
9.8.8 unlock
void IFramebuffer::unlock()
Unlocks the frame buffer. Gets called by the IDisplay object where this frame buffer
is bound to.
9.8.9 videoModeSupported
boolean IFramebuffer::videoModeSupported(
[in] unsigned long width,
[in] unsigned long height,
[in] unsigned long bpp)
width
height
bpp
Returns whether the frame buffer implementation is willing to support a given video
mode. In case it is not able to render the video mode (or for some reason not willing),
it should return false. Usually this method is called when the guest asks the VMM
device whether a given video mode is supported so the information returned is directly
exposed to the guest. It is important that this method returns very quickly.
9.9 IFramebufferOverlay
9.9.1 Attributes
9.9.1.1 x (read-only)
unsigned long IFramebufferOverlay::x
95
9 Classes (interfaces)
9.9.1.2 y (read-only)
unsigned long IFramebufferOverlay::y
The global alpha value for the overlay. This may or may not be supported by a given
front end.
9.9.2 move
void IFramebufferOverlay::move(
[in] unsigned long x,
[in] unsigned long y)
x
y
9.10 IGuest
The IGuest interface represents information about the operating system running inside
the virtual machine. Used in IConsole::guest.
IGuest provides information about the guest operating system, whether Guest Addi-
tions are installed and other OS-specific virtual machine properties.
9.10.1 Attributes
9.10.1.1 OSTypeId (read-only)
wstring IGuest::OSTypeId
Identifier of the Guest OS type as reported by the Guest Additions. You may use
IVirtualBox::getGuestOSType() to obtain an IGuestOSType object representing details
about the given Guest OS type.
96
9 Classes (interfaces)
Note: If Guest Additions are not installed, this value will be the same as
IMachine::OSTypeId.
Flag whether the Guest Additions are installed and active in which case their version
will be returned by the additionsVersion property.
Flag whether the guest is in graphics mode. If it is not, then seamless rendering
will not work, resize hints are not immediately acted on and guest display resizes are
probably not initiated by the guest additions.
97
9 Classes (interfaces)
9.10.2 executeProcess
IProgress IGuest::executeProcess(
[in] wstring execName,
[in] unsigned long flags,
[in] wstring arguments[],
[in] wstring environment[],
[in] wstring userName,
[in] wstring password,
[in] unsigned long timeoutMS,
[out] unsigned long pid)
execName Full path name of the command to execute on the guest; the commands
has to exists in the guest VM in order to be executed.
flags Execution flags - currently not supported and therefore has to be set to 0.
arguments Array of arguments passed to the execution command.
environment Environment variables that can be set while the command is being ex-
ecuted, in form of “NAME=VALUE”; one pair per entry. To unset a variable just
set its name (“NAME”) without a value.
userName User name under which the command will be executed; has to exist and
have the appropriate rights to execute programs in the VM.
password Password of the user account specified.
timeoutMS The maximum timeout value (in msec) to wait for finished program exe-
cution. Pass 0 for an infinite timeout.
pid The PID (process ID) of the started command for later reference.
98
9 Classes (interfaces)
9.10.3 getProcessOutput
octet[] IGuest::getProcessOutput(
[in] unsigned long pid,
[in] unsigned long flags,
[in] unsigned long timeoutMS,
[in] unsigned long long size)
9.10.4 getProcessStatus
unsigned long IGuest::getProcessStatus(
[in] unsigned long pid,
[out] unsigned long exitcode,
[out] unsigned long flags)
Retrieves status, exit code and the exit reason of a formerly started process.
If this method fails, the following error codes may be reported:
9.10.5 internalGetStatistics
void IGuest::internalGetStatistics(
[out] unsigned long cpuUser,
[out] unsigned long cpuKernel,
[out] unsigned long cpuIdle,
[out] unsigned long memTotal,
[out] unsigned long memFree,
[out] unsigned long memBalloon,
99
9 Classes (interfaces)
cpuUser Percentage of processor time spent in user mode as seen by the guest
cpuKernel Percentage of processor time spent in kernel mode as seen by the guest
cpuIdle Percentage of processor time spent idling as seen by the guest
memTotal Total amount of physical guest RAM
memFree Free amount of physical guest RAM
9.10.6 setCredentials
void IGuest::setCredentials(
[in] wstring userName,
[in] wstring password,
[in] wstring domain,
[in] boolean allowInteractiveLogon)
100
9 Classes (interfaces)
allowInteractiveLogon Flag whether the guest should alternatively allow the user to
interactively specify different credentials. This flag might not be supported by
all versions of the Additions.
Store login credentials that can be queried by guest operating systems with Addi-
tions installed. The credentials are transient to the session and the guest may also
choose to erase them. Note that the caller cannot determine whether the guest oper-
ating system has queried or made use of the credentials.
If this method fails, the following error codes may be reported:
9.11 IGuestOSType
Note: With the web service, this interface is mapped to a structure. Attributes
that return this interface will not return an object, but a complete structure
containing the attributes listed below as structure members.
9.11.1 Attributes
9.11.1.1 familyId (read-only)
wstring IGuestOSType::familyId
9.11.1.3 id (read-only)
wstring IGuestOSType::id
101
9 Classes (interfaces)
102
9 Classes (interfaces)
Returns true if using USB Human Interface Devices, such as keyboard and mouse
recommended.
103
9 Classes (interfaces)
9.12 IHost
The IHost interface represents the physical machine that this VirtualBox installation
runs on.
An object implementing this interface is returned by the IVirtualBox::host attribute.
This interface contains read-only information about the host’s physical hardware (such
as what processors and disks are available, what the host operating system is, and so
on) and also allows for manipulating some of the host’s hardware, such as global USB
device filters and host interface networking.
9.12.1 Attributes
9.12.1.1 DVDDrives (read-only)
IMedium IHost::DVDDrives[]
List of USB devices currently attached to the host. Once a new device is physically
attached to the host computer, it appears in this list and remains there until detached.
104
9 Classes (interfaces)
List of USB device filters in action. When a new device is physically attached to the
host computer, filters from this list are applied to it (in order they are stored in the
list). The first matched filter will determine the action performed on the device.
Unless the device is ignored by these filters, filters of all currently running virtual
machines (IUSBController::deviceFilters[]) are applied to it.
105
9 Classes (interfaces)
9.12.2 createHostOnlyNetworkInterface
IProgress IHost::createHostOnlyNetworkInterface(
[out] IHostNetworkInterface hostInterface)
106
9 Classes (interfaces)
9.12.3 createUSBDeviceFilter
IHostUSBDeviceFilter IHost::createUSBDeviceFilter(
[in] wstring name)
9.12.4 findHostDVDDrive
IMedium IHost::findHostDVDDrive(
[in] wstring name)
9.12.5 findHostFloppyDrive
IMedium IHost::findHostFloppyDrive(
[in] wstring name)
9.12.6 findHostNetworkInterfaceById
IHostNetworkInterface IHost::findHostNetworkInterfaceById(
[in] uuid id)
Note: The method returns an error if the given GUID does not correspond to
any host network interface.
107
9 Classes (interfaces)
9.12.7 findHostNetworkInterfaceByName
IHostNetworkInterface IHost::findHostNetworkInterfaceByName(
[in] wstring name)
Note: The method returns an error if the given name does not correspond to
any host network interface.
9.12.8 findHostNetworkInterfacesOfType
IHostNetworkInterface[] IHost::findHostNetworkInterfacesOfType(
[in] HostNetworkInterfaceType type)
9.12.9 findUSBDeviceByAddress
IHostUSBDevice IHost::findUSBDeviceByAddress(
[in] wstring name)
name Address of the USB device (as assigned by the host) to search for.
Searches for a USB device with the given host address.
See also: IHostUSBDevice::address
If this method fails, the following error codes may be reported:
• VBOX_E_OBJECT_NOT_FOUND: Given name does not correspond to any USB de-
vice.
9.12.10 findUSBDeviceById
IHostUSBDevice IHost::findUSBDeviceById(
[in] uuid id)
108
9 Classes (interfaces)
9.12.11 getProcessorCPUIDLeaf
void IHost::getProcessorCPUIDLeaf(
[in] unsigned long cpuId,
[in] unsigned long leaf,
[in] unsigned long subLeaf,
[out] unsigned long valEax,
[out] unsigned long valEbx,
[out] unsigned long valEcx,
[out] unsigned long valEdx)
Note: The current implementation might not necessarily return the descrip-
tion for this exact CPU.
subLeaf CPUID leaf sub index (ecx). This currently only applies to cache information
on Intel CPUs. Use 0 if retriving values for IMachine::setCPUIDLeaf().
valEax CPUID leaf value for register eax.
valEbx CPUID leaf value for register ebx.
9.12.12 getProcessorDescription
wstring IHost::getProcessorDescription(
[in] unsigned long cpuId)
Note: The current implementation might not necessarily return the descrip-
tion for this exact CPU.
109
9 Classes (interfaces)
9.12.13 getProcessorFeature
boolean IHost::getProcessorFeature(
[in] ProcessorFeature feature)
9.12.14 getProcessorSpeed
unsigned long IHost::getProcessorSpeed(
[in] unsigned long cpuId)
9.12.15 insertUSBDeviceFilter
void IHost::insertUSBDeviceFilter(
[in] unsigned long position,
[in] IHostUSBDeviceFilter filter)
Inserts the given USB device to the specified position in the list of filters.
Positions are numbered starting from 0. If the specified position is equal to or greater
than the number of elements in the list, the filter is added at the end of the collection.
110
9 Classes (interfaces)
9.12.16 removeHostOnlyNetworkInterface
IProgress IHost::removeHostOnlyNetworkInterface(
[in] uuid id)
id Adapter GUID.
9.12.17 removeUSBDeviceFilter
void IHost::removeUSBDeviceFilter(
[in] unsigned long position)
Removes a USB device filter from the specified position in the list of filters.
Positions are numbered starting from 0. Specifying a position equal to or greater
than the number of elements in the list will produce an error.
9.13 IHostNetworkInterface
Represents one of host’s network interfaces. IP V6 address and network mask are
strings of 32 hexdecimal digits grouped by four. Groups are separated by colons. For
example, fe80:0000:0000:0000:021e:c2ff:fed2:b030.
9.13.1 Attributes
9.13.1.1 name (read-only)
wstring IHostNetworkInterface::name
111
9 Classes (interfaces)
9.13.1.2 id (read-only)
uuid IHostNetworkInterface::id
Returns the name of a virtual network the interface gets attached to.
112
9 Classes (interfaces)
9.13.2 dhcpRediscover
void IHostNetworkInterface::dhcpRediscover()
9.13.3 enableDynamicIpConfig
void IHostNetworkInterface::enableDynamicIpConfig()
9.13.4 enableStaticIpConfig
void IHostNetworkInterface::enableStaticIpConfig(
[in] wstring IPAddress,
[in] wstring networkMask)
IPAddress IP address.
networkMask network mask.
sets and enables the static IP V4 configuration for the given interface.
113
9 Classes (interfaces)
9.13.5 enableStaticIpConfigV6
void IHostNetworkInterface::enableStaticIpConfigV6(
[in] wstring IPV6Address,
[in] unsigned long IPV6NetworkMaskPrefixLength)
IPV6Address IP address.
IPV6NetworkMaskPrefixLength network mask.
sets and enables the static IP V6 configuration for the given interface.
9.14 IHostUSBDevice
The IHostUSBDevice interface represents a physical USB device attached to the host
computer.
Besides properties inherited from IUSBDevice, this interface adds the state property
that holds the current state of the USB device.
See also: IHost::USBDevices, IHost::USBDeviceFilters
9.14.1 Attributes
9.14.1.1 state (read-only)
USBDeviceState IHostUSBDevice::state
9.15 IHostUSBDeviceFilter
The IHostUSBDeviceFilter interface represents a global filter for a physical USB device
used by the host computer. Used indirectly in IHost::USBDeviceFilters[].
Using filters of this type, the host computer determines the initial state of the USB
device after it is physically attached to the host’s USB controller.
Note: The remote attribute is ignored by this type of filters, because it makes
sense only for machine USB filters.
9.15.1 Attributes
9.15.1.1 action (read/write)
USBDeviceFilterAction IHostUSBDeviceFilter::action
Action performed by the host when an attached USB device matches this filter.
114
9 Classes (interfaces)
9.16 IInternalMachineControl
9.16.1 adoptSavedState
void IInternalMachineControl::adoptSavedState(
[in] wstring savedStateFile)
9.16.2 autoCaptureUSBDevices
void IInternalMachineControl::autoCaptureUSBDevices()
Requests a capture all matching USB devices attached to the host. When the request
is completed, the VM process will get a IInternalSessionControl::onUSBDeviceAttach()
notification per every captured device.
9.16.3 beginPowerUp
void IInternalMachineControl::beginPowerUp(
[in] IProgress progress)
progress
Tells VBoxSVC that IConsole::powerUp() is under ways and gives it the progress ob-
ject that should be part of any pending IVirtualBox::openRemoteSession() operations.
The progress object may be called back to reflect an early cancelation, so some care
have to be taken with respect to any cancelation callbacks. The console object will call
endPowerUp() to signal the completion of the progress object.
9.16.4 beginSavingState
void IInternalMachineControl::beginSavingState(
[in] IProgress progress,
[out] wstring stateFilePath)
progress Progress object created by the VM process to wait until the state is saved.
stateFilePath File path the VM process must save the execution state to.
Called by the VM process to inform the server it wants to save the current state and
stop the VM execution.
115
9 Classes (interfaces)
9.16.5 beginTakingSnapshot
void IInternalMachineControl::beginTakingSnapshot(
[in] IConsole initiator,
[in] wstring name,
[in] wstring description,
[in] IProgress consoleProgress,
[in] boolean fTakingSnapshotOnline,
[out] wstring stateFilePath)
Called from the VM process to request from the server to perform the server-side
actions of creating a snapshot (creating differencing images and the snapshot object).
If this method fails, the following error codes may be reported:
9.16.6 captureUSBDevice
void IInternalMachineControl::captureUSBDevice(
[in] uuid id)
id
Requests a capture of the given host USB device. When the request is completed,
the VM process will get a IInternalSessionControl::onUSBDeviceAttach() notification.
116
9 Classes (interfaces)
9.16.7 deleteSnapshot
IProgress IInternalMachineControl::deleteSnapshot(
[in] IConsole initiator,
[in] uuid id,
[out] MachineState machineState)
9.16.8 detachAllUSBDevices
void IInternalMachineControl::detachAllUSBDevices(
[in] boolean done)
done
Notification that a VM that is being powered down. The done parameter indicates
whether which stage of the power down we’re at. When done = false the VM is
announcing its intentions, while when done = true the VM is reporting what it has
done.
Note: In the done = true case, the server must run its own filters and filters
of all VMs but this one on all detach devices as if they were just attached to
the host computer.
9.16.9 detachUSBDevice
void IInternalMachineControl::detachUSBDevice(
[in] uuid id,
[in] boolean done)
id
done
117
9 Classes (interfaces)
Note: In the done = true case, the server must run its own filters and filters
of all VMs but this one on the detached device as if it were just attached to
the host computer.
9.16.10 endPowerUp
void IInternalMachineControl::endPowerUp(
[in] long result)
result
Tells VBoxSVC that IConsole::powerUp() has completed. This method may query
status information from the progress object it received in beginPowerUp() and copy
it over to any in progress IVirtualBox::openRemoteSession() call in order to complete
that progress object.
9.16.11 endSavingState
void IInternalMachineControl::endSavingState(
[in] boolean success)
Called by the VM process to inform the server that saving the state previously re-
quested by #beginSavingState is either successfully finished or there was a failure.
If this method fails, the following error codes may be reported:
9.16.12 endTakingSnapshot
void IInternalMachineControl::endTakingSnapshot(
[in] boolean success)
Called by the VM process to inform the server that the snapshot previously requested
by #beginTakingSnapshot is either successfully taken or there was a failure.
118
9 Classes (interfaces)
9.16.13 finishOnlineMergeMedium
void IInternalMachineControl::finishOnlineMergeMedium(
[in] IMediumAttachment mediumAttachment,
[in] IMedium source,
[in] IMedium target,
[in] boolean mergeForward,
[in] IMedium parentForTarget,
[in] IMedium childrenToReparent[])
childrenToReparent For backward merges: list of media which need their parent
UUID updated.
9.16.14 getIPCId
wstring IInternalMachineControl::getIPCId()
9.16.15 lockMedia
void IInternalMachineControl::lockMedia()
Locks all media attached to the machine for writing and parents of attached differ-
encing media (if any) for reading. This operation is atomic so that if it fails no media
is actually locked.
This method is intended to be called when the machine is in Starting or Restoring
state. The locked media will be automatically unlocked when the machine is powered
off or crashed.
9.16.16 onSessionEnd
IProgress IInternalMachineControl::onSessionEnd(
[in] ISession session)
Triggered by the given session object when the session is about to close normally.
119
9 Classes (interfaces)
9.16.17 pullGuestProperties
void IInternalMachineControl::pullGuestProperties(
[out] wstring name[],
[out] wstring value[],
[out] unsigned long long timestamp[],
[out] wstring flags[])
9.16.18 pushGuestProperty
void IInternalMachineControl::pushGuestProperty(
[in] wstring name,
[in] wstring value,
[in] unsigned long long timestamp,
[in] wstring flags)
9.16.19 restoreSnapshot
IProgress IInternalMachineControl::restoreSnapshot(
[in] IConsole initiator,
[in] ISnapshot snapshot,
[out] MachineState machineState)
120
9 Classes (interfaces)
9.16.20 runUSBDeviceFilters
void IInternalMachineControl::runUSBDeviceFilters(
[in] IUSBDevice device,
[out] boolean matched,
[out] unsigned long maskedInterfaces)
device
matched
maskedInterfaces
Asks the server to run USB devices filters of the associated machine against the given
USB device and tell if there is a match.
Note: Intended to be used only for remote USB devices. Local ones don’t
require to call this method (this is done implicitly by the Host and USBProxy-
Service).
9.16.21 setRemoveSavedState
void IInternalMachineControl::setRemoveSavedState(
[in] boolean aRemove)
aRemove
Updates the flag whether saved state is removed on a machine state change from
Saved to PoweredOff.
9.16.22 unlockMedia
void IInternalMachineControl::unlockMedia()
9.16.23 updateState
void IInternalMachineControl::updateState(
[in] MachineState state)
state
121
9 Classes (interfaces)
Note: This operation will also update the settings file with the correct infor-
mation about the saved state file and delete this file from disk when appropri-
ate.
9.17 IInternalSessionControl
9.17.1 accessGuestProperty
void IInternalSessionControl::accessGuestProperty(
[in] wstring name,
[in] wstring value,
[in] wstring flags,
[in] boolean isSetter,
[out] wstring retValue,
[out] unsigned long long retTimestamp,
[out] wstring retFlags)
name
value
flags
isSetter
retValue
retTimestamp
retFlags
122
9 Classes (interfaces)
9.17.2 assignMachine
void IInternalSessionControl::assignMachine(
[in] IMachine machine)
machine
Assigns the machine object associated with this direct-type session or informs the
session that it will be a remote one (if machine == null).
If this method fails, the following error codes may be reported:
9.17.3 assignRemoteMachine
void IInternalSessionControl::assignRemoteMachine(
[in] IMachine machine,
[in] IConsole console)
machine
console
Assigns the machine and the (remote) console object associated with this remote-
type session.
If this method fails, the following error codes may be reported:
9.17.4 enumerateGuestProperties
void IInternalSessionControl::enumerateGuestProperties(
[in] wstring patterns,
[out] wstring key[],
[out] wstring value[],
[out] unsigned long long timestamp[],
[out] wstring flags[])
123
9 Classes (interfaces)
flags The flags of the properties returned. The array entries match the corresponding
entries in the key array.
Return a list of the guest properties matching a set of patterns along with their
values, time stamps and flags.
If this method fails, the following error codes may be reported:
9.17.5 getPID
unsigned long IInternalSessionControl::getPID()
9.17.6 getRemoteConsole
IConsole IInternalSessionControl::getRemoteConsole()
9.17.7 onCPUChange
void IInternalSessionControl::onCPUChange(
[in] unsigned long cpu,
[in] boolean add)
9.17.8 onMediumChange
void IInternalSessionControl::onMediumChange(
[in] IMediumAttachment mediumAttachment,
[in] boolean force)
mediumAttachment
124
9 Classes (interfaces)
force
Triggered when attached media of the associated virtual machine have changed.
If this method fails, the following error codes may be reported:
9.17.9 onNetworkAdapterChange
void IInternalSessionControl::onNetworkAdapterChange(
[in] INetworkAdapter networkAdapter,
[in] boolean changeAdapter)
networkAdapter
changeAdapter
Triggered when settings of a network adapter of the associated virtual machine have
changed.
If this method fails, the following error codes may be reported:
9.17.10 onParallelPortChange
void IInternalSessionControl::onParallelPortChange(
[in] IParallelPort parallelPort)
parallelPort
Triggered when settings of a parallel port of the associated virtual machine have
changed.
If this method fails, the following error codes may be reported:
125
9 Classes (interfaces)
9.17.11 onSerialPortChange
void IInternalSessionControl::onSerialPortChange(
[in] ISerialPort serialPort)
serialPort
Triggered when settings of a serial port of the associated virtual machine have
changed.
If this method fails, the following error codes may be reported:
9.17.12 onSharedFolderChange
void IInternalSessionControl::onSharedFolderChange(
[in] boolean global)
global
Triggered when a permanent (global or machine) shared folder has been created or
removed.
Note: We don’t pass shared folder parameters in this notification because the
order in which parallel notifications are delivered is not defined, therefore it
could happen that these parameters were outdated by the time of processing
this notification.
9.17.13 onShowWindow
void IInternalSessionControl::onShowWindow(
[in] boolean check,
[out] boolean canShow,
[out] unsigned long long winId)
check
canShow
winId
126
9 Classes (interfaces)
9.17.14 onStorageControllerChange
void IInternalSessionControl::onStorageControllerChange()
9.17.15 onUSBControllerChange
void IInternalSessionControl::onUSBControllerChange()
Triggered when settings of the USB controller object of the associated virtual ma-
chine have changed.
If this method fails, the following error codes may be reported:
• VBOX_E_INVALID_VM_STATE: Session state prevents operation.
• VBOX_E_INVALID_OBJECT_STATE: Session type prevents operation.
9.17.16 onUSBDeviceAttach
void IInternalSessionControl::onUSBDeviceAttach(
[in] IUSBDevice device,
[in] IVirtualBoxErrorInfo error,
[in] unsigned long maskedInterfaces)
device
error
maskedInterfaces
Triggered when a request to capture a USB device (as a result of matched USB
filters or direct call to IConsole::attachUSBDevice()) has completed. A nullerror
object means success, otherwise it describes a failure.
If this method fails, the following error codes may be reported:
• VBOX_E_INVALID_VM_STATE: Session state prevents operation.
• VBOX_E_INVALID_OBJECT_STATE: Session type prevents operation.
127
9 Classes (interfaces)
9.17.17 onUSBDeviceDetach
void IInternalSessionControl::onUSBDeviceDetach(
[in] uuid id,
[in] IVirtualBoxErrorInfo error)
id
error
Triggered when a request to release the USB device (as a result of machine termi-
nation or direct call to IConsole::detachUSBDevice()) has completed. A nullerror
object means success, otherwise it describes a failure.
If this method fails, the following error codes may be reported:
9.17.18 onVRDPServerChange
void IInternalSessionControl::onVRDPServerChange(
[in] boolean restart)
Triggered when settings of the VRDP server object of the associated virtual machine
have changed.
If this method fails, the following error codes may be reported:
9.17.19 onlineMergeMedium
void IInternalSessionControl::onlineMergeMedium(
[in] IMediumAttachment mediumAttachment,
[in] unsigned long sourceIdx,
[in] unsigned long targetIdx,
[in] IMedium source,
[in] IMedium target,
[in] boolean mergeForward,
[in] IMedium parentForTarget,
[in] IMedium childrenToReparent[],
[in] IProgress progress)
128
9 Classes (interfaces)
sourceIdx The index of the source image in the chain. Redundant, but drastically
reduces IPC.
targetIdx The index of the target image in the chain. Redundant, but drastically
reduces IPC.
source Merge source medium.
target Merge target medium.
mergeForward Merge direction.
parentForTarget For forward merges: new parent for target medium.
childrenToReparent For backward merges: list of media which need their parent
UUID updated.
progress Progress object for this operation.
Triggers online merging of a hard disk. Used internally when deleting a snapshot
while a VM referring to the same hard disk chain is running.
If this method fails, the following error codes may be reported:
• VBOX_E_INVALID_VM_STATE: Machine session is not open.
• VBOX_E_INVALID_OBJECT_STATE: Session type is not direct.
9.17.20 uninitialize
void IInternalSessionControl::uninitialize()
9.17.21 updateMachineState
void IInternalSessionControl::updateMachineState(
[in] MachineState aMachineState)
aMachineState
Updates the machine state in the VM process. Must be called only in certain cases
(see the method implementation).
If this method fails, the following error codes may be reported:
• VBOX_E_INVALID_VM_STATE: Session state prevents operation.
• VBOX_E_INVALID_OBJECT_STATE: Session type prevents operation.
129
9 Classes (interfaces)
9.18 IKeyboard
The IKeyboard interface represents the virtual machine’s keyboard. Used in ICon-
sole::keyboard.
Use this interface to send keystrokes or the Ctrl-Alt-Del sequence to the virtual ma-
chine.
9.18.1 putCAD
void IKeyboard::putCAD()
Sends the Ctrl-Alt-Del sequence to the keyboard. This function is nothing special, it
is just a convenience function calling putScancodes() with the proper scancodes.
If this method fails, the following error codes may be reported:
9.18.2 putScancode
void IKeyboard::putScancode(
[in] long scancode)
scancode
9.18.3 putScancodes
unsigned long IKeyboard::putScancodes(
[in] long scancodes[])
scancodes
130
9 Classes (interfaces)
9.19 ILocalOwner
The ILocalOwner interface allows to register local objects (created without COM
calls, but with new()). Once registered, calls to methods of such objects can be made
from remote COM processes. The main usecase is the event callback implementation
where API clients provide callback objects.
9.19.1 setLocalObject
void ILocalOwner::setLocalObject(
[in] $unknown object)
object Local object to forward requests to. If null, clears currently set local object.
9.20 IMachine
The IMachine interface represents a virtual machine, or guest, created in VirtualBox.
This interface is used in two contexts. First of all, a collection of objects implement-
ing this interface is stored in the IVirtualBox::machines[] attribute which lists all the
virtual machines that are currently registered with this VirtualBox installation. Also,
once a session has been opened for the given virtual machine (e.g. the virtual machine
is running), the machine object associated with the open session can be queried from
the session object; see ISession for details.
The main role of this interface is to expose the settings of the virtual machine and
provide methods to change various aspects of the virtual machine’s configuration. For
machine objects stored in the IVirtualBox::machines[] collection, all attributes are
read-only unless explicitly stated otherwise in individual attribute and method de-
scriptions. In order to change a machine setting, a session for this machine must be
opened using one of IVirtualBox::openSession(), IVirtualBox::openRemoteSession()
or IVirtualBox::openExistingSession() methods. After the session has been success-
fully opened, a mutable machine object needs to be queried from the session object
and then the desired settings changes can be applied to the returned object using
IMachine attributes and methods. See the ISession interface description for more in-
formation about sessions.
Note that IMachine does not provide methods to control virtual machine execution
(such as start the machine, or power it down) – these methods are grouped in a
separate interface called IConsole.
See also: ISession, IConsole
131
9 Classes (interfaces)
9.20.1 Attributes
9.20.1.1 parent (read-only)
IVirtualBox IMachine::parent
Note: In the current implementation, once this property returns true, the
machine will never become inaccessible later, even if its settings file cannot
be successfully read/written any more (at least, until the VirtualBox server is
restarted). This limitation may be removed in future releases.
132
9 Classes (interfaces)
If any of the above limitations are hit, saveSettings() will return an appropriate error
message explaining the exact reason and the changes you made to this machine will
not be saved.
133
9 Classes (interfaces)
9.20.1.6 id (read-only)
uuid IMachine::id
Note: This value may differ from the value returned by IGuest::OSTypeId if
Guest Additions are installed to the guest OS.
The UUID presented to the guest via memory tables, hardware and guest properties.
For most VMs this is the same as the id, but for VMs which have been cloned or tele-
ported it may be the same as the source VM. This latter is because the guest shouldn’t
notice that it was cloned or teleported.
This setting determines whether VirtualBox allows CPU hotplugging for this ma-
chine.
134
9 Classes (interfaces)
This setting determines whether VirtualBox allows page fusion for this machine (64
bits host only).
This setting determines whether VirtualBox allows this machine to make use of the
3D graphics support available on the host.
This setting determines whether VirtualBox allows this machine to make use of the
2D video acceleration support available on the host.
Note: Only effective on Windows XP and later guests with Guest Additions
installed.
135
9 Classes (interfaces)
Type of firmware (such as legacy BIOS or EFI), used for initial bootstrap in this VM.
Type of pointing HID (such as mouse or tablet) used in this VM. The default is typi-
cally “PS2Mouse” but can vary depending on the requirements of the guest operating
system.
Type of keyboard HID used in this VM. The default is typically “PS2Keyboard” but
can vary depending on the requirements of the guest operating system.
This attribute controls if High Precision Event Timer (HPET) is enabled in this VM.
Use this property if you want to provide guests with additional time source, or if guest
requires HPET to function correctly. Default is false.
Full path to the directory used to store snapshot data (differencing media and saved
state files) of this machine.
The initial value of this property is <path_to_settings_file>/<machine_uuid>.
Currently, it is an error to try to change this property on a machine that has snap-
shots (because this would require to move possibly large files to a different location).
A separate method will be available for this purpose later.
Note: Setting this property to null or to an empty string will restore the
initial value.
136
9 Classes (interfaces)
Note: When setting this property, the specified path can be absolute (full
path) or relative to the directory where the machine settings file is located.
When reading this property, a full path is always returned.
Note: The specified path may not exist, it will be created when necessary.
137
9 Classes (interfaces)
Whether the settings of this machine have been modified (but neither yet saved nor
discarded).
Note: For newly created unregistered machines, the value of this property is
always true until saveSettings() is called (no matter if any machine settings
have been changed after the creation or not). For opened machines the value
is set to false (and then follows to normal rules).
138
9 Classes (interfaces)
Time stamp of the last execution state change, in milliseconds since 1970-01-01
UTC.
Full path to the file that stores the execution state of the machine when it is in the
Saved state.
Note: When the machine is not in the Saved state, this attribute is an empty
string.
Full path to the folder that stores a set of rotated log files recorded during machine
execution. The most recent log file is named VBox.log, the previous log file is named
VBox.log.1 and so on (up to VBox.log.3 in the current version).
Current snapshot of this machine. This is null if the machine currently has no
snapshots. If it is not null, then it was set by one of Console::takeSnapshot, Con-
sole::deleteSnapshot or Console::restoreSnapshot, depending on which was called
last. See ISnapshot for details.
Number of snapshots taken on this machine. Zero means the machine doesn’t have
any snapshots.
139
9 Classes (interfaces)
Returns true if the current state of the machine is not identical to the state stored
in the current snapshot.
The current state is identical to the current snapshot only directly after one of the
following calls are made:
• IConsole::restoreSnapshot()
• IConsole::takeSnapshot() (issued on a “powered off” or “saved” machine, for
which settingsModified returns false)
• setCurrentSnapshot()
The current state remains identical until one of the following happens:
Note: For machines that don’t have snapshots, this property is always false.
Collection of shared folders for this machine (permanent shared folders). These
folders are shared automatically at machine startup and available only to the guest OS
installed within this machine.
New shared folders are added to the collection using createSharedFolder(). Existing
shared folders can be removed using removeSharedFolder().
Synchronization mode between the host OS clipboard and the guest OS clipboard.
140
9 Classes (interfaces)
When set to true, the virtual machine becomes a target teleporter the next time it is
powered on. This can only set to true when the VM is in the PoweredOff or Aborted
state.
The TCP port the target teleporter will listen for incoming teleportations on.
0 means the port is automatically selected upon power on. The actual value can be
read from this property while the machine is waiting for incoming teleportations.
The address the target teleporter will listen on. If set to an empty string, it will listen
on all addresses.
The password the to check for on the target teleporter. This is just a very basic
measure to prevent simple hacks and operators accidentally beaming a virtual machine
to the wrong place.
When set to true, the RTC device of the virtual machine will run in UTC time,
otherwise in local time. Especially Unix guests prefer the time in UTC.
141
9 Classes (interfaces)
When set to true, the builtin I/O cache of the virtual machine will be enabled.
9.20.2 addStorageController
IStorageController IMachine::addStorageController(
[in] wstring name,
[in] StorageBus connectionType)
name
connectionType
Adds a new storage controller (SCSI, SAS or SATA controller) to the machine and
returns it as an instance of IStorageController.
name identifies the controller for subsequent calls such as getStorageController-
ByName(), getStorageControllerByInstance(), removeStorageController(), attachDe-
vice() or mountMedium().
After the controller has been added, you can set its exact type by setting the IStor-
ageController::controllerType.
If this method fails, the following error codes may be reported:
142
9 Classes (interfaces)
9.20.3 attachDevice
void IMachine::attachDevice(
[in] wstring name,
[in] long controllerPort,
[in] long device,
[in] DeviceType type,
[in] uuid id)
controllerPort Port to attach the device to. For an IDE controller, 0 specifies the
primary controller and 1 specifies the secondary controller. For a SCSI controller,
this must range from 0 to 15; for a SATA controller, from 0 to 29; for an SAS
controller, from 0 to 7.
device Device slot in the given port to attach the device to. This is only relevant for
IDE controllers, for which 0 specifies the master device and 1 specifies the slave
device. For all other controller types, this must be 0.
type Device type of the attached device.
id UUID of the medium to mount. Zero UUID means do not mount any medium.
Attaches a device and optionally mounts a medium to the given storage controller
(IStorageController, identified by name), at the indicated port and device.
This method is intended for managing storage devices in general (it works for both
fixed and removable media). For storage devices supporting removable media (such
as DVDs and floppies), you can also use IMedium::mountMedium for changing the
media while the machine is running.
In a VM’s default configuration of virtual machines, the secondary master of the IDE
controller is used for a CD/DVD drive.
For fixed media such as hard disks, the given medium identifier cannot be a zero
UUID. It may be a zero UUID for removable media such as DVDs and floppies.
After calling this returns successfully, a new instance of IMediumAttachment will
appear in the machine’s list of medium attachments (mediumAttachments[]).
The specified device slot must not have a device attached to it, or this method will
fail.
See IMedium and IMediumAttachment for more information about attaching media.
Note: You cannot attach a device to a running machine. Also, you cannot
attach a device to a newly created machine until this machine’s settings are
saved to disk using saveSettings().
143
9 Classes (interfaces)
• E_INVALIDARG: SATA device, SATA port, IDE port or IDE slot out of range.
• VBOX_E_INVALID_OBJECT_STATE: Attempt to attach medium to an unregis-
tered virtual machine.
• VBOX_E_INVALID_VM_STATE: Invalid machine state.
• VBOX_E_OBJECT_IN_USE: Hard disk already attached to this or another virtual
machine.
9.20.4 canShowConsoleWindow
boolean IMachine::canShowConsoleWindow()
Returns true if the VM console process can activate the console window and bring
it to foreground on the desktop of the host PC.
Note: This method will fail if a session for this machine is not currently open.
9.20.5 createSharedFolder
void IMachine::createSharedFolder(
[in] wstring name,
[in] wstring hostPath,
[in] boolean writable)
Creates a new permanent shared folder by associating the given logical name with
the given host path, adds it to the collection of shared folders and starts sharing it.
Refer to the description of ISharedFolder to read more about logical names.
If this method fails, the following error codes may be reported:
144
9 Classes (interfaces)
9.20.6 deleteSettings
void IMachine::deleteSettings()
Deletes the settings file of this machine from disk. The machine must not be regis-
tered in order for this operation to succeed.
Note: settingsModified will return true after this method successfully re-
turns.
Note: The deleted machine settings file can be restored (saved again) by
calling saveSettings().
9.20.7 detachDevice
void IMachine::detachDevice(
[in] wstring name,
[in] long controllerPort,
[in] long device)
145
9 Classes (interfaces)
9.20.8 discardSettings
void IMachine::discardSettings()
Discards any changes to the machine settings made since the session has been
opened or since the last call to saveSettings() or discardSettings().
146
9 Classes (interfaces)
9.20.9 enumerateGuestProperties
void IMachine::enumerateGuestProperties(
[in] wstring patterns,
[out] wstring name[],
[out] wstring value[],
[out] unsigned long long timestamp[],
[out] wstring flags[])
patterns The patterns to match the properties against, separated by ’|’ characters. If
this is empty or null, all properties will match.
Return a list of the guest properties matching a set of patterns along with their
values, time stamps and flags.
9.20.10 export
IVirtualSystemDescription IMachine::export(
[in] IAppliance aAppliance)
Exports the machine to an OVF appliance. See IAppliance for the steps required to
export VirtualBox machines to OVF.
9.20.11 findSnapshot
ISnapshot IMachine::findSnapshot(
[in] wstring name)
147
9 Classes (interfaces)
9.20.12 getBootOrder
DeviceType IMachine::getBootOrder(
[in] unsigned long position)
position Position in the boot order (1 to the total number of devices the machine can
boot from, as returned by ISystemProperties::maxBootPosition).
Returns the device type that occupies the specified position in the boot order.
@todo [remove?] If the machine can have more than one device of the returned
type (such as hard disks), then a separate method should be used to retrieve the
individual device that occupies the given position.
If here are no devices at the given position, then Null is returned.
@todo getHardDiskBootOrder(), getNetworkBootOrder()
If this method fails, the following error codes may be reported:
9.20.13 getCPUIDLeaf
void IMachine::getCPUIDLeaf(
[in] unsigned long id,
[out] unsigned long valEax,
[out] unsigned long valEbx,
[out] unsigned long valEcx,
[out] unsigned long valEdx)
Returns the virtual CPU cpuid information for the specified leaf.
Currently supported index values for cpuid: Standard CPUID leafs: 0 - 0xA Extended
CPUID leafs: 0x80000000 - 0x8000000A
See the Intel and AMD programmer’s manuals for detailed information about the
cpuid instruction and its leafs.
If this method fails, the following error codes may be reported:
148
9 Classes (interfaces)
9.20.14 getCPUProperty
boolean IMachine::getCPUProperty(
[in] CPUPropertyType property)
9.20.15 getCPUStatus
boolean IMachine::getCPUStatus(
[in] unsigned long cpu)
9.20.16 getExtraData
wstring IMachine::getExtraData(
[in] wstring key)
9.20.17 getExtraDataKeys
wstring[] IMachine::getExtraDataKeys()
Returns an array representing the machine-specific extra data keys which currently
have values defined.
149
9 Classes (interfaces)
9.20.18 getGuestProperty
void IMachine::getGuestProperty(
[in] wstring name,
[out] wstring value,
[out] unsigned long long timestamp,
[out] wstring flags)
value The value of the property. If the property does not exist then this will be empty.
timestamp The time at which the property was last modified, as seen by the server
process.
flags Additional property parameters, passed as a comma-separated list of
“name=value” type entries.
9.20.19 getGuestPropertyTimestamp
unsigned long long IMachine::getGuestPropertyTimestamp(
[in] wstring property)
9.20.20 getGuestPropertyValue
wstring IMachine::getGuestPropertyValue(
[in] wstring property)
150
9 Classes (interfaces)
9.20.21 getHWVirtExProperty
boolean IMachine::getHWVirtExProperty(
[in] HWVirtExPropertyType property)
9.20.22 getMedium
IMedium IMachine::getMedium(
[in] wstring name,
[in] long controllerPort,
[in] long device)
9.20.23 getMediumAttachment
IMediumAttachment IMachine::getMediumAttachment(
[in] wstring name,
[in] long controllerPort,
[in] long device)
name
controllerPort
device
Returns a medium attachment which corresponds to the controller with the given
name, on the given port and device slot.
If this method fails, the following error codes may be reported:
• VBOX_E_OBJECT_NOT_FOUND: No attachment exists for the given con-
troller/port/device combination.
151
9 Classes (interfaces)
9.20.24 getMediumAttachmentsOfController
IMediumAttachment[] IMachine::getMediumAttachmentsOfController(
[in] wstring name)
name
Returns an array of medium attachments which are attached to the the controller
with the given name.
If this method fails, the following error codes may be reported:
9.20.25 getNetworkAdapter
INetworkAdapter IMachine::getNetworkAdapter(
[in] unsigned long slot)
slot
Returns the network adapter associated with the given slot. Slots are numbered se-
quentially, starting with zero. The total number of adapters per machine is defined by
the ISystemProperties::networkAdapterCount property, so the maximum slot number
is one less than that property’s value.
If this method fails, the following error codes may be reported:
9.20.26 getParallelPort
IParallelPort IMachine::getParallelPort(
[in] unsigned long slot)
slot
Returns the parallel port associated with the given slot. Slots are numbered sequen-
tially, starting with zero. The total number of parallel ports per machine is defined
by the ISystemProperties::parallelPortCount property, so the maximum slot number is
one less than that property’s value.
If this method fails, the following error codes may be reported:
152
9 Classes (interfaces)
9.20.27 getSerialPort
ISerialPort IMachine::getSerialPort(
[in] unsigned long slot)
slot
Returns the serial port associated with the given slot. Slots are numbered sequen-
tially, starting with zero. The total number of serial ports per machine is defined by
the ISystemProperties::serialPortCount property, so the maximum slot number is one
less than that property’s value.
If this method fails, the following error codes may be reported:
9.20.28 getSnapshot
ISnapshot IMachine::getSnapshot(
[in] uuid id)
Returns a snapshot of this machine with the given UUID. A null UUID can be used
to obtain the first snapshot taken on this machine. This is useful if you want to traverse
the whole tree of snapshots starting from the root.
If this method fails, the following error codes may be reported:
9.20.29 getStorageControllerByInstance
IStorageController IMachine::getStorageControllerByInstance(
[in] unsigned long instance)
instance
153
9 Classes (interfaces)
9.20.30 getStorageControllerByName
IStorageController IMachine::getStorageControllerByName(
[in] wstring name)
name
9.20.31 hotPlugCPU
void IMachine::hotPlugCPU(
[in] unsigned long cpu)
9.20.32 hotUnplugCPU
void IMachine::hotUnplugCPU(
[in] unsigned long cpu)
9.20.33 mountMedium
void IMachine::mountMedium(
[in] wstring name,
[in] long controllerPort,
[in] long device,
[in] uuid medium,
[in] boolean force)
medium UUID of the medium to attach. A zero UUID means unmount the currently
mounted medium.
154
9 Classes (interfaces)
Mounts a medium (IMedium, identified by the given UUID id) to the given storage
controller (IStorageController, identified by name), at the indicated port and device.
The device must already exist; see attachDevice() for how to attach a new device.
This method is intended only for managing removable media, where the device is
fixed but media is changeable at runtime (such as DVDs and floppies). It cannot be
used for fixed media such as hard disks.
The controllerPort and device parameters specify the device slot and have have
the same meaning as with attachDevice().
The specified device slot can have a medium mounted, which will be unmounted
first. Specifying a zero UUID (or an empty string) for medium does just an unmount.
See IMedium for more detailed information about attaching media.
If this method fails, the following error codes may be reported:
• E_INVALIDARG: SATA device, SATA port, IDE port or IDE slot out of range.
• VBOX_E_INVALID_OBJECT_STATE: Attempt to attach medium to an unregis-
tered virtual machine.
• VBOX_E_INVALID_VM_STATE: Invalid machine state.
• VBOX_E_OBJECT_IN_USE: Medium already attached to this or another virtual
machine.
9.20.34 passthroughDevice
void IMachine::passthroughDevice(
[in] wstring name,
[in] long controllerPort,
[in] long device,
[in] boolean passthrough)
Sets the passthrough mode of an existing DVD device. Changing the setting while
the VM is running is forbidden. The setting is only used if at VM start the device is
configured as a host DVD drive, in all other cases it is ignored. The device must already
exist; see attachDevice() for how to attach a new device.
The controllerPort and device parameters specify the device slot and have have
the same meaning as with attachDevice().
If this method fails, the following error codes may be reported:
155
9 Classes (interfaces)
• E_INVALIDARG: SATA device, SATA port, IDE port or IDE slot out of range.
• VBOX_E_INVALID_OBJECT_STATE: Attempt to modify an unregistered virtual
machine.
• VBOX_E_INVALID_VM_STATE: Invalid machine state.
9.20.35 queryLogFilename
wstring IMachine::queryLogFilename(
[in] unsigned long idx)
Queries for the VM log file name of an given index. Returns an empty string if a log
file with that index doesn’t exists.
9.20.36 querySavedScreenshotPNGSize
void IMachine::querySavedScreenshotPNGSize(
[in] unsigned long screenId,
[out] unsigned long size,
[out] unsigned long width,
[out] unsigned long height)
Returns size in bytes and dimensions of a saved PNG image of screenshot from saved
state.
9.20.37 querySavedThumbnailSize
void IMachine::querySavedThumbnailSize(
[in] unsigned long screenId,
[out] unsigned long size,
[out] unsigned long width,
[out] unsigned long height)
156
9 Classes (interfaces)
Returns size in bytes and dimensions in pixels of a saved thumbnail bitmap from
saved state.
9.20.38 readLog
octet[] IMachine::readLog(
[in] unsigned long idx,
[in] unsigned long long offset,
[in] unsigned long long size)
Reads the VM log file. The chunk size is limited, so even if you ask for a big piece
there might be less data returned.
9.20.39 readSavedScreenshotPNGToArray
octet[] IMachine::readSavedScreenshotPNGToArray(
[in] unsigned long screenId,
[out] unsigned long width,
[out] unsigned long height)
9.20.40 readSavedThumbnailToArray
octet[] IMachine::readSavedThumbnailToArray(
[in] unsigned long screenId,
[in] boolean BGR,
[out] unsigned long width,
[out] unsigned long height)
157
9 Classes (interfaces)
9.20.41 removeAllCPUIDLeaves
void IMachine::removeAllCPUIDLeaves()
9.20.42 removeCPUIDLeaf
void IMachine::removeCPUIDLeaf(
[in] unsigned long id)
9.20.43 removeSharedFolder
void IMachine::removeSharedFolder(
[in] wstring name)
9.20.44 removeStorageController
void IMachine::removeStorageController(
[in] wstring name)
name
Removes a storage controller from the machine.
If this method fails, the following error codes may be reported:
• VBOX_E_OBJECT_NOT_FOUND: A storage controller with given name doesn’t ex-
ist.
158
9 Classes (interfaces)
9.20.45 saveSettings
void IMachine::saveSettings()
Saves any changes to machine settings made since the session has been opened or
a new machine has been created, or since the last call to saveSettings() or discardSet-
tings(). For registered machines, new settings become visible to all other VirtualBox
clients after successful invocation of this method.
9.20.46 setBootOrder
void IMachine::setBootOrder(
[in] unsigned long position,
[in] DeviceType device)
position Position in the boot order (1 to the total number of devices the machine can
boot from, as returned by ISystemProperties::maxBootPosition).
device The type of the device used to boot at the given position.
Puts the given device to the specified position in the boot order.
To indicate that no device is associated with the given position, Null should be used.
@todo setHardDiskBootOrder(), setNetworkBootOrder()
If this method fails, the following error codes may be reported:
159
9 Classes (interfaces)
9.20.47 setCPUIDLeaf
void IMachine::setCPUIDLeaf(
[in] unsigned long id,
[in] unsigned long valEax,
[in] unsigned long valEbx,
[in] unsigned long valEcx,
[in] unsigned long valEdx)
Sets the virtual CPU cpuid information for the specified leaf. Note that these values
are not passed unmodified. VirtualBox clears features that it doesn’t support.
Currently supported index values for cpuid: Standard CPUID leafs: 0 - 0xA Extended
CPUID leafs: 0x80000000 - 0x8000000A
See the Intel and AMD programmer’s manuals for detailed information about the
cpuid instruction and its leafs.
Do not use this method unless you know exactly what you’re doing. Misuse can lead
to random crashes inside VMs.
If this method fails, the following error codes may be reported:
9.20.48 setCPUProperty
void IMachine::setCPUProperty(
[in] CPUPropertyType property,
[in] boolean value)
160
9 Classes (interfaces)
9.20.49 setCurrentSnapshot
void IMachine::setCurrentSnapshot(
[in] uuid id)
9.20.50 setExtraData
void IMachine::setExtraData(
[in] wstring key,
[in] wstring value)
Note: Before performing the actual data change, this method will ask all
registered callbacks using the IVirtualBoxCallback::onExtraDataCanChange()
notification for a permission. If one of the callbacks refuses the new value,
the change will not be performed.
Note: This method can be called outside the machine session and therefore
it’s a caller’s responsibility to handle possible race conditions when several
clients change the same key at the same time.
161
9 Classes (interfaces)
9.20.51 setGuestProperty
void IMachine::setGuestProperty(
[in] wstring property,
[in] wstring value,
[in] wstring flags)
9.20.52 setGuestPropertyValue
void IMachine::setGuestPropertyValue(
[in] wstring property,
[in] wstring value)
162
9 Classes (interfaces)
9.20.53 setHWVirtExProperty
void IMachine::setHWVirtExProperty(
[in] HWVirtExPropertyType property,
[in] boolean value)
Sets a new value for the specified hardware virtualization boolean property.
If this method fails, the following error codes may be reported:
9.20.54 showConsoleWindow
unsigned long long IMachine::showConsoleWindow()
Activates the console window and brings it to foreground on the desktop of the host
PC. Many modern window managers on many platforms implement some sort of focus
stealing prevention logic, so that it may be impossible to activate a window without
the help of the currently active application. In this case, this method will return a
non-zero identifier that represents the top-level window of the VM console process.
The caller, if it represents a currently active process, is responsible to use this identifier
(in a platform-dependent manner) to perform actual window activation.
Note: This method will fail if a session for this machine is not currently open.
9.21 IMachineDebugger
9.21.1 Attributes
9.21.1.1 singlestep (read/write)
boolean IMachineDebugger::singlestep
163
9 Classes (interfaces)
Flag indicating whether the VM is currently making use of CPU hardware virtualiza-
tion extensions.
Flag indicating whether the VM is currently making use of the nested paging CPU
hardware virtualization extension.
Flag indicating whether the VM is currently making use of the VPID VT-x extension.
164
9 Classes (interfaces)
Flag indicating whether the VM is currently making use of the Physical Address
Extension CPU feature.
The rate at which the virtual time runs expressed as a percentage. The accepted
range is 2% to 20000%.
9.21.1.12 VM (read-only)
unsigned long long IMachineDebugger::VM
Gets the VM handle. This is only for internal use while we carve the details of this
interface.
9.21.2 dumpStats
void IMachineDebugger::dumpStats(
[in] wstring pattern)
9.21.3 getStats
void IMachineDebugger::getStats(
[in] wstring pattern,
[in] boolean withDescriptions,
[out] wstring stats)
9.21.4 injectNMI
void IMachineDebugger::injectNMI()
165
9 Classes (interfaces)
9.21.5 resetStats
void IMachineDebugger::resetStats(
[in] wstring pattern)
Reset VM statistics.
9.22 IManagedObjectRef
Note: This interface is supported in the web service only, not in COM/XPCOM.
9.22.1 getInterfaceName
wstring IManagedObjectRef::getInterfaceName()
Returns the name of the interface that this managed object represents, for example,
“IMachine”, as a string.
9.22.2 release
void IManagedObjectRef::release()
Releases this managed object reference and frees the resources that were allocated
for it in the webservice server process. After calling this method, the identifier of the
reference can no longer be used.
166
9 Classes (interfaces)
9.23 IMedium
The IMedium interface represents virtual storage for a machine’s hard disks, CD/DVD
or floppy drives. It will typically represent a disk image on the host, for example a
VDI or VMDK file representing a virtual hard disk, or an ISO or RAW file representing
virtual removable media, but can also point to a network location (e.g. for iSCSI
targets).
Instances of IMedium are connected to virtual machines by way of medium attach-
ments (see IMediumAttachment), which link the storage medium to a particular device
slot of a storage controller of the virtual machine. In the VirtualBox API, virtual storage
is therefore always represented by the following chain of object links:
Existing media are opened using the following methods, depending on the media
type:
• IVirtualBox::openHardDisk()
• IVirtualBox::openDVDImage()
• IVirtualBox::openFloppyImage()
New hard disk media can be created with the VirtualBox API using the IVirtual-
Box::createHardDisk() method.
CD/DVD and floppy images (ISO and RAW files) are usually created outside
VirtualBox, e.g. by storing a copy of the real medium of the corresponding type in
a regular file.
Only for CD/DVDs and floppies, an IMedium instance can also represent a host
drive; in that case the id attribute contains the UUID of one of the drives in
IHost::DVDDrives[] or IHost::floppyDrives[].
Known media
167
9 Classes (interfaces)
When an existing medium is opened for the first time, it is automatically remem-
bered by the given VirtualBox installation or, in other words, becomes a known
medium. Known media are stored in the media registry transparently maintained by
VirtualBox and stored in settings files so that this registry is preserved when VirtualBox
is not running.
Newly created virtual media are remembered only when the associated storage unit
is actually created.
All known media can be enumerated using IVirtualBox::hardDisks[], IVirtual-
Box::DVDImages[] and IVirtualBox::floppyImages[] attributes. Individual media can
be quickly found by UUID using IVirtualBox::getHardDisk() and similar methods or by
location using IVirtualBox::findHardDisk() and similar methods.
Only known media can be attached to virtual machines.
Removing known media from the media registry is performed when the given
medium is closed using the close() method or when its associated storage unit is
deleted.
Accessibility checks
VirtualBox defers media accessibility checks until the refreshState() method is called
explicitly on a medium. This is done to make the VirtualBox object ready for serving
requests as fast as possible and let the end-user application decide if it needs to check
media accessibility right away or not.
As a result, when VirtualBox starts up (e.g. the VirtualBox object gets created for
the first time), all known media are in the “Inaccessible” state, but the value of the
lastAccessError attribute is an empty string because no actual accessibility check has
been made yet.
After calling refreshState(), a medium is considered accessible if its storage unit can
be read. In that case, the state attribute has a value of “Created”. If the storage
unit cannot be read (for example, because it is located on a disconnected network
resource, or was accidentally deleted outside VirtualBox), the medium is considered
inaccessible, which is indicated by the “Inaccessible” state. The exact reason why the
medium is inaccessible can be obtained by reading the lastAccessError attribute.
Medium types
There are four types of medium behavior (see MediumType): “normal”, “im-
mutable”, “writethrough” and “shareable”, represented by the type attribute. The type
of the medium defines how the medium is attached to a virtual machine and what
happens when a ISnapshot of the virtual machine with the attached medium is taken.
At the moment DVD and floppy media are always of type “writethrough”.
All media can be also divided in two groups: base media and differencing media. A
base medium contains all sectors of the medium data in its own storage and therefore
can be used independently. In contrast, a differencing mediun is a “delta” to some
other medium and contains only those sectors which differ from that other medium,
which is then called a parent. The differencing medium is said to be linked to that
parent. The parent may be itself a differencing medium, thus forming a chain of
linked media. The last element in that chain must always be a base medium. Note
that several differencing media may be linked to the same parent medium.
168
9 Classes (interfaces)
Differencing media can be distinguished from base media by querying the parent
attribute: base media do not have parents they would depend on, so the value of this
attribute is always null for them. Using this attribute, it is possible to walk up the
medium tree (from the child medium to its parent). It is also possible to walk down
the tree using the children[] attribute.
Note that the type of all differencing media is “normal”; all other values are mean-
ingless for them. Base media may be of any type.
Creating hard disks
New base hard disks are created using IVirtualBox::createHardDisk(). Existing hard
disks are opened using IVirtualBox::openHardDisk(). Differencing hard disks are usu-
ally implicitly created by VirtualBox when needed but may also be created explicitly
using createDiffStorage().
After the hard disk is successfully created (including the storage unit) or opened,
it becomes a known hard disk (remembered in the internal media registry).
Known hard disks can be attached to a virtual machine, accessed through IVirtu-
alBox::getHardDisk() and IVirtualBox::findHardDisk() methods or enumerated using
the IVirtualBox::hardDisks[] array (only for base hard disks).
The following methods, besides close(), automatically remove the hard disk from
the media registry:
• deleteStorage()
• mergeTo()
If the storage unit of the hard disk is a regular file in the host’s file system then the
rules stated in the description of the location attribute apply when setting its value. In
addition, a plain file name without any path may be given, in which case the default
hard disk folder will be prepended to it.
Automatic composition of the file name part
Another extension to the location attribute is that there is a possibility to cause
VirtualBox to compose a unique value for the file name part of the location using the
UUID of the hard disk. This applies only to hard disks in NotCreated state, e.g. before
the storage unit is created, and works as follows. You set the value of the location
attribute to a location specification which only contains the path specification but not
the file name part and ends with either a forward slash or a backslash character. In
response, VirtualBox will generate a new UUID for the hard disk and compose the file
name using the following pattern:
<path>/{<uuid>}.<ext>
where <path> is the supplied path specification, <uuid> is the newly generated
UUID and <ext> is the default extension for the storage format of this hard disk. After
that, you may call any of the methods that create a new hard disk storage unit and
they will use the generated UUID and file name.
Attaching Hard Disks
169
9 Classes (interfaces)
• Normal base hard disks that do not have children (i.e. differencing hard disks
linked to them) and that are not already attached to virtual machines in snap-
shots are attached directly. Otherwise, they are attached indirectly because
having dependent children or being part of the snapshot makes it impossible to
modify hard disk contents without breaking the integrity of the dependent party.
The readOnly attribute allows to quickly determine the kind of the attachment
for the given hard disk. Note that if a normal base hard disk is to be indirectly at-
tached to a virtual machine with snapshots then a special procedure called smart
attachment is performed (see below).
• Normal differencing hard disks are like normal base hard disks: they are at-
tached directly if they do not have children and are not attached to virtual ma-
chines in snapshots, and indirectly otherwise. Note that the smart attachment
procedure is never performed for differencing hard disks.
• Immutable hard disks are always attached indirectly because they are designed
to be non-writable. If an immutable hard disk is attached to a virtual machine
with snapshots then a special procedure called smart attachment is performed
(see below).
• Writethrough hard disks are always attached directly, also as designed. This
also means that writethrough hard disks cannot have other hard disks linked to
them at all.
• Shareable hard disks are always attached directly, also as designed. This also
means that shareable hard disks cannot have other hard disks linked to them at
all. They behave almost like writethrough hard disks, except that shareable hard
disks can be attached to several virtual machines which are running, allowing
concurrent accesses. You need special cluster software running in the virtual
machines to make use of such disks.
Note that the same hard disk, regardless of its type, may be attached to more than
one virtual machine at a time. In this case, the machine that is started first gains
170
9 Classes (interfaces)
exclusive access to the hard disk and attempts to start other machines having this hard
disk attached will fail until the first machine is powered down.
Detaching hard disks is performed in a deferred fashion. This means that the
given hard disk remains associated with the given machine after a successful IMa-
chine::detachDevice() call until IMachine::saveSettings() is called to save all changes
to machine settings to disk. This deferring is necessary to guarantee that the hard disk
configuration may be restored at any time by a call to IMachine::discardSettings()
before the settings are saved (committed).
Note that if IMachine::discardSettings() is called after indirectly attaching some
hard disks to the machine but before a call to IMachine::saveSettings() is made,
it will implicitly delete all differencing hard disks implicitly created by IMa-
chine::attachDevice() for these indirect attachments. Such implicitly created hard
disks will also be immediately deleted when detached explicitly using the IMa-
chine::detachDevice() call if it is made before IMachine::saveSettings(). This implicit
deletion is safe because newly created differencing hard disks do not contain any user
data.
However, keep in mind that detaching differencing hard disks that were implicitly
created by IMachine::attachDevice() before the last IMachine::saveSettings() call will
not implicitly delete them as they may already contain some data (for example, as a
result of virtual machine execution). If these hard disks are no more necessary, the
caller can always delete them explicitly using deleteStorage() after they are actually
de-associated from this machine by the IMachine::saveSettings() call.
Smart Attachment
When normal base or immutable hard disks are indirectly attached to a virtual ma-
chine then some additional steps are performed to make sure the virtual machine will
have the most recent “view” of the hard disk being attached. These steps include walk-
ing through the machine’s snapshots starting from the current one and going through
ancestors up to the first snapshot. Hard disks attached to the virtual machine in all
of the encountered snapshots are checked whether they are descendants of the given
normal base or immutable hard disk. The first found child (which is the differencing
hard disk) will be used instead of the normal base or immutable hard disk as a parent
for creating a new differencing hard disk that will be actually attached to the machine.
And only if no descendants are found or if the virtual machine does not have any snap-
shots then the normal base or immutable hard disk will be used itself as a parent for
this differencing hard disk.
It is easier to explain what smart attachment does using the following example:
NOT
171
9 Classes (interfaces)
...
CurState (D3->B.vdi)
The first column is the virtual machine configuration before the base hard disk
B.vdi is attached, the second column shows the machine after this hard disk is at-
tached. Constructs like D1->B.vdi and similar mean that the hard disk that is actually
attached to the machine is a differencing hard disk, D1.vdi, which is linked to (based
on) another hard disk, B.vdi.
As we can see from the example, the hard disk B.vdi was detached from the ma-
chine before taking Snapshot 4. Later, after Snapshot 4 was taken, the user decides to
attach B.vdi again. B.vdi has dependent child hard disks (D1.vdi, D2.vdi), there-
fore it cannot be attached directly and needs an indirect attachment (i.e. implicit
creation of a new differencing hard disk). Due to the smart attachment procedure,
the new differencing hard disk (D3.vdi) will be based on D2.vdi, not on B.vdi itself,
since D2.vdi is the most recent view of B.vdi existing for this snapshot branch of the
given virtual machine.
Note that if there is more than one descendant hard disk of the given base hard disk
found in a snapshot, and there is an exact device, channel and bus match, then this
exact match will be used. Otherwise, the youngest descendant will be picked up.
There is one more important aspect of the smart attachment procedure which
is not related to snapshots at all. Before walking through the snapshots as de-
scribed above, the backup copy of the current list of hard disk attachment is searched
for descendants. This backup copy is created when the hard disk configuration is
changed for the first time after the last IMachine::saveSettings() call and used by IMa-
chine::discardSettings() to undo the recent hard disk changes. When such a descen-
dant is found in this backup copy, it will be simply re-attached back, without creating
a new differencing hard disk for it. This optimization is necessary to make it possi-
ble to re-attach the base or immutable hard disk to a different bus, channel or device
slot without losing the contents of the differencing hard disk actually attached to the
machine in place of it.
9.23.1 Attributes
9.23.1.1 id (read-only)
uuid IMedium::id
UUID of the medium. For a newly created medium, this value is a randomly gener-
ated UUID.
172
9 Classes (interfaces)
Optional description of the medium. For a newly created medium the value of this
attribute is an empty string.
Medium types that don’t support this attribute will return E_NOTIMPL in attempt to
get or set this attribute’s value.
Note: For some storage types, reading this attribute may return an outdated
(last known) value when state is Inaccessible or LockedWrite because the
value of this attribute is stored within the storage unit itself. Also note that
changing the attribute value is not possible in such case, as well as when the
medium is the LockedRead state.
Returns the current medium state, which is the last state set by the accessibility
check performed by refreshState(). If that method has not yet been called on the
medium, the state is “Inaccessible”; as opposed to truly inaccessible media, the value
of lastAccessError will be an empty string in that case.
173
9 Classes (interfaces)
Physical size of the storage unit used to hold medium data (in bytes).
Note: For media whose state is Inaccessible, the value of this property is the
last known size. For NotCreated media, the returned value is zero.
174
9 Classes (interfaces)
The type of a newly created or opened medium is set to Normal, except for DVD and
floppy media, which have a type of Writethrough.
Parent of this medium (the medium this medium is directly based on).
Only differencing media have parents. For base (non-differencing) media, null is
returned.
Children of this medium (all differencing media directly based on this medium). A
null array is returned if this medium does not have any children.
175
9 Classes (interfaces)
Logical size of this medium (in megabytes), as reported to the guest OS running
inside the virtual machine this medium is attached to. The logical size is defined when
the medium is created and cannot be changed later.
Note: Reading this property on a differencing medium will return the size of
its base medium.
Note: For media whose state is state is Inaccessible, the value of this property
is the last known logical size. For :: media, the returned value is zero.
176
9 Classes (interfaces)
Whether this differencing medium will be automatically reset each time a virtual
machine it is attached to is powered up. This attribute is automatically set to true for
the last differencing image of an “immutable” medium (see MediumType).
See reset() for more information about resetting differencing media.
Text message that represents the result of the last accessibility check performed by
refreshState().
An empty string is returned if the last accessibility check was successful or has not
yet been called. As a result, if state is “Inaccessible” and this attribute is empty, then
refreshState() has yet to be called; this is the default value of media after VirtualBox
initialization. A non-empty string indicates a failure and should normally describe a
reason of the failure (for example, a file read error).
Note: The returned array will include a machine even if this medium is not
attached to that machine in the current state but attached to it in one of the
machine’s snapshots. See getSnapshotIds() for details.
9.23.2 cloneTo
IProgress IMedium::cloneTo(
[in] IMedium target,
[in] MediumVariant variant,
[in] IMedium parent)
177
9 Classes (interfaces)
Starts creating a clone of this medium in the format and at the location defined by
the target argument.
The target medium must be either in NotCreated state (i.e. must not have an existing
storage unit) or in Created state (i.e. created and not locked, and big enough to hold
the data or else the copy will be partial). Upon successful completion, the cloned
medium will contain exactly the same sector data as the medium being cloned, except
that in the first case a new UUID for the clone will be randomly generated, and in the
second case the UUID will remain unchanged.
The parent argument defines which medium will be the parent of the clone. Pass-
ing a null reference indicates that the clone will be a base image, i.e. completely
independent. It is possible to specify an arbitrary medium for this parameter, includ-
ing the parent of the medium which is being cloned. Even cloning to a child of the
source medium is possible. Note that when cloning to an existing image, the parent
irgument is ignored.
After the returned progress object reports that the operation is successfully com-
plete, the target medium gets remembered by this VirtualBox installation and may be
attached to virtual machines.
Note: This medium will be placed to LockedRead state for the duration of this
operation.
9.23.3 close
void IMedium::close()
178
9 Classes (interfaces)
9.23.4 compact
IProgress IMedium::compact()
Starts compacting of this medium. This means that the medium is transformed into
a possibly more compact storage representation. This potentially creates temporary
images, which can require a substantial amount of additional disk space.
This medium will be placed to LockedWrite state and all its parent media (if any)
will be placed to LockedRead state for the duration of this operation.
Please note that the results can be either returned straight away, or later as the result
of the background operation via the object returned via the progress parameter.
If this method fails, the following error codes may be reported:
9.23.5 createBaseStorage
IProgress IMedium::createBaseStorage(
[in] unsigned long long logicalSize,
[in] MediumVariant variant)
Starts creating a hard disk storage unit (fixed/dynamic, according to the variant
flags) in in the background. The previous storage unit created for this object, if any,
must first be deleted using deleteStorage(), otherwise the operation will fail.
Before the operation starts, the medium is placed in Creating state. If the create
operation fails, the medium will be placed back in NotCreated state.
After the returned progress object reports that the operation has successfully com-
pleted, the medium state will be set to Created, the medium will be remembered by
this VirtualBox installation and may be attached to virtual machines.
If this method fails, the following error codes may be reported:
179
9 Classes (interfaces)
9.23.6 createDiffStorage
IProgress IMedium::createDiffStorage(
[in] IMedium target,
[in] MediumVariant variant)
Starts creating an empty differencing storage unit based on this medium in the
format and at the location defined by the target argument.
The target medium must be in NotCreated state (i.e. must not have an existing
storage unit). Upon successful completion, this operation will set the type of the target
medium to Normal and create a storage unit necessary to represent the differencing
medium data in the given format (according to the storage format of the target object).
After the returned progress object reports that the operation is successfully com-
plete, the target medium gets remembered by this VirtualBox installation and may be
attached to virtual machines.
Note: The medium will be set to LockedRead state for the duration of this
operation.
9.23.7 deleteStorage
IProgress IMedium::deleteStorage()
180
9 Classes (interfaces)
Note: If the deletion operation fails, it is not guaranteed that the storage unit
still exists. You may check the state value to answer this question.
9.23.8 getProperties
wstring[] IMedium::getProperties(
[in] wstring names,
[out] wstring returnNames[])
9.23.9 getProperty
wstring IMedium::getProperty(
[in] wstring name)
Returns the value of the custom medium property with the given name.
The list of all properties supported by the given medium format can be obtained
with IMediumFormat::describeProperties().
Note that if this method returns an empty string in value, the requested property is
supported but currently not assigned any value.
If this method fails, the following error codes may be reported:
181
9 Classes (interfaces)
9.23.10 getSnapshotIds
uuid[] IMedium::getSnapshotIds(
[in] uuid machineId)
Returns an array of UUIDs of all snapshots of the given machine where this medium
is attached to.
If the medium is attached to the machine in the current state, then the first element
in the array will always be the ID of the queried machine (i.e. the value equal to the
machineId argument), followed by snapshot IDs (if any).
If the medium is not attached to the machine in the current state, then the array will
contain only snapshot IDs.
The returned array may be null if this medium is not attached to the given machine
at all, neither in the current state nor in one of the snapshots.
9.23.11 lockRead
MediumState IMedium::lockRead()
182
9 Classes (interfaces)
The medium locked for reading must be unlocked using the unlockRead() method.
Calls to lockRead() can be nested and must be followed by the same number of paired
unlockRead() calls.
This method sets the medium state (see state) to “LockedRead” on success. The
medium’s previous state must be one of “Created”, “Inaccessible” or “LockedRead”.
Locking an inaccessible medium is not an error; this method performs a logical lock
that prevents modifications of this medium through the VirtualBox API, not a physical
file-system lock of the underlying storage unit.
This method returns the current state of the medium before the operation.
If this method fails, the following error codes may be reported:
9.23.12 lockWrite
MediumState IMedium::lockWrite()
183
9 Classes (interfaces)
9.23.13 mergeTo
IProgress IMedium::mergeTo(
[in] IMedium target)
Starts merging the contents of this medium and all intermediate differencing media
in the chain to the given target medium.
The target medium must be either a descendant of this medium or its ancestor
(otherwise this method will immediately return a failure). It follows that there are two
logical directions of the merge operation: from ancestor to descendant (forward merge)
and from descendant to ancestor (backward merge). Let us consider the following
medium chain:
Base <- Diff_1 <- Diff_2
Here, calling this method on the Base medium object with Diff_2 as an argument
will be a forward merge; calling it on Diff_2 with Base as an argument will be a
backward merge. Note that in both cases the contents of the resulting medium will be
the same, the only difference is the medium object that takes the result of the merge
operation. In case of the forward merge in the above example, the result will be
written to Diff_2; in case of the backward merge, the result will be written to Base.
In other words, the result of the operation is always stored in the target medium.
Upon successful operation completion, the storage units of all media in the chain
between this (source) medium and the target medium, including the source medium
itself, will be automatically deleted and the relevant medium objects (including this
medium) will become uninitialized. This means that any attempt to call any of their
methods or attributes will fail with the "Object not ready" (E_ACCESSDENIED) er-
ror. Applied to the above example, the forward merge of Base to Diff_2 will delete
and uninitialize both Base and Diff_1 media. Note that Diff_2 in this case will
become a base medium itself since it will no longer be based on any other medium.
Considering the above, all of the following conditions must be met in order for the
merge operation to succeed:
• Neither this (source) medium nor any intermediate differencing medium in the
chain between it and the target medium is attached to any virtual machine.
• Neither the source medium nor the target medium is an Immutable medium.
• The part of the medium tree from the source medium to the target medium is a
linear chain, i.e. all medium in this chain have exactly one child which is the next
medium in this chain. The only exception from this rule is the target medium in
the forward merge operation; it is allowed to have any number of child media
184
9 Classes (interfaces)
because the merge operation will not change its logical contents (as it is seen by
the guest OS or by children).
• None of the involved media are in LockedRead or LockedWrite state.
Note: This (source) medium and all intermediates will be placed to Deleting
state and the target medium will be placed to LockedWrite state and for the
duration of this operation.
9.23.14 refreshState
MediumState IMedium::refreshState()
9.23.15 reset
IProgress IMedium::reset()
185
9 Classes (interfaces)
9.23.16 resize
IProgress IMedium::resize(
[in] unsigned long long logicalSize)
Starts resizing this medium. This means that the nominal size of the medium is set
to the new value. Both increasing and decreasing the size is possible, and there are
no safety checks, since VirtualBox does not make any assumptions about the medium
contents.
Resizing usually needs additional disk space, and possibly also some temporary disk
space. Note that resize does not create a full temporary copy of the medium, so the
additional disk space requirement is usually much lower than using the clone opera-
tion.
This medium will be placed to LockedWrite state for the duration of this operation.
Please note that the results can be either returned straight away, or later as the result
of the background operation via the object returned via the progress parameter.
If this method fails, the following error codes may be reported:
9.23.17 setProperties
void IMedium::setProperties(
[in] wstring names[],
[in] wstring values[])
186
9 Classes (interfaces)
The list of all properties supported by the given medium format can be obtained
with IMediumFormat::describeProperties().
Note that setting the property value to null or an empty string is equivalent to
deleting the existing value. A default value (if it is defined for this property) will be
used by the format backend in this case.
9.23.18 setProperty
void IMedium::setProperty(
[in] wstring name,
[in] wstring value)
Sets the value of the custom medium property with the given name.
The list of all properties supported by the given medium format can be obtained
with IMediumFormat::describeProperties().
Note that setting the property value to null or an empty string is equivalent to
deleting the existing value. A default value (if it is defined for this property) will be
used by the format backend in this case.
If this method fails, the following error codes may be reported:
9.23.19 unlockRead
MediumState IMedium::unlockRead()
9.23.20 unlockWrite
MediumState IMedium::unlockWrite()
187
9 Classes (interfaces)
9.24 IMediumAttachment
Note: With the web service, this interface is mapped to a structure. Attributes
that return this interface will not return an object, but a complete structure
containing the attributes listed below as structure members.
9.24.1 Attributes
9.24.1.1 medium (read-only)
IMedium IMediumAttachment::medium
Medium object associated with this attachment; it can be null for removable de-
vices.
Name of the storage controller of this attachment; this refers to one of the controllers
in IMachine::storageControllers[] by name.
188
9 Classes (interfaces)
Device slot number of this attachment. See IMachine::attachDevice() for the mean-
ing of this value for the different controller types.
9.25 IMediumFormat
The IMediumFormat interface represents a medium format.
Each medium format has an associated backend which is used to handle media
stored in this format. This interface provides information about the properties of the
associated backend.
Each medium format is identified by a string represented by the id attribute. This
string is used in calls like IVirtualBox::createHardDisk() to specify the desired format.
The list of all supported medium formats can be obtained using ISystemProper-
ties::mediaFormats.
See also: IMedium
9.25.1 Attributes
9.25.1.1 id (read-only)
wstring IMediumFormat::id
"VDI"
"vdi"
"VdI"
189
9 Classes (interfaces)
9.25.2 describeProperties
void IMediumFormat::describeProperties(
[out] wstring names[],
[out] wstring description[],
[out] DataType types[],
[out] unsigned long flags[],
[out] wstring defaults[])
190
9 Classes (interfaces)
9.26 IMouse
The IMouse interface represents the virtual machine’s mouse. Used in ICon-
sole::mouse.
Through this interface, the virtual machine’s virtual mouse can be controlled.
9.26.1 Attributes
9.26.1.1 absoluteSupported (read-only)
boolean IMouse::absoluteSupported
Whether the guest OS can currently switch to drawing it’s own mouse cursor on
demand.
191
9 Classes (interfaces)
9.26.2 putMouseEvent
void IMouse::putMouseEvent(
[in] long dx,
[in] long dy,
[in] long dz,
[in] long dw,
[in] long buttonState)
dx Amount of pixels the mouse should move to the right. Negative values move the
mouse to the left.
dy Amount of pixels the mouse should move downwards. Negative values move the
mouse upwards.
dz Amount of mouse wheel moves. Positive values describe clockwise wheel rotations,
negative values describe counterclockwise rotations.
Initiates a mouse event using relative pointer movements along x and y axis.
If this method fails, the following error codes may be reported:
9.26.3 putMouseEventAbsolute
void IMouse::putMouseEventAbsolute(
[in] long x,
[in] long y,
[in] long dz,
[in] long dw,
[in] long buttonState)
dz Amount of mouse wheel moves. Positive values describe clockwise wheel rotations,
negative values describe counterclockwise rotations.
192
9 Classes (interfaces)
Positions the mouse pointer using absolute x and y coordinates. These coordinates
are expressed in pixels and start from [1,1] which corresponds to the top left corner
of the virtual display.
Note: This method will have effect only if absolute mouse positioning is sup-
ported by the guest OS.
9.27 INATEngine
Interface for managing a NAT engine which is used with a virtual machine. This allows
for changing NAT behavior such as port-forwarding rules. This interface is used in the
INetworkAdapter::natDriver attribute.
9.27.1 Attributes
9.27.1.1 network (read/write)
wstring INATEngine::network
The network attribute of the NAT engine (the same value is used with built-in DHCP
server to fill corresponding fields of DHCP leases).
193
9 Classes (interfaces)
TFTP prefix attribute which is used with the built-in DHCP server to fill the corre-
sponding fields of DHCP leases.
TFTP boot file attribute which is used with the built-in DHCP server to fill the corre-
sponding fields of DHCP leases.
TFTP server attribute which is used with the built-in DHCP server to fill the corre-
sponding fields of DHCP leases.
Whether the DHCP server should pass the DNS domain used by the host.
Whether the DHCP server (and the DNS traffic by NAT) should pass the address of
the DNS proxy and process traffic using DNS servers registered on the host.
Whether the DHCP server (and the DNS traffic by NAT) should pass the address of
the DNS proxy and process traffic using the host resolver mechanism.
194
9 Classes (interfaces)
9.27.2 addRedirect
void INATEngine::addRedirect(
[in] wstring name,
[in] NATProtocol proto,
[in] wstring hostIp,
[in] unsigned short hostPort,
[in] wstring guestIp,
[in] unsigned short guestPort)
name The name of the rule. An empty name is acceptable, in which case the NAT
engine auto-generates one using the other parameters.
proto Protocol handled with the rule.
hostIp IP of the host interface to which the rule should apply. An empty ip address
is acceptable, in which case the NAT engine binds the handling socket to any
interface.
hostPort The port number to listen on.
guestIp The IP address of the guest which the NAT engine will forward matching
packets to. An empty IP address is acceptable, in which case the NAT engine will
forward packets to the first DHCP lease (x.x.x.15).
guestPort The port number to forward.
9.27.3 getNetworkSettings
void INATEngine::getNetworkSettings(
[out] unsigned long mtu,
[out] unsigned long sockSnd,
[out] unsigned long sockRcv,
[out] unsigned long TcpWndSnd,
[out] unsigned long TcpWndRcv)
mtu
sockSnd
sockRcv
195
9 Classes (interfaces)
TcpWndSnd
TcpWndRcv
9.27.4 removeRedirect
void INATEngine::removeRedirect(
[in] wstring name)
9.27.5 setNetworkSettings
void INATEngine::setNetworkSettings(
[in] unsigned long mtu,
[in] unsigned long sockSnd,
[in] unsigned long sockRcv,
[in] unsigned long TcpWndSnd,
[in] unsigned long TcpWndRcv)
9.28 INetworkAdapter
Represents a virtual network adapter that is attached to a virtual machine. Each virtual
machine has a fixed number of network adapter slots with one instance of this attached
to each of them. Call IMachine::getNetworkAdapter() to get the network adapter that
is attached to a given slot in a given machine.
Each network adapter can be in one of five attachment modes, which are rep-
resented by the NetworkAttachmentType enumeration; see the attachmentType at-
tribute.
196
9 Classes (interfaces)
9.28.1 Attributes
9.28.1.1 adapterType (read/write)
NetworkAdapterType INetworkAdapter::adapterType
Type of the virtual network adapter. Depending on this value, VirtualBox will pro-
vide a different virtual network hardware to the guest.
Slot number this adapter is plugged into. Corresponds to the value you pass to
IMachine::getNetworkAdapter() to obtain this instance.
Flag whether the network adapter is present in the guest system. If disabled, the
virtual guest hardware will not contain this network adapter. Can only be changed
when the VM is not running.
197
9 Classes (interfaces)
Flag whether the adapter reports the cable as connected or not. It can be used to
report offline situations to a VM.
Flag whether network traffic from/to the network card should be traced. Can only
be toggled when the VM is turned off.
Filename where a network trace will be stored. If not set, VBox-pid.pcap will be
used.
Points to the NAT engine which handles the network address translation for this
interface. This is active only when the interface actually uses NAT (see attachToNAT()).
198
9 Classes (interfaces)
Network boot priority of the adapter. Priority 1 is highest. If not set, the priority is
considered to be at the lowest possible setting.
9.28.2 attachToBridgedInterface
void INetworkAdapter::attachToBridgedInterface()
9.28.3 attachToHostOnlyInterface
void INetworkAdapter::attachToHostOnlyInterface()
9.28.4 attachToInternalNetwork
void INetworkAdapter::attachToInternalNetwork()
9.28.5 attachToNAT
void INetworkAdapter::attachToNAT()
Attach the network adapter to the Network Address Translation (NAT) interface.
9.28.6 attachToVDE
void INetworkAdapter::attachToVDE()
9.28.7 detach
void INetworkAdapter::detach()
199
9 Classes (interfaces)
9.29 IParallelPort
The IParallelPort interface represents the virtual parallel port device.
The virtual parallel port device acts like an ordinary parallel port inside the virtual
machine. This device communicates to the real parallel port hardware using the name
of the parallel device on the host computer specified in the #path attribute.
Each virtual parallel port device is assigned a base I/O address and an IRQ number
that will be reported to the guest operating system and used to operate the given
parallel port from within the virtual machine.
See also: IMachine::getParallelPort
9.29.1 Attributes
9.29.1.1 slot (read-only)
unsigned long IParallelPort::slot
Slot number this parallel port is plugged into. Corresponds to the value you pass to
IMachine::getParallelPort() to obtain this instance.
Flag whether the parallel port is enabled. If disabled, the parallel port will not be
reported to the guest OS.
Host parallel device name. If this parallel port is enabled, setting a null or an empty
string as this attribute’s value will result into an error.
200
9 Classes (interfaces)
9.30 IPerformanceCollector
The IPerformanceCollector interface represents a service that collects and stores per-
formance metrics data.
Performance metrics are associated with objects of interfaces like IHost and IMa-
chine. Each object has a distinct set of performance metrics. The set can be obtained
with getMetrics().
Metric data is collected at the specified intervals and is retained internally. The
interval and the number of retained samples can be set with setupMetrics(). Both
metric data and collection settings are not persistent, they are discarded as soon as
VBoxSVC process terminates. Moreover, metric settings and data associated with a
particular VM only exist while VM is running. They disappear as soon as VM shuts
down. It is not possible to set up metrics for machines that are powered off. One
needs to start VM first, then set up metric collection parameters.
Metrics are organized hierarchically, with each level separated by a slash (/) char-
acter. Generally, the scheme for metric names is like this:
Category/Metric[/SubMetric][:aggregation]
“Category/Metric” together form the base metric name. A base metric is the smallest
unit for which a sampling interval and the number of retained samples can be set. Only
base metrics can be enabled and disabled. All sub-metrics are collected when their
base metric is collected. Collected values for any set of sub-metrics can be queried
with queryMetricsData().
For example “CPU/Load/User:avg” metric name stands for the “CPU” category,
“Load” metric, “User” submetric, “average” aggregate. An aggregate function is com-
puted over all retained data. Valid aggregate functions are:
• avg – average
• min – minimum
• max – maximum
• CPU/Load
• CPU/MHz
• RAM/Usage
The general sequence for collecting and retrieving the metrics is:
201
9 Classes (interfaces)
• Allocate and populate an array with references to objects the metrics will be
collected for. Use references to IHost and IMachine objects.
• Allocate and populate an array with base metric names the data will be collected
for.
• Call setupMetrics(). From now on the metric data will be collected and stored.
• Wait for the data to get collected.
• Allocate and populate an array with references to objects the metric values will
be queried for. You can re-use the object array used for setting base metrics.
• Allocate and populate an array with metric names the data will be collected for.
Note that metric names differ from base metric names.
• Call queryMetricsData(). The data that have been collected so far are returned.
Note that the values are still retained internally and data collection continues.
• Java: bindings/webservice/java/jax-ws/samples/metrictest.java
• Python: bindings/xpcom/python/sample/shellcommon.py
9.30.1 Attributes
9.30.1.1 metricNames (read-only)
wstring IPerformanceCollector::metricNames[]
9.30.2 disableMetrics
IPerformanceMetric[] IPerformanceCollector::disableMetrics(
[in] wstring metricNames[],
[in] $unknown objects[])
metricNames Metric name filter. Comma-separated list of metrics with wildcard sup-
port.
objects Set of objects to disable metrics for.
202
9 Classes (interfaces)
Note: Null or empty metric name array means all metrics. Null or empty
object array means all existing objects. If metric name array contains a single
element and object array contains many, the single metric name array element
is applied to each object array element to form metric/object pairs.
9.30.3 enableMetrics
IPerformanceMetric[] IPerformanceCollector::enableMetrics(
[in] wstring metricNames[],
[in] $unknown objects[])
metricNames Metric name filter. Comma-separated list of metrics with wildcard sup-
port.
Note: Null or empty metric name array means all metrics. Null or empty
object array means all existing objects. If metric name array contains a single
element and object array contains many, the single metric name array element
is applied to each object array element to form metric/object pairs.
9.30.4 getMetrics
IPerformanceMetric[] IPerformanceCollector::getMetrics(
[in] wstring metricNames[],
[in] $unknown objects[])
Note: Null metrics array means all metrics. Null object array means all
existing objects.
203
9 Classes (interfaces)
9.30.5 queryMetricsData
long[] IPerformanceCollector::queryMetricsData(
[in] wstring metricNames[],
[in] $unknown objects[],
[out] wstring returnMetricNames[],
[out] $unknown returnObjects[],
[out] wstring returnUnits[],
[out] unsigned long returnScales[],
[out] unsigned long returnSequenceNumbers[],
[out] unsigned long returnDataIndices[],
[out] unsigned long returnDataLengths[])
metricNames Metric name filter. Comma-separated list of metrics with wildcard sup-
port.
objects Set of objects to query metrics for.
204
9 Classes (interfaces)
Note: Null or empty metric name array means all metrics. Null or empty
object array means all existing objects. If metric name array contains a single
element and object array contains many, the single metric name array element
is applied to each object array element to form metric/object pairs.
Note: Data collection continues behind the scenes after call to @c queryMet-
ricsData. The return data can be seen as the snapshot of the current state at
the time of queryMetricsData call. The internally kept metric values are not
cleared by the call. This makes possible querying different subsets of metrics
or aggregates with subsequent calls. If periodic querying is needed it is highly
suggested to query the values with interval*count period to avoid confu-
sion. This way a completely new set of data values will be provided by each
query.
9.30.6 setupMetrics
IPerformanceMetric[] IPerformanceCollector::setupMetrics(
[in] wstring metricNames[],
[in] $unknown objects[],
[in] unsigned long period,
[in] unsigned long count)
metricNames Metric name filter. Comma-separated list of metrics with wildcard sup-
port.
Sets parameters of specified base metrics for a set of objects. Returns an array of
IPerformanceMetric describing the metrics have been affected.
Note: Null or empty metric name array means all metrics. Null or empty
object array means all existing objects. If metric name array contains a single
element and object array contains many, the single metric name array element
is applied to each object array element to form metric/object pairs.
205
9 Classes (interfaces)
9.31 IPerformanceMetric
The IPerformanceMetric interface represents parameters of the given performance
metric.
9.31.1 Attributes
9.31.1.1 metricName (read-only)
wstring IPerformanceMetric::metricName
Number of recent samples retained by the performance collector for this metric.
When the collected sample count exceeds this number, older samples are discarded.
Unit of measurement.
206
9 Classes (interfaces)
9.32 IProgress
The IProgress interface is used to track and control asynchronous tasks within
VirtualBox.
An instance of this is returned every time VirtualBox starts an asynchronous task (in
other words, a separate thread) which continues to run after a method call returns. For
example, IConsole::saveState(), which saves the state of a running virtual machine,
can take a long time to complete. To be able to display a progress bar, a user interface
such as the VirtualBox graphical user interface can use the IProgress object returned
by that method.
Note that IProgress is a “read-only” interface in the sense that only the VirtualBox
internals behind the Main API can create and manipulate progress objects, whereas
client code can only use the IProgress object to monitor a task’s progress and, if can-
celable is true, cancel the task by calling cancel().
A task represented by IProgress consists of either one or several sub-operations that
run sequentially, one by one (see operation and operationCount). Every operation is
identified by a number (starting from 0) and has a separate description.
You can find the individual percentage of completion of the current operation in
operationPercent and the percentage of completion of the task as a whole in percent.
Similarly, you can wait for the completion of a particular operation via waitForOp-
erationCompletion() or for the completion of the whole task via waitForCompletion().
9.32.1 Attributes
9.32.1.1 id (read-only)
uuid IProgress::id
ID of the task.
207
9 Classes (interfaces)
Current progress value of the task as a whole, in percent. This value depends on
how many operations are already complete. Returns 100 if completed is true.
Estimated remaining time until the task completes, in seconds. Returns 0 once the
task has completed; returns -1 if the remaining time cannot be computed, in particular
if the current progress is 0.
Even if a value is returned, the estimate will be unreliable for low progress values.
It will become more reliable as the task progresses; it is not recommended to display
an ETA before at least 20% of a task have completed.
Extended information about the unsuccessful result of the progress operation. May
be null if no extended information is available. Valid only if completed is true and
resultCode indicates a failure.
208
9 Classes (interfaces)
Number of sub-operations this task is divided into. Every task consists of at least
one suboperation.
When non-zero, this specifies the number of milliseconds after which the operation
will automatically be canceled. This can only be set on cancelable objects.
9.32.2 cancel
void IProgress::cancel()
209
9 Classes (interfaces)
9.32.3 setCurrentOperationProgress
void IProgress::setCurrentOperationProgress(
[in] unsigned long percent)
percent
9.32.4 setNextOperation
void IProgress::setNextOperation(
[in] wstring nextOperationDescription,
[in] unsigned long nextOperationsWeight)
nextOperationDescription
nextOperationsWeight
9.32.5 waitForCompletion
void IProgress::waitForCompletion(
[in] long timeout)
Waits until the task is done (including all sub-operations) with a given timeout in
milliseconds; specify -1 for an indefinite wait.
If this method fails, the following error codes may be reported:
9.32.6 waitForOperationCompletion
void IProgress::waitForOperationCompletion(
[in] unsigned long operation,
[in] long timeout)
operation Number of the operation to wait for. Must be less than operationCount.
timeout Maximum time in milliseconds to wait or -1 to wait indefinitely.
Waits until the given operation is done with a given timeout in milliseconds; specify
-1 for an indefinite wait.
If this method fails, the following error codes may be reported:
210
9 Classes (interfaces)
9.33 IRemoteDisplayInfo
Note: With the web service, this interface is mapped to a structure. Attributes
that return this interface will not return an object, but a complete structure
containing the attributes listed below as structure members.
Contains information about the remote display (VRDP) capabilities and status. This
is used in the IConsole::remoteDisplayInfo attribute.
9.33.1 Attributes
9.33.1.1 active (read-only)
boolean IRemoteDisplayInfo::active
VRDP server port number. If this property is equal to 0, then the VRDP server failed
to start, usually because there are no free TCP ports to bind to. If this property is equal
to -1, then the VRDP server has not yet been started.
When the last connection was established, in milliseconds since 1970-01-01 UTC.
When the last connection was terminated or the current time, if connection is still
active, in milliseconds since 1970-01-01 UTC.
211
9 Classes (interfaces)
How many bytes were sent in last or current, if still active, connection.
How many bytes were received in last or current, if still active, connection.
212
9 Classes (interfaces)
Public key exchange method used when connection was established. Values: 0 -
RDP4 public key exchange scheme. 1 - X509 certificates were sent to client.
9.34 ISerialPort
The ISerialPort interface represents the virtual serial port device.
The virtual serial port device acts like an ordinary serial port inside the virtual ma-
chine. This device communicates to the real serial port hardware in one of two modes:
host pipe or host device.
In host pipe mode, the #path attribute specifies the path to the pipe on the host
computer that represents a serial port. The #server attribute determines if this pipe
is created by the virtual machine process at machine startup or it must already exist
before starting machine execution.
In host device mode, the #path attribute specifies the name of the serial port device
on the host computer.
There is also a third communication mode: the disconnected mode. In this mode,
the guest OS running inside the virtual machine will be able to detect the serial port,
but all port write operations will be discarded and all port read operations will return
no data.
See also: IMachine::getSerialPort
9.34.1 Attributes
9.34.1.1 slot (read-only)
unsigned long ISerialPort::slot
Slot number this serial port is plugged into. Corresponds to the value you pass to
IMachine::getSerialPort() to obtain this instance.
Flag whether the serial port is enabled. If disabled, the serial port will not be re-
ported to the guest OS.
213
9 Classes (interfaces)
Note: Changing this attribute may fail if the conditions for path are not met.
Flag whether this serial port acts as a server (creates a new pipe on the host) or
as a client (uses the existing pipe). This attribute is used only when hostMode is
PortMode_HostPipe.
Path to the serial port’s pipe on the host when hostMode is PortMode_HostPipe, or
the host serial device name when hostMode is PortMode_HostDevice. For both cases,
setting a null or empty string as the attribute’s value is an error. Otherwise, the value
of this property is ignored.
9.35 ISession
The ISession interface represents a serialization primitive for virtual machines.
With VirtualBox, every time one wishes to manipulate a virtual machine (e.g.
change its settings or start execution), a session object is required. Such an object
must be passed to one of the session methods that open the given session, which then
initiates the machine manipulation.
214
9 Classes (interfaces)
Note: Unless you are trying to write a new VirtualBox front-end that
performs direct machine execution (like the VirtualBox or VBoxSDL front-
ends), don’t call IConsole::powerUp() in a direct session opened by IVirtual-
Box::openSession() and use this session only to change virtual machine set-
tings. If you simply want to start virtual machine execution using one of the
existing front-ends (for example the VirtualBox GUI or headless server), sim-
ply use IVirtualBox::openRemoteSession(); these front-ends will power up the
machine automatically for you.
215
9 Classes (interfaces)
9.35.1 Attributes
9.35.1.1 state (read-only)
SessionState ISession::state
Type of this session. The value of this attribute is valid only if the session is currently
open (i.e. its #state is SessionType_SessionOpen), otherwise an error will be returned.
9.35.2 close
void ISession::close()
216
9 Classes (interfaces)
Note: Do not expect the session state (state to return to “Closed” immediately
after you invoke ISession::close(), particularly if you have started a remote
session to execute the VM in a new process. The session state will automat-
ically return to “Closed” once the VM is no longer executing, which can of
course take a very long time.
9.36 ISharedFolder
Note: With the web service, this interface is mapped to a structure. Attributes
that return this interface will not return an object, but a complete structure
containing the attributes listed below as structure members.
The ISharedFolder interface represents a folder in the host computer’s file system
accessible from the guest OS running inside a virtual machine using an associated
logical name.
There are three types of shared folders:
Logical names of shared folders must be unique within the given scope (global,
permanent or transient). However, they do not need to be unique across scopes. In
this case, the definition of the shared folder in a more specific scope takes precedence
over definitions in all other scopes. The order of precedence is (more specific to more
general):
1. Transient definitions
2. Permanent definitions
3. Global definitions
217
9 Classes (interfaces)
For example, if MyMachine has a shared folder named C_DRIVE (that points
to C:\\), then creating a transient shared folder named C_DRIVE (that points to
C:\\\\WINDOWS) will change the definition of C_DRIVE in the guest OS so that
\\\\VBOXSVR\\C_DRIVE will give access to C:\\WINDOWS instead of C:\\ on the host
PC. Removing the transient shared folder C_DRIVE will restore the previous (perma-
nent) definition of C_DRIVE that points to C:\\ if it still exists.
Note that permanent and transient shared folders of different machines are in differ-
ent name spaces, so they don’t overlap and don’t need to have unique logical names.
Note: Global shared folders are not implemented in the current version of the
product.
9.36.1 Attributes
9.36.1.1 name (read-only)
wstring ISharedFolder::name
Whether the folder defined by the host path is currently accessible or not. For ex-
ample, the folder can be unaccessible if it is placed on the network share that is not
available by the time this property is read.
218
9 Classes (interfaces)
Text message that represents the result of the last accessibility check.
Accessibility checks are performed each time the accessible attribute is read. An
empty string is returned if the last accessibility check was successful. A non-empty
string indicates a failure and should normally describe a reason of the failure (for
example, a file read error).
9.37 ISnapshot
The ISnapshot interface represents a snapshot of the virtual machine.
Together with the differencing media that are created when a snapshot is taken, a
machine can be brought back to the exact state it was in when the snapshot was taken.
The ISnapshot interface has no methods, only attributes; snapshots are controlled
through methods of the IConsole interface which also manage the media associated
with the snapshot. The following operations exist:
• IConsole::takeSnapshot(): creates a new snapshot by creating new, empty dif-
ferencing images for the machine’s media and saving the VM settings and (if the
VM is running) the current VM state in the snapshot.
The differencing images will then receive all data written to the machine’s me-
dia, while their parent (base) images remain unmodified after the snapshot has
been taken (see IMedium for details about differencing images). This simplifies
restoring a machine to the state of a snapshot: only the differencing images need
to be deleted.
The current machine state is not changed by taking a snapshot. If the machine
is running, it will resume execution after the snapshot has been taken.
• IConsole::restoreSnapshot(): this goes back to a previous snapshot. This resets
the machine’s state to that of the previous snapshot by deleting the differencing
image of each of the machine’s media and setting the machine’s settings and
state to the state that was saved in the snapshot (if any).
This destroys the machine’s current state.
• IConsole::deleteSnapshot(): deletes a snapshot without affecting the current
machine state.
This does not change the machine, but instead frees the resources allocated when
the snapshot was taken: the settings and machine state is deleted (if any), and
the snapshot’s differencing image for each of the machine’s media gets merged
with its parent image.
Neither the current machine state nor other snapshots are affected by this oper-
ation, except that parent media will be modified to contain the disk data associ-
ated with the snapshot being deleted.
219
9 Classes (interfaces)
Each snapshot contains the settings of the virtual machine (hardware configuration
etc.). In addition, if the machine was running when the snapshot was taken (IMa-
chine::state is Running), the current VM state is saved in the snapshot (similarly to
what happens when a VM’s state is saved). The snapshot is then said to be online
because when restoring it, the VM will be running.
If the machine is saved (Saved), the snapshot receives a copy of the execution state
file (IMachine::stateFilePath).
Otherwise, if the machine was not running (PoweredOff or Aborted), the snapshot
is offline; it then contains a so-called “zero execution state”, representing a machine
that is powered off.
Snapshot branches and the “current” snapshot
Snapshots can be chained, whereby every next snapshot is based on the previous
one. This chaining is related to medium branching (see the IMedium description) in
that every time a new snapshot is created, a new differencing medium is implicitly
created for all normal media attached to the machine.
Each virtual machine has a “current snapshot”, identified by IMachine::currentSnapshot.
Presently, this is always set to the last snapshot in the chain. In a future version of
VirtualBox, it will be possible to reset a machine’s current state to that of an ear-
lier snapshot without deleting the current state so that it will be possible to create
alternative snapshot paths in a snapshot tree.
In the current implementation, multiple snapshot branches within one vir-
tual machine are not allowed. Every machine has a single branch, and ICon-
sole::takeSnapshot() operation adds a new snapshot to the top of that branch.
9.37.1 Attributes
9.37.1.1 id (read-only)
uuid ISnapshot::id
220
9 Classes (interfaces)
Virtual machine this snapshot is taken on. This object stores all settings the machine
had when taking this snapshot.
Note: The returned machine object is immutable, i.e. no any settings can be
changed.
Parent snapshot (a snapshot this one is based on), or null if the snapshot has no
parent (i.e. is the first snapshot).
9.38 IStorageController
Represents a storage controller that is attached to a virtual machine (IMachine). Just
as drives (hard disks, DVDs, FDs) are attached to storage controllers in a real computer,
virtual drives (represented by IMediumAttachment) are attached to virtual storage
controllers, represented by this interface.
221
9 Classes (interfaces)
9.38.1 Attributes
9.38.1.1 name (read-only)
wstring IStorageController::name
The number of currently usable ports on the controller. The minimum and maximum
number of ports for one controller are stored in minPortCount and maxPortCount.
222
9 Classes (interfaces)
The bus type of the storage controller (IDE, SATA, SCSI, SAS or Floppy).
The exact variant of storage controller hardware presented to the guest. Depending
on this value, VirtualBox will provide a different virtual storage controller hardware
to the guest. For SATA, SAS and floppy controllers, only one variant is available, but
for IDE and SCSI, there are several.
For SCSI controllers, the default type is LsiLogic.
If true, the storage controller emulation will use a dedicated I/O thread, enable the
host I/O caches and use synchronous file APIs on the host. This was the only option in
the API before VirtualBox 3.2 and is still the default for IDE controllers.
If false, the host I/O cache will be disabled for image files attached to this storage
controller. Instead, the storage controller emulation will use asynchronous I/O APIs on
the host. This makes it possible to turn off the host I/O caches because the emulation
can handle unaligned access to the file. This should be used on OS X and Linux hosts
if a high I/O load is expected or many virtual machines are running at the same time
to prevent I/O cache related hangs. This option new with the API of VirtualBox 3.2
and is now the default for non-IDE storage controllers.
9.38.2 getIDEEmulationPort
long IStorageController::getIDEEmulationPort(
[in] long devicePosition)
devicePosition
Gets the corresponding port number which is emulated as an IDE device. Works
only with SATA controllers.
If this method fails, the following error codes may be reported:
223
9 Classes (interfaces)
9.38.3 setIDEEmulationPort
void IStorageController::setIDEEmulationPort(
[in] long devicePosition,
[in] long portNumber)
devicePosition
portNumber
Sets the port number which is emulated as an IDE device. Works only with SATA
controllers.
If this method fails, the following error codes may be reported:
9.39 ISystemProperties
The ISystemProperties interface represents global properties of the given VirtualBox
installation.
These properties define limits and default values for various attributes and parame-
ters. Most of the properties are read-only, but some can be changed by a user.
9.39.1 Attributes
9.39.1.1 minGuestRAM (read-only)
unsigned long ISystemProperties::minGuestRAM
224
9 Classes (interfaces)
225
9 Classes (interfaces)
Maximum device position in the boot order. This value corresponds to the total
number of devices a machine can boot from, to make it possible to include all possible
devices to the boot list. See also: IMachine::setBootOrder()
Full path to the default directory used to create new or open existing machines when
a settings file name contains no path.
The initial value of this property is <VirtualBox_home>/Machines.
Note: Setting this property to null or an empty string will restore the initial
value.
Note: When settings this property, the specified path can be absolute (full
path) or relative to the VirtualBox home directory. When reading this prop-
erty, a full path is always returned.
Note: The specified path may not exist, it will be created when necessary.
Full path to the default directory used to create new or open existing virtual disks.
This path is used when the storage unit of a hard disk is a regular file in the host’s
file system and only a file name that contains no path is given.
The initial value of this property is <VirtualBox_home>/HardDisks.
Note: Setting this property to null or empty string will restore the initial
value.
226
9 Classes (interfaces)
Note: When settings this property, the specified path can be relative to the
VirtualBox home directory or absolute. When reading this property, a full
path is always returned.
Note: The specified path may not exist, it will be created when necessary.
"VDI"
"vdi"
"VdI"
227
9 Classes (interfaces)
Note: Setting this property to null or empty string will restore the initial
value.
Issue a warning if the free disk space is below (or in some disk intensive operation
is expected to go below) the given size in Megabytes.
Issue a warning if the free disk space is below (or in some disk intensive operation
is expected to go below) the given percentage.
Issue an error if the free disk space is below (or in some disk intensive operation is
expected to go below) the given size in Megabytes.
Issue an error if the free disk space is below (or in some disk intensive operation is
expected to go below) the given percentage.
Library that provides authentication for VRDP clients. The library is used if a virtual
machine’s authentication type is set to “external” in the VM RemoteDisplay configura-
tion.
The system library extension (“.DLL” or “.so”) must be omitted. A full path can be
specified; if not, then the library must reside on the system’s default library path.
The default value of this property is "VRDPAuth". There is a library of that name in
one of the default VirtualBox library directories.
For details about VirtualBox authentication libraries and how to implement them,
please refer to the VirtualBox manual.
228
9 Classes (interfaces)
Note: Setting this property to null or empty string will restore the initial
value.
Library that provides authentication for webservice clients. The library is used if
a virtual machine’s authentication type is set to “external” in the VM RemoteDisplay
configuration and will be called from within the IWebsessionManager::logon() imple-
mentation.
As opposed to remoteDisplayAuthLibrary, there is no per-VM setting for this, as the
webservice is a global resource (if it is running). Only for this setting (for the web-
service), setting this value to a literal "null" string disables authentication, meaning
that IWebsessionManager::logon() will always succeed, no matter what user name and
password are supplied.
The initial value of this property is "VRDPAuth", meaning that the webservice will
use the same authentication library that is used by default for VBoxVRDP (again, see
remoteDisplayAuthLibrary). The format and calling convention of authentication li-
braries is the same for the webservice as it is for VBoxVRDP.
Note: Setting this property to null or empty string will restore the initial
value.
This value specifies how many old release log files are kept.
This value hold the default audio driver for the current system.
9.39.2 getDeviceTypesForStorageBus
DeviceType[] ISystemProperties::getDeviceTypesForStorageBus(
[in] StorageBus bus)
229
9 Classes (interfaces)
9.39.3 getMaxDevicesPerPortForStorageBus
unsigned long ISystemProperties::getMaxDevicesPerPortForStorageBus(
[in] StorageBus bus)
9.39.4 getMaxInstancesOfStorageBus
unsigned long ISystemProperties::getMaxInstancesOfStorageBus(
[in] StorageBus bus)
9.39.5 getMaxPortCountForStorageBus
unsigned long ISystemProperties::getMaxPortCountForStorageBus(
[in] StorageBus bus)
9.39.6 getMinPortCountForStorageBus
unsigned long ISystemProperties::getMinPortCountForStorageBus(
[in] StorageBus bus)
9.40 IUSBController
9.40.1 Attributes
9.40.1.1 enabled (read/write)
boolean IUSBController::enabled
Flag whether the USB controller is present in the guest system. If disabled, the
virtual guest hardware will not contain any USB controller. Can only be changed
when the VM is powered off.
230
9 Classes (interfaces)
Flag whether the USB EHCI controller is present in the guest system. If disabled, the
virtual guest hardware will not contain a USB EHCI controller. Can only be changed
when the VM is powered off.
USB standard version which the controller implements. This is a BCD which means
that the major version is in the high byte and minor version is in the low byte.
9.40.2 createDeviceFilter
IUSBDeviceFilter IUSBController::createDeviceFilter(
[in] wstring name)
231
9 Classes (interfaces)
9.40.3 insertDeviceFilter
void IUSBController::insertDeviceFilter(
[in] unsigned long position,
[in] IUSBDeviceFilter filter)
Note: Duplicates are not allowed, so an attempt to insert a filter that is al-
ready in the collection, will return an error.
9.40.4 removeDeviceFilter
IUSBDeviceFilter IUSBController::removeDeviceFilter(
[in] unsigned long position)
9.41 IUSBDevice
The IUSBDevice interface represents a virtual USB device attached to the virtual ma-
chine.
A collection of objects implementing this interface is stored in the ICon-
sole::USBDevices[] attribute which lists all USB devices attached to a running virtual
machine’s USB controller.
232
9 Classes (interfaces)
9.41.1 Attributes
9.41.1.1 id (read-only)
uuid IUSBDevice::id
Unique USB device ID. This ID is built from #vendorId, #productId, #revision and
#serialNumber.
Vendor ID.
Product ID.
Product revision number. This is a packed BCD represented as unsigned short. The
high byte is the integer part and the low byte is the decimal.
Manufacturer string.
Product string.
233
9 Classes (interfaces)
The major USB version of the host USB port the device is physically connected to
- 1 or 2. For devices not connected to anything this will have the same value as the
version attribute.
9.42 IUSBDeviceFilter
The IUSBDeviceFilter interface represents an USB device filter used to perform actions
on a group of USB devices.
This type of filters is used by running virtual machines to automatically capture
selected USB devices once they are physically attached to the host computer.
A USB device is matched to the given device filter if and only if all attributes of the
device match the corresponding attributes of the filter (that is, attributes are joined
together using the logical AND operation). On the other hand, all together, filters in
the list of filters carry the semantics of the logical OR operation. So if it is desirable to
create a match like “this vendor id OR this product id”, one needs to create two filters
and specify “any match” (see below) for unused attributes.
All filter attributes used for matching are strings. Each string is an expression repre-
senting a set of values of the corresponding device attribute, that will match the given
filter. Currently, the following filtering expressions are supported:
234
9 Classes (interfaces)
• Interval filters. Used to specify valid intervals for integer device attributes (Ven-
dor ID, Product ID and Revision). The format of the string is:
int:((m)|([m]-[n]))(,(m)|([m]-[n]))*
where m and n are integer numbers, either in octal (starting from 0), hexadecimal
(starting from 0x) or decimal (otherwise) form, so that m < n. If m is omitted
before a dash (-), the minimum possible integer is assumed; if n is omitted after
a dash, the maximum possible integer is assumed.
• Boolean filters. Used to specify acceptable values for boolean device attributes.
The format of the string is:
true|false|yes|no|0|1
• Exact match. Used to specify a single value for the given device attribute. Any
string that doesn’t start with int: represents the exact match. String device at-
tributes are compared to this string including case of symbols. Integer attributes
are first converted to a string (see individual filter attributes) and then compared
ignoring case.
• Any match. Any value of the corresponding device attribute will match the given
filter. An empty or null string is used to construct this type of filtering expres-
sions.
Note: On the Windows host platform, interval filters are not currently avail-
able. Also all string filter attributes (manufacturer, product, serialNumber)
are ignored, so they behave as any match no matter what string expression is
specified.
9.42.1 Attributes
9.42.1.1 name (read/write)
wstring IUSBDeviceFilter::name
Visible name for this filter. This name is used to visually distinguish one filter from
another, so it can neither be null nor an empty string.
235
9 Classes (interfaces)
Vendor ID filter. The string representation for the exact matching has the form XXXX,
where X is the hex digit (including leading zeroes).
Product ID filter. The string representation for the exact matching has the form XXXX,
where X is the hex digit (including leading zeroes).
Product revision number filter. The string representation for the exact matching has
the form IIFF, where I is the decimal digit of the integer part of the revision, and F is
the decimal digit of its fractional part (including leading and trailing zeros). Note that
for interval filters, it’s best to use the hexadecimal form, because the revision is stored
as a 16 bit packed BCD value; so the expression int:0x0100-0x0199 will match any
revision from 1.0 to 1.99.
Manufacturer filter.
Product filter.
236
9 Classes (interfaces)
Note: This filter makes sense only for machine USB filters, i.e. it is ignored
by IHostUSBDeviceFilter objects.
This is an advanced option for hiding one or more USB interfaces from the guest.
The value is a bit mask where the bits that are set means the corresponding USB
interface should be hidden, masked off if you like. This feature only works on Linux
hosts.
9.43 IVFSExplorer
The VFSExplorer interface unifies access to different file system types. This includes
local file systems as well remote file systems like S3. For a list of supported types see
VFSType. An instance of this is returned by IAppliance::createVFSExplorer().
9.43.1 Attributes
9.43.1.1 path (read-only)
wstring IVFSExplorer::path
9.43.2 cd
IProgress IVFSExplorer::cd(
[in] wstring aDir)
237
9 Classes (interfaces)
9.43.3 cdUp
IProgress IVFSExplorer::cdUp()
9.43.4 entryList
void IVFSExplorer::entryList(
[out] wstring aNames[],
[out] unsigned long aTypes[])
Returns a list of files/directories after a call to update(). The user is responsible for
keeping this internal list up do date.
9.43.5 exists
wstring[] IVFSExplorer::exists(
[in] wstring aNames[])
Checks if the given file list exists in the current directory level.
9.43.6 remove
IProgress IVFSExplorer::remove(
[in] wstring aNames[])
9.43.7 update
IProgress IVFSExplorer::update()
Updates the internal list of files/directories from the current directory level. Use
entryList() to get the full list after a call to this method.
238
9 Classes (interfaces)
9.44 IVRDPServer
9.44.1 Attributes
9.44.1.1 enabled (read/write)
boolean IVRDPServer::enabled
VRDP server port numbers. The server will try to bind to one of free ports from the
list.
Note: This is a string of comma separated TCP port numbers or port number
ranges. Example 5000,5010-5012,5015
Flag whether multiple simultaneous connections to the VM are permitted. Note that
this will be replaced by a more powerful mechanism in the future.
239
9 Classes (interfaces)
Flag whether the existing connection must be dropped and a new connection must
be established by the VRDP server, when a new client connects in single connection
mode.
9.45 IVirtualBox
The IVirtualBox interface represents the main interface exposed by the product that
provides virtual machine management.
An instance of IVirtualBox is required for the product to do anything useful. Even
though the interface does not expose this, internally, IVirtualBox is implemented as
a singleton and actually lives in the process of the VirtualBox server (VBoxSVC.exe).
This makes sure that IVirtualBox can track the state of all virtual machines on a par-
ticular host, regardless of which frontend started them.
To enumerate all the virtual machines on the host, use the machines[] attribute.
9.45.1 Attributes
9.45.1.1 version (read-only)
wstring IVirtualBox::version
A string representing the version number of the product. The format is 3 integer
numbers divided by dots (e.g. 1.0.1). The last number represents the build number
and will frequently change.
240
9 Classes (interfaces)
Full path to the directory where the global settings file, VirtualBox.xml, is stored.
In this version of VirtualBox, the value of this property is always <user_dir>/.VirtualBox
(where <user_dir> is the path to the user directory, as determined by the host OS),
and cannot be changed.
This path is also used as the base to resolve relative paths in places where relative
paths are allowed (unless otherwise expressly indicated).
Full name of the global settings file. The value of this property corresponds to the
value of homeFolder plus /VirtualBox.xml.
241
9 Classes (interfaces)
Collection of global shared folders. Global shared folders are available to all virtual
machines.
New shared folders are added to the collection using createSharedFolder(). Existing
shared folders can be removed using removeSharedFolder().
Note: In the current version of the product, global shared folders are not
implemented and therefore this collection is always empty.
242
9 Classes (interfaces)
9.45.2 checkFirmwarePresent
boolean IVirtualBox::checkFirmwarePresent(
[in] FirmwareType firmwareType,
[in] wstring version,
[out] wstring url,
[out] wstring file)
Check if this VirtualBox installation has a firmware of the given type available, either
system-wide or per-user. Optionally, this may return a hint where this firmware can be
downloaded from.
9.45.3 createAppliance
IAppliance IVirtualBox::createAppliance()
Creates a new appliance object, which represents an appliance in the Open Vir-
tual Machine Format (OVF). This can then be used to import an OVF appliance into
VirtualBox or to export machines as an OVF appliance; see the documentation for
IAppliance for details.
9.45.4 createDHCPServer
IDHCPServer IVirtualBox::createDHCPServer(
[in] wstring name)
Creates a dhcp server settings to be used for the given internal network name
If this method fails, the following error codes may be reported:
243
9 Classes (interfaces)
9.45.5 createHardDisk
IMedium IVirtualBox::createHardDisk(
[in] wstring format,
[in] wstring location)
format Identifier of the storage format to use for the new medium.
location Location of the storage unit for the new medium.
Creates a new base medium object that will use the given storage format and loca-
tion for medium data.
Note that the actual storage unit is not created by this method. In order to do it, and
before you are able to attach the created medium to virtual machines, you must call
one of the following methods to allocate a format-specific storage unit at the specified
location:
• IMedium::createBaseStorage()
• IMedium::createDiffStorage()
Some medium attributes, such as IMedium::id, may remain uninitialized until the
medium storage unit is successfully created by one of the above methods.
After the storage unit is successfully created, the medium gets remembered by this
VirtualBox installation and will be accessible through getHardDisk() and findHard-
Disk() methods. Remembered base medium are also returned as part of the hard-
Disks[] array. See IMedium for more details.
The list of all storage formats supported by this VirtualBox installation can
be obtained using ISystemProperties::mediumFormats[]. If the format attribute
is empty or null then the default storage format specified by ISystemProper-
ties::defaultHardDiskFormat will be used for creating a storage unit of the medium.
Note that the format of the location string is storage format specific. See
IMedium::location, IMedium and ISystemProperties::defaultHardDiskFolder for more
details.
If this method fails, the following error codes may be reported:
• VBOX_E_OBJECT_NOT_FOUND: format identifier is invalid. See ISystemProper-
ties::mediumFormats[].
• VBOX_E_FILE_ERROR: location is a not valid file name (for file-based formats
only).
9.45.6 createLegacyMachine
IMachine IVirtualBox::createLegacyMachine(
[in] wstring name,
[in] wstring osTypeId,
[in] wstring settingsFile,
[in] uuid id)
244
9 Classes (interfaces)
Creates a new virtual machine in “legacy” mode, using the specified settings file to
store machine settings.
As opposed to machines created by createMachine(), the settings file of the machine
created in “legacy” mode is not automatically renamed when the machine name is
changed – it will always remain the same as specified in this method call.
The specified settings file name can be absolute (full path) or relative to the
VirtualBox home directory. If the file name doesn’t contain an extension, the default
extension (.xml) will be appended.
Note that the configuration of the newly created machine is not saved to disk (and
therefore no settings file is created) until IMachine::saveSettings() is called. If the
specified settings file already exists, this method will fail with ::.
See createMachine() for more information.
@deprecated This method may be removed later. Use createMachine() instead.
Note: There is no way to change the name of the settings file of the machine
created in “legacy” mode.
9.45.7 createMachine
IMachine IVirtualBox::createMachine(
[in] wstring name,
[in] wstring osTypeId,
[in] wstring baseFolder,
[in] uuid id,
[in] boolean override)
245
9 Classes (interfaces)
1. Call this method to have a new machine created. The returned machine object
will be “mutable” allowing to change any machine property.
2. Configure the machine using the appropriate attributes and methods.
3. Call IMachine::saveSettings() to write the settings to the machine’s XML settings
file. The configuration of the newly created machine will not be saved to disk
until this method is called.
You should specify valid name for the newly created machine when calling this
method. See the IMachine::name attribute description for more details about the ma-
chine name.
The specified guest OS type identifier must match an ID of one of known guest OS
types listed in the guestOSTypes[] array.
Every machine has a settings file that is used to store the machine configuration. This
file is stored in a directory called the machine settings subfolder. Both the settings sub-
folder and file will have a name that corresponds to the name of the virtual machine.
You can specify where to create the machine setting subfolder using the baseFolder
argument. The base folder can be absolute (full path) or relative to the VirtualBox
home directory.
If baseFolder is a null or empty string (which is recommended), the default ma-
chine settings folder will be used as a base folder for the created machine. Otherwise
the given base folder will be used. In either case, the full path to the resulting settings
file has the following structure:
<base_folder>/<machine_name>/<machine_name>.xml
Note that if the resulting settings file already exists, this method will fail with ::.
Optionally, you may specify an UUID of to assign to the created machine. However,
this is not recommended and you should normally pass an empty (null) UUID to this
method so that a new UUID will be automatically generated for every created machine.
You can use UUID 00000000-0000-0000-0000-000000000000 as null value.
246
9 Classes (interfaces)
Note: There is no way to change the name of the settings file or subfolder of
the created machine directly.
9.45.8 createSharedFolder
void IVirtualBox::createSharedFolder(
[in] wstring name,
[in] wstring hostPath,
[in] boolean writable)
Creates a new global shared folder by associating the given logical name with the
given host path, adds it to the collection of shared folders and starts sharing it. Refer
to the description of ISharedFolder to read more about logical names.
9.45.9 findDHCPServerByNetworkName
IDHCPServer IVirtualBox::findDHCPServerByNetworkName(
[in] wstring name)
Searches a dhcp server settings to be used for the given internal network name
If this method fails, the following error codes may be reported:
247
9 Classes (interfaces)
9.45.10 findDVDImage
IMedium IVirtualBox::findDVDImage(
[in] wstring location)
9.45.11 findFloppyImage
IMedium IVirtualBox::findFloppyImage(
[in] wstring location)
248
9 Classes (interfaces)
9.45.12 findHardDisk
IMedium IVirtualBox::findHardDisk(
[in] wstring location)
Returns a medium that uses the given location to store medium data.
The given medium must be known to this VirtualBox installation, i.e. it must be
previously created by createHardDisk() or opened by openHardDisk(), or attached to
some known virtual machine.
The search is done by comparing the value of the location argument to the
IMedium::location attribute of each known medium.
For locations represented by file names in the host’s file system, the requested loca-
tion can be a path relative to the VirtualBox home folder. If only a file name without
any path is given, the default medium folder will be prepended to the file name be-
fore searching. Note that on case sensitive file systems, a case sensitive comparison is
performed, otherwise the case of symbols in the file path is ignored.
If this method fails, the following error codes may be reported:
9.45.13 findMachine
IMachine IVirtualBox::findMachine(
[in] wstring name)
name
Attempts to find a virtual machine given its name. To look up a machine by UUID,
use getMachine() instead.
If this method fails, the following error codes may be reported:
9.45.14 getDVDImage
IMedium IVirtualBox::getDVDImage(
[in] uuid id)
249
9 Classes (interfaces)
9.45.15 getExtraData
wstring IVirtualBox::getExtraData(
[in] wstring key)
9.45.16 getExtraDataKeys
wstring[] IVirtualBox::getExtraDataKeys()
Returns an array representing the global extra data keys which currently have values
defined.
9.45.17 getFloppyImage
IMedium IVirtualBox::getFloppyImage(
[in] uuid id)
250
9 Classes (interfaces)
9.45.18 getGuestOSType
IGuestOSType IVirtualBox::getGuestOSType(
[in] uuid id)
9.45.19 getHardDisk
IMedium IVirtualBox::getHardDisk(
[in] uuid id)
9.45.20 getMachine
IMachine IVirtualBox::getMachine(
[in] uuid id)
id
Attempts to find a virtual machine given its UUID. To look up a machine by name,
use findMachine() instead.
If this method fails, the following error codes may be reported:
251
9 Classes (interfaces)
9.45.21 openDVDImage
IMedium IVirtualBox::openDVDImage(
[in] wstring location,
[in] uuid id)
location Full path to the file that contains a valid CD/DVD image.
id UUID to assign to the given image within this VirtualBox installation. If an empty
(null) UUID is specified, the system will randomly generate a new UUID.
Opens a CD/DVD image contained in the specified file of the supported format and
assigns it the given UUID.
After the image is successfully opened by this method, it gets remembered by
(known to) this VirtualBox installation and will be accessible through getDVDImage()
and findDVDImage() methods. Remembered images are also returned as part of the
DVDImages[] array and can be mounted to virtual machines. See IMedium for more
details.
See IMedium::location to get more details about the format of the location string.
Note: Currently only ISO 9960 CD/DVD images are supported by VirtualBox.
• VBOX_E_FILE_ERROR: Invalid CD/DVD image file location or could not find the
CD/DVD image at the specified location.
• VBOX_E_INVALID_OBJECT_STATE: CD/DVD image already exists in the media
registry.
9.45.22 openExistingSession
void IVirtualBox::openExistingSession(
[in] ISession session,
[in] uuid machineId)
session Session object that will represent the open remote session after successful
method invocation. This object must not represent an already open session.
Note: This session will be automatically closed when the peer (direct) session
dies or gets closed.
252
9 Classes (interfaces)
Opens a new remote session with the virtual machine for which a direct session is
already open.
The remote session provides some level of control over the VM execution (using the
IConsole interface) to the caller; however, within the remote session context, not all
VM settings are available for modification.
As opposed to openRemoteSession(), the number of remote sessions opened this
way is not limited by the API
Note: It is an error to open a remote session with the machine that doesn’t
have an open direct session.
9.45.23 openFloppyImage
IMedium IVirtualBox::openFloppyImage(
[in] wstring location,
[in] uuid id)
location Full path to the file that contains a valid floppy image.
id UUID to assign to the given image file within this VirtualBox installation. If an
empty (null) UUID is specified, the system will randomly generate a new UUID.
Opens a floppy image contained in the specified file of the supported format and
assigns it the given UUID.
After the image is successfully opened by this method, it gets remembered by
(known to) this VirtualBox installation and will be accessible through getFloppyIm-
age() and findFloppyImage() methods. Remembered images are also returned as part
of the floppyImages[] array and can be mounted to virtual machines. See IMedium
for more details.
See IMedium::location to get more details about the format of the location string.
253
9 Classes (interfaces)
• VBOX_E_FILE_ERROR: Invalid floppy image file location or could not find the
floppy image at the specified location.
• VBOX_E_INVALID_OBJECT_STATE: Floppy image already exists in the media
registry.
9.45.24 openHardDisk
IMedium IVirtualBox::openHardDisk(
[in] wstring location,
[in] AccessMode accessMode,
[in] boolean setImageId,
[in] uuid imageId,
[in] boolean setParentId,
[in] uuid parentId)
location Location of the storage unit that contains medium data in one of the sup-
ported storage formats.
accessMode Determines whether to open the image in read/write or read-only
mode.
parentId New parent UUID for the image. If an empty string is passed, then a new
UUID is automatically created, provided setParentId is true. A zero UUID is
valid.
Opens a medium from an existing location, optionally replacing the image UUID
and/or parent UUID.
After the medium is successfully opened by this method, it gets remembered by
(known to) this VirtualBox installation and will be accessible through getHardDisk()
and findHardDisk() methods. Remembered base media are also returned as part of
the hardDisks[] array and can be attached to virtual machines. See IMedium for more
details.
If a differencing medium is to be opened by this method, the operation will succeed
only if its parent medium and all ancestors, if any, are already known to this VirtualBox
installation (for example, were opened by this method before).
This method tries to guess the storage format of the specified medium by reading
medium data at the specified location.
254
9 Classes (interfaces)
If accessMode is ReadWrite (which it should be), the image is opened for read/write
access and must have according permissions, as VirtualBox may actually write status
information into the disk’s metadata sections.
Note that write access is required for all typical image usage in VirtualBox, since
VirtualBox may need to write metadata such as a UUID into the image. The only
exception is opening a source image temporarily for copying and cloning when the
image will quickly be closed again.
Note that the format of the location string is storage format specific. See
IMedium::location, IMedium and ISystemProperties::defaultHardDiskFolder for more
details.
If this method fails, the following error codes may be reported:
9.45.25 openMachine
IMachine IVirtualBox::openMachine(
[in] wstring settingsFile)
Opens a virtual machine from the existing settings file. The opened machine remains
unregistered until you call registerMachine().
The specified settings file name can be absolute (full path) or relative to the
VirtualBox home directory. This file must exist and must be a valid machine settings
file whose contents will be used to construct the machine object.
@deprecated Will be removed soon.
If this method fails, the following error codes may be reported:
9.45.26 openRemoteSession
IProgress IVirtualBox::openRemoteSession(
[in] ISession session,
[in] uuid machineId,
[in] wstring type,
[in] wstring environment)
session Session object that will represent the opened remote session after successful
method invocation (this object must not represent an already open session).
255
9 Classes (interfaces)
Spawns a new process that executes a virtual machine (called a “remote session”).
Opening a remote session causes the VirtualBox server to start a new process that
opens a direct session with the given VM. As a result, the VM is locked by that direct
session in the new process, preventing conflicting changes from other processes. Since
sessions act as locks that prevent conflicting changes, one cannot open a remote ses-
sion for a VM that already has another open session (direct or remote), or is currently
in the process of opening one (see IMachine::sessionState).
While the remote session still provides some level of control over the VM execu-
tion to the caller (using the IConsole interface), not all VM settings are available for
modification within the remote session context.
This operation can take some time (a new VM is started in a new process, for
which memory and other resources need to be set up). Because of this, an IProgress
is returned to allow the caller to wait for this asynchronous operation to be com-
pleted. Until then, the remote session object remains in the closed state, and ac-
cessing the machine or its console through it is invalid. It is recommended to use
IProgress::waitForCompletion() or similar calls to wait for completion. Completion is
signalled when the VM is powered on. Error messages etc. can be queried via the
progress object, if available.
As with all ISession objects, it is recommended to call ISession::close() on the local
session object once openRemoteSession() has been called. However, the session’s state
(see ISession::state) will not return to “Closed” until the remote session has also closed
(i.e. until the VM is no longer running). In that case, however, the state of the session
will automatically change back to “Closed”.
Currently supported session types (values of the type argument) are:
256
9 Classes (interfaces)
The progress object will have at least 2 operation. The first operation covers the
period up to the new VM process calls powerUp. The subsequent operations mirrors
the IConsole::powerUp() progress object. Because IConsole::powerUp() may require
some extra operation, the IProgress::operationCount may change at the completion of
operation1.
For details on the teleportation progress operation, see IConsole::powerUp().
See also: openExistingSession
If this method fails, the following error codes may be reported:
9.45.27 openSession
void IVirtualBox::openSession(
[in] ISession session,
[in] uuid machineId)
session Session object that will represent the opened session after successful method
invocation. This object must not represent the already open session.
257
9 Classes (interfaces)
Note: Unless you are writing a new VM frontend, you will not want to execute
a VM in the current process. To spawn a new process that executes a VM, use
openRemoteSession() instead.
Upon successful return, the session object can be used to get access to the machine
and to the VM console.
In VirtualBox terminology, the machine becomes “mutable” after a session has been
opened. Note that the “mutable” machine object, on which you may invoke IMachine
methods to change its settings, will be a different object from the immutable IMachine
objects returned by various IVirtualBox methods. To obtain a mutable IMachine object
(upon which you can invoke settings methods), use the ISession::machine attribute.
One must always call ISession::close() to release the lock on the machine, or the
machine’s state will eventually be set to “Aborted”.
In other words, to change settings on a machine, the following sequence is typically
performed:
1. Call this method (openSession) to have a machine locked for the current session.
2. Obtain a mutable IMachine object from ISession::machine.
3. Change the settings of the machine.
4. Call IMachine::saveSettings().
5. Close the session by calling ISession::close().
9.45.28 registerCallback
void IVirtualBox::registerCallback(
[in] IVirtualBoxCallback callback)
258
9 Classes (interfaces)
Registers a new global VirtualBox callback. The methods of the given callback object
will be called by VirtualBox when an appropriate event occurs.
If this method fails, the following error codes may be reported:
9.45.29 registerMachine
void IVirtualBox::registerMachine(
[in] IMachine machine)
machine
9.45.30 removeDHCPServer
void IVirtualBox::removeDHCPServer(
[in] IDHCPServer server)
9.45.31 removeSharedFolder
void IVirtualBox::removeSharedFolder(
[in] wstring name)
259
9 Classes (interfaces)
Removes the global shared folder with the given name previously created by create-
SharedFolder() from the collection of shared folders and stops sharing it.
9.45.32 setExtraData
void IVirtualBox::setExtraData(
[in] wstring key,
[in] wstring value)
Note: Before performing the actual data change, this method will ask all
registered callbacks using the IVirtualBoxCallback::onExtraDataCanChange()
notification for a permission. If one of the callbacks refuses the new value,
the change will not be performed.
9.45.33 unregisterCallback
void IVirtualBox::unregisterCallback(
[in] IVirtualBoxCallback callback)
260
9 Classes (interfaces)
9.45.34 unregisterMachine
IMachine IVirtualBox::unregisterMachine(
[in] uuid id)
Note: The specified machine must not be in the Saved state, have an open
(or a spawning) direct session associated with it, have snapshots or have any
medium attached.
261
9 Classes (interfaces)
9.45.35 waitForPropertyChange
void IVirtualBox::waitForPropertyChange(
[in] wstring what,
[in] unsigned long timeout,
[out] wstring changed,
[out] wstring values)
Blocks the caller until any of the properties represented by the what argument
changes the value or until the given timeout interval expires.
The what argument is a comma separated list of property masks that describe prop-
erties the caller is interested in. The property mask is a string in the following format:
[[group.]subgroup.]name
where name is the property name and group, subgroup are zero or more property
group specifiers. Each element (group or name) in the property mask may be either
a Latin string or an asterisk symbol (@c “*“) which is used to match any string for
the given element. A property mask that doesn’t contain asterisk symbols represents a
single fully qualified property name.
Groups in the fully qualified property name go from more generic (the left-most
part) to more specific (the right-most part). The first element is usually a name of the
object the property belongs to. The second element may be either a property name,
or a child object name, or an index if the preceding element names an object which is
one of many objects of the same type. This way, property names form a hierarchy of
properties. Here are some examples of property names:
VirtualBox.versionversion propertyMachine.<UUID>.nameIMachine::name
property of the machine with the given UUID
Most property names directly correspond to the properties of objects (components)
provided by the VirtualBox library and may be used to track changes to these prop-
erties. However, there may be pseudo-property names that don’t correspond to any
existing object’s property directly, as well as there may be object properties that don’t
have a corresponding property name that is understood by this method, and there-
fore changes to such properties cannot be tracked. See individual object’s property
descriptions to get a fully qualified property name that can be used with this method
(if any).
262
9 Classes (interfaces)
There is a special property mask @c “*“ (i.e. a string consisting of a single asterisk
symbol) that can be used to match all properties. Below are more examples of property
masks:
VirtualBox.*Track all properties of the VirtualBox objectMachine.*.nameTrack
changes to the IMachine::name property of all registered virtual machines
Note: This function is not implemented in the current version of the product.
9.46 IVirtualBoxCallback
9.46.1 onExtraDataCanChange
boolean IVirtualBoxCallback::onExtraDataCanChange(
[in] uuid machineId,
[in] wstring key,
[in] wstring value,
[out] wstring error)
machineId ID of the machine this event relates to (null ID for global extra data
change requests).
key Extra data key for the attempted write.
value Extra data value for the given key.
error Optional error message describing the reason of the veto (ignored if this notifi-
cation returns true).
Notification when someone tries to change extra data for either the given machine
or (if null) global extra data. This gives the chance to veto against changes.
If this method fails, the following error codes may be reported:
9.46.2 onExtraDataChange
void IVirtualBoxCallback::onExtraDataChange(
[in] uuid machineId,
[in] wstring key,
[in] wstring value)
263
9 Classes (interfaces)
machineId ID of the machine this event relates to. Null for global extra data changes.
key Extra data key that has changed.
9.46.3 onGuestPropertyChange
void IVirtualBoxCallback::onGuestPropertyChange(
[in] uuid machineId,
[in] wstring name,
[in] wstring value,
[in] wstring flags)
9.46.4 onMachineDataChange
void IVirtualBoxCallback::onMachineDataChange(
[in] uuid machineId)
264
9 Classes (interfaces)
9.46.5 onMachineRegistered
void IVirtualBoxCallback::onMachineRegistered(
[in] uuid machineId,
[in] boolean registered)
The given machine was registered or unregistered within this VirtualBox installa-
tion.
If this method fails, the following error codes may be reported:
9.46.6 onMachineStateChange
void IVirtualBoxCallback::onMachineStateChange(
[in] uuid machineId,
[in] MachineState state)
The execution state of the given machine has changed. See also: IMachine::state
If this method fails, the following error codes may be reported:
9.46.7 onMediumRegistered
void IVirtualBoxCallback::onMediumRegistered(
[in] uuid mediumId,
[in] DeviceType mediumType,
[in] boolean registered)
The given medium was registered or unregistered within this VirtualBox installation.
The mediumType parameter describes what type of medium the specified mediumId
refers to. Possible values are:
• HardDisk: the medium is a hard disk that, if registered, can be obtained using
the IVirtualBox::getHardDisk() call.
265
9 Classes (interfaces)
• DVD: the medium is a CD/DVD image that, if registered, can be obtained using
the IVirtualBox::getDVDImage() call.
• Floppy: the medium is a Floppy image that, if registered, can be obtained using
the IVirtualBox::getFloppyImage() call.
Note that if this is a deregistration notification, there is no way to access the object
representing the unregistered medium. It is supposed that the application will do
required cleanup based on the mediumId value.
If this method fails, the following error codes may be reported:
9.46.8 onSessionStateChange
void IVirtualBoxCallback::onSessionStateChange(
[in] uuid machineId,
[in] SessionState state)
The state of the session for the given machine was changed. See also: IMa-
chine::sessionState
If this method fails, the following error codes may be reported:
9.46.9 onSnapshotChange
void IVirtualBoxCallback::onSnapshotChange(
[in] uuid machineId,
[in] uuid snapshotId)
Snapshot properties (name and/or description) have been changed. See also: IS-
napshot
If this method fails, the following error codes may be reported:
266
9 Classes (interfaces)
9.46.10 onSnapshotDeleted
void IVirtualBoxCallback::onSnapshotDeleted(
[in] uuid machineId,
[in] uuid snapshotId)
Note: This notification is delivered after the snapshot object has been unini-
tialized on the server (so that any attempt to call its methods will return an
error).
9.46.11 onSnapshotTaken
void IVirtualBoxCallback::onSnapshotTaken(
[in] uuid machineId,
[in] uuid snapshotId)
A new snapshot of the machine has been taken. See also: ISnapshot
If this method fails, the following error codes may be reported:
9.47 IVirtualBoxErrorInfo
The IVirtualBoxErrorInfo interface represents extended error information.
Extended error information can be set by VirtualBox components after unsuccessful
or partially successful method invocation. This information can be retrieved by the
calling party as an IVirtualBoxErrorInfo object and then shown to the client in addition
to the plain 32-bit result code.
In MS COM, this interface extends the IErrorInfo interface, in XPCOM, it extends
the nsIException interface. In both cases, it provides a set of common attributes to
retrieve error information.
267
9 Classes (interfaces)
9.47.1 Attributes
9.47.1.1 resultCode (read-only)
long IVirtualBoxErrorInfo::resultCode
Result code of the error. Usually, it will be the same as the result code returned by the
method that provided this error information, but not always. For example, on Win32,
CoCreateInstance() will most likely return E_NOINTERFACE upon unsuccessful com-
ponent instantiation attempt, but not the value the component factory returned. Value
is typed ’long’, not ’result’, to make interface usable from scripting languages.
268
9 Classes (interfaces)
9.48 IVirtualSystemDescription
Represents one virtual system (machine) in an appliance. This interface is used in the
IAppliance::virtualSystemDescriptions[] array. After IAppliance::interpret() has been
called, that array contains information about how the virtual systems described in the
OVF should best be imported into VirtualBox virtual machines. See IAppliance for the
steps required to import an OVF into VirtualBox.
9.48.1 Attributes
9.48.1.1 count (read-only)
unsigned long IVirtualSystemDescription::count
9.48.2 addDescription
void IVirtualSystemDescription::addDescription(
[in] VirtualSystemDescriptionType aType,
[in] wstring aVBoxValue,
[in] wstring aExtraConfigValue)
aType
269
9 Classes (interfaces)
aVBoxValue
aExtraConfigValue
This method adds an additional description entry to the stack of already available
descriptions for this virtual system. This is handy for writing values which aren’t di-
rectly supported by VirtualBox. One example would be the License type of VirtualSys-
temDescriptionType.
9.48.3 getDescription
void IVirtualSystemDescription::getDescription(
[out] VirtualSystemDescriptionType aTypes[],
[out] wstring aRefs[],
[out] wstring aOvfValues[],
[out] wstring aVBoxValues[],
[out] wstring aExtraConfigValues[])
aTypes
aRefs
aOvfValues
aVBoxValues
aExtraConfigValues
Returns information about the virtual system as arrays of instruction items. In each
array, the items with the same indices correspond and jointly represent an import
instruction for VirtualBox.
The list below identifies the value sets that are possible depending on the Virtual-
SystemDescriptionType enum value in the array item in aTypes[]. In each case, the
array item with the same index in aOvfValues[] will contain the original value as con-
tained in the OVF file (just for informational purposes), and the corresponding item in
aVBoxValues[] will contain a suggested value to be used for VirtualBox. Depending
on the description type, the aExtraConfigValues[] array item may also be used.
• “OS”: the guest operating system type. There must be exactly one such array
item on import. The corresponding item in aVBoxValues[] contains the sug-
gested guest operating system for VirtualBox. This will be one of the values
listed in IVirtualBox::guestOSTypes[]. The corresponding item in aOvfValues[]
will contain a numerical value that described the operating system in the OVF.
• “Name”: the name to give to the new virtual machine. There can be at most
one such array item; if none is present on import, then an automatic name
will be created from the operating system type. The correponding item im
aOvfValues[] will contain the suggested virtual machine name from the OVF
file, and aVBoxValues[] will contain a suggestion for a unique VirtualBox IMa-
chine name that does not exist yet.
270
9 Classes (interfaces)
• “Memory”: the amount of guest RAM, in bytes. There can be at most one such
array item; if none is present on import, then VirtualBox will set a meaningful
default based on the operating system type.
• “HardDiskControllerIDE”: an IDE hard disk controller. There can be at most
two such items. An optional value in aOvfValues[] and aVBoxValues[] can be
“PIIX3” or “PIIX4” to specify the type of IDE controller; this corresponds to the
ResourceSubType element which VirtualBox writes into the OVF. The matching
item in the aRefs[] array will contain an integer that items of the “Harddisk”
type can use to specify which hard disk controller a virtual disk should be con-
nected to. Note that in OVF, an IDE controller has two channels, corresponding
to “master” and “slave” in traditional terminology, whereas the IDE storage con-
troller that VirtualBox supports in its virtual machines supports four channels
(primary master, primary slave, secondary master, secondary slave) and thus
maps to two IDE controllers in the OVF sense.
• “HardDiskControllerSATA”: an SATA hard disk controller. There can be at most
one such item. This has no value in aOvfValues[] or aVBoxValues[]. The
matching item in the aRefs[] array will be used as with IDE controllers (see
above).
• “HardDiskControllerSCSI”: a SCSI hard disk controller. There can be at most
one such item. The items in aOvfValues[] and aVBoxValues[] will either be
“LsiLogic”, “BusLogic” or “LsiLogicSas”. (Note that in OVF, the LsiLogicSas con-
troller is treated as a SCSI controller whereas VirtualBox considers it a class of
storage controllers of its own; see StorageControllerType). The matching item
in the aRefs[] array will be used as with IDE controllers (see above).
• “HardDiskImage”: a virtual hard disk, most probably as a reference to an image
file. There can be an arbitrary number of these items, one for each virtual disk
image that accompanies the OVF.
The array item in aOvfValues[] will contain the file specification from the OVF
file (without a path since the image file should be in the same location as the
OVF file itself), whereas the item in aVBoxValues[] will contain a qualified path
specification to where VirtualBox uses the hard disk image. This means that on
import the image will be copied and converted from the “ovf” location to the
271
9 Classes (interfaces)
“vbox” location; on export, this will be handled the other way round. On import,
the target image will also be registered with VirtualBox.
The matching item in the aExtraConfigValues[] array must contain a string of
the following format: “controller=<index>;channel=<c>“ In this string, <in-
dex> must be an integer specifying the hard disk controller to connect the im-
age to. That number must be the index of an array item with one of the hard
disk controller types (HardDiskControllerSCSI, HardDiskControllerSATA, Hard-
DiskControllerIDE). In addition, <c> must specify the channel to use on that
controller. For IDE controllers, this can be 0 or 1 for master or slave, respec-
tively. For compatibility with VirtualBox versions before 3.2, the values 2 and 3
(for secondary master and secondary slave) are also supported, but no longer
exported. For SATA and SCSI controllers, the channel can range from 0-29.
• “CDROM”: a virtual CD-ROM drive. The matching item in aExtraConfigValue[]
contains the same attachment information as with “HardDiskImage” items.
• “SoundCard”: a sound card. There can be at most one such item. If and only
if such an item is present, sound support will be enabled for the new virtual
machine. Note that the virtual machine in VirtualBox will always be presented
with the standard VirtualBox soundcard, which may be different from the virtual
soundcard expected by the appliance.
9.48.4 getDescriptionByType
void IVirtualSystemDescription::getDescriptionByType(
[in] VirtualSystemDescriptionType aType,
[out] VirtualSystemDescriptionType aTypes[],
[out] wstring aRefs[],
[out] wstring aOvfValues[],
[out] wstring aVBoxValues[],
[out] wstring aExtraConfigValues[])
aType
aTypes
272
9 Classes (interfaces)
aRefs
aOvfValues
aVBoxValues
aExtraConfigValues
This is the same as getDescription() except that you can specify which types should be
returned.
9.48.5 getValuesByType
wstring[] IVirtualSystemDescription::getValuesByType(
[in] VirtualSystemDescriptionType aType,
[in] VirtualSystemDescriptionValueType aWhich)
aType
aWhich
This is the same as getDescriptionByType() except that you can specify which value
types should be returned. See VirtualSystemDescriptionValueType for possible values.
9.48.6 setFinalValues
void IVirtualSystemDescription::setFinalValues(
[in] boolean aEnabled[],
[in] wstring aVBoxValues[],
[in] wstring aExtraConfigValues[])
aEnabled
aVBoxValues
aExtraConfigValues
This method allows the appliance’s user to change the configuration for the virtual
system descriptions. For each array item returned from getDescription(), you must
pass in one boolean value and one configuration value.
Each item in the boolean array determines whether the particular configuration item
should be enabled. You can only disable items of the types HardDiskControllerIDE,
HardDiskControllerSATA, HardDiskControllerSCSI, HardDiskImage, CDROM, Floppy,
NetworkAdapter, USBController and SoundCard.
For the “vbox” and “extra configuration” values, if you pass in the same arrays as
returned in the aVBoxValues and aExtraConfigValues arrays from getDescription(), the
configuration remains unchanged. Please see the documentation for getDescription()
for valid configuration values for the individual array item types. If the corresponding
item in the aEnabled array is false, the configuration value is ignored.
273
9 Classes (interfaces)
9.49 IWebsessionManager
Note: This interface is supported in the web service only, not in COM/XPCOM.
9.49.1 getSessionObject
ISession IWebsessionManager::getSessionObject(
[in] IVirtualBox refIVirtualBox)
refIVirtualBox
Returns a managed object reference to the internal ISession object that was created
for this web service session when the client logged on.
See also: ISession
9.49.2 logoff
void IWebsessionManager::logoff(
[in] IVirtualBox refIVirtualBox)
refIVirtualBox
Logs off the client who has previously logged on with logoff() and destroys all re-
sources associated with the session (most importantly, all managed objects created in
the server while the session was active).
9.49.3 logon
IVirtualBox IWebsessionManager::logon(
[in] wstring username,
[in] wstring password)
username
password
Logs a new client onto the webservice and returns a managed object reference to
the IVirtualBox instance, which the client can then use as a basis to further queries,
since all calls to the VirtualBox API are based on the IVirtualBox interface, in one way
or the other.
274
10 Enumerations (enums)
10.1 AccessMode
Access mode for opening files.
ReadOnly
ReadWrite
10.2 AudioControllerType
Virtual audio controller type.
AC97
SB16
10.3 AudioDriverType
Host audio driver type.
275
10 Enumerations (enums)
10.4 BIOSBootMenuMode
BIOS boot menu mode.
Disabled
MenuOnly
MessageAndMenu
10.5 CPUPropertyType
Virtual CPU property type. This enumeration represents possible values of the IMa-
chine get- and setCPUProperty methods.
10.6 ClipboardMode
Host-Guest clipboard interchange mode.
Disabled
HostToGuest
GuestToHost
Bidirectional
10.7 DataFlags
None
Mandatory
Expert
Array
FlagMask
276
10 Enumerations (enums)
10.8 DataType
Int32
Int8
String
10.9 DeviceActivity
Device activity for IConsole::getDeviceActivity().
Null
Idle
Reading
Writing
10.10 DeviceType
Device type.
Null Null value, may also mean “no device” (not allowed for IConsole::getDeviceActivity()).
Floppy Floppy device.
DVD CD/DVD-ROM device.
HardDisk Hard disk device.
Network Network device.
USB USB device.
SharedFolder Shared folder device.
10.11 FirmwareType
Firmware type.
BIOS BIOS Firmware.
EFI EFI Firmware, bitness detetced basing on OS type.
EFI32 Efi firmware, 32-bit.
EFI64 Efi firmware, 64-bit.
EFIDUAL Efi firmware, combined 32 and 64-bit.
277
10 Enumerations (enums)
10.12 FramebufferPixelFormat
Format of the video memory buffer. Constants represented by this enum can be
used to test for particular values of IFramebuffer::pixelFormat. See also IFrame-
buffer::requestResize().
See also www.fourcc.org for more information about FOURCC pixel formats.
Opaque Unknown buffer format (the user may not assume any particular format of
the buffer).
FOURCC_RGB Basic RGB format (IFramebuffer::bitsPerPixel determines the bit lay-
out).
10.13 HWVirtExPropertyType
Hardware virtualization property type. This enumeration represents possible val-
ues for the IMachine::getHWVirtExProperty() and IMachine::setHWVirtExProperty()
methods.
VPID Whether VT-x VPID is enabled. If this extension is not available, it will not be
used.
NestedPaging Whether Nested Paging is enabled. If this extension is not available,
it will not be used.
LargePages Whether large page allocation is enabled; requires nested paging and a
64 bits host.
10.14 HostNetworkInterfaceMediumType
Type of encapsulation. Ethernet encapsulation includes both wired and wireless Eth-
ernet connections. See also: IHostNetworkInterface
278
10 Enumerations (enums)
10.15 HostNetworkInterfaceStatus
Current status of the interface. See also: IHostNetworkInterface
10.16 HostNetworkInterfaceType
Network interface type.
Bridged
HostOnly
10.17 KeyboardHidType
Type of keyboard device used in a virtual machine.
None No keyboard.
PS2Keyboard PS/2 keyboard.
USBKeyboard USB keyboard.
10.18 MachineState
Virtual machine execution state.
This enumeration represents possible values of the IMachine::state attribute.
Below is the basic virtual machine state diagram. It shows how the state changes
during virtual machine execution. The text in square braces shows a method of the
IConsole interface that performs the given state transition.
279
10 Enumerations (enums)
Note that states to the right from PoweredOff, Aborted and Saved in the above
diagram are called online VM states. These states represent the virtual machine which
is being executed in a dedicated process (usually with a GUI window attached to it
where you can see the activity of the virtual machine and interact with it). There are
two special pseudo-states, FirstOnline and LastOnline, that can be used in relational
expressions to detect if the given machine state is online or not:
When the virtual machine is in one of the online VM states (that is, being executed),
only a few machine settings can be modified. Methods working with such settings
contain an explicit note about that. An attempt to change any oter setting or perform
a modifying operation during this time will result in the error.
All online states except Running, Paused and Stuck are transitional: they represent
temporary conditions of the virtual machine that will last as long as the operation that
initiated such a condition.
The Stuck state is a special case. It means that execution of the machine has reached
the “Guru Meditation” condition. This condition indicates an internal VMM (virtual
machine manager) failure which may happen as a result of either an unhandled low-
level virtual hardware exception or one of the recompiler exceptions (such as the
too-many-traps condition).
Note also that any online VM state may transit to the Aborted state. This happens if
the process that is executing the virtual machine terminates unexpectedly (for exam-
ple, crashes). Other than that, the Aborted state is equivalent to PoweredOff.
There are also a few additional state diagrams that do not deal with virtual machine
execution and therefore are shown separately. The states shown on these diagrams
are called offline VM states (this includes PoweredOff, Aborted and Saved too).
280
10 Enumerations (enums)
The first diagram shows what happens when a lengthy setup operation is being
executed (such as IMachine::attachDevice()).
The next two diagrams demonstrate the process of taking a snapshot of a powered
off virtual machine, restoring the state to that as of a snapshot or deleting a snapshot,
respectively.
Note that the Saving state is present in both the offline state group and online state
group. Currently, the only way to determine what group is assumed in a particular
case is to remember the previous machine state: if it was Running or Paused, then
Saving is an online state, otherwise it is an offline state. This inconsistency may be
removed in one of the future versions of VirtualBox by adding a new state.
281
10 Enumerations (enums)
Aborted The process running the machine has terminated abnormally. This may in-
dicate a crash of the VM process in host execution context, or the VM process
has been terminated externally.
Stopping Machine is being normally stopped powering it off, or after the guest OS
has initiated a shutdown sequence.
Saving Machine is saving its execution state to a file, or an online snapshot of the
machine is being taken.
Restoring Execution state of the machine is being restored from a file after powering
it on from the saved execution state.
TeleportingPausedVM The machine is being teleported to another host or process,
but it is not running. This is the paused variant of the MachineState::Teleporting
state.
282
10 Enumerations (enums)
10.19 MediumFormatCapabilities
Medium format capability flags.
CreateFixed Supports creating fixed size images, allocating all space instantly.
CreateDynamic Supports creating dynamically growing images, allocating space on
demand.
CreateSplit2G Supports creating images split in chunks of a bit less than 2 GBytes.
File The format backend operates on files (the IMedium::location attribute of the
medium specifies a file used to store medium data; for a list of supported file
extensions see IMediumFormat::fileExtensions[]).
Properties The format backend uses the property interface to configure the stor-
age location and properties (the IMediumFormat::describeProperties() method
is used to get access to properties supported by the given medium format).
CapabilityMask
10.20 MediumState
Virtual medium state. See also: IMedium
NotCreated Associated medium storage does not exist (either was not created yet or
was deleted).
Created Associated storage exists and accessible; this gets set if the accessibility check
performed by IMedium::refreshState() was successful.
283
10 Enumerations (enums)
10.21 MediumType
Virtual medium type. See also: IMedium
Normal Normal medium (attached directly or indirectly, preserved when taking snap-
shots).
Immutable Immutable medium (attached indirectly, changes are wiped out the next
time the virtual machine is started).
Writethrough Write through medium (attached directly, ignored when taking snap-
shots).
Shareable Allow using this medium concurrently by several machines.
10.22 MediumVariant
Virtual medium image variant. More than one flag may be set. See also: IMedium
Standard No particular variant requested, results in using the backend default.
VmdkSplit2G VMDK image split in chunks of less than 2GByte.
VmdkStreamOptimized VMDK streamOptimized image. Special import/export for-
mat which is read-only/append-only.
VmdkESX VMDK format variant used on ESX products.
Fixed Fixed image. Only allowed for base images.
Diff Differencing image. Only allowed for child images.
284
10 Enumerations (enums)
10.23 MouseButtonState
Mouse button state.
LeftButton
RightButton
MiddleButton
WheelUp
WheelDown
XButton1
XButton2
MouseStateMask
10.24 NATAliasMode
AliasLog
AliasProxyOnly
AliasUseSamePorts
10.25 NATProtocol
Protocol definitions used with NAT port-forwarding rules.
10.26 NetworkAdapterType
Network adapter type.
285
10 Enumerations (enums)
10.27 NetworkAttachmentType
Network attachment type.
10.28 PointingHidType
Type of pointing device used in a virtual machine.
None No mouse.
PS2Mouse PS/2 auxillary device, a.k.a. mouse.
USBMouse USB mouse (relative pointer).
USBTablet USB tablet (absolute pointer).
ComboMouse Combined device, working as PS/2 or USB mouse, depending on guest
behavior. Using of such device can have negative performance implications.
10.29 PortMode
The PortMode enumeration represents possible communication modes for the virtual
serial port device.
286
10 Enumerations (enums)
10.30 ProcessorFeature
CPU features.
HWVirtEx
PAE
LongMode
NestedPaging
10.31 Scope
Scope of the operation.
A generic enumeration used in various methods to define the action or argument
scope.
Global
Machine
Session
10.32 SessionState
Session state. This enumeration represents possible values of IMachine::sessionState
and ISession::state attributes. See individual enumerator descriptions for the meaning
for every value.
Spawning A new (direct) session is being opened for the machine as a result of IVir-
tualBox::openRemoteSession() call (IMachine::sessionState or ISession::state).
This state also occurs as a short transient state when a new direct session is
opened by calling IVirtualBox::openSession().
287
10 Enumerations (enums)
10.33 SessionType
Session type. This enumeration represents possible values of the ISession::type at-
tribute.
10.34 SettingsVersion
Settings version of VirtualBox settings files. This is written to the “version” attribute of
the root “VirtualBox” element in the settings file XML and indicates which VirtualBox
version wrote the file.
Future Settings version greater than “1.10”, written by a future VirtualBox version.
288
10 Enumerations (enums)
10.35 StorageBus
The bus type of the storage controller (IDE, SATA, SCSI, SAS or Floppy); see IStorage-
Controller::bus.
10.36 StorageControllerType
The exact variant of storage controller hardware presented to the guest; see IStorage-
Controller::controllerType.
10.37 USBDeviceFilterAction
Actions for host USB device filters. See also: IHostUSBDeviceFilter, USBDeviceState
289
10 Enumerations (enums)
10.38 USBDeviceState
USB device state. This enumeration represents all possible states of the USB device
physically attached to the host computer regarding its state on the host computer and
availability to guest computers (all currently running virtual machines).
Once a supported USB device is attached to the host, global USB filters
(IHost::USBDeviceFilters[]) are activated. They can either ignore the device, or
put it to USBDeviceState_Held state, or do nothing. Unless the device is ignored by
global filters, filters of all currently running guests (IUSBController::deviceFilters[])
are activated that can put it to USBDeviceState_Captured state.
If the device was ignored by global filters, or didn’t match any filters at all (including
guest ones), it is handled by the host in a normal way. In this case, the device state is
determined by the host and can be one of USBDeviceState_Unavailable, USBDeviceS-
tate_Busy or USBDeviceState_Available, depending on the current device usage.
Besides auto-capturing based on filters, the device can be manually captured by
guests (IConsole::attachUSBDevice()) if its state is USBDeviceState_Busy, USBDe-
viceState_Available or USBDeviceState_Held.
10.39 VFSFileType
File types known by VFSExplorer.
Unknown
290
10 Enumerations (enums)
Fifo
DevChar
Directory
DevBlock
File
SymLink
Socket
WhiteOut
10.40 VFSType
Virtual file systems supported by VFSExplorer.
File
Cloud
S3
WebDav
10.41 VRDPAuthType
VRDP authentication type.
External
Guest
10.42 VirtualSystemDescriptionType
Used with IVirtualSystemDescription to describe the type of a configuration value.
Ignore
OS
Name
291
10 Enumerations (enums)
Product
Vendor
Version
ProductUrl
VendorUrl
Description
License
Miscellaneous
CPU
Memory
HardDiskControllerIDE
HardDiskControllerSATA
HardDiskControllerSCSI
HardDiskControllerSAS
HardDiskImage
Floppy
CDROM
NetworkAdapter
USBController
SoundCard
10.43 VirtualSystemDescriptionValueType
Used with IVirtualSystemDescription::getValuesByType() to describe the value type to
fetch.
Reference
Original
Auto
ExtraConfig
292
11 Host-Guest Communication
Manager
The VirtualBox Host-Guest Communication Manager (HGCM) allows a guest applica-
tion or a guest driver to call a host shared library. The following features of VirtualBox
are implemented using HGCM:
• Shared Folders
• Shared Clipboard
• Guest configuration interface
The shared library contains a so called HGCM service. The guest HGCM clients
establish connections to the service to call it. When calling a HGCM service the client
supplies a function code and a number of parameters for the function.
293
11 Host-Guest Communication Manager
Note:
294
11 Host-Guest Communication Manager
11.2.2 Connect
The connection request must be issued by the guest HGCM client before it can call the
HGCM service (VMMDevHGCMConnect):
Name Description
header The generic HGCM request header with type equal to
VMMDevReq_HGCMConnect (60).
type The type of the service location information (32 bit).
loca- The service location information (128 bytes).
tion
clien- The client identifier assigned to the connecting client by the
tId HGCM subsystem (32 bit).
The type field tells the HGCM how to look for the requested service:
Name Description
(hexadecimal
value)
VMMDevHGCM- The requested service is a shared library located on
Loc_LocalHost the host and the location information contains the
(0x1) library name.
VMMDevHGCM- The requested service is a preloaded one and the
Loc_LocalHost_Existinglocation information contains the service name.
(0x2)
• VBoxSharedFolders
• VBoxSharedClipboard
• VBoxGuestPropSvc
• VBoxSharedOpenGL
There is no difference between both types of HGCM services, only the location mech-
anism is different.
The client identifier is returned by the host and must be used in all subsequent
requests by the client.
11.2.3 Disconnect
This request disconnects the client and makes the client identifier invalid (VMMDe-
vHGCMDisconnect):
295
11 Host-Guest Communication Manager
Name Description
header The generic HGCM request header with type equal to
VMMDevReq_HGCMDisconnect (61).
clien- The client identifier previously returned by the connect request
tId (32 bit).
296
11 Host-Guest Communication Manager
The
11.2.5 Cancel
This request cancels a call request (VMMDevHGCMCancel):
Name Description
header The generic HGCM request header with type equal to
VMMDevReq_HGCMCancel (64).
297
11 Host-Guest Communication Manager
VBoxGuestHGCMConnectInfo data;
data.result = VINF_SUCCESS;
data.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
strcpy (data.Loc.u.host.achName, "VBoxSharedFolders");
if (RT_SUCCESS (rc))
{
rc = data.result;
}
if (RT_SUCCESS (rc))
{
/* Get the assigned client identifier. */
ulClientID = data.u32ClientID;
}
VBoxGuestHGCMDisconnectInfo data;
data.result = VINF_SUCCESS;
data.u32ClientID = ulClientID;
298
11 Host-Guest Communication Manager
} VBoxSFRead;
...
VBoxSFRead data;
/* Initialize parameters. */
299
11 Host-Guest Communication Manager
data.root.type = VMMDevHGCMParmType_32bit;
data.root.u.value32 = pMap->root;
data.handle.type = VMMDevHGCMParmType_64bit;
data.handle.u.value64 = hFile;
data.offset.type = VMMDevHGCMParmType_64bit;
data.offset.u.value64 = offset;
data.cb.type = VMMDevHGCMParmType_32bit;
data.cb.u.value32 = *pcbBuffer;
data.buffer.type = VMMDevHGCMParmType_LinAddr_Out;
data.buffer.u.Pointer.size = *pcbBuffer;
data.buffer.u.Pointer.u.linearAddr = (uintptr_t)pBuffer;
if (RT_SUCCESS (rc))
{
rc = data.callInfo.result;
*pcbBuffer = data.cb.u.value32; /* This is returned by the HGCM service. */
}
• VBOXGUEST_IOCTL_HGCM_CONNECT
• VBOXGUEST_IOCTL_HGCM_DISCONNECT
• VBOXGUEST_IOCTL_HGCM_CALL
These IOCTL’s get the same input buffer as VbglHGCM* functions and the output
buffer has the same format as the input buffer. The same address can be used as the
input and output buffers.
For example see the guest part of shared clipboard, which runs as an application
and uses the HGCM interface.
300
11 Host-Guest Communication Manager
301
12 RDP Web Control
The VirtualBox RDP Web Control (RDPWeb) provides remote access to a running VM.
RDPWeb is a RDP (Remote Desktop Protocol) client based on Flash technology and
can be used from a Web browser with a Flash plugin.
302
12 RDP Web Control
<div id=“FlashRDP”>
</div>
would have ElementId equal to FlashRDP and Element equal to the div element.
• RDPWebClient.embedSWF(SWFFileName, ElementId)
Uses SWFObject library to replace the HTML element with the Flash movie.
• RDPWebClient.isRDPWebControlById(ElementId)
Returns true if the given id refers to a RDPWeb Flash element.
• RDPWebClient.isRDPWebControlByElement(Element)
Returns true if the given element is a RDPWeb Flash element.
• RDPWebClient.getFlashById(ElementId)
Returns an element, which is referenced by the given id. This function will try
to resolve any element, event if it is not a Flash movie.
• getProperty(Name)
.
• setProperty(Name)
.
• connect()
.
• disconnect()
.
• keyboardSendCAD()
.
• keyboardSendScancodes(Scancodes)
.
303
12 RDP Web Control
304