Skip to contentSkip to conversation

more misc fixes for 8.0 (tests, gdbstub, meta, docs)

PATCH Superseded Alex Bennée 8 participants 38 messages Mar 30, 2023 – Apr 3, 2023 Arm/Amlogic Meson SoC support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover more misc fixes for 8.0 (tests, gdbstub, meta, docs)

Here are a few more random fixes across the tree. All should be good for the current phase of freeze although I can drop stuff if it causes problems.

I've included another run at using the kaniko build tool and will see if it improves the caching of things as it runs through my CI loop.

Alex.

Alex Bennée (6):
scripts/coverage: initial coverage comparison script
MAINTAINERS: add a section for policy documents
qemu-options: finesse the recommendations around -blockdev
metadata: add .git-blame-ignore-revs
gitlab: fix typo
tests/gitlab: use kaniko to build images

Daniel P. Berrangé (2):
tests/qemu-iotests: explicitly invoke 'check' via 'python' tests/vm: use the default system python for NetBSD

Kautuk Consul (1):
tests/requirements.txt: bump up avocado-framework version to 101.0

Marco Liebel (1):
Use hexagon toolchain version 16.0.0

Philippe Mathieu-Daudé (1):
gdbstub: Only build libgdb_user.fa / libgdb_softmmu.fa if necessary

 MAINTAINERS                                   |  18 +++
 .git-blame-ignore-revs                        |  21 ++++
 .gitlab-ci.d/base.yml                         |   2 +-
 .gitlab-ci.d/container-template.yml           |  22 ++--
 gdbstub/meson.build                           |   6 +-
 qemu-options.hx                               |   8 +-
 scripts/coverage/compare_gcov_json.py         | 118 ++++++++++++++++++
 .../dockerfiles/debian-hexagon-cross.docker   |   2 +-
 tests/qemu-iotests/meson.build                |   7 +-
 tests/requirements.txt                        |   2 +-
 tests/vm/netbsd                               |   3 +-
 11 files changed, 185 insertions(+), 24 deletions(-)
 create mode 100644 .git-blame-ignore-revs
 create mode 100755 scripts/coverage/compare_gcov_json.py
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/11 scripts/coverage: initial coverage comparison script

This is a very rough and ready first pass at comparing gcovr's json output between two different runs. At the moment it will give you a file level diff between two runs but hopefully it wont be too hard to extend to give better insight.

After generating the coverage results you run with something like:

  ./scripts/coverage/compare_gcov_json.py \
    -a ./builds/gcov.config1/coverage.json \
    -b ./builds/gcov.config2/coverage.json

My hope is we can use this to remove some redundancy from testing as well as evaluate if new tests are actually providing additional coverage or just burning our precious CI time.

---
v2
- add MAINTAINERS entry

---
 MAINTAINERS                           |   5 ++
 scripts/coverage/compare_gcov_json.py | 118 ++++++++++++++++++++++++++
 2 files changed, 123 insertions(+)
 create mode 100755 scripts/coverage/compare_gcov_json.py
MAINTAINERS +5 -0
index ef45b5e71e..9e1a60ea24 100644
@@ -3908,3 +3908,8 @@ Performance Tools and Tests
 M: Ahmed Karaman <[email protected]>
 S: Maintained
 F: scripts/performance/
+
+Code Coverage Tools
+M: Alex Bennée <[email protected]>
+S: Odd Fixes
+F: scripts/coverage/
scripts/coverage/compare_gcov_json.py new file +118 -0

118 lines not on this page · raw message

Signature · 1 line
2.39.2
Acked-by on v1 1/11
#2 lore raw

Re: [PATCH 01/11] scripts/coverage: initial coverage comparison script

Quoted 11 lines · Alex Bennée

This is a very rough and ready first pass at comparing gcovr's json output between two different runs. At the moment it will give you a file level diff between two runs but hopefully it wont be too hard to extend to give better insight.

After generating the coverage results you run with something like:

   ./scripts/coverage/compare_gcov_json.py \
     -a ./builds/gcov.config1/coverage.json \
     -b ./builds/gcov.config2/coverage.json
Quoted 5 lines

My hope is we can use this to remove some redundancy from testing as well as evaluate if new tests are actually providing additional coverage or just burning our precious CI time.

FWIW:

#3 lore raw

PATCH 2/11 gdbstub: Only build libgdb_user.fa / libgdb_softmmu.fa if necessary

In reply to Alex Bennée

From: Philippe Mathieu-Daudé <[email protected]>

It is pointless to build libgdb_user.fa in a system-only build (or libgdb_softmmu.fa in a user-only build). Besides, in some restricted build configurations, some APIs might be restricted / not available. Example in a KVM-only builds where TCG is disabled:

  $ ninja qemu-system-x86_64
  [99/2187] Compiling C object gdbstub/libgdb_user.fa.p/user.c.o
  FAILED: gdbstub/libgdb_user.fa.p/user.c.o
  ../../gdbstub/user.c: In function ‘gdb_breakpoint_insert’:
  ../../gdbstub/user.c:438:19: error: implicit declaration of function ‘cpu_breakpoint_insert’; did you mean ‘gdb_breakpoint_insert’? [-Werror=implicit-function-declaration]
    438 |             err = cpu_breakpoint_insert(cpu, addr, BP_GDB, NULL);
        |                   ^~~~~~~~~~~~~~~~~~~~~
        |                   gdb_breakpoint_insert
  ../../gdbstub/user.c:438:19: error: nested extern declaration of ‘cpu_breakpoint_insert’ [-Werror=nested-externs]
  ../../gdbstub/user.c: In function ‘gdb_breakpoint_remove’:
  ../../gdbstub/user.c:459:19: error: implicit declaration of function ‘cpu_breakpoint_remove’; did you mean ‘gdb_breakpoint_remove’? [-Werror=implicit-function-declaration]
    459 |             err = cpu_breakpoint_remove(cpu, addr, BP_GDB);
        |                   ^~~~~~~~~~~~~~~~~~~~~
        |                   gdb_breakpoint_remove
  ../../gdbstub/user.c:459:19: error: nested extern declaration of ‘cpu_breakpoint_remove’ [-Werror=nested-externs]
  cc1: all warnings being treated as errors
  ninja: build stopped: subcommand failed.
Fixes 61b2e136db ("gdbstub: only compile gdbstub twice for whole build")

Message-Id: <[email protected]>

---
 gdbstub/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
gdbstub/meson.build +4 -2
index bd5c5cd67d..cdb4d28691 100644
@@ -20,11 +20,13 @@ gdb_softmmu_ss = gdb_softmmu_ss.apply(config_host, strict: false)
 libgdb_user = static_library('gdb_user',
                              gdb_user_ss.sources() + genh,
                              name_suffix: 'fa',
-                             c_args: '-DCONFIG_USER_ONLY')
+                             c_args: '-DCONFIG_USER_ONLY',
+                             build_by_default: have_user)
 
 libgdb_softmmu = static_library('gdb_softmmu',
                                 gdb_softmmu_ss.sources() + genh,
-                                name_suffix: 'fa')
+                                name_suffix: 'fa',
+                                build_by_default: have_system)
 
 gdb_user = declare_dependency(link_whole: libgdb_user)
 user_ss.add(gdb_user)
Signature · 1 line
2.39.2
#4 lore raw

PATCH 3/11 MAINTAINERS: add a section for policy documents

In reply to Alex Bennée

We don't update these often but if you are the sort of person who enjoys debating and tuning project policies you could now add yourself as a reviewer here so you don't miss the next debate over tabs vs spaces ;-)

Who's with me?

Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kashyap Chamarthy <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Bernhard Beschow <[email protected]>

---
v2
- s/your/you are/
- add some willing victims

---
 MAINTAINERS | 13 +++++++++++++
 1 file changed, 13 insertions(+)
MAINTAINERS +13 -0
index 9e1a60ea24..2c173dbd96 100644
@@ -64,6 +64,19 @@ L: [email protected]
 F: *
 F: */
 
+Project policy and developer guides
+R: Alex Bennée <[email protected]>
+R: Daniel P. Berrangé <[email protected]>
+R: Thomas Huth <[email protected]>
+R: Markus Armbruster <[email protected]>
+W: https://www.qemu.org/docs/master/devel/index.html
+S: Odd Fixes
+F: docs/devel/style.rst
+F: docs/devel/code-of-conduct.rst
+F: docs/devel/conflict-resolution.rst
+F: docs/devel/submitting-a-patch.rst
+F: docs/devel/submitting-a-pull-request.rst
+
 Responsible Disclosure, Reporting Security Issues
 -------------------------------------------------
 W: https://wiki.qemu.org/SecurityProcess
Signature · 1 line
2.39.2
Reviewed-by on v1 3/11
#5 lore raw

Re: [PATCH 03/11] MAINTAINERS: add a section for policy documents

Quoted 35 lines · Alex Bennée

We don't update these often but if you are the sort of person who enjoys debating and tuning project policies you could now add yourself as a reviewer here so you don't miss the next debate over tabs vs spaces ;-)

Who's with me?

Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kashyap Chamarthy <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Bernhard Beschow <[email protected]>

---
v2
- s/your/you are/
- add some willing victims

---
  MAINTAINERS | 13 +++++++++++++
  1 file changed, 13 insertions(+)
MAINTAINERS +2 -0
index 9e1a60ea24..2c173dbd96 100644
@@ -64,6 +64,19 @@ L: [email protected]
  F: *
  F: */
 
+Project policy and developer guides
+R: Alex Bennée <[email protected]>

MAINTAINERS L: [email protected] · line 78

Quoted 10 lines
MAINTAINERS +10 -0
+R: Daniel P. Berrangé <[email protected]>
+R: Thomas Huth <[email protected]>
+R: Markus Armbruster <[email protected]>
+W: https://www.qemu.org/docs/master/devel/index.html
+S: Odd Fixes
+F: docs/devel/style.rst
+F: docs/devel/code-of-conduct.rst
+F: docs/devel/conflict-resolution.rst
+F: docs/devel/submitting-a-patch.rst
+F: docs/devel/submitting-a-pull-request.rst
Reviewed-by on v1 3/11
#6 lore raw

Re: [PATCH 03/11] MAINTAINERS: add a section for policy documents

In reply to Alex Bennée
Quoted 7 lines · Alex Bennée

We don't update these often but if you are the sort of person who enjoys debating and tuning project policies you could now add yourself as a reviewer here so you don't miss the next debate over tabs vs spaces ;-)

Who's with me?

Quoted 9 lines
Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kashyap Chamarthy <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Bernhard Beschow <[email protected]>
Reviewed-by on v1 3/11
#7 lore raw

Re: [PATCH 03/11] MAINTAINERS: add a section for policy documents

In reply to Alex Bennée

Alex,

Quoted 7 lines · Alex Bennée

We don't update these often but if you are the sort of person who enjoys debating and tuning project policies you could now add yourself as a reviewer here so you don't miss the next debate over tabs vs spaces ;-)

Who's with me?

Quoted 10 lines
Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kashyap Chamarthy <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Bernhard Beschow <[email protected]>

Since I'm not on the list, I approve :). I had enough dealing with code of conduct issues with FreeBSD to last for any number of years...

Warner

Quoted 36 lines

---
v2
- s/your/you are/
- add some willing victims

---
 MAINTAINERS | 13 +++++++++++++
 1 file changed, 13 insertions(+)
MAINTAINERS +13 -1
index 9e1a60ea24..2c173dbd96 100644
@@ -64,6 +64,19 @@ L: [email protected]
 F: *
 F: */
 
+Project policy and developer guides
+R: Alex Bennée <[email protected]>
+R: Daniel P. Berrangé <[email protected]>
+R: Thomas Huth <[email protected]>
+R: Markus Armbruster <[email protected]>
+W: https://www.qemu.org/docs/master/devel/index.html
+S: Odd Fixes
+F: docs/devel/style.rst
+F: docs/devel/code-of-conduct.rst
+F: docs/devel/conflict-resolution.rst
+F: docs/devel/submitting-a-patch.rst
+F: docs/devel/submitting-a-pull-request.rst
+
 Responsible Disclosure, Reporting Security Issues
 -------------------------------------------------
 W: https://wiki.qemu.org/SecurityProcess
--

2.39.2

Reviewed-by on v1 3/11
#8 lore raw

Re: [PATCH 03/11] MAINTAINERS: add a section for policy documents

In reply to Alex Bennée
Quoted 6 lines · Alex Bennée

We don't update these often but if you are the sort of person who enjoys debating and tuning project policies you could now add yourself as a reviewer here so you don't miss the next debate over tabs vs spaces ;-)

Who's with me?

Happy to chip in wherever I can be useful :-)

Quoted 45 lines
Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kashyap Chamarthy <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Bernhard Beschow <[email protected]>

---
v2
- s/your/you are/
- add some willing victims

---
 MAINTAINERS | 13 +++++++++++++
 1 file changed, 13 insertions(+)
MAINTAINERS +13 -0
index 9e1a60ea24..2c173dbd96 100644
@@ -64,6 +64,19 @@ L: [email protected]
 F: *
 F: */
 
+Project policy and developer guides
+R: Alex Bennée <[email protected]>
+R: Daniel P. Berrangé <[email protected]>
+R: Thomas Huth <[email protected]>
+R: Markus Armbruster <[email protected]>
+W: https://www.qemu.org/docs/master/devel/index.html
+S: Odd Fixes
+F: docs/devel/style.rst
+F: docs/devel/code-of-conduct.rst
+F: docs/devel/conflict-resolution.rst
+F: docs/devel/submitting-a-patch.rst
+F: docs/devel/submitting-a-pull-request.rst
+
 Responsible Disclosure, Reporting Security Issues
 -------------------------------------------------
 W: https://wiki.qemu.org/SecurityProcess
Signature · 1 line
2.39.2
Signature · 1 line
/kashyap
Reviewed-by on v1 3/11
#9 lore raw

Re: [PATCH 03/11] MAINTAINERS: add a section for policy documents

In reply to Alex Bennée
Quoted 30 lines · Alex Bennée

We don't update these often but if you are the sort of person who enjoys debating and tuning project policies you could now add yourself as a reviewer here so you don't miss the next debate over tabs vs spaces ;-)

Who's with me?

Cc Thomas Huth <[email protected]>
Cc Daniel P. Berrangé <[email protected]>
Cc Markus Armbruster <[email protected]>
Cc Kashyap Chamarthy <[email protected]>
Cc Paolo Bonzini <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Philippe Mathieu-Daudé <[email protected]>
Cc Bernhard Beschow <[email protected]>

---
v2
- s/your/you are/
- add some willing victims

---
  MAINTAINERS | 13 +++++++++++++
  1 file changed, 13 insertions(+)
MAINTAINERS +0 -0
index 9e1a60ea24..2c173dbd96 100644

MAINTAINERS L: [email protected] · line 71

Quoted 8 lines
MAINTAINERS +5 -0
@@ -64,6 +64,19 @@ L: [email protected]
  F: *
  F: */
 
+Project policy and developer guides
+R: Alex Bennée <[email protected]>
+R: Daniel P. Berrangé <[email protected]>
+R: Thomas Huth <[email protected]>
+R: Markus Armbruster <[email protected]>

Please add me too.

Quoted 11 lines
MAINTAINERS +8 -0
+W: https://www.qemu.org/docs/master/devel/index.html
+S: Odd Fixes
+F: docs/devel/style.rst
+F: docs/devel/code-of-conduct.rst
+F: docs/devel/conflict-resolution.rst
+F: docs/devel/submitting-a-patch.rst
+F: docs/devel/submitting-a-pull-request.rst
+
  Responsible Disclosure, Reporting Security Issues
  -------------------------------------------------
  W: https://wiki.qemu.org/SecurityProcess
#10 lore raw

PATCH 4/11 qemu-options: finesse the recommendations around -blockdev

In reply to Alex Bennée

We are a bit premature in recommending -blockdev/-device as the best way to configure block devices, especially in the common case. Improve the language to hopefully make things clearer.

---
 qemu-options.hx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-options.hx +6 -2
index 59bdf67a2c..9a69ed838e 100644
@@ -1143,10 +1143,14 @@ have gone through several iterations as the feature set and complexity
 of the block layer have grown. Many online guides to QEMU often
 reference older and deprecated options, which can lead to confusion.
 
-The recommended modern way to describe disks is to use a combination of
+The most explicit way to describe disks is to use a combination of
 ``-device`` to specify the hardware device and ``-blockdev`` to
 describe the backend. The device defines what the guest sees and the
-backend describes how QEMU handles the data.
+backend describes how QEMU handles the data. The ``-drive`` option
+combines the device and backend into a single command line options
+which is useful in the majority of cases. Older options like ``-hda``
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.
 
 ERST
 
Signature · 1 line
2.39.2
Reviewed-by on v1 4/11
#11 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

Quoted 18 lines · Alex Bennée

We are a bit premature in recommending -blockdev/-device as the best way to configure block devices, especially in the common case. Improve the language to hopefully make things clearer.

---
  qemu-options.hx | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
qemu-options.hx +0 -0
index 59bdf67a2c..9a69ed838e 100644
@@ -1143,10 +1143,14 @@ have gone through several iterations as the feature set and complexity
  of the block layer have grown. Many online guides to QEMU often
  reference older and deprecated options, which can lead to confusion.
 

qemu-options.hx have gone through several iterations as the feature set and complexity · line 1153

Quoted 10 lines
qemu-options.hx +6 -2
-The recommended modern way to describe disks is to use a combination of
+The most explicit way to describe disks is to use a combination of
  ``-device`` to specify the hardware device and ``-blockdev`` to
  describe the backend. The device defines what the guest sees and the
-backend describes how QEMU handles the data.
+backend describes how QEMU handles the data. The ``-drive`` option
+combines the device and backend into a single command line options
+which is useful in the majority of cases. Older options like ``-hda``
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.
Reviewed-by on v1 4/11
#12 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

In reply to Alex Bennée
Quoted 18 lines · Alex Bennée

We are a bit premature in recommending -blockdev/-device as the best way to configure block devices, especially in the common case. Improve the language to hopefully make things clearer.

---
  qemu-options.hx | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
qemu-options.hx +0 -0
index 59bdf67a2c..9a69ed838e 100644
@@ -1143,10 +1143,14 @@ have gone through several iterations as the feature set and complexity
  of the block layer have grown. Many online guides to QEMU often
  reference older and deprecated options, which can lead to confusion.
 

qemu-options.hx have gone through several iterations as the feature set and complexity · line 1153

Quoted 10 lines
qemu-options.hx +6 -2
-The recommended modern way to describe disks is to use a combination of
+The most explicit way to describe disks is to use a combination of
  ``-device`` to specify the hardware device and ``-blockdev`` to
  describe the backend. The device defines what the guest sees and the
-backend describes how QEMU handles the data.
+backend describes how QEMU handles the data. The ``-drive`` option
+combines the device and backend into a single command line options
+which is useful in the majority of cases. Older options like ``-hda``
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.

This is a very welcome change, in my opinion.

Thank you Alex!

/mjt

#13 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

In reply to Alex Bennée
Quoted 16 lines · Alex Bennée

We are a bit premature in recommending -blockdev/-device as the best way to configure block devices, especially in the common case. Improve the language to hopefully make things clearer.

---
 qemu-options.hx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-options.hx +0 -0
index 59bdf67a2c..9a69ed838e 100644
@@ -1143,10 +1143,14 @@ have gone through several iterations as the feature set and complexity
 of the block layer have grown. Many online guides to QEMU often

qemu-options.hx have gone through several iterations as the feature set and complexity · line 1151

Quoted 10 lines
qemu-options.hx +4 -2
 reference older and deprecated options, which can lead to confusion.
 
-The recommended modern way to describe disks is to use a combination of
+The most explicit way to describe disks is to use a combination of
 ``-device`` to specify the hardware device and ``-blockdev`` to
 describe the backend. The device defines what the guest sees and the
-backend describes how QEMU handles the data.
+backend describes how QEMU handles the data. The ``-drive`` option
+combines the device and backend into a single command line options
+which is useful in the majority of cases.

-drive may look simpler from afar, but it really is a hot mess. Sadly, we can't get rid of it until we find a replacement for configuring onboard block devices. We might be able to clean it up some if we accept compatibility breaks. A new convenience option would be less confusing, I guess.

qemu-options.hx have gone through several iterations as the feature set and complexity · line 1155

Quoted 5 lines
qemu-options.hx +2 -0
                                           Older options like ``-hda``
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.
 
 ERST

These older options and the non-option argument are simple macros for -drive:

    IMG-FILE                    -drive index=0,file=IMG-FILE,media=disk
    -hda IMG-FILE               -drive index=0,file=IMG-FILE,media=disk
    -hdb IMG-FILE               -drive index=1,file=IMG-FILE,media=disk
    -hdc IMG-FILE               -drive index=2,file=IMG-FILE,media=disk
    -hdd IMG-FILE               -drive index=3,file=IMG-FILE,media=disk
    -cdrom IMG-FILE             -drive index=2,file=IMG-FILE,media=cdrom
    -fda IMG-FILE               -drive if=floppy,index=0,file=IMG-FILE
    -fdb IMG-FILE               -drive if=floppy,index=1,file=IMG-FILE
    -mtdblock IMG-FILE          -drive if=mtd,file=IMG-FILE
    -sd IMG-FILE                -drive if=sd,file=IMG-FILE
    -pflash IMG-FILE            -drive if=pflash,file=IMG-FILE

What assumptions do you have in mind?

I think you need at least Kevin's Acked-by for this.

#14 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

Quoted 20 lines · Markus Armbruster
Quoted 18 lines · Alex Bennée

We are a bit premature in recommending -blockdev/-device as the best way to configure block devices, especially in the common case. Improve the language to hopefully make things clearer.

---
 qemu-options.hx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-options.hx +0 -0
index 59bdf67a2c..9a69ed838e 100644
@@ -1143,10 +1143,14 @@ have gone through several iterations as the feature set and complexity
 of the block layer have grown. Many online guides to QEMU often
 reference older and deprecated options, which can lead to confusion.
 
Quoted 14 lines

qemu-options.hx have gone through several iterations as the feature set and complexity

Quoted 8 lines
qemu-options.hx +4 -2
-The recommended modern way to describe disks is to use a combination of
+The most explicit way to describe disks is to use a combination of
 ``-device`` to specify the hardware device and ``-blockdev`` to
 describe the backend. The device defines what the guest sees and the
-backend describes how QEMU handles the data.
+backend describes how QEMU handles the data. The ``-drive`` option
+combines the device and backend into a single command line options
+which is useful in the majority of cases.

-drive may look simpler from afar, but it really is a hot mess. Sadly, we can't get rid of it until we find a replacement for configuring onboard block devices. We might be able to clean it up some if we accept compatibility breaks. A new convenience option would be less confusing, I guess.

This is only a partial revert of the original wording which others have pointed out was a little too prescriptive. I believe the case of snapshot was one where a pure device/blockdev command line is hard to use.

Quoted 21 lines

qemu-options.hx have gone through several iterations as the feature set and complexity · line 1155

Quoted 5 lines
qemu-options.hx +2 -0
                                           Older options like ``-hda``
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.
 
 ERST

These older options and the non-option argument are simple macros for -drive:

    IMG-FILE                    -drive index=0,file=IMG-FILE,media=disk
    -hda IMG-FILE               -drive index=0,file=IMG-FILE,media=disk
    -hdb IMG-FILE               -drive index=1,file=IMG-FILE,media=disk
    -hdc IMG-FILE               -drive index=2,file=IMG-FILE,media=disk
    -hdd IMG-FILE               -drive index=3,file=IMG-FILE,media=disk
    -cdrom IMG-FILE             -drive index=2,file=IMG-FILE,media=cdrom
    -fda IMG-FILE               -drive if=floppy,index=0,file=IMG-FILE
    -fdb IMG-FILE               -drive if=floppy,index=1,file=IMG-FILE
    -mtdblock IMG-FILE          -drive if=mtd,file=IMG-FILE
    -sd IMG-FILE                -drive if=sd,file=IMG-FILE
    -pflash IMG-FILE            -drive if=pflash,file=IMG-FILE
Quoted 1 line

What assumptions do you have in mind?

I was under the impression things like -hda wouldn't work say on an Arm machine because you don't know what sort of interface you might be using and -hda implies IDE. Where is this macro substitution done?

Quoted 1 line

I think you need at least Kevin's Acked-by for this.

In the ideal world I could convince the block maintainers to write a new section to the manual that explains the theory behind the block subsystem and how things interact and are put together. Until then this is merely a sticking plaster to make the manual a little more authoritative than then numerous example command lines our users blindly copy from online blog posts.

Of course we could* always ask our new AI overlords:

1. qemu-system-x86_64 -drive file=disk.img,format=raw,if=virtio
In this command, we are running QEMU on an x86_64 CPU architecture and creating a virtual block device using the file disk.img as its storage. The format of the file is set to raw, which means that it will be accessed directly as a block device. We are using the virtio interface to connect the block device to the virtual machine.

2. qemu-system-x86_64 -drive file=disk.img,format=qcow2,if=virtio
This command is similar to the first one, but the format of the disk.img file is set to qcow2. This means that the file is a disk image in the QEMU Copy-On-Write format, which allows for more efficient storage of virtual disks. We are still using the virtio interface to connect the device to the VM.

3. qemu-system-x86_64 -drive file=/dev/sda,if=virtio
In this command, we are using a physical block device as the backend for the virtual block device. The device we are using is /dev/sda, which is typically the first hard disk on a Linux system. We are still using the virtio interface to connect the device to the VM.

4. qemu-system-x86_64 -device ide-hd,drive=mydrive -drive file=disk.img,format=qcow2,id=mydrive
This command sets up two block devices for the virtual machine. The first device is connected using the ide-hd device type, and is connected to a virtual drive called mydrive. The second device is a qcow2 disk image file, also using the virtual drive mydrive. The id property on the second command tells QEMU to use the virtual drive with the identifier mydrive as the backend for this block device.

The differences between these commands lie in the backend layout of the virtual devices. In the first two commands, we are using file-based storage for the devices, with different formats. In the third command, we are using a physical block device as the backend. In the fourth command, we are using a combination of virtual and file-based storage, with virtual drives connected to individual devices. The choice of backend layout will depend on the specific requirements of the virtual machine and its workload.

5. `qemu-system-arm -machine virt,gic-version=3 -cpu cortex-a57 -drive file=disk1.qcow2,if=none,id=drive0 -device virtio-blk-device,drive=drive0 -blockdev node-name=my-snapshot,driver=qcow2,file=snapshot.qcow2,backing=drive0 -device virtio-blk-device,drive=my-snapshot In this command, we are using an "ARM virtual machine" and creating a block device using disk1.qcow2 file as its storage with if=none parameter to not attach it directly to the device. Then, we create a virtual device of virtio-blk-device type and connecting drive0 to it using the -device` option.

Next, we are creating a new block device named my-snapshot with the qcow2 driver using -blockdev and specifying file=snapshot.qcow2 as its storage. We are also specifying backing=drive0, which means the new block device is a snapshot of drive0. Finally, we are creating another virtual device of virtio-blk-device type and connecting my-snapshot to it using the -device option.

This command creates a snapshot of the original disk1.qcow2 image, which allows us to create clones of the original disk that are based on different points in time.

6. `qemu-system-ppc64 -M pseries -drive file=disk1.raw,if=none,id=drive0 -blockdev node-name=my-backup,driver=file,cache.direct=on,cache.no-flush=off,filename=backup.raw -blockdev node-name=my-snapshot,driver=qcow2,file=snapshot.qcow2,backing=my-backup -device virtio-blk-device,drive=my-snapshot In this command, we are using a "PowerPC64 virtual machine" machine type and creating a block device using disk1.raw as its storage with if=none` parameter to not attach it directly to the device.

Next, we are creating a backup block device using the file driver, and set cache.direct to on and cache.no-flush to off, which means that the write operations will go directly to the backup.raw image file and reduces the risk of data loss.

Then, we create a new block device named my-snapshot with the qcow2 driver using -blockdev and specifying file=snapshot.qcow2 as its storage. We are also specifying backing=my-backup, which means the new block device is a snapshot of my-backup. Finally, we are creating a virtual device of virtio-blk-device type and connecting my-snapshot to it using the -device option.

This command creates a snapshot of the my-backup block device, which can be used to recover data if the original disk becomes corrupted or lost. The cache options are used to ensure that write operations are written directly to the backup file, rather than being buffered in memory and potentially lost in the event of a system crash.

But even these stochastic parrots gloss over the meaning of such vagaries as if=none.

* just because we could doesn't mean we should

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#15 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

Quoted 63 lines · Alex Bennée
Quoted 20 lines · Markus Armbruster
Quoted 18 lines · Alex Bennée

We are a bit premature in recommending -blockdev/-device as the best way to configure block devices, especially in the common case. Improve the language to hopefully make things clearer.

---
 qemu-options.hx | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
qemu-options.hx +0 -0
index 59bdf67a2c..9a69ed838e 100644
@@ -1143,10 +1143,14 @@ have gone through several iterations as the feature set and complexity
 of the block layer have grown. Many online guides to QEMU often
 reference older and deprecated options, which can lead to confusion.
 
Quoted 14 lines

qemu-options.hx have gone through several iterations as the feature set and complexity

Quoted 8 lines
qemu-options.hx +4 -2
-The recommended modern way to describe disks is to use a combination of
+The most explicit way to describe disks is to use a combination of
 ``-device`` to specify the hardware device and ``-blockdev`` to
 describe the backend. The device defines what the guest sees and the
-backend describes how QEMU handles the data.
+backend describes how QEMU handles the data. The ``-drive`` option
+combines the device and backend into a single command line options
+which is useful in the majority of cases.

-drive may look simpler from afar, but it really is a hot mess. Sadly, we can't get rid of it until we find a replacement for configuring onboard block devices. We might be able to clean it up some if we accept compatibility breaks. A new convenience option would be less confusing, I guess.

This is only a partial revert of the original wording which others have pointed out was a little too prescriptive. I believe the case of snapshot was one where a pure device/blockdev command line is hard to use.

Quoted 21 lines

qemu-options.hx have gone through several iterations as the feature set and complexity · line 1155

Quoted 5 lines
qemu-options.hx +2 -0
                                           Older options like ``-hda``
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.
 
 ERST

These older options and the non-option argument are simple macros for -drive:

    IMG-FILE                    -drive index=0,file=IMG-FILE,media=disk
    -hda IMG-FILE               -drive index=0,file=IMG-FILE,media=disk
    -hdb IMG-FILE               -drive index=1,file=IMG-FILE,media=disk
    -hdc IMG-FILE               -drive index=2,file=IMG-FILE,media=disk
    -hdd IMG-FILE               -drive index=3,file=IMG-FILE,media=disk
    -cdrom IMG-FILE             -drive index=2,file=IMG-FILE,media=cdrom
    -fda IMG-FILE               -drive if=floppy,index=0,file=IMG-FILE
    -fdb IMG-FILE               -drive if=floppy,index=1,file=IMG-FILE
    -mtdblock IMG-FILE          -drive if=mtd,file=IMG-FILE
    -sd IMG-FILE                -drive if=sd,file=IMG-FILE
    -pflash IMG-FILE            -drive if=pflash,file=IMG-FILE
Quoted 5 lines
Quoted 1 line

What assumptions do you have in mind?

I was under the impression things like -hda wouldn't work say on an Arm machine because you don't know what sort of interface you might be using and -hda implies IDE. Where is this macro substitution done?

qemu_init() calls drive_add() for all these options.

drive_add(TYPE, INDEX, FILE, OPTSTR) creates a QemuOpts in group "drive". It sets "if" to if_name[TYPE] unless TYPE is IF_DEFAULT, "index" to INDEX unless it's negative, and "file" to FILE unless it's null. Then it parses OPTSTR on top.

For -hdX, the call looks like

                drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
                          HD_OPTS);

We pass IF_DEFAULT, so "if" remains unset. "index" is set to 0 for -hda, 1, for -hdb and so forth. "file" is set to the option argument. Since HD_OPTS is "media=disk", we set "media" to "disk".

The QemuOpts in config group "drive" get passed to drive_new() via drive_init_func(). Unset "if" defaults to the current machine's class's block_default_type.

If a machine doesn't set this member explicitly, it remains zero, which is IF_NONE. Documented in blockdev.h:

typedef enum {
IF_DEFAULT = -1, /* for use with drive_add() only */
/*
* IF_NONE must be zero, because we want MachineClass member
---> * block_default_type to default-initialize to IF_NONE

         */
        IF_NONE = 0,
        IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
        IF_COUNT
    } BlockInterfaceType;

Questions?

Quoted 11 lines
Quoted 1 line

I think you need at least Kevin's Acked-by for this.

In the ideal world I could convince the block maintainers to write a new section to the manual that explains the theory behind the block subsystem and how things interact and are put together. Until then this is merely a sticking plaster to make the manual a little more authoritative than then numerous example command lines our users blindly copy from online blog posts.

Of course we could* always ask our new AI overlords:

[...]

Quoted 1 line

* just because we could doesn't mean we should

Heh!

#16 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

Quoted 5 lines · Markus Armbruster
Quoted 3 lines · Alex Bennée
Quoted 1 line · Markus Armbruster

Alex Bennée <[email protected]> writes:

...

Quoted 32 lines
Quoted 3 lines

I was under the impression things like -hda wouldn't work say on an Arm machine because you don't know what sort of interface you might be using and -hda implies IDE. Where is this macro substitution done?

qemu_init() calls drive_add() for all these options.

drive_add(TYPE, INDEX, FILE, OPTSTR) creates a QemuOpts in group "drive". It sets "if" to if_name[TYPE] unless TYPE is IF_DEFAULT, "index" to INDEX unless it's negative, and "file" to FILE unless it's null. Then it parses OPTSTR on top.

For -hdX, the call looks like

                 drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
                           HD_OPTS);

We pass IF_DEFAULT, so "if" remains unset. "index" is set to 0 for -hda, 1, for -hdb and so forth. "file" is set to the option argument. Since HD_OPTS is "media=disk", we set "media" to "disk".

The QemuOpts in config group "drive" get passed to drive_new() via drive_init_func(). Unset "if" defaults to the current machine's class's block_default_type.

If a machine doesn't set this member explicitly, it remains zero, which is IF_NONE. Documented in blockdev.h:

typedef enum {
IF_DEFAULT = -1, /* for use with drive_add() only */
/*
* IF_NONE must be zero, because we want MachineClass member
---> * block_default_type to default-initialize to IF_NONE

Quoted 7 lines
          */
         IF_NONE = 0,
         IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
         IF_COUNT
     } BlockInterfaceType;

Questions?

How's the average user supposed to know that? Our qemu-options.hx just says: "-hda/-hdb file use 'file' as IDE hard disk 0/1 image"...

Thomas

#17 lore raw

Re: [PATCH 04/11] qemu-options: finesse the recommendations around -blockdev

Quoted 45 lines · Thomas Huth
Quoted 5 lines · Markus Armbruster
Quoted 3 lines · Alex Bennée
Quoted 1 line · Markus Armbruster

Alex Bennée <[email protected]> writes:

...

Quoted 38 lines
Quoted 3 lines

I was under the impression things like -hda wouldn't work say on an Arm machine because you don't know what sort of interface you might be using and -hda implies IDE. Where is this macro substitution done?

qemu_init() calls drive_add() for all these options.

drive_add(TYPE, INDEX, FILE, OPTSTR) creates a QemuOpts in group "drive". It sets "if" to if_name[TYPE] unless TYPE is IF_DEFAULT, "index" to INDEX unless it's negative, and "file" to FILE unless it's null. Then it parses OPTSTR on top.

For -hdX, the call looks like

                 drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
                           HD_OPTS);

We pass IF_DEFAULT, so "if" remains unset. "index" is set to 0 for -hda, 1, for -hdb and so forth. "file" is set to the option argument. Since HD_OPTS is "media=disk", we set "media" to "disk".

The QemuOpts in config group "drive" get passed to drive_new() via drive_init_func(). Unset "if" defaults to the current machine's class's block_default_type.

If a machine doesn't set this member explicitly, it remains zero, which is IF_NONE. Documented in blockdev.h:

typedef enum {
IF_DEFAULT = -1, /* for use with drive_add() only */
/*
* IF_NONE must be zero, because we want MachineClass member
---> * block_default_type to default-initialize to IF_NONE

          */
         IF_NONE = 0,
         IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
         IF_COUNT
     } BlockInterfaceType;
Quoted 4 lines
Quoted 1 line

Questions?

How's the average user supposed to know that? Our qemu-options.hx just says:
"-hda/-hdb file use 'file' as IDE hard disk 0/1 image"...

Ancient doc bug. Should have been updated in commit 2d0d2837dcf (Support default block interfaces per QEMUMachine) back in 2012.

#18 lore raw

PATCH 5/11 metadata: add .git-blame-ignore-revs

In reply to Alex Bennée

Someone mentioned this on IRC so I thought I would try it out with a few commits that are pure code style fixes.

Message-Id: <[email protected]>

---
 .git-blame-ignore-revs | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 .git-blame-ignore-revs
.git-blame-ignore-revs new file +21 -0
new file mode 100644
index 0000000000..fa01e77a1e
@@ -0,0 +1,21 @@
+#
+# List of code-formatting clean ups the git blame can ignore
+#
+#   git blame --ignore-revs-file .git-blame-ignore-revs
+#
+# or
+#
+#   git config blame.ignoreRevsFile .git-blame-ignore-revs
+#
+
+# gdbstub: clean-up indents
+ad9e4585b3c7425759d3eea697afbca71d2c2082
+
+# e1000e: fix code style
+0eadd56bf53ab196a16d492d7dd31c62e1c24c32
+
+# target/riscv: coding style fixes
+8c7feddddd9218b407792120bcfda0347ed16205
+
+# replace TABs with spaces
++48805df9c22a0700fba4b3b548fafaa21726ca68
Signature · 1 line
2.39.2
#19 lore raw

Re: [PATCH 05/11] metadata: add .git-blame-ignore-revs

Quoted 29 lines · Alex Bennée

Someone mentioned this on IRC so I thought I would try it out with a few commits that are pure code style fixes.

Message-Id: <[email protected]>

---
  .git-blame-ignore-revs | 21 +++++++++++++++++++++
  1 file changed, 21 insertions(+)

create mode 100644 .git-blame-ignore-revs

.git-blame-ignore-revs new file +11 -0
new file mode 100644
index 0000000000..fa01e77a1e
@@ -0,0 +1,21 @@
+#
+# List of code-formatting clean ups the git blame can ignore
+#
+#   git blame --ignore-revs-file .git-blame-ignore-revs
+#
+# or
+#
+#   git config blame.ignoreRevsFile .git-blame-ignore-revs
+#
+
+# gdbstub: clean-up indents

.git-blame-ignore-revs line 21

Quoted 10 lines
.git-blame-ignore-revs new file +10 -0
+ad9e4585b3c7425759d3eea697afbca71d2c2082
+
+# e1000e: fix code style
+0eadd56bf53ab196a16d492d7dd31c62e1c24c32
+
+# target/riscv: coding style fixes
+8c7feddddd9218b407792120bcfda0347ed16205
+
+# replace TABs with spaces
++48805df9c22a0700fba4b3b548fafaa21726ca68

Looks like there is a superfluous "+" at the beginning of the last line?

Thomas

#20 lore raw

PATCH 6/11 Use hexagon toolchain version 16.0.0

In reply to Alex Bennée

From: Marco Liebel <[email protected]>

Message-Id: <[email protected]>

---
 tests/docker/dockerfiles/debian-hexagon-cross.docker | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/docker/dockerfiles/debian-hexagon-cross.docker +1 -1
index 5308ccb8fe..b99d99f943 100644
@@ -27,7 +27,7 @@ RUN apt-get update && \
 
 
 ENV TOOLCHAIN_INSTALL /opt
-ENV TOOLCHAIN_RELEASE 15.0.3
+ENV TOOLCHAIN_RELEASE 16.0.0
 ENV TOOLCHAIN_BASENAME "clang+llvm-${TOOLCHAIN_RELEASE}-cross-hexagon-unknown-linux-musl"
 ENV TOOLCHAIN_URL https://codelinaro.jfrog.io/artifactory/codelinaro-toolchain-for-hexagon/v${TOOLCHAIN_RELEASE}/${TOOLCHAIN_BASENAME}.tar.xz
 
Signature · 1 line
2.39.2
#21 lore raw

PATCH 7/11 tests/qemu-iotests: explicitly invoke 'check' via 'python'

In reply to Alex Bennée

From: Daniel P. Berrangé <[email protected]>

The 'check' script will use "#!/usr/bin/env python3" by default to locate python, but this doesn't work in distros which lack a bare 'python3' binary like NetBSD.

We need to explicitly invoke 'check' by referring to the 'python' variable in meson, which resolves to the detected python binary that QEMU intends to use.

This fixes a regression introduced by

commit 51ab5f8bd795d8980351f8531e54995ff9e6d163
Author: Daniel P. Berrangé <[email protected]>
Date: Wed Mar 15 17:43:23 2023 +0000

iotests: register each I/O test separately with meson

Message-Id: <[email protected]>

---
 tests/qemu-iotests/meson.build | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tests/qemu-iotests/meson.build +4 -3
index a162f683ef..9735071a29 100644
@@ -47,19 +47,20 @@ foreach format, speed: qemu_iotests_formats
   endif
 
   rc = run_command(
-      [qemu_iotests_check_cmd] + args + ['-n'],
+      [python, qemu_iotests_check_cmd] + args + ['-n'],
       check: true,
   )
 
   foreach item: rc.stdout().strip().split()
-      args = ['-tap', '-' + format, item,
+      args = [qemu_iotests_check_cmd,
+              '-tap', '-' + format, item,
               '--source-dir', meson.current_source_dir(),
               '--build-dir', meson.current_build_dir()]
       # Some individual tests take as long as 45 seconds
       # Bump the timeout to 3 minutes for some headroom
       # on slow machines to minimize spurious failures
       test('io-' + format + '-' + item,
-           qemu_iotests_check_cmd,
+           python,
            args: args,
            depends: qemu_iotests_binaries,
            env: qemu_iotests_env,
Signature · 1 line
2.39.2
Reviewed-by on v1 7/11
#22 lore raw

Re: [PATCH 07/11] tests/qemu-iotests: explicitly invoke 'check' via 'python'

Quoted 45 lines · Alex Bennée

From: Daniel P. Berrangé <[email protected]>

The 'check' script will use "#!/usr/bin/env python3" by default to locate python, but this doesn't work in distros which lack a bare 'python3' binary like NetBSD.

We need to explicitly invoke 'check' by referring to the 'python' variable in meson, which resolves to the detected python binary that QEMU intends to use.

This fixes a regression introduced by

commit 51ab5f8bd795d8980351f8531e54995ff9e6d163
Author: Daniel P. Berrangé <[email protected]>
Date: Wed Mar 15 17:43:23 2023 +0000

iotests: register each I/O test separately with meson

Message-Id: <[email protected]>

---
  tests/qemu-iotests/meson.build | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
tests/qemu-iotests/meson.build +3 -2
index a162f683ef..9735071a29 100644
@@ -47,19 +47,20 @@ foreach format, speed: qemu_iotests_formats
    endif
 
    rc = run_command(
-      [qemu_iotests_check_cmd] + args + ['-n'],
+      [python, qemu_iotests_check_cmd] + args + ['-n'],
        check: true,
    )
 
    foreach item: rc.stdout().strip().split()
-      args = ['-tap', '-' + format, item,
+      args = [qemu_iotests_check_cmd,
+              '-tap', '-' + format, item,
                '--source-dir', meson.current_source_dir(),

tests/qemu-iotests/meson.build foreach format, speed: qemu_iotests_formats · line 66

Quoted 10 lines
tests/qemu-iotests/meson.build +1 -1
                '--build-dir', meson.current_build_dir()]
        # Some individual tests take as long as 45 seconds
        # Bump the timeout to 3 minutes for some headroom
        # on slow machines to minimize spurious failures
        test('io-' + format + '-' + item,
-           qemu_iotests_check_cmd,
+           python,
             args: args,
             depends: qemu_iotests_binaries,
             env: qemu_iotests_env,
#23 lore raw

PATCH 8/11 tests/vm: use the default system python for NetBSD

In reply to Alex Bennée

From: Daniel P. Berrangé <[email protected]>

Currently our NetBSD VM recipe requests instal of the python37 package and explicitly tells QEMU to use that version of python. Since the NetBSD base ISO was updated to version 9.3 though, the default system python version is 3.9 which is sufficiently new for QEMU to rely on. Rather than requesting an older python, just test against the default system python which is what most users will have.

Message-Id: <[email protected]>

---
 tests/vm/netbsd | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tests/vm/netbsd +1 -2
index aa54338dfa..0b9536ca17 100755
@@ -30,7 +30,6 @@ class NetBSDVM(basevm.BaseVM):
         "git-base",
         "pkgconf",
         "xz",
-        "python37",
         "ninja-build",
 
         # gnu tools
@@ -66,7 +65,7 @@ class NetBSDVM(basevm.BaseVM):
         mkdir src build; cd src;
         tar -xf /dev/rld1a;
         cd ../build
-        ../src/configure --python=python3.7 --disable-opengl {configure_opts};
+        ../src/configure --disable-opengl {configure_opts};
         gmake --output-sync -j{jobs} {target} {verbose};
     """
     poweroff = "/sbin/poweroff"
Signature · 1 line
2.39.2
Reviewed-by on v1 8/11
#24 lore raw

Re: [PATCH 08/11] tests/vm: use the default system python for NetBSD

Quoted 31 lines · Alex Bennée

From: Daniel P. Berrangé <[email protected]>

Currently our NetBSD VM recipe requests instal of the python37 package and explicitly tells QEMU to use that version of python. Since the NetBSD base ISO was updated to version 9.3 though, the default system python version is 3.9 which is sufficiently new for QEMU to rely on. Rather than requesting an older python, just test against the default system python which is what most users will have.

Message-Id: <[email protected]>

---
  tests/vm/netbsd | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tests/vm/netbsd +0 -1
index aa54338dfa..0b9536ca17 100755
@@ -30,7 +30,6 @@ class NetBSDVM(basevm.BaseVM):
          "git-base",
          "pkgconf",
          "xz",
-        "python37",
          "ninja-build",
 
          # gnu tools

tests/vm/netbsd class NetBSDVM(basevm.BaseVM): · line 71

Quoted 8 lines
tests/vm/netbsd +1 -1
@@ -66,7 +65,7 @@ class NetBSDVM(basevm.BaseVM):
          mkdir src build; cd src;
          tar -xf /dev/rld1a;
          cd ../build
-        ../src/configure --python=python3.7 --disable-opengl {configure_opts};
+        ../src/configure --disable-opengl {configure_opts};
          gmake --output-sync -j{jobs} {target} {verbose};
      """
      poweroff = "/sbin/poweroff"
#25 lore raw

PATCH 9/11 tests/requirements.txt: bump up avocado-framework version to 101.0

In reply to Alex Bennée

From: Kautuk Consul <[email protected]>

Avocado version 101.0 has a fix to re-compute the checksum of an asset file if the algorithm used in the *-CHECKSUM file isn't the same as the one being passed to it by the avocado user (i.e. the avocado_qemu python module). In the earlier avocado versions this fix wasn't there due to which if the checksum wouldn't match the earlier checksum (calculated by a different algorithm), the avocado code would start downloading a fresh image from the internet URL thus making the test-cases take longer to execute.

Bump up the avocado-framework version to 101.0.

Message-Id: <[email protected]>

---
 tests/requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/requirements.txt +1 -1
index 0ba561b6bd..a6f73da681 100644
@@ -2,5 +2,5 @@
 # in the tests/venv Python virtual environment. For more info,
 # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
 # Note that qemu.git/python/ is always implicitly installed.
-avocado-framework==88.1
+avocado-framework==101.0
 pycdlib==1.11.0
Signature · 1 line
2.39.2
#26 lore raw

Re: [PATCH 09/11] tests/requirements.txt: bump up avocado-framework version to 101.0

Quoted 26 lines · Alex Bennée

From: Kautuk Consul <[email protected]>

Avocado version 101.0 has a fix to re-compute the checksum of an asset file if the algorithm used in the *-CHECKSUM file isn't the same as the one being passed to it by the avocado user (i.e. the avocado_qemu python module). In the earlier avocado versions this fix wasn't there due to which if the checksum wouldn't match the earlier checksum (calculated by a different algorithm), the avocado code would start downloading a fresh image from the internet URL thus making the test-cases take longer to execute.

Bump up the avocado-framework version to 101.0.

Message-Id: <[email protected]>

---
  tests/requirements.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/requirements.txt +0 -0
index 0ba561b6bd..a6f73da681 100644

tests/requirements.txt line 6

Quoted 6 lines
tests/requirements.txt +1 -1
@@ -2,5 +2,5 @@
  # in the tests/venv Python virtual environment. For more info,
  # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
  # Note that qemu.git/python/ is always implicitly installed.
-avocado-framework==88.1
+avocado-framework==101.0
  pycdlib==1.11.0

Did you check whether the same amount of avocado tests still works as before? ... last time I tried to bump the version, a lot of things were failing, and I think Cleber was recently working on fixing things, but I haven't heart anything back from him yet that it would be OK to bump to a newer version now ... So upgrading to a new version of Avocado during the softfreeze sounds somewhat risky to me right now - I'd appreciate if we could do that after the release instead.

Thomas

#27 lore raw

Re: [PATCH 09/11] tests/requirements.txt: bump up avocado-framework version to 101.0

Quoted 27 lines · Thomas Huth
Quoted 26 lines · Alex Bennée

From: Kautuk Consul <[email protected]> Avocado version 101.0 has a fix to re-compute the checksum of an asset file if the algorithm used in the *-CHECKSUM file isn't the same as the one being passed to it by the avocado user (i.e. the avocado_qemu python module). In the earlier avocado versions this fix wasn't there due to which if the checksum wouldn't match the earlier checksum (calculated by a different algorithm), the avocado code would start downloading a fresh image from the internet URL thus making the test-cases take longer to execute. Bump up the avocado-framework version to 101.0.

Message-Id: <[email protected]>

---
  tests/requirements.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tests/requirements.txt +0 -1
index 0ba561b6bd..a6f73da681 100644
@@ -2,5 +2,5 @@
  # in the tests/venv Python virtual environment. For more info,
  # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
  # Note that qemu.git/python/ is always implicitly installed.
-avocado-framework==88.1
Quoted 8 lines

tests/requirements.txt line 6

Quoted 2 lines
tests/requirements.txt +1 -0
+avocado-framework==101.0
  pycdlib==1.11.0

Did you check whether the same amount of avocado tests still works as before? ... last time I tried to bump the version, a lot of things were failing, and I think Cleber was recently working on fixing things, but I haven't heart anything back from him yet that it would be OK to bump to a newer version now ...

I ran it on my default build and the only failure was:

(008/222) tests/avocado/boot_linux.py:BootLinuxS390X.test_s390_ccw_virtio_tcg: INTERRUPTED: timeout (240.01 s)

which passed on a retry. But now I realise with failfast it skipped a bunch:

RESULTS : PASS 46 | ERROR 0 | FAIL 0 | SKIP 174 | WARN 0 | INTERRUPT 1 | CANCEL 1
JOB TIME : 290.26 s

Quoted 3 lines

So upgrading to a new version of Avocado during the softfreeze sounds somewhat risky to me right now - I'd appreciate if we could do that after the release instead.

Sure. I was hoping we would speed up avocado a little by avoiding double downloads.

Quoted 2 lines

Thomas

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#28 lore raw

Re: [PATCH 09/11] tests/requirements.txt: bump up avocado-framework version to 101.0

Quoted 39 lines · Alex Bennée
Quoted 27 lines · Thomas Huth
Quoted 26 lines · Alex Bennée

From: Kautuk Consul <[email protected]> Avocado version 101.0 has a fix to re-compute the checksum of an asset file if the algorithm used in the *-CHECKSUM file isn't the same as the one being passed to it by the avocado user (i.e. the avocado_qemu python module). In the earlier avocado versions this fix wasn't there due to which if the checksum wouldn't match the earlier checksum (calculated by a different algorithm), the avocado code would start downloading a fresh image from the internet URL thus making the test-cases take longer to execute. Bump up the avocado-framework version to 101.0.

Message-Id: <[email protected]>

---
   tests/requirements.txt | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
tests/requirements.txt +0 -1
index 0ba561b6bd..a6f73da681 100644
@@ -2,5 +2,5 @@
   # in the tests/venv Python virtual environment. For more info,
   # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
   # Note that qemu.git/python/ is always implicitly installed.
-avocado-framework==88.1
Quoted 8 lines

tests/requirements.txt line 6

Quoted 2 lines
tests/requirements.txt +1 -0
+avocado-framework==101.0
   pycdlib==1.11.0

Did you check whether the same amount of avocado tests still works as before? ... last time I tried to bump the version, a lot of things were failing, and I think Cleber was recently working on fixing things, but I haven't heart anything back from him yet that it would be OK to bump to a newer version now ...

Quoted 5 lines

I ran it on my default build and the only failure was:

(008/222) tests/avocado/boot_linux.py:BootLinuxS390X.test_s390_ccw_virtio_tcg: INTERRUPTED: timeout (240.01 s)

which passed on a retry. But now I realise with failfast it skipped a bunch:

That one is also failing for me here when I apply the patch. Without the patch, the test is working fine. I think this needs more careful testing first - e.g. the tests are run in parallel now by default, which breaks a lot of our timeout settings.

Thomas

#29 lore raw

Re: [PATCH 09/11] tests/requirements.txt: bump up avocado-framework version to 101.0

Quoted 40 lines · Thomas Huth
Quoted 39 lines · Alex Bennée
Quoted 35 lines · Thomas Huth
Quoted 27 lines · Alex Bennée

From: Kautuk Consul <[email protected]> Avocado version 101.0 has a fix to re-compute the checksum of an asset file if the algorithm used in the *-CHECKSUM file isn't the same as the one being passed to it by the avocado user (i.e. the avocado_qemu python module). In the earlier avocado versions this fix wasn't there due to which if the checksum wouldn't match the earlier checksum (calculated by a different algorithm), the avocado code would start downloading a fresh image from the internet URL thus making the test-cases take longer to execute. Bump up the avocado-framework version to 101.0.

Message-Id: <[email protected]>
---
   tests/requirements.txt | 2 +-

   1 file changed, 1 insertion(+), 1 deletion(-)
tests/requirements.txt +1 -1
index 0ba561b6bd..a6f73da681 100644
@@ -2,5 +2,5 @@
    # in the tests/venv Python virtual environment. For more info,
    # refer to: https://pip.pypa.io/en/stable/user_guide/#id1
    # Note that qemu.git/python/ is always implicitly installed.
-avocado-framework==88.1
+avocado-framework==101.0
Quoted 1 line

   pycdlib==1.11.0

Did you check whether the same amount of avocado tests still works as before? ... last time I tried to bump the version, a lot of things were failing, and I think Cleber was recently working  on fixing things, but I haven't heart anything back from him yet that it would be OK to bump to a newer version now ...

Quoted 7 lines
Quoted 5 lines

I ran it on my default build and the only failure was:

  (008/222) tests/avocado/boot_linux.py:BootLinuxS390X.test_s390_ccw_virtio_tcg: INTERRUPTED: timeout (240.01 s)

which passed on a retry. But now I realise with failfast it skipped a bunch:

That one is also failing for me here when I apply the patch. Without the patch, the test is working fine. I think this needs more careful testing first - e.g. the tests are run in parallel now by default, which breaks a lot of our timeout settings.

FWIW, I think we likely want something like this added to this patch, so we avoid to run those tests in parallel (unless requested with -jX):

tests/Makefile.include +3 -0
diff a/tests/Makefile.include b/tests/Makefile.include
@@ -138,12 +138,15 @@ get-vm-image-fedora-31-%: check-venv
 # download all vm images, according to defined targets
 get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
 
+JOBS_OPTION=$(lastword -j1 $(filter-out -j, $(filter -j%, $(MAKEFLAGS))))
+
 check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
        $(call quiet-command, \
             $(TESTS_PYTHON) -m avocado \
             --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
             $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \
                        --filter-by-tags-include-empty-key) \
+            --max-parallel-tasks $(JOBS_OPTION:-j%=%) \
             $(AVOCADO_CMDLINE_TAGS) \
             $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS), \
             "AVOCADO", "tests/avocado")

That way we can avoid the timeout problems unless we found a proper solution for those.

Thomas

#30 lore raw

PATCH 10/11 gitlab: fix typo

In reply to Alex Bennée
---
 .gitlab-ci.d/base.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
.gitlab-ci.d/base.yml +1 -1
index 0274228de8..2fbb58d2a3 100644
@@ -75,5 +75,5 @@
     - if: '$QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
       when: manual
 
-    # Jobs can run if any jobs they depend on were successfull
+    # Jobs can run if any jobs they depend on were successful
     - when: on_success
Signature · 1 line
2.39.2
Reviewed-by on v1 10/11
#32 lore raw

Re: [PATCH 10/11] gitlab: fix typo

In reply to Alex Bennée
Quoted 10 lines · Alex Bennée
---
  .gitlab-ci.d/base.yml | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
.gitlab-ci.d/base.yml +0 -0
index 0274228de8..2fbb58d2a3 100644

.gitlab-ci.d/base.yml line 79

Quoted 6 lines
.gitlab-ci.d/base.yml +1 -1
@@ -75,5 +75,5 @@
      - if: '$QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
        when: manual
 
-    # Jobs can run if any jobs they depend on were successfull
+    # Jobs can run if any jobs they depend on were successful
      - when: on_success
#33 lore raw

PATCH 11/11 tests/gitlab: use kaniko to build images

In reply to Alex Bennée

Apparently the docker-in-docker approach has some flaws including needing privileged mode to run and being quite slow. An alternative approach is to use Google's kaniko tool. It also works across different gitlab executors.

Following the gitlab example code we drop all the direct docker calls and usage of the script and make a direct call to kaniko and hope the images are cacheable by others.

Message-Id: <[email protected]>

---
v2
- add danpb's --cache suggestions

---
 .gitlab-ci.d/container-template.yml | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
.gitlab-ci.d/container-template.yml +10 -12
index 519b8a9482..cd8e0a1ff6 100644
@@ -1,21 +1,19 @@
 .container_job_template:
   extends: .base_job_template
-  image: docker:stable
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
   stage: containers
-  services:
-    - docker:dind
   before_script:
     - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
     - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
-    - apk add python3
-    - docker info
-    - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
   script:
     - echo "TAG:$TAG"
     - echo "COMMON_TAG:$COMMON_TAG"
-    - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
-      --build-arg BUILDKIT_INLINE_CACHE=1
-      -f "tests/docker/dockerfiles/$NAME.docker" "."
-    - docker push "$TAG"
-  after_script:
-    - docker logout
+    - /kaniko/executor
+          --reproducible
+          --context "${CI_PROJECT_DIR}"
+          --cache=true
+          --cache-repo "${COMMON_TAG}"
+          --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
+          --destination "${TAG}"
Signature · 1 line
2.39.2
#34 lore raw

Re: [PATCH 11/11] tests/gitlab: use kaniko to build images

Quoted 43 lines · Alex Bennée

Apparently the docker-in-docker approach has some flaws including needing privileged mode to run and being quite slow. An alternative approach is to use Google's kaniko tool. It also works across different gitlab executors.

Following the gitlab example code we drop all the direct docker calls and usage of the script and make a direct call to kaniko and hope the images are cacheable by others.

Message-Id: <[email protected]>

---
v2
- add danpb's --cache suggestions

---
 .gitlab-ci.d/container-template.yml | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
.gitlab-ci.d/container-template.yml +3 -7
index 519b8a9482..cd8e0a1ff6 100644
@@ -1,21 +1,19 @@
 .container_job_template:
   extends: .base_job_template
-  image: docker:stable
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
   stage: containers
-  services:
-    - docker:dind
   before_script:
     - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
     - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
-    - apk add python3
-    - docker info
-    - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
   script:
     - echo "TAG:$TAG"
     - echo "COMMON_TAG:$COMMON_TAG"
-    - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"

.gitlab-ci.d/container-template.yml line 17

Quoted 10 lines
.gitlab-ci.d/container-template.yml +5 -5
-      --build-arg BUILDKIT_INLINE_CACHE=1
-      -f "tests/docker/dockerfiles/$NAME.docker" "."
-    - docker push "$TAG"
-  after_script:
-    - docker logout
+    - /kaniko/executor
+          --reproducible
+          --context "${CI_PROJECT_DIR}"
+          --cache=true
+          --cache-repo "${COMMON_TAG}"

IIRC with docker if we told it to cache we would have to first have done a 'docker pull $COMMON_TAG' as it wouldn't pull down the image if it was not already local. I'm fuzzy on whether kaniko has the same need or not ? I guess we were broken already in that respect as we already uses --cache-from with docker without a docker pull

.gitlab-ci.d/container-template.yml line 19

Quoted 2 lines
.gitlab-ci.d/container-template.yml +2 -0
+          --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
+          --destination "${TAG}"

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#35 lore raw

Re: [PATCH 11/11] tests/gitlab: use kaniko to build images

Quoted 52 lines · Daniel P. Berrangé
Quoted 51 lines · Alex Bennée

Apparently the docker-in-docker approach has some flaws including needing privileged mode to run and being quite slow. An alternative approach is to use Google's kaniko tool. It also works across different gitlab executors.

Following the gitlab example code we drop all the direct docker calls and usage of the script and make a direct call to kaniko and hope the images are cacheable by others.

Message-Id: <[email protected]>

---
v2
- add danpb's --cache suggestions

---
 .gitlab-ci.d/container-template.yml | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
.gitlab-ci.d/container-template.yml +6 -12
index 519b8a9482..cd8e0a1ff6 100644
@@ -1,21 +1,19 @@
 .container_job_template:
   extends: .base_job_template
-  image: docker:stable
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
   stage: containers
-  services:
-    - docker:dind
   before_script:
     - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
     - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
-    - apk add python3
-    - docker info
-    - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
   script:
     - echo "TAG:$TAG"
     - echo "COMMON_TAG:$COMMON_TAG"
-    - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
-      --build-arg BUILDKIT_INLINE_CACHE=1
-      -f "tests/docker/dockerfiles/$NAME.docker" "."
-    - docker push "$TAG"
-  after_script:
-    - docker logout
+    - /kaniko/executor
+          --reproducible
+          --context "${CI_PROJECT_DIR}"
Quoted 8 lines

.gitlab-ci.d/container-template.yml line 17

Quoted 2 lines
.gitlab-ci.d/container-template.yml +2 -0
+          --cache=true
+          --cache-repo "${COMMON_TAG}"

IIRC with docker if we told it to cache we would have to first have done a 'docker pull $COMMON_TAG' as it wouldn't pull down the image if it was not already local. I'm fuzzy on whether kaniko has the same need or not ? I guess we were broken already in that respect as we already uses --cache-from with docker without a docker pull

Oh never mind, because we're not docker-in-docker, we can't pull the image tag down locally, and as discussed on IRC, caching works in a very different way. kaniko wants to be able to push & pull in the cache-repo itself.

I'm inclined to think we're better off ignoring layer caching and instead focus on entirely skipping execution of kaniko if we know the dockerfile has not changed eg something along the lines of:

   manifest=$(curl ....some registry URL to fetch image metadata)
   oldchecksum=$(...extract a LABEL from metadata container dockerfile sha256)
   newchecksum=$(sha256sum tests/docker/dockerfiles/$NAME.docker)

if test $oldchecksum != $newchecksum -o -n $QEMU_FORCE_REBUILD" then

      - /kaniko/executor
            --reproducible
            --context "${CI_PROJECT_DIR}"
            --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
	    --label DKR_CHECKSUM=$newchecksum
            --destination "${TAG}"

fi

And then have a weekly pipeline on sundays that sets QEMU_FORCE_REBUILD=1 so that we pick up changes from the distro base images, and/or package repes regularly.

With regards,
Daniel

Signature · 3 lines
|: 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 :|
#36 lore raw

Re: [PATCH 11/11] tests/gitlab: use kaniko to build images

Quoted 86 lines · Daniel P. Berrangé
Quoted 52 lines · Daniel P. Berrangé
Quoted 51 lines · Alex Bennée

Apparently the docker-in-docker approach has some flaws including needing privileged mode to run and being quite slow. An alternative approach is to use Google's kaniko tool. It also works across different gitlab executors.

Following the gitlab example code we drop all the direct docker calls and usage of the script and make a direct call to kaniko and hope the images are cacheable by others.

Message-Id: <[email protected]>

---
v2
- add danpb's --cache suggestions

---
 .gitlab-ci.d/container-template.yml | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
.gitlab-ci.d/container-template.yml +6 -12
index 519b8a9482..cd8e0a1ff6 100644
@@ -1,21 +1,19 @@
 .container_job_template:
   extends: .base_job_template
-  image: docker:stable
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
   stage: containers
-  services:
-    - docker:dind
   before_script:
     - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
     - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
-    - apk add python3
-    - docker info
-    - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
   script:
     - echo "TAG:$TAG"
     - echo "COMMON_TAG:$COMMON_TAG"
-    - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
-      --build-arg BUILDKIT_INLINE_CACHE=1
-      -f "tests/docker/dockerfiles/$NAME.docker" "."
-    - docker push "$TAG"
-  after_script:
-    - docker logout
+    - /kaniko/executor
+          --reproducible
+          --context "${CI_PROJECT_DIR}"
Quoted 8 lines

.gitlab-ci.d/container-template.yml line 17

Quoted 2 lines
.gitlab-ci.d/container-template.yml +2 -0
+          --cache=true
+          --cache-repo "${COMMON_TAG}"

IIRC with docker if we told it to cache we would have to first have done a 'docker pull $COMMON_TAG' as it wouldn't pull down the image if it was not already local. I'm fuzzy on whether kaniko has the same need or not ? I guess we were broken already in that respect as we already uses --cache-from with docker without a docker pull

Oh never mind, because we're not docker-in-docker, we can't pull the image tag down locally, and as discussed on IRC, caching works in a very different way. kaniko wants to be able to push & pull in the cache-repo itself.

I'm inclined to think we're better off ignoring layer caching and instead focus on entirely skipping execution of kaniko if we know the dockerfile has not changed eg something along the lines of:

   manifest=$(curl ....some registry URL to fetch image metadata)
   oldchecksum=$(...extract a LABEL from metadata container dockerfile sha256)
   newchecksum=$(sha256sum tests/docker/dockerfiles/$NAME.docker)
   if test $oldchecksum != $newchecksum -o -n $QEMU_FORCE_REBUILD"
   then
      - /kaniko/executor
            --reproducible
            --context "${CI_PROJECT_DIR}"
            --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
	    --label DKR_CHECKSUM=$newchecksum
            --destination "${TAG}"
   fi
Quoted 3 lines

And then have a weekly pipeline on sundays that sets QEMU_FORCE_REBUILD=1 so that we pick up changes from the distro base images, and/or package repes regularly.

Hmm this appears to be a dead end. I got to this:

--8<---------------cut here---------------start------------->8--- tests/gitlab: use kaniko to build images

Apparently the docker-in-docker approach has some flaws including needing privileged mode to run and being quite slow. An alternative approach is to use Google's kaniko tool. It also works across different gitlab executors.

Following the gitlab example code we drop all the direct docker calls and usage of the script and make a direct call to kaniko and hope the images are cacheable by others.

Message-Id: <[email protected]>

---
v2
- add danpb's --cache suggestions
v3
- don't include :latest in tag
- allow kaniko to infer local registry location, drop COMMON_TAG
- add registry login details
- version bump
- don't push cache layers

1 file changed, 13 insertions(+), 14 deletions(-)

.gitlab-ci.d/container-template.yml | 27 +++++++++++++--------------

modified .gitlab-ci.d/container-template.yml
@@ -1,21 +1,20 @@
.container_job_template:
extends: .base_job_template
- image: docker:stable
+ image:
+ name: gcr.io/kaniko-project/executor:v1.9.2-debug
+ entrypoint: [""]
stage: containers
- services:
- - docker:dind
before_script:

-    - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
-    - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
-    - apk add python3
-    - docker info
-    - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
+    - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME"

script:
- echo "TAG:$TAG"
- echo "COMMON_TAG:$COMMON_TAG"
- - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
- --build-arg BUILDKIT_INLINE_CACHE=1
- -f "tests/docker/dockerfiles/$NAME.docker" "."
- - docker push "$TAG"
- after_script:

-    - docker logout
+    - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(echo -n ${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD} | base64)\"}}}" > /kaniko/.docker/config.json
+    - /kaniko/executor
+          --reproducible
+          --context "${CI_PROJECT_DIR}"
+          --cache=true
+          --reproducible
+          --no-push-cache
+          --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
+          --destination "${TAG}"

--8<---------------cut here---------------end--------------->8---

However the builds are failing so I think I just need to drop this and move on.

Quoted 3 lines

With regards,
Daniel

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
Acked-by on v1 11/11
#37 lore raw

Re: [PATCH 11/11] tests/gitlab: use kaniko to build images

In reply to Alex Bennée
Quoted 45 lines · Alex Bennée

Apparently the docker-in-docker approach has some flaws including needing privileged mode to run and being quite slow. An alternative approach is to use Google's kaniko tool. It also works across different gitlab executors.

Following the gitlab example code we drop all the direct docker calls and usage of the script and make a direct call to kaniko and hope the images are cacheable by others.

Message-Id: <[email protected]>

---
v2
- add danpb's --cache suggestions

---
  .gitlab-ci.d/container-template.yml | 22 ++++++++++------------
  1 file changed, 10 insertions(+), 12 deletions(-)
.gitlab-ci.d/container-template.yml +3 -9
index 519b8a9482..cd8e0a1ff6 100644
@@ -1,21 +1,19 @@
  .container_job_template:
    extends: .base_job_template
-  image: docker:stable
+  image:
+    name: gcr.io/kaniko-project/executor:v1.9.0-debug
+    entrypoint: [""]
    stage: containers
-  services:
-    - docker:dind
    before_script:
      - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest"
      - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
-    - apk add python3
-    - docker info
-    - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
    script:
      - echo "TAG:$TAG"
      - echo "COMMON_TAG:$COMMON_TAG"
-    - docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
-      --build-arg BUILDKIT_INLINE_CACHE=1
-      -f "tests/docker/dockerfiles/$NAME.docker" "."

.gitlab-ci.d/container-template.yml line 19

Quoted 10 lines
.gitlab-ci.d/container-template.yml +7 -3
-    - docker push "$TAG"
-  after_script:
-    - docker logout
+    - /kaniko/executor
+          --reproducible
+          --context "${CI_PROJECT_DIR}"
+          --cache=true
+          --cache-repo "${COMMON_TAG}"
+          --dockerfile "${CI_PROJECT_DIR}/tests/docker/dockerfiles/$NAME.docker"
+          --destination "${TAG}"