From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFphE-0006IM-Sa for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:56:44 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFph9-0006CS-7G for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:56:43 -0500 Received: from [199.232.76.173] (port=55344 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFph9-0006CG-2u for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:56:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42879) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFph8-0004wA-Mn for qemu-devel@nongnu.org; Wed, 02 Dec 2009 08:56:39 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB2Dubsf008081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 2 Dec 2009 08:56:37 -0500 Date: Wed, 2 Dec 2009 15:53:59 +0200 From: "Michael S. Tsirkin" Message-ID: <20091202135359.GA18259@redhat.com> References: <98f690df10290c28da9f981a4d4ac1446675265f.1259754427.git.quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98f690df10290c28da9f981a4d4ac1446675265f.1259754427.git.quintela@redhat.com> Subject: [Qemu-devel] Re: [PATCH 20/41] virtio: abstract test for save/load values List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org This does not make a lot of sense separately: you are changing routines that you yourself then remove. And there is another helper not_msix which you add in the next patch. Maybe just roll this patch in with the next one and be done with it. On Wed, Dec 02, 2009 at 01:04:18PM +0100, Juan Quintela wrote: > > Signed-off-by: Juan Quintela > --- > hw/virtio.c | 27 ++++++++++++++++++++------- > 1 files changed, 20 insertions(+), 7 deletions(-) > > diff --git a/hw/virtio.c b/hw/virtio.c > index 2b36cad..5497716 100644 > --- a/hw/virtio.c > +++ b/hw/virtio.c > @@ -615,6 +615,20 @@ void virtio_notify_config(VirtIODevice *vdev) > virtio_notify_vector(vdev, vdev->config_vector); > } > > +static bool is_virtio_pci(void *opaque, int version_id) > +{ > + VirtIODevice *vdev = opaque; > + > + return vdev->type == VIRTIO_PCI; > +} > + > +static bool is_virtio_msix(void *opaque, int version_id) > +{ > + VirtIODevice *vdev = opaque; > + return (vdev->type == VIRTIO_PCI) && Reuse is_virtio_msix here? Or at least do not add () around ==. > + virtio_pci_msix_present(vdev->binding_opaque); > +} > + > static void virtio_pre_save(void *opaque) > { > VirtIODevice *vdev = opaque; > @@ -633,7 +647,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) > > virtio_pre_save(vdev); > > - if (vdev->type == VIRTIO_PCI) > + if (is_virtio_pci(vdev, 1)) > vmstate_save_state(f, &vmstate_virtio_pci_config, vdev->binding_opaque); > > qemu_put_8s(f, &vdev->status); > @@ -649,8 +663,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f) > qemu_put_be32s(f, &vdev->vq[i].vring.num); > qemu_put_be64s(f, &vdev->vq[i].pa); > qemu_put_be16s(f, &vdev->vq[i].last_avail_idx); > - if (vdev->type == VIRTIO_PCI && > - virtio_pci_msix_present(vdev->binding_opaque)) { > + if (is_virtio_msix(vdev, 1)) { > qemu_put_be16s(f, &vdev->vq[i].vector); > } > } > @@ -682,11 +695,12 @@ static int virtio_post_load(void *opaque, int version_id) > return 0; > } > > + Not needed. > int virtio_load(VirtIODevice *vdev, QEMUFile *f) > { > int i, ret; > > - if (vdev->type == VIRTIO_PCI) { > + if (is_virtio_pci(vdev, 1)) { > ret = vmstate_load_state(f, &vmstate_virtio_pci_config, vdev->binding_opaque, > vmstate_virtio_pci_config.version_id); > if (ret) > @@ -707,9 +721,8 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f) > qemu_get_be64s(f, &vdev->vq[i].pa); > qemu_get_be16s(f, &vdev->vq[i].last_avail_idx); > > - if (vdev->type == VIRTIO_PCI && > - virtio_pci_msix_present(vdev->binding_opaque)) { > - qemu_get_be16s(f, &vdev->vq[i].vector); > + if (is_virtio_msix(vdev, 1)) { > + qemu_get_be16s(f, &vdev->vq[i].vector); > } > } > virtio_post_load(vdev, 1); > -- > 1.6.5.2