[PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract

Philippe Mathieu-Daudé posted 5 patches 5 years, 3 months ago
There is a newer version of this series
[PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Posted by Philippe Mathieu-Daudé 5 years, 3 months ago
The TYPE_XHCI model is abstract and can not be used as it.
It is meant to be overloaded by children classes. Restore
it as abstract type.

Fixes: 8ddab8dd3d8 ("usb/hcd-xhci: Split pci wrapper for xhci base model")
Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/usb/hcd-xhci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 79ce5c4be6c..57b692ad849 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -3595,6 +3595,7 @@ static const TypeInfo xhci_info = {
     .parent        = TYPE_DEVICE,
     .instance_size = sizeof(XHCIState),
     .class_init    = xhci_class_init,
+    .abstract      = true,
 };
 
 static void xhci_register_types(void)
-- 
2.26.2

RE: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Posted by Sai Pavan Boddu 5 years, 3 months ago
Looks good.

Reviewed-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

Thanks,
Sai Pavan
> -----Original Message-----
> From: Philippe Mathieu-Daudé <philmd@redhat.com>
> Sent: Saturday, November 7, 2020 4:43 PM
> To: qemu-devel@nongnu.org
> Cc: Gerd Hoffmann <kraxel@redhat.com>; Sai Pavan Boddu
> <saipava@xilinx.com>; Philippe Mathieu-Daudé <philmd@redhat.com>;
> Miroslav Rezanina <mrezanin@redhat.com>
> Subject: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
> 
> The TYPE_XHCI model is abstract and can not be used as it.
> It is meant to be overloaded by children classes. Restore it as abstract type.
> 
> Fixes: 8ddab8dd3d8 ("usb/hcd-xhci: Split pci wrapper for xhci base model")
> Reported-by: Miroslav Rezanina <mrezanin@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/usb/hcd-xhci.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index
> 79ce5c4be6c..57b692ad849 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -3595,6 +3595,7 @@ static const TypeInfo xhci_info = {
>      .parent        = TYPE_DEVICE,
>      .instance_size = sizeof(XHCIState),
>      .class_init    = xhci_class_init,
> +    .abstract      = true,
>  };
> 
>  static void xhci_register_types(void)
> --
> 2.26.2

Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Posted by Gerd Hoffmann 5 years, 3 months ago
On Sat, Nov 07, 2020 at 12:13:03PM +0100, Philippe Mathieu-Daudé wrote:
> The TYPE_XHCI model is abstract and can not be used as it.
> It is meant to be overloaded by children classes. Restore
> it as abstract type.

Breaks "make check".

MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_IMG=./qemu-img G_TEST_DBUS_DAEMON=/home/kraxel/projects/qemu/tests/dbus-vmstate-daemon.sh QTEST_QEMU_BINARY=./qemu-system-x86_64 tests/qtest/usb-hcd-xhci-test --tap -k
**
ERROR:../../qom/object.c:506:object_initialize_with_type: assertion failed: (type->abstract == false)

take care,
  Gerd


Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Posted by Philippe Mathieu-Daudé 5 years, 3 months ago
Cc'ing Thomas who wrote the test.

On 11/9/20 10:51 AM, Gerd Hoffmann wrote:
> On Sat, Nov 07, 2020 at 12:13:03PM +0100, Philippe Mathieu-Daudé wrote:
>> The TYPE_XHCI model is abstract and can not be used as it.
>> It is meant to be overloaded by children classes. Restore
>> it as abstract type.
> 
> Breaks "make check".
> 
> MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))} QTEST_QEMU_IMG=./qemu-img G_TEST_DBUS_DAEMON=/home/kraxel/projects/qemu/tests/dbus-vmstate-daemon.sh QTEST_QEMU_BINARY=./qemu-system-x86_64 tests/qtest/usb-hcd-xhci-test --tap -k
> **
> ERROR:../../qom/object.c:506:object_initialize_with_type: assertion failed: (type->abstract == false)

Well I suppose the test was always incorrect but working,
and 8ddab8dd3d8 revealed the problem. Testing the correct
device should fix the test:

-- >8 --
diff --git a/tests/qtest/usb-hcd-xhci-test.c
b/tests/qtest/usb-hcd-xhci-test.c
index 10ef9d2a91a..09f5ad71158 100644
--- a/tests/qtest/usb-hcd-xhci-test.c
+++ b/tests/qtest/usb-hcd-xhci-test.c
@@ -18,7 +18,7 @@ static void test_xhci_init(void)

 static void test_xhci_hotplug(void)
 {
-    usb_test_hotplug(global_qtest, "xhci", "1", NULL);
+    usb_test_hotplug(global_qtest, "nec-usb-xhci", "1", NULL);
 }

 static void test_usb_uas_hotplug(void)
---

I'll respin including the fix.

> 
> take care,
>   Gerd
> 


Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Posted by Gerd Hoffmann 5 years, 3 months ago
>  static void test_xhci_hotplug(void)
>  {
> -    usb_test_hotplug(global_qtest, "xhci", "1", NULL);
> +    usb_test_hotplug(global_qtest, "nec-usb-xhci", "1", NULL);
>  }

Better use qemu-xhci.
I'm wondering how that worked before ...

take care,
  Gerd


Re: [PATCH-for-5.2 1/5] hw/usb/hcd-xhci: Make xhci base model abstract
Posted by Philippe Mathieu-Daudé 5 years, 3 months ago
On 11/9/20 12:30 PM, Gerd Hoffmann wrote:
>>  static void test_xhci_hotplug(void)
>>  {
>> -    usb_test_hotplug(global_qtest, "xhci", "1", NULL);
>> +    usb_test_hotplug(global_qtest, "nec-usb-xhci", "1", NULL);
>>  }
> 
> Better use qemu-xhci.
> I'm wondering how that worked before ...

Per commit b3937683147 ("tests: usb: Generic usb device hotplug")
this is the name of the bus, so "xhci" is correct, my patch isn't.

> 
> take care,
>   Gerd
>