Merge ~paelzer/ubuntu/+source/qemu:lp-1921468-1887535-1921665-GROOVY into ubuntu/+source/qemu:ubuntu/groovy-devel

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: 9d1e5c0035e2636a6056d0af886be6272e732b0f
Merge reported by: Christian Ehrhardt 
Merged at revision: 9d1e5c0035e2636a6056d0af886be6272e732b0f
Proposed branch: ~paelzer/ubuntu/+source/qemu:lp-1921468-1887535-1921665-GROOVY
Merge into: ubuntu/+source/qemu:ubuntu/groovy-devel
Diff against target: 586 lines (+529/-0)
8 files modified
debian/changelog (+14/-0)
debian/patches/series (+5/-0)
debian/patches/ubuntu/lp-1887535-configure-replace-enable-disable-git-update-with-wit.patch (+276/-0)
debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-break-loop-if-a-null-block-number-i.patch (+40/-0)
debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-fix-off-by-one-error.patch (+41/-0)
debian/patches/ubuntu/lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch (+66/-0)
debian/patches/ubuntu/lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch (+86/-0)
debian/rules (+1/-0)
Reviewer Review Type Date Requested Status
Utkarsh Gupta (community) Approve
Canonical Server Pending
Canonical Server packageset reviewers Pending
git-ubuntu developers Pending
Review via email: mp+400326@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

* Changelog:
  - [✔] changelog entry correct version and targeted codename
  - [✔] changelog entries correct
  - [✔] update-maintainer has been run

* New Delta:
  - [✔] patches match what was proposed upstream
  - [✔] patches correctly included in debian/patches/series
  - [✔] patches have correct DEP3 metadata
  - [?] patches are all correct

A quick note here: I prefer to run `quilt refresh` after a patch is applied to refresh a patch, this removes the unnecessary noise from all the patches.

The first 3 patches seems to be partially refreshed (which is good!), but the last two (namely, lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch and lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch) haven't been refreshed. I know this is based on preferences, et al, but this is one thing that I always try to adapt to. Trivial (but of significance for me), so you could ignore as well, but I'd love it if you could do a complete refresh of all the 5 patches! :)

* Build/Test:
  - [✔] build is ok
  - [✔] verified PPA package installs/uninstalls
  - [✔] autopkgtest against the PPA package passes

* Extra:
  - [?] lintian warnings

I get a bunch of lintian warning for spelling errors; cf: https://paste.ubuntu.com/p/fbCQ8j47xq/. Maybe worth fixing it now or later? Or in fact, just forward the Debian specific ones to mjt and he can fix them. And maybe, we can fix the Ubuntu specific ones?

Another very, very trivial lintian comment is about trailing whitespaces in debian/changelog. You could run:
sed -i -e 's@[[:space:]]*$@@g' debian/changelog
to get rid of them but I guess worth sending this pointer to mjt maybe?

That said, this MP looks good and you can upload as-is but maybe worth considering my points above?

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

Thanks for having a look.

The whitespace noise mostly is that way in Salsa, and that isn't a Delta I want to reapply every time. The warning is very low prio so I'll ignore that.

Similar for spelling errors, those mostly mark a package I work on and are intentional :-P

For the patch refreshes I agree, that is functional and is due to me picking up patches as suggested by others. But when I had a look at least focal was fine.

To ssh://git.launchpad.net/~usd-import-team/ubuntu/+source/qemu
 * [new tag] upload/1%5.0-5ubuntu9.7 -> upload/1%5.0-5ubuntu9.7

Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading qemu_5.0-5ubuntu9.7.dsc: done.
  Uploading qemu_5.0-5ubuntu9.7.debian.tar.xz: done.
  Uploading qemu_5.0-5ubuntu9.7_source.buildinfo: done.
  Uploading qemu_5.0-5ubuntu9.7_source.changes: done.
Successfully uploaded packages.

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

merged - closing MP

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 996d8d8..6463c36 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,17 @@
6+qemu (1:5.0-5ubuntu9.7) groovy; urgency=medium
7+
8+ * d/p/u/lp-1921468-*: fix issues handling boot menu index on s390x
9+ (LP: #1921468)
10+ * d/p/u/lp-1887535-configure-replace-enable-disable-git-update-with-wit.patch,
11+ d/rules: Backport --with-git-submodules param so building from git repo
12+ doesn't fail (LP: #1887535)
13+ * Fix byte aligned writes when writing to image stored on NFS
14+ server, as they aren't required to be 4kib aligned. (LP: #1921665)
15+ - d/p/u/lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch
16+ - d/p/u/lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch
17+
18+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Fri, 26 Mar 2021 10:36:31 +0100
19+
20 qemu (1:5.0-5ubuntu9.6) groovy-security; urgency=medium
21
22 * SECURITY REGRESSION: fix multiple regressions caused by CVE-2020-13754
23diff --git a/debian/patches/series b/debian/patches/series
24index 905d272..e0e42b7 100644
25--- a/debian/patches/series
26+++ b/debian/patches/series
27@@ -117,3 +117,8 @@ ubuntu/CVE-2020-13754-4.patch
28 ubuntu/CVE-2020-13754-5.patch
29 ubuntu/CVE-2020-13754-6.patch
30 ubuntu/CVE-2020-13754-7.patch
31+ubuntu/lp-1921468-pc-bios-s390-ccw-fix-off-by-one-error.patch
32+ubuntu/lp-1921468-pc-bios-s390-ccw-break-loop-if-a-null-block-number-i.patch
33+ubuntu/lp-1887535-configure-replace-enable-disable-git-update-with-wit.patch
34+ubuntu/lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch
35+ubuntu/lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch
36diff --git a/debian/patches/ubuntu/lp-1887535-configure-replace-enable-disable-git-update-with-wit.patch b/debian/patches/ubuntu/lp-1887535-configure-replace-enable-disable-git-update-with-wit.patch
37new file mode 100644
38index 0000000..f9fd317
39--- /dev/null
40+++ b/debian/patches/ubuntu/lp-1887535-configure-replace-enable-disable-git-update-with-wit.patch
41@@ -0,0 +1,276 @@
42+From 7d7dbf9dc15be6e1465c756c2c5ae7f1ab104fc8 Mon Sep 17 00:00:00 2001
43+From: Dan Streetman <ddstreet@canonical.com>
44+Date: Tue, 19 Jan 2021 12:20:46 -0500
45+Subject: [PATCH] configure: replace --enable/disable-git-update with
46+ --with-git-submodules
47+MIME-Version: 1.0
48+Content-Type: text/plain; charset=UTF-8
49+Content-Transfer-Encoding: 8bit
50+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1887535
51+Origin: upstream, https://git.qemu.org/?p=qemu.git;a=commit;h=7d7dbf9dc15be6e1465c756c2c5ae7f1ab104fc8
52+
53+Replace the --enable-git-update and --disable-git-update configure params
54+with the param --with-git-submodules=(update|validate|ignore) to
55+allow 3 options for building from a git repo.
56+
57+This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
58+also keep the source code in git, but do not want to enable the
59+'git_update' mode; with the current code, that's not possible even
60+if the downstream package specifies --disable-git-update.
61+
62+The previous parameters are deprecated but still available; the
63+--enable-git-update parameter maps to --with-git-submodules=update and
64+--disable-git-update parameter maps to --with-git-submodules=validate.
65+
66+The configure script behavior is slightly modified, where previously
67+the dtc, capstone, and slirp submodules were not validated when
68+--disable-git-update was specified (but were updated with git-update
69+enabled), now they are validated when using --with-git-submodules=validate
70+and are only ignored when using --with-git-submodules=ignore.
71+
72+Signed-off-by: Dan Streetman <ddstreet@canonical.com>
73+Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
74+---
75+ Makefile | 24 ++-----------------
76+ configure | 51 ++++++++++++++++++++++++++++++----------
77+ scripts/git-submodule.sh | 34 ++++++++++++++++++++-------
78+ 3 files changed, 66 insertions(+), 43 deletions(-)
79+
80+--- a/Makefile
81++++ b/Makefile
82+@@ -21,33 +21,11 @@ ifneq ($(wildcard config-host.mak),)
83+ all:
84+ include config-host.mak
85+
86+-git-submodule-update:
87+-
88+ .PHONY: git-submodule-update
89+-
90+-git_module_status := $(shell \
91+- cd '$(SRC_PATH)' && \
92+- GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
93+- echo $$?; \
94+-)
95+-
96+-ifeq (1,$(git_module_status))
97+-ifeq (no,$(GIT_UPDATE))
98+-git-submodule-update:
99+- $(call quiet-command, \
100+- echo && \
101+- echo "GIT submodule checkout is out of date. Please run" && \
102+- echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
103+- echo "from the source directory checkout $(SRC_PATH)" && \
104+- echo && \
105+- exit 1)
106+-else
107+ git-submodule-update:
108+ $(call quiet-command, \
109+- (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
110+- "GIT","$(GIT_SUBMODULES)")
111+-endif
112+-endif
113++ (GIT="$(GIT)" "$(SRC_PATH)/scripts/git-submodule.sh" $(GIT_SUBMODULES_ACTION) $(GIT_SUBMODULES)), \
114++ "GIT","$(GIT_SUBMODULES)")
115+
116+ .git-submodule-status: git-submodule-update config-host.mak
117+
118+--- a/configure
119++++ b/configure
120+@@ -307,12 +307,12 @@ gdb_bin=$(command -v "gdb")
121+
122+ if test -e "$source_path/.git"
123+ then
124+- git_update=yes
125++ git_submodules_action="update"
126+ git_submodules="ui/keycodemapdb"
127+ git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
128+ git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
129+ else
130+- git_update=no
131++ git_submodules_action="ignore"
132+ git_submodules=""
133+
134+ if ! test -f "$source_path/ui/keycodemapdb/README"
135+@@ -1571,9 +1571,16 @@ for opt do
136+ ;;
137+ --with-git=*) git="$optarg"
138+ ;;
139+- --enable-git-update) git_update=yes
140++ --enable-git-update)
141++ git_submodules_action="update"
142++ echo "--enable-git-update deprecated, use --with-git-submodules=update"
143++ ;;
144++ --disable-git-update)
145++ git_submodules_action="validate"
146++ echo "--disable-git-update deprecated, use --with-git-submodules=validate"
147+ ;;
148+- --disable-git-update) git_update=no
149++ --with-git-submodules=*)
150++ git_submodules_action="$optarg"
151+ ;;
152+ --enable-debug-mutex) debug_mutex=yes
153+ ;;
154+@@ -1609,6 +1616,21 @@ for opt do
155+ esac
156+ done
157+
158++case $git_submodules_action in
159++ update|validate)
160++ if test ! -e "$source_path/.git"; then
161++ echo "ERROR: cannot $git_submodules_action git submodules without .git"
162++ exit 1
163++ fi
164++ ;;
165++ ignore)
166++ ;;
167++ *)
168++ echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
169++ exit 1
170++ ;;
171++esac
172++
173+ case "$cpu" in
174+ ppc)
175+ CPU_CFLAGS="-m32"
176+@@ -1736,6 +1758,9 @@ Advanced options (experts only):
177+ --sphinx-build=SPHINX use specified sphinx-build [$sphinx_build]
178+ --smbd=SMBD use specified smbd [$smbd]
179+ --with-git=GIT use specified git [$git]
180++ --with-git-submodules=update update git submodules (default if .git dir exists)
181++ --with-git-submodules=validate fail if git submodules are not up to date
182++ --with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
183+ --static enable static build [$static]
184+ --mandir=PATH install man pages in PATH
185+ --datadir=PATH install firmware in PATH$confsuffix
186+@@ -1962,7 +1987,7 @@ fi
187+ # Consult white-list to determine whether to enable werror
188+ # by default. Only enable by default for git builds
189+ if test -z "$werror" ; then
190+- if test -e "$source_path/.git" && \
191++ if test $git_submodules_action != 'ignore' && \
192+ { test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
193+ werror="yes"
194+ else
195+@@ -4273,10 +4298,10 @@ EOF
196+ fdt=system
197+ else
198+ # have GIT checkout, so activate dtc submodule
199+- if test -e "${source_path}/.git" ; then
200++ if test $git_submodules_action != 'ignore' ; then
201+ git_submodules="${git_submodules} dtc"
202+ fi
203+- if test -d "${source_path}/dtc/libfdt" || test -e "${source_path}/.git" ; then
204++ if test -d "${source_path}/dtc/libfdt" || test $git_submodules_action != 'ignore' ; then
205+ fdt=git
206+ mkdir -p dtc
207+ if [ "$pwd_is_source_path" != "y" ] ; then
208+@@ -5231,7 +5256,7 @@ case "$capstone" in
209+ "" | yes)
210+ if $pkg_config capstone; then
211+ capstone=system
212+- elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
213++ elif test $git_submodules_action != 'ignore' ; then
214+ capstone=git
215+ elif test -e "${source_path}/capstone/Makefile" ; then
216+ capstone=internal
217+@@ -6206,7 +6231,7 @@ case "$slirp" in
218+ "" | yes)
219+ if $pkg_config slirp; then
220+ slirp=system
221+- elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
222++ elif test $git_submodules_action != 'ignore' ; then
223+ slirp=git
224+ elif test -e "${source_path}/slirp/Makefile" ; then
225+ slirp=internal
226+@@ -6791,7 +6816,7 @@ echo "libs_cpu=$libs_cpu" >> $config_hos
227+ echo "libs_softmmu=$libs_softmmu" >> $config_host_mak
228+ echo "GIT=$git" >> $config_host_mak
229+ echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
230+-echo "GIT_UPDATE=$git_update" >> $config_host_mak
231++echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
232+
233+ echo "ARCH=$ARCH" >> $config_host_mak
234+
235+--- a/scripts/git-submodule.sh
236++++ b/scripts/git-submodule.sh
237+@@ -9,9 +9,14 @@ command=$1
238+ shift
239+ maybe_modules="$@"
240+
241++# if --with-git-submodules=ignore, do nothing
242++test "$command" = "ignore" && exit 0
243++
244+ test -z "$GIT" && GIT=git
245+
246+-error() {
247++cd "$(dirname "$0")/.."
248++
249++update_error() {
250+ echo "$0: $*"
251+ echo
252+ echo "Unable to automatically checkout GIT submodules '$modules'."
253+@@ -24,7 +29,7 @@ error() {
254+ echo "Alternatively you may disable automatic GIT submodule checkout"
255+ echo "with:"
256+ echo
257+- echo " $ ./configure --disable-git-update"
258++ echo " $ ./configure --with-git-submodules=validate"
259+ echo
260+ echo "and then manually update submodules prior to running make, with:"
261+ echo
262+@@ -33,6 +38,19 @@ error() {
263+ exit 1
264+ }
265+
266++validate_error() {
267++ if test "$1" = "validate"; then
268++ echo "GIT submodules checkout is out of date, and submodules"
269++ echo "configured for validate only. Please run"
270++ echo " scripts/git-submodule.sh update $maybe_modules"
271++ echo "from the source directory or call configure with"
272++ echo " --with-git-submodules=update"
273++ echo "To disable GIT submodules validation, use"
274++ echo " --with-git-submodules=ignore"
275++ fi
276++ exit 1
277++}
278++
279+ modules=""
280+ for m in $maybe_modules
281+ do
282+@@ -52,18 +70,18 @@ then
283+ fi
284+
285+ case "$command" in
286+-status)
287++status|validate)
288+ if test -z "$maybe_modules"
289+ then
290+- test -s ${substat} && exit 1 || exit 0
291++ test -s ${substat} && validate_error "$command" || exit 0
292+ fi
293+
294+- test -f "$substat" || exit 1
295++ test -f "$substat" || validate_error "$command"
296+ for module in $modules; do
297+ CURSTATUS=$($GIT submodule status $module)
298+ OLDSTATUS=$(cat $substat | grep $module)
299+ if test "$CURSTATUS" != "$OLDSTATUS"; then
300+- exit 1
301++ validate_error "$command"
302+ fi
303+ done
304+ exit 0
305+@@ -76,10 +94,10 @@ update)
306+ fi
307+
308+ $GIT submodule update --init $modules 1>/dev/null
309+- test $? -ne 0 && error "failed to update modules"
310++ test $? -ne 0 && update_error "failed to update modules"
311+
312+ $GIT submodule status $modules > "${substat}"
313+- test $? -ne 0 && error "failed to save git submodule status" >&2
314++ test $? -ne 0 && update_error "failed to save git submodule status" >&2
315+ ;;
316+ esac
317+
318diff --git a/debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-break-loop-if-a-null-block-number-i.patch b/debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-break-loop-if-a-null-block-number-i.patch
319new file mode 100644
320index 0000000..1df9421
321--- /dev/null
322+++ b/debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-break-loop-if-a-null-block-number-i.patch
323@@ -0,0 +1,40 @@
324+From 468184ec9024f4f7b55247f70ec57554e8a500d7 Mon Sep 17 00:00:00 2001
325+From: Marc Hartmayer <mhartmay@linux.ibm.com>
326+Date: Thu, 24 Sep 2020 10:59:25 +0200
327+Subject: [PATCH] pc-bios/s390-ccw: break loop if a null block number is
328+ reached
329+
330+Break the loop if `cur_block_nr` is a null block number because this
331+means that the end of chunk is reached. In this case we will try to
332+boot the default entry.
333+
334+Fixes: ba831b25262a ("s390-ccw: read stage2 boot loader data to find menu")
335+Reviewed-by: Collin Walling <walling@linux.ibm.com>
336+Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
337+Message-Id: <20200924085926.21709-3-mhartmay@linux.ibm.com>
338+Signed-off-by: Thomas Huth <thuth@redhat.com>
339+
340+Origin: upstream, https://git.qemu.org/?p=qemu.git;a=commit;h=468184ec9024
341+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1921468
342+Last-Update: 2021-03-26
343+
344+---
345+ pc-bios/s390-ccw/bootmap.c | 2 +-
346+ 1 file changed, 1 insertion(+), 1 deletion(-)
347+
348+diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
349+index 767bb612db..942fba3fa7 100644
350+--- a/pc-bios/s390-ccw/bootmap.c
351++++ b/pc-bios/s390-ccw/bootmap.c
352+@@ -192,7 +192,7 @@ static int eckd_get_boot_menu_index(block_number_t s1b_block_nr)
353+ for (i = 0; i < STAGE2_BLK_CNT_MAX; i++) {
354+ cur_block_nr = eckd_block_num(&s1b->seek[i].chs);
355+
356+- if (!cur_block_nr) {
357++ if (!cur_block_nr || is_null_block_number(cur_block_nr)) {
358+ break;
359+ }
360+
361+--
362+2.30.0
363+
364diff --git a/debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-fix-off-by-one-error.patch b/debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-fix-off-by-one-error.patch
365new file mode 100644
366index 0000000..b59bdad
367--- /dev/null
368+++ b/debian/patches/ubuntu/lp-1921468-pc-bios-s390-ccw-fix-off-by-one-error.patch
369@@ -0,0 +1,41 @@
370+From 5f97ba0c74ccace0a4014460de9751ff3c6f454a Mon Sep 17 00:00:00 2001
371+From: Marc Hartmayer <mhartmay@linux.ibm.com>
372+Date: Thu, 24 Sep 2020 10:59:24 +0200
373+Subject: [PATCH] pc-bios/s390-ccw: fix off-by-one error
374+
375+This error takes effect when the magic value "zIPL" is located at the
376+end of a block. For example if s2_cur_blk = 0x7fe18000 and the magic
377+value "zIPL" is located at 0x7fe18ffc - 0x7fe18fff.
378+
379+Fixes: ba831b25262a ("s390-ccw: read stage2 boot loader data to find menu")
380+Reviewed-by: Collin Walling <walling@linux.ibm.com>
381+Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
382+Message-Id: <20200924085926.21709-2-mhartmay@linux.ibm.com>
383+Reviewed-by: Thomas Huth <thuth@redhat.com>
384+[thuth: Use "<= ... - 4" instead of "< ... - 3"]
385+Signed-off-by: Thomas Huth <thuth@redhat.com>
386+
387+Origin: upstream, https://git.qemu.org/?p=qemu.git;a=commit;h=5f97ba0c74cc
388+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1921468
389+Last-Update: 2021-03-26
390+
391+---
392+ pc-bios/s390-ccw/bootmap.c | 2 +-
393+ 1 file changed, 1 insertion(+), 1 deletion(-)
394+
395+diff --git a/pc-bios/s390-ccw/bootmap.c b/pc-bios/s390-ccw/bootmap.c
396+index 0ef6b851f3..767bb612db 100644
397+--- a/pc-bios/s390-ccw/bootmap.c
398++++ b/pc-bios/s390-ccw/bootmap.c
399+@@ -163,7 +163,7 @@ static bool find_zipl_boot_menu_banner(int *offset)
400+ int i;
401+
402+ /* Menu banner starts with "zIPL" */
403+- for (i = 0; i < virtio_get_block_size() - 4; i++) {
404++ for (i = 0; i <= virtio_get_block_size() - 4; i++) {
405+ if (magic_match(s2_cur_blk + i, ZIPL_MAGIC_EBCDIC)) {
406+ *offset = i;
407+ return true;
408+--
409+2.30.0
410+
411diff --git a/debian/patches/ubuntu/lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch b/debian/patches/ubuntu/lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch
412new file mode 100644
413index 0000000..a4bdd17
414--- /dev/null
415+++ b/debian/patches/ubuntu/lp-1921665-1-block-Require-aligned-image-size-to-avoid-assert.patch
416@@ -0,0 +1,66 @@
417+From 9c60a5d1978e6dcf85c0e01b50e6f7f54ca09104 Mon Sep 17 00:00:00 2001
418+From: Kevin Wolf <kwolf@redhat.com>
419+Date: Thu, 16 Jul 2020 16:26:00 +0200
420+Subject: [PATCH] block: Require aligned image size to avoid assertion failure
421+
422+Unaligned requests will automatically be aligned to bl.request_alignment
423+and we can't extend write requests to access space beyond the end of the
424+image without resizing the image, so if we have the WRITE permission,
425+but not the RESIZE one, it's required that the image size is aligned.
426+
427+Failing to meet this requirement could cause assertion failures like
428+this if RESIZE permissions weren't requested:
429+
430+qemu-img: block/io.c:1910: bdrv_co_write_req_prepare: Assertion `end_sector <= bs->total_sectors || child->perm & BLK_PERM_RESIZE' failed.
431+
432+This was e.g. triggered by qemu-img converting to a target image with 4k
433+request alignment when the image was only aligned to 512 bytes, but not
434+to 4k.
435+
436+Turn this into a graceful error in bdrv_check_perm() so that WRITE
437+without RESIZE can only be taken if the image size is aligned. If a user
438+holds both permissions and drops only RESIZE, the function will return
439+an error, but bdrv_child_try_set_perm() will ignore the failure silently
440+if permissions are only requested to be relaxed and just keep both
441+permissions while returning success.
442+
443+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
444+Message-Id: <20200716142601.111237-2-kwolf@redhat.com>
445+Reviewed-by: Max Reitz <mreitz@redhat.com>
446+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
447+
448+Origin: backport, https://git.qemu.org/?p=qemu.git;a=commit;h=9c60a5d1978e6dcf85c0e01b50e6f7f54ca09104
449+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1921665
450+Last-Update: 2021-03-29
451+
452+---
453+ block.c | 16 ++++++++++++++++
454+ 1 file changed, 16 insertions(+)
455+
456+Index: qemu-5.0/block.c
457+===================================================================
458+--- qemu-5.0.orig/block.c 2021-03-29 16:46:50.775130508 +1300
459++++ qemu-5.0/block.c 2021-03-29 16:46:50.771130437 +1300
460+@@ -2031,6 +2031,22 @@
461+ return -EPERM;
462+ }
463+
464++ /*
465++ * Unaligned requests will automatically be aligned to bl.request_alignment
466++ * and without RESIZE we can't extend requests to write to space beyond the
467++ * end of the image, so it's required that the image size is aligned.
468++ */
469++ if ((cumulative_perms & (BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED)) &&
470++ !(cumulative_perms & BLK_PERM_RESIZE))
471++ {
472++ if ((bs->total_sectors * BDRV_SECTOR_SIZE) % bs->bl.request_alignment) {
473++ error_setg(errp, "Cannot get 'write' permission without 'resize': "
474++ "Image size is not a multiple of request "
475++ "alignment");
476++ return -EPERM;
477++ }
478++ }
479++
480+ /* Check this node */
481+ if (!drv) {
482+ return 0;
483diff --git a/debian/patches/ubuntu/lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch b/debian/patches/ubuntu/lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch
484new file mode 100644
485index 0000000..069a1bb
486--- /dev/null
487+++ b/debian/patches/ubuntu/lp-1921665-2-file-posix-Allow-byte-aligned-O_DIRECT-with-NFS.patch
488@@ -0,0 +1,86 @@
489+From 5edc85571e7b7269dce408735eba7507f18ac666 Mon Sep 17 00:00:00 2001
490+From: Kevin Wolf <kwolf@redhat.com>
491+Date: Thu, 16 Jul 2020 16:26:01 +0200
492+Subject: [PATCH] file-posix: Allow byte-aligned O_DIRECT with NFS
493+
494+Since commit a6b257a08e3 ('file-posix: Handle undetectable alignment'),
495+we assume that if we open a file with O_DIRECT and alignment probing
496+returns 1, we just couldn't find out the real alignment requirement
497+because some filesystems make the requirement only for allocated blocks.
498+In this case, a safe default of 4k is used.
499+
500+This is too strict for NFS, which does actually allow byte-aligned
501+requests even with O_DIRECT. Because we can't distinguish both cases
502+with generic code, let's just look at the file system magic and disable
503+s->needs_alignment for NFS. This way, O_DIRECT can still be used on NFS
504+for images that are not aligned to 4k.
505+
506+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
507+Reviewed-by: Eric Blake <eblake@redhat.com>
508+Message-Id: <20200716142601.111237-3-kwolf@redhat.com>
509+Reviewed-by: Max Reitz <mreitz@redhat.com>
510+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
511+
512+Origin: backport, https://git.qemu.org/?p=qemu.git;a=commit;h=5edc85571e7b7269dce408735eba7507f18ac666
513+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1921665
514+Last-Update: 2021-03-29
515+
516+---
517+ block/file-posix.c | 26 +++++++++++++++++++++++++-
518+ 1 file changed, 25 insertions(+), 1 deletion(-)
519+
520+Index: qemu-5.0/block/file-posix.c
521+===================================================================
522+--- qemu-5.0.orig/block/file-posix.c 2021-03-29 16:47:07.303430132 +1300
523++++ qemu-5.0/block/file-posix.c 2021-03-29 16:47:07.303430132 +1300
524+@@ -61,10 +61,12 @@
525+ #include <sys/ioctl.h>
526+ #include <sys/param.h>
527+ #include <sys/syscall.h>
528++#include <sys/vfs.h>
529+ #include <linux/cdrom.h>
530+ #include <linux/fd.h>
531+ #include <linux/fs.h>
532+ #include <linux/hdreg.h>
533++#include <linux/magic.h>
534+ #include <scsi/sg.h>
535+ #ifdef __s390__
536+ #include <asm/dasd.h>
537+@@ -299,6 +301,28 @@
538+ #endif
539+ }
540+
541++/*
542++ * Returns true if no alignment restrictions are necessary even for files
543++ * opened with O_DIRECT.
544++ *
545++ * raw_probe_alignment() probes the required alignment and assume that 1 means
546++ * the probing failed, so it falls back to a safe default of 4k. This can be
547++ * avoided if we know that byte alignment is okay for the file.
548++ */
549++static bool dio_byte_aligned(int fd)
550++{
551++#ifdef __linux__
552++ struct statfs buf;
553++ int ret;
554++
555++ ret = fstatfs(fd, &buf);
556++ if (ret == 0 && buf.f_type == NFS_SUPER_MAGIC) {
557++ return true;
558++ }
559++#endif
560++ return false;
561++}
562++
563+ /* Check if read is allowed with given memory buffer and length.
564+ *
565+ * This function is used to check O_DIRECT memory buffer and request alignment.
566+@@ -630,7 +654,7 @@
567+
568+ s->has_discard = true;
569+ s->has_write_zeroes = true;
570+- if ((bs->open_flags & BDRV_O_NOCACHE) != 0) {
571++ if ((bs->open_flags & BDRV_O_NOCACHE) != 0 && !dio_byte_aligned(s->fd)) {
572+ s->needs_alignment = true;
573+ }
574+
575diff --git a/debian/rules b/debian/rules
576index 2d1fa4e..c794d8f 100755
577--- a/debian/rules
578+++ b/debian/rules
579@@ -59,6 +59,7 @@ common_configure_opts = \
580 --disable-strip \
581 --interp-prefix=/etc/qemu-binfmt/%M \
582 --localstatedir=/var \
583+ --with-git-submodules=ignore \
584
585 # Cross compiling support
586 ifneq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))

Subscribers

People subscribed via source and target branches