* [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load"
@ 2024-05-16 8:40 marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 1/3] migration: add "exists" info to load-state-field trace marcandre.lureau
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: marcandre.lureau @ 2024-05-16 8:40 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, Paolo Bonzini, Fiona Ebner, Fabiano Rosas, Yanan Wang,
Marcel Apfelbaum, Peter Maydell, Gerd Hoffmann, Peter Xu,
Eduardo Habkost, Richard Henderson, Philippe Mathieu-Daudé,
Michael S. Tsirkin, =?unknown-8bit?q?Marc-Andr=C3=A9?= Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Hi,
The aforementioned patch breaks virtio-gpu device migrations for versions
pre-9.0/9.0, both forwards and backwards. Versioning of `VMS_STRUCT` is more
complex than it may initially appear, as evidenced in the problematic commit
dfcf74fa68c ("virtio-gpu: fix scanout migration post-load").
v2:
- use a manual version field test (instead of the more complex struct variant)
v3:
- introduce machine_check_version()
- drop the VMSD version, and use machine version field test
v4:
- drop machine_check_version() approach
- property renamed to x-scanout-vmstate-version
Marc-André Lureau (3):
migration: add "exists" info to load-state-field trace
migration: fix a typo
virtio-gpu: fix v2 migration
include/hw/virtio/virtio-gpu.h | 1 +
hw/core/machine.c | 1 +
hw/display/virtio-gpu.c | 24 ++++++++++++++++--------
migration/vmstate.c | 7 ++++---
migration/trace-events | 2 +-
5 files changed, 23 insertions(+), 12 deletions(-)
--
2.41.0.28.gd7d8841f67
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 1/3] migration: add "exists" info to load-state-field trace
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
@ 2024-05-16 8:40 ` marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 2/3] migration: fix a typo marcandre.lureau
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marcandre.lureau @ 2024-05-16 8:40 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, Paolo Bonzini, Fiona Ebner, Fabiano Rosas, Yanan Wang,
Marcel Apfelbaum, Peter Maydell, Gerd Hoffmann, Peter Xu,
Eduardo Habkost, Richard Henderson, Philippe Mathieu-Daudé,
Michael S. Tsirkin, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
---
migration/vmstate.c | 5 +++--
migration/trace-events | 2 +-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/migration/vmstate.c b/migration/vmstate.c
index ef26f26ccd..b51212a75b 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -128,8 +128,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
}
}
while (field->name) {
- trace_vmstate_load_state_field(vmsd->name, field->name);
- if (vmstate_field_exists(vmsd, field, opaque, version_id)) {
+ bool exists = vmstate_field_exists(vmsd, field, opaque, version_id);
+ trace_vmstate_load_state_field(vmsd->name, field->name, exists);
+ if (exists) {
void *first_elem = opaque + field->offset;
int i, n_elems = vmstate_n_elems(opaque, field);
int size = vmstate_size(opaque, field);
diff --git a/migration/trace-events b/migration/trace-events
index d0c44c3853..0b7c3324fb 100644
--- a/migration/trace-events
+++ b/migration/trace-events
@@ -58,7 +58,7 @@ postcopy_page_req_sync(void *host_addr) "sync page req %p"
vmstate_load_field_error(const char *field, int ret) "field \"%s\" load failed, ret = %d"
vmstate_load_state(const char *name, int version_id) "%s v%d"
vmstate_load_state_end(const char *name, const char *reason, int val) "%s %s/%d"
-vmstate_load_state_field(const char *name, const char *field) "%s:%s"
+vmstate_load_state_field(const char *name, const char *field, bool exists) "%s:%s exists=%d"
vmstate_n_elems(const char *name, int n_elems) "%s: %d"
vmstate_subsection_load(const char *parent) "%s"
vmstate_subsection_load_bad(const char *parent, const char *sub, const char *sub2) "%s: %s/%s"
--
2.41.0.28.gd7d8841f67
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] migration: fix a typo
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 1/3] migration: add "exists" info to load-state-field trace marcandre.lureau
@ 2024-05-16 8:40 ` marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 3/3] virtio-gpu: fix v2 migration marcandre.lureau
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marcandre.lureau @ 2024-05-16 8:40 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, Paolo Bonzini, Fiona Ebner, Fabiano Rosas, Yanan Wang,
Marcel Apfelbaum, Peter Maydell, Gerd Hoffmann, Peter Xu,
Eduardo Habkost, Richard Henderson, Philippe Mathieu-Daudé,
Michael S. Tsirkin, Marc-André Lureau
From: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
---
migration/vmstate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/migration/vmstate.c b/migration/vmstate.c
index b51212a75b..ff5d589a6d 100644
--- a/migration/vmstate.c
+++ b/migration/vmstate.c
@@ -479,7 +479,7 @@ static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *vmsd,
len = qemu_peek_byte(f, 1);
if (len < strlen(vmsd->name) + 1) {
- /* subsection name has be be "section_name/a" */
+ /* subsection name has to be "section_name/a" */
trace_vmstate_subsection_load_bad(vmsd->name, "(short)", "");
return 0;
}
--
2.41.0.28.gd7d8841f67
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] virtio-gpu: fix v2 migration
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 1/3] migration: add "exists" info to load-state-field trace marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 2/3] migration: fix a typo marcandre.lureau
@ 2024-05-16 8:40 ` marcandre.lureau
2024-05-16 9:31 ` [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" Fiona Ebner
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marcandre.lureau @ 2024-05-16 8:40 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-arm, Paolo Bonzini, Fiona Ebner, Fabiano Rosas, Yanan Wang,
Marcel Apfelbaum, Peter Maydell, Gerd Hoffmann, Peter Xu,
Eduardo Habkost, Richard Henderson, Philippe Mathieu-Daudé,
Michael S. Tsirkin, Marc-André Lureau
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. Introduce x-scanout-vmstate-version and a field
test to save/load appropriately according to the machine version.
Fixes: dfcf74fa ("virtio-gpu: fix scanout migration post-load")
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/hw/virtio/virtio-gpu.h | 1 +
hw/core/machine.c | 1 +
hw/display/virtio-gpu.c | 24 ++++++++++++++++--------
3 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 56d6e821bf..7a59379f5a 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -177,6 +177,7 @@ typedef struct VGPUDMABuf {
struct VirtIOGPU {
VirtIOGPUBase parent_obj;
+ uint8_t scanout_vmstate_version;
uint64_t conf_max_hostmem;
VirtQueue *ctrl_vq;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index c7ceb11501..8d6dc69f0e 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -42,6 +42,7 @@ GlobalProperty hw_compat_8_2[] = {
{ "migration", "zero-page-detection", "legacy"},
{ TYPE_VIRTIO_IOMMU_PCI, "granule", "4k" },
{ TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "64" },
+ { "virtio-gpu-device", "x-scanout-vmstate-version", "1" },
};
const size_t hw_compat_8_2_len = G_N_ELEMENTS(hw_compat_8_2);
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index ae831b6b3e..85323daf99 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1166,10 +1166,17 @@ static void virtio_gpu_cursor_bh(void *opaque)
virtio_gpu_handle_cursor(&g->parent_obj.parent_obj, g->cursor_vq);
}
+static bool scanout_vmstate_after_v2(void *opaque, int version)
+{
+ struct VirtIOGPUBase *base = container_of(opaque, VirtIOGPUBase, scanout);
+ struct VirtIOGPU *gpu = container_of(base, VirtIOGPU, parent_obj);
+
+ return gpu->scanout_vmstate_version >= 2;
+}
+
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 +1188,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, scanout_vmstate_after_v2),
+ VMSTATE_UINT32_TEST(fb.bytes_pp, struct virtio_gpu_scanout, scanout_vmstate_after_v2),
+ VMSTATE_UINT32_TEST(fb.width, struct virtio_gpu_scanout, scanout_vmstate_after_v2),
+ VMSTATE_UINT32_TEST(fb.height, struct virtio_gpu_scanout, scanout_vmstate_after_v2),
+ VMSTATE_UINT32_TEST(fb.stride, struct virtio_gpu_scanout, scanout_vmstate_after_v2),
+ VMSTATE_UINT32_TEST(fb.offset, struct virtio_gpu_scanout, scanout_vmstate_after_v2),
VMSTATE_END_OF_LIST()
},
};
@@ -1659,6 +1666,7 @@ static Property virtio_gpu_properties[] = {
DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags,
VIRTIO_GPU_FLAG_BLOB_ENABLED, false),
DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0),
+ DEFINE_PROP_UINT8("x-scanout-vmstate-version", VirtIOGPU, scanout_vmstate_version, 2),
DEFINE_PROP_END_OF_LIST(),
};
--
2.41.0.28.gd7d8841f67
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load"
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
` (2 preceding siblings ...)
2024-05-16 8:40 ` [PATCH v4 3/3] virtio-gpu: fix v2 migration marcandre.lureau
@ 2024-05-16 9:31 ` Fiona Ebner
2024-05-16 15:25 ` Peter Xu
2024-05-22 22:02 ` Fabiano Rosas
5 siblings, 0 replies; 7+ messages in thread
From: Fiona Ebner @ 2024-05-16 9:31 UTC (permalink / raw)
To: marcandre.lureau, qemu-devel
Cc: qemu-arm, Paolo Bonzini, Fabiano Rosas, Yanan Wang,
Marcel Apfelbaum, Peter Maydell, Gerd Hoffmann, Peter Xu,
Eduardo Habkost, Richard Henderson, Philippe Mathieu-Daudé,
Michael S. Tsirkin
Am 16.05.24 um 10:40 schrieb marcandre.lureau@redhat.com:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Hi,
>
> The aforementioned patch breaks virtio-gpu device migrations for versions
> pre-9.0/9.0, both forwards and backwards. Versioning of `VMS_STRUCT` is more
> complex than it may initially appear, as evidenced in the problematic commit
> dfcf74fa68c ("virtio-gpu: fix scanout migration post-load").
>
> v2:
> - use a manual version field test (instead of the more complex struct variant)
>
> v3:
> - introduce machine_check_version()
> - drop the VMSD version, and use machine version field test
>
> v4:
> - drop machine_check_version() approach
> - property renamed to x-scanout-vmstate-version
>
> Marc-André Lureau (3):
> migration: add "exists" info to load-state-field trace
> migration: fix a typo
> virtio-gpu: fix v2 migration
>
> include/hw/virtio/virtio-gpu.h | 1 +
> hw/core/machine.c | 1 +
> hw/display/virtio-gpu.c | 24 ++++++++++++++++--------
> migration/vmstate.c | 7 ++++---
> migration/trace-events | 2 +-
> 5 files changed, 23 insertions(+), 12 deletions(-)
>
Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
Tested the same things as for v1/v2, with an Ubuntu 23.10 VM:
Machine type pc-i440fx-8.2:
1. create snapshot with 8.2, load with patched 9.0
2. create snapshot with patched 9.0, load with patched 9.0 and with 8.2
Machine type pc-i440fx-9.0:
1. create snapshot with patched 9.0, load with patched 9.0
No crashes/failures and didn't notice any other issues 🙂
Best Regards,
Fiona
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load"
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
` (3 preceding siblings ...)
2024-05-16 9:31 ` [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" Fiona Ebner
@ 2024-05-16 15:25 ` Peter Xu
2024-05-22 22:02 ` Fabiano Rosas
5 siblings, 0 replies; 7+ messages in thread
From: Peter Xu @ 2024-05-16 15:25 UTC (permalink / raw)
To: Marc-André Lureau
Cc: QEMU Developers, qemu-arm, Paolo Bonzini, Fiona Ebner,
Fabiano Rosas, Yanan Wang, Marcel Apfelbaum, Peter Maydell,
Gerd Hoffmann, Eduardo Habkost, Richard Henderson,
Philippe Mathieu-Daudé, Michael S. Tsirkin
[-- Attachment #1: Type: text/plain, Size: 1285 bytes --]
Looks good here, thanks.
On Thu, May 16, 2024, 2:40 a.m. <marcandre.lureau@redhat.com> wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Hi,
>
> The aforementioned patch breaks virtio-gpu device migrations for versions
> pre-9.0/9.0, both forwards and backwards. Versioning of `VMS_STRUCT` is
> more
> complex than it may initially appear, as evidenced in the problematic
> commit
> dfcf74fa68c ("virtio-gpu: fix scanout migration post-load").
>
> v2:
> - use a manual version field test (instead of the more complex struct
> variant)
>
> v3:
> - introduce machine_check_version()
> - drop the VMSD version, and use machine version field test
>
> v4:
> - drop machine_check_version() approach
> - property renamed to x-scanout-vmstate-version
>
> Marc-André Lureau (3):
> migration: add "exists" info to load-state-field trace
> migration: fix a typo
> virtio-gpu: fix v2 migration
>
> include/hw/virtio/virtio-gpu.h | 1 +
> hw/core/machine.c | 1 +
> hw/display/virtio-gpu.c | 24 ++++++++++++++++--------
> migration/vmstate.c | 7 ++++---
> migration/trace-events | 2 +-
> 5 files changed, 23 insertions(+), 12 deletions(-)
>
> --
> 2.41.0.28.gd7d8841f67
>
>
[-- Attachment #2: Type: text/html, Size: 1767 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load"
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
` (4 preceding siblings ...)
2024-05-16 15:25 ` Peter Xu
@ 2024-05-22 22:02 ` Fabiano Rosas
5 siblings, 0 replies; 7+ messages in thread
From: Fabiano Rosas @ 2024-05-22 22:02 UTC (permalink / raw)
To: qemu-devel, marcandre.lureau
Cc: qemu-arm, Paolo Bonzini, Fiona Ebner, Yanan Wang,
Marcel Apfelbaum, Peter Maydell, Gerd Hoffmann, Peter Xu,
Eduardo Habkost, Richard Henderson, Philippe Mathieu-Daudé,
Michael S. Tsirkin
On Thu, 16 May 2024 12:40:19 +0400, marcandre.lureau@redhat.com wrote:
> The aforementioned patch breaks virtio-gpu device migrations for versions
> pre-9.0/9.0, both forwards and backwards. Versioning of `VMS_STRUCT` is more
> complex than it may initially appear, as evidenced in the problematic commit
> dfcf74fa68c ("virtio-gpu: fix scanout migration post-load").
>
> v2:
> - use a manual version field test (instead of the more complex struct variant)
>
> [...]
Queued, thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-05-22 22:03 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16 8:40 [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 1/3] migration: add "exists" info to load-state-field trace marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 2/3] migration: fix a typo marcandre.lureau
2024-05-16 8:40 ` [PATCH v4 3/3] virtio-gpu: fix v2 migration marcandre.lureau
2024-05-16 9:31 ` [PATCH v4 0/3] Fix "virtio-gpu: fix scanout migration post-load" Fiona Ebner
2024-05-16 15:25 ` Peter Xu
2024-05-22 22:02 ` Fabiano Rosas
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).