qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 12/41] virtio-pci: port pci config to vmstate


From: Michael S. Tsirkin
Subject: [Qemu-devel] Re: [PATCH 12/41] virtio-pci: port pci config to vmstate
Date: Wed, 2 Dec 2009 16:39:09 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

On Wed, Dec 02, 2009 at 01:04:10PM +0100, Juan Quintela wrote:
> 
> Signed-off-by: Juan Quintela <address@hidden>
> ---
>  hw/virtio-pci.c |   72 ++++++++++++++++++++++++++++++++++++++----------------
>  1 files changed, 50 insertions(+), 22 deletions(-)
> 
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index a2179de..4fe55aa 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -105,35 +105,28 @@ static void virtio_pci_notify(void *opaque, uint16_t 
> vector)
>          qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1);
>  }
> 
> -static void virtio_pci_save_config(void * opaque, QEMUFile *f)
> +static bool is_msix(void *opaque, int version_id)
>  {
>      VirtIOPCIProxy *proxy = opaque;
> -    pci_device_save(&proxy->pci_dev, f);
> -    if (msix_present(&proxy->pci_dev)) {
> -        msix_save(&proxy->pci_dev, f);
> -        qemu_put_be16(f, proxy->vdev->config_vector);
> -    }
> +    return msix_present(&proxy->pci_dev);
>  }
> 
> -static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
> -{
> -    VirtIOPCIProxy *proxy = opaque;
> -    if (msix_present(&proxy->pci_dev))
> -        qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
> -}
> +static const VMStateDescription vmstate_msix_vector = {
> +    .name = "msix_vector",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields      = (VMStateField []) {
> +        VMSTATE_UINT16(config_vector, VirtIODevice),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> 
> -static int virtio_pci_load_config(void * opaque, QEMUFile *f)
> +static int virtio_pci_post_load(void * opaque, int version_id)
>  {
>      VirtIOPCIProxy *proxy = opaque;
> -    int ret;
> -    ret = pci_device_load(&proxy->pci_dev, f);
> -    if (ret) {
> -        return ret;
> -    }
> -    if (msix_present(&proxy->pci_dev)) {
> -        msix_load(&proxy->pci_dev, f);
> -        qemu_get_be16s(f, &proxy->vdev->config_vector);
> -    } else {
> +
> +    if (!msix_present(&proxy->pci_dev)) {
>          proxy->vdev->config_vector = VIRTIO_NO_VECTOR;
>      }
>      if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {
> @@ -142,6 +135,41 @@ static int virtio_pci_load_config(void * opaque, 
> QEMUFile *f)
>      return 0;
>  }
> 
> +const VMStateDescription vmstate_virtio_pci_config = {
> +    .name = "pci_config",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .post_load = virtio_pci_post_load,
> +    .fields      = (VMStateField []) {
> +        VMSTATE_PCI_DEVICE(pci_dev, VirtIOPCIProxy),
> +        VMSTATE_STRUCT_TEST(pci_dev, VirtIOPCIProxy, is_msix, 0,
> +                            vmstate_msix, PCIDevice),
> +        VMSTATE_STRUCT_POINTER_TEST(vdev, VirtIOPCIProxy, is_msix,
> +                                    vmstate_msix_vector, VirtIODevice *),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
> +static void virtio_pci_save_config(void * opaque, QEMUFile *f)
> +{
> +    vmstate_save_state(f, &vmstate_virtio_pci_config, opaque);
> +}
> +
> +static int virtio_pci_load_config(void * opaque, QEMUFile *f)
> +{
> +    return vmstate_load_state(f, &vmstate_virtio_pci_config, opaque,
> +                              vmstate_virtio_pci_config.version_id);
> +}
> +
> +static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
> +{
> +    VirtIOPCIProxy *proxy = opaque;
> +    if (msix_present(&proxy->pci_dev))
> +        qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
> +}
> +
> +

extra empty line here

>  static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
>  {
>      VirtIOPCIProxy *proxy = opaque;
> -- 
> 1.6.5.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]