Sasha, So far so good! I applied your patch to an older version of kvm-tool that I had hacked on and it works for a simple test. So I think that I can do some kernel hacking with kvm tool! Very cool. I'm tested with the older version of kvm-tool because I am seeing a bug with an old kernel (2.6.28.10) and the latest version of kvm-tool. It is an old kernel, and now that I can debug more easily; hopefully I won't require it. In case this is worthwhile the error I'm seeing is below. While I do have 9p compiled into my kernel, I'm not actually using it. I haven't tried without the 9p compiled in. $ sudo ~/.../unpatched/linux-kvm/tools/kvm/kvm run -c 1 -m 2048 -k ./bzImage-2.6.28.10 \ --console serial -p 'console=ttyS0 ip=192.168.122.2 ' -i ./initramfs-guest.img \ -n tap --host-ip 192.168.122.1 --guest-ip 192.168.122.2 --shmem pci:0xc8000000:16m:create ... [ 1.245232] Installing 9P2000 support [ 1.246826] 9p: virtio: Maximum channels exceeded [ 1.248674] ------------[ cut here ]------------ [ 1.250291] kernel BUG at net/9p/trans_virtio.c:240! [ 1.252018] invalid opcode: 0000 [#1] SMP [ 1.252491] last sysfs file: [ 1.252491] Dumping ftrace buffer: [ 1.252491] (ftrace buffer empty) [ 1.252491] CPU 0 [ 1.252491] Modules linked in: [ 1.252491] Pid: 1, comm: swapper Not tainted 2.6.28.10big_64 #6 [ 1.252491] RIP: 0010:[<ffffffff8057ee2f>] [<ffffffff8057ee2f>] p9_virtio_probe+0xcf/0x120 [ 1.252491] RSP: 0018:ffff88007ec2bc90 EFLAGS: 00010286 [ 1.252491] RAX: 0000000000000038 RBX: 0000000000000001 RCX: 00000000ffffffff [ 1.252491] RDX: ffffffff807d6978 RSI: 0000000000000086 RDI: 0000000000000246 [ 1.252491] RBP: ffff88007d6ae800 R08: 0000000000000000 R09: 0000000000000000 [ 1.252491] R10: 0000000000000000 R11: 0000000000000000 R12: ffff88007d6ae808 [ 1.252491] R13: 0000000000000000 R14: 0000000000013200 R15: 0000000000000000 [ 1.252491] FS: 0000000000000000(0000) GS:ffffffff809ee000(0000) knlGS:0000000000000000 [ 1.252491] CS: 0010 DS: 0018 ES: 0018 CR0: 000000008005003b [ 1.252491] CR2: 00007f77866892c0 CR3: 0000000000201000 CR4: 00000000000006e0 [ 1.252491] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 1.252491] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 1.252491] Process swapper (pid: 1, threadinfo ffff88007ec2a000, task ffff88007ec29390) [ 1.252491] Stack: [ 1.252491] ffff88007d6ae808 ffffffff804fe696 ffffffff808106e0 ffff88007d6ae800 [ 1.252491] ffff88007d6ae808 ffffffff804fe8db ffffffff808106e0 0000000000000000 [ 1.252491] ffff88007d6ae808 ffffffff8047ee3a ffffffff808106e0 ffff88007d6ae808 [ 1.252491] Call Trace: [ 1.252491] [<ffffffff804fe696>] ? add_status+0x26/0x50 [ 1.252491] [<ffffffff804fe8db>] ? virtio_dev_probe+0xab/0xf0 [ 1.252491] [<ffffffff8047ee3a>] ? driver_probe_device+0x9a/0x1b0 [ 1.252491] [<ffffffff8047eff3>] ? __driver_attach+0xa3/0xb0 [ 1.252491] [<ffffffff8047ef50>] ? __driver_attach+0x0/0xb0 [ 1.252491] [<ffffffff8047e3a8>] ? bus_for_each_dev+0x58/0x80 [ 1.252491] [<ffffffff8047e632>] ? bus_add_driver+0xb2/0x230 [ 1.252491] [<ffffffff8047f1d7>] ? driver_register+0x67/0x130 [ 1.252491] [<ffffffff8059a5cf>] ? _spin_lock+0xf/0x20 [ 1.252491] [<ffffffff80578ce2>] ? v9fs_register_trans+0x42/0x50 [ 1.252491] [<ffffffff809897ea>] ? p9_virtio_init+0x0/0x24 [ 1.252491] [<ffffffff80209042>] ? _stext+0x42/0x1c0 [ 1.252491] [<ffffffff803e40db>] ? ida_get_new_above+0x14b/0x220 [ 1.252491] [<ffffffff802ebd32>] ? kmem_cache_alloc+0x102/0x110 [ 1.252491] [<ffffffff803e431b>] ? idr_pre_get+0x4b/0x90 [ 1.252491] [<ffffffff8059a5cf>] ? _spin_lock+0xf/0x20 [ 1.252491] [<ffffffff80342d72>] ? proc_register+0x142/0x240 [ 1.252491] [<ffffffff8095ad23>] ? kernel_init+0x115/0x15d [ 1.252491] [<ffffffff8095ad1c>] ? kernel_init+0x10e/0x15d [ 1.252491] [<ffffffff8022eaf9>] ? child_rip+0xa/0x11 [ 1.252491] [<ffffffff8095ac0e>] ? kernel_init+0x0/0x15d [ 1.252491] [<ffffffff8022eaef>] ? child_rip+0x0/0x11 [ 1.252491] Code: 68 fa e6 ff c6 83 e1 85 b1 80 00 c6 83 e0 85 b1 80 01 31 c0 48 83 c4 10 5b 5d 41 5c c3 48 c7 c7 e0 42 6e 80 3 1 c0 e8 0b 8b 01 00 <0f> 0b eb fe 48 8b 95 78 02 00 00 48 89 c7 48 89 44 24 08 ff 52 [ 1.252491] RIP [<ffffffff8057ee2f>] p9_virtio_probe+0xcf/0x120 [ 1.252491] RSP <ffff88007ec2bc90> [ 1.360254] ---[ end trace 695d68cac3254cff ]--- [ 1.361863] Kernel panic - not syncing: Attempted to kill init! [ 1.364043] Rebooting in 1 seconds.. *** Compatability Warning *** virtio-9p device was not detected While you have requested a virtio-9p device, the guest kernel didn't seem to detect it. Please make sure that the kernel was compiled with CONFIG_NET_9P_VIRTIO. # KVM session ended normally. For this kernel, CONFIG_NET_9P_VIRTIO is defined, but the kernel is old, so there may be issues. \dae On Thu, Sep 15, 2011 at 03:28:46PM +0300, Sasha Levin wrote: > On Thu, 2011-09-15 at 12:32 +0300, Pekka Enberg wrote: > > On Thu, Sep 15, 2011 at 11:53 AM, Sasha Levin <levinsasha928@xxxxxxxxx> wrote: > > > This patch adds the '-tty' option to 'kvm run' which allows the user to > > > remap a guest TTY into a PTS on the host. > > > > > > Usage: > > > 'kvm run --tty [id] [other options]' > > > > > > The tty will be mapped to a pts and will be printed on the screen: > > > ' Info: Assigned terminal 1 to pty /dev/pts/X' > > > > > > At this point, it is possible to communicate with the guest using that pty. > > > > > > This is useful for debugging guest kernel using KGDB: > > > > > > 1. Run the guest: > > > 'kvm run -k [vmlinuz] -p "kdbgoc=ttyS1 kdbgwait" --tty 1' > > > > > > And see which PTY got assigned to ttyS1. > > > > > > 2. Run GDB on the host: > > > 'gdb [vmlinuz]' > > > > > > 3. Connect to the guest (from within GDB): > > > 'target remote /dev/pty/X' > > > > > > 4. Start debugging! (enter 'continue' to continue boot). > > > > > > Cc: David Evensky <evensky@xxxxxxxxxxxxxxxxxxxx> > > > Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx> > > > > Neat! Would a tools/kvm/Documentation/debugging.txt be helpful for > > people who want to do kernel debugging with kvmtool? > > I'll write a basic doc with the details provided above. > > David, does this patch allows you to properly debug guest kernels? If > so, could you mail back any issues or hacks you had to do to set it up > so I could add it to the doc and move it into 'Documentation/'? > > -- > > Sasha. > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html