From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IzhsQ-0000Vh-Ux for qemu-devel@nongnu.org; Tue, 04 Dec 2007 19:12:34 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IzhsO-0000Th-7a for qemu-devel@nongnu.org; Tue, 04 Dec 2007 19:12:34 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IzhsN-0000Tb-IV for qemu-devel@nongnu.org; Tue, 04 Dec 2007 19:12:31 -0500 Received: from e6.ny.us.ibm.com ([32.97.182.146]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IzhsN-0005O2-Ex for qemu-devel@nongnu.org; Tue, 04 Dec 2007 19:12:31 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e6.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id lB50EAl0002418 for ; Tue, 4 Dec 2007 19:14:10 -0500 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id lB50CS0a131464 for ; Tue, 4 Dec 2007 19:12:28 -0500 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id lB50CS4V013411 for ; Tue, 4 Dec 2007 19:12:28 -0500 Message-ID: <4755ECEA.6060209@us.ibm.com> Date: Tue, 04 Dec 2007 18:12:26 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <4755CCAD.7010403@us.ibm.com> <4755E810.4000106@qumranet.com> In-Reply-To: <4755E810.4000106@qumranet.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 3/3] virtio block device Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dor.laor@qumranet.com Cc: Rusty Russell , qemu-devel@nongnu.org Dor Laor wrote: > Anthony Liguori wrote: > > Subject: [PATCH 3/3] virtio block device > + > +static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq) > +{ > + VirtIOBlock *s = to_virtio_blk(vdev); > + VirtQueueElement elem; > + unsigned int count; > + > + while ((count = virtqueue_pop(vq, &elem)) != 0) { > + struct virtio_blk_inhdr *in; > + struct virtio_blk_outhdr *out; > + unsigned int wlen; > + off_t off; > + int i; > + > + out = (void *)elem.out_sg[0].iov_base; > + in = (void *)elem.in_sg[elem.in_num - 1].iov_base; > + off = out->sector; > + > + if (out->type & VIRTIO_BLK_T_SCSI_CMD) { > + wlen = sizeof(*in); > + in->status = VIRTIO_BLK_S_UNSUPP; > + } else if (out->type & VIRTIO_BLK_T_OUT) { > + wlen = sizeof(*in); > + > + for (i = 1; i < elem.out_num; i++) { > + bdrv_write(s->bs, off, > + elem.out_sg[i].iov_base, > + elem.out_sg[i].iov_len / 512); > + off += elem.out_sg[i].iov_len / 512; > + } > + > + in->status = VIRTIO_BLK_S_OK; > + } else { > + wlen = sizeof(*in); > + > + for (i = 0; i < elem.in_num - 1; i++) { > + bdrv_read(s->bs, off, > + elem.in_sg[i].iov_base, > + elem.in_sg[i].iov_len / 512); > + off += elem.in_sg[i].iov_len / 512; > + wlen += elem.in_sg[i].iov_len; > + } > + > + in->status = VIRTIO_BLK_S_OK; > + } > + > + virtqueue_push(vq, &elem, wlen); > + virtio_notify(vdev, vq); > + } > > > > The notify here should also be outside the while loop. > Yeah, that's in the optimization patch. > =================================================================== > --- qemu.orig/sysemu.h 2007-12-04 13:51:49.000000000 -0600 > +++ qemu/sysemu.h 2007-12-04 14:18:57.000000000 -0600 > @@ -117,7 +117,7 @@ > #endif > > typedef enum { > - IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD > + IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO > } BlockInterfaceType; > > typedef struct DriveInfo { > Index: qemu/hw/pc.c > =================================================================== > --- qemu.orig/hw/pc.c 2007-12-04 13:51:49.000000000 -0600 > +++ qemu/hw/pc.c 2007-12-04 14:18:57.000000000 -0600 > @@ -1008,6 +1008,18 @@ > } > } > } > + > + /* Add virtio block devices */ > + if (pci_enabled) { > + int index; > + int unit_id = 0; > + > + while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { > + virtio_blk_init(pci_bus, 0x5002, 0x2258, > > > > > The pci vendor id should be identical to the network (0x6900) > Indeed! That's for catching that. Regards, Anthony Liguori > regards, > Dor. > >