mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-22 05:28:30 +00:00
e249304721ec2d97e3862669ffae03ab6546320e
Milan Kocian writes: I found the crash in virtio-net-rx thread (I can reproduce it every time by 'aptitude update' in VM): traps: virtio-net-rx[28933] general protection ip:7f00dda3d107 sp:7f00c58f4de8 error:0 in libc-2.17.so[7f00dd90f000+1a2000] gdb backtrace: (gdb) bt #0 0x00007fb6a548e107 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x000000000041259c in memcpy_toiovecend (iov=0x7fb68d346ea0, iov@entry=0x7fb68d345e90, kdata=<optimized out>, kdata@entry=0x7fb68d346e90 "", offset=<optimized out>, len=<optimized out>) at util/iovec.c:70 #2 0x000000000040c66d in virtio_net_rx_thread (p=0x23688a0) at virtio/net.c:117 #3 0x00007fb6a5b2ee0e in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0 #4 0x00007fb6a54489ed in clone () from /lib/x86_64-linux-gnu/libc.so.6 I tried to add some printf to diagnose it but it isn't clear to me: virtio_net_rx_thread: before memcpy_toiovecend; copied: 0, len: 18890, iovsize: 4096, realiovsize: 4096 memcpy_toiovecend: offset: 0, len: 4096 memcpy_toiovecend: iov_len: 4096, len: 4096 virtio_net_rx_thread: before memcpy_toiovecend; copied: 4096, len: 18890, iovsize: 4096, realiovsize: 4096 memcpy_toiovecend: offset: 4096, len: 4096 memcpy_toiovecend: iov_len: 4096, len: 4096 memcpy_toiovecend: iov_len: 0, len: 4096 memcpy_toiovecend: iov_len: 0, len: 4096 . N x memcpy_toiovecend: iov_len: 0, len: 4096 . memcpy_toiovecend: iov_len: 0, len: 4096 memcpy_toiovecend: iov_len: 0, len: 4096 memcpy_toiovecend: iov_len: 1519143547641528320, len: 4096 memcpy_toiovecend: iov_len: 193827583623176, len: 4096 ./runlkvm.sh: line 2: 16090 Segmentation fault IMHO problem come when received len size is bigger than maximum of the dst iovec (realiovsize). Only iovec size is copied and in the next run isn't place to copy the rest of len size. Asias He writes: We should skip copied bytes from the buffer not from the iov itself which memcpy_toiovecend does. Reported-and-tested-by: Milan Kocian <milon@wq.cz> Signed-off-by: Asias He <asias.hejun@gmail.com> Signed-off-by: Pekka Enberg <penberg@iki.fi>
Native Linux KVM tool ===================== The goal of this tool is to provide a clean, from-scratch, lightweight KVM host tool implementation that can boot Linux guest images (just a hobby, won't be big and professional like QEMU) with no BIOS dependencies and with only the minimal amount of legacy device emulation. It's great as a learning tool if you want to get your feet wet in virtualization land: it's only 5 KLOC of clean C code that can already boot a guest Linux image. Right now it can boot a Linux image and provide you output via a serial console, over the host terminal, i.e. you can use it to boot a guest Linux image in a terminal or over ssh and log into the guest without much guest or host side setup work needed. 1. To try out the tool, clone the git repository: git clone git://github.com/penberg/linux-kvm.git or alternatively, if you already have a kernel source tree: git remote add kvm-tool git://github.com/penberg/linux-kvm.git git remote update git checkout kvm-tool/master -b kvm-tool 2. Compile the tool: cd tools/kvm && make 3. Download a raw userspace image: wget http://wiki.qemu.org/download/linux-0.2.img.bz2 && bunzip2 linux-0.2.img.bz2 4. The guest kernel has to be built with the following configuration: - For the default console output: CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y - For running 32bit images on 64bit hosts: CONFIG_IA32_EMULATION=y - Proper FS options according to image FS (e.g. CONFIG_EXT2_FS, CONFIG_EXT4_FS). - For all virtio devices listed below: CONFIG_VIRTIO=y CONFIG_VIRTIO_RING=y CONFIG_VIRTIO_PCI=y - For virtio-blk devices (--disk, -d): CONFIG_VIRTIO_BLK=y - For virtio-net devices ([--network, -n] virtio): CONFIG_VIRTIO_NET=y - For virtio-9p devices (--virtio-9p): CONFIG_NET_9P=y CONFIG_NET_9P_VIRTIO=y CONFIG_9P_FS=y - For virtio-balloon device (--balloon): CONFIG_VIRTIO_BALLOON=y - For virtio-console device (--console virtio): CONFIG_VIRTIO_CONSOLE=y - For virtio-rng device (--rng): CONFIG_HW_RANDOM_VIRTIO=y - For vesa device (--sdl or --vnc): CONFIG_FB_VESA=y 5. And finally, launch the hypervisor: ./lkvm run --disk linux-0.2.img \ --kernel ../../arch/x86/boot/bzImage \ or sudo ./lkvm run --disk linux-0.2.img \ --kernel ../../arch/x86/boot/bzImage \ --network virtio The tool has been written by Pekka Enberg, Cyrill Gorcunov, Asias He, Sasha Levin and Prasad Joshi. Special thanks to Avi Kivity for his help on KVM internals and Ingo Molnar for all-around support and encouragement! See the following thread for original discussion for motivation of this project: http://thread.gmane.org/gmane.linux.kernel/962051/focus=962620 Build dependencies ===================== For deb based systems: 32-bit: sudo apt-get install build-essential 64-bit: sudo apt-get install build-essential libc6-dev-i386 For rpm based systems: 32-bit: yum install glibc-devel 64-bit: yum install glibc-devel glibc-static On 64-bit Arch Linux make sure the multilib repository is enabled in your /etc/pacman.conf and run pacman -Sy lib32-glibc
Description
Languages
C
96.6%
Makefile
2.6%
Assembly
0.5%
Shell
0.3%