[Qemu-devel] [PATCH v2] hw/arm/digic: Mark device with user_creatable = false

Thomas Huth posted 1 patch 6 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1503412231-13961-1-git-send-email-thuth@redhat.com
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
hw/arm/digic.c | 2 ++
1 file changed, 2 insertions(+)
[Qemu-devel] [PATCH v2] hw/arm/digic: Mark device with user_creatable = false
Posted by Thomas Huth 6 years, 8 months ago
QEMU currently shows some unexpected behavior when the user trys to
do a "device_add digic" on an unrelated ARM machine like integratorcp
in "-nographic" mode (the device_add command does not immediately
return to the monitor prompt), and trying to "device_del" the device
later results in a "qemu/qdev-monitor.c:872:qdev_unplug: assertion
failed: (hotplug_ctrl)" error condition.
Looking at the realize function of the device, it uses serial_hds
directly and this means that the device can not be added a second
time, so let's simply mark it with "user_creatable = false" now.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 v2: Updated the comment and the patch description

 hw/arm/digic.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/arm/digic.c b/hw/arm/digic.c
index 94f3263..6184020 100644
--- a/hw/arm/digic.c
+++ b/hw/arm/digic.c
@@ -101,6 +101,8 @@ static void digic_class_init(ObjectClass *oc, void *data)
     DeviceClass *dc = DEVICE_CLASS(oc);
 
     dc->realize = digic_realize;
+    /* Reason: Uses serial_hds in the realize function --> not usable twice */
+    dc->user_creatable = false;
 }
 
 static const TypeInfo digic_type_info = {
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH v2] hw/arm/digic: Mark device with user_creatable = false
Posted by Peter Maydell 6 years, 8 months ago
On 22 August 2017 at 15:30, Thomas Huth <thuth@redhat.com> wrote:
> QEMU currently shows some unexpected behavior when the user trys to
> do a "device_add digic" on an unrelated ARM machine like integratorcp
> in "-nographic" mode (the device_add command does not immediately
> return to the monitor prompt), and trying to "device_del" the device
> later results in a "qemu/qdev-monitor.c:872:qdev_unplug: assertion
> failed: (hotplug_ctrl)" error condition.
> Looking at the realize function of the device, it uses serial_hds
> directly and this means that the device can not be added a second
> time, so let's simply mark it with "user_creatable = false" now.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  v2: Updated the comment and the patch description
>
>  hw/arm/digic.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/hw/arm/digic.c b/hw/arm/digic.c
> index 94f3263..6184020 100644
> --- a/hw/arm/digic.c
> +++ b/hw/arm/digic.c
> @@ -101,6 +101,8 @@ static void digic_class_init(ObjectClass *oc, void *data)
>      DeviceClass *dc = DEVICE_CLASS(oc);
>
>      dc->realize = digic_realize;
> +    /* Reason: Uses serial_hds in the realize function --> not usable twice */
> +    dc->user_creatable = false;
>  }
>
>  static const TypeInfo digic_type_info = {

Applied to target-arm.next for 2.11, thanks.

-- PMM