qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] chardev/char: fix qemu_chr_is_busy() check
@ 2024-10-10  9:26 Roman Penyaev
  2024-10-10 10:19 ` Marc-André Lureau
  0 siblings, 1 reply; 4+ messages in thread
From: Roman Penyaev @ 2024-10-10  9:26 UTC (permalink / raw)
  Cc: Roman Penyaev, Marc-André Lureau, qemu-devel

`mux_cnt` struct member never goes negative or decrements,
so mux chardev can be !busy only when there are no
frontends attached. This patch fixes the always-true
check.

Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend")
Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
---
 chardev/char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chardev/char.c b/chardev/char.c
index c0cc52824b48..f54dc3a86286 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -333,7 +333,7 @@ static bool qemu_chr_is_busy(Chardev *s)
 {
     if (CHARDEV_IS_MUX(s)) {
         MuxChardev *d = MUX_CHARDEV(s);
-        return d->mux_cnt >= 0;
+        return d->mux_cnt > 0;
     } else {
         return s->be != NULL;
     }
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] chardev/char: fix qemu_chr_is_busy() check
  2024-10-10  9:26 [PATCH 1/1] chardev/char: fix qemu_chr_is_busy() check Roman Penyaev
@ 2024-10-10 10:19 ` Marc-André Lureau
  2024-10-10 10:50   ` Roman Penyaev
  2024-10-14 11:44   ` Roman Penyaev
  0 siblings, 2 replies; 4+ messages in thread
From: Marc-André Lureau @ 2024-10-10 10:19 UTC (permalink / raw)
  To: Roman Penyaev; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1279 bytes --]

Hi Roman

On Thu, Oct 10, 2024 at 1:28 PM Roman Penyaev <r.peniaev@gmail.com> wrote:

> `mux_cnt` struct member never goes negative or decrements,
> so mux chardev can be !busy only when there are no
> frontends attached. This patch fixes the always-true
> check.
>
> Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend")
> Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
> Cc: qemu-devel@nongnu.org


Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

That would be worth some new tests for chardev removal. It seems to be
lacking. And mux probably need extra fixing. I can take a look if you don't.

thanks


> ---
>  chardev/char.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/chardev/char.c b/chardev/char.c
> index c0cc52824b48..f54dc3a86286 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -333,7 +333,7 @@ static bool qemu_chr_is_busy(Chardev *s)
>  {
>      if (CHARDEV_IS_MUX(s)) {
>          MuxChardev *d = MUX_CHARDEV(s);
> -        return d->mux_cnt >= 0;
> +        return d->mux_cnt > 0;
>      } else {
>          return s->be != NULL;
>      }
> --
> 2.34.1
>
>
>

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 2281 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] chardev/char: fix qemu_chr_is_busy() check
  2024-10-10 10:19 ` Marc-André Lureau
@ 2024-10-10 10:50   ` Roman Penyaev
  2024-10-14 11:44   ` Roman Penyaev
  1 sibling, 0 replies; 4+ messages in thread
From: Roman Penyaev @ 2024-10-10 10:50 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 989 bytes --]

On Thu, Oct 10, 2024, 12:20 Marc-André Lureau <marcandre.lureau@gmail.com>
wrote:

> Hi Roman
>
> On Thu, Oct 10, 2024 at 1:28 PM Roman Penyaev <r.peniaev@gmail.com> wrote:
>
>> `mux_cnt` struct member never goes negative or decrements,
>> so mux chardev can be !busy only when there are no
>> frontends attached. This patch fixes the always-true
>> check.
>>
>> Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend")
>> Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
>> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> Cc: qemu-devel@nongnu.org
>
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> That would be worth some new tests for chardev removal. It seems to be
> lacking. And mux probably need extra fixing. I can take a look if you don't.
>

I assume no one removes mux device, so no one observes the error. Please,
go ahead, I'm not sure I do fully understand what exactly should be fixed.

--
Roman

[-- Attachment #2: Type: text/html, Size: 2099 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] chardev/char: fix qemu_chr_is_busy() check
  2024-10-10 10:19 ` Marc-André Lureau
  2024-10-10 10:50   ` Roman Penyaev
@ 2024-10-14 11:44   ` Roman Penyaev
  1 sibling, 0 replies; 4+ messages in thread
From: Roman Penyaev @ 2024-10-14 11:44 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel

Hi Marc-André,

On Thu, Oct 10, 2024 at 12:20 PM Marc-André Lureau
<marcandre.lureau@gmail.com> wrote:
>
> Hi Roman
>
> On Thu, Oct 10, 2024 at 1:28 PM Roman Penyaev <r.peniaev@gmail.com> wrote:
>>
>> `mux_cnt` struct member never goes negative or decrements,
>> so mux chardev can be !busy only when there are no
>> frontends attached. This patch fixes the always-true
>> check.
>>
>> Fixes: a4afa548fc6d ("char: move front end handlers in CharBackend")
>> Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
>> Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
>> Cc: qemu-devel@nongnu.org
>
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> That would be worth some new tests for chardev removal. It seems to be lacking. And mux probably need extra fixing. I can take a look if you don't.

I've just sent an attempt to fix the removal of frontends, plus some test cases.
Please take a look.

Thanks.

--
Roman


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-14 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10  9:26 [PATCH 1/1] chardev/char: fix qemu_chr_is_busy() check Roman Penyaev
2024-10-10 10:19 ` Marc-André Lureau
2024-10-10 10:50   ` Roman Penyaev
2024-10-14 11:44   ` Roman Penyaev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).