Skip to contentSkip to conversation

hw/virtio: Build various target-agnostic objects just once

PATCH In review Philippe Mathieu-Daudé 5 participants 24 messages May 24, 2023 – May 26, 2023 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover hw/virtio: Build various target-agnostic objects just once

All patches reviewed.

Since v1:
- Addressed Richard & Thomas review comments
. qemu_target_page_align() dropped
. qemu_target_page_mask() returns signed
. meson shuffle
- Collected R-b/T-b/A-b tags
- Dropped vhost-vdpa patch (to be posted as another series)

Less controvertial than my first approach [*] which caches the access_is_big_endian value in VirtIODevice state, this series just remove a unnecessary / pointless dependency on "virtio-access.h", allowing to build various virtio objects once for all targets.

[*] https://lore.kernel.org/qemu-devel/[email protected]/

Philippe Mathieu-Daudé (10):
softmmu: Introduce qemu_target_page_mask() helper hw/scsi: Introduce VHOST_SCSI_COMMON symbol in Kconfig hw/scsi: Rearrange meson.build
hw/scsi: Rename target-specific source set as
'specific_virtio_scsi_ss'
hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig hw/virtio/virtio-mem: Use qemu_ram_get_fd() helper hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header hw/virtio/virtio-iommu: Use target-agnostic qemu_target_page_mask() hw/virtio: Remove unnecessary 'virtio-access.h' header hw/virtio: Build various target-agnostic objects just once

 include/exec/target_page.h      |  1 +
 hw/block/dataplane/virtio-blk.c |  1 -
 hw/s390x/virtio-ccw.c           |  1 -
 hw/scsi/vhost-scsi.c            |  1 -
 hw/scsi/vhost-user-scsi.c       |  1 -
 hw/scsi/virtio-scsi-dataplane.c |  1 -
 hw/virtio/vdpa-dev.c            |  1 -
 hw/virtio/vhost-vdpa.c          |  1 -
 hw/virtio/vhost-vsock-common.c  |  2 +-
 hw/virtio/vhost.c               |  1 -
 hw/virtio/virtio-crypto.c       |  1 -
 hw/virtio/virtio-iommu.c        |  4 ++--
 hw/virtio/virtio-mem.c          |  3 +--
 softmmu/physmem.c               |  5 +++++
 hw/block/dataplane/meson.build  |  2 +-
 hw/scsi/Kconfig                 |  6 ++++++
 hw/scsi/meson.build             | 20 +++++++++++++-------
 hw/virtio/Kconfig               |  6 ++++++
 hw/virtio/meson.build           | 14 ++++++++------
 19 files changed, 44 insertions(+), 28 deletions(-)
Signature · 1 line
2.38.1
#1 lore raw

PATCH v2 1/10 softmmu: Introduce qemu_target_page_mask() helper

Since TARGET_PAGE_MASK is poisoned in target-agnostic code, introduce the qemu_target_page_mask() helper to get this value from target-agnostic code at runtime.

---
 include/exec/target_page.h | 1 +
 softmmu/physmem.c          | 5 +++++
 2 files changed, 6 insertions(+)
include/exec/target_page.h +1 -0
index bbf37aea17..98ffbb5c23 100644
@@ -15,6 +15,7 @@
 #define EXEC_TARGET_PAGE_H
 
 size_t qemu_target_page_size(void);
+int qemu_target_page_mask(void);
 int qemu_target_page_bits(void);
 int qemu_target_page_bits_min(void);
 
softmmu/physmem.c +5 -0
index 9d7e172260..8067742df0 100644
@@ -3354,6 +3354,11 @@ size_t qemu_target_page_size(void)
     return TARGET_PAGE_SIZE;
 }
 
+int qemu_target_page_mask(void)
+{
+    return TARGET_PAGE_MASK;
+}
+
 int qemu_target_page_bits(void)
 {
     return TARGET_PAGE_BITS;
Signature · 1 line
2.38.1
Reviewed-by on v2 1/10
#2 lore raw

Re: [PATCH v2 01/10] softmmu: Introduce qemu_target_page_mask() helper

Quoted 10 lines · Philippe Mathieu-Daudé

Since TARGET_PAGE_MASK is poisoned in target-agnostic code, introduce the qemu_target_page_mask() helper to get this value from target-agnostic code at runtime.

---
  include/exec/target_page.h | 1 +
  softmmu/physmem.c          | 5 +++++
  2 files changed, 6 insertions(+)

r~

Reviewed-by on v2 1/10
#3 lore raw

Re: [PATCH v2 01/10] softmmu: Introduce qemu_target_page_mask() helper

In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

Since TARGET_PAGE_MASK is poisoned in target-agnostic code, introduce the qemu_target_page_mask() helper to get this value from target-agnostic code at runtime.

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

PATCH v2 2/10 hw/scsi: Introduce VHOST_SCSI_COMMON symbol in Kconfig

In reply to Philippe Mathieu-Daudé

Instead of adding 'vhost-scsi-common.c' twice (for VHOST_SCSI and VHOST_USER_SCSI), have it depend on VHOST_SCSI_COMMON, selected by both symbols.

---
 hw/scsi/Kconfig     | 6 ++++++
 hw/scsi/meson.build | 6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
hw/scsi/Kconfig +6 -0
index e7b34dc8e2..1feab84c4c 100644
@@ -48,13 +48,19 @@ config VIRTIO_SCSI
     depends on VIRTIO
     select SCSI
 
+config VHOST_SCSI_COMMON
+    bool
+    depends on VIRTIO
+
 config VHOST_SCSI
     bool
     default y
+    select VHOST_SCSI_COMMON
     depends on VIRTIO && VHOST_KERNEL
 
 config VHOST_USER_SCSI
     bool
     # Only PCI devices are provided for now
     default y if VIRTIO_PCI
+    select VHOST_SCSI_COMMON
     depends on VIRTIO && VHOST_USER && LINUX
hw/scsi/meson.build +4 -2
index 923a34f344..fa9198e69f 100644
@@ -17,8 +17,10 @@ specific_scsi_ss = ss.source_set()
 
 virtio_scsi_ss = ss.source_set()
 virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
-virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-scsi.c'))
-virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-scsi-common.c', 'vhost-user-scsi.c'))
+
+virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI_COMMON', if_true: files('vhost-scsi-common.c'))
+virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi.c'))
+virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi.c'))
 specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
 
 specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
Signature · 1 line
2.38.1
Reviewed-by on v2 2/10
#5 lore raw

Re: [PATCH v2 02/10] hw/scsi: Introduce VHOST_SCSI_COMMON symbol in Kconfig

Quoted 7 lines · Philippe Mathieu-Daudé

Instead of adding 'vhost-scsi-common.c' twice (for VHOST_SCSI and VHOST_USER_SCSI), have it depend on VHOST_SCSI_COMMON, selected by both symbols.

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

PATCH v2 3/10 hw/scsi: Rearrange meson.build

In reply to Philippe Mathieu-Daudé

We will modify this file shortly. Re-arrange it slightly first, declaring source sets first.

No logical change.

---
 hw/scsi/meson.build | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
hw/scsi/meson.build +5 -5
index fa9198e69f..f2da0bc5ae 100644
@@ -1,4 +1,7 @@
 scsi_ss = ss.source_set()
+specific_scsi_ss = ss.source_set()
+virtio_scsi_ss = ss.source_set()
+
 scsi_ss.add(files(
   'emulation.c',
   'scsi-bus.c',
@@ -11,18 +14,15 @@ scsi_ss.add(when: 'CONFIG_LSI_SCSI_PCI', if_true: files('lsi53c895a.c'))
 scsi_ss.add(when: 'CONFIG_MEGASAS_SCSI_PCI', if_true: files('megasas.c'))
 scsi_ss.add(when: 'CONFIG_MPTSAS_SCSI_PCI', if_true: files('mptsas.c', 'mptconfig.c', 'mptendian.c'))
 scsi_ss.add(when: 'CONFIG_VMW_PVSCSI_SCSI_PCI', if_true: files('vmw_pvscsi.c'))
-softmmu_ss.add_all(when: 'CONFIG_SCSI', if_true: scsi_ss)
 
-specific_scsi_ss = ss.source_set()
-
-virtio_scsi_ss = ss.source_set()
 virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
-
 virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI_COMMON', if_true: files('vhost-scsi-common.c'))
 virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi.c'))
 virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi.c'))
+
 specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
 
 specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
 
+softmmu_ss.add_all(when: 'CONFIG_SCSI', if_true: scsi_ss)
 specific_ss.add_all(when: 'CONFIG_SCSI', if_true: specific_scsi_ss)
Signature · 1 line
2.38.1
Reviewed-by on v2 3/10
#7 lore raw

Re: [PATCH v2 03/10] hw/scsi: Rearrange meson.build

Quoted 10 lines · Philippe Mathieu-Daudé

We will modify this file shortly. Re-arrange it slightly first, declaring source sets first.

No logical change.

---
  hw/scsi/meson.build | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
Reviewed-by on v2 3/10
#8 lore raw

Re: [PATCH v2 03/10] hw/scsi: Rearrange meson.build

In reply to Philippe Mathieu-Daudé
Quoted 7 lines · Philippe Mathieu-Daudé

We will modify this file shortly. Re-arrange it slightly first, declaring source sets first.

No logical change.

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

PATCH v2 4/10 hw/scsi: Rename target-specific source set as 'specific_virtio_scsi_ss'

In reply to Philippe Mathieu-Daudé

Following the SCSI variable named '[specific_]scsi_ss', rename the target-specific VirtIO/SCSI set prefixed with 'specific_'. This will help when adding target-agnostic VirtIO/SCSI set in few commits.

No logical change.

---
 hw/scsi/meson.build | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
hw/scsi/meson.build +6 -6
index f2da0bc5ae..bde72df19c 100644
@@ -1,6 +1,6 @@
 scsi_ss = ss.source_set()
 specific_scsi_ss = ss.source_set()
-virtio_scsi_ss = ss.source_set()
+specific_virtio_scsi_ss = ss.source_set()
 
 scsi_ss.add(files(
   'emulation.c',
@@ -15,12 +15,12 @@ scsi_ss.add(when: 'CONFIG_MEGASAS_SCSI_PCI', if_true: files('megasas.c'))
 scsi_ss.add(when: 'CONFIG_MPTSAS_SCSI_PCI', if_true: files('mptsas.c', 'mptconfig.c', 'mptendian.c'))
 scsi_ss.add(when: 'CONFIG_VMW_PVSCSI_SCSI_PCI', if_true: files('vmw_pvscsi.c'))
 
-virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
-virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI_COMMON', if_true: files('vhost-scsi-common.c'))
-virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi.c'))
-virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi.c'))
+specific_virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
+specific_virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI_COMMON', if_true: files('vhost-scsi-common.c'))
+specific_virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi.c'))
+specific_virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi.c'))
 
-specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
+specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: specific_virtio_scsi_ss)
 
 specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
 
Signature · 1 line
2.38.1
Reviewed-by on v2 4/10
#10 lore raw

Re: [PATCH v2 04/10] hw/scsi: Rename target-specific source set as 'specific_virtio_scsi_ss'

Quoted 11 lines · Philippe Mathieu-Daudé

Following the SCSI variable named '[specific_]scsi_ss', rename the target-specific VirtIO/SCSI set prefixed with 'specific_'. This will help when adding target-agnostic VirtIO/SCSI set in few commits.

No logical change.

---
  hw/scsi/meson.build | 12 ++++++------
  1 file changed, 6 insertions(+), 6 deletions(-)
#11 lore raw

PATCH v2 5/10 hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig

In reply to Philippe Mathieu-Daudé

Instead of adding 'vhost-vsock-common.c' twice (for VHOST_VSOCK and VHOST_USER_VSOCK), have it depend on VHOST_VSOCK_COMMON, selected by both symbols.

---
 hw/virtio/Kconfig     | 6 ++++++
 hw/virtio/meson.build | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)
hw/virtio/Kconfig +6 -0
index 89e9e426d8..de7a35429a 100644
@@ -56,14 +56,20 @@ config VIRTIO_MEM
     depends on VIRTIO_MEM_SUPPORTED
     select MEM_DEVICE
 
+config VHOST_VSOCK_COMMON
+    bool
+    depends on VIRTIO
+
 config VHOST_VSOCK
     bool
     default y
+    select VHOST_VSOCK_COMMON
     depends on VIRTIO && VHOST_KERNEL
 
 config VHOST_USER_VSOCK
     bool
     default y
+    select VHOST_VSOCK_COMMON
     depends on VIRTIO && VHOST_USER
 
 config VHOST_USER_I2C
hw/virtio/meson.build +3 -2
index bdec78bfc6..54c90c24fb 100644
@@ -23,8 +23,9 @@ specific_virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-bal
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c', 'vhost-vsock-common.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c', 'vhost-vsock-common.c'))
+specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK_COMMON', if_true: files('vhost-vsock-common.c'))
+specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c'))
+specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
Signature · 1 line
2.38.1
Reviewed-by on v2 5/10
#12 lore raw

Re: [PATCH v2 05/10] hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig

Quoted 7 lines · Philippe Mathieu-Daudé

Instead of adding 'vhost-vsock-common.c' twice (for VHOST_VSOCK and VHOST_USER_VSOCK), have it depend on VHOST_VSOCK_COMMON, selected by both symbols.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
Reviewed-by on v2 5/10
#13 lore raw

Re: [PATCH v2 05/10] hw/virtio: Introduce VHOST_VSOCK_COMMON symbol in Kconfig

In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

Instead of adding 'vhost-vsock-common.c' twice (for VHOST_VSOCK and VHOST_USER_VSOCK), have it depend on VHOST_VSOCK_COMMON, selected by both symbols.

---
hw/virtio/Kconfig | 6 ++++++
hw/virtio/meson.build | 5 +++--

2 files changed, 9 insertions(+), 2 deletions(-)
#14 lore raw

PATCH v2 6/10 hw/virtio/virtio-mem: Use qemu_ram_get_fd() helper

In reply to Philippe Mathieu-Daudé

Avoid accessing RAMBlock internals, use the provided qemu_ram_get_fd() getter to get the file descriptor.

---
 hw/virtio/virtio-mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-mem.c +1 -1
index 538b695c29..74e63bd47a 100644
@@ -135,7 +135,7 @@ static bool virtio_mem_has_shared_zeropage(RAMBlock *rb)
      * anonymous RAM. In any other case, reading unplugged *can* populate a
      * fresh page, consuming actual memory.
      */
-    return !qemu_ram_is_shared(rb) && rb->fd < 0 &&
+    return !qemu_ram_is_shared(rb) && qemu_ram_get_fd(rb) < 0 &&
            qemu_ram_pagesize(rb) == qemu_real_host_page_size();
 }
 #endif /* VIRTIO_MEM_HAS_LEGACY_GUESTS */
Signature · 1 line
2.38.1
Reviewed-by on v2 6/10
#15 lore raw

Re: [PATCH v2 06/10] hw/virtio/virtio-mem: Use qemu_ram_get_fd() helper

Quoted 6 lines · Philippe Mathieu-Daudé

Avoid accessing RAMBlock internals, use the provided qemu_ram_get_fd() getter to get the file descriptor.

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

PATCH v2 7/10 hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header

In reply to Philippe Mathieu-Daudé

Instead of having "virtio/virtio-bus.h" implicitly included, explicitly include it, to avoid when rearranging headers:

hw/virtio/vhost-vsock-common.c: In function ‘vhost_vsock_common_start’:
hw/virtio/vhost-vsock-common.c:51:5: error: unknown type name ‘VirtioBusClass’; did you mean ‘VirtioDeviceClass’?

     51 |     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
        |     ^~~~~~~~~~~~~~
        |     VirtioDeviceClass
  hw/virtio/vhost-vsock-common.c:51:25: error: implicit declaration of function ‘VIRTIO_BUS_GET_CLASS’; did you mean ‘VIRTIO_DEVICE_CLASS’? [-Werror=implicit-function-declaration]
     51 |     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
        |                         ^~~~~~~~~~~~~~~~~~~~
        |                         VIRTIO_DEVICE_CLASS
---
 hw/virtio/vhost-vsock-common.c | 1 +
 1 file changed, 1 insertion(+)
hw/virtio/vhost-vsock-common.c +1 -0
index d2b5519d5a..e89af9b329 100644
@@ -11,6 +11,7 @@
 #include "qemu/osdep.h"
 #include "standard-headers/linux/virtio_vsock.h"
 #include "qapi/error.h"
+#include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
 #include "qemu/error-report.h"
 #include "hw/qdev-properties.h"
Signature · 1 line
2.38.1
Reviewed-by on v2 7/10
#17 lore raw

Re: [PATCH v2 07/10] hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header

Quoted 15 lines · Philippe Mathieu-Daudé

Instead of having "virtio/virtio-bus.h" implicitly included, explicitly include it, to avoid when rearranging headers:

hw/virtio/vhost-vsock-common.c: In function ‘vhost_vsock_common_start’:
hw/virtio/vhost-vsock-common.c:51:5: error: unknown type name ‘VirtioBusClass’; did you mean ‘VirtioDeviceClass’?

     51 |     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
        |     ^~~~~~~~~~~~~~
        |     VirtioDeviceClass
  hw/virtio/vhost-vsock-common.c:51:25: error: implicit declaration of
function ‘VIRTIO_BUS_GET_CLASS’; did you mean ‘VIRTIO_DEVICE_CLASS’?
[-Werror=implicit-function-declaration]
     51 |     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
        |                         ^~~~~~~~~~~~~~~~~~~~
        |                         VIRTIO_DEVICE_CLASS
Quoted 3 lines
Quoted 3 lines
---
 hw/virtio/vhost-vsock-common.c | 1 +
 1 file changed, 1 insertion(+)
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
Reviewed-by on v2 7/10
#18 lore raw

Re: [PATCH v2 07/10] hw/virtio/vhost-vsock: Include missing 'virtio/virtio-bus.h' header

In reply to Philippe Mathieu-Daudé
Quoted 13 lines · Philippe Mathieu-Daudé

Instead of having "virtio/virtio-bus.h" implicitly included, explicitly include it, to avoid when rearranging headers:

hw/virtio/vhost-vsock-common.c: In function ‘vhost_vsock_common_start’:
hw/virtio/vhost-vsock-common.c:51:5: error: unknown type name ‘VirtioBusClass’; did you mean ‘VirtioDeviceClass’?

    51 |     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
       |     ^~~~~~~~~~~~~~
       |     VirtioDeviceClass
 hw/virtio/vhost-vsock-common.c:51:25: error: implicit declaration of function ‘VIRTIO_BUS_GET_CLASS’; did you mean ‘VIRTIO_DEVICE_CLASS’? [-Werror=implicit-function-declaration]
    51 |     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
       |                         ^~~~~~~~~~~~~~~~~~~~
       |                         VIRTIO_DEVICE_CLASS
Quoted 6 lines

---
hw/virtio/vhost-vsock-common.c | 1 +

1 file changed, 1 insertion(+)
#19 lore raw

PATCH v2 8/10 hw/virtio/virtio-iommu: Use target-agnostic qemu_target_page_mask()

In reply to Philippe Mathieu-Daudé

In order to have virtio-iommu.c become target-agnostic, we need to avoid using TARGET_PAGE_MASK. Get it with the qemu_target_page_mask() helper.

---
 hw/virtio/virtio-iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/virtio-iommu.c +2 -1
index 1cd258135d..85905a9e3d 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "qemu/iov.h"
+#include "exec/target_page.h"
 #include "hw/qdev-properties.h"
 #include "hw/virtio/virtio.h"
 #include "sysemu/kvm.h"
@@ -1164,7 +1165,7 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp)
      * in vfio realize
      */
     s->config.bypass = s->boot_bypass;
-    s->config.page_size_mask = TARGET_PAGE_MASK;
+    s->config.page_size_mask = qemu_target_page_mask();
     s->config.input_range.end = UINT64_MAX;
     s->config.domain_range.end = UINT32_MAX;
     s->config.probe_size = VIOMMU_PROBE_SIZE;
Signature · 1 line
2.38.1
Reviewed-by on v2 8/10
#20 lore raw

Re: [PATCH v2 08/10] hw/virtio/virtio-iommu: Use target-agnostic qemu_target_page_mask()

Quoted 7 lines · Philippe Mathieu-Daudé

In order to have virtio-iommu.c become target-agnostic, we need to avoid using TARGET_PAGE_MASK. Get it with the qemu_target_page_mask() helper.

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

PATCH v2 9/10 hw/virtio: Remove unnecessary 'virtio-access.h' header

In reply to Philippe Mathieu-Daudé

None of these files use the VirtIO Load/Store API declared by "hw/virtio/virtio-access.h". This header probably crept in via copy/pasting, remove it.

Note, "virtio-access.h" is target-specific, so any file including it also become tainted as target-specific.

---
 hw/block/dataplane/virtio-blk.c | 1 -
 hw/s390x/virtio-ccw.c           | 1 -
 hw/scsi/vhost-scsi.c            | 1 -
 hw/scsi/vhost-user-scsi.c       | 1 -
 hw/scsi/virtio-scsi-dataplane.c | 1 -
 hw/virtio/vdpa-dev.c            | 1 -
 hw/virtio/vhost-vdpa.c          | 1 -
 hw/virtio/vhost-vsock-common.c  | 1 -
 hw/virtio/vhost.c               | 1 -
 hw/virtio/virtio-crypto.c       | 1 -
 hw/virtio/virtio-iommu.c        | 1 -
 hw/virtio/virtio-mem.c          | 1 -
 12 files changed, 12 deletions(-)
hw/block/dataplane/virtio-blk.c +0 -1
index af1c24c40c..03ecb51664 100644
@@ -19,7 +19,6 @@
 #include "qemu/main-loop.h"
 #include "qemu/thread.h"
 #include "qemu/error-report.h"
-#include "hw/virtio/virtio-access.h"
 #include "hw/virtio/virtio-blk.h"
 #include "virtio-blk.h"
 #include "block/aio.h"
hw/s390x/virtio-ccw.c +0 -1
index f44de1a8c1..17c548b84f 100644
@@ -22,7 +22,6 @@
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "qemu/module.h"
-#include "hw/virtio/virtio-access.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/s390x/adapter.h"
 #include "hw/s390x/s390_flic.h"
hw/scsi/vhost-scsi.c +0 -1
index 6a0fd0dfb1..443f67daa4 100644
@@ -26,7 +26,6 @@
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/virtio-scsi.h"
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 #include "hw/fw-path-provider.h"
 #include "hw/qdev-properties.h"
 #include "qemu/cutils.h"
hw/scsi/vhost-user-scsi.c +0 -1
index b7a71a802c..ee99b19e7a 100644
@@ -26,7 +26,6 @@
 #include "hw/virtio/vhost-backend.h"
 #include "hw/virtio/vhost-user-scsi.h"
 #include "hw/virtio/virtio.h"
-#include "hw/virtio/virtio-access.h"
 #include "chardev/char-fe.h"
 #include "sysemu/sysemu.h"
 
hw/scsi/virtio-scsi-dataplane.c +0 -1
index f3214e1c57..21344c7cfe 100644
@@ -19,7 +19,6 @@
 #include "hw/scsi/scsi.h"
 #include "scsi/constants.h"
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 
 /* Context: QEMU global mutex held */
 void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
hw/virtio/vdpa-dev.c +0 -1
index 01b41eb0f1..e08e830006 100644
@@ -25,7 +25,6 @@
 #include "hw/virtio/vhost.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 #include "hw/virtio/vdpa-dev.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/runstate.h"
hw/virtio/vhost-vdpa.c +0 -1
index b3094e8a8b..3c575a9a6e 100644
@@ -26,7 +26,6 @@
 #include "cpu.h"
 #include "trace.h"
 #include "qapi/error.h"
-#include "hw/virtio/virtio-access.h"
 
 /*
  * Return one past the end of the end of section. Be careful with uint64_t
hw/virtio/vhost-vsock-common.c +0 -1
index e89af9b329..321262f6b3 100644
@@ -12,7 +12,6 @@
 #include "standard-headers/linux/virtio_vsock.h"
 #include "qapi/error.h"
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 #include "qemu/error-report.h"
 #include "hw/qdev-properties.h"
 #include "hw/virtio/vhost.h"
hw/virtio/vhost.c +0 -1
index 23da579ce2..7f3c727777 100644
@@ -23,7 +23,6 @@
 #include "qemu/log.h"
 #include "standard-headers/linux/vhost_types.h"
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 #include "migration/blocker.h"
 #include "migration/qemu-file-types.h"
 #include "sysemu/dma.h"
hw/virtio/virtio-crypto.c +0 -1
index c729a1f79e..a6d7e1e8ec 100644
@@ -21,7 +21,6 @@
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-crypto.h"
 #include "hw/qdev-properties.h"
-#include "hw/virtio/virtio-access.h"
 #include "standard-headers/linux/virtio_ids.h"
 #include "sysemu/cryptodev-vhost.h"
 
hw/virtio/virtio-iommu.c +0 -1
index 85905a9e3d..1bbad23f4a 100644
@@ -32,7 +32,6 @@
 #include "standard-headers/linux/virtio_ids.h"
 
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 #include "hw/virtio/virtio-iommu.h"
 #include "hw/pci/pci_bus.h"
 #include "hw/pci/pci.h"
hw/virtio/virtio-mem.c +0 -1
index 74e63bd47a..12ea58d5ad 100644
@@ -20,7 +20,6 @@
 #include "sysemu/reset.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-bus.h"
-#include "hw/virtio/virtio-access.h"
 #include "hw/virtio/virtio-mem.h"
 #include "qapi/error.h"
 #include "qapi/visitor.h"
Signature · 1 line
2.38.1
Reviewed-by on v2 9/10
#22 lore raw

Re: [PATCH v2 09/10] hw/virtio: Remove unnecessary 'virtio-access.h' header

Quoted 10 lines · Philippe Mathieu-Daudé

None of these files use the VirtIO Load/Store API declared by "hw/virtio/virtio-access.h". This header probably crept in via copy/pasting, remove it.

Note, "virtio-access.h" is target-specific, so any file including it also become tainted as target-specific.

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

PATCH v2 10/10 hw/virtio: Build various target-agnostic objects just once

In reply to Philippe Mathieu-Daudé

The previous commit remove the unnecessary "virtio-access.h" header. These files no longer have target-specific dependency. Move them to the generic 'softmmu_ss' source set.

---
 hw/block/dataplane/meson.build |  2 +-
 hw/scsi/meson.build            | 10 +++++++---
 hw/virtio/meson.build          | 11 ++++++-----
 3 files changed, 14 insertions(+), 9 deletions(-)
hw/block/dataplane/meson.build +1 -1
index 78d7ac1a11..dec73e7486 100644
@@ -1,2 +1,2 @@
-specific_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
+softmmu_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-blk.c'))
 specific_ss.add(when: 'CONFIG_XEN_BUS', if_true: files('xen-block.c'))
hw/scsi/meson.build +7 -3
index bde72df19c..4c8fa50783 100644
@@ -1,5 +1,6 @@
 scsi_ss = ss.source_set()
 specific_scsi_ss = ss.source_set()
+virtio_scsi_ss = ss.source_set()
 specific_virtio_scsi_ss = ss.source_set()
 
 scsi_ss.add(files(
@@ -15,12 +16,15 @@ scsi_ss.add(when: 'CONFIG_MEGASAS_SCSI_PCI', if_true: files('megasas.c'))
 scsi_ss.add(when: 'CONFIG_MPTSAS_SCSI_PCI', if_true: files('mptsas.c', 'mptconfig.c', 'mptendian.c'))
 scsi_ss.add(when: 'CONFIG_VMW_PVSCSI_SCSI_PCI', if_true: files('vmw_pvscsi.c'))
 
-specific_virtio_scsi_ss.add(files('virtio-scsi.c', 'virtio-scsi-dataplane.c'))
+virtio_scsi_ss.add(files('virtio-scsi-dataplane.c'))
+virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi.c'))
+virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi.c'))
+
+specific_virtio_scsi_ss.add(files('virtio-scsi.c'))
 specific_virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI_COMMON', if_true: files('vhost-scsi-common.c'))
-specific_virtio_scsi_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi.c'))
-specific_virtio_scsi_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi.c'))
 
 specific_scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: specific_virtio_scsi_ss)
+scsi_ss.add_all(when: 'CONFIG_VIRTIO_SCSI', if_true: virtio_scsi_ss)
 
 specific_scsi_ss.add(when: 'CONFIG_SPAPR_VSCSI', if_true: files('spapr_vscsi.c'))
 
hw/virtio/meson.build +6 -5
index 54c90c24fb..16e64e1cf1 100644
@@ -2,13 +2,18 @@ softmmu_virtio_ss = ss.source_set()
 softmmu_virtio_ss.add(files('virtio-bus.c'))
 softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('virtio-pci.c'))
 softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_MMIO', if_true: files('virtio-mmio.c'))
+softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
+softmmu_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK_COMMON', if_true: files('vhost-vsock-common.c'))
+softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
+softmmu_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c'))
 
 specific_virtio_ss = ss.source_set()
 specific_virtio_ss.add(files('virtio.c'))
 specific_virtio_ss.add(files('virtio-config-io.c', 'virtio-qmp.c'))
 
 if have_vhost
-  specific_virtio_ss.add(files('vhost.c', 'vhost-backend.c', 'vhost-iova-tree.c'))
+  softmmu_virtio_ss.add(files('vhost.c'))
+  specific_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.c'))
   if have_vhost_user
     specific_virtio_ss.add(files('vhost-user.c'))
   endif
@@ -20,20 +25,16 @@ else
 endif
 
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-balloon.c'))
-specific_virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-crypto.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_PMEM', if_true: files('virtio-pmem.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK_COMMON', if_true: files('vhost-vsock-common.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c'))
-specific_virtio_ss.add(when: 'CONFIG_VIRTIO_IOMMU', if_true: files('virtio-iommu.c'))
 specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c'))
 specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c'))
 specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c'))
-specific_virtio_ss.add(when: 'CONFIG_VHOST_VDPA_DEV', if_true: files('vdpa-dev.c'))
 
 virtio_pci_ss = ss.source_set()
 virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))
Signature · 1 line
2.38.1