Out of mem - no RuntimeError event raised

Discussion about using the VirtualBox API, Tutorials, Samples.
Post Reply
rousseauhk
Posts: 45
Joined: 8. Apr 2013, 09:16
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu Server
Contact:

Out of mem - no RuntimeError event raised

Post by rousseauhk »

I am listening to all VBox events in a separate thread, but when I started a machine that ran out of memory, I didnt get the expected RuntimeError event (only the machine status changed to Paused).

Here is the relevant log from the machine:

Code: Select all

00:00:20.164397 PGM: Failed to procure handy pages; rc=VERR_NO_MEMORY rcAlloc=VINF_SUCCESS rcSeed=VINF_SUCCESS cHandyPages=0x10
00:00:20.164415      cAllPages=0x20c46 cPrivatePages=0x999b cSharedPages=0x0 cZeroPages=0x17287
00:00:20.164545 GMM: Statistics:
00:00:20.164547      Allocated pages: 8da7
00:00:20.164553      Maximum   pages: 2009e
00:00:20.164556      Ballooned pages: 0
00:00:20.171731 VM: Raising runtime error 'HostMemoryLow' (fFlags=0x2)
00:00:20.172457 Changing the VM state from 'RUNNING' to 'SUSPENDING'.
00:00:20.173069 PDMR3Suspend: after     0 ms, 1 loops: 1 async tasks - ahci/0
00:00:20.190929 PGM: Failed to procure handy pages; rc=VERR_NO_MEMORY rcAlloc=VINF_SUCCESS rcSeed=VINF_SUCCESS cHandyPages=0x8
00:00:20.190933      cAllPages=0x20c46 cPrivatePages=0x9fb3 cSharedPages=0x0 cZeroPages=0x16c6f
00:00:20.195708 GMM: Statistics:
00:00:20.195709      Allocated pages: 93b7
00:00:20.195712      Maximum   pages: 2009e
00:00:20.195713      Ballooned pages: 0
00:00:20.232641 AIOMgr: Preparing flush failed with VERR_NOT_SUPPORTED, disabling async flushes
00:00:20.313533 AIOMgr: Endpoint for file 'C:\Users\steve\AppData\Local\Temp\20130602233819.vdi' (flags 000c0781) created successfully
00:00:20.426681 PDMR3Suspend: 253 616 464 ns run time
00:00:20.426727 Changing the VM state from 'SUSPENDING' to 'SUSPENDED'.
00:00:20.427060 Console: VM runtime error: fatal=false, errorID=HostMemoryLow message="Unable to allocate and lock memory. The virtual machine will be paused. Please close applications to free up memory or close the VM"


And here is the code. Am I missing something?

Code: Select all

            
            //subscribe to all events
            VirtualBox.VirtualBox box = new VirtualBox.VirtualBox();
            IEventSource events = box.EventSource;
            IEventListener listener = events.CreateListener();
            VBoxEventType[] subscriptions = new VBoxEventType[] {VBoxEventType.VBoxEventType_Any};
            events.RegisterListener(listener, subscriptions, 0);

            //process events
            while(active)
            {
                IEvent eventItem = events.GetEvent(listener, 10000);
                if(eventItem != null)
                {
                    Logger.Debug("EVENT:" + eventItem.Type.ToString());
                    switch (eventItem.Type)
                    {
                        case VBoxEventType.VBoxEventType_OnMachineStateChanged:

                            //machine state changed - this works fine
                            IMachineStateChangedEvent stateChange = (IMachineStateChangedEvent)eventItem;
                            Logger.Debug("EVENT: MACHINE:" + stateChange.MachineId + ", " + stateChange.State);
                            //notify listeners
                            if (VMMachineStateChange != null)
                                VMMachineStateChange(null, new VMEventArgs(stateChange.MachineId, stateChange.State.ToString()));
                            break;

                        case VBoxEventType.VBoxEventType_OnRuntimeError:

                            //report any runtime error - this code is never triggered
                            IRuntimeErrorEvent errorEvent = (IRuntimeErrorEvent)eventItem;
                            XLogger.Error("Error detected in VirtualBox VM Environment: " + errorEvent.Id + ", " + errorEvent.Message + ", " + errorEvent.Fatal);
                            break;
                    }
                    events.EventProcessed(listener, eventItem);
                }
            }

            //shutdown cleanly
            events.UnregisterListener(listener);
        }
/Steve
Post Reply