Re: [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid"

2023-04-14 Thread Marc-André Lureau
On Thu, Apr 13, 2023 at 7:07 PM Peter Maydell 
wrote:

> If the -qtest command line argument is passed a string that says
> "use this chardev for I/O", then it will assert:
>
> $ ./build/clang/qemu-system-i386 -chardev file,path=/dev/null,id=myid
> -qtest chardev:myid
> Unexpected error in qtest_set_chardev() at ../../softmmu/qtest.c:1011:
> qemu-system-i386: Cannot find character device 'qtest'
> Aborted (core dumped)
>
> This is because in qtest_server_init() we assume that when we create
> the chardev with qemu_chr_new() it will always have the name "qtest".
> This is true if qemu_chr_new() had to create a new chardev, but not
> true if one already existed and is being referred to with
> "chardev:myid".
>
> Use the name of the chardev we get back from qemu_chr_new() as the
> string to set the qtest 'chardev' property to, instead of hardcoding
> it to "qtest".
>
> Signed-off-by: Peter Maydell 
>

Reviewed-by: Marc-André Lureau 



> ---
>  softmmu/qtest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/softmmu/qtest.c b/softmmu/qtest.c
> index 34bd2a33a76..26852996b5b 100644
> --- a/softmmu/qtest.c
> +++ b/softmmu/qtest.c
> @@ -867,7 +867,7 @@ void qtest_server_init(const char *qtest_chrdev, const
> char *qtest_log, Error **
>  }
>
>  qtest = object_new(TYPE_QTEST);
> -object_property_set_str(qtest, "chardev", "qtest", _abort);
> +object_property_set_str(qtest, "chardev", chr->label, _abort);
>  if (qtest_log) {
>  object_property_set_str(qtest, "log", qtest_log, _abort);
>  }
> --
> 2.34.1
>
>


Re: [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid"

2023-04-14 Thread Thomas Huth

On 13/04/2023 17.07, Peter Maydell wrote:

If the -qtest command line argument is passed a string that says
"use this chardev for I/O", then it will assert:

$ ./build/clang/qemu-system-i386 -chardev file,path=/dev/null,id=myid -qtest 
chardev:myid
Unexpected error in qtest_set_chardev() at ../../softmmu/qtest.c:1011:
qemu-system-i386: Cannot find character device 'qtest'
Aborted (core dumped)

This is because in qtest_server_init() we assume that when we create
the chardev with qemu_chr_new() it will always have the name "qtest".
This is true if qemu_chr_new() had to create a new chardev, but not
true if one already existed and is being referred to with
"chardev:myid".

Use the name of the chardev we get back from qemu_chr_new() as the
string to set the qtest 'chardev' property to, instead of hardcoding
it to "qtest".

Signed-off-by: Peter Maydell 
---
  softmmu/qtest.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 34bd2a33a76..26852996b5b 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -867,7 +867,7 @@ void qtest_server_init(const char *qtest_chrdev, const char 
*qtest_log, Error **
  }
  
  qtest = object_new(TYPE_QTEST);

-object_property_set_str(qtest, "chardev", "qtest", _abort);
+object_property_set_str(qtest, "chardev", chr->label, _abort);
  if (qtest_log) {
  object_property_set_str(qtest, "log", qtest_log, _abort);
  }


Reviewed-by: Thomas Huth 




[PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid"

2023-04-13 Thread Peter Maydell
If the -qtest command line argument is passed a string that says
"use this chardev for I/O", then it will assert:

$ ./build/clang/qemu-system-i386 -chardev file,path=/dev/null,id=myid -qtest 
chardev:myid
Unexpected error in qtest_set_chardev() at ../../softmmu/qtest.c:1011:
qemu-system-i386: Cannot find character device 'qtest'
Aborted (core dumped)

This is because in qtest_server_init() we assume that when we create
the chardev with qemu_chr_new() it will always have the name "qtest".
This is true if qemu_chr_new() had to create a new chardev, but not
true if one already existed and is being referred to with
"chardev:myid".

Use the name of the chardev we get back from qemu_chr_new() as the
string to set the qtest 'chardev' property to, instead of hardcoding
it to "qtest".

Signed-off-by: Peter Maydell 
---
 softmmu/qtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 34bd2a33a76..26852996b5b 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -867,7 +867,7 @@ void qtest_server_init(const char *qtest_chrdev, const char 
*qtest_log, Error **
 }
 
 qtest = object_new(TYPE_QTEST);
-object_property_set_str(qtest, "chardev", "qtest", _abort);
+object_property_set_str(qtest, "chardev", chr->label, _abort);
 if (qtest_log) {
 object_property_set_str(qtest, "log", qtest_log, _abort);
 }
-- 
2.34.1