[Qemu-devel] [PATCH V3] chardev: fix parallel device can't be reconnect

Peng Hao posted 1 patch 6 years, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1499874119-67558-1-git-send-email-peng.hao2@zte.com.cn
Test FreeBSD passed
Test checkpatch passed
Test docker passed
Test s390x passed
hw/char/parallel.c | 6 ++++++
1 file changed, 6 insertions(+)
[Qemu-devel] [PATCH V3] chardev: fix parallel device can't be reconnect
Posted by Peng Hao 6 years, 9 months ago
Parallel device don't register be->chr_can_read function, but remote
disconnect event is handled in chr_read.So connected parallel device
can not detect remote disconnect event. The chardevs with chr_can_read=NULL
has the same problem.

Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Reviewed-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
---
 hw/char/parallel.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 75a1a2f..b33bbb8 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -503,6 +503,10 @@ static const VMStateDescription vmstate_parallel_isa = {
     }
 };
 
+static int parallel_can_receive(void *opaque)
+{
+     return 1;
+}
 
 static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
 {
@@ -535,6 +539,8 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
     isa_init_irq(isadev, &s->irq, isa->isairq);
     qemu_register_reset(parallel_reset, s);
 
+    qemu_chr_fe_set_handlers(&s->chr, parallel_can_receive, NULL,
+                             NULL, s, NULL, true);
     if (qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) {
         s->hw_driver = 1;
         s->status = dummy;
-- 
1.8.3.1



Re: [Qemu-devel] [PATCH V3] chardev: fix parallel device can't be reconnect
Posted by Paolo Bonzini 6 years, 9 months ago
On 12/07/2017 17:41, Peng Hao wrote:
> Parallel device don't register be->chr_can_read function, but remote
> disconnect event is handled in chr_read.So connected parallel device
> can not detect remote disconnect event. The chardevs with chr_can_read=NULL
> has the same problem.
> 
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> Reviewed-by: Wang Yechao <wang.yechao255@zte.com.cn>
> Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
> ---
>  hw/char/parallel.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/hw/char/parallel.c b/hw/char/parallel.c
> index 75a1a2f..b33bbb8 100644
> --- a/hw/char/parallel.c
> +++ b/hw/char/parallel.c
> @@ -503,6 +503,10 @@ static const VMStateDescription vmstate_parallel_isa = {
>      }
>  };
>  
> +static int parallel_can_receive(void *opaque)
> +{
> +     return 1;
> +}
>  
>  static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
>  {
> @@ -535,6 +539,8 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
>      isa_init_irq(isadev, &s->irq, isa->isairq);
>      qemu_register_reset(parallel_reset, s);
>  
> +    qemu_chr_fe_set_handlers(&s->chr, parallel_can_receive, NULL,
> +                             NULL, s, NULL, true);
>      if (qemu_chr_fe_ioctl(&s->chr, CHR_IOCTL_PP_READ_STATUS, &dummy) == 0) {
>          s->hw_driver = 1;
>          s->status = dummy;
> 


Sounds good for a simple fix.

Thanks,

Paolo