All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: qemu-devel@nongnu.org, jasowang@redhat.com, mst@redhat.com
Cc: quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/1] virtio/pci/migration: Convert to VMState
Date: Thu, 5 Oct 2017 20:09:54 +0100	[thread overview]
Message-ID: <20171005190954.GG2556@work-vm> (raw)
In-Reply-To: <20170925160517.681-2-dgilbert@redhat.com>

* Dr. David Alan Gilbert (git) (dgilbert@redhat.com) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Convert the 'modern_state' part of virtio-pci to modern migration
> macros.

Ping.

Dave

> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  hw/virtio/virtio-pci.c | 108 +++++++++++++------------------------------------
>  1 file changed, 27 insertions(+), 81 deletions(-)
> 
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 8b0d6b69cd..f825a68a84 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -88,77 +88,19 @@ static void virtio_pci_save_config(DeviceState *d, QEMUFile *f)
>          qemu_put_be16(f, vdev->config_vector);
>  }
>  
> -static void virtio_pci_load_modern_queue_state(VirtIOPCIQueue *vq,
> -                                               QEMUFile *f)
> -{
> -    vq->num = qemu_get_be16(f);
> -    vq->enabled = qemu_get_be16(f);
> -    vq->desc[0] = qemu_get_be32(f);
> -    vq->desc[1] = qemu_get_be32(f);
> -    vq->avail[0] = qemu_get_be32(f);
> -    vq->avail[1] = qemu_get_be32(f);
> -    vq->used[0] = qemu_get_be32(f);
> -    vq->used[1] = qemu_get_be32(f);
> -}
> -
> -static bool virtio_pci_has_extra_state(DeviceState *d)
> -{
> -    VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
> -
> -    return proxy->flags & VIRTIO_PCI_FLAG_MIGRATE_EXTRA;
> -}
> -
> -static int get_virtio_pci_modern_state(QEMUFile *f, void *pv, size_t size,
> -                                       VMStateField *field)
> -{
> -    VirtIOPCIProxy *proxy = pv;
> -    int i;
> -
> -    proxy->dfselect = qemu_get_be32(f);
> -    proxy->gfselect = qemu_get_be32(f);
> -    proxy->guest_features[0] = qemu_get_be32(f);
> -    proxy->guest_features[1] = qemu_get_be32(f);
> -    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
> -        virtio_pci_load_modern_queue_state(&proxy->vqs[i], f);
> -    }
> -
> -    return 0;
> -}
> -
> -static void virtio_pci_save_modern_queue_state(VirtIOPCIQueue *vq,
> -                                               QEMUFile *f)
> -{
> -    qemu_put_be16(f, vq->num);
> -    qemu_put_be16(f, vq->enabled);
> -    qemu_put_be32(f, vq->desc[0]);
> -    qemu_put_be32(f, vq->desc[1]);
> -    qemu_put_be32(f, vq->avail[0]);
> -    qemu_put_be32(f, vq->avail[1]);
> -    qemu_put_be32(f, vq->used[0]);
> -    qemu_put_be32(f, vq->used[1]);
> -}
> -
> -static int put_virtio_pci_modern_state(QEMUFile *f, void *pv, size_t size,
> -                                       VMStateField *field, QJSON *vmdesc)
> -{
> -    VirtIOPCIProxy *proxy = pv;
> -    int i;
> -
> -    qemu_put_be32(f, proxy->dfselect);
> -    qemu_put_be32(f, proxy->gfselect);
> -    qemu_put_be32(f, proxy->guest_features[0]);
> -    qemu_put_be32(f, proxy->guest_features[1]);
> -    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
> -        virtio_pci_save_modern_queue_state(&proxy->vqs[i], f);
> +static const VMStateDescription vmstate_virtio_pci_modern_queue_state = {
> +    .name = "virtio_pci/modern_queue_state",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_UINT16(num, VirtIOPCIQueue),
> +        VMSTATE_UNUSED(1), /* enabled was stored as be16 */
> +        VMSTATE_BOOL(enabled, VirtIOPCIQueue),
> +        VMSTATE_UINT32_ARRAY(desc, VirtIOPCIQueue, 2),
> +        VMSTATE_UINT32_ARRAY(avail, VirtIOPCIQueue, 2),
> +        VMSTATE_UINT32_ARRAY(used, VirtIOPCIQueue, 2),
> +        VMSTATE_END_OF_LIST()
>      }
> -
> -    return 0;
> -}
> -
> -static const VMStateInfo vmstate_info_virtio_pci_modern_state = {
> -    .name = "virtqueue_state",
> -    .get = get_virtio_pci_modern_state,
> -    .put = put_virtio_pci_modern_state,
>  };
>  
>  static bool virtio_pci_modern_state_needed(void *opaque)
> @@ -168,21 +110,18 @@ static bool virtio_pci_modern_state_needed(void *opaque)
>      return virtio_pci_modern(proxy);
>  }
>  
> -static const VMStateDescription vmstate_virtio_pci_modern_state = {
> +static const VMStateDescription vmstate_virtio_pci_modern_state_sub = {
>      .name = "virtio_pci/modern_state",
>      .version_id = 1,
>      .minimum_version_id = 1,
>      .needed = &virtio_pci_modern_state_needed,
>      .fields = (VMStateField[]) {
> -        {
> -            .name         = "modern_state",
> -            .version_id   = 0,
> -            .field_exists = NULL,
> -            .size         = 0,
> -            .info         = &vmstate_info_virtio_pci_modern_state,
> -            .flags        = VMS_SINGLE,
> -            .offset       = 0,
> -        },
> +        VMSTATE_UINT32(dfselect, VirtIOPCIProxy),
> +        VMSTATE_UINT32(gfselect, VirtIOPCIProxy),
> +        VMSTATE_UINT32_ARRAY(guest_features, VirtIOPCIProxy, 2),
> +        VMSTATE_STRUCT_ARRAY(vqs, VirtIOPCIProxy, VIRTIO_QUEUE_MAX, 0,
> +                             vmstate_virtio_pci_modern_queue_state,
> +                             VirtIOPCIQueue),
>          VMSTATE_END_OF_LIST()
>      }
>  };
> @@ -196,11 +135,18 @@ static const VMStateDescription vmstate_virtio_pci = {
>          VMSTATE_END_OF_LIST()
>      },
>      .subsections = (const VMStateDescription*[]) {
> -        &vmstate_virtio_pci_modern_state,
> +        &vmstate_virtio_pci_modern_state_sub,
>          NULL
>      }
>  };
>  
> +static bool virtio_pci_has_extra_state(DeviceState *d)
> +{
> +    VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
> +
> +    return proxy->flags & VIRTIO_PCI_FLAG_MIGRATE_EXTRA;
> +}
> +
>  static void virtio_pci_save_extra_state(DeviceState *d, QEMUFile *f)
>  {
>      VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
> -- 
> 2.13.5
> 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

      reply	other threads:[~2017-10-05 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-25 16:05 [Qemu-devel] [PATCH 0/1] VMState conversion for virtio-pci 'modern state' Dr. David Alan Gilbert (git)
2017-09-25 16:05 ` [Qemu-devel] [PATCH 1/1] virtio/pci/migration: Convert to VMState Dr. David Alan Gilbert (git)
2017-10-05 19:09   ` Dr. David Alan Gilbert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171005190954.GG2556@work-vm \
    --to=dgilbert@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.