From patchwork Sun Apr 10 03:36:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 696311 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3A3ajXA010348 for ; Sun, 10 Apr 2011 03:36:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754926Ab1DJDgm (ORCPT ); Sat, 9 Apr 2011 23:36:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16041 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751747Ab1DJDgm (ORCPT ); Sat, 9 Apr 2011 23:36:42 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3A3aL0Z014546 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 9 Apr 2011 23:36:21 -0400 Received: from localhost (vpn1-4-5.sin2.redhat.com [10.67.4.5]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3A3aHjv001865; Sat, 9 Apr 2011 23:36:18 -0400 Date: Sun, 10 Apr 2011 11:36:17 +0800 From: Amos Kong To: Pekka Enberg Cc: kvm@vger.kernel.org Subject: kvm tools: about using virtio-console Message-ID: <20110410033616.GA4899@t400> Reply-To: Amos Kong MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 10 Apr 2011 03:36:46 +0000 (UTC) Hi pekka, Does virtio-console work with kvm-tools? It seems that virtio-console.vps[] is not initialized in virtio-console.c (gdb) r run -i linux-0.2.img -k ./vmlinuz-2.6.38-rc6+ -r ./initrd.img-2.6.38-rc6+ -p=init=1 -m 500 -c Starting program: /project/rh/kvm-tools/tools/kvm/kvm run -i linux-0.2.img -k ./vmlinuz-2.6.38-rc6+ -r ./initrd.img-2.6.38-rc6+ -p=init=1 -m 500 -c [Thread debugging using libthread_db enabled] [New Thread 0x7fffd6e2d700 (LWP 19280)] Warning: request type 8 Program received signal SIGSEGV, Segmentation fault. 0x00000000004026ca in virt_queue__available (vq=0x60d3c8) at include/kvm/virtio.h:31 31 return vq->vring.avail->idx != vq->last_avail_idx; (gdb) (gdb) bt #0 0x00000000004026ca in virt_queue__available (vq=0x60d3c8) at include/kvm/virtio.h:31 #1 0x00000000004027f7 in virtio_console__inject_interrupt (self=0x68f010) at virtio-console.c:71 #2 0x00000000004083b2 in handle_sigalrm (sig=14) at kvm-run.c:51 #3 #4 0x00007ffff79bf283 in pthread_join () from /lib/libpthread.so.0 #5 0x00000000004088bb in kvm_cmd_run (argc=0, argv=0x7fffffffdd18, prefix=0x0) at kvm-run.c:216 #6 0x000000000040834e in handle_command (command=0x7fffffffdbb0, argc=11, argv=0x7fffffffdd10) at kvm-cmd.c:55 #7 0x0000000000405bd5 in handle_kvm_command (argc=11, argv=0x7fffffffdd10) at main.c:16 #8 0x0000000000405bfe in main (argc=12, argv=0x7fffffffdd08) at main.c:21 (gdb) p *vq $2 = {vring = {num = 0, desc = 0x0, avail = 0x0, used = 0x0}, pfn = 0, last_avail_idx = 0} ------- I added the check of vq->vring.avail in virt_queue__available(), but it also failed. (gdb) r run -i linux-0.2.img -k ./vmlinuz-2.6.38-rc6+ -r ./initrd.img-2.6.38-rc6+ -p=init=1 -m 500 -c Starting program: /project/rh/kvm-tools/tools/kvm/kvm run -i linux-0.2.img -k ./vmlinuz-2.6.38-rc6+ -r ./initrd.img-2.6.38-rc6+ -p=init=1 -m 500 -c [Thread debugging using libthread_db enabled] [New Thread 0x7fffd6e2d700 (LWP 19434)] Warning: request type 8 Program received signal SIGFPE, Arithmetic exception. 0x00000000004066cd in virt_queue__pop (queue=0x60d3c8) at include/kvm/virtio.h:21 21 return queue->vring.avail->ring[queue->last_avail_idx++ % queue->vring.num]; (gdb) bt #0 0x00000000004066cd in virt_queue__pop (queue=0x60d3c8) at include/kvm/virtio.h:21 #1 0x000000000040679c in virt_queue__get_iov (queue=0x60d3c8, iov=0x7fffffffcda0, out=0x7fffffffd5be, in=0x7fffffffd5bc, kvm=0x68f010) at virtio.c:21 #2 0x000000000040284b in virtio_console__inject_interrupt (self=0x68f010) at virtio-console.c:72 #3 0x00000000004083da in handle_sigalrm (sig=14) at kvm-run.c:51 #4 #5 0x00007ffff79bf283 in pthread_join () from /lib/libpthread.so.0 #6 0x00000000004088e3 in kvm_cmd_run (argc=0, argv=0x7fffffffdd18, prefix=0x0) at kvm-run.c:216 #7 0x0000000000408376 in handle_command (command=0x7fffffffdbb0, argc=11, argv=0x7fffffffdd10) at kvm-cmd.c:55 #8 0x0000000000405bfd in handle_kvm_command (argc=11, argv=0x7fffffffdd10) at main.c:16 #9 0x0000000000405c26 in main (argc=12, argv=0x7fffffffdd08) at main.c:21 (gdb) p *queue $2 = {vring = {num = 0, desc = 0x0, avail = 0x0, used = 0x0}, pfn = 0, last_avail_idx = 0} Amos. --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/tools/kvm/include/kvm/virtio.h b/tools/kvm/include/kvm/virtio.h index 9f892a1..d3622b1 100644 --- a/tools/kvm/include/kvm/virtio.h +++ b/tools/kvm/include/kvm/virtio.h @@ -28,6 +28,8 @@ static inline struct vring_desc *virt_queue__get_desc(struct virt_queue *queue, static inline bool virt_queue__available(struct virt_queue *vq) { + if (!vq->vring.avail) + return -1; return vq->vring.avail->idx != vq->last_avail_idx; }