Skip to content

Commit

Permalink
qtest: Don't assert on "-qtest chardev:myid"
Browse files Browse the repository at this point in the history
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 <peter.maydell@linaro.org>
Message-Id: <20230413150724.404304-2-peter.maydell@linaro.org>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
  • Loading branch information
pm215 authored and huth committed Apr 20, 2023
1 parent 9a29e02 commit 537a138
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion softmmu/qtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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", &error_abort);
object_property_set_str(qtest, "chardev", chr->label, &error_abort);
if (qtest_log) {
object_property_set_str(qtest, "log", qtest_log, &error_abort);
}
Expand Down

0 comments on commit 537a138

Please sign in to comment.