From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark McLoughlin Subject: Re: [PATCH 2/5] virtio-net: Add a virtqueue for control commands from the guest Date: Wed, 14 Jan 2009 10:15:15 +0000 Message-ID: <1231928115.4944.293.camel@localhost.localdomain> References: <1231881831.9095.192.camel@bling> Reply-To: Mark McLoughlin Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: kvm , qemu-devel To: Alex Williamson Return-path: Received: from mx2.redhat.com ([66.187.237.31]:53607 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758760AbZANKP2 (ORCPT ); Wed, 14 Jan 2009 05:15:28 -0500 In-Reply-To: <1231881831.9095.192.camel@bling> Sender: kvm-owner@vger.kernel.org List-ID: 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.