From patchwork Thu Apr 13 15:07:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 672838 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp934262wrx; Thu, 13 Apr 2023 08:08:57 -0700 (PDT) X-Google-Smtp-Source: AKy350YVzpRkA+v5P7IN3WkuBIa/1rjrsqAD3gyQsQsvAahN9Wa6ptGFu9EHH4IFbjP827eko5bk X-Received: by 2002:ad4:5c8b:0:b0:5e6:8e03:994e with SMTP id o11-20020ad45c8b000000b005e68e03994emr4020560qvh.38.1681398536722; Thu, 13 Apr 2023 08:08:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681398536; cv=none; d=google.com; s=arc-20160816; b=TH8nuZjDLs9uGfjvV7j8FWGYdtYeylM6vZnFRQ6yVckOGzOHiCO3Rrco6Z4kVipJ+a UtjKgaYdpB1MuJfC7Ms1YBiC7BneXo8o9dTJ/MCM6MWOrblX2id7Wk1XNXb2nqtuztdn URl3k5CdMAqzFoghHE+yMiQddSPxbjf7bg/08kBdqM6eOs1zGwpG9jB5j8n4SyBW2cBP taHuITqxqANIneIcM299NJ8zxyz1i1zCaYY3A0y2XlD10AjjD2eorZzQzZ4Z8WhSK0lJ iQs1UDSZCoKqkOViaJyJebS/dUPJvz4B5NoquUtzPwcXEO7+7djGb1wF3Svs4sczzR+D RgiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yo+EgMosNtZ80RQKxt6SkmU9l8pELWDWAv7GI9lbZVg=; b=uQBt+sahPL0KMsKOWWLjaoO+7sk2bCIQ7xA9qcYSGl9YCStO3b09C4AvCJcxB+gabI B/3JtG3XljMzW1AR3eQdRmI47x3pcrKIOEwLLgB0krVMYIkTEwxjra9oK+Ik8ksiZMLD qhviJDK56nkWPsAizL1uaixfGZtunecP7rZYPSAISWctBVgL0uIujBcKd0FBPdEFVwlx L9tVzT2i31MzGolyXxrTHqDnwMzdxfEkY0zSsgMaRSWtW1J+meLYFVs4IXUfn5mN+SHy 0JktT0Rj2UMlRNy28NVywwUiXBwQMCilS1oTBczNS4fnsSyufbMKLvA5X9p+3ysHMpQz Ctwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T8/hm3AQ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jp11-20020ad45f8b000000b005bef4536d6bsi1026801qvb.2.2023.04.13.08.08.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Apr 2023 08:08:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T8/hm3AQ"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmyY2-00082e-1Z; Thu, 13 Apr 2023 11:07:42 -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 1pmyY0-000828-01 for qemu-devel@nongnu.org; Thu, 13 Apr 2023 11:07:40 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmyXr-000546-0R for qemu-devel@nongnu.org; Thu, 13 Apr 2023 11:07:39 -0400 Received: by mail-wr1-x42e.google.com with SMTP id v27so5306949wra.13 for ; Thu, 13 Apr 2023 08:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681398448; x=1683990448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Yo+EgMosNtZ80RQKxt6SkmU9l8pELWDWAv7GI9lbZVg=; b=T8/hm3AQHnWPVgwwTb+nMduEMHZLg8TFO3zciuCSR0x+63Ax35Aa9NjTLJ6q+WACRi kGigKnrUK3I2DjWkDh5OpEPJxioqyFBZWXKIRmrOpzVBTE6z3mZutBJbX8FqZoJRCPRz k4EkR8GU6YqJNEvigRezoNmGmjg5k9l3B17kXlsijsUmBx3m28d199IaSVLP8+yBCUVu QsuUIea37MHUhx+Nv4TdpTZXC8uiBfeCyBe6chV6YYWbBBM8i0Dxv2dAg4HwTJTwZIhP zhI69xb+vadzQHTdRle9s8Lkh7C1PJaVwhPSUR/2O3kKG/bx7UKPpyu+NOXyJYY3t0aZ UhOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681398448; x=1683990448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yo+EgMosNtZ80RQKxt6SkmU9l8pELWDWAv7GI9lbZVg=; b=kqGutOEy9ZfK+xNK6ksjWKwQCLobI+0ibU+Yd+Hsumpc/OGUDXgAPxuXqZxXagCHgx 0ZUuPrdacTyyi2vd/n7mTQPwZJZ0O78HG8dmJAe2zJIPHSN5QoOOdto3FyXDmWdffwzZ lMJXm7ah06mHOcL7F4FebF/BOggdQkl19KzCobuSdy7OiLo12Xcj05qMWnlfAwSbm8Mx nmwr9Lh+nV1+9Fv2CtAiUSO20WEc/zr3vBysTI7VTPfrwqwyulSWLcnxQhlizd6xMQWf EbbghTICFXbV2yN+fH29gFvI4vwhudDI1EkTl2vsD9wjZ1p954FAFEl2wn6o78jGjTeX KPmg== X-Gm-Message-State: AAQBX9fTF5lsJQCcM2X07y85ON9mfmZ0PctfMh0ERuxJT0Z7Sxtn+4/S OgkzaL3PPQzdvWZmFVN534WuhAMhEaPoKhC2oew= X-Received: by 2002:a5d:6ac6:0:b0:2f4:9f46:6865 with SMTP id u6-20020a5d6ac6000000b002f49f466865mr1864104wrw.30.1681398447907; Thu, 13 Apr 2023 08:07:27 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b002c55521903bsm1484870wrv.51.2023.04.13.08.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 08:07:27 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Laurent Vivier , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH 1/2] qtest: Don't assert on "-qtest chardev:myid" Date: Thu, 13 Apr 2023 16:07:23 +0100 Message-Id: <20230413150724.404304-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230413150724.404304-1-peter.maydell@linaro.org> References: <20230413150724.404304-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42e.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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: Thomas Huth 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", &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); } From patchwork Thu Apr 13 15:07:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 672839 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:184:0:0:0:0 with SMTP id p4csp934286wrx; Thu, 13 Apr 2023 08:08:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ashYPYUAdcjBq3dZeJJg5UEPRf7RE/6wpfRkUni8ehj6AVNVRxLPxX0rXgsHHpjgrSIQ5d X-Received: by 2002:ad4:5de6:0:b0:56e:9986:4fa9 with SMTP id jn6-20020ad45de6000000b0056e99864fa9mr2575960qvb.7.1681398539316; Thu, 13 Apr 2023 08:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681398539; cv=none; d=google.com; s=arc-20160816; b=ZrZxBS5SqUwI7mreFHS4wSwXDSxuWGTWuZgPSG0Y2FhRAHza67HAvUhrHF7FdUpB7L JgXciAswFV3a+uxe8U245CxwVCODfdyWTH69RNFGMIQUW9KXH8xUpbP7ATqD5Nr1V3KJ PDcL3y+y3xzbb0NEXmtaWeF3/UR8HkfjIDyTTI6yXq58NK4gRWfGgTjGaDEthydXjM7X OCg3/zhayRHhd4q47fF26LMNkIk71KYGqBadAQRrW0dn4hvUFll61Q31ltQLYQ7xbyPa WRRiRXEUF51FP7vVlMJFh+D272Yeb1cH4z7VxwVbZxIBsOtm50PCXbui6eYASLPoDa1p 8byg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EYoH05xSwr3WP+EI6CHPy/FAEMfj+7UKOwsjq5SbNj8=; b=lFG5F2B9BDCtDFMBDQhbhTTe+JfFnADn6Fsuw5F6CkNDeLcTU/OUfl1pjfDN0k/TtR /zsCGhi1ODuefrH3DvuHVLMfuscizVErAa1hon3necX9zTEBi+GsUSOu5tHFbYOYIl0M mG7XPjCzjF1QUdmKPBR2y1HZsMpD5yhYi9dTpjelBOu3QHcbMtHkNUpEFEOzwREMMwJX bjMfJQsNizrAzi3tYl2VFkmbPyRcx8ua++uaVZ3id5xy26DhjxBOlHvXjKbbSSr1XMcR YN4q0u8PK9ywZq9ryFslscCShJAL/9AaWyyl4FCBWdttqYvn9IFhd/J9/RcDhsJrB3ro 5cpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rwhq9Q/w"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a17-20020a05620a067100b0074aaa628539si969469qkh.482.2023.04.13.08.08.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Apr 2023 08:08:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Rwhq9Q/w"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmyXx-000822-EW; Thu, 13 Apr 2023 11:07:37 -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 1pmyXv-00081O-Gm for qemu-devel@nongnu.org; Thu, 13 Apr 2023 11:07:35 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmyXr-00054E-TW for qemu-devel@nongnu.org; Thu, 13 Apr 2023 11:07:35 -0400 Received: by mail-wr1-x432.google.com with SMTP id j11so18164160wrd.2 for ; Thu, 13 Apr 2023 08:07:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681398448; x=1683990448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EYoH05xSwr3WP+EI6CHPy/FAEMfj+7UKOwsjq5SbNj8=; b=Rwhq9Q/wULbueen7xmOKEawd5ln0ovlIMEVWPKhcWxHR7kECIqurL8zSj4NX+NmgKa nR/wNJUsEFsWnOF2XhNlpyl4M4wj3pX43HM5waQ0FkPyQKgtNu7epklzBRAJl9Czi3Fs y6SDgRMsZDc+isGJg65juO10iK7ynAZ98y6zMwUws4GgpxMmWbA2em5bmSM/QJ98t2wK +G10OaEdjGPnRE4sWMMkc/i9lv8blSjPwkc/4c6w6IMfHYtPJ1SMQrCGN/U3ACNp+Kes PAWFR0e8OwHq6WMm/Qgkn2a+ICD+/NGB6LQsjmg+QOY3U4BnsgxUgrXmWJvLJTfiT0gV JXCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681398448; x=1683990448; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EYoH05xSwr3WP+EI6CHPy/FAEMfj+7UKOwsjq5SbNj8=; b=BSTm0JDMHII5sOowpJjYUu02kYzhNhQco5KDr9lBXaWWyZlC+MbF2Bm0+cCHHm7DIm 5mT6V8BeJg38GG6q8j7/wjP58uBXAi8kcZo9mK36ILbm+EPFjM7B+/sbfvvddQQudKR0 kjrLb2wkEcwRL7CBRFQW5g3fMelX3ryiscg7f4u9Pt2njVvLPODOsng0I4/8q5Pec80k r91Lm2oSJAmoKVnGCUv6Obd2NhyYu/E5qArdHh+4dpNxUMNy1J8QcfaE1D1aXAJkcFyx HKQqhPKHGcXdLrOQvTd2um/CLqI0w8pvOqjWvb4AfSDCMbzzofq7FfH57mNla34DnW/j Hxxw== X-Gm-Message-State: AAQBX9cntjS8E8ak299MKBkLwXrxtAyHuzGXN9ZKS6PdT1t+PWfFOSJL uGGSfCjqbBUyqHaRJW363bpiacRIylfUksLXTF8= X-Received: by 2002:a5d:6b91:0:b0:2ef:eb11:4618 with SMTP id n17-20020a5d6b91000000b002efeb114618mr1834705wrx.8.1681398448320; Thu, 13 Apr 2023 08:07:28 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id t3-20020a5d5343000000b002c55521903bsm1484870wrv.51.2023.04.13.08.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 08:07:28 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Thomas Huth , Laurent Vivier , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Subject: [PATCH 2/2] chardev: Allow setting file chardev input file on the command line Date: Thu, 13 Apr 2023 16:07:24 +0100 Message-Id: <20230413150724.404304-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230413150724.404304-1-peter.maydell@linaro.org> References: <20230413150724.404304-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Our 'file' chardev backend supports both "output from this chardev is written to a file" and "input from this chardev should be read from a file" (except on Windows). However, you can only set up the input file if you're using the QMP interface -- there is no command line syntax to do it. Add command line syntax to allow specifying an input file as well as an output file, using a new 'input-path' suboption. The specific use case I have is that I'd like to be able to feed fuzzer reproducer input into qtest without having to use '-qtest stdio' and put the input onto stdin. Being able to use a file chardev like this: -chardev file,id=repro,path=/dev/null,input-path=repro.txt -qtest chardev:repro means that stdio is free for use by gdb. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau --- The "not on Windows" ifdeffery is because qmp_chardev_open_file() does something similar; it seems likely to produce a nicer error message to catch it at parse time rather than open time. --- chardev/char-file.c | 8 ++++++++ chardev/char.c | 3 +++ qemu-options.hx | 10 ++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/chardev/char-file.c b/chardev/char-file.c index 3a7b9caf6f0..263e6da5636 100644 --- a/chardev/char-file.c +++ b/chardev/char-file.c @@ -100,6 +100,7 @@ static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend, Error **errp) { const char *path = qemu_opt_get(opts, "path"); + const char *inpath = qemu_opt_get(opts, "input-path"); ChardevFile *file; backend->type = CHARDEV_BACKEND_KIND_FILE; @@ -107,9 +108,16 @@ static void qemu_chr_parse_file_out(QemuOpts *opts, ChardevBackend *backend, error_setg(errp, "chardev: file: no filename given"); return; } +#ifdef _WIN32 + if (inpath) { + error_setg(errp, "chardev: file: input-path not supported on Windows"); + return; + } +#endif file = backend->u.file.data = g_new0(ChardevFile, 1); qemu_chr_parse_common(opts, qapi_ChardevFile_base(file)); file->out = g_strdup(path); + file->in = g_strdup(inpath); file->has_append = true; file->append = qemu_opt_get_bool(opts, "append", false); diff --git a/chardev/char.c b/chardev/char.c index e69390601fc..661ad8176a9 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -805,6 +805,9 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "path", .type = QEMU_OPT_STRING, + },{ + .name = "input-path", + .type = QEMU_OPT_STRING, },{ .name = "host", .type = QEMU_OPT_STRING, diff --git a/qemu-options.hx b/qemu-options.hx index 59bdf67a2c5..31d08c60264 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3360,7 +3360,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n" " [,mux=on|off][,logfile=PATH][,logappend=on|off]\n" "-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n" - "-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + "-chardev file,id=id,path=path[,input-file=input-file][,mux=on|off][,logfile=PATH][,logappend=on|off]\n" "-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" #ifdef _WIN32 "-chardev console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" @@ -3563,13 +3563,19 @@ The available backends are: Create a ring buffer with fixed size ``size``. size must be a power of two and defaults to ``64K``. -``-chardev file,id=id,path=path`` +``-chardev file,id=id,path=path[,input-path=input-path]`` Log all traffic received from the guest to a file. ``path`` specifies the path of the file to be opened. This file will be created if it does not already exist, and overwritten if it does. ``path`` is required. + If ``input-path`` is specified, this is the path of a second file + which will be used for input. If ``input-path`` is not specified, + no input will be available from the chardev. + + Note that ``input-path`` is not supported on Windows hosts. + ``-chardev pipe,id=id,path=path`` Create a two-way connection to the guest. The behaviour differs slightly between Windows hosts and other hosts: