From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LN2mW-0007jU-5f for qemu-devel@nongnu.org; Wed, 14 Jan 2009 05:15:28 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LN2mT-0007hf-VC for qemu-devel@nongnu.org; Wed, 14 Jan 2009 05:15:27 -0500 Received: from [199.232.76.173] (port=48420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LN2mT-0007hR-Jc for qemu-devel@nongnu.org; Wed, 14 Jan 2009 05:15:25 -0500 Received: from mx2.redhat.com ([66.187.237.31]:52513) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LN2mS-0006qW-KM for qemu-devel@nongnu.org; Wed, 14 Jan 2009 05:15:25 -0500 From: Mark McLoughlin In-Reply-To: <1231881831.9095.192.camel@bling> References: <1231881831.9095.192.camel@bling> Content-Type: text/plain Date: Wed, 14 Jan 2009 10:15:15 +0000 Message-Id: <1231928115.4944.293.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/5] virtio-net: Add a virtqueue for control commands from the guest Reply-To: Mark McLoughlin , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: qemu-devel , kvm On Tue, 2009-01-13 at 14:23 -0700, Alex Williamson wrote: > @@ -110,6 +111,36 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features) > #endif > } > > +static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) > +{ > + struct { > + uint8_t class; > + uint8_t cmd; > + } *ctrl; > + uint8_t *status; > + VirtQueueElement elem; > + > + while (virtqueue_pop(vq, &elem)) { > + if ((elem.in_num < 1) | (elem.out_num < 1)) { > + fprintf(stderr, "virtio-net ctrl missing headers\n"); > + exit(1); > + } > + > + if (elem.out_sg[0].iov_len < sizeof(*ctrl) || > + elem.out_sg[elem.in_num - 1].iov_len < sizeof(*status)) { > + fprintf(stderr, "virtio-net ctrl header not in correct element\n"); > + exit(1); > + } > + > + ctrl = (void *)elem.out_sg[0].iov_base; > + status = (void *)elem.in_sg[elem.in_num - 1].iov_base; These casts aren't needed - iov_base is a void pointer. Cheers, Mark.