qemu-s390x
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/1] hw/s390x: modularize virtio-gpu-ccw


From: Gerd Hoffmann
Subject: Re: [PATCH 1/1] hw/s390x: modularize virtio-gpu-ccw
Date: Fri, 19 Feb 2021 14:58:31 +0100

  Hi,

> > Maybe we need a type_register_mayfail() variant which doesn't abort in
> > case the parent isn't found (see also commit
> > 501093207eb1ed4845e0a65ee1ce7db7b9676e0b).
> 
> I was also thinking along the same lines last night, and came up with
> this workaround:
> 
> diff --git a/hw/s390x/virtio-ccw-gpu.c b/hw/s390x/virtio-ccw-gpu.c
> index c301e2586b..bbe591cd62 100644
> --- a/hw/s390x/virtio-ccw-gpu.c
> +++ b/hw/s390x/virtio-ccw-gpu.c
> @@ -62,7 +62,16 @@ static const TypeInfo virtio_ccw_gpu = {
>  
>  static void virtio_ccw_gpu_register(void)
>  {
> +#ifdef CONFIG_MODULES
> +    /*
> +     * Ugly hack: Avoid targets that don't have it aborting when this module
> +     * is loaded.
> +    if (object_class_by_name(TYPE_VIRTIO_CCW_DEVICE)) {
> +        type_register_static(&virtio_ccw_gpu);
> +    }
> +#else
>      type_register_static(&virtio_ccw_gpu);
> +#endif
>  }
>  
>  type_init(virtio_ccw_gpu_register)
> 
> but then I decided it is too ugly to post. Something like
> type_register_mayfail() would be certainly nicer, although I would still
> prefer the failing type register if the device ain't built as a module.

type_register_mayfail() could have different behavior depending on
CONFIG_MODULES (and a comment block explaining why).

take care,
  Gerd




reply via email to

[Prev in Thread] Current Thread [Next in Thread]