From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFqTD-0007Fg-6o for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:46:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFqT8-0007BW-4g for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:46:18 -0500 Received: from [199.232.76.173] (port=46797 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFqT6-0007BH-Oq for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:46:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5105) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFqT6-00017z-7Q for qemu-devel@nongnu.org; Wed, 02 Dec 2009 09:46:12 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB2EkBVH027490 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Dec 2009 09:46:11 -0500 Date: Wed, 2 Dec 2009 16:43:33 +0200 From: "Michael S. Tsirkin" Message-ID: <20091202144333.GB18519@redhat.com> References: <67f3d61df137cfd59fbf5da6b0b999cdf8d28758.1259754427.git.quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <67f3d61df137cfd59fbf5da6b0b999cdf8d28758.1259754427.git.quintela@redhat.com> Subject: [Qemu-devel] Re: [PATCH 15/41] virtio: remove save/load_queue for virtio List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org On Wed, Dec 02, 2009 at 01:04:13PM +0100, Juan Quintela wrote: > It was used only for PCI virtio devices, state that explicitely > > Signed-off-by: Juan Quintela > --- > hw/virtio-pci.c | 24 ++++++------------------ > hw/virtio.c | 22 ++++++++++++++++------ > hw/virtio.h | 4 ++-- > 3 files changed, 24 insertions(+), 26 deletions(-) > > diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c > index 45d0adc..12f3961 100644 > --- a/hw/virtio-pci.c > +++ b/hw/virtio-pci.c > @@ -151,28 +151,18 @@ const VMStateDescription vmstate_virtio_pci_config = { > } > }; > > -static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f) > +bool virtio_pci_msix_present(void *opaque) > { > VirtIOPCIProxy *proxy = opaque; > - if (msix_present(&proxy->pci_dev)) > - qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n)); > -} > > + return msix_present(&proxy->pci_dev); > +} > > -static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f) > +int virtio_pci_msix_vector_use(void *opaque, unsigned vector) > { > VirtIOPCIProxy *proxy = opaque; > - uint16_t vector; > - if (msix_present(&proxy->pci_dev)) { > - qemu_get_be16s(f, &vector); > - } else { > - vector = VIRTIO_NO_VECTOR; > - } > - virtio_queue_set_vector(proxy->vdev, n, vector); > - if (vector != VIRTIO_NO_VECTOR) { > - return msix_vector_use(&proxy->pci_dev, vector); > - } > - return 0; > + > + return msix_vector_use(&proxy->pci_dev, vector); > } > > static void virtio_pci_reset(DeviceState *d) > @@ -402,8 +392,6 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, > > static const VirtIOBindings virtio_pci_bindings = { > .notify = virtio_pci_notify, > - .save_queue = virtio_pci_save_queue, > - .load_queue = virtio_pci_load_queue, > }; > > static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, > diff --git a/hw/virtio.c b/hw/virtio.c > index c136005..b565bf9 100644 > --- a/hw/virtio.c > +++ b/hw/virtio.c > @@ -643,8 +643,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) > qemu_put_be32(f, vdev->vq[i].vring.num); > qemu_put_be64(f, vdev->vq[i].pa); > qemu_put_be16s(f, &vdev->vq[i].last_avail_idx); > - if (vdev->binding->save_queue) > - vdev->binding->save_queue(vdev->binding_opaque, i, f); > + if (vdev->type == VIRTIO_PCI && > + virtio_pci_msix_present(vdev->binding_opaque)) { > + qemu_put_be16s(f, &vdev->vq[i].vector); > + } > } > } > I think this will break build on systems without PCI because virtio_pci.c is not linked in there. Correct? Making generic virtio.c depend on virtio_pci.c looks wrong in any case. We have bindings to resolve exactly this dependency problem. > @@ -676,10 +678,18 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f) > if (vdev->vq[i].pa) { > virtqueue_init(&vdev->vq[i]); > } > - if (vdev->binding->load_queue) { > - ret = vdev->binding->load_queue(vdev->binding_opaque, i, f); > - if (ret) > - return ret; > + if (vdev->type == VIRTIO_PCI) { > + if (virtio_pci_msix_present(vdev->binding_opaque)) { > + qemu_get_be16s(f, &vdev->vq[i].vector); > + } else { > + vdev->vq[i].vector = VIRTIO_NO_VECTOR; > + } > + if (vdev->vq[i].vector != VIRTIO_NO_VECTOR) { > + ret = virtio_pci_msix_vector_use(vdev->binding_opaque, > + vdev->vq[i].vector); > + if (ret) > + return ret; > + } > } > } > > diff --git a/hw/virtio.h b/hw/virtio.h > index 9d2e2cc..91a6c10 100644 > --- a/hw/virtio.h > +++ b/hw/virtio.h > @@ -78,8 +78,6 @@ typedef struct VirtQueueElement > > typedef struct { > void (*notify)(void * opaque, uint16_t vector); > - void (*save_queue)(void * opaque, int n, QEMUFile *f); > - int (*load_queue)(void * opaque, int n, QEMUFile *f); > } VirtIOBindings; > > #define VIRTIO_PCI_QUEUE_MAX 16 > @@ -176,5 +174,7 @@ void virtio_net_exit(VirtIODevice *vdev); > > /* virtio-pci. */ > extern const VMStateDescription vmstate_virtio_pci_config; > +bool virtio_pci_msix_present(void *opaque); > +int virtio_pci_msix_vector_use(void *opaque, unsigned vector); > > #endif > -- > 1.6.5.2