From: "Daniel P. Berrangé" <berrange@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org, "Eduardo Habkost" <eduardo@habkost.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Fiona Ebner" <f.ebner@proxmox.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
qemu-arm@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Fabiano Rosas" <farosas@suse.de>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Xu" <peterx@redhat.com>
Subject: Re: [PATCH v3 5/5] virtio-gpu: fix v2 migration
Date: Wed, 15 May 2024 17:03:44 +0100 [thread overview]
Message-ID: <ZkTc4Ott5M15k55R@redhat.com> (raw)
In-Reply-To: <20240515141557.1277999-6-marcandre.lureau@redhat.com>
On Wed, May 15, 2024 at 06:15:56PM +0400, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Commit dfcf74fa ("virtio-gpu: fix scanout migration post-load") broke
> forward/backward version migration. Versioning of nested VMSD structures
> is not straightforward, as the wire format doesn't have nested
> structures versions.
>
> Use the previously introduced check_machine_version() function as a
> field test to ensure proper saving/loading based on the machine version.
> The VMSD.version is irrelevant now.
>
> Fixes: dfcf74fa ("virtio-gpu: fix scanout migration post-load")
> Suggested-by: Peter Xu <peterx@redhat.com>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> hw/display/virtio-gpu.c | 21 +++++++++++++--------
> 1 file changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index ae831b6b3e..b2d8e5faeb 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -20,6 +20,7 @@
> #include "trace.h"
> #include "sysemu/dma.h"
> #include "sysemu/sysemu.h"
> +#include "hw/boards.h"
> #include "hw/virtio/virtio.h"
> #include "migration/qemu-file-types.h"
> #include "hw/virtio/virtio-gpu.h"
> @@ -1166,10 +1167,14 @@ static void virtio_gpu_cursor_bh(void *opaque)
> virtio_gpu_handle_cursor(&g->parent_obj.parent_obj, g->cursor_vq);
> }
>
> +static bool machine_check_9_0(void *opaque, int version)
> +{
> + return machine_check_version(9, 0);
> +}
I think applying version number checks to decide machine type
compatibility is a highly undesirable direction for QEMU to
take.
Machine type compatibility is a difficult problem, but one of
the good aspects about our current solution is that it is
clear what the differences are for each version. We can see
all the compatibility properties/flags/values being set in
one place, in the declaration of each machine's class.
Sprinkling version number checks around the codebase in
arbitrary files will harm visibility of what ABI is expressd
by each machine, and thus is liable to increase the liklihood
of mistakes.
This will negatively impact downstream vendors cherry-picking
patches to their stable branches, as the version number logic
may have incorrect semantics.
It will also create trouble for downstream vendors who define
their own machines with distinct versioning from upstream, as
there will be confusion over whether a version check is for
the base QEMU version, or the downstream version, and such
code added to the tree is less visible than the machine type
definitions.
Above all, I'm failing to see why there's a compelling reason
for virtio_gpu to diverge from our long standing practice of
adding a named property flag "virtio_scanout_vmstate_fix"
on the machine class, and then setting it in machine types
which need it.
> +
> static const VMStateDescription vmstate_virtio_gpu_scanout = {
> .name = "virtio-gpu-one-scanout",
> - .version_id = 2,
> - .minimum_version_id = 1,
> + .version_id = 1,
> .fields = (const VMStateField[]) {
> VMSTATE_UINT32(resource_id, struct virtio_gpu_scanout),
> VMSTATE_UINT32(width, struct virtio_gpu_scanout),
> @@ -1181,12 +1186,12 @@ static const VMStateDescription vmstate_virtio_gpu_scanout = {
> VMSTATE_UINT32(cursor.hot_y, struct virtio_gpu_scanout),
> VMSTATE_UINT32(cursor.pos.x, struct virtio_gpu_scanout),
> VMSTATE_UINT32(cursor.pos.y, struct virtio_gpu_scanout),
> - VMSTATE_UINT32_V(fb.format, struct virtio_gpu_scanout, 2),
> - VMSTATE_UINT32_V(fb.bytes_pp, struct virtio_gpu_scanout, 2),
> - VMSTATE_UINT32_V(fb.width, struct virtio_gpu_scanout, 2),
> - VMSTATE_UINT32_V(fb.height, struct virtio_gpu_scanout, 2),
> - VMSTATE_UINT32_V(fb.stride, struct virtio_gpu_scanout, 2),
> - VMSTATE_UINT32_V(fb.offset, struct virtio_gpu_scanout, 2),
> + VMSTATE_UINT32_TEST(fb.format, struct virtio_gpu_scanout, machine_check_9_0),
> + VMSTATE_UINT32_TEST(fb.bytes_pp, struct virtio_gpu_scanout, machine_check_9_0),
> + VMSTATE_UINT32_TEST(fb.width, struct virtio_gpu_scanout, machine_check_9_0),
> + VMSTATE_UINT32_TEST(fb.height, struct virtio_gpu_scanout, machine_check_9_0),
> + VMSTATE_UINT32_TEST(fb.stride, struct virtio_gpu_scanout, machine_check_9_0),
> + VMSTATE_UINT32_TEST(fb.offset, struct virtio_gpu_scanout, machine_check_9_0),
> VMSTATE_END_OF_LIST()
> },
> };
> --
> 2.41.0.28.gd7d8841f67
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2024-05-15 16:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 14:15 [PATCH v3 0/5] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
2024-05-15 14:15 ` [PATCH v3 1/5] migration: add "exists" info to load-state-field trace marcandre.lureau
2024-05-15 14:15 ` [PATCH v3 2/5] migration: fix a typo marcandre.lureau
2024-05-15 14:15 ` [PATCH v3 3/5] hw/boards: add machine_check_version() marcandre.lureau
2024-05-15 14:15 ` [PATCH v3 4/5] Set major/minor for PC and arm machines marcandre.lureau
2024-05-15 16:03 ` Michael S. Tsirkin
2024-05-15 14:15 ` [PATCH v3 5/5] virtio-gpu: fix v2 migration marcandre.lureau
2024-05-15 16:02 ` Michael S. Tsirkin
2024-05-15 16:31 ` Peter Xu
2024-05-15 22:02 ` Michael S. Tsirkin
2024-05-15 16:03 ` Daniel P. Berrangé [this message]
2024-05-15 17:03 ` Peter Xu
2024-05-15 17:15 ` Daniel P. Berrangé
2024-05-16 4:11 ` Peter Xu
2024-05-15 16:07 ` [PATCH v3 0/5] Fix "virtio-gpu: fix scanout migration post-load" Peter Xu
2024-05-15 16:21 ` Daniel P. Berrangé
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=ZkTc4Ott5M15k55R@redhat.com \
--to=berrange@redhat.com \
--cc=eduardo@habkost.net \
--cc=f.ebner@proxmox.com \
--cc=farosas@suse.de \
--cc=kraxel@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=wangyanan55@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).