All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH 21/41] virtio: port to vmstate
Date: Wed, 2 Dec 2009 20:22:05 +0200	[thread overview]
Message-ID: <20091202182205.GA3956@redhat.com> (raw)
In-Reply-To: <e450dccaf2d8f5e32e7eaaa59bfe7d5e4f7a4c02.1259754427.git.quintela@redhat.com>

On Wed, Dec 02, 2009 at 01:04:19PM +0100, Juan Quintela wrote:
> We need to do the virt queue msix and not msix version because we know
> if there is msix at virtio level, not at queue element level
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hw/hw.h     |   10 +++++
>  hw/virtio.c |  121 ++++++++++++++++++++++++++++++++---------------------------
>  hw/virtio.h |    5 ++
>  3 files changed, 81 insertions(+), 55 deletions(-)
> 
> diff --git a/hw/hw.h b/hw/hw.h
> index 5f34991..747a311 100644
> --- a/hw/hw.h
> +++ b/hw/hw.h
> @@ -476,6 +476,16 @@ extern const VMStateInfo vmstate_info_unused_buffer;
>      .offset     = vmstate_offset_array(_state, _field, _type, _num), \
>  }
> 
> +#define VMSTATE_VARRAY_STRUCT_INT32(_field, _state, _field_num, _test, _vmsd, _type) {\

line too long

> +    .name         = (stringify(_field)),                             \
> +    .field_exists = (_test),                                         \
> +    .num_offset   = vmstate_offset_value(_state, _field_num, int32_t), \
> +    .vmsd         = &(_vmsd),                                        \
> +    .size         = sizeof(_type),                                   \
> +    .flags        = VMS_VARRAY_INT32|VMS_POINTER|VMS_STRUCT,         \
> +    .offset       = vmstate_offset_pointer(_state, _field, _type),   \
> +}
> +
>  #define VMSTATE_STATIC_BUFFER(_field, _state, _version, _test, _start, _size) { \

line too long

>      .name         = (stringify(_field)),                             \
>      .version_id   = (_version),                                      \
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 5497716..73dae7c 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -625,10 +625,19 @@ static bool is_virtio_pci(void *opaque, int version_id)
>  static bool is_virtio_msix(void *opaque, int version_id)
>  {
>      VirtIODevice *vdev = opaque;
> +
>      return (vdev->type == VIRTIO_PCI) &&
>          virtio_pci_msix_present(vdev->binding_opaque);
>  }
> 
> +static bool is_virtio_not_msix(void *opaque, int version_id)
> +{
> +    VirtIODevice *vdev = opaque;
> +
> +    return !((vdev->type == VIRTIO_PCI) &&
> +             virtio_pci_msix_present(vdev->binding_opaque));
> +}
> +

previous comment about using pci in virtio.c applies here
as well.

>  static void virtio_pre_save(void *opaque)
>  {
>      VirtIODevice *vdev = opaque;
> @@ -641,34 +650,6 @@ static void virtio_pre_save(void *opaque)
>      vdev->num_pci_queues = i;
>  }
> 
> -void virtio_save(VirtIODevice *vdev, QEMUFile *f)
> -{
> -    int i;
> -
> -    virtio_pre_save(vdev);
> -
> -    if (is_virtio_pci(vdev, 1))
> -        vmstate_save_state(f, &vmstate_virtio_pci_config, vdev->binding_opaque);
> -
> -    qemu_put_8s(f, &vdev->status);
> -    qemu_put_8s(f, &vdev->isr);
> -    qemu_put_be16s(f, &vdev->queue_sel);
> -    qemu_put_be32s(f, &vdev->features);
> -    qemu_put_sbe32s(f, &vdev->config_len);
> -    qemu_put_buffer(f, vdev->config, vdev->config_len);
> -
> -    qemu_put_sbe32s(f, &vdev->num_pci_queues);
> -
> -    for (i = 0; i < vdev->num_pci_queues; i++) {
> -        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 (is_virtio_msix(vdev, 1)) {
> -            qemu_put_be16s(f, &vdev->vq[i].vector);
> -        }
> -    }
> -}
> -
>  static int virtio_post_load(void *opaque, int version_id)
>  {
>      VirtIODevice *vdev = opaque;
> @@ -695,38 +676,68 @@ static int virtio_post_load(void *opaque, int version_id)
>      return 0;
>  }
> 
> -
> -int virtio_load(VirtIODevice *vdev, QEMUFile *f)
> -{
> -    int i, ret;
> -
> -    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)
> -            return ret;
> +static const VMStateDescription vmstate_virtio_pci_queue = {
> +    .name = "virtio_pci_queue",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields      = (VMStateField []) {
> +        VMSTATE_UINT32(vring.num, VirtQueue),
> +        VMSTATE_UINT64(pa, VirtQueue),
> +        VMSTATE_UINT16(last_avail_idx, VirtQueue),
> +        VMSTATE_END_OF_LIST()
>      }
> +};
> 
> -    qemu_get_8s(f, &vdev->status);
> -    qemu_get_8s(f, &vdev->isr);
> -    qemu_get_be16s(f, &vdev->queue_sel);
> -    qemu_get_be32s(f, &vdev->features);
> -    qemu_get_sbe32s(f, &vdev->config_len);
> -    qemu_get_buffer(f, vdev->config, vdev->config_len);
> +static const VMStateDescription vmstate_virtio_pci_queue_msix = {
> +    .name = "virtio_pci_queue_msix",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields      = (VMStateField []) {
> +        VMSTATE_UINT32(vring.num, VirtQueue),
> +        VMSTATE_UINT64(pa, VirtQueue),
> +        VMSTATE_UINT16(last_avail_idx, VirtQueue),
> +        VMSTATE_UINT16(vector, VirtQueue),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> 
> -    qemu_get_sbe32s(f, &vdev->num_pci_queues);
> +const VMStateDescription vmstate_virtio = {
> +     .name = "virtio",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .post_load = virtio_post_load,
> +    .pre_save = virtio_pre_save,
> +    .fields      = (VMStateField []) {
> +        VMSTATE_STRUCT_POINTER_TEST(binding_opaque, VirtIODevice, is_virtio_pci,
> +                                    vmstate_virtio_pci_config, void *),
> +        VMSTATE_UINT8(status, VirtIODevice),
> +        VMSTATE_UINT8(isr, VirtIODevice),
> +        VMSTATE_UINT16(queue_sel, VirtIODevice),
> +        VMSTATE_UINT32(features, VirtIODevice),
> +        VMSTATE_INT32(config_len, VirtIODevice),
> +        VMSTATE_PARTIAL_VBUFFER(config, VirtIODevice, config_len),
> +        VMSTATE_INT32(num_pci_queues, VirtIODevice),
> +        VMSTATE_VARRAY_STRUCT_INT32(vq, VirtIODevice, num_pci_queues,
> +                                    is_virtio_msix,
> +                                    vmstate_virtio_pci_queue_msix, VirtQueue),
> +        VMSTATE_VARRAY_STRUCT_INT32(vq, VirtIODevice, num_pci_queues,
> +                                    is_virtio_not_msix,
> +                                    vmstate_virtio_pci_queue, VirtQueue),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> 
> -    for (i = 0; i < vdev->num_pci_queues; i++) {
> -        qemu_get_be32s(f, &vdev->vq[i].vring.num);
> -        qemu_get_be64s(f, &vdev->vq[i].pa);
> -        qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);
> +void virtio_save(VirtIODevice *vdev, QEMUFile *f)
> +{
> +    vmstate_save_state(f, &vmstate_virtio, vdev);
> +}
> 
> -        if (is_virtio_msix(vdev, 1)) {
> -            qemu_get_be16s(f, &vdev->vq[i].vector);
> -        }
> -    }
> -    virtio_post_load(vdev, 1);
> -    return 0;
> +int virtio_load(VirtIODevice *vdev, QEMUFile *f)
> +{
> +    return vmstate_load_state(f, &vmstate_virtio, vdev, vmstate_virtio.version_id);
>  }
> 
>  void virtio_cleanup(VirtIODevice *vdev)
> diff --git a/hw/virtio.h b/hw/virtio.h
> index f56f672..ac7b8eb 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -130,6 +130,11 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes);
> 
>  void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
> 
> +extern const VMStateDescription vmstate_virtio;
> +
> +#define VMSTATE_VIRTIO(_field, _state)                                         \
> +    VMSTATE_STRUCT_TEST(_field, _state, NULL, 0, vmstate_virtio, VirtIODevice)
> +
>  void virtio_save(VirtIODevice *vdev, QEMUFile *f);
> 
>  int virtio_load(VirtIODevice *vdev, QEMUFile *f);
> -- 
> 1.6.5.2

  reply	other threads:[~2009-12-02 18:24 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-02 12:03 [Qemu-devel] [PATCH 00/41] virtio: port to vmstate Juan Quintela
2009-12-02 12:03 ` [Qemu-devel] [PATCH 01/41] virtio: Teach virtio-balloon about DO_UPCAST Juan Quintela
2009-12-02 18:40   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 02/41] virtio: Teach virtio-blk " Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 03/41] virtio: Teach virtio-console " Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 04/41] virtio: Teach virtio-net " Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 05/41] virtio-console: Remove useless casts Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 06/41] virtio: Use DO_UPCAST instead of a cast Juan Quintela
2009-12-02 13:41   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:19     ` Juan Quintela
2009-12-02 18:19       ` Michael S. Tsirkin
2009-12-02 18:42         ` Juan Quintela
2009-12-02 18:44           ` Michael S. Tsirkin
2009-12-02 19:03             ` Juan Quintela
2009-12-03  9:48               ` Michael S. Tsirkin
2009-12-03 11:56                 ` Juan Quintela
2009-12-03 12:04                   ` Michael S. Tsirkin
2009-12-03 12:55                     ` Juan Quintela
2009-12-03 13:39                       ` Avi Kivity
2009-12-02 12:04 ` [Qemu-devel] [PATCH 07/41] virtio-pci: Remove duplicate test Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 08/41] msix: Store sizes that we send/receive Juan Quintela
2009-12-02 13:39   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 09/41] msix: port to vmstate Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 10/41] qemu/pci: document msix_entries_nr field Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 11/41] virtio: Introduce type field to distingish between PCI and Syborg Juan Quintela
2009-12-02 18:42   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 12/41] virtio-pci: port pci config to vmstate Juan Quintela
2009-12-02 14:39   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 13/41] msix: msix_load/save are not needed anymore Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 14/41] virtio: remove save/load_config for virtio Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 15/41] virtio: remove save/load_queue " Juan Quintela
2009-12-02 14:43   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:22     ` Juan Quintela
2009-12-02 18:27       ` Michael S. Tsirkin
2009-12-02 18:50         ` Juan Quintela
2009-12-02 18:57           ` Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 16/41] virtio: Add num_pci_queues field Juan Quintela
2009-12-02 14:46   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 17/41] virtio: split virtio_post_load() from virtio_load() Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 18/41] virtio: change config_len type to int32_t Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 19/41] virtio: use the right types for VirtQueue elements Juan Quintela
2009-12-02 13:47   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:24     ` Juan Quintela
2009-12-02 18:24       ` Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 20/41] virtio: abstract test for save/load values Juan Quintela
2009-12-02 13:53   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 21/41] virtio: port to vmstate Juan Quintela
2009-12-02 18:22   ` Michael S. Tsirkin [this message]
2009-12-02 12:04 ` [Qemu-devel] [PATCH 22/41] virtio-net: change tx_timer_active to uint32_t Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 23/41] virtio-net: change mergeable_rx_bufs " Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 24/41] virtio-net: use type checking version of qemu_put/get-* Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 25/41] virtio-net: MAC_TABLE_ENTRIES has never been bigger Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 26/41] virtio-net: we know vlans size at compile time, make it static Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 27/41] virtio-net: abstract vlans operations Juan Quintela
2009-12-02 14:49   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:26     ` Juan Quintela
2009-12-02 18:29       ` Michael S. Tsirkin
2009-12-02 18:53         ` Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 28/41] virtio-net: make vlan operations on uint8_t, not uint32_t Juan Quintela
2009-12-02 14:50   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 29/41] virtio-net: in_use and first_multi only handle unsigned values Juan Quintela
2009-12-02 14:52   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:30     ` Juan Quintela
2009-12-02 18:32       ` Michael S. Tsirkin
2009-12-02 18:55         ` Juan Quintela
2009-12-02 18:58           ` Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 30/41] virtio-net: use save/load type chek functions for has_vent_hdr Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 31/41] virtio-net: we know macs size at compile time, make it static Juan Quintela
2009-12-02 14:54   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:33     ` Juan Quintela
2009-12-02 18:48       ` Alex Williamson
2009-12-02 12:04 ` [Qemu-devel] [PATCH 32/41] virtio-net: split virtio_net_post_load Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 33/41] virtio-net: port to vmstate Juan Quintela
2009-12-02 14:58   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:38     ` Juan Quintela
2009-12-02 18:40       ` Michael S. Tsirkin
2009-12-02 19:07         ` Juan Quintela
2009-12-02 18:37   ` Michael S. Tsirkin
2009-12-02 19:18     ` Juan Quintela
2009-12-03  9:19       ` Michael S. Tsirkin
2009-12-03 12:01         ` Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 34/41] virtio-console: " Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 35/41] virtio-balloon: " Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 36/41] virtio-blk: change rq type to VirtIOBlockReq Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 37/41] QLIST: Introduce QLIST_COPY_HEAD Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 38/41] virtio-blk: use QLIST for the list of requests Juan Quintela
2009-12-02 17:38   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:56     ` Juan Quintela
2009-12-02 19:00       ` Michael S. Tsirkin
2009-12-02 12:04 ` [Qemu-devel] [PATCH 39/41] virtio-blk: add VirtIOBlokReqHead type Juan Quintela
2009-12-02 12:04 ` [Qemu-devel] [PATCH 40/41] virtio-blk: port to vmstate Juan Quintela
2009-12-02 17:54   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-04 18:15     ` Anthony Liguori
2009-12-02 12:04 ` [Qemu-devel] [PATCH 41/41] virtio: virtio_save/load are not used anymore Juan Quintela
2009-12-02 18:17   ` [Qemu-devel] " Michael S. Tsirkin
2009-12-02 18:57     ` Juan Quintela

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=20091202182205.GA3956@redhat.com \
    --to=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.