What Every C programmer should know about undefined behavior Part 1
This blog focusses mainly on the Kernel Resource Management infrastructure available in Linux, Completely Fair Scheduler (CFS), & Virtualization. The postings on this blog are my own and doesn’t necessarily represent the view of my employer.
Thursday, May 19, 2011
Undefined Behavior in C
A few excellent articles on the undefined behavior of C programming language.
What Every C programmer should know about undefined behavior Part 1
What Every C programmer should know about undefined behavior Part 1
Monday, April 11, 2011
Native Linux KVM tool
I recently came across native Linux KVM tool developed by Pekka Enberg and team. Its pretty simple and cool. Just 5 KLOC and it provides a wonderful opportunity to learn the basics of virtualization. You can read the announcement here.
The setup for this tool is very simple. The steps given by the developer just works fine. Make sure that you have Ext2 / Ext3 / Ext4 file systems are built as part of your kernel. This will be handy if you are only giving a kernel image. Like any other virtualization solution kvm tool also require a disk image to get started with. You can create your own disk file or try to get a working one from qemu wiki.
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.37 (root@hs22) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #2 SMP Sat Apr 9 01:05:10 IST 2011
Command line: notsc nolapic noacpi pci=conf1 console=ttyS0 root=/dev/vda rw
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 00000000000fffff (reserved)
BIOS-e820: 0000000000100000 - 0000000004000000 (usable)
NX (Execute Disable) protection: active
DMI not present or invalid.
[..............................................................................................]
Freeing unused kernel memory: 1476k freed
Write protecting the kernel read-only data: 10240k
Freeing unused kernel memory: 768k freed
Freeing unused kernel memory: 1720k freed
EXT4-fs (vda): re-mounted. Opts:
mount: mount point /dev/pts does not exist
Linux version 2.6.37 (root@hs22) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #2 SMP Sat Apr 9 01:05:10 IST 2011
QEMU Linux test distribution (based on Redhat 9)
Type 'exit' to halt the system
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
SIOCADDRT: No such process
sh-2.05b#
Wow! There you go. We have a minimal shell.
sh-2.05b# ls
20thfull.mp2 nbench
You can also have a initrd built and give that as a parameter.
[root@hs22 kernels]# linux-kvm/tools/kvm/kvm --image=./linux-0.2.img --kernel=linux-kvm/arch/x86/boot/bzImage --initrd=./initrd.img
[root@hs22 kernels]# linux-kvm/tools/kvm/kvm
usage: linux-kvm/tools/kvm/kvm [--single-step] [--ioport-debug] [--kvm-dev=<device>] [--mem=<size-in-MiB>] [--params=<kernel-params>] [--initrd=<initrd>] [--kernel=]<kernel-image> [--image=]<disk-image>
As I said earlier its a simple tool with very minimal features. The first thing that might want to get added would be SMP support. I am yet to go through the code. Will be posting the design in another post.
The setup for this tool is very simple. The steps given by the developer just works fine. Make sure that you have Ext2 / Ext3 / Ext4 file systems are built as part of your kernel. This will be handy if you are only giving a kernel image. Like any other virtualization solution kvm tool also require a disk image to get started with. You can create your own disk file or try to get a working one from qemu wiki.
[root@hs22 kernels]# linux-kvm/tools/kvm/kvm --image=./linux-0.2.img --kernel=linux-kvm/arch/x86/boot/bzImage
Initializing cgroup subsys cpu
Linux version 2.6.37 (root@hs22) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #2 SMP Sat Apr 9 01:05:10 IST 2011
Command line: notsc nolapic noacpi pci=conf1 console=ttyS0 root=/dev/vda rw
BIOS-provided physical RAM map:
BIOS-e820: 0000000000000000 - 000000000009fc00 (usable)
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 00000000000fffff (reserved)
BIOS-e820: 0000000000100000 - 0000000004000000 (usable)
NX (Execute Disable) protection: active
DMI not present or invalid.
[..............................................................................................]
Freeing unused kernel memory: 1476k freed
Write protecting the kernel read-only data: 10240k
Freeing unused kernel memory: 768k freed
Freeing unused kernel memory: 1720k freed
EXT4-fs (vda): re-mounted. Opts:
mount: mount point /dev/pts does not exist
Linux version 2.6.37 (root@hs22) (gcc version 4.4.5 20110214 (Red Hat 4.4.5-6) (GCC) ) #2 SMP Sat Apr 9 01:05:10 IST 2011
QEMU Linux test distribution (based on Redhat 9)
Type 'exit' to halt the system
SIOCSIFADDR: No such device
eth0: unknown interface: No such device
SIOCADDRT: No such process
sh-2.05b#
Wow! There you go. We have a minimal shell.
sh-2.05b# ls
20thfull.mp2 nbench
You can also have a initrd built and give that as a parameter.
[root@hs22 kernels]# linux-kvm/tools/kvm/kvm --image=./linux-0.2.img --kernel=linux-kvm/arch/x86/boot/bzImage --initrd=./initrd.img
[root@hs22 kernels]# linux-kvm/tools/kvm/kvm
usage: linux-kvm/tools/kvm/kvm [--single-step] [--ioport-debug] [--kvm-dev=<device>] [--mem=<size-in-MiB>] [--params=<kernel-params>] [--initrd=<initrd>] [--kernel=]<kernel-image> [--image=]<disk-image>
As I said earlier its a simple tool with very minimal features. The first thing that might want to get added would be SMP support. I am yet to go through the code. Will be posting the design in another post.
Subscribe to:
Posts (Atom)