Skip to contentSkip to conversation

testing/next: avocado, docs (pre-PR)

PATCH In review Alex Bennée 4 participants 22 messages Apr 24, 2023 – Apr 26, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover testing/next: avocado, docs (pre-PR)

This is my pre-PR tree for the current state of testing/next and the various documentation patches that haven't been picked up by others. I'll look to send the PR later in the week.

The following patches still need review:

tests/tcg: limit the scope of the plugin tests (1 acks, 1 sobs, 0 tbs) tests/avocado: use the new snapshots for testing

Alex Bennée (7):
tests/avocado: use the new snapshots for testing
qemu-options: finesse the recommendations around -blockdev tests/tcg: limit the scope of the plugin tests docs/system: remove excessive punctuation from guest-loader docs docs/devel: make a statement about includes docs/devel: mention the spacing requirement for QOM docs/style: call out the use of GUARD macros

Kautuk Consul (3):
tests/requirements.txt: bump up avocado-framework version to 101.0 avocado_qemu/__init__.py: factor out the qemu-img finding tests/avocado/tuxrun_baselines.py: improve code coverage for ppc64

Philippe Mathieu-Daudé (1):
tests/avocado: Add set of boot tests on SBSA-ref

Thomas Huth (6):
gitlab-ci: Avoid to re-run "configure" in the device-crash-test jobs scripts/device-crash-test: Add a parameter to run with TCG only .gitlab-ci.d/cirrus: Drop the CI job for compiling with FreeBSD 12 tests/avocado: Make ssh_command_output_contains() globally available tests/avocado/machine_aspeed: Fix the broken ast2[56]00_evb_sdk tests
MAINTAINERS: Cover tests/avocado/machine_aspeed.py

Yohei Kojima (1):
qemu-options.hx: Update descriptions of memory options for NUMA node

 MAINTAINERS                               |   3 +-
 docs/devel/qom.rst                        |   2 +
 docs/devel/style.rst                      | 108 ++++++++++
 docs/system/guest-loader.rst              |   6 +-
 .gitlab-ci.d/buildtest.yml                |   6 +-
 .gitlab-ci.d/cirrus.yml                   |  13 --
 .gitlab-ci.d/cirrus/freebsd-12.vars       |  16 --
 qemu-options.hx                           |  49 ++++-
 scripts/device-crash-test                 |   4 +-
 tests/Makefile.include                    |  18 +-
 tests/avocado/avocado_qemu/__init__.py    |  35 +++-
 tests/avocado/linux_ssh_mips_malta.py     |   8 -
 tests/avocado/machine_aarch64_sbsaref.py  | 158 +++++++++++++++
 tests/avocado/machine_aspeed.py           |  30 +--
 tests/avocado/tuxrun_baselines.py         | 232 +++++++++++++++++++---
 tests/lcitool/refresh                     |   1 -
 tests/requirements.txt                    |   2 +-
 tests/tcg/Makefile.target                 |  10 +-
 tests/tcg/aarch64/Makefile.softmmu-target |   2 -
 tests/tcg/aarch64/Makefile.target         |   1 -
 tests/tcg/arm/Makefile.softmmu-target     |   4 +-
 tests/tcg/arm/Makefile.target             |   8 -
 tests/tcg/cris/Makefile.target            |   3 +
 tests/tcg/hppa/Makefile.target            |   2 -
 tests/tcg/i386/Makefile.target            |  10 -
 tests/tcg/ppc64/Makefile.target           |   2 -
 tests/tcg/riscv64/Makefile.softmmu-target |   3 +
 tests/tcg/riscv64/Makefile.target         |   1 -
 tests/tcg/s390x/Makefile.softmmu-target   |   3 +
 tests/tcg/tricore/Makefile.softmmu-target |   3 +
 tests/tcg/xtensa/Makefile.softmmu-target  |   3 +
 31 files changed, 599 insertions(+), 147 deletions(-)
 delete mode 100644 .gitlab-ci.d/cirrus/freebsd-12.vars
 create mode 100644 tests/avocado/machine_aarch64_sbsaref.py
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/18 tests/requirements.txt: bump up avocado-framework version to 101.0

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]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>

---
v2
- limit --max-parallel-tasks $(JOBS_OPTION:-j%=%)

---
 tests/Makefile.include | 18 +++++++++++-------
 tests/requirements.txt |  2 +-
 2 files changed, 12 insertions(+), 8 deletions(-)
tests/Makefile.include +11 -7
index 9422ddaece..a4de0ad5a2 100644
@@ -138,14 +138,18 @@ 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) \
-            $(AVOCADO_CMDLINE_TAGS) \
-            $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS), \
+	$(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")
 
 check-acceptance-deprecated-warning:
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
#2 lore raw

PATCH 2/18 tests/avocado: use the new snapshots for testing

In reply to Alex Bennée

The tuxboot images now have a stable snapshot URL so we can enable the checksums and remove the avocado warnings. We will have to update as old snapshots retire but that won't be too frequent.

---
 tests/avocado/tuxrun_baselines.py | 170 +++++++++++++++++++++++++-----
 1 file changed, 144 insertions(+), 26 deletions(-)
tests/avocado/tuxrun_baselines.py +144 -26
index d343376faa..e8749717e9 100644
@@ -77,20 +77,33 @@ def wait_for_console_pattern(self, success_message, vm=None):
                                  failure_message='Kernel panic - not syncing',
                                  vm=vm)
 
-    def fetch_tuxrun_assets(self, dt=None):
+    def fetch_tuxrun_assets(self, csums=None, dt=None):
         """
         Fetch the TuxBoot assets. They are stored in a standard way so we
         use the per-test tags to fetch details.
         """
-        base_url = f"https://storage.tuxboot.com/{self.tuxboot}/"
-        kernel_image =  self.fetch_asset(base_url + self.image)
-        disk_image_zst = self.fetch_asset(base_url + "rootfs.ext4.zst")
+        base_url = f"https://storage.tuxboot.com/20230331/{self.tuxboot}/"
+
+        # empty hash if we weren't passed one
+        csums = {} if csums is None else csums
+        ksum = csums.get(self.image, None)
+        isum = csums.get("rootfs.ext4.zst", None)
+
+        kernel_image =  self.fetch_asset(base_url + self.image,
+                                         asset_hash = ksum,
+                                         algorithm = "sha256")
+        disk_image_zst = self.fetch_asset(base_url + "rootfs.ext4.zst",
+                                         asset_hash = isum,
+                                         algorithm = "sha256")
 
         cmd = f"{self.zstd} -d {disk_image_zst} -o {self.workdir}/rootfs.ext4"
         process.run(cmd)
 
         if dt:
-            dtb = self.fetch_asset(base_url + dt)
+            dsum = csums.get(dt, None)
+            dtb = self.fetch_asset(base_url + dt,
+                                   asset_hash = dsum,
+                                   algorithm = "sha256")
         else:
             dtb = None
 
@@ -149,7 +162,9 @@ def run_tuxtest_tests(self, haltmsg):
         else:
             self.vm.wait()
 
-    def common_tuxrun(self, dt=None,
+    def common_tuxrun(self,
+                      csums=None,
+                      dt=None,
                       drive="virtio-blk-device",
                       haltmsg="reboot: System halted",
                       console_index=0):
@@ -158,7 +173,7 @@ def common_tuxrun(self, dt=None,
         special with the command line we can process most things using
         the tag metadata.
         """
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets(dt)
+        (kernel, disk, dtb) = self.fetch_tuxrun_assets(csums, dt)
 
         self.prepare_run(kernel, disk, drive, dtb, console_index)
         self.vm.launch()
@@ -182,7 +197,11 @@ def test_arm64(self):
         :avocado: tags=console:ttyAMA0
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun()
+        sums = {"Image" :
+                "ce95a7101a5fecebe0fe630deee6bd97b32ba41bc8754090e9ad8961ea8674c7",
+                "rootfs.ext4.zst" :
+                "bbd5ed4b9c7d3f4ca19ba71a323a843c6b585e880115df3b7765769dbd9dd061"}
+        self.common_tuxrun(csums=sums)
 
     def test_arm64be(self):
         """
@@ -194,7 +213,11 @@ def test_arm64be(self):
         :avocado: tags=console:ttyAMA0
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun()
+        sums = { "Image" :
+                 "e0df4425eb2cd9ea9a283e808037f805641c65d8fcecc8f6407d8f4f339561b4",
+                 "rootfs.ext4.zst" :
+                 "e6ffd8813c8a335bc15728f2835f90539c84be7f8f5f691a8b01451b47fb4bd7"}
+        self.common_tuxrun(csums=sums)
 
     def test_armv5(self):
         """
@@ -206,7 +229,15 @@ def test_armv5(self):
         :avocado: tags=console:ttyAMA0
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="virtio-blk-pci",
+        sums = { "rootfs.ext4.zst" :
+                 "17177afa74e7294da0642861f08c88ca3c836764299a54bf6d1ce276cb9712a5",
+                 "versatile-pb.dtb" :
+                 "0bc0c0b0858cefd3c32b385c0d66d97142ded29472a496f4f490e42fc7615b25",
+                 "zImage" :
+                 "c95af2f27647c12265d75e9df44c22ff5228c59855f54aaa70f41ec2842e3a4d" }
+
+        self.common_tuxrun(csums=sums,
+                           drive="virtio-blk-pci",
                            dt="versatile-pb.dtb")
 
     def test_armv7(self):
@@ -219,7 +250,12 @@ def test_armv7(self):
         :avocado: tags=console:ttyAMA0
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun()
+        sums = { "rootfs.ext4.zst" :
+                 "ab1fbbeaddda1ffdd45c9405a28cd5370c20f23a7cbc809cc90dc9f243a8eb5a",
+                 "zImage" :
+                 "4c7a22e9f15875bec06bd2a29d822496571eb297d4f22694099ffcdb19077572" }
+
+        self.common_tuxrun(csums=sums)
 
     def test_armv7be(self):
         """
@@ -232,7 +268,12 @@ def test_armv7be(self):
         :avocado: tags=console:ttyAMA0
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun()
+        sums = {"rootfs.ext4.zst" :
+                "42ed46dd2d59986206c5b1f6cf35eab58fe3fd20c96b41aaa16b32f3f90a9835",
+                "zImage" :
+                "7facc62082b57af12015b08f7fdbaf2f123ba07a478367853ae12b219afc9f2f" }
+
+        self.common_tuxrun(csums=sums)
 
     def test_i386(self):
         """
@@ -243,7 +284,12 @@ def test_i386(self):
         :avocado: tags=image:bzImage
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="virtio-blk-pci")
+        sums = {"bzImage" :
+                "a3e5b32a354729e65910f5a1ffcda7c14a6c12a55e8213fb86e277f1b76ed956",
+                "rootfs.ext4.zst" :
+                "f15e66b2bf673a210ec2a4b2e744a80530b36289e04f5388aab812b97f69754a" }
+
+        self.common_tuxrun(csums=sums, drive="virtio-blk-pci")
 
     def test_mips32(self):
         """
@@ -256,7 +302,12 @@ def test_mips32(self):
         :avocado: tags=root:sda
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="driver=ide-hd,bus=ide.0,unit=0")
+        sums = { "rootfs.ext4.zst" :
+                 "fc3da0b4c2f38d74c6d705123bb0f633c76ed953128f9d0859378c328a6d11a0",
+                 "vmlinux" :
+                 "bfd2172f8b17fb32970ca0c8c58f59c5a4ca38aa5855d920be3a69b5d16e52f0" }
+
+        self.common_tuxrun(csums=sums, drive="driver=ide-hd,bus=ide.0,unit=0")
 
     def test_mips32el(self):
         """
@@ -268,7 +319,12 @@ def test_mips32el(self):
         :avocado: tags=root:sda
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="driver=ide-hd,bus=ide.0,unit=0")
+        sums = { "rootfs.ext4.zst" :
+                 "e799768e289fd69209c21f4dacffa11baea7543d5db101e8ce27e3bc2c41d90e",
+                 "vmlinux" :
+                 "8573867c68a8443db8de6d08bb33fb291c189ca2ca671471d3973a3e712096a3" }
+
+        self.common_tuxrun(csums=sums, drive="driver=ide-hd,bus=ide.0,unit=0")
 
     def test_mips64(self):
         """
@@ -280,7 +336,12 @@ def test_mips64(self):
         :avocado: tags=root:sda
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="driver=ide-hd,bus=ide.0,unit=0")
+        sums = { "rootfs.ext4.zst" :
+                 "69d91eeb04df3d8d172922c6993bb37d4deeb6496def75d8580f6f9de3e431da",
+                 "vmlinux" :
+                 "09010e51e4b8bcbbd2494786ffb48eca78f228e96e5c5438344b0eac4029dc61" }
+
+        self.common_tuxrun(csums=sums, drive="driver=ide-hd,bus=ide.0,unit=0")
 
     def test_mips64el(self):
         """
@@ -291,7 +352,12 @@ def test_mips64el(self):
         :avocado: tags=root:sda
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="driver=ide-hd,bus=ide.0,unit=0")
+        sums = { "rootfs.ext4.zst" :
+                 "fba585368f5915b1498ed081863474b2d7ec4e97cdd46d21bdcb2f9698f83de4",
+                 "vmlinux" :
+                 "d4e08965e2155c4cccce7c5f34d18fe34c636cda2f2c9844387d614950155266" }
+
+        self.common_tuxrun(csums=sums, drive="driver=ide-hd,bus=ide.0,unit=0")
 
     def test_ppc32(self):
         """
@@ -302,7 +368,12 @@ def test_ppc32(self):
         :avocado: tags=image:uImage
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="virtio-blk-pci")
+        sums = { "rootfs.ext4.zst" :
+                 "8885b9d999cc24d679542a02e9b6aaf48f718f2050ece6b8347074b6ee41dd09",
+                 "uImage" :
+                 "1a68f74b860fda022fb12e03c5efece8c2b8b590d96cca37a8481a3ae0b3f81f" }
+
+        self.common_tuxrun(csums=sums, drive="virtio-blk-pci")
 
     def test_ppc64(self):
         """
@@ -316,7 +387,12 @@ def test_ppc64(self):
         :avocado: tags=extradev:driver=spapr-vscsi
         :avocado: tags=root:sda
         """
-        self.common_tuxrun(drive="scsi-hd")
+        sums = { "rootfs.ext4.zst" :
+                 "1d953e81a4379e537fc8e41e05a0a59d9b453eef97aa03d47866c6c45b00bdff",
+                 "vmlinux" :
+                 "f22a9b9e924174a4c199f4c7e5d91a2339fcfe51c6eafd0907dc3e09b64ab728" }
+
+        self.common_tuxrun(csums=sums, drive="scsi-hd")
 
     def test_ppc64le(self):
         """
@@ -329,7 +405,12 @@ def test_ppc64le(self):
         :avocado: tags=extradev:driver=spapr-vscsi
         :avocado: tags=root:sda
         """
-        self.common_tuxrun(drive="scsi-hd")
+        sums = { "rootfs.ext4.zst" :
+                 "b442678c93fb8abe1f7d3bfa20556488de6b475c22c8fed363f42cf81a0a3906",
+                 "vmlinux" :
+                 "979eb61b445a010fb13e2b927126991f8ceef9c590fa2be0996c00e293e80cf2" }
+
+        self.common_tuxrun(csums=sums, drive="scsi-hd")
 
     def test_riscv32(self):
         """
@@ -337,7 +418,14 @@ def test_riscv32(self):
         :avocado: tags=machine:virt
         :avocado: tags=tuxboot:riscv32
         """
-        self.common_tuxrun()
+        sums = { "Image" :
+                 "89599407d7334de629a40e7ad6503c73670359eb5f5ae9d686353a3d6deccbd5",
+                 "fw_jump.elf" :
+                 "f2ef28a0b77826f79d085d3e4aa686f1159b315eff9099a37046b18936676985",
+                 "rootfs.ext4.zst" :
+                 "7168d296d0283238ea73cd5a775b3dd608e55e04c7b92b76ecce31bb13108cba" }
+
+        self.common_tuxrun(csums=sums)
 
     def test_riscv64(self):
         """
@@ -345,7 +433,14 @@ def test_riscv64(self):
         :avocado: tags=machine:virt
         :avocado: tags=tuxboot:riscv64
         """
-        self.common_tuxrun()
+        sums = { "Image" :
+                 "cd634badc65e52fb63465ec99e309c0de0369f0841b7d9486f9729e119bac25e",
+                 "fw_jump.elf" :
+                 "6e3373abcab4305fe151b564a4c71110d833c21f2c0a1753b7935459e36aedcf",
+                 "rootfs.ext4.zst" :
+                 "b18e3a3bdf27be03da0b285e84cb71bf09eca071c3a087b42884b6982ed679eb" }
+
+        self.common_tuxrun(csums=sums)
 
     def test_s390(self):
         """
@@ -355,7 +450,13 @@ def test_s390(self):
         :avocado: tags=image:bzImage
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="virtio-blk-ccw",
+        sums = { "bzImage" :
+                 "0414e98dd1c3dafff8496c9cd9c28a5f8d04553bb5ba37e906a812b48d442ef0",
+                 "rootfs.ext4.zst" :
+                 "88c37c32276677f873a25ab9ec6247895b8e3e6f8259134de2a616080b8ab3fc" }
+
+        self.common_tuxrun(csums=sums,
+                           drive="virtio-blk-ccw",
                            haltmsg="Requesting system halt")
 
     # Note: some segfaults caused by unaligned userspace access
@@ -370,9 +471,14 @@ def test_sh4(self):
         :avocado: tags=root:sda
         :avocado: tags=console:ttySC1
         """
+        sums = { "rootfs.ext4.zst" :
+                 "3592a7a3d5a641e8b9821449e77bc43c9904a56c30d45da0694349cfd86743fd",
+                 "zImage" :
+                 "29d9b2aba604a0f53a5dc3b5d0f2b8e35d497de1129f8ee5139eb6fdf0db692f" }
+
         # The test is currently too unstable to do much in userspace
         # so we skip common_tuxrun and do a minimal boot and shutdown.
-        (kernel, disk, dtb) = self.fetch_tuxrun_assets()
+        (kernel, disk, dtb) = self.fetch_tuxrun_assets(csums=sums)
 
         # the console comes on the second serial port
         self.prepare_run(kernel, disk,
@@ -395,7 +501,13 @@ def test_sparc64(self):
         :avocado: tags=root:sda
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="driver=ide-hd,bus=ide.0,unit=0")
+
+        sums = { "rootfs.ext4.zst" :
+                 "ad2f1dc436ab51583543d25d2c210cab478645d47078d30d129a66ab0e281d76",
+                 "vmlinux" :
+                 "e34313e4325ff21deaa3d38a502aa09a373ef62b9bd4d7f8f29388b688225c55" }
+
+        self.common_tuxrun(csums=sums, drive="driver=ide-hd,bus=ide.0,unit=0")
 
     def test_x86_64(self):
         """
@@ -407,4 +519,10 @@ def test_x86_64(self):
         :avocado: tags=root:sda
         :avocado: tags=shutdown:nowait
         """
-        self.common_tuxrun(drive="driver=ide-hd,bus=ide.0,unit=0")
+        sums = { "bzImage" :
+                 "2bc7480a669ee9b6b82500a236aba0c54233debe98cb968268fa230f52f03461",
+                 "rootfs.ext4.zst" :
+                 "b72ac729769b8f51c6dffb221113c9a063c774dbe1d66af30eb593c4e9999b4b" }
+
+        self.common_tuxrun(csums=sums,
+                           drive="driver=ide-hd,bus=ide.0,unit=0")
Signature · 1 line
2.39.2
Acked-by on v1 2/18
#3 lore raw

Re: [PATCH 02/18] tests/avocado: use the new snapshots for testing

Quoted 8 lines · Alex Bennée

The tuxboot images now have a stable snapshot URL so we can enable the checksums and remove the avocado warnings. We will have to update as old snapshots retire but that won't be too frequent.

---
  tests/avocado/tuxrun_baselines.py | 170 +++++++++++++++++++++++++-----
  1 file changed, 144 insertions(+), 26 deletions(-)

FWIW,

#4 lore raw

PATCH 3/18 tests/avocado: Add set of boot tests on SBSA-ref

In reply to Alex Bennée

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

This change adds set of boot tests on SBSA-ref machine:

1. boot firmware up to the EDK2 banner
2. boot Alpine Linux

Prebuilt flash volumes are included, built using upstream documentation.

To unify tests for AArch64/virt and AArch64/sbsa-ref we boot the same Alpine Linux image on both.

Message-Id: <[email protected]>

Message-Id: <[email protected]>

---
 MAINTAINERS                              |   1 +
 tests/avocado/machine_aarch64_sbsaref.py | 158 +++++++++++++++++++++++
 2 files changed, 159 insertions(+)
 create mode 100644 tests/avocado/machine_aarch64_sbsaref.py
MAINTAINERS +1 -0
index 24154f5721..034ff71dac 100644
@@ -943,6 +943,7 @@ L: [email protected]
 S: Maintained
 F: hw/arm/sbsa-ref.c
 F: docs/system/arm/sbsa.rst
+F: tests/avocado/machine_aarch64_sbsaref.py
 
 Sharp SL-5500 (Collie) PDA
 M: Peter Maydell <[email protected]>
tests/avocado/machine_aarch64_sbsaref.py new file +158 -0

158 lines not on this page · raw message

Signature · 1 line
2.39.2
#5 lore raw

PATCH 4/18 gitlab-ci: Avoid to re-run "configure" in the device-crash-test jobs

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

After "make check-venv" had been added to these jobs, they started to re-run "configure" each time since our logic in the makefile thinks that some files are out of date here. Avoid it with the same trick that we are using in buildtest-template.yml already by disabling the up-to-date check via NINJA=":".

Fixes 1d8cf47e5b ("tests: run 'device-crash-test' from tests/venv")

Message-Id: <[email protected]>

---
 .gitlab-ci.d/buildtest.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
.gitlab-ci.d/buildtest.yml +2 -2
index ba6f551752..333eea9dd3 100644
@@ -102,7 +102,7 @@ crash-test-debian:
     IMAGE: debian-amd64
   script:
     - cd build
-    - make check-venv
+    - make NINJA=":" check-venv
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
 
 build-system-fedora:
@@ -145,7 +145,7 @@ crash-test-fedora:
     IMAGE: fedora
   script:
     - cd build
-    - make check-venv
+    - make NINJA=":" check-venv
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
 
Signature · 1 line
2.39.2
#6 lore raw

PATCH 5/18 scripts/device-crash-test: Add a parameter to run with TCG only

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

We're currently facing the problem that the device-crash-test script runs twice as long in the CI when a runner supports KVM - which sometimes results in a timeout of the CI job. To get a more deterministic runtime here, add an option to the script that allows to run it with TCG only.

Message-Id: <[email protected]>
Message-Id: <[email protected]>

---
 .gitlab-ci.d/buildtest.yml | 2 +-
 scripts/device-crash-test  | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
.gitlab-ci.d/buildtest.yml +1 -1
index 333eea9dd3..bb3650a51c 100644
@@ -103,7 +103,7 @@ crash-test-debian:
   script:
     - cd build
     - make NINJA=":" check-venv
-    - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
+    - tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
 
 build-system-fedora:
   extends:
scripts/device-crash-test +3 -1
index 73bcb98693..b74d887331 100755
@@ -397,7 +397,7 @@ def binariesToTest(args, testcase):
 
 
 def accelsToTest(args, testcase):
-    if getBinaryInfo(args, testcase['binary']).kvm_available:
+    if getBinaryInfo(args, testcase['binary']).kvm_available and not args.tcg_only:
         yield 'kvm'
     yield 'tcg'
 
@@ -510,6 +510,8 @@ def main():
                         help="Full mode: test cases that are expected to fail")
     parser.add_argument('--strict', action='store_true', dest='strict',
                         help="Treat all warnings as fatal")
+    parser.add_argument('--tcg-only', action='store_true', dest='tcg_only',
+                        help="Only test with TCG accelerator")
     parser.add_argument('qemu', nargs='*', metavar='QEMU',
                         help='QEMU binary to run')
     args = parser.parse_args()
Signature · 1 line
2.39.2
#7 lore raw

PATCH 6/18 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. It seems there are times the more human friendly -drive still makes sense especially when -snapshot is involved.

Improve the language to hopefully make things clearer.

Message-Id: <[email protected]>

---
v3
- more re-wording to try and approach consensus
- add explicit warning to -snapshot option

---
 qemu-options.hx | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
qemu-options.hx +22 -2
index 04c259157a..baa0589733 100644
@@ -1143,10 +1143,22 @@ 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. It is the only guaranteed
+stable interface for describing block devices and as such is
+recommended for management tools and scripting.
+
+The ``-drive`` option combines the device and backend into a single
+command line option which is a more human friendly. There is however no
+interface stability guarantee although some older board models still
+need updating to work with the modern blockdev forms.
+
+Older options like ``-hda`` are essentially macros which expand into
+``-drive`` options for various drive interfaces. The original forms
+bake in a lot of assumptions from the days when QEMU was emulating a
+legacy PC, they are not recommended for modern configurations.
 
 ERST
 
@@ -1639,6 +1651,14 @@ SRST
     the raw disk image you use is not written back. You can however
     force the write back by pressing C-a s (see the :ref:`disk images`
     chapter in the System Emulation Users Guide).
+
+    .. warning::
+       snapshot is incompatible with ``-blockdev`` (instead use qemu-img
+       to manually create snapshot images to attach to your blockdev).
+       If you have mixed ``-blockdev`` and ``-drive`` declarations you
+       can use the 'snapshot' property on your drive declarations
+       instead of this global option.
+
 ERST
 
 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
Signature · 1 line
2.39.2
#8 lore raw

PATCH 7/18 .gitlab-ci.d/cirrus: Drop the CI job for compiling with FreeBSD 12

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

FreeBSD 13.0 has been released in April 2021:

https://www.freebsd.org/releases/13.0R/announce/

According to QEMU's support policy, we stop supporting the previous major release two years after the the new major release has been published. So we can stop testing FreeBSD 12 in our CI now.

Message-Id: <[email protected]>

---
 .gitlab-ci.d/cirrus.yml             | 13 -------------
 .gitlab-ci.d/cirrus/freebsd-12.vars | 16 ----------------
 tests/lcitool/refresh               |  1 -
 3 files changed, 30 deletions(-)
 delete mode 100644 .gitlab-ci.d/cirrus/freebsd-12.vars
.gitlab-ci.d/cirrus.yml +0 -13
index 502dfd612c..1507c928e5 100644
@@ -44,19 +44,6 @@
   variables:
     QEMU_JOB_CIRRUS: 1
 
-x64-freebsd-12-build:
-  extends: .cirrus_build_job
-  variables:
-    NAME: freebsd-12
-    CIRRUS_VM_INSTANCE_TYPE: freebsd_instance
-    CIRRUS_VM_IMAGE_SELECTOR: image_family
-    CIRRUS_VM_IMAGE_NAME: freebsd-12-4
-    CIRRUS_VM_CPUS: 8
-    CIRRUS_VM_RAM: 8G
-    UPDATE_COMMAND: pkg update; pkg upgrade -y
-    INSTALL_COMMAND: pkg install -y
-    TEST_TARGETS: check
-
 x64-freebsd-13-build:
   extends: .cirrus_build_job
   variables:
.gitlab-ci.d/cirrus/freebsd-12.vars deleted +0 -16
deleted file mode 100644
index 44d8a2a511..0000000000
@@ -1,16 +0,0 @@
-# THIS FILE WAS AUTO-GENERATED
-#
-#  $ lcitool variables freebsd-12 qemu
-#
-# https://gitlab.com/libvirt/libvirt-ci
-
-CCACHE='/usr/local/bin/ccache'
-CPAN_PKGS=''
-CROSS_PKGS=''
-MAKE='/usr/local/bin/gmake'
-NINJA='/usr/local/bin/ninja'
-PACKAGING_COMMAND='pkg'
-PIP3='/usr/local/bin/pip-3.8'
-PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache cdrkit-genisoimage cmocka ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson ncurses nettle ninja opencv pixman pkgconf png py39-numpy py39-pillow py39-pip py39-sphinx py39-sphinx_rtd_theme py39-yaml python3 rpm2cpio sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 zstd'
-PYPI_PKGS=''
-PYTHON='/usr/local/bin/python3'
tests/lcitool/refresh +0 -1
index 33ef1282da..f1570b54df 100755
@@ -182,7 +182,6 @@ try:
     #
     # Cirrus packages lists for GitLab
     #
-    generate_cirrus("freebsd-12")
     generate_cirrus("freebsd-13")
     generate_cirrus("macos-12")
 
Signature · 1 line
2.39.2
Reviewed-by on v1 7/18
#9 lore raw

Re: [PATCH 07/18] .gitlab-ci.d/cirrus: Drop the CI job for compiling with FreeBSD 12

Quoted 11 lines · Alex Bennée

From: Thomas Huth<[email protected]>

FreeBSD 13.0 has been released in April 2021:

https://www.freebsd.org/releases/13.0R/announce/

According to QEMU's support policy, we stop supporting the previous major release two years after the the new major release has been published. So we can stop testing FreeBSD 12 in our CI now.

Quoted 8 lines

Message-Id:<[email protected]>

---
  .gitlab-ci.d/cirrus.yml             | 13 -------------
  .gitlab-ci.d/cirrus/freebsd-12.vars | 16 ----------------
  tests/lcitool/refresh               |  1 -
  3 files changed, 30 deletions(-)

delete mode 100644 .gitlab-ci.d/cirrus/freebsd-12.vars

r~

#10 lore raw

PATCH 8/18 tests/avocado: Make ssh_command_output_contains() globally available

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

This function will be useful in other tests, too, so move it to the core LinuxSSHMixIn class.

Message-Id: <[email protected]>

---
 tests/avocado/avocado_qemu/__init__.py | 8 ++++++++
 tests/avocado/linux_ssh_mips_malta.py  | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)
tests/avocado/avocado_qemu/__init__.py +8 -0
index cb71f50db9..6788837e1b 100644
@@ -431,6 +431,14 @@ def ssh_command(self, command):
                          f'Guest command failed: {command}')
         return stdout_lines, stderr_lines
 
+    def ssh_command_output_contains(self, cmd, exp):
+        stdout, _ = self.ssh_command(cmd)
+        for line in stdout:
+            if exp in line:
+                break
+        else:
+            self.fail('"%s" output does not contain "%s"' % (cmd, exp))
+
 class LinuxDistro:
     """Represents a Linux distribution
 
tests/avocado/linux_ssh_mips_malta.py +0 -8
index 0179d8a6ca..d9bb525ad9 100644
@@ -101,14 +101,6 @@ def shutdown_via_ssh(self):
         self.ssh_disconnect_vm()
         wait_for_console_pattern(self, 'Power down', 'Oops')
 
-    def ssh_command_output_contains(self, cmd, exp):
-        stdout, _ = self.ssh_command(cmd)
-        for line in stdout:
-            if exp in line:
-                break
-        else:
-            self.fail('"%s" output does not contain "%s"' % (cmd, exp))
-
     def run_common_commands(self, wordsize):
         self.ssh_command_output_contains(
             'cat /proc/cpuinfo',
Signature · 1 line
2.39.2
#11 lore raw

PATCH 9/18 tests/avocado/machine_aspeed: Fix the broken ast2[56]00_evb_sdk tests

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

test_arm_ast2500_evb_sdk and test_arm_ast2600_evb_sdk are currently failing. The problem is that they are trying to look for the login prompt that does not have a newline at the end - but the logic in _console_interaction() only handles full lines. It used to work by accident in the past since there were sometimes kernel (warning and error) messages popping up that finally provided a newline character in the output, but since the tests have been changed to run with the "quiet" kernel parameter, this is not working anymore.

To make this work reliably, we must not look for the "login:" prompt, but have to use some text ending with a newline instead. And in the ast2600 test, switch to ssh instead of trying to log into the serial console - this works much more reliable and also has the benefit of excercising the network interface here a little bit, too.

Message-Id: <[email protected]>

[AJB: remove stray debug log]
---
 tests/avocado/machine_aspeed.py | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
tests/avocado/machine_aspeed.py +17 -13
index 2b532c4834..724ee72c02 100644
@@ -10,6 +10,7 @@
 import tempfile
 import subprocess
 
+from avocado_qemu import LinuxSSHMixIn
 from avocado_qemu import QemuSystemTest
 from avocado_qemu import wait_for_console_pattern
 from avocado_qemu import exec_command
@@ -268,7 +269,7 @@ def test_arm_ast2600_evb_buildroot_tpm(self):
 
         self.do_test_arm_aspeed_buildroot_poweroff()
 
-class AST2x00MachineSDK(QemuSystemTest):
+class AST2x00MachineSDK(QemuSystemTest, LinuxSSHMixIn):
 
     EXTRA_BOOTARGS = (
         'quiet '
@@ -295,7 +296,7 @@ def do_test_arm_aspeed_sdk_start(self, image):
         self.require_netdev('user')
         self.vm.set_console()
         self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
-                         '-net', 'nic', '-net', 'user')
+                         '-net', 'nic', '-net', 'user,hostfwd=:127.0.0.1:0-:22')
         self.vm.launch()
 
         self.wait_for_console_pattern('U-Boot 2019.04')
@@ -323,7 +324,7 @@ def test_arm_ast2500_evb_sdk(self):
 
         self.do_test_arm_aspeed_sdk_start(
             self.workdir + '/ast2500-default/image-bmc')
-        self.wait_for_console_pattern('ast2500-default login:')
+        self.wait_for_console_pattern('nodistro.0 ast2500-default ttyS4')
 
     @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
     def test_arm_ast2600_evb_sdk(self):
@@ -345,22 +346,25 @@ def test_arm_ast2600_evb_sdk(self):
                          'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
         self.do_test_arm_aspeed_sdk_start(
             self.workdir + '/ast2600-default/image-bmc')
-        self.wait_for_console_pattern('ast2600-default login:')
-        exec_command_and_wait_for_pattern(self, 'root', 'Password:')
-        exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
+        self.wait_for_console_pattern('nodistro.0 ast2600-default ttyS4')
 
-        exec_command_and_wait_for_pattern(self,
-             'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
+        self.ssh_connect('root', '0penBmc', False)
+        self.ssh_command('dmesg -c > /dev/null')
+
+        self.ssh_command_output_contains(
+             'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device ; '
+             'dmesg -c',
              'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
-        exec_command_and_wait_for_pattern(self,
+        self.ssh_command_output_contains(
                              'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
         self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
                         property='temperature', value=18000);
-        exec_command_and_wait_for_pattern(self,
+        self.ssh_command_output_contains(
                              'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
 
-        exec_command_and_wait_for_pattern(self,
-             'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
+        self.ssh_command_output_contains(
+             'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device ; '
+             'dmesg -c',
              'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
         year = time.strftime("%Y")
-        exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
+        self.ssh_command_output_contains('/sbin/hwclock -f /dev/rtc1', year);
Signature · 1 line
2.39.2
#12 lore raw

PATCH 10/18 MAINTAINERS: Cover tests/avocado/machine_aspeed.py

In reply to Alex Bennée

From: Thomas Huth <[email protected]>

tests/avocado/machine_aspeed.py should belong to the ASPEED section in the maintainers file. Improve the wildcards here a little bit, so that it is covered, too.

Message-Id: <[email protected]>

---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
MAINTAINERS +1 -1
index 034ff71dac..d0f48a5113 100644
@@ -1113,7 +1113,7 @@ F: include/hw/misc/pca9552*.h
 F: hw/net/ftgmac100.c
 F: include/hw/net/ftgmac100.h
 F: docs/system/arm/aspeed.rst
-F: tests/qtest/*aspeed*
+F: tests/*/*aspeed*
 F: hw/arm/fby35.c
 
 NRF51
Signature · 1 line
2.39.2
#13 lore raw

PATCH 11/18 avocado_qemu/__init__.py: factor out the qemu-img finding

In reply to Alex Bennée

From: Kautuk Consul <[email protected]>

Factor out the code that finds the qemu-img binary in the QemuSystemTest class and create a new get_qemu_img() function with it. This function will get called also from the new code in tuxrun_baselines.py avocado test-case.

Message-Id: <[email protected]>

---
 tests/avocado/avocado_qemu/__init__.py | 27 +++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)
tests/avocado/avocado_qemu/__init__.py +16 -11
index 6788837e1b..33090903f1 100644
@@ -330,6 +330,19 @@ def _new_vm(self, name, *args):
             vm.add_args(*args)
         return vm
 
+    def get_qemu_img(self):
+        self.log.debug('Looking for and selecting a qemu-img binary')
+
+        # If qemu-img has been built, use it, otherwise the system wide one
+        # will be used.
+        qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
+        if not os.path.exists(qemu_img):
+            qemu_img = find_command('qemu-img', False)
+        if qemu_img is False:
+            self.cancel('Could not find "qemu-img"')
+
+        return qemu_img
+
     @property
     def vm(self):
         return self.get_vm(name='default')
@@ -602,17 +615,9 @@ def set_up_existing_ssh_keys(self):
         return (ssh_public_key, ssh_private_key)
 
     def download_boot(self):
-        self.log.debug('Looking for and selecting a qemu-img binary to be '
-                       'used to create the bootable snapshot image')
-        # If qemu-img has been built, use it, otherwise the system wide one
-        # will be used.  If none is available, the test will cancel.
-        qemu_img = os.path.join(BUILD_DIR, 'qemu-img')
-        if not os.path.exists(qemu_img):
-            qemu_img = find_command('qemu-img', False)
-        if qemu_img is False:
-            self.cancel('Could not find "qemu-img", which is required to '
-                        'create the bootable image')
-        vmimage.QEMU_IMG = qemu_img
+        # Set the qemu-img binary.
+        # If none is available, the test will cancel.
+        vmimage.QEMU_IMG = super().get_qemu_img()
 
         self.log.info('Downloading/preparing boot image')
         # Fedora 31 only provides ppc64le images
Signature · 1 line
2.39.2
#14 lore raw

PATCH 12/18 tests/avocado/tuxrun_baselines.py: improve code coverage for ppc64

In reply to Alex Bennée

From: Kautuk Consul <[email protected]>

Commit c0c8687ef0fd990db8db1655a8a6c5a5e35dd4bb disabled the boot_linux.py test-case due to which the code coverage for ppc decreased by around 2%. As per the discussion on
https://lore.kernel.org/qemu-devel/[email protected]/ it was mentioned that the baseline test for ppc64 could be modified to make up this 2% code coverage. This patch attempts to achieve this 2% code coverage by adding various device command line arguments (to ./qemu-system-ppc64) in the tuxrun_baselines.py test-case.

The code coverage report with boot_linux.py, without it and finally with these tuxrun_baselines.py changes is as follows:

With boot_linux.py
------------------
lines......: 13.8% (58006 of 420997 lines) functions..: 20.7% (7675 of 36993 functions) branches...: 9.2% (22146 of 240611 branches)
Without boot_linux.py (without this patch changes)
--------------------------------------------------
lines......: 11.9% (50174 of 420997 lines) functions..: 18.8% (6947 of 36993 functions) branches...: 7.4% (17580 of 239017 branches)
Without boot_linux.py (with this patch changes)
-----------------------------------------------
lines......: 13.8% (58287 of 420997 lines) functions..: 20.7% (7640 of 36993 functions) branches...: 8.4% (20223 of 240611 branches)

Rebased on Alex Benee's testing/next branch:
https://gitlab.com/stsquad/qemu/-/tree/testing/next

Message-Id: <[email protected]>

---
 tests/avocado/tuxrun_baselines.py | 70 ++++++++++++++++++++++++++++---
 1 file changed, 64 insertions(+), 6 deletions(-)
tests/avocado/tuxrun_baselines.py +64 -6
index e8749717e9..3a46e7a745 100644
@@ -11,6 +11,7 @@
 
 import os
 import time
+import tempfile
 
 from avocado import skip, skipIf
 from avocado_qemu import QemuSystemTest
@@ -72,6 +73,8 @@ def setUp(self):
         # Occasionally we need extra devices to hook things up
         self.extradev = self.get_tag('extradev')
 
+        self.qemu_img = super().get_qemu_img()
+
     def wait_for_console_pattern(self, success_message, vm=None):
         wait_for_console_pattern(self, success_message,
                                  failure_message='Kernel panic - not syncing',
@@ -179,6 +182,63 @@ def common_tuxrun(self,
         self.vm.launch()
         self.run_tuxtest_tests(haltmsg)
 
+    def ppc64_common_tuxrun(self, sums, prefix):
+        # add device args to command line.
+        self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22',
+                         '-device', 'virtio-net,netdev=vnet')
+        self.vm.add_args('-netdev', '{"type":"user","id":"hostnet0"}',
+                         '-device', '{"driver":"virtio-net-pci","netdev":'
+                         '"hostnet0","id":"net0","mac":"52:54:00:4c:e3:86",'
+                         '"bus":"pci.0","addr":"0x9"}')
+        self.vm.add_args('-device', '{"driver":"qemu-xhci","p2":15,"p3":15,'
+                         '"id":"usb","bus":"pci.0","addr":"0x2"}')
+        self.vm.add_args('-device', '{"driver":"virtio-scsi-pci","id":"scsi0"'
+                         ',"bus":"pci.0","addr":"0x3"}')
+        self.vm.add_args('-device', '{"driver":"virtio-serial-pci","id":'
+                         '"virtio-serial0","bus":"pci.0","addr":"0x4"}')
+        self.vm.add_args('-device', '{"driver":"scsi-cd","bus":"scsi0.0"'
+                         ',"channel":0,"scsi-id":0,"lun":0,"device_id":'
+                         '"drive-scsi0-0-0-0","id":"scsi0-0-0-0"}')
+        self.vm.add_args('-device', '{"driver":"virtio-balloon-pci",'
+                         '"id":"balloon0","bus":"pci.0","addr":"0x6"}')
+        self.vm.add_args('-audiodev', '{"id":"audio1","driver":"none"}')
+        self.vm.add_args('-device', '{"driver":"usb-tablet","id":"input0"'
+                         ',"bus":"usb.0","port":"1"}')
+        self.vm.add_args('-device', '{"driver":"usb-kbd","id":"input1"'
+                         ',"bus":"usb.0","port":"2"}')
+        self.vm.add_args('-device', '{"driver":"VGA","id":"video0",'
+                         '"vgamem_mb":16,"bus":"pci.0","addr":"0x7"}')
+        self.vm.add_args('-object', '{"qom-type":"rng-random","id":"objrng0"'
+                         ',"filename":"/dev/urandom"}',
+                         '-device', '{"driver":"virtio-rng-pci","rng":"objrng0"'
+                         ',"id":"rng0","bus":"pci.0","addr":"0x8"}')
+        self.vm.add_args('-object', '{"qom-type":"cryptodev-backend-builtin",'
+                         '"id":"objcrypto0","queues":1}',
+                         '-device', '{"driver":"virtio-crypto-pci",'
+                         '"cryptodev":"objcrypto0","id":"crypto0","bus"'
+                         ':"pci.0","addr":"0xa"}')
+        self.vm.add_args('-device', '{"driver":"spapr-pci-host-bridge"'
+                         ',"index":1,"id":"pci.1"}')
+        self.vm.add_args('-device', '{"driver":"spapr-vscsi","id":"scsi1"'
+                         ',"reg":12288}')
+        self.vm.add_args('-m', '2G,slots=32,maxmem=4G',
+                         '-object', 'memory-backend-ram,id=ram1,size=1G',
+                         '-device', 'pc-dimm,id=dimm1,memdev=ram1')
+
+        # Create a temporary qcow2 and launch the test-case
+        with tempfile.NamedTemporaryFile(prefix=prefix,
+                                         suffix='.qcow2') as qcow2:
+            process.run(self.qemu_img + ' create -f qcow2 ' +
+                        qcow2.name + ' 1G')
+
+            self.vm.add_args('-drive', 'file=' + qcow2.name +
+                         ',format=qcow2,if=none,id='
+                         'drive-virtio-disk1',
+                         '-device', 'virtio-blk-pci,scsi=off,bus=pci.0,'
+                         'addr=0xb,drive=drive-virtio-disk1,id=virtio-disk1'
+                         ',bootindex=2')
+            self.common_tuxrun(csums=sums, drive="scsi-hd")
+
     #
     # The tests themselves. The configuration is derived from how
     # tuxrun invokes qemu (with minor tweaks like using -blockdev
@@ -379,7 +439,7 @@ def test_ppc64(self):
         """
         :avocado: tags=arch:ppc64
         :avocado: tags=machine:pseries
-        :avocado: tags=cpu:POWER8
+        :avocado: tags=cpu:POWER10
         :avocado: tags=endian:big
         :avocado: tags=console:hvc0
         :avocado: tags=tuxboot:ppc64
@@ -391,14 +451,13 @@ def test_ppc64(self):
                  "1d953e81a4379e537fc8e41e05a0a59d9b453eef97aa03d47866c6c45b00bdff",
                  "vmlinux" :
                  "f22a9b9e924174a4c199f4c7e5d91a2339fcfe51c6eafd0907dc3e09b64ab728" }
-
-        self.common_tuxrun(csums=sums, drive="scsi-hd")
+        self.ppc64_common_tuxrun(sums, prefix='tuxrun_ppc64_')
 
     def test_ppc64le(self):
         """
         :avocado: tags=arch:ppc64
         :avocado: tags=machine:pseries
-        :avocado: tags=cpu:POWER8
+        :avocado: tags=cpu:POWER10
         :avocado: tags=console:hvc0
         :avocado: tags=tuxboot:ppc64le
         :avocado: tags=image:vmlinux
@@ -409,8 +468,7 @@ def test_ppc64le(self):
                  "b442678c93fb8abe1f7d3bfa20556488de6b475c22c8fed363f42cf81a0a3906",
                  "vmlinux" :
                  "979eb61b445a010fb13e2b927126991f8ceef9c590fa2be0996c00e293e80cf2" }
-
-        self.common_tuxrun(csums=sums, drive="scsi-hd")
+        self.ppc64_common_tuxrun(sums, prefix='tuxrun_ppc64le_')
 
     def test_riscv32(self):
         """
Signature · 1 line
2.39.2
#15 lore raw

PATCH 13/18 tests/tcg: limit the scope of the plugin tests

In reply to Alex Bennée

Running every plugin with every test is getting excessive as well as not really improving coverage that much. Restrict the plugin tests to just the MULTIARCH_TESTS which are shared between most architecture for both system and user-mode. For those that aren't we need to squash MULTIARCH_TESTS so we don't add them when they are not part of the TESTS global.

Message-Id: <[email protected]>

---
 tests/tcg/Makefile.target                 | 10 +++++++---
 tests/tcg/aarch64/Makefile.softmmu-target |  2 --
 tests/tcg/aarch64/Makefile.target         |  1 -
 tests/tcg/arm/Makefile.softmmu-target     |  4 +++-
 tests/tcg/arm/Makefile.target             |  8 --------
 tests/tcg/cris/Makefile.target            |  3 +++
 tests/tcg/hppa/Makefile.target            |  2 --
 tests/tcg/i386/Makefile.target            | 10 ----------
 tests/tcg/ppc64/Makefile.target           |  2 --
 tests/tcg/riscv64/Makefile.softmmu-target |  3 +++
 tests/tcg/riscv64/Makefile.target         |  1 -
 tests/tcg/s390x/Makefile.softmmu-target   |  3 +++
 tests/tcg/tricore/Makefile.softmmu-target |  3 +++
 tests/tcg/xtensa/Makefile.softmmu-target  |  3 +++
 14 files changed, 25 insertions(+), 30 deletions(-)
tests/tcg/Makefile.target +7 -3
index 8318caf924..72876cc84e 100644
@@ -152,13 +152,17 @@ PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))
 
 # We need to ensure expand the run-plugin-TEST-with-PLUGIN
 # pre-requistes manually here as we can't use stems to handle it. We
-# also add some special helpers the run-plugin- rules can use bellow.
+# only expand MULTIARCH_TESTS which are common on most of our targets
+# to avoid an exponential explosion as new tests are added. We also
+# add some special helpers the run-plugin- rules can use bellow.
 
+ifneq ($(MULTIARCH_TESTS),)
 $(foreach p,$(PLUGINS), \
-	$(foreach t,$(TESTS),\
+	$(foreach t,$(MULTIARCH_TESTS),\
 		$(eval run-plugin-$(t)-with-$(p): $t $p) \
 		$(eval RUN_TESTS+=run-plugin-$(t)-with-$(p))))
-endif
+endif # MULTIARCH_TESTS
+endif # CONFIG_PLUGIN
 
 strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1))
 extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1))
tests/tcg/aarch64/Makefile.softmmu-target +0 -2
index df9747bae8..b74a2534e3 100644
@@ -81,6 +81,4 @@ pauth-3:
 	$(call skip-test, "BUILD of $@", "missing compiler support")
 run-pauth-3:
 	$(call skip-test, "RUN of pauth-3", "not built")
-run-plugin-pauth-3-with-%:
-	$(call skip-test, "RUN of pauth-3 ($*)", "not built")
 endif
tests/tcg/aarch64/Makefile.target +0 -1
index 9e91a20b0d..0315795487 100644
@@ -32,7 +32,6 @@ ifneq ($(CROSS_CC_HAS_ARMV8_3),)
 AARCH64_TESTS += pauth-1 pauth-2 pauth-4 pauth-5
 pauth-%: CFLAGS += -march=armv8.3-a
 run-pauth-%: QEMU_OPTS += -cpu max
-run-plugin-pauth-%: QEMU_OPTS += -cpu max
 endif
 
 # BTI Tests
tests/tcg/arm/Makefile.softmmu-target +3 -1
index 7df88ddea8..8b546e2aa3 100644
@@ -23,4 +23,6 @@ LDFLAGS+=-nostdlib -N -static
 test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 -mfloat-abi=soft
 
 run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
-run-plugin-test-armv6m-undef-%: QEMU_OPTS+=-semihosting -M microbit -kernel
+
+# We don't currently support the multiarch system tests
+undefine MULTIARCH_TESTS
tests/tcg/arm/Makefile.target +0 -8
index b3b1504a1c..0038cef02c 100644
@@ -46,11 +46,6 @@ semihosting-arm: semihosting.c
 run-semihosting-arm: semihosting-arm
 	$(call run-test,$<,$(QEMU) $< 2> $<.err)
 
-run-plugin-semihosting-arm-with-%:
-	$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
-		-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
-		 $(call strip-plugin,$<) 2> $<.err)
-
 ARM_TESTS += semiconsole-arm
 
 semiconsole: CFLAGS += -mthumb
@@ -62,9 +57,6 @@ semiconsole-arm: semihosting.c
 run-semiconsole-arm: semiconsole-arm
 	$(call skip-test, $<, "MANUAL ONLY")
 
-run-plugin-semiconsole-arm-with-%:
-	$(call skip-test, $<, "MANUAL ONLY")
-
 endif
 
 ARM_TESTS += commpage
tests/tcg/cris/Makefile.target +3 -0
index 372287bd03..43587d2769 100644
@@ -57,3 +57,6 @@ SIMG:=cris-axis-linux-gnu-run
 # e.g.: make -f ../../tests/tcg/Makefile run-check_orm-on-sim
 run-%-on-sim:
 	$(call run-test, $<, $(SIMG) $<)
+
+# We don't currently support the multiarch tests
+undefine MULTIARCH_TESTS
tests/tcg/hppa/Makefile.target +0 -2
index b78e6b4849..cdd0d572a7 100644
@@ -10,8 +10,6 @@ EXTRA_RUNS+=run-test-mmap-4096 # run-test-mmap-16384 run-test-mmap-65536
 # it requires the full vdso with dwarf2 unwind info.
 run-signals: signals
 	$(call skip-test, $<, "BROKEN awaiting vdso support")
-run-plugin-signals-with-%:
-	$(call skip-test, $<, "BROKEN awaiting vdso support")
 
 VPATH += $(SRC_PATH)/tests/tcg/hppa
 TESTS += stby
tests/tcg/i386/Makefile.target +0 -10
index bafd8c2180..821822ed0c 100644
@@ -18,19 +18,15 @@ X86_64_TESTS:=$(filter test-i386-adcox test-i386-bmi2 $(SKIP_I386_TESTS), $(ALL_
 
 test-i386-sse-exceptions: CFLAGS += -msse4.1 -mfpmath=sse
 run-test-i386-sse-exceptions: QEMU_OPTS += -cpu max
-run-plugin-test-i386-sse-exceptions-%: QEMU_OPTS += -cpu max
 
 test-i386-pcmpistri: CFLAGS += -msse4.2
 run-test-i386-pcmpistri: QEMU_OPTS += -cpu max
-run-plugin-test-i386-pcmpistri-%: QEMU_OPTS += -cpu max
 
 test-i386-bmi2: CFLAGS=-O2
 run-test-i386-bmi2: QEMU_OPTS += -cpu max
-run-plugin-test-i386-bmi2-%: QEMU_OPTS += -cpu max
 
 test-i386-adcox: CFLAGS=-O2
 run-test-i386-adcox: QEMU_OPTS += -cpu max
-run-plugin-test-i386-adcox-%: QEMU_OPTS += -cpu max
 
 #
 # hello-i386 is a barebones app
@@ -52,8 +48,6 @@ test-i386:
 	$(call skip-test, "BUILD of $@", "missing -no-pie compiler support")
 run-test-i386:
 	$(call skip-test, "RUN of test-i386", "not built")
-run-plugin-test-i386-with-%:
-	$(call skip-test, "RUN of test-i386 ($*)", "not built")
 endif
 
 ifeq ($(SPEED), slow)
@@ -87,7 +81,6 @@ sha512-sse: sha512.c
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 
 run-sha512-sse: QEMU_OPTS+=-cpu max
-run-plugin-sha512-sse-with-%: QEMU_OPTS+=-cpu max
 
 TESTS+=sha512-sse
 
@@ -103,15 +96,12 @@ test-avx.h: test-avx.py x86.csv
 
 test-3dnow: CFLAGS += -masm=intel -O -I.
 run-test-3dnow: QEMU_OPTS += -cpu max
-run-plugin-test-3dnow: QEMU_OPTS += -cpu max
 test-3dnow: test-3dnow.h
 
 test-mmx: CFLAGS += -masm=intel -O -I.
 run-test-mmx: QEMU_OPTS += -cpu max
-run-plugin-test-mmx: QEMU_OPTS += -cpu max
 test-mmx: test-mmx.h
 
 test-avx: CFLAGS += -mavx -masm=intel -O -I.
 run-test-avx: QEMU_OPTS += -cpu max
-run-plugin-test-avx: QEMU_OPTS += -cpu max
 test-avx: test-avx.h
tests/tcg/ppc64/Makefile.target +0 -2
index f081f1c683..6d47d3cae6 100644
@@ -24,14 +24,12 @@ PPC64_TESTS += byte_reverse sha512-vector
 endif
 byte_reverse: CFLAGS += -mcpu=power10
 run-byte_reverse: QEMU_OPTS+=-cpu POWER10
-run-plugin-byte_reverse-with-%: QEMU_OPTS+=-cpu POWER10
 
 sha512-vector: CFLAGS +=-mcpu=power10 -O3
 sha512-vector: sha512.c
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
 
 run-sha512-vector: QEMU_OPTS+=-cpu POWER10
-run-plugin-sha512-vector-with-%: QEMU_OPTS+=-cpu POWER10
 
 PPC64_TESTS += signal_save_restore_xer
 PPC64_TESTS += xxspltw
tests/tcg/riscv64/Makefile.softmmu-target +3 -0
index e22cdb34c5..d5b126e5f1 100644
@@ -19,3 +19,6 @@ QEMU_OPTS += -M virt -display none -semihosting -device loader,file=
 EXTRA_RUNS += run-issue1060
 run-issue1060: issue1060
 	$(call run-test, $<, $(QEMU) $(QEMU_OPTS)$<)
+
+# We don't currently support the multiarch system tests
+undefine MULTIARCH_TESTS
tests/tcg/riscv64/Makefile.target +0 -1
index cc3ed65ffd..9973ba3b5f 100644
@@ -9,4 +9,3 @@ TESTS += noexec
 TESTS += test-noc
 test-noc: LDFLAGS = -nostdlib -static
 run-test-noc: QEMU_OPTS += -cpu rv64,c=false
-run-plugin-test-noc-%: QEMU_OPTS += -cpu rv64,c=false
tests/tcg/s390x/Makefile.softmmu-target +3 -0
index 3e7f72abcd..192315dd20 100644
@@ -23,3 +23,6 @@ include $(S390X_SRC)/pgm-specification.mak
 $(PGM_SPECIFICATION_TESTS): pgm-specification-softmmu.o
 $(PGM_SPECIFICATION_TESTS): LDFLAGS+=pgm-specification-softmmu.o
 TESTS += $(PGM_SPECIFICATION_TESTS)
+
+# We don't currently support the multiarch system tests
+undefine MULTIARCH_TESTS
tests/tcg/tricore/Makefile.softmmu-target +3 -0
index b3cd56fffc..49e573bc3b 100644
@@ -29,3 +29,6 @@ QEMU_OPTS += -M tricore_testboard -cpu tc27x -nographic -kernel
 
 %.tst: %.o
 	$(LD) $(LDFLAGS) $< -o $@
+
+# We don't currently support the multiarch system tests
+undefine MULTIARCH_TESTS
tests/tcg/xtensa/Makefile.softmmu-target +3 -0
index ba6cd9fde3..78bf72dfaa 100644
@@ -41,3 +41,6 @@ $(XTENSA_USABLE_TESTS): linker.ld macros.inc $(CRT) Makefile.softmmu-target
 	$(CC) $(XTENSA_INC) $(ASFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) $(NOSTDFLAGS) $(CRT)
 
 endif
+
+# We don't currently support the multiarch system tests
+undefine MULTIARCH_TESTS
Signature · 1 line
2.39.2
#16 lore raw

PATCH 14/18 qemu-options.hx: Update descriptions of memory options for NUMA node

In reply to Alex Bennée

From: Yohei Kojima <[email protected]>

This commit adds the following description:
1. memdev option is recommended over mem option (see [1,2])
2. users must specify memory for all NUMA nodes (see [2])

This commit also separates descriptions for mem and memdev into two paragraphs. The old doc describes legacy mem option first, and it was a bit confusing.

Related documentation:
[1] https://wiki.qemu.org/ChangeLog/5.1#Incompatible_changes
[2] https://www.qemu.org/docs/master/about/removed-features.html

Message-Id: <TYZPR06MB5418D6B0175A49E8E76988439D8E9@TYZPR06MB5418.apcprd06.prod.outlook.com>

Message-Id: <[email protected]>

[AJB: fix documentation in commit message]
---
 qemu-options.hx | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)
qemu-options.hx +16 -9
index baa0589733..b5efa648ba 100644
@@ -405,15 +405,22 @@ SRST
         -numa node,nodeid=0 -numa node,nodeid=1 \
         -numa cpu,node-id=0,socket-id=0 -numa cpu,node-id=1,socket-id=1
 
-    Legacy '\ ``mem``\ ' assigns a given RAM amount to a node (not supported
-    for 5.1 and newer machine types). '\ ``memdev``\ ' assigns RAM from
-    a given memory backend device to a node. If '\ ``mem``\ ' and
-    '\ ``memdev``\ ' are omitted in all nodes, RAM is split equally between them.
-
-
-    '\ ``mem``\ ' and '\ ``memdev``\ ' are mutually exclusive.
-    Furthermore, if one node uses '\ ``memdev``\ ', all of them have to
-    use it.
+    '\ ``memdev``\ ' option assigns RAM from a given memory backend
+    device to a node. It is recommended to use '\ ``memdev``\ ' option
+    over legacy '\ ``mem``\ ' option. This is because '\ ``memdev``\ '
+    option provides better performance and more control over the
+    backend's RAM (e.g. '\ ``prealloc``\ ' parameter of
+    '\ ``-memory-backend-ram``\ ' allows memory preallocation).
+
+    For compatibility reasons, legacy '\ ``mem``\ ' option is
+    supported in 5.0 and older machine types. Note that '\ ``mem``\ '
+    and '\ ``memdev``\ ' are mutually exclusive. If one node uses
+    '\ ``memdev``\ ', the rest nodes have to use '\ ``memdev``\ '
+    option, and vice versa.
+
+    Users must specify memory for all NUMA nodes by '\ ``memdev``\ '
+    (or legacy '\ ``mem``\ ' if available). In QEMU 5.2, the support
+    for '\ ``-numa node``\ ' without memory specified was removed.
 
     '\ ``initiator``\ ' is an additional option that points to an
     initiator NUMA node that has best performance (the lowest latency or
Signature · 1 line
2.39.2
#17 lore raw

PATCH 15/18 docs/system: remove excessive punctuation from guest-loader docs

In reply to Alex Bennée

A possessive its needs no ' whereas the contraction of it is does.

Message-Id: <[email protected]>

---
 docs/system/guest-loader.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
docs/system/guest-loader.rst +3 -3
index 9ef9776bf0..304ee5d531 100644
@@ -14,7 +14,7 @@ The guest loader does two things:
   - load blobs (kernels and initial ram disks) into memory
   - sets platform FDT data so hypervisors can find and boot them
 
-This is what is typically done by a boot-loader like grub using it's
+This is what is typically done by a boot-loader like grub using its
 multi-boot capability. A typical example would look like:
 
 .. parsed-literal::
@@ -25,9 +25,9 @@ multi-boot capability. A typical example would look like:
     -device guest-loader,addr=0x47000000,initrd=rootfs.cpio
 
 In the above example the Xen hypervisor is loaded by the -kernel
-parameter and passed it's boot arguments via -append. The Dom0 guest
+parameter and passed its boot arguments via -append. The Dom0 guest
 is loaded into the areas of memory. Each blob will get
-``/chosen/module@<addr>`` entry in the FDT to indicate it's location and
+``/chosen/module@<addr>`` entry in the FDT to indicate its location and
 size. Additional information can be passed with by using additional
 arguments.
 
Signature · 1 line
2.39.2
#18 lore raw

PATCH 16/18 docs/devel: make a statement about includes

In reply to Alex Bennée

While not explicitly disallowing header macro abuse (because that would make us hypocrites) lets at least address some things to think about.

Message-Id: <[email protected]>

---
 docs/devel/style.rst | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
docs/devel/style.rst +14 -0
index 68aa776930..5bc6f2f095 100644
@@ -300,6 +300,20 @@ putting those into qemu/typedefs.h instead of including the header.
 
 Cyclic inclusion is forbidden.
 
+Generative Includes
+-------------------
+
+QEMU makes fairly extensive use of the macro pre-processor to
+instantiate multiple similar functions. While such abuse of the macro
+processor isn't discouraged it can make debugging and code navigation
+harder. You should consider carefully if the same effect can be
+achieved by making it easy for the compiler to constant fold or using
+python scripting to generate grep friendly code.
+
+If you do use template header files they should be named with the
+``.c.inc`` or ``.h.inc`` suffix to make it clear they are being
+included for expansion.
+
 C types
 =======
 
Signature · 1 line
2.39.2
#19 lore raw

PATCH 17/18 docs/devel: mention the spacing requirement for QOM

In reply to Alex Bennée

We have a more complete document on QOM but we should at least mention the style requirements in the style guide.

Message-Id: <[email protected]>

---
vppr:
- use Mark's formulation, briefly mention property separation.

---
 docs/devel/qom.rst   |  2 ++
 docs/devel/style.rst | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
docs/devel/qom.rst +2 -0
index 3e34b07c98..c9237950d0 100644
@@ -1,3 +1,5 @@
+.. _qom:
+
 ===========================
 The QEMU Object Model (QOM)
 ===========================
docs/devel/style.rst +40 -0
index 5bc6f2f095..e9fce0fc69 100644
@@ -628,6 +628,46 @@ are still some caveats to beware of
 QEMU Specific Idioms
 ********************
 
+QEMU Object Model Declarations
+==============================
+
+QEMU Object Model Declarations
+==============================
+
+The QEMU Object Model (QOM) provides a framework for handling objects
+in the base C language. The first declaration of a storage or class
+structure should always be the parent and leave a visual space between
+that declaration and the new code. It is also useful to separate
+backing for properties (options driven by the user) and internal state
+to make navigation easier.
+
+For a storage structure the first declaration should always be called
+"parent_obj" and for a class structure the first member should always
+be called "parent_class" as below:
+
+.. code-block:: c
+
+    struct MyDeviceState {
+        DeviceState parent_obj;
+
+        /* Properties */
+        int prop_a;
+        char *prop_b;
+        /* Other stuff */
+        int internal_state;
+    };
+
+    struct MyDeviceClass {
+        DeviceClass parent_class;
+
+        void (*new_fn1)(void);
+        bool (*new_fn2)(CPUState *);
+    };
+
+Note that there is no need to provide typedefs for QOM structures
+since these are generated automatically by the QOM declaration macros.
+See :ref:`qom` for more details.
+
 Error handling and reporting
 ============================
 
Signature · 1 line
2.39.2
Reviewed-by on v1 17/18
#20 lore raw

Re: [PATCH 17/18] docs/devel: mention the spacing requirement for QOM

Quoted 31 lines · Alex Bennée

We have a more complete document on QOM but we should at least mention the style requirements in the style guide.

Message-Id: <[email protected]>

---
vppr:
- use Mark's formulation, briefly mention property separation.

---
  docs/devel/qom.rst   |  2 ++
  docs/devel/style.rst | 40 ++++++++++++++++++++++++++++++++++++++++
  2 files changed, 42 insertions(+)
docs/devel/qom.rst +2 -0
index 3e34b07c98..c9237950d0 100644
@@ -1,3 +1,5 @@
+.. _qom:
+
  ===========================
  The QEMU Object Model (QOM)
  ===========================
docs/devel/style.rst +0 -0
index 5bc6f2f095..e9fce0fc69 100644

docs/devel/style.rst are still some caveats to beware of · line 635

Quoted 8 lines
docs/devel/style.rst +5 -0
@@ -628,6 +628,46 @@ are still some caveats to beware of
  QEMU Specific Idioms
  ********************
 
+QEMU Object Model Declarations
+==============================
+
+QEMU Object Model Declarations
+==============================

Accidental repetition here :)

Quoted 26 lines
docs/devel/style.rst +26 -0
+The QEMU Object Model (QOM) provides a framework for handling objects
+in the base C language. The first declaration of a storage or class
+structure should always be the parent and leave a visual space between
+that declaration and the new code. It is also useful to separate
+backing for properties (options driven by the user) and internal state
+to make navigation easier.
+
+For a storage structure the first declaration should always be called
+"parent_obj" and for a class structure the first member should always
+be called "parent_class" as below:
+
+.. code-block:: c
+
+    struct MyDeviceState {
+        DeviceState parent_obj;
+
+        /* Properties */
+        int prop_a;
+        char *prop_b;
+        /* Other stuff */
+        int internal_state;
+    };
+
+    struct MyDeviceClass {
+        DeviceClass parent_class;
+

docs/devel/style.rst are still some caveats to beware of · line 672

Quoted 10 lines
docs/devel/style.rst +8 -0
+        void (*new_fn1)(void);
+        bool (*new_fn2)(CPUState *);
+    };
+
+Note that there is no need to provide typedefs for QOM structures
+since these are generated automatically by the QOM declaration macros.
+See :ref:`qom` for more details.
+
  Error handling and reporting
  ============================

Otherwise:

ATB,

Mark.

#21 lore raw

PATCH 18/18 docs/style: call out the use of GUARD macros

In reply to Alex Bennée

There use makes our code safer so we should mention them.

Message-Id: <[email protected]>

---
vppr:
- show example of what QEMU_LOCK_GUARD makes easier (although I didn't repeat for the WITH_ form)

---
 docs/devel/style.rst | 54 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
docs/devel/style.rst +54 -0
index e9fce0fc69..b97e5111fc 100644
@@ -668,6 +668,60 @@ Note that there is no need to provide typedefs for QOM structures
 since these are generated automatically by the QOM declaration macros.
 See :ref:`qom` for more details.
 
+QEMU GUARD macros
+=================
+
+QEMU provides a number of ``_GUARD`` macros intended to make the
+handling of multiple exit paths easier. For example using
+``QEMU_LOCK_GUARD`` to take a lock will ensure the lock is released on
+exit from the function.
+
+.. code-block:: c
+
+    static int my_critical_function(SomeState *s, void *data)
+    {
+        QEMU_LOCK_GUARD(&s->lock);
+        do_thing1(data);
+        if (check_state2(data)) {
+            return -1;
+        }
+        do_thing3(data);
+        return 0;
+    }
+
+will ensure s->lock is released however the function is exited. The
+equivalent code without _GUARD macro makes us to carefully put
+qemu_mutex_unlock() on all exit points:
+
+.. code-block:: c
+
+    static int my_critical_function(SomeState *s, void *data)
+    {
+        qemu_mutex_lock(&s->lock);
+        do_thing1(data);
+        if (check_state2(data)) {
+            qemu_mutex_unlock(&s->lock);
+            return -1;
+        }
+        do_thing3(data);
+        qemu_mutex_unlock(&s->lock);
+        return 0;
+    }
+
+There are often ``WITH_`` forms of macros which more easily wrap
+around a block inside a function.
+
+.. code-block:: c
+
+    WITH_RCU_READ_LOCK_GUARD() {
+        QTAILQ_FOREACH_RCU(kid, &bus->children, sibling) {
+            err = do_the_thing(kid->child);
+            if (err < 0) {
+                return err;
+            }
+        }
+    }
+
 Error handling and reporting
 ============================
 
Signature · 1 line
2.39.2