1. A method for monitoring a virtual machine, the method comprising: copying, by a processor, a program module into a non-swappable area of memory previously allocated to the virtual machine; halting, by the processor, execution of an operating system in the virtual machine; loading, by the processor, the program module for execution as part of a kernel of the operating system; restarting, by the processor, the operating system; initiating, by the processor, execution of the program module in the kernel of the operating system, the program module including first program instructions to load an agent program into a swappable area of memory previously allocated to the virtual machine and initiate execution of the loaded agent program as an application program whose execution is controlled by the operating system, the agent program including second program instructions to perform a task for monitoring the virtual machine; and executing, by the processor, the second program instructions of the loaded agent program to perform the task when the execution of the loaded agent program is initiated.