[Solved] Function IConsole::PowerUp() return error rc=VERR_NOT_SUPPORTED

Discussion about using the VirtualBox API, Tutorials, Samples.

[Solved] Function IConsole::PowerUp() return error rc=VERR_NOT_SUPPORTED

Postby siuks24 » 6. May 2019, 15:58

Hi
I'm trying to run virtual machine using vBox API, I can find and lock a virtual machine but I have a problem with power up it.
To power up machine I use function IConsole::PowerUp() but it doesn't work properly, when I looked at the log file I found that error:

00:00:03.775017 VMSetError: /home/vbox/vbox-5.2.28/src/VBox/VMM/VMMR3/VM.cpp(330) int VMR3Create(uint32_t, PCVMM2USERMETHODS, PFNVMATERROR, void*, PFNCFGMCONSTRUCTOR, void*, VM**, UVM**); rc=VERR_NOT_SUPPORTED
00:00:03.775021 VMSetError: Not supported..

I attached full content of log file and source code on the end of this post.

I use:
Ubuntu 18.04 kernel 4.15.0-48-generic
VirtualBox Version 5.2.28 r130011 (Qt5.9.5)
vbox-sdk-5.2.26-128414

I tried to find some information in the Internet but I found nothing.
What's more, when I run the virtual machine using the vBox GUI, everything works fine.
I don't understand whats mean "version unsupported". Which versions are supported? I was trying to run it on several version of vBox but it doesn't work on anything.
Does anyone know what this error means or where can I find a solution?

Log file:
Code: Select all   Expand viewCollapse view
VirtualBox VM 5.2.28 r130011 linux.amd64 (Apr 12 2019 14:51:18) release log
00:00:03.697525 Log opened 2019-05-06T13:30:28.831974000Z
00:00:03.697529 Build Type: release
00:00:03.697540 OS Product: Linux
00:00:03.697544 OS Release: 4.15.0-48-generic
00:00:03.697547 OS Version: #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019
00:00:03.697603 DMI Product Name: HP Pavilion Notebook                   
00:00:03.697627 DMI Product Version: Type1ProductConfigId
00:00:03.697751 Host RAM: 7867MB (7.6GB) total, 3851MB (3.7GB) available
00:00:03.697764 Executable: /home/nomachine/virtualBox/vboxCpp-short/tstVBoxAPIXPCOM
00:00:03.697766 Process ID: 26120
00:00:03.697769 Package type: LINUX_64BITS__UBUNTU_18_04
00:00:03.704520 Installed Extension Packs:
00:00:03.704587   Oracle VM VirtualBox Extension Pack (Version: 5.2.28 r130011; VRDE Module: VBoxVRDP)
00:00:03.705259 Console: Machine state changed to 'Starting'
00:00:03.719615 SUP: Loaded VMMR0.r0 (/usr/lib/virtualbox/VMMR0.r0) at 0xXXXXXXXXXXXXXXXX - ModuleInit at XXXXXXXXXXXXXXXX and ModuleTerm at XXXXXXXXXXXXXXXX
00:00:03.719719 SUP: VMMR0EntryEx located at XXXXXXXXXXXXXXXX and VMMR0EntryFast at XXXXXXXXXXXXXXXX
00:00:03.722461 Guest OS type: 'Ubuntu_64'
00:00:03.725227 fHMForced=true - 64-bit guest
00:00:03.738450 File system of '/home/nomachine/VirtualBox VMs/Ubuntu1/Snapshots' (snapshots) is unknown
00:00:03.738603 File system of '/home/nomachine/VirtualBox VMs/Ubuntu1/Ubuntu1.vdi' is ext4
00:00:03.755412 Shared clipboard service loaded
00:00:03.755434 Shared clipboard mode: Off
00:00:03.756145 Drag and drop service loaded
00:00:03.756161 Drag and drop mode: Off
00:00:03.757009 Guest Control service loaded
00:00:03.765143 ************************* CFGM dump *************************
00:00:03.765146 [/] (level 0)
00:00:03.765161   CSAMEnabled       <integer> = 0x0000000000000001 (1)
00:00:03.765164   CpuExecutionCap   <integer> = 0x0000000000000064 (100)
00:00:03.765165   EnablePAE         <integer> = 0x0000000000000000 (0)
00:00:03.765166   HMEnabled         <integer> = 0x0000000000000001 (1)
00:00:03.765167   MemBalloonSize    <integer> = 0x0000000000000000 (0)
00:00:03.765167   Name              <string>  = "Ubuntu1" (cb=8)
00:00:03.765168   NumCPUs           <integer> = 0x0000000000000001 (1)
00:00:03.765169   PATMEnabled       <integer> = 0x0000000000000001 (1)
00:00:03.765170   PageFusionAllowed <integer> = 0x0000000000000000 (0)
00:00:03.765171   RamHoleSize       <integer> = 0x0000000020000000 (536 870 912, 512 MB)
00:00:03.765173   RamSize           <integer> = 0x0000000040c00000 (1 086 324 736, 1 036 MB)
00:00:03.765174   RawR0Enabled      <integer> = 0x0000000000000001 (1)
00:00:03.765175   RawR3Enabled      <integer> = 0x0000000000000001 (1)
00:00:03.765176   TimerMillies      <integer> = 0x000000000000000a (10)
00:00:03.765177   UUID              <bytes>   = "e6 bb 75 91 e0 ec 8c 4e 83 9e 3d fb 72 2e 09 78" (cb=16)
00:00:03.765181
00:00:03.765182 [/CPUM/] (level 1)
00:00:03.765183   GuestCpuName       <string>  = "host" (cb=5)
00:00:03.765184   PortableCpuIdLevel <integer> = 0x0000000000000000 (0)
00:00:03.765185   SpecCtrl           <integer> = 0x0000000000000000 (0)
00:00:03.765186
00:00:03.765186 [/DBGC/] (level 1)
00:00:03.765187   GlobalInitScript <string>  = "/home/nomachine/.config/VirtualBox/dbgc-init" (cb=45)
00:00:03.765188   HistoryFile      <string>  = "/home/nomachine/.config/VirtualBox/dbgc-history" (cb=48)
00:00:03.765189   LocalInitScript  <string>  = "/home/nomachine/VirtualBox VMs/Ubuntu1/dbgc-init" (cb=49)
00:00:03.765189
00:00:03.765190 [/DBGF/] (level 1)
00:00:03.765191   Path <string>  = "/home/nomachine/VirtualBox VMs/Ubuntu1/debug/;/home/nomachine/VirtualBox VMs/Ubuntu1/;/root/" (cb=93)
00:00:03.765191
00:00:03.765192 [/Devices/] (level 1)
00:00:03.765193
00:00:03.765193 [/Devices/8237A/] (level 2)
00:00:03.765194
00:00:03.765195 [/Devices/8237A/0/] (level 3)
00:00:03.765196   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765196
00:00:03.765197 [/Devices/GIMDev/] (level 2)
00:00:03.765198
00:00:03.765198 [/Devices/GIMDev/0/] (level 3)
00:00:03.765199   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765200
00:00:03.765200 [/Devices/VMMDev/] (level 2)
00:00:03.765201
00:00:03.765201 [/Devices/VMMDev/0/] (level 3)
00:00:03.765203   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765203   PCIDeviceNo   <integer> = 0x0000000000000004 (4)
00:00:03.765204   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765205   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765206
00:00:03.765206 [/Devices/VMMDev/0/Config/] (level 4)
00:00:03.765207   GuestCoreDumpDir <string>  = "/home/nomachine/VirtualBox VMs/Ubuntu1/Snapshots" (cb=49)
00:00:03.765208
00:00:03.765208 [/Devices/VMMDev/0/LUN#0/] (level 4)
00:00:03.765209   Driver <string>  = "HGCM" (cb=5)
00:00:03.765210
00:00:03.765211 [/Devices/VMMDev/0/LUN#0/Config/] (level 5)
00:00:03.765212   Object <integer> = 0x00007fee2c000b70 (140 660 917 144 432)
00:00:03.765213
00:00:03.765214 [/Devices/VMMDev/0/LUN#999/] (level 4)
00:00:03.765215   Driver <string>  = "MainStatus" (cb=11)
00:00:03.765216
00:00:03.765216 [/Devices/VMMDev/0/LUN#999/Config/] (level 5)
00:00:03.765217   First   <integer> = 0x0000000000000000 (0)
00:00:03.765218   Last    <integer> = 0x0000000000000000 (0)
00:00:03.765219   papLeds <integer> = 0x00007fee34001c60 (140 661 051 366 496)
00:00:03.765220
00:00:03.765221 [/Devices/acpi/] (level 2)
00:00:03.765222
00:00:03.765222 [/Devices/acpi/0/] (level 3)
00:00:03.765223   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765224   PCIDeviceNo   <integer> = 0x0000000000000007 (7)
00:00:03.765225   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765225   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765226
00:00:03.765226 [/Devices/acpi/0/Config/] (level 4)
00:00:03.765228   CpuHotPlug          <integer> = 0x0000000000000000 (0)
00:00:03.765229   FdcEnabled          <integer> = 0x0000000000000000 (0)
00:00:03.765229   HostBusPciAddress   <integer> = 0x0000000000000000 (0)
00:00:03.765230   HpetEnabled         <integer> = 0x0000000000000000 (0)
00:00:03.765231   IOAPIC              <integer> = 0x0000000000000001 (1)
00:00:03.765232   IocPciAddress       <integer> = 0x0000000000010000 (65 536)
00:00:03.765233   NumCPUs             <integer> = 0x0000000000000001 (1)
00:00:03.765234   Parallel0IoPortBase <integer> = 0x0000000000000000 (0)
00:00:03.765234   Parallel0Irq        <integer> = 0x0000000000000000 (0)
00:00:03.765235   Parallel1IoPortBase <integer> = 0x0000000000000000 (0)
00:00:03.765236   Parallel1Irq        <integer> = 0x0000000000000000 (0)
00:00:03.765237   Serial0IoPortBase   <integer> = 0x0000000000000000 (0)
00:00:03.765237   Serial0Irq          <integer> = 0x0000000000000000 (0)
00:00:03.765238   Serial1IoPortBase   <integer> = 0x0000000000000000 (0)
00:00:03.765239   Serial1Irq          <integer> = 0x0000000000000000 (0)
00:00:03.765239   ShowCpu             <integer> = 0x0000000000000001 (1)
00:00:03.765240   ShowRtc             <integer> = 0x0000000000000000 (0)
00:00:03.765241   SmcEnabled          <integer> = 0x0000000000000000 (0)
00:00:03.765242
00:00:03.765242 [/Devices/acpi/0/LUN#0/] (level 4)
00:00:03.765243   Driver <string>  = "ACPIHost" (cb=9)
00:00:03.765244
00:00:03.765244 [/Devices/acpi/0/LUN#0/Config/] (level 5)
00:00:03.765246
00:00:03.765246 [/Devices/ahci/] (level 2)
00:00:03.765247
00:00:03.765247 [/Devices/ahci/0/] (level 3)
00:00:03.765248   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765249   PCIDeviceNo   <integer> = 0x000000000000000d (13)
00:00:03.765250   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765250   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765251
00:00:03.765252 [/Devices/ahci/0/Config/] (level 4)
00:00:03.765253   Bootable  <integer> = 0x0000000000000001 (1)
00:00:03.765253   PortCount <integer> = 0x0000000000000001 (1)
00:00:03.765254
00:00:03.765254 [/Devices/ahci/0/Config/Port0/] (level 5)
00:00:03.765256   Hotpluggable <integer> = 0x0000000000000000 (0)
00:00:03.765256
00:00:03.765257 [/Devices/ahci/0/LUN#0/] (level 4)
00:00:03.765258   Driver <string>  = "VD" (cb=3)
00:00:03.765259
00:00:03.765259 [/Devices/ahci/0/LUN#0/Config/] (level 5)
00:00:03.765260   BlockCache <integer> = 0x0000000000000001 (1)
00:00:03.765261   Format     <string>  = "VDI" (cb=4)
00:00:03.765262   Mountable  <integer> = 0x0000000000000000 (0)
00:00:03.765262   Path       <string>  = "/home/nomachine/VirtualBox VMs/Ubuntu1/Ubuntu1.vdi" (cb=51)
00:00:03.765263   Type       <string>  = "HardDisk" (cb=9)
00:00:03.765264   UseNewIo   <integer> = 0x0000000000000001 (1)
00:00:03.765265
00:00:03.765265 [/Devices/ahci/0/LUN#0/Config/Plugins/] (level 6)
00:00:03.765267
00:00:03.765270 [/Devices/ahci/0/LUN#0/Config/Plugins/VDPluginCrypt/] (level 7)
00:00:03.765272   Path <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VDPluginCrypt.so" (cb=100)
00:00:03.765273
00:00:03.765273 [/Devices/ahci/0/LUN#999/] (level 4)
00:00:03.765274   Driver <string>  = "MainStatus" (cb=11)
00:00:03.765275
00:00:03.765275 [/Devices/ahci/0/LUN#999/Config/] (level 5)
00:00:03.765277   DeviceInstance        <string>  = "ahci/0" (cb=7)
00:00:03.765277   First                 <integer> = 0x0000000000000000 (0)
00:00:03.765278   Last                  <integer> = 0x0000000000000000 (0)
00:00:03.765279   pConsole              <integer> = 0x00007fee34001470 (140 661 051 364 464)
00:00:03.765281   papLeds               <integer> = 0x00007fee34001860 (140 661 051 365 472)
00:00:03.765282   pmapMediumAttachments <integer> = 0x00007fee34001c80 (140 661 051 366 528)
00:00:03.765284
00:00:03.765284 [/Devices/apic/] (level 2)
00:00:03.765285
00:00:03.765285 [/Devices/apic/0/] (level 3)
00:00:03.765286   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765287
00:00:03.765287 [/Devices/apic/0/Config/] (level 4)
00:00:03.765289   IOAPIC  <integer> = 0x0000000000000001 (1)
00:00:03.765289   Mode    <integer> = 0x0000000000000003 (3)
00:00:03.765290   NumCPUs <integer> = 0x0000000000000001 (1)
00:00:03.765291
00:00:03.765291 [/Devices/e1000/] (level 2)
00:00:03.765292
00:00:03.765292 [/Devices/e1000/0/] (level 3)
00:00:03.765293   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765294   PCIDeviceNo   <integer> = 0x0000000000000003 (3)
00:00:03.765295   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765295   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765296
00:00:03.765297 [/Devices/e1000/0/Config/] (level 4)
00:00:03.765298   AdapterType    <integer> = 0x0000000000000000 (0)
00:00:03.765298   CableConnected <integer> = 0x0000000000000001 (1)
00:00:03.765299   LineSpeed      <integer> = 0x0000000000000000 (0)
00:00:03.765300   MAC            <bytes>   = "08 00 27 f1 f8 23" (cb=6)
00:00:03.765302
00:00:03.765302 [/Devices/e1000/0/LUN#0/] (level 4)
00:00:03.765303   Driver <string>  = "NAT" (cb=4)
00:00:03.765304
00:00:03.765304 [/Devices/e1000/0/LUN#0/Config/] (level 5)
00:00:03.765306   AliasMode       <integer> = 0x0000000000000000 (0)
00:00:03.765306   BootFile        <string>  = "Ubuntu1.pxe" (cb=12)
00:00:03.765307   DNSProxy        <integer> = 0x0000000000000000 (0)
00:00:03.765308   Network         <string>  = "10.0.2.0/24" (cb=12)
00:00:03.765309   PassDomain      <integer> = 0x0000000000000001 (1)
00:00:03.765309   TFTPPrefix      <string>  = "/home/nomachine/.config/VirtualBox/TFTP" (cb=40)
00:00:03.765310   UseHostResolver <integer> = 0x0000000000000000 (0)
00:00:03.765311
00:00:03.765311 [/Devices/e1000/0/LUN#999/] (level 4)
00:00:03.765312   Driver <string>  = "MainStatus" (cb=11)
00:00:03.765313
00:00:03.765313 [/Devices/e1000/0/LUN#999/Config/] (level 5)
00:00:03.765314   First   <integer> = 0x0000000000000000 (0)
00:00:03.765315   Last    <integer> = 0x0000000000000000 (0)
00:00:03.765316   papLeds <integer> = 0x00007fee34001b40 (140 661 051 366 208)
00:00:03.765317
00:00:03.765318 [/Devices/i8254/] (level 2)
00:00:03.765319
00:00:03.765319 [/Devices/i8254/0/] (level 3)
00:00:03.765320
00:00:03.765320 [/Devices/i8254/0/Config/] (level 4)
00:00:03.765321
00:00:03.765322 [/Devices/i8259/] (level 2)
00:00:03.765323
00:00:03.765323 [/Devices/i8259/0/] (level 3)
00:00:03.765324   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765325
00:00:03.765325 [/Devices/i8259/0/Config/] (level 4)
00:00:03.765326
00:00:03.765326 [/Devices/ichac97/] (level 2)
00:00:03.765327
00:00:03.765328 [/Devices/ichac97/0/] (level 3)
00:00:03.765329   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765329   PCIDeviceNo   <integer> = 0x0000000000000005 (5)
00:00:03.765330   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765331   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765331
00:00:03.765332 [/Devices/ichac97/0/AudioConfig/] (level 4)
00:00:03.765334
00:00:03.765335 [/Devices/ichac97/0/Config/] (level 4)
00:00:03.765336   Codec        <string>  = "AD1980" (cb=7)
00:00:03.765337   DebugEnabled <integer> = 0x0000000000000000 (0)
00:00:03.765337   DebugPathOut <string>  = "" (cb=1)
00:00:03.765338
00:00:03.765338 [/Devices/ichac97/0/LUN#0/] (level 4)
00:00:03.765340   Driver <string>  = "AUDIO" (cb=6)
00:00:03.765340
00:00:03.765341 [/Devices/ichac97/0/LUN#0/AttachedDriver/] (level 5)
00:00:03.765342   Driver <string>  = "PulseAudio" (cb=11)
00:00:03.765343
00:00:03.765343 [/Devices/ichac97/0/LUN#0/AttachedDriver/Config/] (level 6)
00:00:03.765344   StreamName <string>  = "Ubuntu1" (cb=8)
00:00:03.765345
00:00:03.765345 [/Devices/ichac97/0/LUN#0/Config/] (level 5)
00:00:03.765347   BufferSizeMs    <integer> = 0x0000000000000000 (0)
00:00:03.765347   DriverName      <string>  = "PulseAudio" (cb=11)
00:00:03.765348   InputEnabled    <integer> = 0x0000000000000000 (0)
00:00:03.765349   OutputEnabled   <integer> = 0x0000000000000001 (1)
00:00:03.765350   PeriodSizeMs    <integer> = 0x0000000000000000 (0)
00:00:03.765350   PreBufferSizeMs <integer> = 0x00000000ffffffff (4 294 967 295)
00:00:03.765352
00:00:03.765352 [/Devices/ichac97/0/LUN#1/] (level 4)
00:00:03.765353   Driver <string>  = "AUDIO" (cb=6)
00:00:03.765354
00:00:03.765354 [/Devices/ioapic/] (level 2)
00:00:03.765355
00:00:03.765355 [/Devices/ioapic/0/] (level 3)
00:00:03.765356   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765357
00:00:03.765357 [/Devices/ioapic/0/Config/] (level 4)
00:00:03.765358   NumCPUs <integer> = 0x0000000000000001 (1)
00:00:03.765359
00:00:03.765359 [/Devices/mc146818/] (level 2)
00:00:03.765360
00:00:03.765360 [/Devices/mc146818/0/] (level 3)
00:00:03.765361
00:00:03.765362 [/Devices/mc146818/0/Config/] (level 4)
00:00:03.765363   UseUTC <integer> = 0x0000000000000001 (1)
00:00:03.765363
00:00:03.765364 [/Devices/parallel/] (level 2)
00:00:03.765365
00:00:03.765365 [/Devices/pcarch/] (level 2)
00:00:03.765366
00:00:03.765366 [/Devices/pcarch/0/] (level 3)
00:00:03.765367   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765368
00:00:03.765368 [/Devices/pcarch/0/Config/] (level 4)
00:00:03.765369
00:00:03.765370 [/Devices/pcbios/] (level 2)
00:00:03.765377
00:00:03.765377 [/Devices/pcbios/0/] (level 3)
00:00:03.765378   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765378
00:00:03.765379 [/Devices/pcbios/0/Config/] (level 4)
00:00:03.765383   APIC               <integer> = 0x0000000000000001 (1)
00:00:03.765384   BootDevice0        <string>  = "FLOPPY" (cb=7)
00:00:03.765384   BootDevice1        <string>  = "DVD" (cb=4)
00:00:03.765385   BootDevice2        <string>  = "IDE" (cb=4)
00:00:03.765386   BootDevice3        <string>  = "NONE" (cb=5)
00:00:03.765387   FloppyDevice       <string>  = "i82078" (cb=7)
00:00:03.765387   HardDiskDevice     <string>  = "piix3ide" (cb=9)
00:00:03.765388   IOAPIC             <integer> = 0x0000000000000001 (1)
00:00:03.765389   LanBootRom         <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/PXE-Intel.rom" (cb=85)
00:00:03.765390   McfgBase           <integer> = 0x0000000000000000 (0)
00:00:03.765390   McfgLength         <integer> = 0x0000000000000000 (0)
00:00:03.765391   NumCPUs            <integer> = 0x0000000000000001 (1)
00:00:03.765392   PXEDebug           <integer> = 0x0000000000000000 (0)
00:00:03.765393   SataHardDiskDevice <string>  = "ahci" (cb=5)
00:00:03.765394   SataLUN1           <integer> = 0x0000000000000000 (0)
00:00:03.765394   UUID               <bytes>   = "e6 bb 75 91 e0 ec 8c 4e 83 9e 3d fb 72 2e 09 78" (cb=16)
00:00:03.765397
00:00:03.765397 [/Devices/pcbios/0/Config/NetBoot/] (level 5)
00:00:03.765398
00:00:03.765399 [/Devices/pcbios/0/Config/NetBoot/0/] (level 6)
00:00:03.765400   NIC           <integer> = 0x0000000000000000 (0)
00:00:03.765401   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765402   PCIDeviceNo   <integer> = 0x0000000000000003 (3)
00:00:03.765402   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765404
00:00:03.765405 [/Devices/pci/] (level 2)
00:00:03.765406
00:00:03.765406 [/Devices/pci/0/] (level 3)
00:00:03.765407   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765408
00:00:03.765408 [/Devices/pci/0/Config/] (level 4)
00:00:03.765409   IOAPIC <integer> = 0x0000000000000001 (1)
00:00:03.765410
00:00:03.765410 [/Devices/pcibridge/] (level 2)
00:00:03.765411
00:00:03.765411 [/Devices/pckbd/] (level 2)
00:00:03.765412
00:00:03.765413 [/Devices/pckbd/0/] (level 3)
00:00:03.765414   Trusted <integer> = 0x0000000000000001 (1)
00:00:03.765414
00:00:03.765415 [/Devices/pckbd/0/Config/] (level 4)
00:00:03.765416
00:00:03.765416 [/Devices/pckbd/0/LUN#0/] (level 4)
00:00:03.765417   Driver <string>  = "KeyboardQueue" (cb=14)
00:00:03.765418
00:00:03.765418 [/Devices/pckbd/0/LUN#0/AttachedDriver/] (level 5)
00:00:03.765420   Driver <string>  = "MainKeyboard" (cb=13)
00:00:03.765420
00:00:03.765421 [/Devices/pckbd/0/LUN#0/AttachedDriver/Config/] (level 6)
00:00:03.765422   Object <integer> = 0x000055b8040f4f90 (94 248 830 455 696)
00:00:03.765423
00:00:03.765424 [/Devices/pckbd/0/LUN#0/Config/] (level 5)
00:00:03.765425   QueueSize <integer> = 0x0000000000000040 (64)
00:00:03.765426
00:00:03.765426 [/Devices/pckbd/0/LUN#1/] (level 4)
00:00:03.765427   Driver <string>  = "MouseQueue" (cb=11)
00:00:03.765428
00:00:03.765428 [/Devices/pckbd/0/LUN#1/AttachedDriver/] (level 5)
00:00:03.765429   Driver <string>  = "MainMouse" (cb=10)
00:00:03.765430
00:00:03.765430 [/Devices/pckbd/0/LUN#1/AttachedDriver/Config/] (level 6)
00:00:03.765431   Object <integer> = 0x00007fee3400e270 (140 661 051 417 200)
00:00:03.765433
00:00:03.765433 [/Devices/pckbd/0/LUN#1/Config/] (level 5)
00:00:03.765434   QueueSize <integer> = 0x0000000000000080 (128)
00:00:03.765435
00:00:03.765436 [/Devices/pcnet/] (level 2)
00:00:03.765436
00:00:03.765437 [/Devices/piix3ide/] (level 2)
00:00:03.765438
00:00:03.765438 [/Devices/piix3ide/0/] (level 3)
00:00:03.765439   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765440   PCIDeviceNo   <integer> = 0x0000000000000001 (1)
00:00:03.765441   PCIFunctionNo <integer> = 0x0000000000000001 (1)
00:00:03.765441   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765442
00:00:03.765442 [/Devices/piix3ide/0/Config/] (level 4)
00:00:03.765443   Type <string>  = "PIIX4" (cb=6)
00:00:03.765444
00:00:03.765445 [/Devices/piix3ide/0/LUN#0/] (level 4)
00:00:03.765446   Driver <string>  = "VD" (cb=3)
00:00:03.765446
00:00:03.765447 [/Devices/piix3ide/0/LUN#0/Config/] (level 5)
00:00:03.765448   EmptyDrive <integer> = 0x0000000000000001 (1)
00:00:03.765449   Mountable  <integer> = 0x0000000000000001 (1)
00:00:03.765449   Type       <string>  = "DVD" (cb=4)
00:00:03.765450
00:00:03.765450 [/Devices/piix3ide/0/LUN#999/] (level 4)
00:00:03.765451   Driver <string>  = "MainStatus" (cb=11)
00:00:03.765452
00:00:03.765452 [/Devices/piix3ide/0/LUN#999/Config/] (level 5)
00:00:03.765454   DeviceInstance        <string>  = "piix3ide/0" (cb=11)
00:00:03.765454   First                 <integer> = 0x0000000000000000 (0)
00:00:03.765455   Last                  <integer> = 0x0000000000000003 (3)
00:00:03.765456   pConsole              <integer> = 0x00007fee34001470 (140 661 051 364 464)
00:00:03.765458   papLeds               <integer> = 0x00007fee34001840 (140 661 051 365 440)
00:00:03.765459   pmapMediumAttachments <integer> = 0x00007fee34001c80 (140 661 051 366 528)
00:00:03.765460
00:00:03.765461 [/Devices/serial/] (level 2)
00:00:03.765461
00:00:03.765462 [/Devices/usb-ohci/] (level 2)
00:00:03.765463
00:00:03.765463 [/Devices/usb-ohci/0/] (level 3)
00:00:03.765464   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765465   PCIDeviceNo   <integer> = 0x0000000000000006 (6)
00:00:03.765465   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765466   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765467
00:00:03.765467 [/Devices/usb-ohci/0/Config/] (level 4)
00:00:03.765468
00:00:03.765469 [/Devices/usb-ohci/0/LUN#0/] (level 4)
00:00:03.765471   Driver <string>  = "VUSBRootHub" (cb=12)
00:00:03.765471
00:00:03.765472 [/Devices/usb-ohci/0/LUN#0/Config/] (level 5)
00:00:03.765473
00:00:03.765473 [/Devices/usb-ohci/0/LUN#999/] (level 4)
00:00:03.765474   Driver <string>  = "MainStatus" (cb=11)
00:00:03.765475
00:00:03.765475 [/Devices/usb-ohci/0/LUN#999/Config/] (level 5)
00:00:03.765476   First   <integer> = 0x0000000000000000 (0)
00:00:03.765477   Last    <integer> = 0x0000000000000000 (0)
00:00:03.765478   papLeds <integer> = 0x00007fee34001c68 (140 661 051 366 504)
00:00:03.765479
00:00:03.765479 [/Devices/vga/] (level 2)
00:00:03.765480
00:00:03.765481 [/Devices/vga/0/] (level 3)
00:00:03.765482   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:03.765482   PCIDeviceNo   <integer> = 0x0000000000000002 (2)
00:00:03.765483   PCIFunctionNo <integer> = 0x0000000000000000 (0)
00:00:03.765484   Trusted       <integer> = 0x0000000000000001 (1)
00:00:03.765484
00:00:03.765485 [/Devices/vga/0/Config/] (level 4)
00:00:03.765486   CustomVideoModes <integer> = 0x0000000000000000 (0)
00:00:03.765487   FadeIn           <integer> = 0x0000000000000001 (1)
00:00:03.765487   FadeOut          <integer> = 0x0000000000000001 (1)
00:00:03.765488   HeightReduction  <integer> = 0x0000000000000000 (0)
00:00:03.765489   LogoFile         <string>  = "" (cb=1)
00:00:03.765490   LogoTime         <integer> = 0x0000000000000000 (0)
00:00:03.765491   MonitorCount     <integer> = 0x0000000000000001 (1)
00:00:03.765491   ShowBootMenu     <integer> = 0x0000000000000002 (2)
00:00:03.765492   VRamSize         <integer> = 0x0000000001000000 (16 777 216, 16 MB)
00:00:03.765493
00:00:03.765494 [/Devices/vga/0/LUN#0/] (level 4)
00:00:03.765495   Driver <string>  = "MainDisplay" (cb=12)
00:00:03.765496
00:00:03.765496 [/Devices/vga/0/LUN#0/Config/] (level 5)
00:00:03.765497   Object <integer> = 0x00007fee34003110 (140 661 051 371 792)
00:00:03.765498
00:00:03.765499 [/Devices/vga/0/LUN#999/] (level 4)
00:00:03.765500   Driver <string>  = "MainStatus" (cb=11)
00:00:03.765500
00:00:03.765501 [/Devices/vga/0/LUN#999/Config/] (level 5)
00:00:03.765502   First   <integer> = 0x0000000000000000 (0)
00:00:03.765503   Last    <integer> = 0x0000000000000000 (0)
00:00:03.765503   papLeds <integer> = 0x00007fee34001c78 (140 661 051 366 520)
00:00:03.765505
00:00:03.765505 [/Devices/virtio-net/] (level 2)
00:00:03.765506
00:00:03.765506 [/EM/] (level 1)
00:00:03.765507   TripleFaultReset <integer> = 0x0000000000000000 (0)
00:00:03.765508
00:00:03.765508 [/GIM/] (level 1)
00:00:03.765509   Provider <string>  = "KVM" (cb=4)
00:00:03.765510
00:00:03.765510 [/HM/] (level 1)
00:00:03.765511   64bitEnabled       <integer> = 0x0000000000000001 (1)
00:00:03.765512   EnableLargePages   <integer> = 0x0000000000000000 (0)
00:00:03.765512   EnableNestedPaging <integer> = 0x0000000000000001 (1)
00:00:03.765513   EnableUX           <integer> = 0x0000000000000001 (1)
00:00:03.765514   EnableVPID         <integer> = 0x0000000000000001 (1)
00:00:03.765515   Exclusive          <integer> = 0x0000000000000001 (1)
00:00:03.765515   HMForced           <integer> = 0x0000000000000001 (1)
00:00:03.765516   IBPBOnVMEntry      <integer> = 0x0000000000000000 (0)
00:00:03.765517   IBPBOnVMExit       <integer> = 0x0000000000000000 (0)
00:00:03.765518   L1DFlushOnSched    <integer> = 0x0000000000000001 (1)
00:00:03.765518   L1DFlushOnVMEntry  <integer> = 0x0000000000000000 (0)
00:00:03.765519   SpecCtrlByHost     <integer> = 0x0000000000000000 (0)
00:00:03.765520
00:00:03.765520 [/MM/] (level 1)
00:00:03.765521   CanUseLargerHeap <integer> = 0x0000000000000000 (0)
00:00:03.765522
00:00:03.765522 [/PDM/] (level 1)
00:00:03.765523
00:00:03.765523 [/PDM/AsyncCompletion/] (level 2)
00:00:03.765524
00:00:03.765524 [/PDM/AsyncCompletion/File/] (level 3)
00:00:03.765525
00:00:03.765526 [/PDM/AsyncCompletion/File/BwGroups/] (level 4)
00:00:03.765527
00:00:03.765527 [/PDM/BlkCache/] (level 2)
00:00:03.765528   CacheSize <integer> = 0x0000000000500000 (5 242 880, 5 MB)
00:00:03.765529
00:00:03.765530 [/PDM/Devices/] (level 2)
00:00:03.765532
00:00:03.765532 [/PDM/Devices/VBoxEhci/] (level 3)
00:00:03.765533   Path         <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxEhciR3.so" (cb=97)
00:00:03.765534   R0SearchPath <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64" (cb=83)
00:00:03.765535   RCSearchPath <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64" (cb=83)
00:00:03.765536
00:00:03.765536 [/PDM/Devices/VBoxNvme/] (level 3)
00:00:03.765537   Path         <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxNvmeR3.so" (cb=97)
00:00:03.765538   R0SearchPath <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64" (cb=83)
00:00:03.765538   RCSearchPath <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64" (cb=83)
00:00:03.765539
00:00:03.765539 [/PDM/Devices/VBoxPciRaw/] (level 3)
00:00:03.765541   Path         <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxPciRawR3.so" (cb=99)
00:00:03.765541   R0SearchPath <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64" (cb=83)
00:00:03.765542
00:00:03.765542 [/PDM/Drivers/] (level 2)
00:00:03.765543
00:00:03.765544 [/PDM/Drivers/DrvHostWebcam/] (level 3)
00:00:03.765544   Path <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxHostWebcam.so" (cb=101)
00:00:03.765545
00:00:03.765546 [/PDM/Drivers/VBoxC/] (level 3)
00:00:03.765547   Path <string>  = "/usr/lib/virtualbox/components/VBoxC" (cb=37)
00:00:03.765547
00:00:03.765548 [/PDM/Drivers/VBoxPciRawDrv/] (level 3)
00:00:03.765549   Path <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxPciRawDrv.so" (cb=100)
00:00:03.765549
00:00:03.765550 [/PDM/NetworkShaper/] (level 2)
00:00:03.765550
00:00:03.765551 [/PDM/NetworkShaper/BwGroups/] (level 3)
00:00:03.765552
00:00:03.765552 [/PDM/USB/] (level 2)
00:00:03.765553
00:00:03.765553 [/PDM/USB/VBoxUsbCardReader/] (level 3)
00:00:03.765554   Path <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxUsbCardReaderR3.so" (cb=106)
00:00:03.765555
00:00:03.765555 [/PDM/USB/VBoxUsbWebcam/] (level 3)
00:00:03.765556   Path <string>  = "/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack/linux.amd64/VBoxUsbWebcamR3.so" (cb=102)
00:00:03.765557
00:00:03.765557 [/TM/] (level 1)
00:00:03.765558   UTCOffset <integer> = 0x0000000000000000 (0)
00:00:03.765559
00:00:03.765559 [/USB/] (level 1)
00:00:03.765560
00:00:03.765560 [/USB/HidMouse/] (level 2)
00:00:03.765561
00:00:03.765562 [/USB/HidMouse/0/] (level 3)
00:00:03.765563
00:00:03.765563 [/USB/HidMouse/0/Config/] (level 4)
00:00:03.765564   Mode <string>  = "absolute" (cb=9)
00:00:03.765565
00:00:03.765565 [/USB/HidMouse/0/LUN#0/] (level 4)
00:00:03.765566   Driver <string>  = "MouseQueue" (cb=11)
00:00:03.765567
00:00:03.765567 [/USB/HidMouse/0/LUN#0/AttachedDriver/] (level 5)
00:00:03.765568   Driver <string>  = "MainMouse" (cb=10)
00:00:03.765569
00:00:03.765569 [/USB/HidMouse/0/LUN#0/AttachedDriver/Config/] (level 6)
00:00:03.765570   Object <integer> = 0x00007fee3400e270 (140 661 051 417 200)
00:00:03.765572
00:00:03.765572 [/USB/HidMouse/0/LUN#0/Config/] (level 5)
00:00:03.765573   QueueSize <integer> = 0x0000000000000080 (128)
00:00:03.765574
00:00:03.765574 [/USB/USBProxy/] (level 2)
00:00:03.765575
00:00:03.765576 [/USB/USBProxy/GlobalConfig/] (level 3)
00:00:03.765577
00:00:03.765577 ********************* End of CFGM dump **********************
00:00:03.765581 VM: fHMEnabled=true  (configured) fRecompileUser=false fRecompileSupervisor=false
00:00:03.765583 VM: fRawRing1Enabled=false CSAM=true  PATM=true
00:00:03.765662 HM: HMR3Init: VT-x w/ nested paging and unrestricted guest execution hw support
00:00:03.765688 MM: cbHyperHeap=0x100000 (1048576)
00:00:03.766402 CPUM: fXStateHostMask=0x7; initial: 0x7; host XCR0=0x1f
00:00:03.767436 CPUM: Matched host CPU INTEL 0x6/0x4e/0x3 Intel_Core7_Skylake with CPU DB entry 'Intel Core i7-6700K' (INTEL 0x6/0x5e/0x3 Intel_Core7_Skylake)
00:00:03.767485 CPUM: MXCSR_MASK=0xffff (host: 0xffff)
00:00:03.767511 CPUM: Microcode revision 0x000000C6
00:00:03.767522 CPUM: Changing leaf 13[0]: EBX=0x440 -> 0x340, ECX=0x440 -> 0x340
00:00:03.767534 CPUM: MSR/CPUID reconciliation insert: 0x0000010b IA32_FLUSH_CMD
00:00:03.767756 PGM: HCPhysInterPD=00000000717c7000 HCPhysInterPaePDPT=0000000074e22000 HCPhysInterPaePML4=00000000669de000
00:00:03.767766 PGM: apInterPTs={000000007086d000,000000003d146000} apInterPaePTs={00000001a0b7c000,000000025bc76000} apInterPaePDs={0000000169be6000,000000013f436000,000000012915f000,000000012915c000} pInterPaePDPT64=0000000077e05000
00:00:03.767774 PGM: Host paging mode: AMD64+PGE+NX
00:00:03.767779 PGM: PGMPool: cMaxPages=560 (u64MaxPages=551)
00:00:03.767784 PGM: pgmR3PoolInit: cMaxPages=0x230 cMaxUsers=0x460 cMaxPhysExts=0x460 fCacheEnable=true
00:00:03.774187 TM: GIP - u32Mode=3 (Invariant) u32UpdateHz=83 u32UpdateIntervalNS=12000000 enmUseTscDelta=2 (Pratically Zero) fGetGipCpu=0xb cCpus=4
00:00:03.774214 TM: GIP - u64CpuHz=2 399 995 073 (0x8f0d04c1)  SUPGetCpuHzFromGip => 2 399 995 073
00:00:03.774225 TM: GIP - CPU: iCpuSet=0x0 idCpu=0x0 idApic=0x0 iGipCpu=0x0 i64TSCDelta=0 enmState=3 u64CpuHz=2399995073(*) cErrors=0
00:00:03.774232 TM: GIP - CPU: iCpuSet=0x1 idCpu=0x1 idApic=0x2 iGipCpu=0x1 i64TSCDelta=0 enmState=3 u64CpuHz=2399986244(*) cErrors=0
00:00:03.774237 TM: GIP - CPU: iCpuSet=0x2 idCpu=0x2 idApic=0x1 iGipCpu=0x3 i64TSCDelta=0 enmState=3 u64CpuHz=2399994167(*) cErrors=0
00:00:03.774242 TM: GIP - CPU: iCpuSet=0x3 idCpu=0x3 idApic=0x3 iGipCpu=0x2 i64TSCDelta=0 enmState=3 u64CpuHz=2399994970(*) cErrors=0
00:00:03.774283 TM: cTSCTicksPerSecond=2 399 995 073 (0x8f0d04c1) enmTSCMode=3 (Dynamic)
00:00:03.774285 TM: TSCTiedToExecution=false TSCNotTiedToHalt=false
00:00:03.775017 VMSetError: /home/vbox/vbox-5.2.28/src/VBox/VMM/VMMR3/VM.cpp(330) int VMR3Create(uint32_t, PCVMM2USERMETHODS, PFNVMATERROR, void*, PFNCFGMCONSTRUCTOR, void*, VM**, UVM**); rc=VERR_NOT_SUPPORTED
00:00:03.775021 VMSetError: Not supported.
00:00:03.826316 ERROR [COM]: aRC=NS_ERROR_FAILURE (0x80004005) aIID={872da645-4a9b-1727-bee2-5585105b9eed} aComponent={ConsoleWrap} aText={Not supported. (VERR_NOT_SUPPORTED)}, preserve=false aResultDetail=0
00:00:03.826459 Console: Machine state changed to 'PoweredOff'
00:00:03.831298 Power up failed (vrc=VERR_NOT_SUPPORTED, rc=NS_ERROR_FAILURE (0X80004005))

Source code:
Code: Select all   Expand viewCollapse view
#include <stdio.h>
#include <stdlib.h>
#include <iconv.h>
#include <time.h>
#include <unistd.h>

#include <nsMemory.h>
#include <nsString.h>
#include <nsIServiceManager.h>
#include <nsEventQueueUtils.h>

#include <nsIExceptionService.h>

#include "VirtualBox_XPCOM.h"

char *nsIDToString(nsID *guid);
void printErrorInfo();

int main()
{
    if (sizeof(PRUnichar) != sizeof(wchar_t))
    {
        printf("Error: sizeof(PRUnichar) {%lu} != sizeof(wchar_t) {%lu}!\n"
               "Probably, you forgot the -fshort-wchar compiler option.\n",
               (unsigned long) sizeof(PRUnichar),
               (unsigned long) sizeof(wchar_t));
        return -1;
    }

    nsresult rc;

    {
        nsCOMPtr<nsIServiceManager> serviceManager;
        rc = NS_InitXPCOM2(getter_AddRefs(serviceManager), nsnull, nsnull);
        if (NS_FAILED(rc))
        {
            printf("Error: XPCOM could not be initialized! rc=%#x\n", rc);
            return -1;
        }

        nsCOMPtr<nsIEventQueue> eventQ;
        rc = NS_GetMainEventQ(getter_AddRefs(eventQ));
        if (NS_FAILED(rc))
        {
            printf("Error: could not get main event queue! rc=%#x\n", rc);
            return -1;
        }

        //
        // nsIComponentManager.
        //

        nsCOMPtr<nsIComponentManager> manager;
        rc = NS_GetComponentManager(getter_AddRefs(manager));
        if (NS_FAILED(rc))
        {
            printf("Error: could not get component manager! rc=%#x\n", rc);
            return -1;
        }

        //
        // ISession.
        //

        nsCOMPtr<ISession> session;

        rc = manager->CreateInstanceByContractID(NS_SESSION_CONTRACTID,
                                                 nsnull,
                                                 NS_GET_IID(ISession),
                                                 getter_AddRefs(session));
        if (NS_FAILED(rc))
        {
            printf("Error, could not instantiate session object! rc=%#x\n", rc);
            return -1;
        }
       
        //
        // IVirtualBox.
        //

        nsCOMPtr<IVirtualBox> virtualBox;
        rc = manager->CreateInstanceByContractID(NS_VIRTUALBOX_CONTRACTID,
                                                 nsnull,
                                                 NS_GET_IID(IVirtualBox),
                                                 getter_AddRefs(virtualBox));
        if (NS_FAILED(rc))
        {
            printf("Error, could not instantiate VirtualBox object! rc=%#x\n", rc);
            return -1;
        }
        printf("VirtualBox object created\n");

        //
        // Get the list of all registered VMs.
        //

        IMachine **machines = NULL;
        unsigned int machineCnt = 0;

        rc = virtualBox->GetMachines(&machineCnt, &machines);
        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR: Cannot get machines. rc=%#x.\n", rc);
            return -1;
        }

        //
        // Iterate through the collection.
        //
       
        printf("----------------------------------------------------\n");
        printf("VM List:\n\n");

        for (int i = 0; i < machineCnt; ++ i)
        {
            IMachine *machine = machines[i];
            if (machine)
            {
                PRBool isAccessible = PR_FALSE;
                machine->GetAccessible(&isAccessible);

                if (isAccessible)
                {
                    nsXPIDLString machineName;
                    machine->GetName(getter_Copies(machineName));
                    char *machineNameAscii = ToNewCString(machineName);
                    printf("\t%d):   %s\n", i, machineNameAscii);
                    free(machineNameAscii);
                }
                else
                {
                    printf("\tName:        <inaccessible>\n");
                }

                /* don't forget to release the objects in the array... */
                //machine->Release();
            }
        }

        printf("----------------------------------------------------\n\n");

        //
        // Chose machie to run/connect.
        //

        printf("Type Machine# to start (0 - %u): ", (unsigned)(machineCnt - 1));
        fflush(stdout);

        unsigned start_id;

        if (scanf("%u", &start_id) != 1 || start_id >= machineCnt)
        {
            printf("--> LOG: ERROR Wrong input value.\n");
            return -1;
        }

        printf("--> LOG: Selected machine %d.\n", start_id);

        IMachine *machine = machines[start_id];

        if (machine == NULL)
        {
            printf("--> LOG: ERROR Cannot get machine.\n");
            return -1;
        }

        //
        // Check machine status.
        // List of statuses:
        // https://www.virtualbox.org/sdkref/_virtual_box_8idl.html#a80b08f71210afe16038e904a656ed9eb
        //

        unsigned int machineState;

        rc = machine->GetState(&machineState);
        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR Cannot get status. rc=%#x\n", rc);
            return -1;
        }


        printf("\033[0;32m");
        printf("--> LOG: Machine state: Machine is poweroff.\n");
        printf("\033[0m");

        //
        // Check sesion state.
        // List of sesion states:
        // https://www.virtualbox.org/sdkref/_virtual_box_8idl.html#ac82c179a797c0d7c249d1b98a8e3aa8f
        //

        const static char* sessionStates[] = {"SessionState_Null",
                                                "SessionState_Unlocked",
                                                "SessionState_Locked",
                                                "SessionState_Spawning",
                                                "SessionState_Unlocking"};

        unsigned sessionState;

        rc = machine->GetSessionState(&sessionState);

        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR Cannot get sesion state. rc=%#x\n", rc);
            return -1;
        }

        printf("--> LOG: Got sesion state: %s.\n", sessionStates[sessionState]);

        //
        // Lock state.
        //

        rc = machine->LockMachine(session, LockType::VM);
       
        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR Cannot get lock state. rc=%#x\n", rc);
            return -1;
        }

        printf("--> LOG: Locked session.\n");

        //
        // Get IConsole.
        //

        IConsole *console = NULL;

        rc = session->GetConsole(&console);

        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR Cannot get console. rc=%#x\n", rc);
            return -1;
        }

        printf("--> LOG: Got Console.\n");

        //
        // Get display.
        //

        IDisplay *display = NULL;

        rc = console->GetDisplay(&display);

        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR Cannot get display. rc=%#x\n", rc);
            return -1;
        }

        printf("--> LOG: Got Display.\n");

        //
        // Run Machine
        //

        IProgress *progress = NULL;
        int completed;

        rc = console->PowerUp(&progress);

        if (NS_FAILED(rc))
        {
            printf("--> LOG: ERROR Cannot start virtual machine. rc=%#x\n", rc);
            session->UnlockMachine();
            return -1;
        }

        rc =  progress->WaitForCompletion(-1);
        if (NS_FAILED(rc)) 
        {
            printf("--> LOG: Error: WaitForCompletion status failed. rc=%#x\n", rc);
            session->UnlockMachine();
            return -1;
        }

        rc = progress->GetCompleted(&completed);

        if (NS_FAILED(rc))
        {
            printf("--> LOG: Error: GetCompleted status failed. rc=%#x\n", rc);
            session->UnlockMachine();
            return -1;
        }

        printf("--> LOG: VM process was started successfully.\n");

        do
        {
            //
            // https://www.virtualbox.org/sdkref/_virtual_box_8idl.html#a80b08f71210afe16038e904a656ed9eb
            //

            rc = machine->GetState(&machineState);
            if (NS_FAILED(rc))
            {
                printf("--> LOG: ERROR Cannot get status. rc=%#x\n", rc);
                session->UnlockMachine();
                return -1;
            }

            switch (machineState)
            {
                case 1:
                    printf("\033[0;35m");
                    printf("--> LOG: Check machine state: MachineState_PoweredOff .\n");
                    printf("\033[0m");
                    break;

                case 5:
                    printf("\033[0;35m");
                    printf("--> LOG: Check machine state: MachineState_Running.\n");
                    printf("\033[0m");
                    break;

                default:
                    printf("\033[0;35m");
                    printf("--> LOG: Check machine state: %d.\n", machineState);
                    printf("\033[0m");
                    break;
            }
           

        }while(machineState == MachineState::Running);

        return 0;
    }
}


//
// Helpers
//

//
// Helper function to convert an nsID into a human readable string
// @returns result string, allocated. Has to be freed using free()
// @param   guid Pointer to nsID that will be converted.
//

char *nsIDToString(nsID *guid)
{
    char *res = (char*)malloc(39);

    if (res != NULL)
    {
        snprintf(res, 39, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
                 guid->m0, (PRUint32)guid->m1, (PRUint32)guid->m2,
                 (PRUint32)guid->m3[0], (PRUint32)guid->m3[1], (PRUint32)guid->m3[2],
                 (PRUint32)guid->m3[3], (PRUint32)guid->m3[4], (PRUint32)guid->m3[5],
                 (PRUint32)guid->m3[6], (PRUint32)guid->m3[7]);
    }
    return res;
}

My program output:
Code: Select all   Expand viewCollapse view
--> LOG: Selected machine 0.
--> LOG: Machine state: Machine is poweroff.
--> LOG: Got sesion state: SessionState_Unlocked.
--> LOG: Locked session.
--> LOG: Got Console.
--> LOG: Got Display.
--> LOG: VM process was started successfully.
--> LOG: Check machine state: MachineState_PoweredOff .
Last edited by siuks24 on 9. Jul 2019, 12:06, edited 2 times in total.
siuks24
 
Posts: 12
Joined: 28. Mar 2019, 18:04

Re: Call function IConsole::PowerUp() cause rc=VERR_NOT_SUPPORTED

Postby LordKaoS » 7. May 2019, 13:02

From the reference for IConsole::powerUp()
Note: This method is only useful for front-ends that want to actually execute virtual machines in their own process (like the VirtualBox or VBoxSDL front-ends). Unless you are intending to write such a front-end, do not call this method. If you simply want to start virtual machine execution using one of the existing front-ends (for example the VirtualBox GUI or headless server), use IMachine::launchVMProcess() instead; these front-ends will power up the machine automatically for you.
LordKaoS
 
Posts: 11
Joined: 29. Oct 2018, 09:04
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Ubuntu 18.04, MS Windows 7

Re: Call function IConsole::PowerUp() cause rc=VERR_NOT_SUPPORTED

Postby siuks24 » 7. May 2019, 15:53

Thanks LordKaoS but I can't use function IMachine::launchVMProcess(). I need to write something like my own front-end so I need to start VM via IConsole::PowerUp().

On the Internet I've found e-mail with similar problem:
https://www.virtualbox.org/pipermail/vbox-dev/2015-March/012940.html

exactly in this answer someone told that my own front-end require adding my binary to the list of trusted front-ends:
https://www.virtualbox.org/pipermail/vbox-dev/2015-March/012942.html

I'm currently looking for a way to add my binary to trusted list. I hope it will fix this issue but still I'm open to any other ideas.
siuks24
 
Posts: 12
Joined: 28. Mar 2019, 18:04

Re: Function IConsole::PowerUp() return error rc=VERR_NOT_SUPPORTED

Postby siuks24 » 9. Jul 2019, 12:02

I forget to register my component, when I registered my components using code below and I resolved problems with shared libraries all work ok

Code: Select all   Expand viewCollapse view
nsCOMPtr<nsIComponentRegistrar> registrar =  NULL;

    registrar = do_QueryInterface(serviceManager);

    if (registrar == NULL)
    {
        return -1;
    }

    registrar->AutoRegister(nsnull);
siuks24
 
Posts: 12
Joined: 28. Mar 2019, 18:04


Return to The VirtualBox API

Who is online

Users browsing this forum: No registered users and 1 guest