From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 28BB7C77B72 for ; Fri, 14 Apr 2023 19:02:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pnOg4-00061r-6Y; Fri, 14 Apr 2023 15:01:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnOfz-0005wP-9Y for qemu-devel@nongnu.org; Fri, 14 Apr 2023 15:01:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pnOfw-0000TD-Mr for qemu-devel@nongnu.org; Fri, 14 Apr 2023 15:01:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681498894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TCB+NNUOrogMvR0c+OI54bouDZIlhzSw+zhdUNb/4eE=; b=Pr04VReSwNs7uq52kMqNieP7OtUTar5lR9LXvSfwt/vyemiIdy9YBsAjJkYlrvGvrrxbwi Qq5cg3xeCs1uRnedlbWI5GiGU2iWj8rQI9MlqPxcLeS1mwtsuJOJ0oIKKyGdt/Zv/YCqqP sjA46UlSLAlQnG72Lah/tnZedAD540o= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581--7KN5FRHPbWjU87Q1KB6pA-1; Fri, 14 Apr 2023 15:01:32 -0400 X-MC-Unique: -7KN5FRHPbWjU87Q1KB6pA-1 Received: by mail-ed1-f72.google.com with SMTP id q19-20020a50c353000000b0050683052191so1528315edb.19 for ; Fri, 14 Apr 2023 12:01:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681498891; x=1684090891; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TCB+NNUOrogMvR0c+OI54bouDZIlhzSw+zhdUNb/4eE=; b=H2ogjT/Xn3udXcLPVc96OxkSBp0gMuCaVswaDK9YN7PBNXsZa7azJ5h6EXHAqYaJLz LVjkOoFuPwOs3rlFkSTYyvcP7dgGVhzg8OYtzUpcKUUXVo69JfYlrGWlaV9mgRd6A4wD 2dhHPhd/6r14quCkwbRP/NrgzZLTc3upUAOo8Ph8jXtVoyR8fvT3/SY1uY1ij5dWlEmn GgGpbNGXPy1W6p/aaisJ29HvjroDW8w2RNis+dkh5hDV3njVOqrDhVMLH90XMMq5NxwO 2GOiCBNLxDUVZuHUbVi47mD1VM6tn1UciLYFfKMc7dkGf7roPE3UrZzLQB/J39h+gr6g /wWg== X-Gm-Message-State: AAQBX9dneYl2qau93hg1SwWW3VpI/jqb3ln5LLTS8lMqprpKGcmyHlm8 yaSE6EtEurwupbOqPrj7qdmTBsIKhyeZB3bsrK5zyfWm1IgOydq1HYJPrN0wDUHrRfIctK7eL0P rPYRMcT1/d4t10XTkyos6VKlZUkz1syw= X-Received: by 2002:a17:906:1e43:b0:94a:5615:fbbd with SMTP id i3-20020a1709061e4300b0094a5615fbbdmr50513ejj.15.1681498891043; Fri, 14 Apr 2023 12:01:31 -0700 (PDT) X-Google-Smtp-Source: AKy350YuDwSHcuFDiWmr+BqYn+GxrKx6zxq8ZwpPPgyU7nILZgOTXeJW7/QH9f90RmE8ZC/WW0wEwLcI77lGlR+jK9Y= X-Received: by 2002:a17:906:1e43:b0:94a:5615:fbbd with SMTP id i3-20020a1709061e4300b0094a5615fbbdmr50503ejj.15.1681498890747; Fri, 14 Apr 2023 12:01:30 -0700 (PDT) MIME-Version: 1.0 References: <20230413150724.404304-1-peter.maydell@linaro.org> <20230413150724.404304-2-peter.maydell@linaro.org> In-Reply-To: <20230413150724.404304-2-peter.maydell@linaro.org> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 14 Apr 2023 23:01:19 +0400 Message-ID: Subject: Re: [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" To: Peter Maydell Cc: qemu-devel@nongnu.org, Paolo Bonzini , Thomas Huth , Laurent Vivier Content-Type: multipart/alternative; boundary="00000000000012d27605f95078e3" Received-SPF: pass client-ip=170.10.129.124; envelope-from=mlureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org --00000000000012d27605f95078e3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 13, 2023 at 7:07=E2=80=AFPM 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=3D/dev/null,id=3Dmyid > -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=C3=A9 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, cons= t > char *qtest_log, Error ** > } > > qtest =3D 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); > } > -- > 2.34.1 > > --00000000000012d27605f95078e3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Apr 13, 2023 at 7:07=E2=80=AF= PM Peter Maydell <peter.mayd= ell@linaro.org> wrote:
If the -qtest command line argument is passed a string that s= ays
"use this chardev for I/O", then it will assert:

$ ./build/clang/qemu-system-i386 -chardev file,path=3D/dev/null,id=3Dmyid -= 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&qu= ot;.
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 hardcodin= g
it to "qtest".

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
<= br>
Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com>

=C2=A0=
---
=C2=A0softmmu/qtest.c | 2 +-
=C2=A01 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 **
=C2=A0 =C2=A0 =C2=A0}

=C2=A0 =C2=A0 =C2=A0qtest =3D object_new(TYPE_QTEST);
-=C2=A0 =C2=A0 object_property_set_str(qtest, "chardev", "qt= est", &error_abort);
+=C2=A0 =C2=A0 object_property_set_str(qtest, "chardev", chr->= label, &error_abort);
=C2=A0 =C2=A0 =C2=A0if (qtest_log) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0object_property_set_str(qtest, "log&= quot;, qtest_log, &error_abort);
=C2=A0 =C2=A0 =C2=A0}
--
2.34.1

--00000000000012d27605f95078e3--