== [0] Boot the guest == ########################################################################## [kashyap@moon kvm]$ ./kvm run --balloon -k ../../arch/x86/boot/bzImage # kvm run -k ../../arch/x86/boot/bzImage -m 448 -c 4 --name guest-31362 . . . [ 1.505724] Bluetooth: BNEP filters: protocol multicast [ 1.508899] Bluetooth: HIDP (Human Interface Emulation) ver 1.2 [ 1.511511] lib80211: common routines for IEEE802.11 drivers [ 1.513885] Installing 9P2000 support [ 1.517080] Registering the dns_resolver key type [ 1.518737] Magic number: 15:85:793 [ 1.520495] BIOS EDD facility v0.16 2004-Jun-25, 0 devices found [ 1.523497] EDD information not available. [ 1.537035] Sending DHCP requests ., OK [ 1.558038] IP-Config: Got DHCP answer from 192.168.33.1, my address is 192.168.33.15 [ 1.560257] IP-Config: Complete: [ 1.561163] device=eth0, addr=192.168.33.15, mask=255.255.255.0, gw=192.168.33.1, [ 1.563257] host=192.168.33.15, domain=, nis-domain=(none), [ 1.564861] bootserver=192.168.33.1, rootserver=0.0.0.0, rootpath= [ 1.567199] VFS: Unable to mount root fs via NFS, trying floppy. [ 1.574154] VFS: Mounted root (9p filesystem) on device 0:13. [ 1.576080] devtmpfs: mounted [ 1.578602] Freeing unused kernel memory: 512k freed [ 1.580356] Write protecting the kernel read-only data: 12288k [ 1.591640] Freeing unused kernel memory: 1916k freed [ 1.601083] Freeing unused kernel memory: 1436k freed Mounting... Starting '/bin/sh'... sh-4.2# ########################################################################## == [1] kvm 'stat' test == To get memory statistics, we need to run the guest w/ virtio --ballon option like: ################################################################## [kashyap@moon kvm]$ ./kvm run --balloon -k ../../arch/x86/boot/bzImage ################################################################## (Thanks to Sasha) Result: Successful memory statistics when kvm 'stat' is run ################################################################## [kashyap@moon kvm]$ ./kvm stat -m --all *** Guest memory statistics *** The amount of memory that has been swapped in (in bytes):0 The amount of memory that has been swapped out to disk (in bytes):0 The number of major page faults that have occurred:40 The number of minor page faults that have occurred:495 The amount of memory not being used for any purpose (in bytes):438673408 The total amount of memory available (in bytes):449032192 [kashyap@moon kvm]$ ################################################################## == [2] kvm 'pause' / 'resume' test == Find out the running list instances, and pause the guest ################################################################## [kashyap@moon kvm]$ ./kvm list -i PID GUEST 31362 guest-31362 [kashyap@moon kvm]$ ./kvm pause -n guest-31362 [kashyap@moon kvm]$ ################################################################## Result: On the serial console, guest is paused. ################################################################## [ 1.482720] Freeing unused kernel memory: 1916k freed [ 1.492068] Freeing unused kernel memory: 1436k freed Mounting... Starting '/bin/sh'... sh-4.2# Info: Guest paused ################################################################## Now, resume the guest: [kashyap@moon kvm]$ ./kvm resume -n guest-31362 [kashyap@moon kvm]$ Result: On the serial console, guest is resumed ################################################################## Starting '/bin/sh'... sh-4.2# Info: Guest paused Info: Guest resumed ################################################################## == [3] kvm 'balloon' inflate/deflate test == [3a] Test kvm balloon inflate (meaning: return some memory from guest to host) ################################################################## [kashyap@moon kvm]$ ./kvm balloon -n guest-31362 --inflate 10 [kashyap@moon kvm]$ ################################################################## Now, run the memory status again, 10485760 bytes(10MB) is now hot-removed from the guest. (compare it w/ test [1]) from the guest(and returned to the host) ################################################################## [kashyap@moon kvm]$ ./kvm stat -m --all *** Guest memory statistics *** The amount of memory that has been swapped in (in bytes):0 The amount of memory that has been swapped out to disk (in bytes):0 The number of major page faults that have occurred:40 The number of minor page faults that have occurred:502 The amount of memory not being used for any purpose (in bytes):428339200 The total amount of memory available (in bytes):438546432 [kashyap@moon kvm]$ ################################################################## [3b] Test kvm balloon deflate (meaning: return the previously inflated memory back from host to guest) ################################################################## [kashyap@moon kvm]$ ./kvm balloon -n guest-31362 --deflate 10 [kashyap@moon kvm]$ ################################################################## Now, run the memory status again, 10485760 bytes(10MB) is now hot-added back to the guest. (compare it w/ test [1]) from the guest(and returned to the host) ################################################################## [kashyap@moon kvm]$ ./kvm stat -m --all *** Guest memory statistics *** The amount of memory that has been swapped in (in bytes):0 The amount of memory that has been swapped out to disk (in bytes):0 The number of major page faults that have occurred:40 The number of minor page faults that have occurred:502 The amount of memory not being used for any purpose (in bytes):436846592 The total amount of memory available (in bytes):449032192 [kashyap@moon kvm]$ ################################################################## [3c] Negative test: Inflate 10MB, and defulate 20MB : ################################################################## [kashyap@moon kvm]$ ./kvm balloon -n guest-31362 --inflate 10 [kashyap@moon kvm]$ ./kvm stat -m --all *** Guest memory statistics *** The amount of memory that has been swapped in (in bytes):0 The amount of memory that has been swapped out to disk (in bytes):0 The number of major page faults that have occurred:40 The number of minor page faults that have occurred:502 The amount of memory not being used for any purpose (in bytes):428847104 The total amount of memory available (in bytes):438546432 ################################################################## [kashyap@moon kvm]$ ./kvm balloon -n guest-31362 --deflate 20 [kashyap@moon kvm]$ ./kvm stat -m --all *** Guest memory statistics *** The amount of memory that has been swapped in (in bytes):0 The amount of memory that has been swapped out to disk (in bytes):0 The number of major page faults that have occurred:40 The number of minor page faults that have occurred:502 The amount of memory not being used for any purpose (in bytes):428847104 The total amount of memory available (in bytes):438546432 [kashyap@moon kvm]$ ##################################################################