[PATCH for-5.2] s390x: fix build for --without-default-devices

Cornelia Huck posted 1 patch 3 years, 6 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20201103123237.718242-1-cohuck@redhat.com
Maintainers: Cornelia Huck <cohuck@redhat.com>, Thomas Huth <thuth@redhat.com>
hw/s390x/meson.build             | 2 +-
include/hw/s390x/s390-pci-vfio.h | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
[PATCH for-5.2] s390x: fix build for --without-default-devices
Posted by Cornelia Huck 3 years, 6 months ago
s390-pci-vfio.c calls into the vfio code, so we need it to be
built conditionally on vfio (which implies CONFIG_LINUX).

Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Fixes: cd7498d07fbb ("s390x/pci: Add routine to get the vfio dma available count")
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
---
 hw/s390x/meson.build             | 2 +-
 include/hw/s390x/s390-pci-vfio.h | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
index f4663a835514..2a7818d94b94 100644
--- a/hw/s390x/meson.build
+++ b/hw/s390x/meson.build
@@ -27,7 +27,7 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
 ))
 s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c'))
 s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c'))
-s390x_ss.add(when: 'CONFIG_LINUX', if_true: files('s390-pci-vfio.c'))
+s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c'))
 
 virtio_ss = ss.source_set()
 virtio_ss.add(files('virtio-ccw.c'))
diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-vfio.h
index c7984905b3b7..ff708aef500f 100644
--- a/include/hw/s390x/s390-pci-vfio.h
+++ b/include/hw/s390x/s390-pci-vfio.h
@@ -13,8 +13,9 @@
 #define HW_S390_PCI_VFIO_H
 
 #include "hw/s390x/s390-pci-bus.h"
+#include CONFIG_DEVICES
 
-#ifdef CONFIG_LINUX
+#ifdef CONFIG_VFIO
 bool s390_pci_update_dma_avail(int fd, unsigned int *avail);
 S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
                                           S390PCIBusDevice *pbdev);
-- 
2.26.2


Re: [PATCH for-5.2] s390x: fix build for --without-default-devices
Posted by Matthew Rosato 3 years, 6 months ago
On 11/3/20 7:32 AM, Cornelia Huck wrote:
> s390-pci-vfio.c calls into the vfio code, so we need it to be
> built conditionally on vfio (which implies CONFIG_LINUX).
> 
> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Fixes: cd7498d07fbb ("s390x/pci: Add routine to get the vfio dma available count")
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>

Good catch.  Did a test compile and this clearly works, but I'm 
wondering if it should be checking against CONFIG_VFIO_PCI?

> ---
>   hw/s390x/meson.build             | 2 +-
>   include/hw/s390x/s390-pci-vfio.h | 3 ++-
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
> index f4663a835514..2a7818d94b94 100644
> --- a/hw/s390x/meson.build
> +++ b/hw/s390x/meson.build
> @@ -27,7 +27,7 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
>   ))
>   s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c'))
>   s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c'))
> -s390x_ss.add(when: 'CONFIG_LINUX', if_true: files('s390-pci-vfio.c'))
> +s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c'))
>   
>   virtio_ss = ss.source_set()
>   virtio_ss.add(files('virtio-ccw.c'))
> diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-vfio.h
> index c7984905b3b7..ff708aef500f 100644
> --- a/include/hw/s390x/s390-pci-vfio.h
> +++ b/include/hw/s390x/s390-pci-vfio.h
> @@ -13,8 +13,9 @@
>   #define HW_S390_PCI_VFIO_H
>   
>   #include "hw/s390x/s390-pci-bus.h"
> +#include CONFIG_DEVICES
>   
> -#ifdef CONFIG_LINUX
> +#ifdef CONFIG_VFIO
>   bool s390_pci_update_dma_avail(int fd, unsigned int *avail);
>   S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
>                                             S390PCIBusDevice *pbdev);
> 


Re: [PATCH for-5.2] s390x: fix build for --without-default-devices
Posted by Matthew Rosato 3 years, 6 months ago
On 11/3/20 8:21 AM, Matthew Rosato wrote:
> On 11/3/20 7:32 AM, Cornelia Huck wrote:
>> s390-pci-vfio.c calls into the vfio code, so we need it to be
>> built conditionally on vfio (which implies CONFIG_LINUX).
>>
>> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Fixes: cd7498d07fbb ("s390x/pci: Add routine to get the vfio dma 
>> available count")
>> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> 
> Good catch.  Did a test compile and this clearly works, but I'm 
> wondering if it should be checking against CONFIG_VFIO_PCI?
> 

I guess looking at it again, there's nothing in s390-vfio-pci today that 
strictly needs it, just the VIOPCIDevice struct defined in hw/vfio/pci.h 
and that should still be available even if CONFIG_VFIO_PCI=n (not like 
you'll be able to create these devices without CONFIG_VFIO or 
CONFIG_VFIO_PCI anyway).

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>

>> ---
>>   hw/s390x/meson.build             | 2 +-
>>   include/hw/s390x/s390-pci-vfio.h | 3 ++-
>>   2 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
>> index f4663a835514..2a7818d94b94 100644
>> --- a/hw/s390x/meson.build
>> +++ b/hw/s390x/meson.build
>> @@ -27,7 +27,7 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
>>   ))
>>   s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: 
>> files('s390-virtio-ccw.c'))
>>   s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c'))
>> -s390x_ss.add(when: 'CONFIG_LINUX', if_true: files('s390-pci-vfio.c'))
>> +s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c'))
>>   virtio_ss = ss.source_set()
>>   virtio_ss.add(files('virtio-ccw.c'))
>> diff --git a/include/hw/s390x/s390-pci-vfio.h 
>> b/include/hw/s390x/s390-pci-vfio.h
>> index c7984905b3b7..ff708aef500f 100644
>> --- a/include/hw/s390x/s390-pci-vfio.h
>> +++ b/include/hw/s390x/s390-pci-vfio.h
>> @@ -13,8 +13,9 @@
>>   #define HW_S390_PCI_VFIO_H
>>   #include "hw/s390x/s390-pci-bus.h"
>> +#include CONFIG_DEVICES
>> -#ifdef CONFIG_LINUX
>> +#ifdef CONFIG_VFIO
>>   bool s390_pci_update_dma_avail(int fd, unsigned int *avail);
>>   S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
>>                                             S390PCIBusDevice *pbdev);
>>
> 


Re: [PATCH for-5.2] s390x: fix build for --without-default-devices
Posted by Philippe Mathieu-Daudé 3 years, 6 months ago
On 11/3/20 1:32 PM, Cornelia Huck wrote:
> s390-pci-vfio.c calls into the vfio code, so we need it to be
> built conditionally on vfio (which implies CONFIG_LINUX).
> 
> Reported-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Fixes: cd7498d07fbb ("s390x/pci: Add routine to get the vfio dma available count")
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> ---
>  hw/s390x/meson.build             | 2 +-
>  include/hw/s390x/s390-pci-vfio.h | 3 ++-
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/meson.build b/hw/s390x/meson.build
> index f4663a835514..2a7818d94b94 100644
> --- a/hw/s390x/meson.build
> +++ b/hw/s390x/meson.build
> @@ -27,7 +27,7 @@ s390x_ss.add(when: 'CONFIG_KVM', if_true: files(
>  ))
>  s390x_ss.add(when: 'CONFIG_S390_CCW_VIRTIO', if_true: files('s390-virtio-ccw.c'))
>  s390x_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('3270-ccw.c'))
> -s390x_ss.add(when: 'CONFIG_LINUX', if_true: files('s390-pci-vfio.c'))
> +s390x_ss.add(when: 'CONFIG_VFIO', if_true: files('s390-pci-vfio.c'))
>  
>  virtio_ss = ss.source_set()
>  virtio_ss.add(files('virtio-ccw.c'))
> diff --git a/include/hw/s390x/s390-pci-vfio.h b/include/hw/s390x/s390-pci-vfio.h
> index c7984905b3b7..ff708aef500f 100644
> --- a/include/hw/s390x/s390-pci-vfio.h
> +++ b/include/hw/s390x/s390-pci-vfio.h
> @@ -13,8 +13,9 @@
>  #define HW_S390_PCI_VFIO_H
>  
>  #include "hw/s390x/s390-pci-bus.h"
> +#include CONFIG_DEVICES

This odd include should come with a comment IMHO.

This fixes the issue, thanks.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>  
> -#ifdef CONFIG_LINUX
> +#ifdef CONFIG_VFIO
>  bool s390_pci_update_dma_avail(int fd, unsigned int *avail);
>  S390PCIDMACount *s390_pci_start_dma_count(S390pciState *s,
>                                            S390PCIBusDevice *pbdev);
>