From patchwork Sun Sep 25 11:29:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987899 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 B8E5DC04A95 for ; Sun, 25 Sep 2022 11:40:20 +0000 (UTC) Received: from localhost ([::1]:46538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocPzf-0000oM-Pu for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:40:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqT-0002WO-GM for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:51 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:55125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqR-0006I4-Tq for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:49 -0400 Received: by mail-pj1-x102d.google.com with SMTP id y11so3941998pjv.4 for ; Sun, 25 Sep 2022 04:30:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xnFrQK3bS6jDORxTN0ClsvhvIgU1UaPy49FL95nw1To=; b=NlTohaiu4KpwH5DQ2va1OLthEox0Gh4UO96l3qE1Jn0q69y2eP4lTwnsuYJj81hWeh M7HVzpczovnQwtjBQsK98upw0pR7kdpxh6rA3kMcJdaa/+fZlwQfJG5qWwlHJ+k7DyMk On0eo7wJg1hZ2Nh/C1PUrFE6lDjuv+1rLjkzXI7BQI9Dao42nlXlEeAit3Tzsmp2ouwj v0UhMPzk2qg/pexxTpTdoP2SJe1gQuQ1fHnITMVpe7D3KtHXo6MDluJ8SOpdD1qbRDEQ 7K1yy9LQZUePVg0lgQ1ciUN0jA0IZKa4U4zNFUqHfhHGLuoRSOjGdYkYlGcNHi1zvkm+ PCCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=xnFrQK3bS6jDORxTN0ClsvhvIgU1UaPy49FL95nw1To=; b=pt2+BYZgw+BdTI1xyaZMuaMNABON7jswMDKJS3b0T4I/D4l5QQNOHws5kR7Zsb9t/r z2k/KHIeygJiYBaFoH4fQzx3oLgLWic2VpTWUeHmFwC4aukYV5cfuDDXBox/BvyqhEgq tcWsb/peZs6frtHkhzZuAilzbLN443d3LhxbknoVfjBeArbNB2Ouucga04Mu0TJ1jPuy L3hVt1n1z6+VUkAYDBfkaIvndItxsN61Ibn0s7oHDTjPh1GfkAym+EOJOlm94UP2Xmh1 M0ciCh2B9XtWDHrXTIqmBpcSWczIuZMDZhnMDUYp2V6xD93JZSRwbqevSZUIA/9LmddW MiaA== X-Gm-Message-State: ACrzQf0n3KRMvXs7IeMY8kTtjEAon3jxY8Gw2tLNeangT0Vg6JwBjklh 53L6X2FXKhSAAWknDDwQ8G/MZ2Wb14w= X-Google-Smtp-Source: AMsMyM6/RkDI8C39fTx6tEtkLthGeN554FEQLBzyHLSo1lfiyKfmy+v8litX/i0jqihvae9XNT1JUQ== X-Received: by 2002:a17:90b:180a:b0:202:ae1f:328a with SMTP id lw10-20020a17090b180a00b00202ae1f328amr31603392pjb.78.1664105446371; Sun, 25 Sep 2022 04:30:46 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:30:46 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 01/54] tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable Date: Sun, 25 Sep 2022 19:29:39 +0800 Message-Id: <20220925113032.1949844-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102d.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Previously request_{bios, pflash} cases were skipped on win32, mainly due to create_blob_file() calling mmap() which does not exist on win32. This rewirtes create_blob_file() to be portable, so that we can enable these cases on Windows. Suggested-by: Marc-André Lureau Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- Changes in v3: - Remove unnecessary "error = NULL" statements Changes in v2: - new patch: "tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable" tests/qtest/i440fx-test.c | 54 ++++++++++----------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/tests/qtest/i440fx-test.c b/tests/qtest/i440fx-test.c index 3890f1237c..795fd85343 100644 --- a/tests/qtest/i440fx-test.c +++ b/tests/qtest/i440fx-test.c @@ -278,56 +278,34 @@ static void test_i440fx_pam(gconstpointer opaque) qtest_end(); } -#ifndef _WIN32 - #define BLOB_SIZE ((size_t)65536) #define ISA_BIOS_MAXSZ ((size_t)(128 * 1024)) -/* Create a blob file, and return its absolute pathname as a dynamically +/* + * Create a blob file, and return its absolute pathname as a dynamically * allocated string. * The file is closed before the function returns. - * In case of error, NULL is returned. The function prints the error message. + * In case of error, the function aborts and prints the error message. */ static char *create_blob_file(void) { - int ret, fd; + int i, fd; char *pathname; GError *error = NULL; + g_autofree uint8_t *buf = g_malloc(BLOB_SIZE); - ret = -1; fd = g_file_open_tmp("blob_XXXXXX", &pathname, &error); - if (fd == -1) { - fprintf(stderr, "unable to create blob file: %s\n", error->message); - g_error_free(error); - } else { - if (ftruncate(fd, BLOB_SIZE) == -1) { - fprintf(stderr, "ftruncate(\"%s\", %zu): %s\n", pathname, - BLOB_SIZE, strerror(errno)); - } else { - void *buf; - - buf = mmap(NULL, BLOB_SIZE, PROT_WRITE, MAP_SHARED, fd, 0); - if (buf == MAP_FAILED) { - fprintf(stderr, "mmap(\"%s\", %zu): %s\n", pathname, BLOB_SIZE, - strerror(errno)); - } else { - size_t i; - - for (i = 0; i < BLOB_SIZE; ++i) { - ((uint8_t *)buf)[i] = i; - } - munmap(buf, BLOB_SIZE); - ret = 0; - } - } - close(fd); - if (ret == -1) { - unlink(pathname); - g_free(pathname); - } + g_assert_no_error(error); + close(fd); + + for (i = 0; i < BLOB_SIZE; i++) { + buf[i] = i; } - return ret == -1 ? NULL : pathname; + g_file_set_contents(pathname, (char *)buf, BLOB_SIZE, &error); + g_assert_no_error(error); + + return pathname; } static void test_i440fx_firmware(FirmwareTestFixture *fixture, @@ -398,8 +376,6 @@ static void request_pflash(FirmwareTestFixture *fixture, fixture->is_bios = false; } -#endif /* _WIN32 */ - int main(int argc, char **argv) { TestData data; @@ -410,10 +386,8 @@ int main(int argc, char **argv) qtest_add_data_func("i440fx/defaults", &data, test_i440fx_defaults); qtest_add_data_func("i440fx/pam", &data, test_i440fx_pam); -#ifndef _WIN32 add_firmware_test("i440fx/firmware/bios", request_bios); add_firmware_test("i440fx/firmware/pflash", request_pflash); -#endif return g_test_run(); } From patchwork Sun Sep 25 11:29:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987900 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 43994C04A95 for ; Sun, 25 Sep 2022 11:43:12 +0000 (UTC) Received: from localhost ([::1]:36540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ2R-0003y2-4S for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:43:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqV-0002WR-Jn for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:51 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:35711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqT-0006IE-UZ for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:51 -0400 Received: by mail-pf1-x436.google.com with SMTP id e5so4188220pfl.2 for ; Sun, 25 Sep 2022 04:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NHZEwyZe4QvDxYFPPW8rgMjXXwZjWrApXq6jqgxMbHA=; b=eSxFd8QWEz63E3jXfmNOFHJMU6CbKHFE9mQJuc8c7HkViaTjcHS1GWWK0kIUJ8oVna vIg7nmaQasrGqnqCKqdIvH+fF1Jwb1HbphGpaL+ePuhAh4MX/hr9WA7AnOBuODavFfjy xdeaqsTnqhG7AI8DGbUEvcpp53LeBbP/Z8wWQGeM0ySZ0KdiWgNfyrzKsgfcHc7sqrxM yZ1qm+Y3b/qV32JSNLUHRnVtRcDRqHbkFcOtLx1SCogSsKo0QELAd2TWReQaFD51gS9E qN5AAEpU5wXSzOsksrUAUeGJt2nyCyxZtdCVVgfVrhnhFkAIz7kpnv8mQorkOAT6BcRU krBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=NHZEwyZe4QvDxYFPPW8rgMjXXwZjWrApXq6jqgxMbHA=; b=19VdIYN3qf55N7zNvRzjet+imEG4X7hDY7MI5OecNVGbP1JctB2ZLeQPme3pYRI7tV c3y4KIBeQRRYjCy7Dzptfof5zo/F3wekD9v3AHORmCcXl8y6Y0RIfLjnJqlJvP9Ajxdd okG8dz68cmaAPFgPT3F5eP88Qd3PM6WaPy25CY9csd1zTdHsMI9wh+7j4OUnqYiKTtDp NEag24HmTLnIgoZDjliWsczN3erHxJ9yrMBh98A2Zu+pQkuVL1bnL+P+4BYlauJ04HAP Nj92KLbzX3A+NHKTdfGnFwuLY+++X7SkFtarcZTPBDkT87dgXsd7Vmw4lOYtkJLECpcZ 3kNA== X-Gm-Message-State: ACrzQf10eprMnU7d+nM9twLYGZ5EHxmDR7eNo0mbO95M88IPhzSbq6C9 U8uwt2zf8WGHiq3vOWQChrm/iSi8Jo0= X-Google-Smtp-Source: AMsMyM5RAKdwNBeBVXvr2q+yVqdKkYr4+6Qiq9nco+paeNd2ZRNzLy+xIg3gISwQUtNHA2WwtcjZIQ== X-Received: by 2002:aa7:9e0d:0:b0:540:94a7:9051 with SMTP id y13-20020aa79e0d000000b0054094a79051mr18380275pfq.59.1664105448328; Sun, 25 Sep 2022 04:30:48 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:30:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v3 02/54] semihosting/arm-compat-semi: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:40 +0800 Message-Id: <20220925113032.1949844-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x436.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Use g_get_tmp_dir() to get the directory to use for temporary files. Signed-off-by: Bin Meng Reviewed-by: Alex Bennée --- (no changes since v1) semihosting/arm-compat-semi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c index e741674238..d5e66cc298 100644 --- a/semihosting/arm-compat-semi.c +++ b/semihosting/arm-compat-semi.c @@ -503,7 +503,8 @@ void do_common_semihosting(CPUState *cs) GET_ARG(0); GET_ARG(1); GET_ARG(2); - len = asprintf(&s, "/tmp/qemu-%x%02x", getpid(), (int)arg1 & 0xff); + len = asprintf(&s, "%s/qemu-%x%02x", g_get_tmp_dir(), + getpid(), (int)arg1 & 0xff); if (len < 0) { common_semi_set_ret(cs, -1); break; From patchwork Sun Sep 25 11:29:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987903 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 94FC4C04A95 for ; Sun, 25 Sep 2022 11:46:32 +0000 (UTC) Received: from localhost ([::1]:45922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ5e-0007fb-Ll for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:46:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqX-0002Z1-8u for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:54 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:38845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqV-0006IN-RT for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:53 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 129so2788464pgc.5 for ; Sun, 25 Sep 2022 04:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=x1b0DAXqWLfiXhIrelVULtyJQz5QogyXKHVADLX3USo=; b=iA6vrJKoZVzb5mhtTIoFaWpmlKmn9U+D8y7LSFOh9NQ6lgS9oRR10DQkxFr4K3mYxS ZCuPGux3bKDDgSp/75rFlnSwIzoQNIxbeX5wL0wqKssG8fbepzlT0h5YQ+/eHvvaJUm8 4z1+M122Qnm4aQMnkjXJYidsQhc62xbdKvYCI4fnMvGD824X/aVBsQckB1kJ57GDIP+t LV2fAaBJsKV/ivN7NCucQLiR4U8EngEQSsayXnDTDUFIa/hkn4xpZo72gdfSji4U6k4Y oXcr0InPZQj23H685BE+W/+w3fmeTy9oysDR97JMl+4X6ruSn1fjfFP0GgoYp3fraQRf tWSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=x1b0DAXqWLfiXhIrelVULtyJQz5QogyXKHVADLX3USo=; b=qCX4uo0QxHxtix/eNr4Skd4FHvEr5bVrTlrn+Va0Bwqi+gH+YSSKTA3ylpMKJeCdSq 1gAa2HHYavN7Z071p3cgBlO0iNiTHarTVnN1N5Z4kPxNoXlBKowFY5oLeQWA3NrcyRcA FkRT2vZFX86XORNw7fRa1qD+sgIWtjVGwFTs8nnnkyWRkJX71ShqpPXO+YjOVxUwJBNC tPixJtIrna2vUuw71AU9GYzSox1aDlznm9Xe6dObFrrtUogKxQfBKFemx2iD3kDhDMCf J4GcetIjiP+FRdHdQIR6GFjIpagdqOAn8OaMJpYUyx9E4j9Jc74V9U5aw9MCGSuO/JCb Eauw== X-Gm-Message-State: ACrzQf3vcg7WOVCQhhXcDq+kx1YIyW/0ealXCuD3CmjRrOzLvS//TfvG zgSkgjzmpXyiQxOPYYphdQVV6H3BMPg= X-Google-Smtp-Source: AMsMyM43PM8miWusED9cJMfV4AqxZyczvi+AcnGhfm3v0KlBNH/lfe1f/kM3aC+52GvWsdLv+Tf2rQ== X-Received: by 2002:a63:5fd6:0:b0:434:96fe:f508 with SMTP id t205-20020a635fd6000000b0043496fef508mr15312985pgb.306.1664105450400; Sun, 25 Sep 2022 04:30:50 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:30:50 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Subject: [PATCH v3 03/54] tcg: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:41 +0800 Message-Id: <20220925113032.1949844-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52b.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Use g_get_tmp_dir() to get the directory to use for temporary files. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau Reviewed-by: Alex Bennée --- (no changes since v2) Changes in v2: - Use g_autofree to declare the variable tcg/tcg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 0f9cfe96f2..8847053176 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4729,7 +4729,8 @@ static void tcg_register_jit_int(const void *buf_ptr, size_t buf_size, /* Enable this block to be able to debug the ELF image file creation. One can use readelf, objdump, or other inspection utilities. */ { - FILE *f = fopen("/tmp/qemu.jit", "w+b"); + g_autofree char *jit = g_strdup_printf("%s/qemu.jit", g_get_tmp_dir()); + FILE *f = fopen(jit, "w+b"); if (f) { if (fwrite(img, img_size, 1, f) != img_size) { /* Avoid stupid unused return value warning for fwrite. */ From patchwork Sun Sep 25 11:29:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987904 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 6AD2DC04A95 for ; Sun, 25 Sep 2022 11:48:54 +0000 (UTC) Received: from localhost ([::1]:43100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ7x-0001NL-Hn for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:48:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqZ-0002aW-H8 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:56 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:34444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqX-0006Ic-MR for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:30:55 -0400 Received: by mail-pg1-x529.google.com with SMTP id 3so4237734pga.1 for ; Sun, 25 Sep 2022 04:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ptPSCcbuG++AcglR+Ify0H9lkcBvjcAqRFsbcccQhHg=; b=JRrGE8zCoW8iODFwX8r6CjMN9/8Qjd0GMphUuuvu13la6TH5AxF6ETefFqMvMTFcOG 5A3BHJhEA+hig3nmiwA6xGceVL4GHMgh5+HSkHD58licsBJf6Vbxy/Nq5IDhPjfF3GSb hzpEOAUKwUQAtCRDCMrSAcza6ZsvNon0x0ANhFWD8zV/0ZCyw+/Gv0+Op6JNJXZKsUfR OWbsAtD9T5gddexVbw1Pk4WcWfHG96osqWDjmfMb8C61Y+rvopf4VzBXO7zakTBdHV2S QKSpiuCl0i0Nx5xvaj3kzMD6B1ZMNdBe3AFNotRBXrTAPQWgCf9AVZ6drPwCIhw2XnV5 ObrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=ptPSCcbuG++AcglR+Ify0H9lkcBvjcAqRFsbcccQhHg=; b=GaBErD8LdT/zhzOzTLOkjeEQf276Ep1KUVtkzaAKpQqiPWkZiuzKlGfym2w+NCGRLB A4/9qyqFmtA67VnRT3LiH6Ruuj1yn76eNbuo5WPX3qymB1VRugrrwZGt+HxIpxw2pVTB sqQBpgp00GAmD1K3TOpwiESniOM9JBRB3RcMD52pI4fr6PTWtlkD6JSI+EAdgSKJUCjb CCGd8HHQoRXzMyaKXMLvnKO8wbZ3/pl/uOPCoEja7UpquQD+Q1B842xU8KpNT9N+leOh 0NWXHxRe4PIa5svqj9F99ED34aP8lSzVc0oDQoOGrbZyvWQiKeBpIDy7Xeeg7CMmwaVP UUoA== X-Gm-Message-State: ACrzQf0oadxq/VqzpLHKUU1zbQ0/EUBhelwmCcXvJCAEvDGjXWGrXCBk Z5jxJ1c5PrXySeqCnY6x8CsMzadcRBs= X-Google-Smtp-Source: AMsMyM7I7SNO8WRhF+QSPJwJBxRWG1cI/y5rV1S8CCA+Gnc6+Xisom0lvo00TakuplLJ03ukwfmVlA== X-Received: by 2002:a63:188:0:b0:43c:22e9:2d10 with SMTP id 130-20020a630188000000b0043c22e92d10mr13362459pgb.12.1664105452324; Sun, 25 Sep 2022 04:30:52 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:30:52 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v3 04/54] util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files Date: Sun, 25 Sep 2022 19:29:42 +0800 Message-Id: <20220925113032.1949844-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x529.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Replace the existing logic to get the directory for temporary files with g_get_tmp_dir(), which works for win32 too. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) util/qemu-sockets.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 83f4bd6fd2..0c41ca9e42 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -919,9 +919,8 @@ static int unix_listen_saddr(UnixSocketAddress *saddr, if (saddr->path[0] || abstract) { path = saddr->path; } else { - const char *tmpdir = getenv("TMPDIR"); - tmpdir = tmpdir ? tmpdir : "/tmp"; - path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", tmpdir); + path = pathbuf = g_strdup_printf("%s/qemu-socket-XXXXXX", + g_get_tmp_dir()); } pathlen = strlen(path); From patchwork Sun Sep 25 11:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987897 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 59558C6FA82 for ; Sun, 25 Sep 2022 11:36:23 +0000 (UTC) Received: from localhost ([::1]:38748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocPvq-0005pY-8O for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:36:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqe-0002cs-HK; Sun, 25 Sep 2022 07:31:00 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:38743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqc-0006Iv-7Y; Sun, 25 Sep 2022 07:31:00 -0400 Received: by mail-pf1-x431.google.com with SMTP id a29so4178779pfk.5; Sun, 25 Sep 2022 04:30:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=D3VuKooJ4UjKkQ3haTWxtVaNZNqddm2jJatcFkZLIyw=; b=Bsrhixs7M5N+gFRyjPlEPb6cOLd5VotPkQxGklGu3O0ykrIrdiOGEqGEc9Vf8nWOc/ FmtRRCb26BG45sVYhj9C13y81YiB+ZShUdodNFjhT+MmnPgy9ZNasqKk9Tc6/UQkjFkj 1uRyjkIxTJBe3PBPtupfvCKTvgd9etSbxlKW1JkVH7yUjZk4v0Z1nkD0V3pz1+63hTgL P399Rhne/VGom+m1f8nDRKG97oOg1opWShZNMLgEhcxB4W2tojpUafDm3swi+vgF2KfA BcKH5TrPsKewWDimNrFEvJU40m8zWt0I0K5vVq/WVqJmxQ+s31QKgALZP+6cWw+k2jAM P4iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=D3VuKooJ4UjKkQ3haTWxtVaNZNqddm2jJatcFkZLIyw=; b=yQY5zBo5EKvLdU32LZMpyciFMa6LIHqWjjlkElpd5qKfY+OMi1cV31O1910+3ePXbt sD7dQ80z69omz2F/5wtWy8Lzi2ZXdWxVOmOVV8i6aV/cm0FWogtF/nbexRie8T1KgOxY Jn+mwUKTD5E7viLwh7A5HeqGnVKtsjbZny+aPeHH9fdbXyJxE6bgsPfMSzqyD+ZtXmLv z27D8F4ytZfiHKqtu3nfzHWbqgc0kdN+cNhX/aJgHDP+lYSwnYRLPnL8T3MH+DHwOZXG L4NxNEaNZhNIjVuyM5gY6NjqGHtlyKIap7LA3xbTTQtApZW3ZJ87pzu9Cc7XuXyNJ9nI PpSg== X-Gm-Message-State: ACrzQf3lrnN6LmWhT0cesFqZc+eaKftlaeGcHA4tSJ3OaEZK1fiP3roL 8KZqyOKeCkGI4iKHRcBp16kc2wyKwmk= X-Google-Smtp-Source: AMsMyM5ePHUXeP23k1ejSBAYg4EjYazAQbFudw3/cFXjoAkjLBVY4zJ1noJnjhgk8Y4MyLKu/cNB5g== X-Received: by 2002:a63:20f:0:b0:439:c92f:e6d1 with SMTP id 15-20020a63020f000000b00439c92fe6d1mr15319770pgc.334.1664105455051; Sun, 25 Sep 2022 04:30:55 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:30:54 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 05/54] tests/qtest: ahci-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:43 +0800 Message-Id: <20220925113032.1949844-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x431.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/ahci-test.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index f1e510b0ac..1d5929d8c3 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -44,9 +44,9 @@ #define TEST_IMAGE_SIZE_MB_SMALL 64 /*** Globals ***/ -static char tmp_path[] = "/tmp/qtest.XXXXXX"; -static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX"; -static char mig_socket[] = "/tmp/qtest-migration.XXXXXX"; +static char *tmp_path; +static char *debug_path; +static char *mig_socket; static bool ahci_pedantic; static const char *imgfmt; static unsigned test_image_size_mb; @@ -1437,10 +1437,10 @@ static void test_ncq_simple(void) static int prepare_iso(size_t size, unsigned char **buf, char **name) { - char cdrom_path[] = "/tmp/qtest.iso.XXXXXX"; + g_autofree char *cdrom_path = NULL; unsigned char *patt; ssize_t ret; - int fd = mkstemp(cdrom_path); + int fd = g_file_open_tmp("qtest.iso.XXXXXX", &cdrom_path, NULL); g_assert(fd != -1); g_assert(buf); @@ -1872,7 +1872,7 @@ int main(int argc, char **argv) } /* Create a temporary image */ - fd = mkstemp(tmp_path); + fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL); g_assert(fd >= 0); if (have_qemu_img()) { imgfmt = "qcow2"; @@ -1889,12 +1889,12 @@ int main(int argc, char **argv) close(fd); /* Create temporary blkdebug instructions */ - fd = mkstemp(debug_path); + fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL); g_assert(fd >= 0); close(fd); /* Reserve a hollow file to use as a socket for migration tests */ - fd = mkstemp(mig_socket); + fd = g_file_open_tmp("qtest-migration.XXXXXX", &mig_socket, NULL); g_assert(fd >= 0); close(fd); @@ -1947,8 +1947,11 @@ int main(int argc, char **argv) /* Cleanup */ unlink(tmp_path); + g_free(tmp_path); unlink(debug_path); + g_free(debug_path); unlink(mig_socket); + g_free(mig_socket); return ret; } From patchwork Sun Sep 25 11:29:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987907 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 AFBF6C04A95 for ; Sun, 25 Sep 2022 11:52:10 +0000 (UTC) Received: from localhost ([::1]:34430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQB7-00053X-Hb for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqf-0002dH-DL; Sun, 25 Sep 2022 07:31:01 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:50756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqd-0006J2-SJ; Sun, 25 Sep 2022 07:31:01 -0400 Received: by mail-pj1-x102a.google.com with SMTP id fv3so3992199pjb.0; Sun, 25 Sep 2022 04:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6rt1OwHx0poTtFu+/xYq6h3N3Rvq3r0ijnGYMxiWCtU=; b=icbzfD3or1/jGBFdIDKRm+a1PbJu/AAD9twNGAwhoJ1qRT3990fek5NtyuxVm+desi hZTFSsziyBitkl8ka0GEjfgWtqZLPubIfxOwBYpIMS4KGJtLn0yUl4O0tXY5fodlOSod x4NgAm9Mghm9c/qNqbdDO6m3zhMPtCNf/eRsPZRe3kXge8L7Exp2o89XBwnA5T9gvKca qWP0J/ZCwOkbrrwN7p/vD97eBk8pJf6b8SY4CD1AX0nTWaqGx/QU38eSDv5V1c75qLuR d89VqBwNiFcpTCJ7SCy3uvFIw/LgfsydasaHuhBs2GMaUAlUZ04OH//1fZzewjB+rPYN tEyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=6rt1OwHx0poTtFu+/xYq6h3N3Rvq3r0ijnGYMxiWCtU=; b=Yzbp9Ee/wiuMsA2eSJIFO/tSgZbp4KrG8wHSgDxlch7rWuxZrwj1IARCKwITzwPWXP QaTaOe3/utR3koUUC+F7rUbjlQ/z63jDRvijs3dPPVkG2Rx4vsMude+DiReQc5iwVjHX yIhanIGJOLYjD0uxVgtE6CR40xqteFumnGEJ2qqkAm3l3VehHXxOi13sjzT63v26q7xp xZ8NROo1wPlptbldlMryg5PY49S8WOJz9fdeAez7g5hc1C8q75tzQcTkuV/XubK3t1pT mlpDy5V51d5jp5G/FpQ5RgFVvu21JvWEamTHAkK6nqBUM6qLDfUB/ZxP0bT+/3U/yKFi xBrw== X-Gm-Message-State: ACrzQf2SlTEPMEEQkeaL1NfayxyGeIGvQeS3eMGZTCBAOTGG0rrNaCWA Zzo5Umuhsod9tC8PBp3Q17y1/anqeGk= X-Google-Smtp-Source: AMsMyM64OHWFSEPb3UyUJiiLsy7oVoYE+Sftx9mg53tLhM7Q4tCCUPA1BJsQZpm8hj0Hk/Bk6N2tXQ== X-Received: by 2002:a17:90b:1b4c:b0:202:c1a3:25ce with SMTP id nv12-20020a17090b1b4c00b00202c1a325cemr31787763pjb.232.1664105458206; Sun, 25 Sep 2022 04:30:58 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:30:58 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Andrew Jeffery , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Joel Stanley , Laurent Vivier , Paolo Bonzini , Peter Maydell , Thomas Huth , qemu-arm@nongnu.org Subject: [PATCH v3 06/54] tests/qtest: aspeed_smc-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:44 +0800 Message-Id: <20220925113032.1949844-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102a.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Cédric Le Goater Reviewed-by: Thomas Huth --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/aspeed_smc-test.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c index 05ce941566..c713a3700b 100644 --- a/tests/qtest/aspeed_smc-test.c +++ b/tests/qtest/aspeed_smc-test.c @@ -608,16 +608,15 @@ static void test_write_block_protect_bottom_bit(void) flash_reset(); } -static char tmp_path[] = "/tmp/qtest.m25p80.XXXXXX"; - int main(int argc, char **argv) { + g_autofree char *tmp_path = NULL; int ret; int fd; g_test_init(&argc, &argv, NULL); - fd = mkstemp(tmp_path); + fd = g_file_open_tmp("qtest.m25p80.XXXXXX", &tmp_path, NULL); g_assert(fd >= 0); ret = ftruncate(fd, FLASH_SIZE); g_assert(ret == 0); From patchwork Sun Sep 25 11:29:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987901 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 CCB9FC04A95 for ; Sun, 25 Sep 2022 11:43:52 +0000 (UTC) Received: from localhost ([::1]:46756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ35-0004x4-Qj for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:43:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqh-0002dt-SY for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:05 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:42954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqg-0006JK-2R for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:03 -0400 Received: by mail-pl1-x630.google.com with SMTP id v1so3915258plo.9 for ; Sun, 25 Sep 2022 04:31:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=artXxf134UnHwbGPHataxK5Sb0F+FjJJHNdQ9P3EeuE=; b=hw4Ju76c9r5ZEeqOvmmALbHJ/WSeaJkcXR/bFk4ef5PQf0upstLQg+4nMapfb7e0Kg 9UdHeChOf62mTF8kmM/Nxz1RjR30IDFE3g8A9gVSoU1otUyIlWkna8yMr9qS+ulc9wkt vDoAZK/Aq3dtdHwjO+XabfKQ5sOQQutfUZZneqOy0l2TMh+7v8+rfCLkFZdM5ileT/Y+ igaVou75ZIb75j2azHMWisIxxNlQE6lzL1RXhBp5gxpqDkDSayCM4c/b7dabrK5Fthol LGV/y2CrfO0dH++o3U3FNoKjWWyEWK1WMkjgAzobFLuw2ObX0krV82+GKxzq46JSZU0f 3jhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=artXxf134UnHwbGPHataxK5Sb0F+FjJJHNdQ9P3EeuE=; b=AL/f2P09vdWI6Kex1u2FlfEKR0F6eXIxawv2eS2Ey4X/uRfFYWmiB6MlrrskKC++kb M5HdqbP6WH+OlZQ39Jvv7mJtNZhdLCKSSVIySD5rsqfGXKPFXcRJ7tg+Fae7YfiDnqW7 37LEmECSZ3xsLPqE/GPqrZCHHqT9VVpn87M83O/WbYGgE436F8qbvIM+m8ZJWt/MqP4n 9kKxoiwSW7SQv5rX19v4xQ2sBi2SLzYpsTFlRkAsglbQhaN2X4XrcAThIpWPvvUFfXZL Y822zQtv6/h44Tt31nkAu2ZrXqPU7ZuXtkrqXi7nZnTVNPNfnKTYRyZSpIo0zQyB7zQa xNVw== X-Gm-Message-State: ACrzQf134cgTbTdy/t0Wq3MuTU3WkOMy6nAclmNzs54g5i78hztnGK8Z dfEO74mWWSnme6JHhn/SjsKEVYVpDj4= X-Google-Smtp-Source: AMsMyM5CZDUOuNC1DHO1i+icS0Iy3SpL0mNH+2v3rG3bqUV7x1gw/ovPTiBW7etpSvCNFJA1lgoIaQ== X-Received: by 2002:a17:90b:48c5:b0:205:a605:4f40 with SMTP id li5-20020a17090b48c500b00205a6054f40mr5017900pjb.104.1664105460500; Sun, 25 Sep 2022 04:31:00 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.30.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:00 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 07/54] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:45 +0800 Message-Id: <20220925113032.1949844-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x630.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/boot-serial-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c index 2f99d71cab..72310ba30e 100644 --- a/tests/qtest/boot-serial-test.c +++ b/tests/qtest/boot-serial-test.c @@ -224,14 +224,14 @@ static bool check_guest_output(QTestState *qts, const testdef_t *test, int fd) static void test_machine(const void *data) { const testdef_t *test = data; - char serialtmp[] = "/tmp/qtest-boot-serial-sXXXXXX"; - char codetmp[] = "/tmp/qtest-boot-serial-cXXXXXX"; + g_autofree char *serialtmp = NULL; + g_autofree char *codetmp = NULL; const char *codeparam = ""; const uint8_t *code = NULL; QTestState *qts; int ser_fd; - ser_fd = mkstemp(serialtmp); + ser_fd = g_file_open_tmp("qtest-boot-serial-sXXXXXX", &serialtmp, NULL); g_assert(ser_fd != -1); if (test->kernel) { @@ -246,7 +246,7 @@ static void test_machine(const void *data) ssize_t wlen; int code_fd; - code_fd = mkstemp(codetmp); + code_fd = g_file_open_tmp("qtest-boot-serial-cXXXXXX", &codetmp, NULL); g_assert(code_fd != -1); wlen = write(code_fd, code, test->codesize); g_assert(wlen == test->codesize); From patchwork Sun Sep 25 11:29:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987911 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 D4BC0C04A95 for ; Sun, 25 Sep 2022 11:55:14 +0000 (UTC) Received: from localhost ([::1]:44832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQE5-0002MB-Vi for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:55:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqj-0002ef-ON for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:05 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:43679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqi-0006Jc-7V for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:05 -0400 Received: by mail-pl1-x631.google.com with SMTP id l10so3913794plb.10 for ; Sun, 25 Sep 2022 04:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=uPBeW/aIJLGwHIjEsjRiKxOEq2N/h6aNVIB5R50FGk8=; b=Uux5Lb6daqndboYLiMUfTE5xrl/s0e5gWRiLwjf+o0VW+ENtejh47h8TLQCul4bFxe HsZy+li4Te6AdtTt+/7Nh2Kt/Vgt3yhPQ6a8n+49gBwHds6UG7B3loTJSyGEEfMTw7ni t4IUWySI8suQVEtcY/Hoz/6S2LBMc9SMG1KlBF8gfLYEErOHxpfmozVAEwo+Zs0ScKlh DuyDfyby+yHBOgrGZWTPLIaY0ZEkqD0b1zp5gk036v2x4KWJ3tq9dqQWDh7U/gUrZ77v iZcN9OWbFUlWljfPcGPv9/hF7mqXNLmn4nlQ6OW9z264h9QSEmPDPRAxR4dV//kLjv0/ kD8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=uPBeW/aIJLGwHIjEsjRiKxOEq2N/h6aNVIB5R50FGk8=; b=sUaqqXF9Axae/tXkwrDGTojdp5cjX4GvaBDHrLar+Hq+Rkn+hpQkIbIaI29RZWwO8H WYoajrhhRHrKTp2SAmxX0TnTmi5Ei4eCF7SyiiRk5g6mBMcd2RK1T6WvCS31WosOsvP5 eAWHRbvcR92J4/GiMgipZPAFbBpUgeMIn0XCH3zAAKdup/0OyOwHWOVK2Te4z2J4p4OQ rnJAxuPUodpNk6wztlmGnfJ6ZRHOPNvvRkG0bAPJUKab2K3fBBJZw3l4luJ5ihtEHAGr J42pe4cMSUCFd5Es3ZcLiPyglhGtK5a2FB8ItaFxDk9I5iwo6UCVUtq8Ho8zin0ssbWV yKdw== X-Gm-Message-State: ACrzQf0a7WX2ZjGZE9ylQVgZKi2/fzFr305khLqie11nX/fKGhTM3uPq /bomX377bXedG0MP1dN+2mOefP1cEWQ= X-Google-Smtp-Source: AMsMyM7mDPcgIxQwg079wDhpx4D62sntBZ4neFZUZtbyHWBTEGAdZOa6BTuxFnzwuotk0rCOAsFSBA== X-Received: by 2002:a17:903:2286:b0:178:349b:d21c with SMTP id b6-20020a170903228600b00178349bd21cmr16914230plh.71.1664105462855; Sun, 25 Sep 2022 04:31:02 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:02 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 08/54] tests/qtest: cxl-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:46 +0800 Message-Id: <20220925113032.1949844-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x631.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/cxl-test.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/qtest/cxl-test.c b/tests/qtest/cxl-test.c index 2e14da7dee..cbe0fb549b 100644 --- a/tests/qtest/cxl-test.c +++ b/tests/qtest/cxl-test.c @@ -93,10 +93,9 @@ static void cxl_2root_port(void) static void cxl_t3d(void) { g_autoptr(GString) cmdline = g_string_new(NULL); - char template[] = "/tmp/cxl-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("cxl-test-XXXXXX", NULL); g_string_printf(cmdline, QEMU_PXB_CMD QEMU_RP QEMU_T3D, tmpfs, tmpfs); @@ -107,10 +106,9 @@ static void cxl_t3d(void) static void cxl_1pxb_2rp_2t3d(void) { g_autoptr(GString) cmdline = g_string_new(NULL); - char template[] = "/tmp/cxl-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("cxl-test-XXXXXX", NULL); g_string_printf(cmdline, QEMU_PXB_CMD QEMU_2RP QEMU_2T3D, tmpfs, tmpfs, tmpfs, tmpfs); @@ -122,10 +120,9 @@ static void cxl_1pxb_2rp_2t3d(void) static void cxl_2pxb_4rp_4t3d(void) { g_autoptr(GString) cmdline = g_string_new(NULL); - char template[] = "/tmp/cxl-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("cxl-test-XXXXXX", NULL); g_string_printf(cmdline, QEMU_2PXB_CMD QEMU_4RP QEMU_4T3D, tmpfs, tmpfs, tmpfs, tmpfs, tmpfs, tmpfs, From patchwork Sun Sep 25 11:29:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987905 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 665A1C6FA82 for ; Sun, 25 Sep 2022 11:49:19 +0000 (UTC) Received: from localhost ([::1]:48600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ8L-0002Ms-Ix for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:49:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPqo-0002gO-HC; Sun, 25 Sep 2022 07:31:15 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:45635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPql-0006Js-GD; Sun, 25 Sep 2022 07:31:09 -0400 Received: by mail-pl1-x636.google.com with SMTP id w20so3901623ply.12; Sun, 25 Sep 2022 04:31:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zguLWmiD6IuG7yrS2NpjVBr5INGxJ8UZ9U8MjSEIiIU=; b=JiMvea3xpXLMHVlL2igokD6nyhClhCDJJwiu12Uyzf9xylc0CEOvjgokaHlB5PJIK8 ACFKdKGQ8Ssn8bowp7WYO3ibusZfS7X08gGX01R8I1uhtJVLdP7weRzzkUyhMwnNlKN1 3qhYF/hga/2iISZ0pMhk1pZFF2SQ4kVx92TskZTNu8+waDiG9iAhlK/GWHPrmQN5VDZV hwla5Q0Zvya2Hre3ywq5f8ovnIXgsAStV/O6nINnqVbWuWi8RYl8cQLLf+bm0LzJxTvh vCy4Dg9yHQ7T5yaEF4cspBvwLjJW5ooB+Br0ojSY+u5QF/KBMGoKkqRmWms91KkWnTjq gw0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=zguLWmiD6IuG7yrS2NpjVBr5INGxJ8UZ9U8MjSEIiIU=; b=VVKRmO4uEK0hEUbUwd7q54tOWL8dbhmCNT2bzs+6evNryRxxK/CTH8qRYmz/LKdOZ3 hXACNPJECKQJFhkuEFby4dpTyUZhewoRzfEni0TJ1tY0AvyjfjvGhiH7D4zinFojKZu+ sxOjTWQZXBmANlGgMG2MUJ+A9JHW/3UN4Q1RqZc2A23Fl+pzA1pG2tyfbo0L0TvfGlAQ xRmwOAVPTGZlOeG6ap93uAcMdVYKYvxE3X4twt+4ja+5t+6TeqT+h0xwVUGvUogqrv9w CoSC8j75j29uPq5it0sRHMXGlAM4bIZNjUn836DcBStBhZVJEsCelXEqNKKroJp42IMC FnzA== X-Gm-Message-State: ACrzQf09wShw2Et3r36ek9Tj72J6vg3NR6OT372dd2v/OG2Du4Zo9gV4 L2k3RyksITaqGggLwlTOThrT2SLnEfY= X-Google-Smtp-Source: AMsMyM5+Z33FvtX4sSWLYy0Wznqvxry7fFXCO/2dEAKa9UZXxxZMG0cCznApXn5Fxvedg6FhswT4uQ== X-Received: by 2002:a17:902:d70e:b0:178:2d9d:ba7b with SMTP id w14-20020a170902d70e00b001782d9dba7bmr17287849ply.90.1664105465749; Sun, 25 Sep 2022 04:31:05 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:05 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 09/54] tests/qtest: fdc-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:47 +0800 Message-Id: <20220925113032.1949844-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x636.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/qtest/fdc-test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/qtest/fdc-test.c b/tests/qtest/fdc-test.c index 52ade90a7d..1f9b99ad6d 100644 --- a/tests/qtest/fdc-test.c +++ b/tests/qtest/fdc-test.c @@ -68,7 +68,7 @@ enum { DSKCHG = 0x80, }; -static char test_image[] = "/tmp/qtest.XXXXXX"; +static char *test_image; #define assert_bit_set(data, mask) g_assert_cmphex((data) & (mask), ==, (mask)) #define assert_bit_clear(data, mask) g_assert_cmphex((data) & (mask), ==, 0) @@ -608,7 +608,7 @@ int main(int argc, char **argv) int ret; /* Create a temporary raw image */ - fd = mkstemp(test_image); + fd = g_file_open_tmp("qtest.XXXXXX", &test_image, NULL); g_assert(fd >= 0); ret = ftruncate(fd, TEST_IMAGE_SIZE); g_assert(ret == 0); @@ -640,6 +640,7 @@ int main(int argc, char **argv) /* Cleanup */ qtest_end(); unlink(test_image); + g_free(test_image); return ret; } From patchwork Sun Sep 25 11:29:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987898 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 69877C6FA82 for ; Sun, 25 Sep 2022 11:38:09 +0000 (UTC) Received: from localhost ([::1]:56360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocPxY-00074N-GH for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:38:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPr5-0002hG-7C for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:34 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:40881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqo-0006K6-AE for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:11 -0400 Received: by mail-pf1-x436.google.com with SMTP id b75so4165109pfb.7 for ; Sun, 25 Sep 2022 04:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wXX7o9vyXe+cnIaSrbOC6Qyjf1ISL58lfb5Pt+UbcI0=; b=Qa+OVJtg9ub68JAm+Aq1Joqx7kI7m0t08L/SSoIAQeudgicfopSh0GBKuLLTkIeZLa UnAwoOMKnMF0mLBlrso63fIHCfzTmHUwa1aIvVCJgmzJiXR2ShaXOT5+9pUFbv/gDB5S qGNmTn/Dkx4Gxm2BmNTmrMt0SzQUQvxHydHAISMMWtlkBlrmQLisedUOFPY9NEunDgTw oM9swQa0yXjVmqmjGuri1T5+abxWA8Ir0Y5eB+ahKuBtp310qzC4R8IhrO+cmuCQzR+B OhXbc0BPjlAqMNvecD0XjpH/lIt7C/Ycr4TxMzzYj0/lujICW4JZWLmYE+R7pPDAXFY/ Sy5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=wXX7o9vyXe+cnIaSrbOC6Qyjf1ISL58lfb5Pt+UbcI0=; b=6XU+gRNKA46AQK8EM7n4D8urQVEpLlWSmo/p2tYaz/1ZMIl1FR13zOUxURax6/Q225 E8phbi0YAW9Vo7zAwbWDnY1p5auC60b7wCHCg5WTXPkYMU2X8p3Em8R0mdySUqMT/GFK zSiSVBh28S90ZkKsQSsN5YXRAEJdsnkPpaHGw44MLL3dqNFprh5bC6bf2ur7DOZ7zlId DbXSdNNKKRrRdsMupviTt6gXZZISFI/e12xUQkNlXmJG8M62FQsQHmM7S3Ixx4I7GZ3i KaFxdhuqD06+wVMujPZuOgeMgCE8xa3TPcG4PbuBq4etkQRN2ncsqjPIob4AevpmiEOG sOag== X-Gm-Message-State: ACrzQf1lFWFm+XFleBXg1Tt8/MwgwJoPcJP2Z+y6Xai7loA93Vahx6Mb utNXZ3xMx9zdZhZ5JdPeZ426yDJ4aC4= X-Google-Smtp-Source: AMsMyM7jgcjb4M6hCBRjyjVlhNtX+SqKlZs4Pn+Be5BXTXL7QXDOgpLkLcHc0kS7kdxBZ4esPpC4sg== X-Received: by 2002:a63:f20e:0:b0:439:398f:80f8 with SMTP id v14-20020a63f20e000000b00439398f80f8mr15043585pgh.494.1664105469013; Sun, 25 Sep 2022 04:31:09 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:08 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Alexander Bulekov , Bandan Das , Darren Kenny , Laurent Vivier , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , Thomas Huth Subject: [PATCH v3 10/54] tests/qtest: generic_fuzz: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:48 +0800 Message-Id: <20220925113032.1949844-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x436.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/qtest/fuzz/generic_fuzz_configs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz_configs.h b/tests/qtest/fuzz/generic_fuzz_configs.h index 0775e6702b..a825b78c14 100644 --- a/tests/qtest/fuzz/generic_fuzz_configs.h +++ b/tests/qtest/fuzz/generic_fuzz_configs.h @@ -20,8 +20,8 @@ typedef struct generic_fuzz_config { } generic_fuzz_config; static inline gchar *generic_fuzzer_virtio_9p_args(void){ - char tmpdir[] = "/tmp/qemu-fuzz.XXXXXX"; - g_assert_nonnull(g_mkdtemp(tmpdir)); + g_autofree char *tmpdir = g_dir_make_tmp("qemu-fuzz.XXXXXX", NULL); + g_assert_nonnull(tmpdir); return g_strdup_printf("-machine q35 -nodefaults " "-device virtio-9p,fsdev=hshare,mount_tag=hshare " From patchwork Sun Sep 25 11:29:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987902 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 BFFF6C6FA82 for ; Sun, 25 Sep 2022 11:44:22 +0000 (UTC) Received: from localhost ([::1]:46762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ3Z-0005Ag-LI for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:44:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55924) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrD-0002ic-RZ for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:36 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:40873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPqy-0006KI-Q3 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:28 -0400 Received: by mail-pf1-x42d.google.com with SMTP id b75so4165190pfb.7 for ; Sun, 25 Sep 2022 04:31:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=2+1alW6pcV3s50DFLFvhmZFtyW2mHcuX13PJl/8tAGE=; b=O2fhrHyvNhkWsZFel5Gyd/i8yon/slS7ds0ao06mBc9tnhGQKVzndLeCtG8i9fA36S QMNp1ZJVyvQF3EB/golHDF80ALRBC5IMrD4sVH0snIxkRv2QrOJs1xX6HXzKRYaXdrD4 +wqdnkRiNb0o3qwfHFnfQ1bH7MdzVmCWtQpyCFkTkGCtQFDZ3WGHA1n9yKFoDBdLMx0z P0ciQViKcVeM3ap6JkTjS/O11aPfTqzrjLTjjbx0XL3dl3lH0tLrFk7x9dwnofquQj9b FyS/ULFHG8Du8l+L11usUn4ws344txev0KrncMGSlTIDPgohZFUQsA1/lNqIz7uO6xn8 mbiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=2+1alW6pcV3s50DFLFvhmZFtyW2mHcuX13PJl/8tAGE=; b=SVrgzZslYPBqkbLMO9QR5LYENPse/s/a63vwyrVYa3HJtRX7W69uIhiKSG9Zfw92Y/ JJmml3EO3sF5jln9+yiju7kbfiPzfOULpCTrfpLUW7bKV4ri5Q1oUX7Nl+vaKmPo1Z0J 5pNxgAYKTYVShQyXl3S82sfcG8HYxhc5EGKPQFwWgNt6cpCam8/f9WL0rtF0rvOrEQCz CP1OITs3mDQ/9KJtofuBBRYBAYoSrBIHOV+cccye+iT1/SfPT08vNWCGO8mvIqMQvt5X hzbh1KuvPGiEGKF9z32yz9DF92GF8YRf5MYQUI+qdXbd62sL5ijyTohFCf1Rt4f2bVhL UQeQ== X-Gm-Message-State: ACrzQf3/BOFiyzZp8dX/U7CPLd4SLoggUKB/hPnArPX5jErCrfS5lBlm 1X5MQ57/sooiez+3MrzjBnm0L3AJvus= X-Google-Smtp-Source: AMsMyM7ugtQ09jHGR73qPmAw5sKaunU+7pHSeKpyokgpQ8bKO8pxLat/btIF05FHZqfL6esn6hAwLA== X-Received: by 2002:a63:87c8:0:b0:43a:c2e4:efcc with SMTP id i191-20020a6387c8000000b0043ac2e4efccmr15732582pge.410.1664105472181; Sun, 25 Sep 2022 04:31:12 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:11 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Alexander Bulekov , Bandan Das , Darren Kenny , Laurent Vivier , Paolo Bonzini , Qiuhao Li , Stefan Hajnoczi , Thomas Huth Subject: [PATCH v3 11/54] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:49 +0800 Message-Id: <20220925113032.1949844-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42d.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/qtest/fuzz/virtio_blk_fuzz.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/fuzz/virtio_blk_fuzz.c b/tests/qtest/fuzz/virtio_blk_fuzz.c index 236d078cc8..a9fb9ecf6c 100644 --- a/tests/qtest/fuzz/virtio_blk_fuzz.c +++ b/tests/qtest/fuzz/virtio_blk_fuzz.c @@ -181,10 +181,10 @@ static void drive_destroy(void *path) static char *drive_create(void) { int fd, ret; - char *t_path = g_strdup("/tmp/qtest.XXXXXX"); + char *t_path; /* Create a temporary raw image */ - fd = mkstemp(t_path); + fd = g_file_open_tmp("qtest.XXXXXX", &t_path, NULL); g_assert_cmpint(fd, >=, 0); ret = ftruncate(fd, TEST_IMAGE_SIZE); g_assert_cmpint(ret, ==, 0); From patchwork Sun Sep 25 11:29:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987915 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 8D765C6FA82 for ; Sun, 25 Sep 2022 11:58:08 +0000 (UTC) Received: from localhost ([::1]:38566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQGt-00083N-JF for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:58:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrD-0002ia-Tv for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:36 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:42593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPr3-0006KO-RT for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:28 -0400 Received: by mail-pg1-x531.google.com with SMTP id t190so4208012pgd.9 for ; Sun, 25 Sep 2022 04:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wj7NFE4UEqf1bXdPeQ070iFkhBShBJOjWt5P85H+XeI=; b=G9koeUdrjJZrYH2/Ca1dkiSWRbpTJqAwlZb30pYM6dopeGaOMDCUEPs124Ui/H6ii4 L+Q2YWqhlUOUtlTdtd+apOOzeFgmPU+irSPwCVINPPj9wv8t27yKHeYh+b/HptVt7s9T 9vEwaCjYaEy51JNpOyWZx/+2dQkBfMbAAlyTRc0FxTVThrx+jEVhu2D9bwZTbJzh8zSj 2FAmeorrbeUAe1fsM59Wz6t91JQ0fhjPAbjz0OWJW/RGdPPsqHgeKrYruISWJ2q9Lngm +l/Iz7jCgmc/mgC3qWQwwEuwFTCAsSsHGa5Qe7088U2BgF/46oSWgvIu79IdNtpbOpQi CVYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=wj7NFE4UEqf1bXdPeQ070iFkhBShBJOjWt5P85H+XeI=; b=AGw7jP+O6tNe1rkY6pByW3It9leb/M9nBrQl6iMlVN8nMbTnkqqk1gS6GjNn7jyqSh pXt4EG2vMN9T/BWRjcjCJCXcIjL2M7s9UkKW/RfK/6XnL5qaTxQLz0VV5RGUy2+IJcsk 4ym/FwpxxQGw4CbBEhUoiQPnYMTr9MiVrdMlAoiwRANV4EZMMZzSQ7psWqF8sf76qHO0 l60AFU9BmO3GBmKvMy05Hyf2Hijx5rLbaMTHEcU/+sDPOTAYNR4AZaHgHxtUPlAzKtUL I737EWooN0szoR/uuMgtvKHTnsiLqblhB5Fu53vATxqqKU/BeqYNY9NNqIWEv3TNRGeR Sycw== X-Gm-Message-State: ACrzQf3cvLfQuILST/jvOaIOgfYKEskneGdg+p7QMQZkc9TgonRJz9iv ge1jyA5oyQfMiQAKcP4EzuvaMiRM2Ds= X-Google-Smtp-Source: AMsMyM47LSROCIetAPTVF/+L8i72Uf/hK9p7yfvfyMuct7Trnop1goAV/gPyjOJ9UoU1Cv4Rd+Rb5Q== X-Received: by 2002:a63:1508:0:b0:438:eb90:52d1 with SMTP id v8-20020a631508000000b00438eb9052d1mr15639271pgl.252.1664105474639; Sun, 25 Sep 2022 04:31:14 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:14 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 12/54] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:50 +0800 Message-Id: <20220925113032.1949844-13-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x531.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized - Use g_steal_pointer() in create_test_img() tests/qtest/hd-geo-test.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 413cf964c0..455bc5db5c 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -27,20 +27,19 @@ static char *create_test_img(int secs) { - char *template = strdup("/tmp/qtest.XXXXXX"); + g_autofree char *template = NULL; int fd, ret; - fd = mkstemp(template); + fd = g_file_open_tmp("qtest.XXXXXX", &template, NULL); g_assert(fd >= 0); ret = ftruncate(fd, (off_t)secs * 512); close(fd); if (ret) { - free(template); template = NULL; } - return template; + return g_steal_pointer(&template); } typedef struct { @@ -422,9 +421,8 @@ static MBRpartitions empty_mbr = { {false, 0, 0, 0, 0, 0, 0, 0, 0}, static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) { - const char *template = "/tmp/qtest.XXXXXX"; - char *raw_path = strdup(template); - char *qcow2_path = strdup(template); + g_autofree char *raw_path = NULL; + char *qcow2_path; char cmd[100 + 2 * PATH_MAX]; uint8_t buf[512] = {}; int i, ret, fd, offset; @@ -468,7 +466,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) offset += 0x10; } - fd = mkstemp(raw_path); + fd = g_file_open_tmp("qtest.XXXXXX", &raw_path, NULL); g_assert(fd >= 0); close(fd); @@ -478,7 +476,7 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) g_assert(ret == sizeof(buf)); close(fd); - fd = mkstemp(qcow2_path); + fd = g_file_open_tmp("qtest.XXXXXX", &qcow2_path, NULL); g_assert(fd >= 0); close(fd); @@ -506,7 +504,6 @@ static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) free(qemu_img_abs_path); unlink(raw_path); - free(raw_path); return qcow2_path; } @@ -714,7 +711,7 @@ static void test_override(TestArgs *args, CHSResult expected[]) for (i = 0; i < args->n_drives; i++) { unlink(args->drives[i]); - free(args->drives[i]); + g_free(args->drives[i]); } g_free(args->drives); g_strfreev(args->argv); @@ -867,7 +864,7 @@ static void test_override_scsi_hot_unplug(void) for (i = 0; i < args->n_drives; i++) { unlink(args->drives[i]); - free(args->drives[i]); + g_free(args->drives[i]); } g_free(args->drives); g_strfreev(args->argv); @@ -927,7 +924,7 @@ static void test_override_virtio_hot_unplug(void) for (i = 0; i < args->n_drives; i++) { unlink(args->drives[i]); - free(args->drives[i]); + g_free(args->drives[i]); } g_free(args->drives); g_strfreev(args->argv); @@ -987,7 +984,7 @@ test_add_done: for (i = 0; i < backend_last; i++) { if (img_file_name[i]) { unlink(img_file_name[i]); - free(img_file_name[i]); + g_free(img_file_name[i]); } } From patchwork Sun Sep 25 11:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987912 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 E3346C04A95 for ; Sun, 25 Sep 2022 11:56:55 +0000 (UTC) Received: from localhost ([::1]:42218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQFi-00056R-Kg for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:56:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0002ja-F3; Sun, 25 Sep 2022 07:31:41 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:44841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPr5-0006KX-6R; Sun, 25 Sep 2022 07:31:36 -0400 Received: by mail-pj1-x1034.google.com with SMTP id i15-20020a17090a4b8f00b0020073b4ac27so4300374pjh.3; Sun, 25 Sep 2022 04:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9nzx3zjt1kod4XqM/j/+23LNx+kI/TyLGdD65qxmPHA=; b=qh9+xWZTZsahhWsuw+fAzNxkydMBkRpxxRNuQ84c9UiAs+MyYXBYF7Dn+2X/ZjujbB zaoxtb03v631ZXIgQUon6Z4p+FGTfGuaYzYsWzSgPr2La54FiHjQ/+zFw9QWOCpUX/xw 9q1iXa9ikB+45HGQ5/3H78WJ4fWTd2qgPJnDL26vr3fHA85YhlGOuwPqHxECO7Io6xkO SvikYaWHq+MylsU/H7dayyn+TQ7CBlrspTaZ14czlWJ9xhFyiaD9fma0RQ9J2gCo+ibb J4Jj3y6F9AoAjUsL2s40HlOHJnU3yMke0sX2WcEqz34XUnmJBwLCmDx5c6ntMztm7nxy Gq8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=9nzx3zjt1kod4XqM/j/+23LNx+kI/TyLGdD65qxmPHA=; b=AJPrumFqFJ1AV0S6ZNakFenW8uSpoJEEkBTzoDTNA8v3Hu6YAufZaWf3SZOSjlVbiD JJiuVNqYydGPNFSZ4h6O2FVmDTiLBx8VBAW1EIIqw2jEzuniXdiK2TVS+XiykMlc4M8F A5vlt5Gz6DLz4i7ifoEhie3h+notQe5iHSfeJ4rnGMt8Q1/w1SpuWRBsPxvWodn8NIT3 iK1B2CykxEQn4dXlr2/1x143thzDnjZ2NtUoQn8WUD888YEfjYap0nDoiHfj6F08DKm6 gkydJj8f8X7YEt4MiBa61W5l0jjVPoxK6dCshcI8V8/mplnMoFGoL+CTzzm1+32/sdzp zFZQ== X-Gm-Message-State: ACrzQf2rsX0gFss8AXJpBoXtgp6WnAsMAhJIj+RObGfTc/Di5djK3aMB VlfSKeMeQPRwOaHEgNnfPBeWq/bJHP8= X-Google-Smtp-Source: AMsMyM4eB8CwrjEmFjARLBF0NWCyIWEQDuAwxQiZXkDem69G+xcUDez/LNxuLWzwNTCym5jVYWx7OA== X-Received: by 2002:a17:90b:1e0d:b0:202:91ec:e167 with SMTP id pg13-20020a17090b1e0d00b0020291ece167mr19014437pjb.174.1664105477259; Sun, 25 Sep 2022 04:31:17 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:17 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 13/54] tests/qtest: ide-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:51 +0800 Message-Id: <20220925113032.1949844-14-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1034.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/qtest/ide-test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c index 5bcb75a7e5..25302be6dc 100644 --- a/tests/qtest/ide-test.c +++ b/tests/qtest/ide-test.c @@ -121,8 +121,8 @@ enum { static QPCIBus *pcibus = NULL; static QGuestAllocator guest_malloc; -static char tmp_path[] = "/tmp/qtest.XXXXXX"; -static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX"; +static char *tmp_path; +static char *debug_path; static QTestState *ide_test_start(const char *cmdline_fmt, ...) { @@ -1015,12 +1015,12 @@ int main(int argc, char **argv) int ret; /* Create temporary blkdebug instructions */ - fd = mkstemp(debug_path); + fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL); g_assert(fd >= 0); close(fd); /* Create a temporary raw image */ - fd = mkstemp(tmp_path); + fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL); g_assert(fd >= 0); ret = ftruncate(fd, TEST_IMAGE_SIZE); g_assert(ret == 0); @@ -1049,7 +1049,9 @@ int main(int argc, char **argv) /* Cleanup */ unlink(tmp_path); + g_free(tmp_path); unlink(debug_path); + g_free(debug_path); return ret; } From patchwork Sun Sep 25 11:29:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987909 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 DA203C04A95 for ; Sun, 25 Sep 2022 11:54:13 +0000 (UTC) Received: from localhost ([::1]:46938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQD6-0008Ct-TZ for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:54:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0002jc-Gc for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:41 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:39536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPr8-0006Ki-Md for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:37 -0400 Received: by mail-pl1-x62c.google.com with SMTP id f23so3929103plr.6 for ; Sun, 25 Sep 2022 04:31:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xSaeu3bMM0haLGRmrvVDTyuVh+uN3dsUBZJf+5l/M5A=; b=NKLUKPCdqqOgJf9p53DOUSaPLKDNdfMlQdi9QRbvSxPLjSJ8ScUh6ZGl9Q6kx2EeIY uLwt5qiIo6wpDdZp/iKyw9dg4S9eH3ETV0eCbZS9EjUY5Lhug/pKNMxZS2tOivmZUNLi 16Uw4OVGT637TzMe50UocZKQuaFlsiyRpTzUoSxO8LaqgIvyt4Ay3TGq6OGgfXbr25to rpzvqo0CD5tcr2wAqzzfSLFUgf4AdtsFNoTsguUoZffxQxFlV8b0zo4dmP5vOepDPmsc LYT6gIdJCrEn+chgV9HFgSOFE6sZQctimRfD59/LrBB0QCRQnQiyij3qGiHvhEWbaMlf MBHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=xSaeu3bMM0haLGRmrvVDTyuVh+uN3dsUBZJf+5l/M5A=; b=2K9gpq+Hbzpc+ja7t3iA8qOGMjbaYj5ymAPwFnJPwHo4zy62lmIj3NifgZGCJzljZF L0pQ0HfCfslnf1bH7cbq77p2stn/e06MPWJpyyrPL1wgZ0kc/7Sicby0cxJ835GNBBeI UP+ODpn+giWmG8xcsBR6ZPM5oDpKGwjX88ypG0sPBBlYRh7ZnFLa8OmX4HgYFieeZHpk zb2KHKp2dwJWq50SnL+egtj/QdbJ+coJAtA8HGL8xw5Qxo+odEa5w72efQzWskS9QgdB EeQr99nFX60EwvjRkmoIVpuHIRGe4CJzTAik4FxM0cITbVhzghQ7VGP41bxC/vE7ruBs hfpA== X-Gm-Message-State: ACrzQf01mKo2CWs6rKKojGPf+s1/zgcmc4zRWbpWbLlr56g672gieC88 TU3swcEoyM+PuRtcIAS/sUiHqsfN600= X-Google-Smtp-Source: AMsMyM4DbDp9AKe1BDF/g3DryP32wT/Vb6yDv94+lee825jtBPEaTMuVUzehG+oPvA39Oj/YT5VVvw== X-Received: by 2002:a17:902:f545:b0:178:b4c3:eab6 with SMTP id h5-20020a170902f54500b00178b4c3eab6mr16831566plf.148.1664105479913; Sun, 25 Sep 2022 04:31:19 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:19 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 14/54] tests/qtest: migration-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:52 +0800 Message-Id: <20220925113032.1949844-15-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng --- Changes in v3: - Split to a separate patch tests/qtest/migration-test.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 4728d528bb..029c4f3a6a 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2434,7 +2434,6 @@ static bool kvm_dirty_ring_supported(void) int main(int argc, char **argv) { - char template[] = "/tmp/migration-test-XXXXXX"; const bool has_kvm = qtest_has_accel("kvm"); const bool has_uffd = ufd_version_check(); const char *arch = qtest_get_arch(); @@ -2462,9 +2461,10 @@ int main(int argc, char **argv) return g_test_run(); } - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("migration-test-XXXXXX", NULL); if (!tmpfs) { - g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno)); + g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs, + strerror(errno)); } g_assert(tmpfs); @@ -2589,6 +2589,7 @@ int main(int argc, char **argv) g_test_message("unable to rmdir: path (%s): %s", tmpfs, strerror(errno)); } + g_free((gpointer)tmpfs); return ret; } From patchwork Sun Sep 25 11:29:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987923 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 3A07FC04A95 for ; Sun, 25 Sep 2022 12:06:38 +0000 (UTC) Received: from localhost ([::1]:57612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQP7-0002rs-5C for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:06:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55934) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrK-0002m8-PU for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:42 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:45853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrD-0006Km-KI for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:42 -0400 Received: by mail-pj1-x1036.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso4291911pjd.4 for ; Sun, 25 Sep 2022 04:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nM74FruDmU4z4IA66IfyAjmi4E35/GiRsCvNkBTqFAc=; b=KCPNTydWPmJ5bBn1MGb6t5mz5qm7zt5MZ+/qPPFcPvsc9+cKfuFzWn4LstvqNxpFdo h6bJDnu6PwnFSCelrUjmiWA/L5fqrYvOZxKapd4jF1Mwz0CBPQxJBYmOZ40yjaf98a33 9N0suiAtIsw67i8co48UxP/sBaaqUd83dMjqHM+myoiwnqQ20qACrNKbY3yE4qqj7TVR cB304e9y4pRAHe24hZWZcYCRrn0hzajUagff7c4Feg04KT23krYiz0d80NrzT5MCi8vC RTjxyUp0Suec+TgINcaXAtRZjBJYlQWmETFmFRsfkaiitM8jQEXdNkRkDZs9bxwetEX/ ku6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=nM74FruDmU4z4IA66IfyAjmi4E35/GiRsCvNkBTqFAc=; b=WU3VCYCnPD18EenOGCtdjSbWx6YQfR3DroKv//HQpibBd1UpAUkQjQUd7L+EqCVJRn LdRhX5w/WJSRvpt1e8khIdHnHTJvGebJjm31SeWvCM6z9BUlzPhJtEyiQxGvVX/Z72Dl Osu2sMeydlmTldwOHBtYKuj18pkj2ppEqiK2ONEH/+o6IkAZ/1YfcayhrJGGVKLqepf5 Q4GhUIuitPjVHQdR+mEFNA8OQmWhpHYvZ+rgqr38wztIPMuwefUEUnjTxXp7DGSjlMXQ k+qKhEbDU649Zo27rZamkzDHeO+HJiIqyd83LRNbRuZcpyDBNe6RXbme9C9gFXbGsGNS LVUw== X-Gm-Message-State: ACrzQf2MfZ47Mo2OyP4+93djZmWpQ3wKSPvnurX+brhLoJLqGIN6Ub9W bAVYot0m73agGY2/mZgBzjxaiw9qWpI= X-Google-Smtp-Source: AMsMyM4qo0ajlMcNaTJH4aKQGZG/PYlVn5qBa1tBQuluWkvMV/S1mMaeX2DuOgGlVtvxKx1+ILygCQ== X-Received: by 2002:a17:902:7c0d:b0:178:a6ca:1dbc with SMTP id x13-20020a1709027c0d00b00178a6ca1dbcmr17304140pll.115.1664105482181; Sun, 25 Sep 2022 04:31:22 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:21 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 15/54] tests/qtest: pflash-cfi02-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:53 +0800 Message-Id: <20220925113032.1949844-16-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1036.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng --- Changes in v3: - Split to a separate patch tests/qtest/pflash-cfi02-test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/qtest/pflash-cfi02-test.c b/tests/qtest/pflash-cfi02-test.c index 7fce614b64..55890b7d95 100644 --- a/tests/qtest/pflash-cfi02-test.c +++ b/tests/qtest/pflash-cfi02-test.c @@ -56,7 +56,7 @@ typedef struct { QTestState *qtest; } FlashConfig; -static char image_path[] = "/tmp/qtest.XXXXXX"; +static char *image_path; /* * The pflash implementation allows some parameters to be unspecified. We want @@ -608,6 +608,7 @@ static void test_cfi_in_autoselect(const void *opaque) static void cleanup(void *opaque) { unlink(image_path); + g_free(image_path); } /* @@ -635,16 +636,17 @@ static const FlashConfig configuration[] = { int main(int argc, char **argv) { - int fd = mkstemp(image_path); + int fd = g_file_open_tmp("qtest.XXXXXX", &image_path, NULL); if (fd == -1) { g_printerr("Failed to create temporary file %s: %s\n", image_path, strerror(errno)); + g_free(image_path); exit(EXIT_FAILURE); } if (ftruncate(fd, UNIFORM_FLASH_SIZE) < 0) { int error_code = errno; close(fd); - unlink(image_path); + cleanup(NULL); g_printerr("Failed to truncate file %s to %u MB: %s\n", image_path, UNIFORM_FLASH_SIZE, strerror(error_code)); exit(EXIT_FAILURE); From patchwork Sun Sep 25 11:29:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987908 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 18A06C6FA82 for ; Sun, 25 Sep 2022 11:54:08 +0000 (UTC) Received: from localhost ([::1]:47646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQD0-0007jZ-Sv for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:54:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0002jb-Fw for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:41 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:37572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPr5-0006Ks-0W for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:36 -0400 Received: by mail-pf1-x436.google.com with SMTP id a80so4178780pfa.4 for ; Sun, 25 Sep 2022 04:31:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5qjVxtNqYJcB9xh5QVsfjKrkZmQUDej/8jaQ07ygeG4=; b=dUP8NSpP3Uw2ZDEQoL3vIwnDCFYFDntCksNF+bs4Awr7QFRT+oZPcHm9nKHo/2+Dca zUztCUGIgQyS4xBZvzn10B1Kahonrrh5Fs68x671HYWw1yHVNYH89wTpToUcn5+146aY OMqzttrJKPsrU5wEQcVpwCNE0hNrQA8nLc6Jh0PpuvmINE0We9thkCFngOXhXaCTeUpL pYG1aJSchB2e78cbjVvhvyhirTy6OZcGec5ckFYRZAr58UmGS79jZ5yFvBP5nKvwu8gh Uxqvf9ISz5YKXxrIo+5jWsvWv2TvWI7xO/A+Z6/d0YxP1PQjAGhHe3JtfQ4fZE2ORXQh nXrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=5qjVxtNqYJcB9xh5QVsfjKrkZmQUDej/8jaQ07ygeG4=; b=uqlARiKN4Y1RWJVEabUQSnozNlcnWKTFLVES8e5FmGkh88j/JRQqxD1AUlMzpiEE8a T3x8CBI2fWhocmMGh5abk5ReLzFpAoxmH10Sx8M+HAAXTcfV/UH+UO6DWsOJVuzNabK1 PB7YbbcP/N0YY/BybZOzOeVhUm9YHoyAGmwIdQXb1m2iMwd8G9w0bouTuyTO6kI9wDI0 vvCPKcsWHp452loqn2frpXTxqgGDnGnx+foL2w4JHs6D4970VRkuLCq4l5w7a1RY8jKP fcnTSzhOLYlSlOlOvdidw3yg+qgRluHKDxPhsT1+vwWvZj5xwQDpe7d8iYBsEywRdLm3 F7HQ== X-Gm-Message-State: ACrzQf06ZYfQobCW+4/J1G3M5zxfvLs6UArpGjFHSoD1qjjeK6C71Kkl qleZ/qV0ndaPT0Cx+21JTBUhkmG4niw= X-Google-Smtp-Source: AMsMyM6w+C2GK3eE0r2aG17P0qiipC+fdcKkohVFP/SHK84JvneX1GUh70RJh9jQ78YQYznPUIAa2w== X-Received: by 2002:a65:63ce:0:b0:43a:2103:b7b8 with SMTP id n14-20020a6563ce000000b0043a2103b7b8mr15903976pgv.59.1664105484759; Sun, 25 Sep 2022 04:31:24 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:24 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Markus Armbruster , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 16/54] tests/qtest: qmp-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:54 +0800 Message-Id: <20220925113032.1949844-17-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x436.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng --- Changes in v3: - Split to a separate patch tests/qtest/qmp-test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index bf7304c7dc..0fa00c12dc 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -161,12 +161,13 @@ static void test_qmp_protocol(void) /* Out-of-band tests */ -char tmpdir[] = "/tmp/qmp-test-XXXXXX"; +char *tmpdir; char *fifo_name; static void setup_blocking_cmd(void) { - if (!g_mkdtemp(tmpdir)) { + tmpdir = g_dir_make_tmp("qmp-test-XXXXXX", NULL); + if (!tmpdir) { g_error("g_mkdtemp: %s", strerror(errno)); } fifo_name = g_strdup_printf("%s/fifo", tmpdir); @@ -179,6 +180,7 @@ static void cleanup_blocking_cmd(void) { unlink(fifo_name); rmdir(tmpdir); + g_free(tmpdir); } static void send_cmd_that_blocks(QTestState *s, const char *id) From patchwork Sun Sep 25 11:29:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987919 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 890DFC6FA82 for ; Sun, 25 Sep 2022 12:02:24 +0000 (UTC) Received: from localhost ([::1]:51108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQL1-0005Ru-Eb for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:02:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0002jd-Ge for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:41 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:43995) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrC-0006L8-Sz for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:37 -0400 Received: by mail-pj1-x102c.google.com with SMTP id g1-20020a17090a708100b00203c1c66ae3so4330639pjk.2 for ; Sun, 25 Sep 2022 04:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=qbVb74P1/xkJ4BQfOMUf3tDqORu0pugyYl7K9BClc2s=; b=DcDQELU+Y1ihIZYe+ek00BuygNqgMTcMfOR7srtmuA8wYmc9KyE7NJnTKBYg61+8f7 7bw1aUDsjUihmoc1yh8MNq3vJ/nX/OW+MnceRaMh0ixHlOJhg9RBONAeP6tVegy2g5um 045C2bxvpB0BDb7Yp+wbaK+9UvExTspGCr/irV7ZaVeVwxFVvLuBxCkJWbi+2gqDM92B A9TmC0Jb7MlzpuEiuPKm987V3rxHPYz8sKAXNnKr85gKxNp0pYIpnkzFHt86D0Qsg8nN nYqOSmlHwaPKpzofVAlUrt01wyiKaZmBdZIBr+zhPfdBiKvSPdP4o3L9mQriHDhm0VEy bYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=qbVb74P1/xkJ4BQfOMUf3tDqORu0pugyYl7K9BClc2s=; b=W1f230STylcrfN5VUWzDuaHe5PrFvQ6FDVDC7L0yMst0P7RmbDCrzWJJ3uwMm3AoGb 8O599YMRagh2j2wjFsb3YehfoErqCFXSnw5X1Ofk3IgM8ZOclkLIzoWN7bu7hvndhnFZ 52DNkub9opF+La97OYIOjvO7+PaB+IMc3u8rCBQ9HHO6sD1gC2NhxLGEF/rxrR6bhCYC esZ1YYCn4T9bTF+uR4hf1UTt0y4XqpC1QcMXHAc2y/Argd0uFx+lRKkbRqogUPG8Kjs1 QS0l5PFzBopcc0sviCVx47fPF0uS/epVTa7oC8GS736/7mCRQxcNesKac+8wXrrUiNXz zvMg== X-Gm-Message-State: ACrzQf3hSAIk5vc8Wq32Sw0z5Njhuq9QdzfVXZpMM1VcWdWgGr8QAYTy P/OvdTypYMwHnF/mpkQJU3nmoU6hgMw= X-Google-Smtp-Source: AMsMyM5wHeBmqBz7sLyXg1EXlAMqHL/aA9nzXrPMZeVgkPKi+8ZP6W5x+rAXDnNd/Ig+16OH0HTmfA== X-Received: by 2002:a17:90b:314b:b0:203:41c:2dbb with SMTP id ip11-20020a17090b314b00b00203041c2dbbmr19245573pjb.18.1664105487289; Sun, 25 Sep 2022 04:31:27 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:27 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Coiby Xu , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 17/54] tests/qtest: vhost-user-blk-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:55 +0800 Message-Id: <20220925113032.1949844-18-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102c.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_get_tmp_dir() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/qtest/vhost-user-blk-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c index a81c2a2715..07a4c2d500 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -841,7 +841,8 @@ static char *create_listen_socket(int *fd) char *path; /* No race because our pid makes the path unique */ - path = g_strdup_printf("/tmp/qtest-%d-sock.XXXXXX", getpid()); + path = g_strdup_printf("%s/qtest-%d-sock.XXXXXX", + g_get_tmp_dir(), getpid()); tmp_fd = mkstemp(path); g_assert_cmpint(tmp_fd, >=, 0); close(tmp_fd); From patchwork Sun Sep 25 11:29:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987934 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 63A98C04A95 for ; Sun, 25 Sep 2022 12:15:47 +0000 (UTC) Received: from localhost ([::1]:39132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQXy-0003ZS-II for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:15:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrV-0002wE-47 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:57 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:52864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0006LF-6P for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:52 -0400 Received: by mail-pj1-x1032.google.com with SMTP id go6so3958617pjb.2 for ; Sun, 25 Sep 2022 04:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=9yPbmRSXJkOB6gGFBYdiy2ri+l1NC0dZ3NCtbtHGDjE=; b=Q14cdA6JVK65YzY2nHlWeyow4HhcIUl2rkPWddktvRreNFKNRGjQn3CgihNOhlsG3H QeiE34WkSTefp3M7yJsNw6C7A7KbWbNW8dzjmYdVLZ057EAmSTKQCmHCIjr1DzsuucZ4 tg0Aztoz2pUh9kD/LNn1VsA1FQnezr/zcNudAhyFy52EqcFANE2c2BKkwsUu7P35eXGk YtNQaYt5hJpR3jaSfAtlIEplUrtff5IWM86kbRvKmLFUi8epAARnYvuPG3LnhYx8f/U7 wXm2cXsJEqjn6v7LNdXPP1wn8pWSUFC8lFZyXNkn1ewN9y0bBrkYnJ8Xi+FZKdkhyCni hFVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=9yPbmRSXJkOB6gGFBYdiy2ri+l1NC0dZ3NCtbtHGDjE=; b=hDijYrjNiXppCqNApmL68kiyoXA9pOiVhR8xjhiKDbV56uiC9JxrX1jmKDEESfuPQ2 c76R2fiAHAQEYtEz2GVRoERiImbiGB/sbhL7kwsH9/7ZcSOc96AhPVQoP6tdwXDpgT9j cTjTbElgHSwXae6l5+FzmoNi0xAuto0OO0lNrVqT6yiLHe5KlOCrIoJN8ypyhEOi4Hqr ZL8nxGe1qQriEODg3hfiqJ7HaQJnOWhyCWZrIsBxhcAbajcbBFfQvFnMaN944EQkDgeU yVCjhXxrsbDVBM0IqB68H2AAZJfqtLaPYWMXQB7ezJgn3ZrCenHAnhoaKXHBxe2tya7y QseQ== X-Gm-Message-State: ACrzQf32X8Ak3J355Z0dimIEfbOXt0/G1FvEmYXl4jehS3TT3oeneZmR M5RAHSsGRiAdV5ZpsmAeWA2JBVb929o= X-Google-Smtp-Source: AMsMyM5k+nKdnvmABKAKtIbmNFM3c+wYNTGGpv04YZrIMsIiHREjKSu0sYAEj1T6srGWF/JvjU18AA== X-Received: by 2002:a17:90a:d982:b0:203:814d:dde6 with SMTP id d2-20020a17090ad98200b00203814ddde6mr31117124pjv.66.1664105489649; Sun, 25 Sep 2022 04:31:29 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:29 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:56 +0800 Message-Id: <20220925113032.1949844-19-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1032.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/vhost-user-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d7d6cfc9bd..448fda3e7f 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -482,8 +482,7 @@ static TestServer *test_server_new(const gchar *name, struct vhost_user_ops *ops) { TestServer *server = g_new0(TestServer, 1); - char template[] = "/tmp/vhost-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs = NULL; server->context = g_main_context_new(); server->loop = g_main_loop_new(server->context, FALSE); @@ -491,9 +490,10 @@ static TestServer *test_server_new(const gchar *name, /* run the main loop thread so the chardev may operate */ server->thread = g_thread_new(NULL, thread_function, server->loop); - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("vhost-test-XXXXXX", NULL); if (!tmpfs) { - g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno)); + g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs, + strerror(errno)); } g_assert(tmpfs); From patchwork Sun Sep 25 11:29:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987926 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 AEA27C04A95 for ; Sun, 25 Sep 2022 12:09:16 +0000 (UTC) Received: from localhost ([::1]:46586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQRf-0000og-PR for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:09:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrM-0002qH-4P; Sun, 25 Sep 2022 07:31:44 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:38857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0006LJ-H4; Sun, 25 Sep 2022 07:31:43 -0400 Received: by mail-pg1-x535.google.com with SMTP id 129so2789309pgc.5; Sun, 25 Sep 2022 04:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=m9AGKNA/tIixBbJopd2bItPygulGLgdib3k9UNSIIX4=; b=aSCopK1VJ1oG4iLuvwcID5s1rbh6d8iY3538bY9N22Bm/5bzEXeHRHlPfigLAftD2q avFOsKLrf+YyuhC6vVgZQrbkBXJ4QIDEqPL3YbJabv6c4hCHJTRgOhoMdAFRq5CnarQD DLA2xFFhzjjYqEpktQe1//T/IlxRIhTSdm/63FapWJ6gi+OpSegiQZikKtAVzIcWFSqq l46CXuyAVPKkyF2a+ZnqNNGAlO6z2pVHeKMMjltblZ6rKtNI1FSXbWRAQY8WKtgYTBb8 6xGvpyRPlDxUIIsI3NowNmc0CzVMpgDC4A1xYTpxGK+bxP+o7imJfpzH/aZof/8s4DS1 jgjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=m9AGKNA/tIixBbJopd2bItPygulGLgdib3k9UNSIIX4=; b=gvL7mfXiudRQJ4hRkuphdVtC2ZnOQK7dsTKY94pyJAgCdcynVuakKkhFSW084tqkx7 3Zn8fMBYuWaqhGUpwUhWouRul/oSwxWzrAYWaE3hiFFxhEmc/ZmzZcmVepuFwoYtgw5W YVDRbhw4rnp6v2FvFXxXAOkgvzzIrXptWXyTbUwYPMszIhzLis2mFEXBNN1bf6B7bvC4 ZsYHuoTpYcgrzRuxx38Pz0VfbijDElCnW/f/6RlMlQG6h/sXljrX885Ws/CbxnOXELRs 5hsDBrE0kCefKWhEmJ+tA+MqsZCXC6INuwDW1AtuiW1qb0lSFcRr3+DQuqjH1s/V3+oH dHbg== X-Gm-Message-State: ACrzQf2AwJFu0NzKAZTCWbIhidu110erbECTIYkuHO8pfG0z3kWRv/Pj 2S8jDklTSoEp09kap2H8wx32Dd3OAfU= X-Google-Smtp-Source: AMsMyM78BW32mt1q50K/AXEKe47/iaVReNfA9Er+hqB8I6vG9g9imbc2OyYamgrhz255w6sSxAuqkg== X-Received: by 2002:a63:20f:0:b0:43c:1ef6:ebd6 with SMTP id 15-20020a63020f000000b0043c1ef6ebd6mr13844323pgc.217.1664105492286; Sun, 25 Sep 2022 04:31:32 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:32 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Stefan Hajnoczi , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 19/54] tests/qtest: virtio-blk-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:57 +0800 Message-Id: <20220925113032.1949844-20-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x535.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/qtest/virtio-blk-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c index dc5eed31c8..19c01f808b 100644 --- a/tests/qtest/virtio-blk-test.c +++ b/tests/qtest/virtio-blk-test.c @@ -49,10 +49,10 @@ static void drive_destroy(void *path) static char *drive_create(void) { int fd, ret; - char *t_path = g_strdup("/tmp/qtest.XXXXXX"); + char *t_path; /* Create a temporary raw image */ - fd = mkstemp(t_path); + fd = g_file_open_tmp("qtest.XXXXXX", &t_path, NULL); g_assert_cmpint(fd, >=, 0); ret = ftruncate(fd, TEST_IMAGE_SIZE); g_assert_cmpint(ret, ==, 0); From patchwork Sun Sep 25 11:29:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987930 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 C85B4C04A95 for ; Sun, 25 Sep 2022 12:12:00 +0000 (UTC) Received: from localhost ([::1]:52368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQUJ-0006KP-Tc for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:11:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrM-0002q5-1Q for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:44 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:36432) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrG-0006LO-6e for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:43 -0400 Received: by mail-pg1-x531.google.com with SMTP id s206so4232887pgs.3 for ; Sun, 25 Sep 2022 04:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5zDG7Ny3LkxdeNWaqDhYiABIowN2pKfIq67zjjwVq/4=; b=QgnCuO3NhvxclXmeyb6qshj+/m4KyRrISJAyLt8H5kLyvy6nA2nGFrquGY5hay6flJ iUVmWBjAskcDGR9ZK0Ez5erbt28/PQeP1vzlBTasdNmRI8MnnJ0bFwMdKGZMqyicMeNq fN5zT8hdR6a6qNdcKRJkTQdC+u55P7yIpTQ3Qrf+PKCVIFJe7Ek4vdkyKKJaK7drhGrh AGMJhSgZ07mLaw0uJ38v8gqZN0+sYL3FEakxUnxk85oZJg2lkfaZE9mRNUNyJddZ2Yi8 zDrf4HWZ57S1Lw1YgYkDoSapMvr7WFAY7dz1rtwRhnnto5jpjVrE2LGcva3oWRFUfcFn VOCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=5zDG7Ny3LkxdeNWaqDhYiABIowN2pKfIq67zjjwVq/4=; b=g0G8vnZ5ETkoViM1vU6kp+RJ2ilF0Xj7lBZWU3zVXGn32v78EbsPnlLzpIw734PT5g 96EKwfvTARApdApP+8NtFosQEvWOiRomwHUKsbblz6Y8pMMj11otLTYqx9EQc+qCcxRI +3UZaEY0mw8wPoYxv6MtGfEGnGD6j2fvY+a+j5fnv1gbR0EfeAzNm18xAaaWVGwv3kHI 2zdXbqEaVRvtQhL2nokGunH+eatB0g4jGtO9JbyTtUL08KE3xPbpzyYv4jY6K09bWVkX shdwlN6Cz+TE8T2qWV9emDmwnVASW0inOTz0nOnfAd9ylUUHFVq7c1PFR8XDA8wMQUjn MShA== X-Gm-Message-State: ACrzQf21gGC7qezZNqkDKoxpQzgkkmLgqaPmFcOtVvdxC053BsoLrMuA YOftLMz/LV/3bcsgoAh9M11eh5TrKM0= X-Google-Smtp-Source: AMsMyM5029PkTWax31JH3MZ4vBK7E2iARxalIjXN2NXOremvq0evtswLuDjhMuOVpVXSvoyjQHPgYA== X-Received: by 2002:a63:d652:0:b0:43c:9566:5394 with SMTP id d18-20020a63d652000000b0043c95665394mr4561925pgj.536.1664105494933; Sun, 25 Sep 2022 04:31:34 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:34 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Fam Zheng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 20/54] tests/qtest: virtio-scsi-test: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:58 +0800 Message-Id: <20220925113032.1949844-21-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x531.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/virtio-scsi-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index 8ceb12aacd..ceaa7f2415 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -268,7 +268,7 @@ static void test_iothread_attach_node(void *obj, void *data, QVirtioSCSIPCI *scsi_pci = obj; QVirtioSCSI *scsi = &scsi_pci->scsi; QVirtioSCSIQueues *vs; - char tmp_path[] = "/tmp/qtest.XXXXXX"; + g_autofree char *tmp_path = NULL; int fd; int ret; @@ -282,7 +282,7 @@ static void test_iothread_attach_node(void *obj, void *data, vs = qvirtio_scsi_init(scsi->vdev); /* Create a temporary qcow2 overlay*/ - fd = mkstemp(tmp_path); + fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL); g_assert(fd >= 0); close(fd); From patchwork Sun Sep 25 11:29:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987910 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 76DEAC6FA82 for ; Sun, 25 Sep 2022 11:54:19 +0000 (UTC) Received: from localhost ([::1]:46940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQD9-0008Hl-H3 for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:54:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrM-0002qF-3e for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:44 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:50766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrH-0006Ll-Id for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:43 -0400 Received: by mail-pj1-x1033.google.com with SMTP id fv3so3993054pjb.0 for ; Sun, 25 Sep 2022 04:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=6WLhUrJWwoyaZltxXdwTFjHJ10oyCwX/30tJ/pG+zJk=; b=D4LPnJN11V8ZZSma2/DmCFBmZuWHf0YYiuzEfzpyxB3Rhyi25qLKOKYVj50361LB5U Yx97SLdcth5a2nCWKK+01zd7GiXN6WtaUsSgG1asyJqAxcHAT09BoJLBFRbsGntht/z/ C97jgowTELj4DLqGgmlos7oFH7iEddkSrxf9QTndk6JyG0lSqhi0/x+YQaZ38wkBpnOC +jFr1qv0qi7rS2tTyHf8aCJFfmDKyqog4mzE4Z2F9ol9xYMWykdqa2b8lzbLO+wbZKeb +kz1ucr3unUqurZNLS8OiKbR8CXyNlxQNQaC7qF3RsJQdUyJQDVeJNKjQM2MHaQZWxSA Lrag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=6WLhUrJWwoyaZltxXdwTFjHJ10oyCwX/30tJ/pG+zJk=; b=uYE6ppZeF5grIJVR5j1RL6SKYtBS6xPCj+OkrX4hrEjQTa2rPU8OzvUSoVODG0RFuB f5h9++rzDRJJe/EXm9xEMxRY4yxWVej86VdsoBZ34BfcVdIx/MMN6i6cV6MgiKdKWDcz HynzLxikbYdDO7+fd0PZUgL1ba/d+YTQ9CQ0X3t9vSy+WlHuBTX/hM+NAbDmaffJ3ccb t7ys7+upUEHE58Sboq5MoRPYtuYlueIf00W898Rz9pGHZrjv9Zr5xVIOMi3869StnCZW fzbtxdkUqrK+8d4dV79zqNKht18c3RL6RVqx5qJH8PYQKlu52AcC9NyletLxoU5A/cVW MhvQ== X-Gm-Message-State: ACrzQf19OmlhMyILoQ8hSxh3xM7N64z/Gqqft1Rx1m8HhYi7DyPgXaAA +H7yAYEavunkUhvDwhNvaTH2zSLb5D8= X-Google-Smtp-Source: AMsMyM7Xjw6O6vbzsyxF9vOvIxGSHyXKf8CAv8mzie4gIFmQ4mblzK8fbhSpXvR7CTRUI3PaglhU6A== X-Received: by 2002:a17:902:ec87:b0:176:d549:2f28 with SMTP id x7-20020a170902ec8700b00176d5492f28mr16984047plg.12.1664105497678; Sun, 25 Sep 2022 04:31:37 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:36 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 21/54] tests/qtest: libqtest: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:29:59 +0800 Message-Id: <20220925113032.1949844-22-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1033.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng The qtest library was written to use hardcoded /tmp directory for temporary files. Update to use g_get_tmp_dir() and g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/libqtest.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 7c9fc07de4..d8ffa0e7b1 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -265,8 +265,10 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) s = g_new(QTestState, 1); - socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); - qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); + socket_path = g_strdup_printf("%s/qtest-%d.sock", + g_get_tmp_dir(), getpid()); + qmp_socket_path = g_strdup_printf("%s/qtest-%d.qmp", + g_get_tmp_dir(), getpid()); /* It's possible that if an earlier test run crashed it might * have left a stale unix socket lying around. Delete any @@ -390,10 +392,12 @@ QTestState *qtest_initf(const char *fmt, ...) QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd) { int sock_fd_init; - char *sock_path, sock_dir[] = "/tmp/qtest-serial-XXXXXX"; + g_autofree char *sock_dir = NULL; + char *sock_path; QTestState *qts; - g_assert_true(g_mkdtemp(sock_dir) != NULL); + sock_dir = g_dir_make_tmp("qtest-serial-XXXXXX", NULL); + g_assert_true(sock_dir != NULL); sock_path = g_strdup_printf("%s/sock", sock_dir); sock_fd_init = init_socket(sock_path); From patchwork Sun Sep 25 11:30:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987906 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 E8853C04A95 for ; Sun, 25 Sep 2022 11:49:20 +0000 (UTC) Received: from localhost ([::1]:43272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQ8O-0002Zh-1O for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:49:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrM-0002qI-5i for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:44 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:45635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrJ-0006Js-05 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:43 -0400 Received: by mail-pl1-x636.google.com with SMTP id w20so3902209ply.12 for ; Sun, 25 Sep 2022 04:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=fcS3F/JfCp6zFQVQ4uOqfbe0hQm4j7AcaWC5M8e5occ=; b=euRMx6Y5Z7uUeLot3C2wCKUY/OwrBrvLPyjuzn+rHpljb3MCup1dcLN0uZm6Q9n3FJ JmiV5WaHJ2tvH3D5HGfstVCmPbJb6KnTS4bStkTshm0ETfnazkQSlnGzZHpvXxE+ob2F IbclPzv742VQX1xtKThyWMnKjIACZfYgF9r62c3P1Lm/swwnhcYBllvxXhvVwWz2T8Ad ZTfn/s8rkt2lvz9jjn6H0eEzCyKnb1iyBE7DFWvRxTogUslyfnnChauHk4YaynXe0lRw fPcI3KfnhfJ3hqMFV+Wf2XdDeQfeurJvQZQbSejgMpKcXVEgN0Q7FlkitGY08XgspIeR oi8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=fcS3F/JfCp6zFQVQ4uOqfbe0hQm4j7AcaWC5M8e5occ=; b=09ZWyu23qbEPcNPJg5tfv5heUAmSZHueDMMd03dBuM+babH92RehddSSUrAlob4vPt b1lDS5yAph8LlNjMewZSbbDdD0iYFEYu0h/e4Fvjp+G2I1urJrVFE3ODW2lydfVnm5yJ SV8MPwJ223/XOlvkIZcKXOOt04zfGSj07/d7g/ju74n9QkjB+IFMXGMoyeFjOpAE30ND zPmx1W9yLQMujVyIsFwuzXrRVtAjsCKyniWoOFHKQ3tuKDN6MQzfz8vuP5VA2Cndb2gK hWIx1IZY55Bh7TyYTQp2fLKtqM9u/GVsGlgY/BOeLnGpebyjQC974TSTvUDw5qzGx3/Y /3Ag== X-Gm-Message-State: ACrzQf3KUadBjswP4BERRQQ1Gb/bH/gMZp1Dooa2DyZA1G8BlOEUexoh DNquEc/O2jwpz7EYrRoMRDCuTfzEN9Q= X-Google-Smtp-Source: AMsMyM4wW9LZzEJWru1sZHKcvMf0C25Syg6MWKQOJqeeK/g9tJB1WE5i9QpR5kOZhoWleDK4cBTkKw== X-Received: by 2002:a17:902:d482:b0:178:1585:40b6 with SMTP id c2-20020a170902d48200b00178158540b6mr17435463plg.134.1664105499467; Sun, 25 Sep 2022 04:31:39 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:39 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng Subject: [PATCH v3 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:30:00 +0800 Message-Id: <20220925113032.1949844-23-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x636.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/unit/test-image-locking.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-image-locking.c b/tests/unit/test-image-locking.c index ba057bd66c..a47299c247 100644 --- a/tests/unit/test-image-locking.c +++ b/tests/unit/test-image-locking.c @@ -76,10 +76,10 @@ static void check_locked_bytes(int fd, uint64_t perm_locks, static void test_image_locking_basic(void) { BlockBackend *blk1, *blk2, *blk3; - char img_path[] = "/tmp/qtest.XXXXXX"; + g_autofree char *img_path = NULL; uint64_t perm, shared_perm; - int fd = mkstemp(img_path); + int fd = g_file_open_tmp("qtest.XXXXXX", &img_path, NULL); assert(fd >= 0); perm = BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ; @@ -117,10 +117,10 @@ static void test_image_locking_basic(void) static void test_set_perm_abort(void) { BlockBackend *blk1, *blk2; - char img_path[] = "/tmp/qtest.XXXXXX"; + g_autofree char *img_path = NULL; uint64_t perm, shared_perm; int r; - int fd = mkstemp(img_path); + int fd = g_file_open_tmp("qtest.XXXXXX", &img_path, NULL); assert(fd >= 0); perm = BLK_PERM_WRITE | BLK_PERM_CONSISTENT_READ; From patchwork Sun Sep 25 11:30:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987914 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 280E2C6FA82 for ; Sun, 25 Sep 2022 11:57:10 +0000 (UTC) Received: from localhost ([::1]:42450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQFx-0005uj-2T for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:57:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrN-0002re-Aw for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:45 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:35483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrK-0006Nc-Pi for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:45 -0400 Received: by mail-pl1-x631.google.com with SMTP id t3so3950840ply.2 for ; Sun, 25 Sep 2022 04:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OJRDzQX/DMg/UmxTVGA3PP9Zj/iY4BqjzFCS4YP7c5A=; b=clST+9dxP/LsJWnC3czzJqKlnsT4x+wDqYhY+nRknlfzoNTvxmLY9tfa8gbnfQDJw/ 2kBdWsvC86dsq83LMwiL/XVrhPEjg1oAlANFSBzKmI6YAC1q4iQlcs1JI/LJMgLdrZlH c2ACasq3N9lB3TifUuu7bsqMfU6/CrgbUvsEoC+yyNRCVbjLiT8v6JFAtXb3Wh7FI2DD JkefAQybAdwteMOuUd63gTKZRVj2ErnDMy8fyPrtkE7/lG7wzA6h7lS1KKAOcmKdUKX/ v2N9CTAB5dJI0rvf0zkDzj2+HjTgrtjJFP9DvnGew9yUrkxp89y6C3DgtJuf2Jg2KKMH X3jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=OJRDzQX/DMg/UmxTVGA3PP9Zj/iY4BqjzFCS4YP7c5A=; b=UZf/JxnVtdfiq1ZDe3r2Bn/9dj2rQrB0Qt5mO6DQCEbJg0RHfyQY/Matm423G7LWHw /4+CNN1gZJljvKZOCG+PeVCJHRV+yMuU8eZNCfS6w3KYFS2VYuZ454uujnVZMfHOQzcq I8N4VTsXspaSYqfOPs0Cv+d3p8p2WFwF2vn5ysNKOuPPD/QZUOSUcWRrPFmOnvi6OMIT o+CLNSR5uFZwlcvqz/l22klAJkzLCZWpUiqB/h/8nMuj8TU6NxyOxgsEBipqsmliQ8FT hSYp7xdd7CQjuHIdDNS+w01GUXZX39lY9Mrv6nky7OZwTFaYLuWAfShd3RxLKlDOhwjA +ipA== X-Gm-Message-State: ACrzQf2P6ZCx441F/tBw42W8ufYpdO5EXCXy+Mo8Xrisu4L1w91Gj75c gnDuTCg60I8jbJhXoSBShJU+XX9t2iI= X-Google-Smtp-Source: AMsMyM6N4i1QZwOy7KiuQRPfv3pOnIJhcxoGZoYKOk7pPnWmb+X/VRIhz96HY/HfMMf4MRR2CUE1pw== X-Received: by 2002:a17:902:6907:b0:179:c9bc:dd73 with SMTP id j7-20020a170902690700b00179c9bcdd73mr9041939plk.159.1664105501489; Sun, 25 Sep 2022 04:31:41 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:41 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Konstantin Kostiuk , Michael Roth Subject: [PATCH v3 23/54] tests/unit: test-qga: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:30:01 +0800 Message-Id: <20220925113032.1949844-24-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x631.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_get_tmp_dir() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/unit/test-qga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index b6ea7c7304..b4e0a14573 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -60,7 +60,7 @@ fixture_setup(TestFixture *fixture, gconstpointer data, gchar **envp) fixture->loop = g_main_loop_new(NULL, FALSE); - fixture->test_dir = g_strdup("/tmp/qgatest.XXXXXX"); + fixture->test_dir = g_strdup_printf("%s/qgatest.XXXXXX", g_get_tmp_dir()); g_assert_nonnull(g_mkdtemp(fixture->test_dir)); path = g_build_filename(fixture->test_dir, "sock", NULL); From patchwork Sun Sep 25 11:30:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987916 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 C5D62C04A95 for ; Sun, 25 Sep 2022 11:59:59 +0000 (UTC) Received: from localhost ([::1]:48932 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQIg-0002n5-R0 for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:59:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrO-0002ur-JR for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:50 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:52033) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrN-0006O1-3D for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:46 -0400 Received: by mail-pj1-x102a.google.com with SMTP id rt12so3963500pjb.1 for ; Sun, 25 Sep 2022 04:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=1YLw5d0z7vrk2yTXPwCxIPgCJCukpGZvEFJhnHR42Jk=; b=kG4FEvn7Mnpo8pO9WVbI9tYYETb4riRHgLSdi6UUVvlcN6W3Y6IgXTPVAb2VXQrVLF I1dA3S3MBQTBKQBdcGiy3Hbu0+CkywDYC7jr1OcXXbzVeg5u9EUvQBV5FhdhsUA/+hzt I6tVQS1JEGaxFWVfTj9NG/TM1A7OP4PPMpHHMxgJrKTNxm3KdT4RRbXhhBAPsZ2twW0Y Zsprrkv1hR0TiP2Y4eGGBa7Qg0QCE21m+AtmivWt3RnozCgHpVoAX6EfQJFeFV/nruVM 185FXfNJRKmEwtWsX1Q/01XrD9X8tFbxXOQUeyjj4GFqy6unj0uWKA453qPXy/PB78bm JK/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=1YLw5d0z7vrk2yTXPwCxIPgCJCukpGZvEFJhnHR42Jk=; b=GVlU4gJN/2qo0NdX6Vpj2GRmNWiCeFMGLvfWyjwAioBQULbF7vLLp4DmArwnz5Jv/J VX0TTPOMjkXMbrvS4UFt4wCAyOuyr2btcP2ti1HtIAY+LUlK0DmM/dRY5s5DN+aNJjw+ cN8qCnOpX0+1njlI4NcLkzf8OcV4gnED/lXaPye1BrWii/ChGCcfG5i3udr56n3sxzUi STbazJyojnynmHEvtcQ3RGkFwyoihKtRlzQ8uBoIWRdlY7kYvq37giCUTzT2MPbFK3l0 V+M0RQXnraZ7iIR9ms0VmvDWqHRrsaXvWa4zlKchFAtTINiorBKHUfWuoiHQ5uRm38v6 L0Vw== X-Gm-Message-State: ACrzQf3v8FtZZoC+aIGi8lwp0Ywyn3BQi8TKNzdL71+OfxauZznD3bJm HSe9Uapj5kUXTa24HnklJxyKuZvKytA= X-Google-Smtp-Source: AMsMyM4DTZEQHKDkQtneJ4tKwnFxY33CIZd8Xd132Kbh18Eo/ltb660VIk8l8k11KvpyFSdaFhEw4g== X-Received: by 2002:a17:902:efd2:b0:176:b888:2481 with SMTP id ja18-20020a170902efd200b00176b8882481mr16768109plb.144.1664105503371; Sun, 25 Sep 2022 04:31:43 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:43 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Paolo Bonzini Subject: [PATCH v3 24/54] tests: vhost-user-bridge: Avoid using hardcoded /tmp Date: Sun, 25 Sep 2022 19:30:02 +0800 Message-Id: <20220925113032.1949844-25-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102a.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_file_open_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v3: - Split to a separate patch tests/vhost-user-bridge.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c index 9b1dab2f28..fecdf915e7 100644 --- a/tests/vhost-user-bridge.c +++ b/tests/vhost-user-bridge.c @@ -631,7 +631,6 @@ static void *notifier_thread(void *arg) static void vubr_host_notifier_setup(VubrDev *dev) { - char template[] = "/tmp/vubr-XXXXXX"; pthread_t thread; size_t length; void *addr; @@ -639,7 +638,7 @@ vubr_host_notifier_setup(VubrDev *dev) length = qemu_real_host_page_size() * VHOST_USER_BRIDGE_MAX_QUEUES; - fd = mkstemp(template); + fd = g_file_open_tmp("vubr-XXXXXX", NULL, NULL); if (fd < 0) { vubr_die("mkstemp()"); } From patchwork Sun Sep 25 11:30:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987917 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 146B5C04A95 for ; Sun, 25 Sep 2022 12:00:26 +0000 (UTC) Received: from localhost ([::1]:36586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQJ6-0003CP-WD for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:00:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrQ-0002v5-RZ; Sun, 25 Sep 2022 07:31:52 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:34676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrP-0006OR-EY; Sun, 25 Sep 2022 07:31:48 -0400 Received: by mail-pf1-x434.google.com with SMTP id e68so4194425pfe.1; Sun, 25 Sep 2022 04:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=mASgTbgC1fZZDNGRrUnVCNQGIWuAR0DCWfyrQC7EGTU=; b=T/c1Ie4xiK/itSGbdjFWp79DpP8SzIdHZMBx2ABtzib0ylNv07zcy7xXU3NaAu1TAQ P8HbIKai/6nAp3WrbaKBzofCq+ru0/pK8Lnbtmt55F3SJ8aiPH6nMvY9iVU6siVD31N6 1PWEDcmPD4gx+f7KhtpuwBcL4F3w/th5CTP+WYSYzK+dfSx5yUx8KOnPGzI18B27n0pr ZUlGxr9ZODAIR6+kOi9a9tGt+ZMoRnIKwQ1J/KGEqsTB3WlW2F6A5ItEkQPMCLPqKVXL e+pXpd8lL7POEy3Quo+T3y9Xi3vFfuDgkKO3lRkoB0hsNrc9c4U04lNSnEi5xZuk+aKi vUrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=mASgTbgC1fZZDNGRrUnVCNQGIWuAR0DCWfyrQC7EGTU=; b=dm2YfQpe1fLpwHgQJFgqxLlzAoyy/WLU9T+BMfWFEyD/Tpja2QI4VzsxI1dFqlq+Id mNYFvnIsdbKd8o/pBQPVWXqONgdpCj73owqUNeM9+zUJFHMWk9C+rBOioxAjUk0zl4kj JvE37UxilppBFqOshd5eq22BeOZU07lQBxulqa5JSlOIY8sTgWX8W4mSFLUHR//fjxiz pdUZXmgsvRwkiiEA4q233eWmo/jK4P/l7YWI9SAVsPxHDxj1L1Ul9xZUmt4HjEEOFsKp FeAtYYWUVj/PNDfa5S1R/krnFk7vgqBwcvoUV59VclQ7w6LAoqHPpA/Qo0za0ZS2+ZlD ynaQ== X-Gm-Message-State: ACrzQf03yiMivoyzIjYj+V/jJx0iFh/+8G0fI0bHdd2j9/XLJri6VXpW 4Ju2Er0/I5xEkNI7WALQC6UAM1BZi3g= X-Google-Smtp-Source: AMsMyM71GS+dydzBR6N5JwYed3msH3GIGN5545/yaH05bI6sJEFAlBcdXBF32X1dnP8LzdjShEGzCg== X-Received: by 2002:a63:1546:0:b0:42c:50dc:2115 with SMTP id 6-20020a631546000000b0042c50dc2115mr15522845pgv.613.1664105505711; Sun, 25 Sep 2022 04:31:45 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:45 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH v3 25/54] block/vvfat: Unify the mkdir() call Date: Sun, 25 Sep 2022 19:30:03 +0800 Message-Id: <20220925113032.1949844-26-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x434.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng There is a difference in the mkdir() call for win32 and non-win32 platforms, and currently is handled in the codes with #ifdefs. glib provides a portable g_mkdir() API and we can use it to unify the codes without #ifdefs. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Change to use g_mkdir() block/vvfat.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index d6dd919683..723beef025 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include +#include #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -2726,13 +2727,9 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s) mapping_t* mapping; int j, parent_path_len; -#ifdef __MINGW32__ - if (mkdir(commit->path)) + if (g_mkdir(commit->path, 0755)) { return -5; -#else - if (mkdir(commit->path, 0755)) - return -5; -#endif + } mapping = insert_mapping(s, commit->param.mkdir.cluster, commit->param.mkdir.cluster + 1); From patchwork Sun Sep 25 11:30:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987937 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 B7F7CC6FA82 for ; Sun, 25 Sep 2022 12:21:05 +0000 (UTC) Received: from localhost ([::1]:40266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQd6-0000xL-SZ for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:21:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37296) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrU-0002wB-CV for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:57 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:40682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrR-0006Oc-Bo for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:51 -0400 Received: by mail-pl1-x62f.google.com with SMTP id b21so3924206plz.7 for ; Sun, 25 Sep 2022 04:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=gkhXgeI8VVKYUE8bIuW2cVwuIZ0uivwbyCoudHIFJ54=; b=o9wcy89bT6sQnxN7657PUcydunYmuA8Gjf/8K2fU6+IZvxnq8GlfuBZdpylQAHkYQm BlBH9AI1JoQSyXBnE+KyodT76DVNiIgnLiZlBzI+hTTU2uzKkvJyzqi5oAYzPk/a2TFp sKHpApeKE7B5hy2ZQXpiEEN8sssXzDWfAU3OR75HakcGswr0SDBzNhFQ8c0HMTetwAQ3 OiDBKaSd15kx10l27zy4GVxhSM9Dx+TEGUTSfRemZrQfgohygoCw8ddIE7WIab9h4e1J jX4xhXxr+M0HkgrNBtG1PVxBBK2i81uCNgnCpiQrRUjH6f9rfHUHGYCkrNPoX9LHgTg1 F0mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=gkhXgeI8VVKYUE8bIuW2cVwuIZ0uivwbyCoudHIFJ54=; b=hLjyDpEojmHtfKNjEGlrELjpxkazmyc49hQ+/vLr2W01dfShO+uqrleE3/jdv5mTr7 +wscQViExrUZT5UFn3eYnu7jTcD9ZBaHRkpLO5/4zyfSKl/GUA1mgL2yTEMJ5NPeQZRZ pegquklw75IpNK22gFx2XLl2efzV7YW24PGkZ48c5fyrwxQ+x8jBiyRSiAzRmloEUrHA sW6rva+6QOeVah4d5v5RH3i/+oicLvAB+8wMssFAKbvHY+/ffPHhWsWinul7ESRXbez4 Gdfts6PstoEdrEAbCRndB+uXV4oW5e+Fz0X19zoW/vhYXX8c73yUDABlclzS7wYUh2xz 6pGQ== X-Gm-Message-State: ACrzQf1KdRno9Z56QQAXltC9gljw6dj9g3ss7Hbjg7rRuhcbnO9rhpqW FNPaw/QVHr7x376JB2v56FCJkiXl2lk= X-Google-Smtp-Source: AMsMyM72WZXM9hUfHWkF5Nag0pQ76uxeBhYeMBzN2n1ApsYXAYhPzixFqxn91yA8f7zbi0+aSwipvA== X-Received: by 2002:a17:90b:4b88:b0:202:e381:e643 with SMTP id lr8-20020a17090b4b8800b00202e381e643mr30601410pjb.148.1664105507857; Sun, 25 Sep 2022 04:31:47 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:47 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Christian Schoenebeck , Greg Kurz Subject: [PATCH v3 26/54] fsdev/virtfs-proxy-helper: Use g_mkdir() Date: Sun, 25 Sep 2022 19:30:04 +0800 Message-Id: <20220925113032.1949844-27-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62f.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Use g_mkdir() to create a directory on all platforms. Signed-off-by: Bin Meng Reviewed-by: Christian Schoenebeck --- (no changes since v2) Changes in v2: - Change to use g_mkdir() fsdev/virtfs-proxy-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 2dde27922f..5cafcd7703 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -10,6 +10,7 @@ */ #include "qemu/osdep.h" +#include #include #include #include @@ -639,7 +640,7 @@ static int do_create_others(int type, struct iovec *iovec) if (retval < 0) { goto err_out; } - retval = mkdir(path.data, mode); + retval = g_mkdir(path.data, mode); break; case T_SYMLINK: retval = proxy_unmarshal(iovec, offset, "ss", &oldpath, &path); From patchwork Sun Sep 25 11:30:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987920 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 E282AC6FA82 for ; Sun, 25 Sep 2022 12:05:32 +0000 (UTC) Received: from localhost ([::1]:57622 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQO1-0000bZ-JP for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:05:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrU-0002wA-Ce for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:57 -0400 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:45635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrS-0006Js-Pp for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:51 -0400 Received: by mail-pl1-x636.google.com with SMTP id w20so3902378ply.12 for ; Sun, 25 Sep 2022 04:31:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=gBbYIR+cYUeZZvc5gKxNpLwekX68RaD7k9jxuyBt2nM=; b=RloJdN42EcVyV+5IR4av96YpzAswmToWEH9m7h1YZ6CEPyUIKF42hxt726/3P1cDT0 sRAN5cwchPXrJA2NMlCJ+Ef81aBstmGXBZ4QLik9eOUp+vfr2b+ZdWfFFJP4aD9gulHm 0kN1tYDh9pvzS+8I3tKESmqVfWcMHY6MQDbARExDRluYwABmWlAMevGNl1U5z/+bYnM6 NLLd+Cp4kpn703eAz87p13aGeNXmxRJgBeAa1x3xqTmZOpq2GyLrAPuON1se0SaEJ9Ty Cq5SXeyNR745M3/cuJgCoNFArbhwHDGckLDmLbr1gB8GrZQOun45juiRD4/KR0QAfS7p GJlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=gBbYIR+cYUeZZvc5gKxNpLwekX68RaD7k9jxuyBt2nM=; b=3iZ4TYlXp0YgJ1hMku/Noeryqt8eS8+NAnnP9Q+09KB8mtykeELguCyFlWPdS5Q9PW WIcaxNMCvvzf9P5qno1E7Z/S/8HKqfDSmNyqqh27YtomfWix7EtQNq4fEMrgCj38qPjF lqMi++b7I8eBJfx1hRcIJCnRg2labgBqMdkN9RBV+ffHIbP3JK9dfkOM+128XGpaygxd BrymeOafcPLCht/AN25V3eWBOXdmGdeGjAjqXnRjuRuwdqwAZN0qtNc/uDcUOT5u45O/ govJRjQ7lu5GbCfiXEWjHz7f7tVc2O84D5Ja4OsU+KtqHVdbYNB+26dHZaHvxKip6KxG hmsw== X-Gm-Message-State: ACrzQf2mszcnJUiWhI6HmfyWI+m2CUSQClLwqdMOYp5Fpx1FLkvsxZrr 3z8u4Nv9PCbZzLhYoOgUNIOzl2hmgoY= X-Google-Smtp-Source: AMsMyM4p5ZPbp3KJLRMyaDHrHgz5X+MvAeqFlr6eAblRpzoOJUc/0gUlkI3cSGLLtN17EmgiQG5JXQ== X-Received: by 2002:a17:90a:b00a:b0:203:87a3:9e70 with SMTP id x10-20020a17090ab00a00b0020387a39e70mr19104487pjq.218.1664105509895; Sun, 25 Sep 2022 04:31:49 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:49 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Gerd Hoffmann Subject: [PATCH v3 27/54] hw/usb: dev-mtp: Use g_mkdir() Date: Sun, 25 Sep 2022 19:30:05 +0800 Message-Id: <20220925113032.1949844-28-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x636.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Use g_mkdir() to create a directory on all platforms. Signed-off-by: Bin Meng Acked-by: Gerd Hoffmann --- (no changes since v2) Changes in v2: - Change to use g_mkdir() hw/usb/dev-mtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 5831395cef..1cac1cd435 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -14,7 +14,7 @@ #include "qemu/error-report.h" #include #include - +#include #include @@ -1622,7 +1622,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t handle) if (s->dataset.filename) { path = g_strdup_printf("%s/%s", parent->path, s->dataset.filename); if (s->dataset.format == FMT_ASSOCIATION) { - ret = mkdir(path, mask); + ret = g_mkdir(path, mask); if (!ret) { usb_mtp_queue_result(s, RES_OK, d->trans, 3, QEMU_STORAGE_ID, From patchwork Sun Sep 25 11:30:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987913 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 2BC85C6FA82 for ; Sun, 25 Sep 2022 11:57:05 +0000 (UTC) Received: from localhost ([::1]:56684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQFs-0005bk-9E for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 07:57:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrY-0002wN-7d for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:57 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:33398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrW-0006P9-5J for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:55 -0400 Received: by mail-pf1-x433.google.com with SMTP id w2so4222437pfb.0 for ; Sun, 25 Sep 2022 04:31:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=SZXLVRmmnhtpF37sbXWA0CFlA2zznYKmR2V+rAyp5Mc=; b=cMdtW7UQy4+TPYUSNN04xa6YMGHU46/FQgRHlS8qt4E+vbBvyqqSmSUNHNIXB0cM2C XE27U0qBPZ+5vkwBVeP78Yi3NOIzoLgvVaYJe9ChzPrss3E9yzvlTLhJaj6aOO65iAZv MCtrmNswPFCpwuzBUhyOWYE9h5Bj4lGiJgSR6Lfrn+j9SbtbnTm7HIuHpjYKmcGtXyEW GoJwIHpWhehlnLjUGwwU/95t6N2ghDpDUp8lVeAPsS31QANmjcW9koCcV+T7Sc7Lm1ec HnQT1MMcKx+PsXAGaT7aEoqvp0pj7xbcbPO9grT623nH1mL78HFp/CiWtDYozw/f0Gl7 Oe9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=SZXLVRmmnhtpF37sbXWA0CFlA2zznYKmR2V+rAyp5Mc=; b=oduyEw0LsiOKHiY9nUAU3vOvc6EBLGPtw+YhAzTG2kfus/GK+OhncyXje4clEFDgFy HljOZG0+xvgxBQw3RLAjMLeC+ML3N62QXu/Rii14ayPHnr0ijM/06iMVG6W+oh8J/LI3 zQWqAgBiRH0h0LjzyMf31qSh39lx2EDZbxZZNuXB7Zr3tHOEtgbvMAnsiW7PGQvEOj8a MLmjObVtvRkrlNc4GdANIugComvzMpUmWJnfi0Ai8T36vXqBPB3MaOf8FHU0dsl9qIb1 9Q5KoC1DV6dWnxkcooAooiTOUsHyhAWdLL0GI0D+JEU5xIN7w8dnrETn4ffxLcIgTSdh q6lQ== X-Gm-Message-State: ACrzQf3YNGZe0LRKePDb4UMgNwmJZEs2YeNldA4cVb+YCo9l2SFQwpd4 StzwfFq/S3kmhvCn6ixCvL9paiqWgjg= X-Google-Smtp-Source: AMsMyM66KcKWZ3UbRaVZszszy2tNDgxD0+c5fxiyRTY/sUspWzmHubyTwrerBU9r/Gb8ICm7vpVVng== X-Received: by 2002:aa7:88d0:0:b0:542:d98d:bf1f with SMTP id k16-20020aa788d0000000b00542d98dbf1fmr18196751pff.78.1664105512599; Sun, 25 Sep 2022 04:31:52 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:52 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Jason Wang , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 28/54] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32 Date: Sun, 25 Sep 2022 19:30:06 +0800 Message-Id: <20220925113032.1949844-29-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x433.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Some of the virtio-net-test test cases require socketpair() to do the test setup. Skip them for win32. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Change to skip only part of the virtio-net-test cases that require socketpair() intead of disabling all of them tests/qtest/virtio-net-test.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/qtest/virtio-net-test.c b/tests/qtest/virtio-net-test.c index 6ded252901..dff43f0f60 100644 --- a/tests/qtest/virtio-net-test.c +++ b/tests/qtest/virtio-net-test.c @@ -165,8 +165,6 @@ static void stop_cont_test(void *obj, void *data, QGuestAllocator *t_alloc) rx_stop_cont_test(dev, t_alloc, rx, sv[0]); } -#endif - static void hotplug(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtioPCIDevice *dev = obj; @@ -286,6 +284,8 @@ static void *virtio_net_test_setup(GString *cmd_line, void *arg) return sv; } +#endif /* _WIN32 */ + static void large_tx(void *obj, void *data, QGuestAllocator *t_alloc) { QVirtioNet *dev = obj; @@ -319,16 +319,15 @@ static void *virtio_net_test_setup_nosocket(GString *cmd_line, void *arg) static void register_virtio_net_test(void) { - QOSGraphTestOptions opts = { - .before = virtio_net_test_setup, - }; + QOSGraphTestOptions opts = { 0 }; - qos_add_test("hotplug", "virtio-net-pci", hotplug, &opts); #ifndef _WIN32 + opts.before = virtio_net_test_setup; + qos_add_test("hotplug", "virtio-net-pci", hotplug, &opts); qos_add_test("basic", "virtio-net", send_recv_test, &opts); qos_add_test("rx_stop_cont", "virtio-net", stop_cont_test, &opts); -#endif qos_add_test("announce-self", "virtio-net", announce_self, &opts); +#endif /* These tests do not need a loopback backend. */ opts.before = virtio_net_test_setup_nosocket; From patchwork Sun Sep 25 11:30:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987921 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 88D4BC04A95 for ; Sun, 25 Sep 2022 12:05:44 +0000 (UTC) Received: from localhost ([::1]:58962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQOD-0000nf-HH for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:05:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrb-0002xl-9O for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:00 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:38857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrY-0006LJ-0d for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:31:57 -0400 Received: by mail-pg1-x535.google.com with SMTP id 129so2789805pgc.5 for ; Sun, 25 Sep 2022 04:31:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=bgoeJG+EitAc6steECPvwA+eqgU3ODIY2NLoSDcVQq4=; b=gC3zL9HFx52uurQYDWZ4C2ZiCZGhwj1xWSRsfqhb21GDZIr85rLug/Zl0dK4O2uQ1W Zz1yBWyB3Hc92fOtr7emHGgZqJVrJbuOZcYvS6/zI/dO22Li4vptgBuqN9oSkPnikJ6+ QzGnCK/LwyImEdB3PlS3zvH3eJEXcCGPS11zFVY+yo1r3yCTiG1rwY/+gAVvDGyYSXz3 ErwxUYKtiDKEskYfit5JYsdKYKELxp64alTitqtpNiVqbZmOhI51ZYZ854x9jo+8cWut g3ggFJLxAr4CqOQzgiYkoXacQrjxIwIJ8p5C3BVn8q6ojHtjRfpUTk6D0hmxgYHtSH68 GgbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=bgoeJG+EitAc6steECPvwA+eqgU3ODIY2NLoSDcVQq4=; b=N3s8tsWwLiX7UVQIVD0sKzM2IFn4k/IzhEv1rn2rIdm/Zn2b8UjT8fqqZ80RGjIOtP zJTGEQFRycsVMRzl+LeSx9mUkiToVlAt7XhcRPynPwNOna6ShcfTy6udjx82revv6XyM e7QdH1SWGDi9+3ez6i+YFULy1BDGxlAmoTWBc/m/U6VMkEvfVn+dfC4nEloHIoSa0vAz D+QtPUJuIlv6wrjYIfxy0Q/MHsA9EQY1d00fOl0Nu9llecRPNiODdEQOapLgW7GF9W8c svwxh4xs5+5hxg/1EXMeokT8Zuwo6+fdS7G6x0Z0FpR5ouKS0Lx4N4qU0G3Y2LH7nfau +ETw== X-Gm-Message-State: ACrzQf3D8xdckHiltTNTc45MZFU9Cg+KZxcYve2TE4jz4Ww6f1lePjS2 urehP+e42CHryS8EoT244Wb2rN7O11c= X-Google-Smtp-Source: AMsMyM4TSK41GYrfDRPMzxMIZCfbAWttAhUolfdVJuRbVMeAgVnF+oyAn7ZnBSm4zikSn9/0iU1c+A== X-Received: by 2002:a63:210c:0:b0:43b:e1c8:ecf0 with SMTP id h12-20020a63210c000000b0043be1c8ecf0mr15682121pgh.32.1664105515026; Sun, 25 Sep 2022 04:31:55 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:54 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 29/54] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only Date: Sun, 25 Sep 2022 19:30:07 +0800 Message-Id: <20220925113032.1949844-30-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x535.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng The test-filter-{mirror,redirector} cases use socketpair() API that is only available on POSIX and should only be built for POSIX. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Introduce a new variable qtests_filter and add that to the qtests_ARCH variables tests/qtest/meson.build | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index e910cb32ca..455f1bbb7e 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -39,9 +39,14 @@ qtests_pci = \ qtests_cxl = \ (config_all_devices.has_key('CONFIG_CXL') ? ['cxl-test'] : []) +qtests_filter = \ + (slirp.found() ? ['test-netfilter'] : []) + \ + (config_host.has_key('CONFIG_POSIX') ? ['test-filter-mirror'] : []) + \ + (config_host.has_key('CONFIG_POSIX') ? ['test-filter-redirector'] : []) + qtests_i386 = \ - (slirp.found() ? ['pxe-test', 'test-netfilter'] : []) + \ - (config_host.has_key('CONFIG_POSIX') ? ['test-filter-mirror'] : []) + \ + (slirp.found() ? ['pxe-test'] : []) + \ + qtests_filter + \ (have_tools ? ['ahci-test'] : []) + \ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \ (config_all_devices.has_key('CONFIG_SGA') ? ['boot-serial-test'] : []) + \ @@ -95,8 +100,7 @@ qtests_i386 = \ 'vmgenid-test', 'migration-test', 'test-x86-cpuid-compat', - 'numa-test', - 'test-filter-redirector' + 'numa-test' ] if dbus_display @@ -120,30 +124,25 @@ endif qtests_x86_64 = qtests_i386 qtests_alpha = ['boot-serial-test'] + \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + \ + qtests_filter + \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) qtests_avr = [ 'boot-serial-test' ] qtests_hppa = ['boot-serial-test'] + \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + \ + qtests_filter + \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) qtests_m68k = ['boot-serial-test'] + \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + qtests_filter qtests_microblaze = ['boot-serial-test'] + \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + qtests_filter qtests_microblazeel = qtests_microblaze qtests_mips = \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + \ + qtests_filter + \ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) @@ -152,8 +151,7 @@ qtests_mips64 = qtests_mips qtests_mips64el = qtests_mips qtests_ppc = \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + \ + qtests_filter + \ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \ (config_all_devices.has_key('CONFIG_M48T59') ? ['m48t59-test'] : []) + \ (config_all_devices.has_key('CONFIG_TCG') ? ['prom-env-test'] : []) + \ @@ -174,13 +172,11 @@ qtests_sh4 = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-te qtests_sh4eb = (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) qtests_sparc = ['prom-env-test', 'm48t59-test', 'boot-serial-test'] + \ - ['test-filter-mirror', 'test-filter-redirector'] + \ - (slirp.found() ? ['test-netfilter'] : []) + qtests_filter qtests_sparc64 = \ (config_all_devices.has_key('CONFIG_ISA_TESTDEV') ? ['endianness-test'] : []) + \ - (slirp.found() ? ['test-netfilter'] : []) + \ - ['test-filter-mirror', 'test-filter-redirector'] + \ + qtests_filter + \ ['prom-env-test', 'boot-serial-test'] qtests_npcm7xx = \ From patchwork Sun Sep 25 11:30:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987940 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 B2A9DC04A95 for ; Sun, 25 Sep 2022 12:24:48 +0000 (UTC) Received: from localhost ([::1]:48494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQgh-0006nL-Kv for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrd-0002zE-No for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:02 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:44690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrb-0006PP-Tp for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:01 -0400 Received: by mail-pg1-x534.google.com with SMTP id c7so4197109pgt.11 for ; Sun, 25 Sep 2022 04:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=2Xb7XrmaLcBqtVTEcO7c2koX6kjKx3/BJ5rv1pbp5Aw=; b=K8eA5KO6qLEeHaIv9EFQN7305Bz+4dCXeyxFkTnfekjRtiqKWD2TptqP9CZUIkYo5A OCsuyUZ+k9h39Qnew59tQQOYbsRfg/p3CoZirBltqDKu2p2EgnPjKqgBLFs6FGwYWXeq LhN8d/6ThkIZgfuT90b1Gi2bES/ZyqyKJQUuFGmsRNuz8CUZEQKAmQD1+ALCR1zLbG9a GnosFmDXjpsx3j+WJutTal2XkGJwBGFYDt6EvthijRQcG7QkczzB6Np9GBdAwn5HSo1j oowJh7G+SzH/ZxaaEENdybPbUzBbOdMeVW+1nmhjADN2Rmyuc6tVU07madocDt/yF7PY FmIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=2Xb7XrmaLcBqtVTEcO7c2koX6kjKx3/BJ5rv1pbp5Aw=; b=RAqiZ1XZV1t3TJuXH8ZHJ5IRsptHhhTEwKfN42WxAhKEH+RMNG3aSVmor0w4MV4x50 OdV58Arki/WH/IkeJUYYPLqoEzMukH8Ffd/+XDK7snxwFFnWD22kmG7FUIg75GcRTbHc u1dzUKQHWJm7tzkMMEjjgDPXMlYdjTk2UO7sad8EpmnfxZ/J6J7aUtNwTcpQ3hmgQxyY ZNZQKAQjI6rqKFSaLa2xkc9ko1ENtIOQpeNfUE10J3UdkZw6+kNiltgPdt7WaIf3i1D3 nzAKRDjrmlX6XesFWXoj4p7xbzrSHIA/EkqIqaAFPmCcx+85AuSpK5HqEQR4mjBuL+RJ Sb4Q== X-Gm-Message-State: ACrzQf0m2w9PA1tC1tWieSoA7JB2WwSZpSW/61VfwJ68yP/uJdlDbtyw kVcdihEQIzsZb4/KlThBCUbA/ktdM30= X-Google-Smtp-Source: AMsMyM5bMWXnRqkRfB3om9wrOKkmwZceKNGKfsYdRlvVaiojIUkMuf7Zw/ml5e7fyGAU7dk1RAA99Q== X-Received: by 2002:a63:5511:0:b0:439:12f6:fb9a with SMTP id j17-20020a635511000000b0043912f6fb9amr15989620pgb.197.1664105517503; Sun, 25 Sep 2022 04:31:57 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:31:57 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Thomas Huth , Laurent Vivier , Markus Armbruster , Paolo Bonzini Subject: [PATCH v3 30/54] tests/qtest: qmp-test: Skip running test_qmp_oob for win32 Date: Sun, 25 Sep 2022 19:30:08 +0800 Message-Id: <20220925113032.1949844-31-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x534.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng The test_qmp_oob test case calls mkfifo() which does not exist on win32. Exclude it. Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- (no changes since v2) Changes in v2: - Add a comment in the code to explain why test_qmp_oob test case is skipped on win32 tests/qtest/qmp-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index 0fa00c12dc..074953fdf0 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -159,6 +159,8 @@ static void test_qmp_protocol(void) qtest_quit(qts); } +#ifndef _WIN32 + /* Out-of-band tests */ char *tmpdir; @@ -279,6 +281,8 @@ static void test_qmp_oob(void) qtest_quit(qts); } +#endif /* _WIN32 */ + /* Preconfig tests */ static void test_qmp_preconfig(void) @@ -338,7 +342,10 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); qtest_add_func("qmp/protocol", test_qmp_protocol); +#ifndef _WIN32 + /* This case calls mkfifo() which does not exist on win32 */ qtest_add_func("qmp/oob", test_qmp_oob); +#endif qtest_add_func("qmp/preconfig", test_qmp_preconfig); qtest_add_func("qmp/missing-any-arg", test_qmp_missing_any_arg); From patchwork Sun Sep 25 11:30:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987924 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 6E158C6FA82 for ; Sun, 25 Sep 2022 12:08:33 +0000 (UTC) Received: from localhost ([::1]:53730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQQy-00072n-DI for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:08:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrg-00030W-8P for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:04 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:42953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPre-0006Ph-Iv for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:04 -0400 Received: by mail-pf1-x431.google.com with SMTP id b23so4158363pfp.9 for ; Sun, 25 Sep 2022 04:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=FodAt/+tlmeyr8mO0vp74otmvfdLkdpAkh8HSKQOwPY=; b=LDpBwdzsxv/HF7iMvBwC8uY0zLEGmQP9MZqP1UiBw7T7xVarF5VSulafavuCHILMUa ljgEMn53OZ3pdSiVwB7en3XyRHQXlueWYqgR4aQNUi+4MdrZCfVlBsTwc9LebQKxr0vt 3jp3ItYjqK7BOOW0FYFU8yYCbYNhOCGAooTrPdflN63sU1/cdvo3timhaNk5+tBY444B c8uraSb5gzO8UYxreuL0liE6CX2tgbL2xUrBK7O0ThdbPLbGN8VbV/mZRcVRU4X8Cj1m LhF2eQcOjVk32T7/eW2/KCLk5Nh5/y2Q0UnFcPNUst3bY7Uj6A3q9YlU9dxj/tZsmmzT pq9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=FodAt/+tlmeyr8mO0vp74otmvfdLkdpAkh8HSKQOwPY=; b=YcFxl090ML7mcDMC/Mzd+eDMzQaVPqXxowDxYV/TRqUDsjN0LdA6/ZUvcloImglTYl 9ekhc+XRiPnXhmQIY/SMUic/VEA/XT703FHoiVmy/zjg01YxBjA/xsDpia0H8i9MqOl+ 3PXLl/+JLz6UhZr4fyV1StP9tiJqtfDq2qnCgUjVzLzcVDCUUJVzqy4x3pEMZh4wxjjv yJCPixrXJaUX5lYPgzOVfvLtW2eZMzEnWeRfn9OJaz5M0xab4pOsEUSelaRHNBjnBiKU LfrWwc0KxdL52iRP/VuLnCv4dZ8l52bNViLz+9cTnxLTRSHPrI21SZHRBivTNWE70RVh DZYw== X-Gm-Message-State: ACrzQf1Fyhfmhz2EULNgaggd4BaD3xPZjM/+wbQMY8/vJZIz5AidkByz fwxxsgPNbLV9CEgukrq8g8sCS4NHaVY= X-Google-Smtp-Source: AMsMyM6DIyfKfPMKkqoYxqpTIyf+Xd62YV8smvJn4fPSTDJa0PNEtpVHYBbYNmINfC2WszLJm19F+A== X-Received: by 2002:a65:6e87:0:b0:438:e26c:167a with SMTP id bm7-20020a656e87000000b00438e26c167amr14986527pgb.421.1664105521033; Sun, 25 Sep 2022 04:32:01 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:00 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Eduardo Habkost , Laurent Vivier , Marcel Apfelbaum , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth , Yanan Wang Subject: [PATCH v3 31/54] accel/qtest: Implement a portable qtest accelerator Date: Sun, 25 Sep 2022 19:30:09 +0800 Message-Id: <20220925113032.1949844-32-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x431.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng Currently signal SIGIPI [=SIGUSR1] is used to kick the dummy CPU when qtest accelerator is used. However SIGUSR1 is unsupported on Windows. To support Windows, we add a QemuSemaphore CPUState::sem to kick the dummy CPU instead. As a result of this, the POSIX implementation via signal is no longer needed and can use the same path as Windows. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Replace signal by the semaphore on posix too include/hw/core/cpu.h | 1 + accel/dummy-cpus.c | 15 ++------------- softmmu/cpus.c | 10 +--------- accel/meson.build | 1 + accel/qtest/meson.build | 1 + 5 files changed, 6 insertions(+), 22 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 500503da13..2f46c37dc1 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -326,6 +326,7 @@ struct CPUState { #ifdef _WIN32 HANDLE hThread; #endif + QemuSemaphore sem; int thread_id; bool running, has_waiter; struct QemuCond *halt_cond; diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c index 10429fdfb2..3769d3db0a 100644 --- a/accel/dummy-cpus.c +++ b/accel/dummy-cpus.c @@ -21,8 +21,6 @@ static void *dummy_cpu_thread_fn(void *arg) { CPUState *cpu = arg; - sigset_t waitset; - int r; rcu_register_thread(); @@ -32,23 +30,13 @@ static void *dummy_cpu_thread_fn(void *arg) cpu->can_do_io = 1; current_cpu = cpu; - sigemptyset(&waitset); - sigaddset(&waitset, SIG_IPI); - /* signal CPU creation */ cpu_thread_signal_created(cpu); qemu_guest_random_seed_thread_part2(cpu->random_seed); do { qemu_mutex_unlock_iothread(); - do { - int sig; - r = sigwait(&waitset, &sig); - } while (r == -1 && (errno == EAGAIN || errno == EINTR)); - if (r == -1) { - perror("sigwait"); - exit(1); - } + qemu_sem_wait(&cpu->sem); qemu_mutex_lock_iothread(); qemu_wait_io_event(cpu); } while (!cpu->unplug); @@ -67,6 +55,7 @@ void dummy_start_vcpu_thread(CPUState *cpu) qemu_cond_init(cpu->halt_cond); snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/DUMMY", cpu->cpu_index); + qemu_sem_init(&cpu->sem, 0); qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu, QEMU_THREAD_JOINABLE); } diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 23b30484b2..2a992d0d5f 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -437,19 +437,11 @@ void qemu_wait_io_event(CPUState *cpu) void cpus_kick_thread(CPUState *cpu) { -#ifndef _WIN32 - int err; - if (cpu->thread_kicked) { return; } cpu->thread_kicked = true; - err = pthread_kill(cpu->thread->thread, SIG_IPI); - if (err && err != ESRCH) { - fprintf(stderr, "qemu:%s: %s", __func__, strerror(err)); - exit(1); - } -#endif + qemu_sem_post(&cpu->sem); } void qemu_cpu_kick(CPUState *cpu) diff --git a/accel/meson.build b/accel/meson.build index b9a963cf80..b21c85dc0a 100644 --- a/accel/meson.build +++ b/accel/meson.build @@ -17,4 +17,5 @@ dummy_ss.add(files( )) specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss) +specific_ss.add_all(when: ['CONFIG_WIN32'], if_true: dummy_ss) specific_ss.add_all(when: ['CONFIG_XEN'], if_true: dummy_ss) diff --git a/accel/qtest/meson.build b/accel/qtest/meson.build index 4c65600293..a4876fc0f2 100644 --- a/accel/qtest/meson.build +++ b/accel/qtest/meson.build @@ -1,2 +1,3 @@ qtest_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: files('qtest.c')) +qtest_module_ss.add(when: ['CONFIG_WIN32'], if_true: files('qtest.c')) From patchwork Sun Sep 25 11:30:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987918 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 43481C6FA82 for ; Sun, 25 Sep 2022 12:02:10 +0000 (UTC) Received: from localhost ([::1]:50536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQKn-0004oj-D7 for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:02:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrl-00036A-5M for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:09 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:47071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrh-0006Q7-Cp for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:08 -0400 Received: by mail-pj1-x102b.google.com with SMTP id j6-20020a17090a694600b00200bba67dadso4287893pjm.5 for ; Sun, 25 Sep 2022 04:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HHmHosbI1UH5JFaYMLGsioCy3QztSrpxpXb6IzEKUQo=; b=qLFQ3sHXskR5B9tl/idxnNA1zpDCypNl3tIv7EP5aZO2Bp/akPl/1KXfX9z64CuAfU PFINAf9ti1QO9rb7NsdUgZGNDwW6T+F1Vzz1wKOlcXEYzxoZqnvsmz5PRz/WBNQNib8J dQmRgeNyzPyjeWcxpyiUS5DYopc86WF1IyBoNQrXahuRzAG+Ncgx/25RwP8wmJuvp27U z6yruD1hD1XqMkrIux/2Btp9+y80ATx08kFNEeFBBc0kN0/VR2VeRreslDUg0AFLKM1p z7x3XaHGSjug3SnX9lycgLXRSO+Zz/HIo+KgeOj/SxVb1j+rolXw28dlzBjhY69SOJ7H 56Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=HHmHosbI1UH5JFaYMLGsioCy3QztSrpxpXb6IzEKUQo=; b=Ihz/INeIK9CU6/Rxp+cgUXhkE6H0YvtAY++texGMkCGMC5n6/HigGxVK6pufvg86Yi xTLeF0/V3kiFq2c7+T/cal2Hd1t467hIZlwJa2K8Oo3zNqIHPvD01wJSTavOjICySJeG Qv8F6lh72wrL6K86iY2vDb0j/G1i1bXE4WImoeG8T3mdalCCEp0EDIR7PJSrv8vZsQ9c tIMriGSCL+/nRXLmWJrrDq/MfZsV9JXqTrrVBoDne34+XQen83KDRhmsZ7PbCh6BjjBV mHOqjBXYKDQORQG4qEcX1qAV2DjQoZNgpqAtIV5UqS/oDILXmQCN1k7J3XOwM8HvLd7a t0oQ== X-Gm-Message-State: ACrzQf18JeTbi4tDpIWqhnDibu47BCdukGB9Y0Wnmj5lUOUTW8oioKbC hOlzQCbzX2grydF3h8lkudDZVE2JiaA= X-Google-Smtp-Source: AMsMyM6dTmGCBh6m/dzWze3nAQ4PaIFObuO1BK1qirUlu1E/Yn2frQsCUGgHHG4TO1EN1TAsnEfPYw== X-Received: by 2002:a17:90a:e552:b0:203:627b:6c6e with SMTP id ei18-20020a17090ae55200b00203627b6c6emr19053956pjb.59.1664105523560; Sun, 25 Sep 2022 04:32:03 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:03 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32 Date: Sun, 25 Sep 2022 19:30:10 +0800 Message-Id: <20220925113032.1949844-33-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102b.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng Commit dd2107497275 ("tests/libqtest: Use libqtest-single.h in tests that require global_qtest") moved global_qtest to libqtest-single.h, by declaring global_qtest attribute to be common and weak. This trick unfortunately does not work on Windows, and building qtest test cases results in multiple definition errors of the weak symbol global_qtest, as Windows PE does not have the concept of the so-called weak symbol like ELF in the *nix world. However Windows does provide a trick to declare a variable to be a common symbol, via __declspec(selectany) [1]. It does not provide the "strong override weak" effect but we don't need it in our use case anyway. So let's use it for win32. [1] https://docs.microsoft.com/en-us/cpp/cpp/selectany Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- (no changes since v2) Changes in v2: - Use __declspec(selectany) for the common weak symbol on Windows tests/qtest/libqtest-single.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h index 4e7d0ae1dc..851724cbcb 100644 --- a/tests/qtest/libqtest-single.h +++ b/tests/qtest/libqtest-single.h @@ -13,7 +13,11 @@ #include "libqtest.h" +#ifndef _WIN32 QTestState *global_qtest __attribute__((common, weak)); +#else +__declspec(selectany) QTestState *global_qtest; +#endif /** * qtest_start: From patchwork Sun Sep 25 11:30:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987925 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 03CE9C6FA82 for ; Sun, 25 Sep 2022 12:08:37 +0000 (UTC) Received: from localhost ([::1]:42256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQR1-0007H7-Sw for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:08:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrm-0003AZ-Lk for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:10 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]:36390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrk-0006QI-UH for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:10 -0400 Received: by mail-pl1-x62d.google.com with SMTP id c24so3943363plo.3 for ; Sun, 25 Sep 2022 04:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=csOaISwTSwLoJpsFvuVDUfystuDYu8jpDcj/GRjEV6A=; b=ogKSeqs7uhfc2bi395QMh0UBP807IHIoaQK0YCku8bUDzwN2slpX4Szl/rs7/cXq54 0NtotQm++GTcKQMC4bFuinImfVSKYAysbe3r9jyaO8uDlLMoBtpBpKp774Ar41xpo1LK y5PrAEQH2Pu7ojNdFCS63GhpvJIppO95UY5LIyxRnzjgQAiTDc0S9Y43riLwL5qEAbs6 CrRPorj4nSa2OQyK2nuFfqf3WiXfxlXRRHIC0SEO54e9uRD6i9lcFVU5ciqVuErrUbF5 nlqf8K+YfkYbAQfvenxLQFFDakptR2CE5eMLT+JW0RbEieMkdSBkinW5erFYzt4YVofD 4oBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=csOaISwTSwLoJpsFvuVDUfystuDYu8jpDcj/GRjEV6A=; b=INo1vrl1jIxafM1IHM91mxZAh6TuOQX40iaOKJlX/mmKS4clkmM3QrAnRgPGdSTQJM 7ZOVGyC8Mu3rW3mFYS7LvIzljJ1JA9tY87GGOgYF0rQgWZMIrt79UY5lbUtOyP0YTqBD BQdKUYf75nehimv3bZ6FgAOCwFx44WbavHDK1CvMXjCgRvhx5fpunF+xerfq6/W1Y8xM Vhurke3I4n7EjL7bqMdvPKbPlB1ZPMde5MAZa+Ievb/muICgAerSgCvKIBbu48Gwkm+c DVpGUykT3gwmzU+i1VC8QD/IixF7BuYVyCYFlcnrmNe4nDT+lpPyVFPcBChnnGMvQQLK QWpQ== X-Gm-Message-State: ACrzQf0BbJUTL9GKfrRMccMS2IMT8qCBb9oOYnNkiIZ6ebbY6LHw1487 EZ8mUGQZfZ4KLqxuoPolFeaL7KLMerU= X-Google-Smtp-Source: AMsMyM5zX/blaCS4kbMNEAwt6fghIeWgCAAo0A026D7p1JnlDPfThdGX+g+Icsyt1DOIfdIJGCQM1A== X-Received: by 2002:a17:902:e14c:b0:177:e7be:2ab6 with SMTP id d12-20020a170902e14c00b00177e7be2ab6mr17017869pla.25.1664105526496; Sun, 25 Sep 2022 04:32:06 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:05 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 33/54] tests/qtest: Use send/recv for socket communication Date: Sun, 25 Sep 2022 19:30:11 +0800 Message-Id: <20220925113032.1949844-34-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62d.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng Socket communication in the libqtest and libqmp codes uses read() and write() which work on any file descriptor on *nix, and sockets in *nix are an example of a file descriptor. However sockets on Windows do not use *nix-style file descriptors, so read() and write() cannot be used on sockets on Windows. Switch over to use send() and recv() instead which work on both Windows and *nix. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Introduce qemu_send_full() and use it include/qemu/sockets.h | 2 ++ tests/qtest/libqmp.c | 5 +++-- tests/qtest/libqtest.c | 4 ++-- util/osdep.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 038faa157f..8ff7832eba 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -15,6 +15,8 @@ int inet_aton(const char *cp, struct in_addr *ia); bool fd_is_socket(int fd); int qemu_socket(int domain, int type, int protocol); int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen); +ssize_t qemu_send_full(int s, const void *buf, size_t count) + G_GNUC_WARN_UNUSED_RESULT; int socket_set_cork(int fd, int v); int socket_set_nodelay(int fd); void qemu_socket_set_block(int fd); diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c index ade26c15f0..2b08382e5d 100644 --- a/tests/qtest/libqmp.c +++ b/tests/qtest/libqmp.c @@ -23,6 +23,7 @@ #endif #include "qemu/cutils.h" +#include "qemu/sockets.h" #include "qapi/error.h" #include "qapi/qmp/json-parser.h" #include "qapi/qmp/qjson.h" @@ -36,7 +37,7 @@ typedef struct { static void socket_send(int fd, const char *buf, size_t size) { - size_t res = qemu_write_full(fd, buf, size); + ssize_t res = qemu_send_full(fd, buf, size); assert(res == size); } @@ -69,7 +70,7 @@ QDict *qmp_fd_receive(int fd) ssize_t len; char c; - len = read(fd, &c, 1); + len = recv(fd, &c, 1, 0); if (len == -1 && errno == EINTR) { continue; } diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index d8ffa0e7b1..0dfe630373 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -436,7 +436,7 @@ void qtest_quit(QTestState *s) static void socket_send(int fd, const char *buf, size_t size) { - size_t res = qemu_write_full(fd, buf, size); + ssize_t res = qemu_send_full(fd, buf, size); assert(res == size); } @@ -468,7 +468,7 @@ static GString *qtest_client_socket_recv_line(QTestState *s) ssize_t len; char buffer[1024]; - len = read(s->fd, buffer, sizeof(buffer)); + len = recv(s->fd, buffer, sizeof(buffer), 0); if (len == -1 && errno == EINTR) { continue; } diff --git a/util/osdep.c b/util/osdep.c index 60fcbbaebe..0342e754e1 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -502,6 +502,39 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen) return ret; } +/* + * A variant of send(2) which handles partial send. + * + * Return the number of bytes transferred over the socket. + * Set errno if fewer than `count' bytes are sent. + * + * This function don't work with non-blocking socket's. + * Any of the possibilities with non-blocking socket's is bad: + * - return a short write (then name is wrong) + * - busy wait adding (errno == EAGAIN) to the loop + */ +ssize_t qemu_send_full(int s, const void *buf, size_t count) +{ + ssize_t ret = 0; + ssize_t total = 0; + + while (count) { + ret = send(s, buf, count, 0); + if (ret < 0) { + if (errno == EINTR) { + continue; + } + break; + } + + count -= ret; + buf += ret; + total += ret; + } + + return total; +} + void qemu_set_hw_version(const char *version) { hw_version = version; From patchwork Sun Sep 25 11:30:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987928 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 DBDBDC6FA82 for ; Sun, 25 Sep 2022 12:10:34 +0000 (UTC) Received: from localhost ([::1]:39368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQSv-0004Z9-Rm for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:10:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPro-0003Dh-An for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:12 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:38603) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrm-0006QU-Fe for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:12 -0400 Received: by mail-pl1-x62c.google.com with SMTP id x1so3934520plv.5 for ; Sun, 25 Sep 2022 04:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=p0xLVSd98uOEEzWCz4ddtwbkgDpwCzSvQCc4PqL/v9w=; b=FXQc2rauP7dgvCzjti8C7X2ZFmvYvv7VxiSWsZlFUktKDmMCpyksjs5t606ULFWiaR N/7uFuCoiXa7jBSHnLjvBSQl9Ty0YC92Nd7YyylLncNHB44mBGfGqJsayA2kB8TfiuX1 VGuX7VX6e6weTcmInJZb/PbB0BW/k4gOcQB28sMbu/SWQ9iEPpXwQsc0n4KOOimMvABj tvrID536Tv6htENRtGTYRc9jG5ddBJ33bEw2/wOvn1zNKou/vaSoRhYwSCkNlJfvPVy9 HNnmMHRoE1YufKO1yAyxcJYPdne7XI+gwxdztNClXdDF8MNtdHDNWN7uh3uX867O9ySr oKsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=p0xLVSd98uOEEzWCz4ddtwbkgDpwCzSvQCc4PqL/v9w=; b=mFb5SsuRc2NkX0S0fIrCg6o0mMJ/AVdSl39CO5X3PAd2v8ppkGs1q0qvrI0mUEM1TU CIOvh0eIJ+Ku3HDKbHS60OnBvU13nAAs1aiZoIO+hCN8odO9b6ff/+9U8kKU3oujyeAI +8VO6cz1lHJ7KhzG12dDsPn2TP3npgierF4a2WpDhwFgqb17M76OTjnhBNK+RaB3zGJH 6YH4CoauTIEHKO+WYle8MIvYwRmaedl3h3T1wpWXf472yQEMSD2gpdoazP0IWeGb81zj 352b+SZzKYQjiujAIeRHh0JluE7fIuGKz3Y5rymeOIxo0vP/8w2yCy9IHngAFWUslzZG RLxA== X-Gm-Message-State: ACrzQf0IPj2aNcLHfYqFkwJr+upICmmhToUlvr0W44g5MVG0uQ4phqye mNJqicgdgnuvC95RTA2kLITnxIjQfmk= X-Google-Smtp-Source: AMsMyM7gjyKZYbYGNe4J6Se5gsoD9eeZU8nPlWRdNPU/wq+yDo4Mh859Bof0XYCCeMxuEonRfwMC4w== X-Received: by 2002:a17:90a:7843:b0:203:5861:fc3d with SMTP id y3-20020a17090a784300b002035861fc3dmr19103139pjl.87.1664105528888; Sun, 25 Sep 2022 04:32:08 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:08 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32 Date: Sun, 25 Sep 2022 19:30:12 +0800 Message-Id: <20220925113032.1949844-35-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng libqmp.c::qmp_fd_vsend_fds() is not available on Windows, hence any APIs in libqtest that call libqmp.c::qmp_fd_vsend_fds() should be excluded for win32 too. This includes the following: * qtest_qmp_vsend_fds() * qtest_vqmp_fds() * qtest_qmp_fds() * qtest_qmp_add_client() Note qtest_qmp_vsend() was wrongly written to call qmp_fd_vsend_fds() previously, but it should call the non fds version API qmp_fd_vsend(). Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/libqtest.h | 8 ++++++++ tests/qtest/libqtest.c | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 94b187837d..3abc75964d 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -94,6 +94,7 @@ void qtest_kill_qemu(QTestState *s); */ void qtest_quit(QTestState *s); +#ifndef _WIN32 /** * qtest_qmp_fds: * @s: #QTestState instance to operate on. @@ -108,6 +109,7 @@ void qtest_quit(QTestState *s); QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num, const char *fmt, ...) G_GNUC_PRINTF(4, 5); +#endif /* _WIN32 */ /** * qtest_qmp: @@ -152,6 +154,7 @@ void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...) */ int qtest_socket_server(const char *socket_path); +#ifndef _WIN32 /** * qtest_vqmp_fds: * @s: #QTestState instance to operate on. @@ -167,6 +170,7 @@ int qtest_socket_server(const char *socket_path); QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num, const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0); +#endif /* _WIN32 */ /** * qtest_vqmp: @@ -181,6 +185,7 @@ QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num, QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0); +#ifndef _WIN32 /** * qtest_qmp_vsend_fds: * @s: #QTestState instance to operate on. @@ -196,6 +201,7 @@ QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap) void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num, const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0); +#endif /* _WIN32 */ /** * qtest_qmp_vsend: @@ -743,6 +749,7 @@ void qtest_qmp_device_add_qdict(QTestState *qts, const char *drv, void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, const char *fmt, ...) G_GNUC_PRINTF(4, 5); +#ifndef _WIN32 /** * qtest_qmp_add_client: * @qts: QTestState instance to operate on @@ -752,6 +759,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, * Call QMP ``getfd`` followed by ``add_client`` with the given @fd. */ void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd); +#endif /* _WIN32 */ /** * qtest_qmp_device_del: diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 0dfe630373..269d622fe3 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -592,17 +592,20 @@ int qtest_socket_server(const char *socket_path) return sock; } +#ifndef _WIN32 void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num, const char *fmt, va_list ap) { qmp_fd_vsend_fds(s->qmp_fd, fds, fds_num, fmt, ap); } +#endif void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap) { - qmp_fd_vsend_fds(s->qmp_fd, NULL, 0, fmt, ap); + qmp_fd_vsend(s->qmp_fd, fmt, ap); } +#ifndef _WIN32 QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num, const char *fmt, va_list ap) { @@ -611,6 +614,7 @@ QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num, /* Receive reply */ return qtest_qmp_receive(s); } +#endif QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap) { @@ -620,6 +624,7 @@ QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap) return qtest_qmp_receive(s); } +#ifndef _WIN32 QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num, const char *fmt, ...) { @@ -631,6 +636,7 @@ QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num, va_end(ap); return response; } +#endif QDict *qtest_qmp(QTestState *s, const char *fmt, ...) { @@ -1327,6 +1333,7 @@ void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id, qobject_unref(args); } +#ifndef _WIN32 void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd) { QDict *resp; @@ -1346,6 +1353,7 @@ void qtest_qmp_add_client(QTestState *qts, const char *protocol, int fd) g_assert(!qdict_haskey(resp, "error")); qobject_unref(resp); } +#endif /* * Generic hot-unplugging test via the device_del QMP command. From patchwork Sun Sep 25 11:30:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987922 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 7B739C04A95 for ; Sun, 25 Sep 2022 12:06:27 +0000 (UTC) Received: from localhost ([::1]:47742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQOw-0002GD-Iu for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:06:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrp-0003Fg-Rl for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:14 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:35483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPro-0006Nc-Es for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:13 -0400 Received: by mail-pl1-x631.google.com with SMTP id t3so3951366ply.2 for ; Sun, 25 Sep 2022 04:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xtwjvK+ljk9V4L1gl+kZ+9qGQZitePo4pIZQo5m0KXA=; b=GCJCxqp6sS84jyOLLgrXV/2aKNyOFVtS3he2bkmFFcwgBcKOiLUNqPEtnMSMSc+6H7 waMP5bBKahK2D3qpXEPqzhDP0FMVUdmp0ClKwz8eLHY82SWCWgr6rGtRB2uD5G5FaOJH 2expNQY3NpsVuwhP7GGLxiWLbpbKG/XQAFd4Dn55MFmWLSFVitzYlLx+Lc8bqB6hlTWF lKWDvp6CRWAa+bYITiT7tMTR2qz5gpje22fGksDHok2FiqEtb6RnBlnbGNLKPVn4QkkS 6QV1kBUNfvhIzYhtJT8XGh0Z5jl4ZKY3+Z7o2RLOglfiZZeT1xjYkunD+qTTGAeRtWx8 vaJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=xtwjvK+ljk9V4L1gl+kZ+9qGQZitePo4pIZQo5m0KXA=; b=DgzygJHf9Y0ghyP8/J//mo2ZpVzYCXf6hKyLaFgtM2YQ5NlwNgk9A6ZRNdMai97i0X VVme38T3c12GSr/S/NyGSJ6cIKY9oCf6uCdeYxOnESNKMim68gcXtWi2/gm6j3iayica /nm40PqdfKwbMm1L6o0HOFRA71D5ogltNGjDBSeNCAQ/P5GyfFO5uhZeCCj3y84+O9w+ OArCcqIJwNMJ83oJbaJ+vDki+IuI//zult4tRS21laaPo8RDm766bJXmUyuYwk7qSKbi AGzrrajVlYmdsAFlIO0ngOjDNQZKc/EG3PS57338ptndcPoVa8bv+uinJ0v+Ow05QcJj uZAg== X-Gm-Message-State: ACrzQf15J5wwX+4THawDydp4nLSqfMyTnYdU9TVI17oFhMwm+zG30HBs innfteXzPXk92OdUD2esmPYLP3DSeMk= X-Google-Smtp-Source: AMsMyM6TrXp0WEptusnQztJwbG6B0+cxe1Juza/FM/aCtFa84DXqr/mQ5rxjy1rx2D4ht4LKifdV7Q== X-Received: by 2002:a17:903:284:b0:178:2a94:9b6a with SMTP id j4-20020a170903028400b001782a949b6amr17471306plr.135.1664105531417; Sun, 25 Sep 2022 04:32:11 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:11 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 35/54] tests/qtest: libqtest: Install signal handler via signal() Date: Sun, 25 Sep 2022 19:30:13 +0800 Message-Id: <20220925113032.1949844-36-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x631.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng At present the codes uses sigaction() to install signal handler with a flag SA_RESETHAND. Such usage can be covered by the signal() API that is a simplified interface to the general sigaction() facility. Update to use signal() to install the signal handler, as it is available on Windows which we are going to support. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/libqtest.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 269d622fe3..f0ac467903 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -66,7 +66,7 @@ struct QTestState }; static GHookList abrt_hooks; -static struct sigaction sigact_old; +static sighandler_t sighandler_old; static int qtest_query_target_endianness(QTestState *s); @@ -179,20 +179,12 @@ static void sigabrt_handler(int signo) static void setup_sigabrt_handler(void) { - struct sigaction sigact; - - /* Catch SIGABRT to clean up on g_assert() failure */ - sigact = (struct sigaction){ - .sa_handler = sigabrt_handler, - .sa_flags = SA_RESETHAND, - }; - sigemptyset(&sigact.sa_mask); - sigaction(SIGABRT, &sigact, &sigact_old); + sighandler_old = signal(SIGABRT, sigabrt_handler); } static void cleanup_sigabrt_handler(void) { - sigaction(SIGABRT, &sigact_old, NULL); + signal(SIGABRT, sighandler_old); } static bool hook_list_is_empty(GHookList *hook_list) From patchwork Sun Sep 25 11:30:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987932 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 ED362C04A95 for ; Sun, 25 Sep 2022 12:14:26 +0000 (UTC) Received: from localhost ([::1]:58682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQWf-00020M-Kq for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:14:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrt-0003Jl-IZ for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:27 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:43962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrr-0006Qs-DW for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:17 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d82so4152930pfd.10 for ; Sun, 25 Sep 2022 04:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Piw1OXyWwwLD9JGgfjn4u0pfw+bsIph7Kp2bvtzr/Js=; b=eb3faEaDa/EKMQwOaEBYIvKXNq40p2dH3X9bkNgyVR3homHLG1wP2/XakmHx1/PaqT rNIh+VM5inOm+TqdTf0a8RttswbcaXF6J2q7ogMeQ3i3OQRlGGSh24NzkwvVBRn7uMs0 E0waPXdEX0H7ItRquoSFNoHwcCQ8TFNhcImbEgwwwv66sJKbAstm5sCgMCYeIpKOSt84 U+JJpzD/qUSbdrJyqpox7OUE8zeQOFM9ZdEiL0H2FPs9q75i2ikRq0PuGhW8qDScBLMm 4xF7ghXyQjxWGqXOS5WE3g13XVgcHvSZvvC9Q7lyfnU0umBo5h74wSEZoU5P9JKb4Nhc UN7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Piw1OXyWwwLD9JGgfjn4u0pfw+bsIph7Kp2bvtzr/Js=; b=ECQ1dZH5wLOFSMyVmkYvRG6LEz7hSioyRRi6+27+d9iJtVdZ3tvGNE54oLiIsLwdcp hqWBEhOQp7X9jlOBq+wX8dzNsNh6vqTHyOeexU3rXq0dU3FD9grxaZe9vlzRQ5W6tgmN zSbpX3XkmtgF7WaNDYiOjcLInp2c63cWDPoswhGOPcqpPaV8Flfvhc4BwyKv15bnxt5P CucrE8CyoRNc19pAX+6u1cYDC4zz6W1yRx9oUOYhRWXtuKvvo3vfAFCahQ5KmkUEJXeV O08XVNcR1/HwGe5PiPhfBk7IWsc7Z79SIbD2olazQ9b0a2fEzcMA4WKoXJzYdMNRroKh bxHQ== X-Gm-Message-State: ACrzQf2bGNlNw2Ffir0FuKwOmnnEOJf8V3R+iObSDT4150qQ1lYOYj/1 BS8Dxczgl8J8HGlx/66xRBl5ZPCpuEY= X-Google-Smtp-Source: AMsMyM4kyTB8GXA3CyLgplKV/qpsiAzgTiP6uEV+fwbCKiXkB2lcmS0P0zo+I9EmDXEkHa68iTo9xA== X-Received: by 2002:a63:4c5f:0:b0:439:49b4:809f with SMTP id m31-20020a634c5f000000b0043949b4809fmr14841749pgl.382.1664105533942; Sun, 25 Sep 2022 04:32:13 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:13 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Xuzhou Cheng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 36/54] tests/qtest: Support libqtest to build and run on Windows Date: Sun, 25 Sep 2022 19:30:14 +0800 Message-Id: <20220925113032.1949844-37-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42b.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng At present the libqtest codes were written to depend on several POSIX APIs, including fork(), kill() and waitpid(). Unfortunately these APIs are not available on Windows. This commit implements the corresponding functionalities using win32 native APIs. With this change, all qtest cases can build successfully on a Windows host, and we can start qtest testing on Windows now. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Move the enabling of building qtests on Windows to a separate patch to keep bisectablity - Call socket_init() unconditionally - Add a missing CloseHandle() call tests/qtest/libqtest.c | 98 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index f0ac467903..12b1e85b51 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -16,9 +16,11 @@ #include "qemu/osdep.h" +#ifndef _WIN32 #include #include #include +#endif /* _WIN32 */ #ifdef __linux__ #include #endif /* __linux__ */ @@ -27,6 +29,7 @@ #include "libqmp.h" #include "qemu/ctype.h" #include "qemu/cutils.h" +#include "qemu/sockets.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qlist.h" @@ -35,6 +38,16 @@ #define MAX_IRQ 256 #define SOCKET_TIMEOUT 50 +#ifndef _WIN32 +# define CMD_EXEC "exec " +# define DEV_STDERR "/dev/fd/2" +# define DEV_NULL "/dev/null" +#else +# define CMD_EXEC "" +# define DEV_STDERR "2" +# define DEV_NULL "nul" +#endif + typedef void (*QTestSendFn)(QTestState *s, const char *buf); typedef void (*ExternalSendFn)(void *s, const char *buf); typedef GString* (*QTestRecvFn)(QTestState *); @@ -66,6 +79,9 @@ struct QTestState }; static GHookList abrt_hooks; +#ifdef _WIN32 +typedef void (*sighandler_t)(int); +#endif static sighandler_t sighandler_old; static int qtest_query_target_endianness(QTestState *s); @@ -118,10 +134,19 @@ bool qtest_probe_child(QTestState *s) pid_t pid = s->qemu_pid; if (pid != -1) { +#ifndef _WIN32 pid = waitpid(pid, &s->wstatus, WNOHANG); if (pid == 0) { return true; } +#else + DWORD exit_code; + GetExitCodeProcess((HANDLE)pid, &exit_code); + if (exit_code == STILL_ACTIVE) { + return true; + } + CloseHandle((HANDLE)pid); +#endif s->qemu_pid = -1; } return false; @@ -135,13 +160,23 @@ void qtest_set_expected_status(QTestState *s, int status) void qtest_kill_qemu(QTestState *s) { pid_t pid = s->qemu_pid; +#ifndef _WIN32 int wstatus; +#else + DWORD ret, exit_code; +#endif /* Skip wait if qtest_probe_child already reaped. */ if (pid != -1) { +#ifndef _WIN32 kill(pid, SIGTERM); TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0)); assert(pid == s->qemu_pid); +#else + TerminateProcess((HANDLE)pid, s->expected_status); + ret = WaitForSingleObject((HANDLE)pid, INFINITE); + assert(ret == WAIT_OBJECT_0); +#endif s->qemu_pid = -1; } @@ -149,6 +184,7 @@ void qtest_kill_qemu(QTestState *s) * Check whether qemu exited with expected exit status; anything else is * fishy and should be logged with as much detail as possible. */ +#ifndef _WIN32 wstatus = s->wstatus; if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != s->expected_status) { fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU " @@ -165,6 +201,16 @@ void qtest_kill_qemu(QTestState *s) __FILE__, __LINE__, sig, signame, dump); abort(); } +#else + GetExitCodeProcess((HANDLE)pid, &exit_code); + CloseHandle((HANDLE)pid); + if (exit_code != s->expected_status) { + fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU " + "process but encountered exit status %ld (expected %d)\n", + __FILE__, __LINE__, exit_code, s->expected_status); + abort(); + } +#endif } static void kill_qemu_hook_func(void *s) @@ -243,6 +289,38 @@ static const char *qtest_qemu_binary(void) return qemu_bin; } +#ifdef _WIN32 +static pid_t qtest_create_process(char *cmd) +{ + STARTUPINFO si; + PROCESS_INFORMATION pi; + BOOL ret; + + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + ZeroMemory(&pi, sizeof(pi)); + + ret = CreateProcess(NULL, /* module name */ + cmd, /* command line */ + NULL, /* process handle not inheritable */ + NULL, /* thread handle not inheritable */ + FALSE, /* set handle inheritance to FALSE */ + 0, /* No creation flags */ + NULL, /* use parent's environment block */ + NULL, /* use parent's starting directory */ + &si, /* pointer to STARTUPINFO structure */ + &pi /* pointer to PROCESS_INFORMATION structure */ + ); + if (ret == 0) { + fprintf(stderr, "%s:%d: unable to create a new process (%s)\n", + __FILE__, __LINE__, strerror(GetLastError())); + abort(); + } + + return (pid_t)pi.hProcess; +} +#endif /* _WIN32 */ + QTestState *qtest_init_without_qmp_handshake(const char *extra_args) { QTestState *s; @@ -270,6 +348,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) unlink(socket_path); unlink(qmp_socket_path); + socket_init(); sock = init_socket(socket_path); qmpsock = init_socket(qmp_socket_path); @@ -278,7 +357,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) qtest_add_abrt_handler(kill_qemu_hook_func, s); - command = g_strdup_printf("exec %s %s" + command = g_strdup_printf(CMD_EXEC "%s %s" "-qtest unix:%s " "-qtest-log %s " "-chardev socket,path=%s,id=char0 " @@ -287,7 +366,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) "%s" " -accel qtest", qemu_binary, tracearg, socket_path, - getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null", + getenv("QTEST_LOG") ? DEV_STDERR : DEV_NULL, qmp_socket_path, extra_args ?: ""); @@ -296,6 +375,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) s->pending_events = NULL; s->wstatus = 0; s->expected_status = 0; +#ifndef _WIN32 s->qemu_pid = fork(); if (s->qemu_pid == 0) { #ifdef __linux__ @@ -318,6 +398,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) execlp("/bin/sh", "sh", "-c", command, NULL); exit(1); } +#else + s->qemu_pid = qtest_create_process(command); +#endif /* _WIN32 */ g_free(command); s->fd = socket_accept(sock); @@ -336,9 +419,19 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args) s->irq_level[i] = false; } + /* + * Stopping QEMU for debugging is not supported on Windows. + * + * Using DebugActiveProcess() API can suspend the QEMU process, + * but gdb cannot attach to the process. Using the undocumented + * NtSuspendProcess() can suspend the QEMU process and gdb can + * attach to the process, but gdb cannot resume it. + */ +#ifndef _WIN32 if (getenv("QTEST_STOP")) { kill(s->qemu_pid, SIGSTOP); } +#endif /* ask endianness of the target */ @@ -392,6 +485,7 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd) g_assert_true(sock_dir != NULL); sock_path = g_strdup_printf("%s/sock", sock_dir); + socket_init(); sock_fd_init = init_socket(sock_path); qts = qtest_initf("-chardev socket,id=s0,path=%s -serial chardev:s0 %s", From patchwork Sun Sep 25 11:30:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987943 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 3064FC6FA82 for ; Sun, 25 Sep 2022 12:29:28 +0000 (UTC) Received: from localhost ([::1]:50996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQlD-0004C8-7F for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:29:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrx-0003Js-0r; Sun, 25 Sep 2022 07:32:27 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:36601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrv-0006R1-4x; Sun, 25 Sep 2022 07:32:20 -0400 Received: by mail-pj1-x102e.google.com with SMTP id s14-20020a17090a6e4e00b0020057c70943so9958581pjm.1; Sun, 25 Sep 2022 04:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Ys9PZej6Jr5Eh4o88j9BYOYlVXd3vSbqdt82ya5TQNo=; b=fl2pimBvUzMN51z5bGZhplbgYzfXG/TQLSWrOhNspA7XArF4mGSJLVIGDH2APkdQBc lvGhUmPQYccO3X7WoC8Ru86J2C65W317XAFg+jk8d9U5YD07r2wlfqH962aAIIjRK4TS k3tSye2jyM7QRw2YyXPf4w4pl0DV0el5akZ5T4vzPU803ZzUbVuyJ7grZRK6zpdlSyH+ zOzo/HBByqMDUPthJTEiyzo9vY3Y7zSW0Vew2XnlPY5ZjXKpKb/Z8mO02I5ukc3Zy9xF GkZCm+qodIBF6n5tbqShacyFhZqrnasMzazVVhIzGMTe8jGVlYHlgb50y5BwzdVXuW8c Mshg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Ys9PZej6Jr5Eh4o88j9BYOYlVXd3vSbqdt82ya5TQNo=; b=f6K9KTlvaaFt8BaFD3TCFziG+OjnAyrVo1VV2S4lx3hyBNMyr7iGv4Claze1Ylffqj Zc3Hy1r0aOhRuLveyecSieyQd9MrBEPEio82EXZRwxaRZeTnF0qtHm4STRp0zNpvc0+k +/jZD2R61cajMM9PuFSiOWtw9KFQfKSsiW4Bf7SZYvT8qggsTP621uYTAk7vHZ/0JD/i vfz/SfXLljaQPoH5Ya8Uk+rjQSet4xvuJ/8bDk4PXhm3rvv5r1yMsMnmNl7vOkugCrem trXfIVaITP6+Jpazk9bq4lt+Zy8F9pJkFTHF74Ai3vNZ1OUVIpEtKdO+vcUdlr/rwHqH jnvQ== X-Gm-Message-State: ACrzQf0G9tAOq5NAMiQTA4Kn9q+bVdWgottDUhvD3kv2OiEL6xe+QnKL DBVityBRjZDd/o+EtLWjz+thqtZmpYk= X-Google-Smtp-Source: AMsMyM6h7pPSfpnYYRBqI4Ogv8wPLIdXbBnNEXC/rMDx2Z1UpmQDK6G3zR46q9G+KmzGIpMLUy+6KQ== X-Received: by 2002:a17:90a:8909:b0:203:ab27:a41 with SMTP id u9-20020a17090a890900b00203ab270a41mr19918230pjn.163.1664105536721; Sun, 25 Sep 2022 04:32:16 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:16 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 37/54] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32 Date: Sun, 25 Sep 2022 19:30:15 +0800 Message-Id: <20220925113032.1949844-38-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102e.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng These test cases uses "blkdebug:path/to/config:path/to/image" for testing. On Windows, absolute file paths contain the delimiter ':' which causes the blkdebug filename parser fail to parse filenames. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau Reviewed-by: Thomas Huth --- (no changes since v1) tests/qtest/ahci-test.c | 21 ++++++++++++++++++--- tests/qtest/ide-test.c | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index 1d5929d8c3..66652fed04 100644 --- a/tests/qtest/ahci-test.c +++ b/tests/qtest/ahci-test.c @@ -1833,7 +1833,7 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr, int main(int argc, char **argv) { - const char *arch; + const char *arch, *base; int ret; int fd; int c; @@ -1871,8 +1871,22 @@ int main(int argc, char **argv) return 0; } + /* + * "base" stores the starting point where we create temporary files. + * + * On Windows, this is set to the relative path of current working + * directory, because the absolute path causes the blkdebug filename + * parser fail to parse "blkdebug:path/to/config:path/to/image". + */ +#ifndef _WIN32 + base = g_get_tmp_dir(); +#else + base = "."; +#endif + /* Create a temporary image */ - fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL); + tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base); + fd = g_mkstemp(tmp_path); g_assert(fd >= 0); if (have_qemu_img()) { imgfmt = "qcow2"; @@ -1889,7 +1903,8 @@ int main(int argc, char **argv) close(fd); /* Create temporary blkdebug instructions */ - fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL); + debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base); + fd = g_mkstemp(debug_path); g_assert(fd >= 0); close(fd); diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c index 25302be6dc..5e3e28aea2 100644 --- a/tests/qtest/ide-test.c +++ b/tests/qtest/ide-test.c @@ -1011,16 +1011,32 @@ static void test_cdrom_dma(void) int main(int argc, char **argv) { + const char *base; int fd; int ret; + /* + * "base" stores the starting point where we create temporary files. + * + * On Windows, this is set to the relative path of current working + * directory, because the absolute path causes the blkdebug filename + * parser fail to parse "blkdebug:path/to/config:path/to/image". + */ +#ifndef _WIN32 + base = g_get_tmp_dir(); +#else + base = "."; +#endif + /* Create temporary blkdebug instructions */ - fd = g_file_open_tmp("qtest-blkdebug.XXXXXX", &debug_path, NULL); + debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base); + fd = g_mkstemp(debug_path); g_assert(fd >= 0); close(fd); /* Create a temporary raw image */ - fd = g_file_open_tmp("qtest.XXXXXX", &tmp_path, NULL); + tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base); + fd = g_mkstemp(tmp_path); g_assert(fd >= 0); ret = ftruncate(fd, TEST_IMAGE_SIZE); g_assert(ret == 0); From patchwork Sun Sep 25 11:30:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987935 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 12B13C6FA82 for ; Sun, 25 Sep 2022 12:19:43 +0000 (UTC) Received: from localhost ([::1]:59000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQbl-0007r1-OU for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:19:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPrz-0003Ju-GE for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:28 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:46712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPrw-0006RL-QQ for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:22 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 78so4188343pgb.13 for ; Sun, 25 Sep 2022 04:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=tuLrhiLQdAPzFXDphS6mjumk8PaBwG5Yc1g/mTPgSBs=; b=dJIRoFIJ4EOGsN8OWRhXMf99HMJ2b9qhCkeGNFtAkN9K/uNsWEPY0cquyHqCVi1fA0 wH0F4R8Kl/pcGK6eYCNbDsWnshcW/BqO2mpII52ZoBnANMizapJR1J8EHTVNI50zW1NH XcDxaolap9pyjBlUcX8+PLYm20M8rhQymWrT/C6WaCC/YFF5aqfX/O/3oOn3PL03m40T 1guY1lPgna9haGI9OxQvAFjW9Z63IQd0XpB3y1Yfb/HW9N8Aa7g5O4L+plxCpzLqf7lV qtfSF6VK528QOkP5NVXLSNHPwNCvxj0VuXW+klkIV9gI1p49Q0DMwn4osUPvEXjf4rkI lFbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=tuLrhiLQdAPzFXDphS6mjumk8PaBwG5Yc1g/mTPgSBs=; b=nL7EmtIL0WdUG7RVzDzLbm7nsP3BysHbrW4sdYJ85k4OO1wG5AZhiq556PERWN/4vJ cSXxkRZsYV1ebz5zoDB9zcz34HgMt0SAM83ae4sOk0FjAfGbsGlU4SuQ4nLWzjTb0tK2 yEFh4KAZ6J+1FR9Sm9OFT1KpOq6fGE4h9tYR9v+yn+O6w1lAzxQxgypqi+60I7zAQeZI zDzGVdffNcFz3Ylar7WMnAa+JEnwwKZBk3ypmFh37I//jjYmE8H+t+qWPihywz1W0Tvs jBw1tOqAGlwKQlYZJpqjkm1bjNqaUsce4RjmG6M/5YhQX7ZIMrSmnDGJd10rJr4xy5hQ B4vg== X-Gm-Message-State: ACrzQf1l23PFNG/i8qZvQVuDlzWkAhrn8B0DEjWSdl+82Eb83LagLUyG DXGUI9WnIGiJdSrXU5+1Z/CViA/nhLw= X-Google-Smtp-Source: AMsMyM6uFxo35m8NUr6OcY63TgxDBpyqTKGMpHivCNvX/Brdnl2e55f9l1vVZ7ckt68xpvo9/wQhEg== X-Received: by 2002:a63:9141:0:b0:43b:d645:e057 with SMTP id l62-20020a639141000000b0043bd645e057mr15243846pge.225.1664105539148; Sun, 25 Sep 2022 04:32:19 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:18 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Ani Sinha , Igor Mammedov , "Michael S. Tsirkin" Subject: [PATCH v3 38/54] tests/qtest: bios-tables-test: Adapt the case for win32 Date: Sun, 25 Sep 2022 19:30:16 +0800 Message-Id: <20220925113032.1949844-39-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52a.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Single quotes in the arguments (oem_id='CRASH ') are not removed in the Windows environment before it is passed to the QEMU executable. The space in the argument causes the "-acpitable" option parser to think that all of its parameters are done, hence it complains: '-acpitable' requires one of 'data' or 'file' Change to use double quotes which works fine on all platforms. Also /dev/null does not work on win32, and nul should be used. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau Acked-by: Michael S. Tsirkin --- (no changes since v1) tests/qtest/bios-tables-test.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 46a46fe0aa..2ebeb530b2 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1615,6 +1615,12 @@ static void test_acpi_virt_viot(void) free_test_data(&data); } +#ifndef _WIN32 +# define DEV_NULL "/dev/null" +#else +# define DEV_NULL "nul" +#endif + static void test_acpi_q35_slic(void) { test_data data = { @@ -1622,9 +1628,9 @@ static void test_acpi_q35_slic(void) .variant = ".slic", }; - test_acpi_one("-acpitable sig=SLIC,oem_id='CRASH ',oem_table_id='ME'," - "oem_rev=00002210,asl_compiler_id='qemu'," - "asl_compiler_rev=00000000,data=/dev/null", + test_acpi_one("-acpitable sig=SLIC,oem_id=\"CRASH \",oem_table_id=ME," + "oem_rev=00002210,asl_compiler_id=qemu," + "asl_compiler_rev=00000000,data=" DEV_NULL, &data); free_test_data(&data); } From patchwork Sun Sep 25 11:30:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987927 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 145F7C6FA82 for ; Sun, 25 Sep 2022 12:10:31 +0000 (UTC) Received: from localhost ([::1]:39360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQSs-0004No-7J for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:10:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPs2-0003KB-W7 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:28 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:36439) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPs0-0006Rg-5v for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:25 -0400 Received: by mail-pg1-x535.google.com with SMTP id s206so4233888pgs.3 for ; Sun, 25 Sep 2022 04:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=5kKZaIAKRf3+/+NyY6g6OcFI9UiTTHHGJ90OxnS38Zw=; b=m26TbFMjIlzTSYajRBhcg/LSYervDzHNUo2oBh7F+VV0SSy3Dvb+ibvpc7jgqgOw3s IM7zSTwvy4tNJDXWJyqLi8XO46Q9p0AGu0FRz7lW8F/D2iUm9Y0qvRX0j0szVm0HK9Bo x22EQyS8vfjx8o11rSSxCbAsLkRqVBIST1BmvJ/bLVhSqANTc4NY2aON8Nej/hQuTSv9 ZFgeoF8Wd/w1rxYTPO2mjTGKrT9cvL+mEYVRVSDz53oTdNUeBZSKqLAuNeWFof40Aj5P uf/0II55nBtU6zy1RLBIsqgWKilReqc8385RT3UZxNLOQeZVHtzKgFna+mQOORiSrN+Q 0ZDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=5kKZaIAKRf3+/+NyY6g6OcFI9UiTTHHGJ90OxnS38Zw=; b=EeklUez5D56yWYApBf0WhCKAzLWKZkgNe8hUQGaGEJAuYKDNGAP0Rx2aGUglmFJji0 UmlT4c4eGTX79tYN6VIGvKnXXptV54qBYmx/SR7rC/0RBPD4ia++E1D7QIbDtzgJI9l8 qev/Mz2zEVkuyRXwli0w3NrafMjVz4PKUpHk48aVJQ6nC+qgLRUiOBNAPvx4ZxpI8Mx9 VWWBp5AyCAvxEHE/vmTd1AQ2okz6/Tff3xzgx7DjhLHxy8L2I+DOu6kXYnBN4hW39OJG CvbiDv1uFxfGDu30Ropj6ImGtAoqd1uy6ZxOknZvkdLRaGsYpGhnwEzEAfM0/74z9syZ CVqQ== X-Gm-Message-State: ACrzQf2VB3nV35Txkjc+CyqbWvkCDOIjPNHVpTJCEp2w/mdXVTWYGcpk voioy1WsOloj838ltICNVqslw7j5pwc= X-Google-Smtp-Source: AMsMyM4Lm4+tJNAcUytsW6fPp/qL7u3n4dOsB6iOTWW3G36DRk8kOn+J6If4ry9Qx1EG2RIJYmBB/A== X-Received: by 2002:a62:4c2:0:b0:52e:bd4d:50e1 with SMTP id 185-20020a6204c2000000b0052ebd4d50e1mr18689505pfe.8.1664105541844; Sun, 25 Sep 2022 04:32:21 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:21 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 39/54] tests/qtest: migration-test: Disable IO redirection for win32 Date: Sun, 25 Sep 2022 19:30:17 +0800 Message-Id: <20220925113032.1949844-40-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::535; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x535.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng On Windows the QEMU executable is created via CreateProcess() and IO redirection does not work, so don't bother adding IO redirection to the command line. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Change the place that sets IO redirection in the command line tests/qtest/migration-test.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 029c4f3a6a..a1dd342739 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -647,7 +647,16 @@ static int test_migrate_start(QTestState **from, QTestState **to, } if (!getenv("QTEST_LOG") && args->hide_stderr) { +#ifndef _WIN32 ignore_stderr = "2>/dev/null"; +#else + /* + * On Windows the QEMU executable is created via CreateProcess() and + * IO redirection does not work, so don't bother adding IO redirection + * to the command line. + */ + ignore_stderr = ""; +#endif } else { ignore_stderr = ""; } From patchwork Sun Sep 25 11:30:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987931 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 8489DC04A95 for ; Sun, 25 Sep 2022 12:14:17 +0000 (UTC) Received: from localhost ([::1]:44238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQWW-0001hs-DV for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:14:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPs8-0003Nb-Fb; Sun, 25 Sep 2022 07:32:33 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:46660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPs3-0006Rt-7N; Sun, 25 Sep 2022 07:32:28 -0400 Received: by mail-pf1-x42e.google.com with SMTP id c198so4138848pfc.13; Sun, 25 Sep 2022 04:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=OBfXa3xFVi4lbcy7vm7XKQ/MxZiXQOmmQuqalNwWIA4=; b=dCsDknvWnfotQeY7AC9SontTAI7/UX8fr/91Hfq9NBI4f91dl3DmCkLjGFcfdu8u+L CArNlDYUIrvqe72Wl9hSFAYLgb4C2ykB31jcboIUwmjxJzAcp26HTdalE0WepR7Yi87N rBTL6y3gqcmquY0hibe0L/jq7PC2JBQpKRnGbTOtSkDZXtq8V9zISe/dtkwpTbK+sB6p Ar+AixcHICI/8sx5foVDEWM2uVt7bZWyGNcxz6E1pA6SgYmMrE0zxtC0xLptEn8qRCWg 2LU/CqEEO9tCyQj1gxVuhRPM8+L4lbiyGRtlXFoxBpgJUPLLCGnqTP6L9MPWpzk4h9N/ 171A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=OBfXa3xFVi4lbcy7vm7XKQ/MxZiXQOmmQuqalNwWIA4=; b=Mf1FTmsUkGQRBaJuxTvjkPmfHUw/GWFgDjfFc2YP3DLAOoxarokI2Sd3AaD2R8nRjT vzuBqM084gMY56nVlhv3asnKCLMmgKWOK3puNWjZ4n4XBmUO5Ln+ocQdEsBISVGnqRfW 2QG2PYY7mQ+NhFJpGYEYSBWXZ8qx+nElARSHqJmzv/MwHGsEVWWpcCz/WnoLWDlq3lBv mtgYFb8BPuPzjqff0Xiz45L5Hf+acx7RvW0lSURafnFEdeL6Lhbty0KvSyDU6xIxnAYl lW0GSeF8TqfR9I0tyWwSBp7TfBT8kHvbJsl9JZLQuhFwZ0vlZftbvB0iSOnsXoKlDv94 9JJg== X-Gm-Message-State: ACrzQf3JOSx4tRsNXu5DX9JrZ7juUuFehQyzAubQKOHrO4XciWVsNJph vt9eQ28PnYqZONqp9QF/3zxuRIWfNK8= X-Google-Smtp-Source: AMsMyM62rQF2HCdx52L2ETTIilN+MAkxuVk8L/p1GhZGWYqDye0ZHnw+4ZI23tvKFcj+MdFfMbiAJA== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr15084465pgc.465.1664105544646; Sun, 25 Sep 2022 04:32:24 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:24 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v3 40/54] tests/qtest: ide-test: Open file in binary mode Date: Sun, 25 Sep 2022 19:30:18 +0800 Message-Id: <20220925113032.1949844-41-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng By default Windows opens file in text mode, while a POSIX compliant implementation treats text files and binary files the same. The fopen() 'mode' string can include the letter 'b' to indicate binary mode shall be used. POSIX spec says the character 'b' shall have no effect, but is allowed for ISO C standard conformance. Let's add the letter 'b' which works on both POSIX and Windows. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Drop ahci-test.c changes that are no longer needed tests/qtest/ide-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/ide-test.c b/tests/qtest/ide-test.c index 5e3e28aea2..4ea89c26c9 100644 --- a/tests/qtest/ide-test.c +++ b/tests/qtest/ide-test.c @@ -892,7 +892,7 @@ static void cdrom_pio_impl(int nblocks) /* Prepopulate the CDROM with an interesting pattern */ generate_pattern(pattern, patt_len, ATAPI_BLOCK_SIZE); - fh = fopen(tmp_path, "w+"); + fh = fopen(tmp_path, "wb+"); ret = fwrite(pattern, ATAPI_BLOCK_SIZE, patt_blocks, fh); g_assert_cmpint(ret, ==, patt_blocks); fclose(fh); @@ -993,7 +993,7 @@ static void test_cdrom_dma(void) prdt[0].size = cpu_to_le32(len | PRDT_EOT); generate_pattern(pattern, ATAPI_BLOCK_SIZE * 16, ATAPI_BLOCK_SIZE); - fh = fopen(tmp_path, "w+"); + fh = fopen(tmp_path, "wb+"); ret = fwrite(pattern, ATAPI_BLOCK_SIZE, 16, fh); g_assert_cmpint(ret, ==, 16); fclose(fh); From patchwork Sun Sep 25 11:30:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987938 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 50AFAC6FA82 for ; Sun, 25 Sep 2022 12:24:18 +0000 (UTC) Received: from localhost ([::1]:59522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQgD-0005Dg-9V for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:24:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPs9-0003O1-Mm for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:35 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:46662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPs8-0006SC-7c for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:33 -0400 Received: by mail-pf1-x430.google.com with SMTP id c198so4138892pfc.13 for ; Sun, 25 Sep 2022 04:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=szrrAWQi57rwmVvkIAS0k/zzBtjmcZYK/YPRpaNr+UQ=; b=Ac8zwGnmGEkBx+sIGgR5ofdu27upsvLWQjI7ItCxyNFxWR/H/qIDBZT1EnKn8jlDit bFFv7kFOUfIaIW2RsWr50f/CgGHQ8Tj0+QaMNVoL2XY+W4QsAZrGjyO74HiXNwvrXW7d EQjN1G39ehRyzp9GL7k7IyQbkFS3F7zDm08GkO2km81c5s4U8iEg64s8N8YH7dq29sb4 brBEj1do5EuRNvsipKsJNlcoCtxjxVa7aFuWeqzPE2KZkqAW+eFohJFW7JkQXAauSNn5 GfdbrVJqmzJg2SNOd5fhO9ttQspZDDciD3Bgjv2c7dBUjabR/l0VKOKK7cvifeUieb0l 3v+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=szrrAWQi57rwmVvkIAS0k/zzBtjmcZYK/YPRpaNr+UQ=; b=rPtqaweyq7L9BA94+e2iiLPixcrkFEjvO6oAshxUS1RNmw6Cj8okZhc8NfJ2UB0aHl 53PIkAZu8/5BBxt2u83Iy8y9zSOOCfCvdyYGepE69nKdKfcswiMx4AV8RVkxY4VWATQQ Jay2wMl9hqMf3l46DTp7hoG4buPJzXPY+zFEF62lWK3IaQzFb9ejQh8bxvFIV5GKIupY fB6m/1v4ZcZEbbHAHwy35G/J4osO1NVj8jzIWai4kLU6JR5Xl8nUqJTvlUluQW4D31SU IGefHTs+udOlx2b2oqqVuQzxFxJODBCWzimmMegqHcAneBymlpOyZtu3/W11F/nRqvi0 DoWg== X-Gm-Message-State: ACrzQf1xyQCBd0ebEm/w1swmUYhyLd4FI9nQDatM9B/1CaeMogdnMdz8 SFvA/VoTYz3VEdsizI6QnitObiDzhvg= X-Google-Smtp-Source: AMsMyM4UppYF8Bvy2NzVS20xvywW4F1yUk5nykbcJn1aUxjokm8yYhg3fe4rE1WAM6iak8/r4dv1Ow== X-Received: by 2002:a63:5fd6:0:b0:434:96fe:f508 with SMTP id t205-20020a635fd6000000b0043496fef508mr15319120pgb.306.1664105547217; Sun, 25 Sep 2022 04:32:27 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:26 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 41/54] tests/qtest: virtio-net-failover: Disable migration tests for win32 Date: Sun, 25 Sep 2022 19:30:19 +0800 Message-Id: <20220925113032.1949844-42-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x430.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng These tests use the exec migration protocol, which is unsupported on Windows as of today. Disable these tests for now. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/virtio-net-failover.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/qtest/virtio-net-failover.c b/tests/qtest/virtio-net-failover.c index 443ee56de9..4a809590bf 100644 --- a/tests/qtest/virtio-net-failover.c +++ b/tests/qtest/virtio-net-failover.c @@ -588,6 +588,7 @@ static void test_hotplug_2_reverse(void) machine_stop(qts); } +#ifndef _WIN32 static QDict *migrate_status(QTestState *qts) { QDict *resp, *ret; @@ -1827,6 +1828,7 @@ static void test_multi_in(gconstpointer opaque) machine_stop(qts); } +#endif /* _WIN32 */ int main(int argc, char **argv) { @@ -1857,7 +1859,11 @@ int main(int argc, char **argv) qtest_add_func("failover-virtio-net/hotplug/2_reverse", test_hotplug_2_reverse); - /* migration tests */ +#ifndef _WIN32 + /* + * These migration tests cases use the exec migration protocol, + * which is unsupported on Windows. + */ qtest_add_data_func("failover-virtio-net/migrate/on/out", tmpfile, test_migrate_out); qtest_add_data_func("failover-virtio-net/migrate/on/in", tmpfile, @@ -1886,6 +1892,7 @@ int main(int argc, char **argv) tmpfile, test_multi_out); qtest_add_data_func("failover-virtio-net/migrate/multi/in", tmpfile, test_multi_in); +#endif /* _WIN32 */ ret = g_test_run(); From patchwork Sun Sep 25 11:30:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987949 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 120DFC6FA82 for ; Sun, 25 Sep 2022 12:36:59 +0000 (UTC) Received: from localhost ([::1]:44534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQsT-0002Aw-Lx for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:36:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60074) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPs9-0003O3-TH for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:35 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]:40688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPs8-0006SH-7x for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:33 -0400 Received: by mail-pl1-x633.google.com with SMTP id b21so3924935plz.7 for ; Sun, 25 Sep 2022 04:32:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=AlbGfswSfsbErT9c2Vi9QSm49FyIznpLBZX8XPIW0d4=; b=SrMry3rmOnWUdusjOufGMRu9nZcspylO/6ONnFiJCK/eQrBkH2QeKrfbOOqe2CsASA q4LkcYkpwXXz4GMqG646aB7siPQXPTkSxttPf4p69iE4xaqD80UXMQ+0kFC0+8o8Ar29 SIhanLbuBotHp+wX22wxVBOvZbwZPaZM5PVMmoBqSzgLlc+zvsI6pzEZzEQzAQoO3Xsn W+J0NIgAH7Hw1FAav7hbUSQp44uFa08evML+8OB7mpFM1i1bYCEaaGLDzj5j9FTFlY8i O2im47GFSmg9jlIHyJxXb3z5UMRTJiTUeX+bBJxG8j+wEXi/+IloL/vR/Zj2UOSDZd+r lMxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=AlbGfswSfsbErT9c2Vi9QSm49FyIznpLBZX8XPIW0d4=; b=gaj70qbt8rm4Kmpjl7yuzXK7LQ4H0ggj4mpV9yEYcFM0XUUgnHJmeEYaarhsoNNRK5 gA9Nght9g+qtn4Bw+v7J5nvqPjAKcq8RponCR/hJ1loz3h0uwXiI29BnbUyagHHwkPgQ 9rmLwgADH2Mn2anJF28TKq+UL0DpIaxeXzfEBsoooSHh57M70YZrkLxylyQ2dcZp7h5v Fb1Gsr1ml/xUqpf0bm+QzGzcp3oE6MmlTWZ3xFkPfhkjO8IPV+TNTe57eQju14aHSXRe 6Ot0Mf4jk6CQQgUmmK4F3D0vjMJ2H+UOc4dsfaGZAQM83wSC2UH887LWzO7maTmkEu7i DcuQ== X-Gm-Message-State: ACrzQf08W3YixezLGRjKFH5whFLtBwxcPTIxMUnzax4Thngw8yQjZMq/ TqkpwDEc750XkzMsQYMkSgrSHt6gHAA= X-Google-Smtp-Source: AMsMyM7nsQtx6dGZ4T4pblWiJCZCK1+8w1wjzjgON28oYhIw/bEbbSgqB85e48W5Yjr8b6Zrd/Vn/w== X-Received: by 2002:a17:903:244e:b0:178:4f50:1ca0 with SMTP id l14-20020a170903244e00b001784f501ca0mr17163678pls.104.1664105549289; Sun, 25 Sep 2022 04:32:29 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:29 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Paolo Bonzini Subject: [PATCH v3 42/54] chardev/char-file: Add FILE_SHARE_WRITE when opening the file for win32 Date: Sun, 25 Sep 2022 19:30:20 +0800 Message-Id: <20220925113032.1949844-43-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x633.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng The combination of GENERIC_WRITE and FILE_SHARE_READ options does not allow the same file to be opened again by CreateFile() from another QEMU process with the same options when the previous QEMU process still holds the file handle opened. This was triggered by running the test_multifd_tcp_cancel() case on Windows, which cancels the migration, and launches another QEMU process to migrate with the same file opened for write. Chances are that the previous QEMU process does not quit before the new QEMU process runs hence the old one still holds the file handle that does not allow shared write permission then the new QEMU process will fail. There is another test case boot-serial-test that triggers the same issue. The qtest executable created a serial chardev file to be passed to the QEMU executable. The serial file was created by g_file_open_tmp(), which internally opens the file with FILE_SHARE_WRITE security attribute, and based on [1], there is only one case that allows the first call to CreateFile() with GENERIC_READ & FILE_SHARE_WRITE, and second call to CreateFile() with GENERIC_WRITE & FILE_SHARE_READ. All other combinations require FILE_SHARE_WRITE in the second call. But there is no way for the second call (in this case the QEMU executable) to know what combination was passed to the first call, so we will have to add FILE_SHARE_WRITE to the second call. For both scenarios we should add FILE_SHARE_WRITE in the chardev file backend driver. This change also makes the behavior to be consistent with the POSIX platforms. [1] https://docs.microsoft.com/en-us/windows/win32/fileio/creating-and-opening-files Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- Changes in v3: - Add another case "boot-serial-test" to justify the change Changes in v2: - Update commit message to include the use case why we should set FILE_SHARE_WRITE when opening the file for win32 chardev/char-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char-file.c b/chardev/char-file.c index 2fd80707e5..66385211eb 100644 --- a/chardev/char-file.c +++ b/chardev/char-file.c @@ -60,8 +60,8 @@ static void qmp_chardev_open_file(Chardev *chr, flags = CREATE_ALWAYS; } - out = CreateFile(file->out, accessmode, FILE_SHARE_READ, NULL, flags, - FILE_ATTRIBUTE_NORMAL, NULL); + out = CreateFile(file->out, accessmode, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, flags, FILE_ATTRIBUTE_NORMAL, NULL); if (out == INVALID_HANDLE_VALUE) { error_setg(errp, "open %s failed", file->out); return; From patchwork Sun Sep 25 11:30:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987929 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 D339FC6FA82 for ; Sun, 25 Sep 2022 12:11:24 +0000 (UTC) Received: from localhost ([::1]:42198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQTk-0005Hj-0q for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:11:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsB-0003On-Bb for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:37 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:45704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPs9-0006SV-K3 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:34 -0400 Received: by mail-pg1-x52d.google.com with SMTP id r62so390332pgr.12 for ; Sun, 25 Sep 2022 04:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=YsVoae9ivi9Cg+kCdP1PRZfFksunz3gscATDK4L4ZUA=; b=cNxpQ7jSHDfY68Cqg/xlvB6wyba2e1lDf/2BVtZb5AuhvkuR9C3GhMF/R5kKUlc7du habTHdHW9uSMqw36KQ4e28GWl4UswDrgf/pViczPQbsueHogqxwUsv+Y3ONrIRvdfGzT whauQR6V76i/yG95qlxnKWlue0DkWqmn0pb+8QN69Lin/QIOPU9DIpSgJNP3NUdrvivU h+n9PpGDmrTzcu2adZAdZJjTaShJ8d6RxMeD1ZApXHQRuUV6bDfm4gf7SvOl1yfwOuDw Dg7sUPuat9m+6g6PR6a8wlmPoBjO1aTtuxmoVOA7nZbCWGZl3D5bqX6UkOP3WNzVfWbK JQqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=YsVoae9ivi9Cg+kCdP1PRZfFksunz3gscATDK4L4ZUA=; b=48RoMIfKk2RSbpkN2+2WpqaKIZRUqTug/3TUDaRrTboViDZIPBD9nyyXhRoKyWK+3j CDP8tH3LrcGND02tNQ9kwb7ODjf+fbTHXamLTjkpYk7w6wYFBU4hRR+CUURoJd+XRsZp +iqC8qoMISHE/7md5p8pkeos5Uig+FijZvcdvGLUMkkSjKf+H+pgLwH0wmqwA3AaTUh5 BZi/N85+RjI/TtLswyI860E3UXjMcVmJfigyaGAuE+EXYEhe+rC5iiTp7EyLJ/z+s0eE xjz7DKr2sxJcWMUDUG6RVFKVlEyEzCt4h2IdUEP9XXDsFj7ZJt3v2nYeZFJ/IwgNpQjD d+UA== X-Gm-Message-State: ACrzQf0acWatcsr+F383WcUMj/MhmOR2q+TbvKS8y8BnhTYpWBSNdbzy ++tZeV+A3bDysNPqOln3qYCXV6Xbs5w= X-Google-Smtp-Source: AMsMyM4kJ8GIssnDjNjwmzdNK7nTimeh1EXZXcfv/6dw4DGF8DGNmjcUkakEq2EaS/Y7wAWoqqlbMQ== X-Received: by 2002:a05:6a00:1a44:b0:528:6af7:ff4a with SMTP id h4-20020a056a001a4400b005286af7ff4amr18381770pfv.78.1664105552193; Sun, 25 Sep 2022 04:32:32 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:31 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 43/54] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled Date: Sun, 25 Sep 2022 19:30:21 +0800 Message-Id: <20220925113032.1949844-44-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52d.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng Make sure QEMU process "to" exited before launching another target for migration in the test_multifd_tcp_cancel case. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- Changes in v3: - Add a usleep(1) in the busy wait loop Changes in v2: - Change to a busy wait after migration is canceled tests/qtest/migration-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index a1dd342739..9ec501d1eb 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2132,6 +2132,10 @@ static void test_multifd_tcp_cancel(void) wait_for_migration_pass(from); migrate_cancel(from); + /* Make sure QEMU process "to" exited */ + while (qtest_probe_child(to)) { + usleep(1); + } args = (MigrateStart){ .only_target = true, From patchwork Sun Sep 25 11:30:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987953 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 40F45C04A95 for ; Sun, 25 Sep 2022 12:42:02 +0000 (UTC) Received: from localhost ([::1]:56818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQxN-0002a1-2c for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:42:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56622) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsE-0003Ph-6J; Sun, 25 Sep 2022 07:32:38 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:45704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsC-0006SV-Iz; Sun, 25 Sep 2022 07:32:37 -0400 Received: by mail-pg1-x52d.google.com with SMTP id r62so390384pgr.12; Sun, 25 Sep 2022 04:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cdOM1RV7vfdzIOgDlIpgFRBOhfRCBARffZGNXtbDMOw=; b=ckQm1fbAl9t6B4cGBfQxqm7V7vseIckI5swjAOXzsBs5s2ph+lRuq6Yk6bxqFM/8nl MeX9A0d8aMxtMyWQWjez1bup8rizgea+bBdYMvZA8xcPrK/EVLFAq56e69ZJ+CvRz6Ta uaZmHeKf5NZa0Mdjkpdc/iWIkTEdLPZTCVlK5xX9RMQmpCHJII+4ngNn2NFN82VVL5zp QevNsje6x9Rhhx8woqENCMndCI0WpWWKIjcghKO6xgdXSuEQiOnmoHjsEqGf6nTXP1j6 6NQ7XjH3b8hmXNnfU4vOPipGbvbYG4IZaVkTUl3d9FRgxs5BH1uMhBR2p4VuFcSOYNV6 Cbzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=cdOM1RV7vfdzIOgDlIpgFRBOhfRCBARffZGNXtbDMOw=; b=haUwKDLqAD+Sa0JbXHBovarSdK87o7kjCvQK49Fq0R0uOH6Ldi9WfHXj/iRtrqJqTD ymfCItcNGMeV5k5sL+Cn3ao3z7vEeoLb1Obu3Xl7niwEkMjZ9jLQTU7F2wL5hpTvgYon QR+mlXk/ZciloPNPYt3pVvtMc3BxoMSeE0mg5GU1BbcvA5kyRvHKAyvBd6grYPuuRPpE LUNcQH5AUewaaJE64Gk7nhDn/PmamC/Olk/W3sR2SM1DSW4E5vhxb70GHAv/rm4DlSQz FdcnFeFB9ZEjqR68Wz5fdKsGjM7EGgcqpsYm8XOftCAcWfSmV1kxcDUexBSDHbrj3LZZ M1Eg== X-Gm-Message-State: ACrzQf27LuULOV6w430v1YrLnDXGPvJ1Iw/5q+8b2sVN/GF7MJBGjWB1 MNAKHYmgMCzrkYO5OkLAxciZYu+Oi3w= X-Google-Smtp-Source: AMsMyM4oL0h8hnl2A8YK4HFYPQRMitc7/hF9PEg9p+IEuijli9f6v69p/RHyauZtbZWczZ3M2VGW7w== X-Received: by 2002:a63:31d6:0:b0:43a:1129:e485 with SMTP id x205-20020a6331d6000000b0043a1129e485mr15393067pgx.177.1664105555146; Sun, 25 Sep 2022 04:32:35 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:34 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Joel Stanley , Laurent Vivier , Paolo Bonzini , Peter Maydell , Thomas Huth , qemu-arm@nongnu.org Subject: [PATCH v3 44/54] tests/qtest: microbit-test: Fix socket access for win32 Date: Sun, 25 Sep 2022 19:30:22 +0800 Message-Id: <20220925113032.1949844-45-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52d.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Sockets on Windows do not use *nix-style file descriptors, so write()/read()/close() do not work on Windows. Switch over to use send()/recv()/closesocket() which work with sockets on all platforms. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/microbit-test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/qtest/microbit-test.c b/tests/qtest/microbit-test.c index b71daae9a9..4bc267020b 100644 --- a/tests/qtest/microbit-test.c +++ b/tests/qtest/microbit-test.c @@ -51,7 +51,7 @@ static void uart_rw_to_rxd(QTestState *qts, int sock_fd, const char *in, { int i, in_len = strlen(in); - g_assert_true(write(sock_fd, in, in_len) == in_len); + g_assert_true(send(sock_fd, in, in_len, 0) == in_len); for (i = 0; i < in_len; i++) { g_assert_true(uart_wait_for_event(qts, NRF51_UART_BASE + A_UART_RXDRDY)); @@ -77,7 +77,7 @@ static void test_nrf51_uart(void) char s[10]; QTestState *qts = qtest_init_with_serial("-M microbit", &sock_fd); - g_assert_true(write(sock_fd, "c", 1) == 1); + g_assert_true(send(sock_fd, "c", 1, 0) == 1); g_assert_cmphex(qtest_readl(qts, NRF51_UART_BASE + A_UART_RXD), ==, 0x00); qtest_writel(qts, NRF51_UART_BASE + A_UART_ENABLE, 0x04); @@ -97,17 +97,17 @@ static void test_nrf51_uart(void) qtest_writel(qts, NRF51_UART_BASE + A_UART_STARTTX, 0x01); uart_w_to_txd(qts, "d"); - g_assert_true(read(sock_fd, s, 10) == 1); + g_assert_true(recv(sock_fd, s, 10, 0) == 1); g_assert_cmphex(s[0], ==, 'd'); qtest_writel(qts, NRF51_UART_BASE + A_UART_SUSPEND, 0x01); qtest_writel(qts, NRF51_UART_BASE + A_UART_TXD, 'h'); qtest_writel(qts, NRF51_UART_BASE + A_UART_STARTTX, 0x01); uart_w_to_txd(qts, "world"); - g_assert_true(read(sock_fd, s, 10) == 5); + g_assert_true(recv(sock_fd, s, 10, 0) == 5); g_assert_true(memcmp(s, "world", 5) == 0); - close(sock_fd); + closesocket(sock_fd); qtest_quit(qts); } From patchwork Sun Sep 25 11:30:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987956 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 80032C6FA83 for ; Sun, 25 Sep 2022 12:46:17 +0000 (UTC) Received: from localhost ([::1]:48652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocR1U-0000MK-JR for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:46:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsG-0003UU-I6 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:40 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:44021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsF-0006T8-1p for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:40 -0400 Received: by mail-pg1-x52c.google.com with SMTP id v4so4202759pgi.10 for ; Sun, 25 Sep 2022 04:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=GlznwSHa9K/cOS1FRxJZ04KXhLV4Kvl8Dx3ESYYXk8U=; b=ehVsBlTe0XK2u79214xRV+1QcnzqShkpzsQeAY6Fk3ilNUOl6Y99NPYCnWVg7uuJ9W rV95a1RiUmp/7X00u0YeWJPzzhlp6P0REEcwKOIQWb+SQR50Y9SjvCD2a48G/gBv1WNm BXvipG1B/fNWMnhN1auP+tMoFE0X82HHuhc5f+reG+pNarObzW4Vrc/ZDrRLKO0ftPoM 0HyyUH6Rp+xbZWwP+IW6EyCWm5zeibZviY9NqPzrsaIQjGMyewhtVYMLFcI98BrnfcYl RN/yk32QNnI8kk9NlB9TeE8TJJGAVEjCjhSMJl8RJ+C8i9KO5N0JzfDUcHZV0C2yn51/ V/aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=GlznwSHa9K/cOS1FRxJZ04KXhLV4Kvl8Dx3ESYYXk8U=; b=UF9SsIcRvezscTrkI2XrRPIDgDIcO8jfSa2mgvDpvP690SaixSM/HH7uZxUsevl45A wSjlKcJe4wey2+blljX8SQPu3oPzu9gQicjCXomP1NjQpLQcDlO+9HvZdQfpesUum3+m 7jOAkKrurId4uDsIEvLv8jFYjWBFjMosyigblHpu34uGR3MpscH+xBXMkFQWZJF3+G09 JNadO09SjDpF16QMesv8GrpS7IbPzLe/R3cGczqzAoh6rRJTlWvGvThltJlXZ9a4ow+/ 5WBPim5rRjCyZ54G8B2lIUN3jKsH7zSVlcnOU3myqPAAWHvzw+/fpRG42XRRfZhdR4bc kMvw== X-Gm-Message-State: ACrzQf1xTJH1B13FhOtMEX+J0PK46qDKVXomzX3hH0QM5aNdJNztvzyn xwAUC5b1/4PlHKhqmhJerAvVRGOb70Y= X-Google-Smtp-Source: AMsMyM7mHcsiVDwf6MUSB81GExd3WL5nUF8H3SC/EE/uvSs7nN3pGrQmJwHssVLdy8FGGpiYOE+OXg== X-Received: by 2002:a63:f20e:0:b0:439:398f:80f8 with SMTP id v14-20020a63f20e000000b00439398f80f8mr15048977pgh.494.1664105557683; Sun, 25 Sep 2022 04:32:37 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:37 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 45/54] tests/qtest: libqtest: Replace the call to close a socket with closesocket() Date: Sun, 25 Sep 2022 19:30:23 +0800 Message-Id: <20220925113032.1949844-46-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52c.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng close() is a *nix function. It works on any file descriptor, and sockets in *nix are an example of a file descriptor. closesocket() is a Windows-specific function, which works only specifically with sockets. Sockets on Windows do not use *nix-style file descriptors, and socket() returns a handle to a kernel object instead, so it must be closed with closesocket(). In QEMU there is already a logic to handle such platform difference in os-posix.h and os-win32.h, that: * closesocket maps to close on POSIX * closesocket maps to a wrapper that calls the real closesocket() on Windows Replace the call to close a socket with closesocket() instead. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/libqtest.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 12b1e85b51..1ae58624d9 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -113,7 +113,7 @@ static int socket_accept(int sock) (void *)&timeout, sizeof(timeout))) { fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n", __func__, strerror(errno)); - close(sock); + closesocket(sock); return -1; } @@ -124,7 +124,7 @@ static int socket_accept(int sock) if (ret == -1) { fprintf(stderr, "%s failed: %s\n", __func__, strerror(errno)); } - close(sock); + closesocket(sock); return ret; } @@ -507,8 +507,8 @@ void qtest_quit(QTestState *s) qtest_remove_abrt_handler(s); qtest_kill_qemu(s); - close(s->fd); - close(s->qmp_fd); + closesocket(s->fd); + closesocket(s->qmp_fd); g_string_free(s->rx, true); for (GList *it = s->pending_events; it != NULL; it = it->next) { From patchwork Sun Sep 25 11:30:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987936 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 DB8F9C6FA82 for ; Sun, 25 Sep 2022 12:19:49 +0000 (UTC) Received: from localhost ([::1]:41886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQbs-0008F7-TS for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:19:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsK-0003e5-Bj for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:44 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:44811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsI-0006UY-Qn for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:44 -0400 Received: by mail-pf1-x435.google.com with SMTP id v186so4155010pfv.11 for ; Sun, 25 Sep 2022 04:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=0TjyjmagWil3MltuTF+3LjPFTwhOERwy0g28RMKJdOI=; b=nhZBHOeN1xd8kMcx7wpmo7uQ8IGD2Wf32D8BF4BsAmvMNHojPaaw4d2f8VCKIM6WRs VXNlqFfpfIapimaOQB2DiEoLy/BswhkfxRMSsueDJkBcfxA99zyvMjCVypH+rrgwp5r0 8JPthJ0GAmxuqrkIf7Y6FRwXhXc76Gw8+rA5EMxxJzWMrPx+f6mLlp2dQjoAk0baT54a bMZBm164H0Fpz+CaqDqMhJd4ZmgOW9vSzrXbQFeAX2guacNvZrdYp9o+HroJw1zr7qti 2HQQ8yLImkzivRrVWJiaNJAgF4QCIyxaMrJTqc4BamsVVBlAMoYHSWFixF1nsIlgUckA 5Gfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=0TjyjmagWil3MltuTF+3LjPFTwhOERwy0g28RMKJdOI=; b=2S+TsvFjnCNFE7kPiDfNe9FJSTs2v/ZsKrgB6Ebco75yfi6WqatV5lmEbRQOqYNMv3 iWLuxvNO551mhUHoDhAhQEoe0BzMk0IK0F39MGsalpj+Lf0TC+FY+aJNl34dVr9XU6zL eVXu+ia4747gjPGhcYB8YarE/MUyqMdLCdN3vC1Px7QjWL/rMeezGEC+CmgTWH1YhoYT 7euzUiDMIth0BsXB0OXuR+wo5F2CdLB+OFSggE/08LRiWa5BS/+CIypoEhNTM0UbfZsl Sa/Bl2gZWPspqj/BTbGr59386lBAzNnFEYAvb+YdQFSIZlFrG2nr5fLPATWOWN7nKlTv viKQ== X-Gm-Message-State: ACrzQf3ykEjYWKbuvkI8/EoXI8OaZfqZH3epx4I2EqmI6WN2+WGs0+2a yJrSXYDmSOnqIzT0vhcENJNW8nD60ug= X-Google-Smtp-Source: AMsMyM6+3QjmY4Kf6hTuo0xwKAB1GvxZ3TYSGfpBeRKmE5FiisqW+EIyIWrOP0SRKyOZ+XC8DOV/Xw== X-Received: by 2002:a63:141:0:b0:43a:3851:b2ba with SMTP id 62-20020a630141000000b0043a3851b2bamr16035199pgb.90.1664105560155; Sun, 25 Sep 2022 04:32:40 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:39 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 46/54] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32 Date: Sun, 25 Sep 2022 19:30:24 +0800 Message-Id: <20220925113032.1949844-47-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x435.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Some qtest cases don't get response from the QEMU executable under test in time on Windows. It turns out that the socket receive call got timeout before it receive the complete response. The timeout value is supposed to be set to 50 seconds via the setsockopt() call, but there is a difference among platforms. The timeout unit of blocking receive calls is measured in seconds on non-Windows platforms but milliseconds on Windows. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) tests/qtest/libqtest.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 1ae58624d9..e3360338de 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -36,13 +36,14 @@ #include "qapi/qmp/qstring.h" #define MAX_IRQ 256 -#define SOCKET_TIMEOUT 50 #ifndef _WIN32 +# define SOCKET_TIMEOUT 50 # define CMD_EXEC "exec " # define DEV_STDERR "/dev/fd/2" # define DEV_NULL "/dev/null" #else +# define SOCKET_TIMEOUT 50000 # define CMD_EXEC "" # define DEV_STDERR "2" # define DEV_NULL "nul" @@ -106,8 +107,16 @@ static int socket_accept(int sock) struct sockaddr_un addr; socklen_t addrlen; int ret; + /* + * timeout unit of blocking receive calls is different among platfoms. + * It's in seconds on non-Windows platforms but milliseconds on Windows. + */ +#ifndef _WIN32 struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT, .tv_usec = 0 }; +#else + DWORD timeout = SOCKET_TIMEOUT; +#endif if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, sizeof(timeout))) { From patchwork Sun Sep 25 11:30:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987939 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 EDE64C6FA82 for ; Sun, 25 Sep 2022 12:24:24 +0000 (UTC) Received: from localhost ([::1]:57478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQgJ-0005bi-RZ for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:24:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56628) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsL-0003ge-Bv for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:45 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]:42593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsJ-0006Ui-Px for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:45 -0400 Received: by mail-pg1-x52c.google.com with SMTP id t190so4209835pgd.9 for ; Sun, 25 Sep 2022 04:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wJ46lPbUundlzLry/XhmGks2ORwcj9XXEHBkBSD1tlY=; b=b+5s+002U58pVE0pOMSxgvC9taWDLxYNrFddYJprsoSrXGDEQbm2kylGP2KxgfmAJk YNLYNxFMBkasehtM68neierp2/4mSfo3J4jyKSCD7/py3jTG8/mqTg+SIeZjF5+ZNlkF qpVy50qMWD9BRuzScpFKgSCxWlnvGqeK5/iy1NaQ9cAO9+yfpNnrizoRA0yJPxNNIH2g 8qyHTCSf6vMkz9ite7C8P8VbAAmzKm4nCcOdZ/zEHcykO5Y9UeftFAiEAqg6OsL+/53f R7gdcpz7ULlX0UllKHj/sJ4SappMD5V/jbOWkZ5GcGvApERWYqWqlQ8bud+Rfk+vJ5IC DG9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=wJ46lPbUundlzLry/XhmGks2ORwcj9XXEHBkBSD1tlY=; b=0rAiHsm3rtfXyFQUQAgu4VMn9MdHruRpB5vZpG33NRcbHIuCw7xnscj9R0rusvaAbG crFw67haYKmaAF1bHOjwoDjrEAhOwkEZ83FqNuZ9XQt3ksDRk8wsn3m3VvBKcDsDVIf9 ktv8+gzDAt1EJ49g2UvjR+1uoOJCMAU3/O8KY4ENof+2trMb+HRL4d5jDvVP9gsi8X3J Gbo23Bh9SFPe+mX4NxRYXrPcysCcWDStAs5p48NINY8lMooQSsVO3DwyqOrYq7syIXR9 9ECcdExxy7AybHGjigMQgU3NkTWrGRSfeexyq/tS/++JepYRrc2bYQKLwrIK/bjRXPex BOZQ== X-Gm-Message-State: ACrzQf3cQawab3MkBTvb/mwzrfWfpiR9bnMWCJHhVSFYagM0CEaBte9F i22Vr4QqC3RCiQZM48xgmFZk91Jir8I= X-Google-Smtp-Source: AMsMyM6aEakLRqZMjYGekwKl0kxNwbRlAw9gmeHOSRqlXpCldfBIapn0HKbNW2CviAV8CjXYEYzsZQ== X-Received: by 2002:a63:87c8:0:b0:43a:c2e4:efcc with SMTP id i191-20020a6387c8000000b0043ac2e4efccmr15738344pge.410.1664105562289; Sun, 25 Sep 2022 04:32:42 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:42 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v3 47/54] io/channel-watch: Drop a superfluous '#ifdef WIN32' Date: Sun, 25 Sep 2022 19:30:25 +0800 Message-Id: <20220925113032.1949844-48-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52c.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng In the win32 version qio_channel_create_socket_watch() body there is no need to do a '#ifdef WIN32'. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) io/channel-watch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/io/channel-watch.c b/io/channel-watch.c index 0289b3647c..89f3c8a88a 100644 --- a/io/channel-watch.c +++ b/io/channel-watch.c @@ -285,11 +285,9 @@ GSource *qio_channel_create_socket_watch(QIOChannel *ioc, GSource *source; QIOChannelSocketSource *ssource; -#ifdef WIN32 WSAEventSelect(socket, ioc->event, FD_READ | FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_WRITE | FD_OOB); -#endif source = g_source_new(&qio_channel_socket_source_funcs, sizeof(QIOChannelSocketSource)); From patchwork Sun Sep 25 11:30:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987941 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 B0F2DC04A95 for ; Sun, 25 Sep 2022 12:28:20 +0000 (UTC) Received: from localhost ([::1]:42530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQk7-0002uf-OV for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:28:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsM-0003j8-Oj for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:47 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:46712) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsL-0006RL-7P for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:46 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 78so4188868pgb.13 for ; Sun, 25 Sep 2022 04:32:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=FMvqR5WvHSrhd6FoBOh5bPNiyVgL3g0xwaaD6f1HGpU=; b=nom1DnXizdus8O9cJKckrVxSlw9ApoiQhEtk8If+caySJBrWo7oSX9ZLfvMoqada1N 7Wf70BMmYNyI31yaxViEPYM4x6N7ugOSYezmvisavf+gDXIncNod1LUoEvqNsBJdNYms Ta6FXDHwGLb1J/9PdgerrMGL3ecvT5J4olcmX5wi2bqAH43qxGSXLQ0WdP1266vG0wCK do/Q5Zrh5jCwh+DwlOcaFd/WNytQz97weQ1cfNTUhuG+6Xuh3V/slJps7ZTLLdFWSW53 D6HhkdrlvAuVTjBOmpaxZhmPoFKcOol1rBLAlLpAEL7IrREsu2l4sJTlKmJP29Z81YAF Xf5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=FMvqR5WvHSrhd6FoBOh5bPNiyVgL3g0xwaaD6f1HGpU=; b=uxyu2rSBfwaLE2We+aMrGXvd+eUaLhOoWdFQeJREN0X70BBwDQv/IDX2Ebb/pHcjW/ 8GWC0eJlF2co8acpqsuiqqWB39yzRJUeJqV5ZowqSC+xbc2eMj2Bf1XtiYhCWJ1vNUyI Xs1At0VwJxcUgku/+4n1SS0/xQwsLA1kOGkESIdHVD86uTcuoqKm3KZkWrnzbDJyn4v6 bazQ/RLJSj9yCacfIs/bk5RRlbCRow/KwdrcrUxYstBb3wc/f+rLK77pSM59q2oivKeZ Pn01XmW6nX0H2YEjNh1rXW97Ystyu8uWSfj8qrdihgV7Dd7hdjVxMFwqFE5bWdBTVd0h /puA== X-Gm-Message-State: ACrzQf0yOsvUS7zGAu1LHBGMZIVx43lhiN5UodwZCzyaEJcg5kmHYnNu H+SjZ7xf1HCeGaEo9UhImislxH4PT8o= X-Google-Smtp-Source: AMsMyM6XFLYk0cNUvqmE5Q624IctAcRdcgKcoLmHPkBvgWVyeiWZQ51bvWg2WXjPuDSZ5MYS3EsPyw== X-Received: by 2002:a05:6a00:1346:b0:546:ff1e:26ae with SMTP id k6-20020a056a00134600b00546ff1e26aemr18435705pfu.45.1664105564230; Sun, 25 Sep 2022 04:32:44 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:43 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v3 48/54] io/channel-watch: Drop the unnecessary cast Date: Sun, 25 Sep 2022 19:30:26 +0800 Message-Id: <20220925113032.1949844-49-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52a.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng There is no need to do a type cast on ssource->socket as it is already declared as a SOCKET. Suggested-by: Marc-André Lureau Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - new patch: "io/channel-watch: Drop the unnecessary cast" io/channel-watch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/channel-watch.c b/io/channel-watch.c index 89f3c8a88a..43d38494f7 100644 --- a/io/channel-watch.c +++ b/io/channel-watch.c @@ -130,13 +130,13 @@ qio_channel_socket_source_check(GSource *source) FD_ZERO(&wfds); FD_ZERO(&xfds); if (ssource->condition & G_IO_IN) { - FD_SET((SOCKET)ssource->socket, &rfds); + FD_SET(ssource->socket, &rfds); } if (ssource->condition & G_IO_OUT) { - FD_SET((SOCKET)ssource->socket, &wfds); + FD_SET(ssource->socket, &wfds); } if (ssource->condition & G_IO_PRI) { - FD_SET((SOCKET)ssource->socket, &xfds); + FD_SET(ssource->socket, &xfds); } ssource->revents = 0; if (select(0, &rfds, &wfds, &xfds, &tv0) == 0) { From patchwork Sun Sep 25 11:30:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987933 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 8F77EC04A95 for ; Sun, 25 Sep 2022 12:14:50 +0000 (UTC) Received: from localhost ([::1]:58552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQX2-0002eH-7C for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:14:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsP-0003mD-2U for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:52 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:44811) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsN-0006UY-7d for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:48 -0400 Received: by mail-pf1-x435.google.com with SMTP id v186so4155117pfv.11 for ; Sun, 25 Sep 2022 04:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=xIwwdkQ/UueIjTq9LmfxXmdWH0OF4K6cF8/Wmny7JFg=; b=paDsIp/geoV+flWTxrLf9AtfM0yW1S7bTrjVeZ9uuD35w4JdjQVk+IhqZRSbItKpwF gK1hoWerc1xk+oK43Z8CjY/8J8r+8fuzzqlkwlRG5A6FpJ3HHNqNua9Lk+h5IP31z+Pt pSstGCrHoVaZ0O6d2cXHEBT0HO2pIFPOHTP9e5K0px1LC/ZRNKqigeu0jTdxFVzyu4pA 3Bx0YSdkupmsq1vW8qksQw807G+nZO6NdybAXkrRzNLJNs1ZrNG6PbDB09eTZBt9nev3 /iqicJU2GiHmx+v+8ECslc/D95fMJUDg+MPNEd3s3ebO1uTjGAHKO5O1dHw6LxDwdpc8 OpNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=xIwwdkQ/UueIjTq9LmfxXmdWH0OF4K6cF8/Wmny7JFg=; b=nYL6Vgyg+9TalxidVmhOyx35DlCyCwlJ3kkW1afpVrY2D+KSgCmVWVbPeA1g2IYQbh 1TwcCNZ9elv5MbIC4YpU+RobcJqLDzL3t8V4Dq8tcTRJKwgbpiwCkv+GF+Ww9i0mxbMr XsbbqAbE9dvP29AP7xJAQxcL/ION5gxv0BUu757VlDaXtusjV6aLp6Vf932Obga3SWsh x92MWAFIsWHfNc+IOJoa+wwzIA0d6vujvOKN4X92+f2o0pFW64iHhuStiuXlFtOocn2V cMM+O4u8aQo93P3nmE7LGzHfDGpwXw9jo/tIyQCCV19K8c2YQGiVpNDzZy+eNoHacgTB 63AQ== X-Gm-Message-State: ACrzQf0M/bRT0xVZ7FHEbrJTWd0vZziF+sO3Dat74XABXqrFPfoZLzYR Dhz0llKY+2QlcazZEwYeNUTOkd9O6Wg= X-Google-Smtp-Source: AMsMyM51g7z7OQwizHuEZxcY19BSb3V1khL7ofAY5/lr5T+5NRb9dBRuoHgEhSVyQoZk7BpCId6QJw== X-Received: by 2002:a62:2985:0:b0:544:77d4:f43b with SMTP id p127-20020a622985000000b0054477d4f43bmr18353833pfp.9.1664105566317; Sun, 25 Sep 2022 04:32:46 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:45 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v3 49/54] io/channel-watch: Fix socket watch on Windows Date: Sun, 25 Sep 2022 19:30:27 +0800 Message-Id: <20220925113032.1949844-50-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x435.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Random failure was observed when running qtests on Windows due to "Broken pipe" detected by qmp_fd_receive(). What happened is that the qtest executable sends testing data over a socket to the QEMU under test but no response is received. The errno of the recv() call from the qtest executable indicates ETIMEOUT, due to the qmp chardev's tcp_chr_read() is never called to receive testing data hence no response is sent to the other side. tcp_chr_read() is registered as the callback of the socket watch GSource. The reason of the callback not being called by glib, is that the source check fails to indicate the source is ready. There are two socket watch sources created to monitor the same socket event object from the char-socket backend in update_ioc_handlers(). During the source check phase, qio_channel_socket_source_check() calls WSAEnumNetworkEvents() to discover occurrences of network events for the indicated socket, clear internal network event records, and reset the event object. Testing shows that if we don't reset the event object by not passing the event handle to WSAEnumNetworkEvents() the symptom goes away and qtest runs very stably. It seems we don't need to call WSAEnumNetworkEvents() at all, as we don't parse the result of WSANETWORKEVENTS returned from this API. We use select() to poll the socket status. Fix this instability by dropping the WSAEnumNetworkEvents() call. Some side notes: During the testing, I removed the following codes in update_ioc_handlers(): remove_hup_source(s); s->hup_source = qio_channel_create_watch(s->ioc, G_IO_HUP); g_source_set_callback(s->hup_source, (GSourceFunc)tcp_chr_hup, chr, NULL); g_source_attach(s->hup_source, chr->gcontext); and such change also makes the symptom go away. And if I moved the above codes to the beginning, before the call to io_add_watch_poll(), the symptom also goes away. It seems two sources watching on the same socket event object is the key that leads to the instability. The order of adding a source watch seems to also play a role but I can't explain why. Hopefully a Windows and glib expert could explain this behavior. Signed-off-by: Bin Meng --- (no changes since v1) io/channel-watch.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/io/channel-watch.c b/io/channel-watch.c index 43d38494f7..ad7c568a84 100644 --- a/io/channel-watch.c +++ b/io/channel-watch.c @@ -115,17 +115,13 @@ static gboolean qio_channel_socket_source_check(GSource *source) { static struct timeval tv0; - QIOChannelSocketSource *ssource = (QIOChannelSocketSource *)source; - WSANETWORKEVENTS ev; fd_set rfds, wfds, xfds; if (!ssource->condition) { return 0; } - WSAEnumNetworkEvents(ssource->socket, ssource->ioc->event, &ev); - FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); From patchwork Sun Sep 25 11:30:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987942 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 D2C65C6FA82 for ; Sun, 25 Sep 2022 12:28:20 +0000 (UTC) Received: from localhost ([::1]:42532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQk7-0002uu-GK for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:28:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsS-0003nO-IQ for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:52 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:45853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsQ-0006VJ-N0 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:52 -0400 Received: by mail-pj1-x1033.google.com with SMTP id p1-20020a17090a2d8100b0020040a3f75eso4293658pjd.4 for ; Sun, 25 Sep 2022 04:32:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/b7s3t9sw9bpXRC73xt9PPRDwHP5U56OXk3X7W+M0Uo=; b=ZPgQvJHEqHa5Se/V+/7vCTaWLrmZVr47f2j5TqHxQVV7i/aTnk3L5nNeDFmYR9pQvr CLZfLvlzoia1KU55mPT22VECR9om89eseWr3DExzWhLMG1Sx7eOS9g45jukYxZjpxvjf RgYzYvBOjS6K/vneae3Sy2lX2IIq/gwtlZPCaE3cSUU+o2m5AnneGEllJPt4dIj+Hz5T Y+kcZZS32SKZ9Jjs3/aMyxUDqK7jgNq5g/6C2J+72udpL2UaPHAZikyDmxN63ON/GWRv ACiAxOOnqBV5Y6d/vjZzJQb1daBk9Dq35LDmTSnVNOGRYIhx6Wzz8k/14dqwgo5LBFRW 4pIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=/b7s3t9sw9bpXRC73xt9PPRDwHP5U56OXk3X7W+M0Uo=; b=0tLqpN+9x9tw/3MfUnkr84OoDnB+51D4zmdZZJXq5IxMltm3bTta9dnWwa7kH+nC61 xFuVrbOCV0hGnu8iE04gs8HwQWSJNF1wcpPBndB2AAaJk5vvT9Uh2mHXeN7sZRN45b4T sxIN2xaA4odyv2kg+V/2vgFlTHrwnx2jbimWzgArlYWTzy3NGo7Cl5q3tXLdEJpK+eCU 0OOFzwWl67kjGCZQSdhNNJ1vNP3OM/DK1iNPiWDLTkHplNGLp08EE/WnF8w1lvCynmn5 T9E8P986UQkrkxG9YXt3q6HZpMyGj5Zdsrs3ykw4efeyNOKaHbOezNz4Z4pILgaQKKfu 1oUg== X-Gm-Message-State: ACrzQf2QbxPzHnOdblJyLAJcfoIfTdGlCRDKtnzt5P9MNPzIX6Mq8Sgp l+CjHFVJQfwoSixBqiGbtT69b2zt38Q= X-Google-Smtp-Source: AMsMyM7dwo7QsdyDvJnvuEkRWbUFGV5ZUh3PLQeBgLIGyy+uT3a4B3iBJkgD8vaQSSenJXNbhm227A== X-Received: by 2002:a17:902:c401:b0:178:41d1:ef50 with SMTP id k1-20020a170902c40100b0017841d1ef50mr17030889plk.66.1664105569144; Sun, 25 Sep 2022 04:32:49 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 50/54] tests/qtest: migration-test: Skip running some TLS cases for win32 Date: Sun, 25 Sep 2022 19:30:28 +0800 Message-Id: <20220925113032.1949844-51-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1033.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Some migration test cases use TLS to communicate, but they fail on Windows with the following error messages: qemu-system-x86_64: TLS handshake failed: Insufficient credentials for that request. qemu-system-x86_64: TLS handshake failed: Error in the pull function. query-migrate shows failed migration: TLS handshake failed: Error in the pull function. Disable them temporarily. Signed-off-by: Bin Meng --- I am not familar with the gnutls and simply enabling the gnutls debug output does not give me an immedidate hint on why it's failing on Windows. Disable these cases for now until someone or maintainers who may want to test this on Windows. (no changes since v1) tests/qtest/migration-test.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 9ec501d1eb..e22637a4e3 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1402,6 +1402,7 @@ static void test_precopy_unix_dirty_ring(void) } #ifdef CONFIG_GNUTLS +#ifndef _WIN32 static void test_precopy_unix_tls_psk(void) { g_autofree char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); @@ -1414,6 +1415,7 @@ static void test_precopy_unix_tls_psk(void) test_precopy_common(&args); } +#endif /* _WIN32 */ #ifdef CONFIG_TASN1 static void test_precopy_unix_tls_x509_default_host(void) @@ -1522,6 +1524,7 @@ static void test_precopy_tcp_plain(void) } #ifdef CONFIG_GNUTLS +#ifndef _WIN32 static void test_precopy_tcp_tls_psk_match(void) { MigrateCommon args = { @@ -1532,6 +1535,7 @@ static void test_precopy_tcp_tls_psk_match(void) test_precopy_common(&args); } +#endif /* _WIN32 */ static void test_precopy_tcp_tls_psk_mismatch(void) { @@ -1929,6 +1933,7 @@ static void test_multifd_tcp_zstd(void) #endif #ifdef CONFIG_GNUTLS +#ifndef _WIN32 static void * test_migrate_multifd_tcp_tls_psk_start_match(QTestState *from, QTestState *to) @@ -1936,6 +1941,7 @@ test_migrate_multifd_tcp_tls_psk_start_match(QTestState *from, test_migrate_precopy_tcp_multifd_start_common(from, to, "none"); return test_migrate_tls_psk_start_match(from, to); } +#endif /* _WIN32 */ static void * test_migrate_multifd_tcp_tls_psk_start_mismatch(QTestState *from, @@ -1987,6 +1993,7 @@ test_migrate_multifd_tls_x509_start_reject_anon_client(QTestState *from, } #endif /* CONFIG_TASN1 */ +#ifndef _WIN32 static void test_multifd_tcp_tls_psk_match(void) { MigrateCommon args = { @@ -1996,6 +2003,7 @@ static void test_multifd_tcp_tls_psk_match(void) }; test_precopy_common(&args); } +#endif /* _WIN32 */ static void test_multifd_tcp_tls_psk_mismatch(void) { @@ -2496,8 +2504,10 @@ int main(int argc, char **argv) qtest_add_func("/migration/precopy/unix/plain", test_precopy_unix_plain); qtest_add_func("/migration/precopy/unix/xbzrle", test_precopy_unix_xbzrle); #ifdef CONFIG_GNUTLS +#ifndef _WIN32 qtest_add_func("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); +#endif if (has_uffd) { /* @@ -2523,8 +2533,10 @@ int main(int argc, char **argv) qtest_add_func("/migration/precopy/tcp/plain", test_precopy_tcp_plain); #ifdef CONFIG_GNUTLS +#ifndef _WIN32 qtest_add_func("/migration/precopy/tcp/tls/psk/match", test_precopy_tcp_tls_psk_match); +#endif qtest_add_func("/migration/precopy/tcp/tls/psk/mismatch", test_precopy_tcp_tls_psk_mismatch); #ifdef CONFIG_TASN1 @@ -2568,8 +2580,10 @@ int main(int argc, char **argv) test_multifd_tcp_zstd); #endif #ifdef CONFIG_GNUTLS +#ifndef _WIN32 qtest_add_func("/migration/multifd/tcp/tls/psk/match", test_multifd_tcp_tls_psk_match); +#endif qtest_add_func("/migration/multifd/tcp/tls/psk/mismatch", test_multifd_tcp_tls_psk_mismatch); #ifdef CONFIG_TASN1 From patchwork Sun Sep 25 11:30:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987945 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 D5033C6FA82 for ; Sun, 25 Sep 2022 12:34:24 +0000 (UTC) Received: from localhost ([::1]:55068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQpz-0000LF-Vp for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:34:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsV-0003pq-H1 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:33:05 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:33587) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsT-0006VW-BP for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:54 -0400 Received: by mail-pl1-x635.google.com with SMTP id iw17so3974364plb.0 for ; Sun, 25 Sep 2022 04:32:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=WijaFh1+3eGNmoiPADdFaEnlm/n1XUXqlNMKiv/+vQo=; b=Ip0L8/OFM69Vaxz/SdSSAF3O4mqnqYTXLZ+plCQMRST7JBNtMGcD4wpVtn9d1Iot8r F4SYOwKOQ8v6FqRjh/h+8uzXCg+PRxy6GwlrIVIte6SDfrPYvjD/japAfmehh6t8H9IO xfqDJ+sll0+mpAfCDJ5GYKxM77N7YaBJOcjdxiBDyS6bnFboPEEawKZJoVp5fsB+fTOW axFyOhaYLxkOlMwwbfipBgvD293uA9+F62hlI2yyKM7eawKETIkBMR8vnh1MDlgnteod bBqXWvWFMrBtQJlnLmxwkigbtW0IRoAwlL6xTo3DMIDW1qUtDdEyDPhQgOcFMe3L+/yY tpDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=WijaFh1+3eGNmoiPADdFaEnlm/n1XUXqlNMKiv/+vQo=; b=jaRv+5I+vrswIv9SYYF+BoknCg+iCQSDyTpOLKWUV3wHNNqPHVE5FXPLkwsFkIJlDV QOaMg2dLOBdQUSZSb3vK1O63OaC5/HJq95rqKKGPwnot9cS59/SOnxIVlWWZwZrkRnpC M67LyMy8SwL6MHw1siYBCgBOR7zm1EeZA8/Xzxdf4LNCeH0r9QvTDLN2AFAf0T1buaOO 6Qwnoao0kA1ojH5qF7f04tjjBnX+S+xQOPBwpOZkESZ8nGhUdYd4C49SpKOxEG7HITc5 aAiBy1DswOuIw04YxXofYyozLHEb7kbTXkWHkZGadEAa5oESfb5k5m31ingLSNGK8bZ6 mqrw== X-Gm-Message-State: ACrzQf2E0S5NtDtvCAa5FHxbhKYCsW6mVhUXnP8jtNcH3Tw+86J48r9G qZD60Y7lpaIqyGiaR5anIOYzjDt6cSo= X-Google-Smtp-Source: AMsMyM4SXgadq0LC79zGE/h1Eow7+GYslY5YeCln3VZ2PSdh6luLSaBEV+YPDrshPmpG6N4rGpKvDA== X-Received: by 2002:a17:90b:4b05:b0:202:b76e:a274 with SMTP id lx5-20020a17090b4b0500b00202b76ea274mr30914320pjb.59.1664105571857; Sun, 25 Sep 2022 04:32:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:51 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta Subject: [PATCH v3 51/54] .gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes Date: Sun, 25 Sep 2022 19:30:29 +0800 Message-Id: <20220925113032.1949844-52-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x635.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng commit 9f8e6cad65a6 ("gitlab-ci: Speed up the msys2-64bit job by using --without-default-devices" changed to compile QEMU with the --without-default-devices switch for the msys2-64bit job, due to the build could not complete within the project timeout (1h), and also mentioned that a bigger timeout was getting ignored on the shared Gitlab-CI Windows runners. However as of today it seems the shared Gitlab-CI Windows runners does honor the job timeout, and the runner has the timeout limit of 2h, so let's increase the timeout to 90 minutes and drop the configure switch "--without-default-devices" to get a larger build coverage. Signed-off-by: Bin Meng --- (no changes since v2) Changes in v2: - Change the timeout limit to 90 minutes .gitlab-ci.d/windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.d/windows.yml b/.gitlab-ci.d/windows.yml index 86a4339c48..9ef4667317 100644 --- a/.gitlab-ci.d/windows.yml +++ b/.gitlab-ci.d/windows.yml @@ -10,7 +10,7 @@ - ${CI_PROJECT_DIR}/msys64/var/cache needs: [] stage: build - timeout: 70m + timeout: 90m before_script: - If ( !(Test-Path -Path msys64\var\cache ) ) { mkdir msys64\var\cache @@ -59,7 +59,7 @@ msys2-64bit: - $env:MSYSTEM = 'MINGW64' # Start a 64 bit Mingw environment - $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu - --enable-capstone --without-default-devices' + --enable-capstone' - .\msys64\usr\bin\bash -lc 'make' - .\msys64\usr\bin\bash -lc 'make check' From patchwork Sun Sep 25 11:30:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987950 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 BBD14C04A95 for ; Sun, 25 Sep 2022 12:39:00 +0000 (UTC) Received: from localhost ([::1]:39808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQuR-0006a2-RH for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:38:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsX-0003pt-O2 for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:33:05 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:41571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsW-0006Vn-8Q for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:32:57 -0400 Received: by mail-pj1-x1030.google.com with SMTP id q15-20020a17090a304f00b002002ac83485so4371303pjl.0 for ; Sun, 25 Sep 2022 04:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=zI8S+RBT1OKVz18s8MzM0BknkzeLLfGnw9ZmAFPh81s=; b=XinJF7eikkeRLkkgoN1DbgEItZCiLlysGWElcYqEZ+nDWvssF5YNSBr7cZgJuBLvsz n5gb4BgPrMLK9hI5FccuGHC30isNv9jphDbHdOTmQ6YoTR0Vj9bwkeotGbCb2UCEFFnf Umd5avZc2fzFw0WArqL1Azev0VsVy22fG7tArqL57p/2e0DPIi+ZCqjYUOClA2XiJKXA QbwFPH0JMRKxoTfPyaii6/NilcSUWOaNnp4/gFfebTM4RBRQeNvtsO4+pRpIi/irgXVv DEfiGevhKLfS6lsSkqVevf+Fcx0nszr6EkPpJyjejSzTFr3crrEdwAFiy6WsVJcjuWKi Pezw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=zI8S+RBT1OKVz18s8MzM0BknkzeLLfGnw9ZmAFPh81s=; b=kO6eiRUXpZQu2EBJDw8pTnc+O9WAVWWnzaeQYfud7HH9C0shLdfAuVQB5TwOb4eTq8 DgmwQFkYnB/do6BhxeszMxyVGhx+quw05qTeS6F+sRcmKWdBVpa0CWcQMyxHyJ9G4rSQ dlnyXjhxoLrtmbJpcitNcmJbflajrW9LMT+gi9QIM4n2bbbikQKRQsWMJj3O7s4S5nug PGNbjuA6izhvp7RkSN7H3nw3JErKWHuXzbJhsC3011+XlqcvXhE1jnAloXHXlH3FceEC CE6cpG9ZmPfBcI3CyaNTG6e3VtpEVX25L+6GfZ45tJzzTEuJTD+reyEeLxNGlRJsOeyQ SN0g== X-Gm-Message-State: ACrzQf1iRIn1kF4lgtXhX8vP2tt2PiygfaUB/WVdwLDAjsnZy0NFOWCG lC7C6YjsnZiJY3soJ+kSzde6HrOXnxE= X-Google-Smtp-Source: AMsMyM4ifsv+4XUtmrnBkP6Z/G1PFcRRA26xEkXPE5UUdcKpRE4mPUCBCkOAekvew5//BccjV1CoKw== X-Received: by 2002:a17:902:b710:b0:178:3128:b593 with SMTP id d16-20020a170902b71000b001783128b593mr17029118pls.50.1664105574646; Sun, 25 Sep 2022 04:32:54 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:54 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta Subject: [PATCH v3 52/54] .gitlab-ci.d/windows.yml: Display meson test logs Date: Sun, 25 Sep 2022 19:30:30 +0800 Message-Id: <20220925113032.1949844-53-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1030.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng When CI fails we don't know what causes the failure. Displaying the meson test logs can be helpful. Signed-off-by: Bin Meng Reviewed-by: Thomas Huth --- (no changes since v2) Changes in v2: - new patch: Display meson test logs in the Windows CI .gitlab-ci.d/windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.d/windows.yml b/.gitlab-ci.d/windows.yml index 9ef4667317..29a3ba04a4 100644 --- a/.gitlab-ci.d/windows.yml +++ b/.gitlab-ci.d/windows.yml @@ -61,7 +61,7 @@ msys2-64bit: - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu --enable-capstone' - .\msys64\usr\bin\bash -lc 'make' - - .\msys64\usr\bin\bash -lc 'make check' + - .\msys64\usr\bin\bash -lc 'make check || { cat build/meson-logs/testlog.txt; exit 1; } ;' msys2-32bit: extends: .shared_msys2_builder @@ -94,4 +94,4 @@ msys2-32bit: - cd output - ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu" - ..\msys64\usr\bin\bash -lc 'make' - - ..\msys64\usr\bin\bash -lc 'make check' + - ..\msys64\usr\bin\bash -lc 'make check || { cat meson-logs/testlog.txt; exit 1; } ;' From patchwork Sun Sep 25 11:30:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987946 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 41D42C04A95 for ; Sun, 25 Sep 2022 12:34:26 +0000 (UTC) Received: from localhost ([::1]:55070 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQq1-0000Nl-9i for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:34:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33350) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsb-0003qI-Jd for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:33:10 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:37626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsZ-0006W2-Te for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:33:01 -0400 Received: by mail-pj1-x102c.google.com with SMTP id o99-20020a17090a0a6c00b002039c4fce53so9955476pjo.2 for ; Sun, 25 Sep 2022 04:32:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=IzZQnIYLsxtqAyksVgAZZh7li/fTF9V/3ilSBmBdf+4=; b=Sl3dbP8od4b7azHLzM8n0CrsSS7JJtj0tBPS8LBByTp/kfyTsfrRHEAsrRZIy1Q2aK HiNn8KQbaeAmHRD4CMj2zr6pJvc7Jb/X4Ol5V2BVwDbQ9PTQ8l6gBXiyRfQO5CoH8j1T kSUFCsU8rDVSEsKr2NbpXlPlxmwF4ZGE4AYXGhECXz2VxL6wOEr+aS6untUE7YnoGF/V IzXkLths9Ckr5kAE4zKTmhmbqVijr5mpcAn7qe/zTReBpCitV5yk1o/Y9b6FVOSMUEnd gqnyZT+YtOYu+aNgATWNOdwL2H4TBiWUTJtNRxvHIXMWmFvhBpgzqqkyDWKsavDDkM/1 /MjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=IzZQnIYLsxtqAyksVgAZZh7li/fTF9V/3ilSBmBdf+4=; b=uB8P6UUNznoBqMWwduxI8bLXL1EnekIwwHVElXpHUr8UV18Hcx+czGpEG1VFhNv6lM NAeAkBBY8Zmpm2qVJ7uaptbqK/HumY+sHtyeY677ur2yWx1Rv47Ed3HMqlDAM2+NhVc1 sCyqfpeoPuqIbDc45P8xj7mmRsF5ixi0EJFUewBlIbb4V+a20XlaW4fVw/MtexqUHNGI zrICaLknFOc8Rs8ORASm5wT38GHBcitt2TQ/dlSg2B5IpTpp7ygekEhxlfswc4AhuMSQ abOHGQ9K/e3bY9i3HIOIKHHs9b6oyDXj3VNsurWrD+vHtui2s2rVtUKIfTH3CudPmrae ovmw== X-Gm-Message-State: ACrzQf3so2hHBwkJw/P1QN23G0WTrbcFg8yfA0FiuV7HuasL49r3KMu4 w8f93rPudJIUrlOhlazihs183hkcPKY= X-Google-Smtp-Source: AMsMyM50s6JR0pEIRdPb5gOG+1OceQ4JlXTyy+2o7EwhiBVHESskytgtaHIsOba7O+Y9xKOKFhR93Q== X-Received: by 2002:a17:902:ac98:b0:176:9e76:a930 with SMTP id h24-20020a170902ac9800b001769e76a930mr16809207plr.15.1664105576978; Sun, 25 Sep 2022 04:32:56 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:56 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v3 53/54] tests/qtest: Enable qtest build on Windows Date: Sun, 25 Sep 2022 19:30:31 +0800 Message-Id: <20220925113032.1949844-54-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102c.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows. Signed-off-by: Bin Meng --- Changes in v3: - Drop the host test Changes in v2: - new patch: "tests/qtest: Enable qtest build on Windows" tests/qtest/meson.build | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 455f1bbb7e..8701c3a8e7 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -1,9 +1,3 @@ -# All QTests for now are POSIX-only, but the dependencies are -# really in libqtest, not in the testcases themselves. -if not config_host.has_key('CONFIG_POSIX') - subdir_done() -endif - slow_qtests = { 'ahci-test' : 60, 'bios-tables-test' : 120, From patchwork Sun Sep 25 11:30:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12987954 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 57A1FC04A95 for ; Sun, 25 Sep 2022 12:42:40 +0000 (UTC) Received: from localhost ([::1]:43834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ocQxz-0004SR-ET for qemu-devel@archiver.kernel.org; Sun, 25 Sep 2022 08:42:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ocPsd-0003qN-Ac for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:33:10 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:34459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ocPsb-0006WC-AA for qemu-devel@nongnu.org; Sun, 25 Sep 2022 07:33:02 -0400 Received: by mail-pg1-x532.google.com with SMTP id 3so4240324pga.1 for ; Sun, 25 Sep 2022 04:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=wBKfIvS9x64YlkQ8k7SGVBoOTJo9nKg2KRFTaNM53ZE=; b=VYcmbmT294xMJ0Ic1NZN6/TvkWt8L6fxHIZGNpKX6j2EvWKvIuRnW2+ruqPA+LPlXz 26d6k/u6Zg/uFSMafm0gsF8mAoh2/+m+Py8MIh++I5tcip8cjGS6jGgHBu//ISag2B5t ySBCBZUASda1xMPIcOlmbzLzVWzpQ1QIWhqwWbs6FeAZWfNoCuXO1IvCXUsOpVbUXLhn PJQ+TAejyFzH2tTfVhVA2pLRMcpQA3HVjA3KzV1NftEcJezTVtD/JsZrRTocLdQXCeNv X5HRSqLhOk7WqKiNXdSfYxUZsy1ABteY7jZPm/x/+YNoZETYsx9IoZRxBvp5QK08hEJt 3vfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=wBKfIvS9x64YlkQ8k7SGVBoOTJo9nKg2KRFTaNM53ZE=; b=OXmHHLcwC3/6uS+x1kSxFq+WHXOxcMACFaOsSUpmi5v2AT1x8qHEbm8WUHsPmyAXmi uyPHJbWMB8CD823fJvUCczELRrMtbPJIWnSb118VjF7RS0yjsUu1v52w+FeJwtK4awDC KANueGbJc7CUFT1zHKpOlVyIV0EChVU2DHoUtjEe+RHJC6miQc57vEruXfWoVeMbN2NI PBGB58W5wYWmGEqaLlhdmzKg4OScTuDBveUUjCUyaLdBq/VVVrd9h+PfRQ6KlWsmx0Ei NKp95yPKL/YobGlHsnXUea5yHw4HsAJsQ9A+fFvO0ROHPfvFSFVPQ8VhS+qbiIN+coe/ jcJg== X-Gm-Message-State: ACrzQf2Zqqe5jGkm2wMx8gJXNcYUxd+nLHIHWm8tvrHo59TgT4tCxlXu Tzi8U1gSiA0GOSODyKbiWcmZsFBFFEc= X-Google-Smtp-Source: AMsMyM5KQkgRfkHabl8V/DD1txSdIRoSS4nsqHt0uwCNggqc40BbQc4mH8ZW3imV5g0w0pk1ftcVrA== X-Received: by 2002:a05:6a00:3392:b0:547:f861:1fc9 with SMTP id cm18-20020a056a00339200b00547f8611fc9mr18155798pfb.17.1664105579878; Sun, 25 Sep 2022 04:32:59 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id z4-20020a1709027e8400b00176c6738d13sm9187760pla.169.2022.09.25.04.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 04:32:59 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Willian Rampazzo Subject: [PATCH v3 54/54] docs/devel: testing: Document writing portable test cases Date: Sun, 25 Sep 2022 19:30:32 +0800 Message-Id: <20220925113032.1949844-55-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220925113032.1949844-1-bmeng.cn@gmail.com> References: <20220925113032.1949844-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x532.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, FREEMAIL_FROM=0.001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Update the best practices of how to write portable test cases that can be built and run successfully on both Linux and Windows hosts. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v3) Changes in v2: - Minor wording changes - Drop patches that were already applied in the mainline - Drop patch: "qga/commands-posix-ssh: Use g_mkdir_with_parents()" - Drop patch: "tests: Skip iotests and qtest when '--without-default-devices'" - Drop patch: "tests/qtest: Fix ERROR_SHARING_VIOLATION for win32" docs/devel/testing.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index aea5b42356..0eae9c4654 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -115,6 +115,36 @@ check-block are in the "auto" group). See the "QEMU iotests" section below for more information. +Writing portable test cases +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Both unit tests and qtests can run on POSIX hosts as well as a Windows host. +Care must be taken when writing portable test cases that can be built and run +successfully on various hosts. The following are some best practices: + +* Use portable APIs from glib whenever necessary, e.g.: g_setenv(), + g_mkdtemp(), g_mkdir(). +* Avoid using hardcoded /tmp for temporary file directory. + Use g_get_tmp_dir() instead. +* Bear in mind that Windows has different special string representation for + stdin/stdout/stderr and null devices. For example if your test case uses + "/dev/fd/2" and "/dev/null" on Linux, remember to use "2" and "nul" on + Windows instead. Also IO redirection does not work on Windows, so avoid + using "2>nul" whenever necessary. +* If your test cases uses the blkdebug feature, use relative path to pass + the config and image file paths in the command line as Windows absolute + path contains the delimeter ":" which will confuse the blkdebug parser. +* Use double quotes in your extra QEMU commmand line in your test cases + instead of single quotes, as Windows does not drop single quotes when + passing the command line to QEMU. +* Windows opens a file in text mode by default, while a POSIX compliant + implementation treats text files and binary files the same. So if your + test cases opens a file to write some data and later wants to compare the + written data with the original one, be sure to pass the letter 'b' as + part of the mode string to fopen(), or O_BINARY flag for the open() call. +* If a certain test case can only run on POSIX or Linux hosts, use a proper + #ifdef in the codes. If the whole test suite cannot run on Windows, disable + the build in the meson.build file. + QEMU iotests ------------