[{"id":1780933,"web_url":"http://patchwork.ozlabs.org/comment/1780933/","msgid":"<20171005190954.GG2556@work-vm>","list_archive_url":null,"date":"2017-10-05T19:09:54","subject":"Re: [Qemu-devel] [PATCH 1/1] virtio/pci/migration: Convert to\n\tVMState","submitter":{"id":48102,"url":"http://patchwork.ozlabs.org/api/people/48102/","name":"Dr. David Alan Gilbert","email":"dgilbert@redhat.com"},"content":"* Dr. David Alan Gilbert (git) (dgilbert@redhat.com) wrote:\n> From: \"Dr. David Alan Gilbert\" <dgilbert@redhat.com>\n> \n> Convert the 'modern_state' part of virtio-pci to modern migration\n> macros.\n\nPing.\n\nDave\n\n> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>\n> ---\n>  hw/virtio/virtio-pci.c | 108 +++++++++++++------------------------------------\n>  1 file changed, 27 insertions(+), 81 deletions(-)\n> \n> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c\n> index 8b0d6b69cd..f825a68a84 100644\n> --- a/hw/virtio/virtio-pci.c\n> +++ b/hw/virtio/virtio-pci.c\n> @@ -88,77 +88,19 @@ static void virtio_pci_save_config(DeviceState *d, QEMUFile *f)\n>          qemu_put_be16(f, vdev->config_vector);\n>  }\n>  \n> -static void virtio_pci_load_modern_queue_state(VirtIOPCIQueue *vq,\n> -                                               QEMUFile *f)\n> -{\n> -    vq->num = qemu_get_be16(f);\n> -    vq->enabled = qemu_get_be16(f);\n> -    vq->desc[0] = qemu_get_be32(f);\n> -    vq->desc[1] = qemu_get_be32(f);\n> -    vq->avail[0] = qemu_get_be32(f);\n> -    vq->avail[1] = qemu_get_be32(f);\n> -    vq->used[0] = qemu_get_be32(f);\n> -    vq->used[1] = qemu_get_be32(f);\n> -}\n> -\n> -static bool virtio_pci_has_extra_state(DeviceState *d)\n> -{\n> -    VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);\n> -\n> -    return proxy->flags & VIRTIO_PCI_FLAG_MIGRATE_EXTRA;\n> -}\n> -\n> -static int get_virtio_pci_modern_state(QEMUFile *f, void *pv, size_t size,\n> -                                       VMStateField *field)\n> -{\n> -    VirtIOPCIProxy *proxy = pv;\n> -    int i;\n> -\n> -    proxy->dfselect = qemu_get_be32(f);\n> -    proxy->gfselect = qemu_get_be32(f);\n> -    proxy->guest_features[0] = qemu_get_be32(f);\n> -    proxy->guest_features[1] = qemu_get_be32(f);\n> -    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {\n> -        virtio_pci_load_modern_queue_state(&proxy->vqs[i], f);\n> -    }\n> -\n> -    return 0;\n> -}\n> -\n> -static void virtio_pci_save_modern_queue_state(VirtIOPCIQueue *vq,\n> -                                               QEMUFile *f)\n> -{\n> -    qemu_put_be16(f, vq->num);\n> -    qemu_put_be16(f, vq->enabled);\n> -    qemu_put_be32(f, vq->desc[0]);\n> -    qemu_put_be32(f, vq->desc[1]);\n> -    qemu_put_be32(f, vq->avail[0]);\n> -    qemu_put_be32(f, vq->avail[1]);\n> -    qemu_put_be32(f, vq->used[0]);\n> -    qemu_put_be32(f, vq->used[1]);\n> -}\n> -\n> -static int put_virtio_pci_modern_state(QEMUFile *f, void *pv, size_t size,\n> -                                       VMStateField *field, QJSON *vmdesc)\n> -{\n> -    VirtIOPCIProxy *proxy = pv;\n> -    int i;\n> -\n> -    qemu_put_be32(f, proxy->dfselect);\n> -    qemu_put_be32(f, proxy->gfselect);\n> -    qemu_put_be32(f, proxy->guest_features[0]);\n> -    qemu_put_be32(f, proxy->guest_features[1]);\n> -    for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {\n> -        virtio_pci_save_modern_queue_state(&proxy->vqs[i], f);\n> +static const VMStateDescription vmstate_virtio_pci_modern_queue_state = {\n> +    .name = \"virtio_pci/modern_queue_state\",\n> +    .version_id = 1,\n> +    .minimum_version_id = 1,\n> +    .fields = (VMStateField[]) {\n> +        VMSTATE_UINT16(num, VirtIOPCIQueue),\n> +        VMSTATE_UNUSED(1), /* enabled was stored as be16 */\n> +        VMSTATE_BOOL(enabled, VirtIOPCIQueue),\n> +        VMSTATE_UINT32_ARRAY(desc, VirtIOPCIQueue, 2),\n> +        VMSTATE_UINT32_ARRAY(avail, VirtIOPCIQueue, 2),\n> +        VMSTATE_UINT32_ARRAY(used, VirtIOPCIQueue, 2),\n> +        VMSTATE_END_OF_LIST()\n>      }\n> -\n> -    return 0;\n> -}\n> -\n> -static const VMStateInfo vmstate_info_virtio_pci_modern_state = {\n> -    .name = \"virtqueue_state\",\n> -    .get = get_virtio_pci_modern_state,\n> -    .put = put_virtio_pci_modern_state,\n>  };\n>  \n>  static bool virtio_pci_modern_state_needed(void *opaque)\n> @@ -168,21 +110,18 @@ static bool virtio_pci_modern_state_needed(void *opaque)\n>      return virtio_pci_modern(proxy);\n>  }\n>  \n> -static const VMStateDescription vmstate_virtio_pci_modern_state = {\n> +static const VMStateDescription vmstate_virtio_pci_modern_state_sub = {\n>      .name = \"virtio_pci/modern_state\",\n>      .version_id = 1,\n>      .minimum_version_id = 1,\n>      .needed = &virtio_pci_modern_state_needed,\n>      .fields = (VMStateField[]) {\n> -        {\n> -            .name         = \"modern_state\",\n> -            .version_id   = 0,\n> -            .field_exists = NULL,\n> -            .size         = 0,\n> -            .info         = &vmstate_info_virtio_pci_modern_state,\n> -            .flags        = VMS_SINGLE,\n> -            .offset       = 0,\n> -        },\n> +        VMSTATE_UINT32(dfselect, VirtIOPCIProxy),\n> +        VMSTATE_UINT32(gfselect, VirtIOPCIProxy),\n> +        VMSTATE_UINT32_ARRAY(guest_features, VirtIOPCIProxy, 2),\n> +        VMSTATE_STRUCT_ARRAY(vqs, VirtIOPCIProxy, VIRTIO_QUEUE_MAX, 0,\n> +                             vmstate_virtio_pci_modern_queue_state,\n> +                             VirtIOPCIQueue),\n>          VMSTATE_END_OF_LIST()\n>      }\n>  };\n> @@ -196,11 +135,18 @@ static const VMStateDescription vmstate_virtio_pci = {\n>          VMSTATE_END_OF_LIST()\n>      },\n>      .subsections = (const VMStateDescription*[]) {\n> -        &vmstate_virtio_pci_modern_state,\n> +        &vmstate_virtio_pci_modern_state_sub,\n>          NULL\n>      }\n>  };\n>  \n> +static bool virtio_pci_has_extra_state(DeviceState *d)\n> +{\n> +    VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);\n> +\n> +    return proxy->flags & VIRTIO_PCI_FLAG_MIGRATE_EXTRA;\n> +}\n> +\n>  static void virtio_pci_save_extra_state(DeviceState *d, QEMUFile *f)\n>  {\n>      VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);\n> -- \n> 2.13.5\n> \n> \n--\nDr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=dgilbert@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y7Mmj5JJvz9t42\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  6 Oct 2017 06:10:45 +1100 (AEDT)","from localhost ([::1]:41701 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1e0BXf-0004YR-4h\n\tfor incoming@patchwork.ozlabs.org; Thu, 05 Oct 2017 15:10:43 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:55199)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1e0BX6-0004Uw-3o\n\tfor qemu-devel@nongnu.org; Thu, 05 Oct 2017 15:10:09 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <dgilbert@redhat.com>) id 1e0BX0-0008F6-3S\n\tfor qemu-devel@nongnu.org; Thu, 05 Oct 2017 15:10:08 -0400","from mx1.redhat.com ([209.132.183.28]:37048)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <dgilbert@redhat.com>) id 1e0BWz-0008Cw-R0\n\tfor qemu-devel@nongnu.org; Thu, 05 Oct 2017 15:10:02 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 04BE37EAB7\n\tfor <qemu-devel@nongnu.org>; Thu,  5 Oct 2017 19:10:01 +0000 (UTC)","from work-vm (ovpn-117-200.ams2.redhat.com [10.36.117.200])\n\tby smtp.corp.redhat.com (Postfix) with ESMTPS id 56BFF60603;\n\tThu,  5 Oct 2017 19:09:57 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 04BE37EAB7","Date":"Thu, 5 Oct 2017 20:09:54 +0100","From":"\"Dr. David Alan Gilbert\" <dgilbert@redhat.com>","To":"qemu-devel@nongnu.org, jasowang@redhat.com, mst@redhat.com","Message-ID":"<20171005190954.GG2556@work-vm>","References":"<20170925160517.681-1-dgilbert@redhat.com>\n\t<20170925160517.681-2-dgilbert@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20170925160517.681-2-dgilbert@redhat.com>","User-Agent":"Mutt/1.9.0 (2017-09-02)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]);\n\tThu, 05 Oct 2017 19:10:01 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH 1/1] virtio/pci/migration: Convert to\n\tVMState","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"quintela@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]