Merge ~paelzer/ubuntu/+source/qemu:fix-1848497-virt-balloon-migrate-eoan into ubuntu/+source/qemu:ubuntu/eoan-devel

Proposed by Christian Ehrhardt 
Status: Rejected
Rejected by: Christian Ehrhardt 
Proposed branch: ~paelzer/ubuntu/+source/qemu:fix-1848497-virt-balloon-migrate-eoan
Merge into: ubuntu/+source/qemu:ubuntu/eoan-devel
Diff against target: 167 lines (+145/-0)
3 files modified
debian/changelog (+7/-0)
debian/patches/series (+1/-0)
debian/patches/ubuntu/lp-1848497-virtio-balloon-fix-QEMU-4.0-config-size-migration-in.patch (+137/-0)
Reviewer Review Type Date Requested Status
Christian Ehrhardt  (community) Needs Resubmitting
Canonical Server Pending
Canonical Server packageset reviewers Pending
Review via email: mp+374446@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

PPA: https://launchpad.net/~paelzer/+archive/ubuntu/bug-1848497-virt-balloon-migrate/+packages

I have multiple changes for qemu inbound, and we know Focal is coming but not yet open.
I have made PPAs and MPs for Eoan and will submit them separate.

Lets review and ack it on that base, I'll eventually upload it to Focal first (with normal new version) and then kick off an SRU.

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Focal is properly open and we know nothing else will be stacked for this upload.
Abandonign this one ...
New MP for both at once: https://code.launchpad.net/~paelzer/ubuntu/+source/qemu/+git/qemu/+merge/374447

review: Needs Resubmitting

Unmerged commits

e3a095c... by Christian Ehrhardt 

changelog MERGE

Signed-off-by: Christian Ehrhardt <email address hidden>

cd3c742... by Christian Ehrhardt 

changelog: fix migration issue from qemu <4.0 when using virtio-balloon (LP: #1848497)

Signed-off-by: Christian Ehrhardt <email address hidden>

96453b8... by Christian Ehrhardt 

fix migration issue from qemu <4.0 when using virtio-balloon (LP: #1848497)

Signed-off-by: Christian Ehrhardt <email address hidden>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 430c149..4177f2a 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+qemu (1:4.0+dfsg-0ubuntu9.1) eoan; urgency=medium
7+
8+ * d/p/u/lp-1848497-virtio-balloon-fix-QEMU-4.0-config-size-migration-in.patch:
9+ fix migration issue from qemu <4.0 when using virtio-balloon (LP: #1848497)
10+
11+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Mon, 21 Oct 2019 15:58:57 +0200
12+
13 qemu (1:4.0+dfsg-0ubuntu9) eoan; urgency=medium
14
15 * d/p/lp-1842774-s390x-cpumodel-Add-the-z15-name-to-the-description-o.patch:
16diff --git a/debian/patches/series b/debian/patches/series
17index 72b9e84..b3a43a4 100644
18--- a/debian/patches/series
19+++ b/debian/patches/series
20@@ -31,3 +31,4 @@ ubuntu/lp-1836154-s390x-cpumodel-also-change-name-of-vxbeh.patch
21 ubuntu/lp-1841066-i386-x86_cpu_list_feature_names-function.patch
22 ubuntu/lp-1841066-i386-unavailable-features-QOM-property.patch
23 lp-1842774-s390x-cpumodel-Add-the-z15-name-to-the-description-o.patch
24+ubuntu/lp-1848497-virtio-balloon-fix-QEMU-4.0-config-size-migration-in.patch
25diff --git a/debian/patches/ubuntu/lp-1848497-virtio-balloon-fix-QEMU-4.0-config-size-migration-in.patch b/debian/patches/ubuntu/lp-1848497-virtio-balloon-fix-QEMU-4.0-config-size-migration-in.patch
26new file mode 100644
27index 0000000..37e5f34
28--- /dev/null
29+++ b/debian/patches/ubuntu/lp-1848497-virtio-balloon-fix-QEMU-4.0-config-size-migration-in.patch
30@@ -0,0 +1,137 @@
31+From 2bbadb08ce272d65e1f78621002008b07d1e0f03 Mon Sep 17 00:00:00 2001
32+From: Stefan Hajnoczi <stefanha@redhat.com>
33+Date: Wed, 10 Jul 2019 16:14:40 +0200
34+Subject: [PATCH] virtio-balloon: fix QEMU 4.0 config size migration
35+ incompatibility
36+
37+The virtio-balloon config size changed in QEMU 4.0 even for existing
38+machine types. Migration from QEMU 3.1 to 4.0 can fail in some
39+circumstances with the following error:
40+
41+ qemu-system-x86_64: get_pci_config_device: Bad config data: i=0x10 read: a1 device: 1 cmask: ff wmask: c0 w1cmask:0
42+
43+This happens because the virtio-balloon config size affects the VIRTIO
44+Legacy I/O Memory PCI BAR size.
45+
46+Introduce a qdev property called "qemu-4-0-config-size" and enable it
47+only for the QEMU 4.0 machine types. This way <4.0 machine types use
48+the old size, 4.0 uses the larger size, and >4.0 machine types use the
49+appropriate size depending on enabled virtio-balloon features.
50+
51+Live migration to and from old QEMUs to QEMU 4.1 works again as long as
52+a versioned machine type is specified (do not use just "pc"!).
53+
54+Originally-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
55+Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
56+Message-Id: <20190710141440.27635-1-stefanha@redhat.com>
57+Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
58+Tested-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
59+Tested-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
60+Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
61+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
62+
63+Backport-Note: upstream commit was targetted for 4.1, needed changes to
64+work in 4.0 as HW_COMPAT code has the understanding of the "current"
65+level and when backported that is 4.0 and not 4.1 anymore.
66+Origin: backport, https://git.qemu.org/?p=qemu.git;a=commit;h=2bbadb08ce272d65e1f78621002008b07d1e0f03
67+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1848497
68+Last-Update: 2019-10-21
69+
70+---
71+ hw/core/machine.c | 2 ++
72+ hw/virtio/virtio-balloon.c | 28 +++++++++++++++++++++++++---
73+ include/hw/virtio/virtio-balloon.h | 2 ++
74+ 3 files changed, 29 insertions(+), 3 deletions(-)
75+
76+--- a/hw/core/machine.c
77++++ b/hw/core/machine.c
78+@@ -36,6 +36,7 @@ GlobalProperty hw_compat_3_1[] = {
79+ { "usb-kbd", "serial", "42" },
80+ { "virtio-blk-device", "discard", "false" },
81+ { "virtio-blk-device", "write-zeroes", "false" },
82++ { "virtio-balloon-device", "qemu-4-0-config-size", "false" },
83+ };
84+ const size_t hw_compat_3_1_len = G_N_ELEMENTS(hw_compat_3_1);
85+
86+--- a/hw/virtio/virtio-balloon.c
87++++ b/hw/virtio/virtio-balloon.c
88+@@ -615,6 +615,22 @@ virtio_balloon_free_page_report_notify(N
89+ return 0;
90+ }
91+
92++static size_t virtio_balloon_config_size(VirtIOBalloon *s)
93++{
94++ uint64_t features = s->host_features;
95++
96++ if (s->qemu_4_0_config_size) {
97++ return sizeof(struct virtio_balloon_config);
98++ }
99++ if (virtio_has_feature(features, VIRTIO_BALLOON_F_PAGE_POISON)) {
100++ return sizeof(struct virtio_balloon_config);
101++ }
102++ if (virtio_has_feature(features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
103++ return offsetof(struct virtio_balloon_config, poison_val);
104++ }
105++ return offsetof(struct virtio_balloon_config, free_page_report_cmd_id);
106++}
107++
108+ static void virtio_balloon_get_config(VirtIODevice *vdev, uint8_t *config_data)
109+ {
110+ VirtIOBalloon *dev = VIRTIO_BALLOON(vdev);
111+@@ -635,7 +651,7 @@ static void virtio_balloon_get_config(Vi
112+ }
113+
114+ trace_virtio_balloon_get_config(config.num_pages, config.actual);
115+- memcpy(config_data, &config, sizeof(struct virtio_balloon_config));
116++ memcpy(config_data, &config, virtio_balloon_config_size(dev));
117+ }
118+
119+ static int build_dimm_list(Object *obj, void *opaque)
120+@@ -679,7 +695,7 @@ static void virtio_balloon_set_config(Vi
121+ uint32_t oldactual = dev->actual;
122+ ram_addr_t vm_ram_size = get_current_ram_size();
123+
124+- memcpy(&config, config_data, sizeof(struct virtio_balloon_config));
125++ memcpy(&config, config_data, virtio_balloon_config_size(dev));
126+ dev->actual = le32_to_cpu(config.actual);
127+ if (dev->actual != oldactual) {
128+ qapi_event_send_balloon_change(vm_ram_size -
129+@@ -766,7 +782,7 @@ static void virtio_balloon_device_realiz
130+ int ret;
131+
132+ virtio_init(vdev, "virtio-balloon", VIRTIO_ID_BALLOON,
133+- sizeof(struct virtio_balloon_config));
134++ virtio_balloon_config_size(s));
135+
136+ ret = qemu_add_balloon_handler(virtio_balloon_to_target,
137+ virtio_balloon_stat, s);
138+@@ -897,6 +913,18 @@ static Property virtio_balloon_propertie
139+ VIRTIO_BALLOON_F_DEFLATE_ON_OOM, false),
140+ DEFINE_PROP_BIT("free-page-hint", VirtIOBalloon, host_features,
141+ VIRTIO_BALLOON_F_FREE_PAGE_HINT, false),
142++ /* QEMU 4.0 accidentally changed the config size even when free-page-hint
143++ * is disabled, resulting in QEMU 3.1 migration incompatibility. This
144++ * property retains this quirk for QEMU 4.1 machine types.
145++ * Backport:
146++ * Original patch is for 4.1 and sets "false", but in HW_COMPAT sets
147++ * 4.0 to "true" and 3.1 (and former) to "false".
148++ * Emulate that in the 4.0 code by setting true here, and keeping the
149++ * HW_COMPAT for 3.1 (4.0 HW_COMPAT doesn't exist yet anyway).
150++ * That way it will be forward compatible to qemu >=4.1
151++ */
152++ DEFINE_PROP_BOOL("qemu-4-0-config-size", VirtIOBalloon,
153++ qemu_4_0_config_size, true),
154+ DEFINE_PROP_LINK("iothread", VirtIOBalloon, iothread, TYPE_IOTHREAD,
155+ IOThread *),
156+ DEFINE_PROP_END_OF_LIST(),
157+--- a/include/hw/virtio/virtio-balloon.h
158++++ b/include/hw/virtio/virtio-balloon.h
159+@@ -71,6 +71,8 @@ typedef struct VirtIOBalloon {
160+ int64_t stats_poll_interval;
161+ uint32_t host_features;
162+ PartiallyBalloonedPage *pbp;
163++
164++ bool qemu_4_0_config_size;
165+ } VirtIOBalloon;
166+
167+ #endif

Subscribers

People subscribed via source and target branches