Wednesday, December 28, 2011

QEMU Networking


#switch=$(/sbin/ip route list | awk '/^default / { print $5 }') -- error/remove
switch=virbr0 -- correct
/sbin/ifconfig $1 up -- keep
/usr/sbin/brctl addif ${switch} $1 -- keep

#switch=$(/sbin/ip route list | awk '/^default / { print $5 }') -- error/remove
swtich=virbr0 -- correct
/usr/sbin/brctl delif $switch $1 -- keep
/sbin/ifconfig $1 down -- keep

add these parameters to qemu: -net nic,vlan=0 -net tap,vlan=0

Previous Writing:
Write 2 network scripts as below: ( don't forget the chmod +x on each file. )

[root@sitedesign ~]# cat /etc/qemu-ifdown
/sbin/ifconfig virbr0 down
/sbin/ifconfig down $1
/sbin/ifup eth0

[root@sitedesign ~]# cat /etc/qemu-ifup
/sbin/ifconfig $1 promisc up
/usr/sbin/brctl addif virbr0 $1

Then to start the VM:

as root:
#~> qemu-kvm -net nic,vlan=0 -net,tap,vlan=0 -hda winxp.img -hdb winxp_disk2.img -usb -usbdevice tablet -localtime -daemonize
That should start you up with a connection to the default virbr that gets made by fedora at boot time.

(original link)

using CSCOPE

1. build database: cscope -b -q -k -R
2. invoke: cscope -d ... does not create the database again

3: invoke command line:
      find all functions that calls bad_page()
          cscope -d -3 bad_page -L
      find all functions that bad_page() calls
          cscope -d -2 bad_page -L

exit: ctrl_d

Friday, December 16, 2011

Using QEMU for Direct Debugging (INCOMPLETE)

Install kvm-pxe first

kernel build: two places
     inside the vm
     in in the host

make initrd inside vm, copy it to host in the qemu disk directory
copy vmlinux, sysmap and config into qemu disk directory

then run the kernel:
qemu -smp 4 -m 384 -hda ubswapper.img -kernel vmlinuz- -initrd initrd.img- "console=ttyS0,115200n8 root=/dev/sda1 text" -serial stdio > trace

Friday, December 9, 2011

Tracing In Brief

cd /sys/kernel/debug/tracing

# viewing functions
functions are listed in available_filter_function
grep shrink available_filter_function

# viewing tracers
cat available_tracers
function_graph, function are important

# setting function and graph
root@musfiq-Dell-DM051:/sys/kernel/debug/tracing# echo shrink_zone > set_ftrace_filter
root@musfiq-Dell-DM051:/sys/kernel/debug/tracing# echo shrink_zone > set_graph_function

# set tracer
root@musfiq-Dell-DM051:/sys/kernel/debug/tracing# echo function_graph > current_tracer
root@musfiq-Dell-DM051:/sys/kernel/debug/tracing# echo 1 > tracing_on

root@musfiq-Dell-DM051:/sys/kernel/debug/tracing# echo 0 > tracing_on

Thursday, December 8, 2011

Console Over Serial

in kvm, add another serial connection
in kernel boot parameters, add: console=ttyS1
now, all kernel messages will be redirected to ttyS1
if kgdboc=ttyS0, then run gdb on that port.
that's it!

so, now you can debug kernel on one serial port while get the kernel messages on another serial port.