From patchwork Tue Sep 27 11:05: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: 12990535 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 3F99FC54EE9 for ; Tue, 27 Sep 2022 12:27:44 +0000 (UTC) Received: from localhost ([::1]:48704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8cj-0006J9-7G for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:19:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8QO-0002Gh-1y for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:52 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:44623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QM-0004mO-8H for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:51 -0400 Received: by mail-pl1-x62a.google.com with SMTP id w10so8742018pll.11 for ; Tue, 27 Sep 2022 04:06: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=oneS/5NhgJGKLAYvnqqmGUrPQyryOhpOkHe8cX+R0Kc=; b=L/56Bt+JX9X0Ne8ftKzKqy51aMdWdq9uLz1c6x7Mk871a7uObql/hnJMFC+5F8tgwF cd0NwS1EhN0q3FogVu0yVlXCXbTg3m7NrKW2Bq1RmSncXQoH1B19wV9qNliT88zLo7Ae E1AxijGZXLUDndQR3VuO35bdKPXrEUQDgigERi48PpMsQqiigHSioqxg8H4cyCCm7mj7 uIUgDRJKXD0vsedtfnR3BsuShEZgj9fwFB969vYkghl7xTjG5l/kIubNC30g9EMpLCPD GTNZQPFl0ikQIkEE6aL9ptWBvmjrO77FBWl6/YcN1JyzV0Rpt92nkO/iEbFSYawu5xst k6Ew== 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=oneS/5NhgJGKLAYvnqqmGUrPQyryOhpOkHe8cX+R0Kc=; b=kJD5HhQkINiMEJSd5qXM5tnCY5KXmjWLylZri60G9OOPEdT99x8oAy3un0a13u5h9I YWb99GZ5rcwAT+rHkWDiWl+Kp2LeecOzuCvavnzkP4vCbwTdWOoQiCD1+ub8rCGtoJkZ CLQR3Q5EqzSgqyV3FVgXoL3VROc5Zo+z+17rXw5cQqCk/5pP66ud7KosP9WZM0dvjV72 ZxVgrNd3rBTwboiBrUc04r61yVWNexVmgEJdrGADP6ivORj5/SSqEfuI/mL0y6+4pifS HYuAtKH66z2tDfjfu7HIx65sa7VeImiPHRDnCDgr9OvrHgC6wV3EQPYfjJJjGNgJve6b nXng== X-Gm-Message-State: ACrzQf3IwtipL5eXadU0xy+aIpkrU+Gis8e2hlZ79zoBfNke5EaFYtcv O5w8UrWjjOUT7kwRNuXC1rTySNUSTxk= X-Google-Smtp-Source: AMsMyM4YhPwvB/lQqL0TSDlTnsWywhHcI/HguAOqgcIkAmjOee0Ea57UxnGjKJnEeRVD0n455LYZVg== X-Received: by 2002:a17:90b:38cb:b0:203:100:bb53 with SMTP id nn11-20020a17090b38cb00b002030100bb53mr4003138pjb.107.1664276806560; Tue, 27 Sep 2022 04:06:46 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:06:46 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 01/54] tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable Date: Tue, 27 Sep 2022 19:05:39 +0800 Message-Id: <20220927110632.1973965-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62a.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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990441 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 B0B20C54EE9 for ; Tue, 27 Sep 2022 11:24:32 +0000 (UTC) Received: from localhost ([::1]:50008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8hT-0004AH-OK for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:24:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8QP-0002IC-Bz for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:53 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:37882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QM-0004mj-FE for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:52 -0400 Received: by mail-pl1-x630.google.com with SMTP id d24so8764846pls.4 for ; Tue, 27 Sep 2022 04:06: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=XTsx8CxNq/kOZS8aJ0d3oeKrI1TXbCHvnBVEV6WfrAxuxYAaLM2DvQCkX2HpLTqWmH baNuzEMWRHlTXHj0rV9D385IXUL73G8DJlMQX4uKDfPIoAGBHjnVGn/kdYrOT2oadTsp Bkm4QTaGpgs3HUmKlQbJgbNG4mvfvMvknCarYjGMpGs1huGG6dIfrrSaC33VvJHTLaX0 oJxaCEfrNzqQYJunMMEIbKxS4Onwj15Is+UjFrZ1QLm/8xw6VLklj8R7BstJyQj2wahN 9Cn8wEmDDKkh5SxJ7gMB8fMUwSa3mH0tDgU3xIDOP/pQRomRECsHJTYhB8RtVpVPwBYi veLw== 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=GDcEdi+T6DLPGBg2Ls34Cwd1uuHhCaC/pBXbLvKeYDgOiLfZA5Mt4VWBL0YV3EReM2 zdi/L0o6Rk5R+osFMV61MuEv01D897w4zanFkSGM68gmbfjSOJcRXRp75xgEVwbI1nN2 9Hagh4DgDVn995lfC1xwqHNzqyUFZ4r5hGidWQAierz6pBbfFwIHwmKrOt+P/Pat89u0 E5ckkxwj+KYKcRt7iwEeqQ3UOrS3pNSdmv1uPY2gy9JS7J239GvC7qhKJGbka+QkFNiH NRnVqHpxvYZKb1Sd/9V/Fl/rDCo1+gMA92EGhR5S+3+po+qgMLCb/wYbUdP58JQT5nku HR5Q== X-Gm-Message-State: ACrzQf1VJ0a3l2u/fPwT+hhp/LOvHpZfYPs4i2KyVaK0hlvy+aMn4WFH KtpvNDHb3x1dZTaQ2sAVpvrgywsvUmg= X-Google-Smtp-Source: AMsMyM4Tq2inUqqUQwZ05wknyyfHiH4CXnC09PUMS8u5RHYmSYHF9SgPQce8yMLpbImsuzFLdmjSHw== X-Received: by 2002:a17:903:228c:b0:178:3bc7:8a3f with SMTP id b12-20020a170903228c00b001783bc78a3fmr26393633plh.88.1664276808836; Tue, 27 Sep 2022 04:06:48 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:06:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v4 02/54] semihosting/arm-compat-semi: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:40 +0800 Message-Id: <20220927110632.1973965-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:05: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: 12990442 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 0C2D6C07E9D for ; Tue, 27 Sep 2022 11:25:39 +0000 (UTC) Received: from localhost ([::1]:43006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8iZ-0004sl-2f for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:25:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8QR-0002LL-Rp for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:57 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:43553) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QO-0004n2-SX for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:54 -0400 Received: by mail-pj1-x1033.google.com with SMTP id g1-20020a17090a708100b00203c1c66ae3so9748640pjk.2 for ; Tue, 27 Sep 2022 04:06: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=x1b0DAXqWLfiXhIrelVULtyJQz5QogyXKHVADLX3USo=; b=OEQWGlp8ddYVy7KDzCF87peGjiai92wCcSzyVkTBc9cmZCEWf7WrXCKCDovalt9Lvd UWUJYNe85u+1QbWKPfgYBygtFVUNML1w1Y+tVVUYp+P+Wfh6IBtndToijmRkoH67IQbh IQmyQEKQGUUiMJ8KM0Aah6+PjP7kCaamRH1tFumlRlkVCnM7cdOVGu2pzckNe25J1MSH +/dqOft0gsK0wqM7xdTDh+ysbcMoMWhepRhbKZwqqNgIgauBW9K5lYg3ZDyveS+AqMKw PCTgbFJNlrGT99i7ugu6mR46JGjXWluLQqyP3H47DvG4QXgt+n215YgSCr2yhfmqmyR0 5g+A== 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=lgBYuLR6KSNqeAo4whf77eHfzLuo+eCgk+tYkpicAWXxrPhTjV3rbDJfruwCPDpYL7 PlW/Ru8DzgawhpAknq88a8OVuYEhitzvikEmmy3Imch4ZOpwoS59QeijKSi7AsgayLKW 5PGT8Maj8bUgDeLfXjGkOoa3VBqRTjeYDnrKUpx3AaDXvgDLN5eied06gzUp7E3b8xNj E2PB2H3B3ChFAWuxrGbNwUuZsZVWRooqCf07LK+jX/mp89yJlJpmZOMyICEMq0mnp6aV M8FV2SLsGcpDYKWPx6zEnh3E2VVylwHXkGNhQdOgpPVJ12eE6YVRnrVLhd78EpnkqbW8 ohgw== X-Gm-Message-State: ACrzQf2LVrZij0wHlfK/wlvEEt16ikSSSNOHWyAriqlcVQeQ62BG6l1I LXTkd8IhriMbtAPqF4bs56lUv+JeNN4= X-Google-Smtp-Source: AMsMyM6UaTGNIt9dmWu/ifbDD6PghbSeQ3rAJPsddSwIUAiTmbHKitWvFIOcFaO5kJSI0sWtC9bo2Q== X-Received: by 2002:a17:903:32c2:b0:178:2ca7:fade with SMTP id i2-20020a17090332c200b001782ca7fademr26738551plr.71.1664276811143; Tue, 27 Sep 2022 04:06:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:06:50 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Subject: [PATCH v4 03/54] tcg: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:41 +0800 Message-Id: <20220927110632.1973965-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:05: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: 12990466 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 24BF5C07E9D for ; Tue, 27 Sep 2022 11:28:59 +0000 (UTC) Received: from localhost ([::1]:48750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8lm-0001vN-9h for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:28:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8QT-0002M3-1E for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:57 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:38526) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QR-0004nU-Jn for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:06:56 -0400 Received: by mail-pj1-x1033.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so15216272pjq.3 for ; Tue, 27 Sep 2022 04:06:54 -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=QJ+jF4FAvyLHHd39Ryac5KgNlIvQKd6gJdzhNVeaMfsOpGlko166lZ0yPd8A/O30uJ Wkd+byf+ElRKC8TEE3QewkG6w6xNuOzd9QRz+/EBHxFWVKFR7EgIfbhfgwD4lQBtM7yr JsJVbU+DomNCJbCQQyDXcXZM0B4F5f6PPfV+l65I1veLUoOr6TbwVWZ1W8GagjkXeuId VCo5B8rJjEbwgwirQs2l0rYheja9Onr8qe/a91wnVDhYgVShr/FS0dQgWMOgatQqcSQM AcXtnX906sKmHPwj34UxrJ/m9QvAUqedhw9oYcTfcC+e73m1siZVL1aBYchA6WbeprfM HvOQ== 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=SrEpxt9Sz67c1V62ABhkP+isny6ZLgOVbmFREUY3Yeh7vOFqAsPkA7WQ3GReGwKGbr 2tArbv02tuXk39KurkvH7OlC7LfcNozSNBq7sY1sHOQ+dkTsdmslkr5tC5ZSiAliZfDx W7mwLqTDdVfdqUqus9lHGLhZnm2dZY5PncNcSXNN0fl9XpvJB22fdyejyKD5SC0/hhr/ HiYQ4vu/xVqxi4jaR6V0zDjR4DgoE1J1qQ8HLqlb+yPkl2juuz5MhDygd7MBLO6IzzOp kFHHxXW9lINepR2/qlS2yFz8d6hxyFo+q3EKo/6BoN/Qy9GvrZNFewfbl9nkIBl+4h6Y AShQ== X-Gm-Message-State: ACrzQf3nlkvPQov7lKqeJR6THhurQIlD62kS49fzyROQbtH18BOyxLOG lxqM5c7K5ciWvnOYxhYdS/Bif+5DCyw= X-Google-Smtp-Source: AMsMyM418LnzV3gLYD4MgIm3jrOF9gLm9oJW7zPf4Af1i7cGr1RTmZMWxuYhD5ulQ+0e8bcTPCfNfw== X-Received: by 2002:a17:903:110f:b0:178:a07e:e643 with SMTP id n15-20020a170903110f00b00178a07ee643mr25840159plh.41.1664276813278; Tue, 27 Sep 2022 04:06:53 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:06:52 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v4 04/54] util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files Date: Tue, 27 Sep 2022 19:05:42 +0800 Message-Id: <20220927110632.1973965-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:05: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: 12990534 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 C7AA5C54EE9 for ; Tue, 27 Sep 2022 12:27:39 +0000 (UTC) Received: from localhost ([::1]:60228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od90A-0002El-2p for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:43:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8QV-0002Oh-NJ; Tue, 27 Sep 2022 07:07:05 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:39909) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QU-0004ng-2d; Tue, 27 Sep 2022 07:06:59 -0400 Received: by mail-pl1-x62e.google.com with SMTP id f23so8755546plr.6; Tue, 27 Sep 2022 04:06: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=GthvPF7Fn8DUocZcof26qEqCqGyYjxBZwhptHR5ty04=; b=e1IHWcWmKnSdT8OPU1Ki1S1H1aDT3MPejjhKW4FQD86Z1hFv218mBzJtzyluKD+jeZ 6WGPn0OCiSubz1R3eB+6QCiS/VA7X1Uy2gb83iaIDH4qEuo/st1NQ+2xUYyeMVbIcEig U4AqTgDcn4lS4RRtM6UdUsgKSiqEcWsZsO7DbnWsX2GSuv/ftrEz3lY8LYcs8r5JqtEw j2kXfWNs1Zq1W9m3wjaQq4x3UGY29rsQgb3/A4AO6uPm0oZj4k3kZQnYh1DmGEuS0vrn mHvCYpftqPjMPQ/OAViq3sU9TpwPmC5W5k41NJcvgOy4gm00jkDLFjcXyU7IogmVClw9 VTgQ== 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=GthvPF7Fn8DUocZcof26qEqCqGyYjxBZwhptHR5ty04=; b=ehQ8EhO07IUI+SDXEnbL7BgUrkcozxRm9WiM8DGJPVs340gQDVwLZyqnMPHQNHYXyd SgbMxbzxmEeaGUiz72YrA8skUzEBMWGzYJurN8fIsG2YA7PXNu+BUPM2c+ipsnSddpLD SWIecv15/miQzDCwpwy+7YA7qA2d2Tfq38YkCMcKSLhTwQ5SkGzAZ5G6e/WCJXw0hD3O KrZFOftUtZrt/+egmc8JkYZ66tsQ/BJb2isycoryWCpAEhKN9OSwoEkxCI4lvWJN60ms qU1hXeNMUNXllV1TOlbbRWmWmZUzAlMdem7+uSAtGnrSGSxep7TuPvo7G8tzOaz3hcUG FeVQ== X-Gm-Message-State: ACrzQf2ATjDV+gBzK/SEabFiBvszOg4w75JAM4zI62Iuhatn383WTCNd lnXUSYMglVeqA4uNadB384gWDzF2wec= X-Google-Smtp-Source: AMsMyM6baih2nT8mwFxNrLbUEZLeDhvGE6P0fCF9YqesQ9SKP2JzDFjrc/VuYxnP6t7g1/5EyXKRpg== X-Received: by 2002:a17:902:d3c6:b0:178:37e0:2e72 with SMTP id w6-20020a170902d3c600b0017837e02e72mr26809341plb.28.1664276816045; Tue, 27 Sep 2022 04:06:56 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:06:55 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PATCH v4 05/54] tests/qtest: ahci-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:43 +0800 Message-Id: <20220927110632.1973965-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62e.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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990443 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 2D3F6C54EE9 for ; Tue, 27 Sep 2022 11:26:38 +0000 (UTC) Received: from localhost ([::1]:43768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8jV-0006cO-A3 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:26:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qb-0002On-BQ; Tue, 27 Sep 2022 07:07:05 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:44623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QW-0004mO-EL; Tue, 27 Sep 2022 07:07:04 -0400 Received: by mail-pl1-x62a.google.com with SMTP id w10so8742403pll.11; Tue, 27 Sep 2022 04:06: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=IOk5o82HlzTaRF4tA+m1XabKpzTdOlWa4a9Iku2Z2e8=; b=MarMC6WZTRnjGKtbJ+/SgdtdUhwaMAwWiTa6NCxabjkl6RGOLmqz5rSM00xZQD0/Ok qHEEqXGbPwUKH+74taZOLJWfAw/kHTfYSMRasvPJXeaSGHA/o0S8TyadDwX4tNb5Laij VR17l6AZ9OrO6OQHDv5VJs6z72NfEm/iWRqevmk7Cjhhr/lGmwQU1VqgqXrozhHYDsB6 qbG3flK8ExigClWP/oFWIfI5bTbM2GKKyp8qZ9S8qLLbnDvO0/9iwKg0F6HcU0Lx+eTe EhrfqEdzLydEvqHQaPlakyszoDF9V9rHUdRezw4xWT+7TyuRGVDZaPVcqqKA0VM8JcKE Q4wQ== 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=IOk5o82HlzTaRF4tA+m1XabKpzTdOlWa4a9Iku2Z2e8=; b=Os1i7gepuAYcOXwY332hRx3iP0di7ccpXPLEu9is7Ond4Bd3VCWPsCF+l+mvuJEpgp hsPIMi7fehCJA6Zy5n6q9pUaZnDSUH5LkAJRwaFPZ8IF7V0uSCwI3ZLaM9KS5Z0mnwb7 fT0N53S7CsHXZ6ke+i1I6RkoHWQPAfIImkeM4fKRceH7KXlDuwxEd5c4CuMG+vuoX8JA R3uJMW/2gBu9qdNq0veW78+6SKgjwII3+Y1IrybBLyjM1Ejz5hclF2hlIsCm+neCtbKY 9DhQ3nGhT/KQvrgt70ssQEdosX8BsbjxQWcKZynQHgrS1avOmRDtDc7Yn0MstqpuErDh we2w== X-Gm-Message-State: ACrzQf0XW5AhJuSDj7WcUzewYqtaHwpkzJ9M3FCXSWBCrS0xJajaBKBR iuQl5eAfTbE/apt3aYqxkz9Q69akXaY= X-Google-Smtp-Source: AMsMyM4UjIooe4Wrok7vwuqleKH9/0A9t/Kil7ss+TG3Cqvi31voALfoXU7sauagV+LdC8j+5vnf3w== X-Received: by 2002:a17:90b:4d8e:b0:200:73b4:4da2 with SMTP id oj14-20020a17090b4d8e00b0020073b44da2mr4068276pjb.197.1664276819344; Tue, 27 Sep 2022 04:06:59 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:06:59 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Andrew Jeffery , Joel Stanley , Laurent Vivier , Paolo Bonzini , Peter Maydell , qemu-arm@nongnu.org Subject: [PATCH v4 06/54] tests/qtest: aspeed_smc-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:44 +0800 Message-Id: <20220927110632.1973965-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62a.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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990472 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 E4B64C07E9D for ; Tue, 27 Sep 2022 11:34:20 +0000 (UTC) Received: from localhost ([::1]:56230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8qx-0002ir-Oe for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:34:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51436) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qb-0002Om-En for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:05 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:40956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8QZ-0004pX-Ew for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:04 -0400 Received: by mail-pl1-x62e.google.com with SMTP id b21so8755378plz.7 for ; Tue, 27 Sep 2022 04:07: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=nYT5Ib6w3wC5eXhDEWVPn1yI3eXtWTmEMRT0Iv/KX3M=; b=CuJX9oWHsSCd5PaVzvfY0DvF20SaZMpxRU/HSfvv0If2UQlqmX1WW3IkzrpH3FYsYd fNJf9szMS60R3ia0guZqjbtHSuj9pqQFF1rhP2eGqQCKttN7jMqmQqvj6HU3R+5oNd/5 9KEaLZEEN1p/GCMUKsdWp5eTgMYxasFaWEKJFcfRqXANLp6IrzhrJHmcvOTxlZ7OiSLf TXcvmVDLQlpsLJjIm99bpypmqELx3kR0UC1t9TAFcrUdwvmM5rwPfx759qeKJAA5FeBW xndOOcT5Ms5QIFz4BwrR8FL8WoBY/sXyV+gi8pUC6SUqnb21wFuiho1FhGtHJUIJ/eej GTGg== 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=nYT5Ib6w3wC5eXhDEWVPn1yI3eXtWTmEMRT0Iv/KX3M=; b=dYsAoPH3Ey5c+GU1Ooo8am/wL3QTv8z4g/J17YSkO2LYrrfCt0zCeZa382CQA8qwJP 8ABcNIOoTJmRkl0JV6HMRJ+LrVjL/kaM9wo8zzCFjwwsPAn/7diWSBRx07OH1mOqzjRV b0LgQQtMkZ9iaVr32T6+WcdP4LdkoO3QsKE/DcGwKgP0LtSoEPxnLXkpbK+8RkqyRLuS cB+PfJK7MfmTijoE4zs5/kr7eVMUA3/nasG0wyhPD72oOgT3TA2y16orkM/v7PxMfIb6 TmQeGgnr8iG1oyb9U/Kgb2V2LlQh0XnNXgigwFIpw6yCPkYy4tTQcv23eILHQ/yEhjNW Xs6A== X-Gm-Message-State: ACrzQf20Et3pfKGPZJwSw9gdQw7br1IEq4dkxPnjUsYrwel1GK7gFFAE NcKAizRbGDrgtOghOjcpq851R7Fhq3I= X-Google-Smtp-Source: AMsMyM7ieFJoP7Xg0RQ8Xk09osRShMuZGoR9r9j/5GD7+4eSmbCoamDu+ZBlsIBe0N+eVu9/s7bHfA== X-Received: by 2002:a17:903:2593:b0:179:efd1:bc4b with SMTP id jb19-20020a170903259300b00179efd1bc4bmr1561786plb.35.1664276821716; Tue, 27 Sep 2022 04:07:01 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:01 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 07/54] tests/qtest: boot-serial-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:45 +0800 Message-Id: <20220927110632.1973965-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62e.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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990473 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 A6B61C07E9D for ; Tue, 27 Sep 2022 11:35:20 +0000 (UTC) Received: from localhost ([::1]:46824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8rv-0005Uy-Mt for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:35:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qd-0002Sy-JF for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:07 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:35575) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qb-0004q1-Pl for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:07 -0400 Received: by mail-pj1-x102d.google.com with SMTP id q35-20020a17090a752600b002038d8a68fbso15268900pjk.0 for ; Tue, 27 Sep 2022 04:07:05 -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=QWOXKMHz0rXQ5dPdBLcePkLMQ3bbMjZW51rAm26MIow=; b=hizRdoxmoaGwHWJJDA0ZCotI0xKXEfEzQvaoz6uRmQ0w10buExYaBkiuIFgYpURFDl HqM9ZwtCifPf4sj9Do+DaEiNQwOeCFQ84MCHrpUbVrVVisVVBgnV5ExFTaRhB1MxHUFk zO0OQPTo7IXNvE7k4wf77V09ulSm9oNya+B54YX7NZMK0kmqohEfeeVLZJMriJ+XVMrt gNc5tTcMHwLKdWpEWWt8Nu4sqXNPFdJ9Vn1XJhlH9+G9vNzVhnNF3dFLsKyc+l3F4Yjd N/SvuM/4qWKgLszVsM4Xjn2NYWDRrEdMT/sTxmGZ9RDHihKbMrgIco4QkgAqrYCKMau3 iBWQ== 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=QWOXKMHz0rXQ5dPdBLcePkLMQ3bbMjZW51rAm26MIow=; b=fBqrwawpw2yDYy5qTu/hbzngRCFjS6s2po2G/TgGA6m4uwF1l/hhr5gJlRbEH9lGdL EPOzLMGJ2NYDc3bo38y8vrLuf8PARkL89SnGrp6Ny0yaQJGM1e1pAEa9Zsp0fv65I3B+ u4tFWzm5uO2ynEjP3op0a57xYcypK9F1Co94Y6PYrJw9te3nnIBXgsIqPhlY12qPkX3A 6cHnW5HhnqbYKapob7oo9zOKhvM/aYYWppLz3xF20PfLN/5Tj1wd7MLl5pf1N01c96e+ 9CVY9EIa664SPihMN34JvTbUzn1VbUVNJ+mXWry33YvxZiWdEHCi11GnoSXkQS/Jl7jk n73Q== X-Gm-Message-State: ACrzQf2cGptf3ICDO16uuFW7CmuoM7F5IurYhmhsr418MsiaxHqZLsDf Gl3oPMEl7iKjJ/lK7R/a+GsRaBK4IK0= X-Google-Smtp-Source: AMsMyM7aHwZ/dXxbQtSDcko9DEqS3+4XHuCM95SIAt4eUTaRyibolagtjxnifvkfdsfApq5FGQkmLA== X-Received: by 2002:a17:902:e749:b0:178:3980:45ad with SMTP id p9-20020a170902e74900b00178398045admr26702035plf.153.1664276824148; Tue, 27 Sep 2022 04:07:04 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:03 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 08/54] tests/qtest: cxl-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:46 +0800 Message-Id: <20220927110632.1973965-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990536 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 4598FC54EE9 for ; Tue, 27 Sep 2022 12:28:07 +0000 (UTC) Received: from localhost ([::1]:41832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od91Y-0003Z2-Vk for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:45:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qg-0002ZK-9A; Tue, 27 Sep 2022 07:07:10 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:34543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qe-0004qi-Jm; Tue, 27 Sep 2022 07:07:09 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 3so9115020pga.1; Tue, 27 Sep 2022 04:07:07 -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=DDfvonev3t2AiyDX5B9LyzyUqH7SwQcTwUB4VoIT05s=; b=Q5VYaqW5NSqPWE457QCR7hHozqPWjsKjCEhJ36Mxvbn3oZLNsaexYY6zq+tmwfxLUP sa0gdTkNI8WoEHb6FpCHWavRK75IfoZ68xsWX2isCfOBNVZRZePEbk/jF6TrF7OfvHUw g4uRu6LL6TXvD6qeC0PqlI3Wht410p4m0MWPOadjJ8Qy+tK+RZSB2Qx0GJR7PenY0CML fA8eG6BZL5PMyMo48NF2t69+QS1X9fEVhti7WWGAQQR0TOg2iGDzhJwLIxAwlaFoqztZ bAnEmvo05v+i27vrELZtnBq7LiUQA6S+C4a6tOoDiBp7YqNP4Z5oH+cub4eftKE7KzY4 lAxA== 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=DDfvonev3t2AiyDX5B9LyzyUqH7SwQcTwUB4VoIT05s=; b=4lBAJH0LQNO4QCRZXjdMhivoBq031G2V57EyOU/TRc+uB7ZdPI6T2CVsGo/US+g8bU lx/D/umrpWn2Yv/tAHQTp30tOZtaSTNOwnf8Fqr4BEunF4YT3zUNcnEjAqbDtmnXKUI2 2+50JIWyClyf9QOa0Q6FRXQyVOpPJB/pNnhoY2ig9qOnCZMNTHlVxmrSUNF5O5W9fkgl UmvXuzUVzcbXLejA05KYGZ1/Xzl14Z34RC/pVIggoTmBIUnfH914Ls/gGxBSTaFcGOxq ZaPTyZgNRR3LEk7JsVnCZkwrH8uCExeXBwt8pQt9AoypnT8/lsuiyxKSEnBCZzeishRg Qm5A== X-Gm-Message-State: ACrzQf3+vSEHyyyJ1BB1z7N8ntE/yNEOJLi005gexF++wgMP9cWcxABr UgJ7fCtx1oqIdQ1avDt8fK3SoRhtEY4= X-Google-Smtp-Source: AMsMyM7hl09IOpc6CpDqMs6Uq0BaYfbnUorj9ZeEeSy5dC1UW+PgDthyTm55BLWWYAubmUr1zVrUIw== X-Received: by 2002:a63:5511:0:b0:439:12f6:fb9a with SMTP id j17-20020a635511000000b0043912f6fb9amr25031540pgb.197.1664276826819; Tue, 27 Sep 2022 04:07:06 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:06 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PATCH v4 09/54] tests/qtest: fdc-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:47 +0800 Message-Id: <20220927110632.1973965-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990501 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 A5512C6FA83 for ; Tue, 27 Sep 2022 11:53:41 +0000 (UTC) Received: from localhost ([::1]:36632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8cA-0005h3-Ll for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:19:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qj-0002gf-Ai for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:13 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:35656) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qh-0004sD-Nb for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:13 -0400 Received: by mail-pg1-x52d.google.com with SMTP id u69so9109250pgd.2 for ; Tue, 27 Sep 2022 04:07: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=cirh3Kjj/nxbkwXCG/8RgduffnSu2srYvVt4uLgnRrE=; b=mdFXY5X7i/+JwRyJR39fsLhQmWKhET0cgh++DL+0IWLoQaCX2TzEMQZWAg5ezhvRbI m3INbKwLYZanw59MMsqV10AsusoOH4hM7ue+abxQL3zYgYWl6ORgsqiTWOCqwG6K6zbr d2B1GrzAwDulcBeb4zYOl/jSEopCiuCWcnIYA2o6X2qc62JSXKLeKFqG30Y6eeqydq5V C4qabhC+3rOCl4T1YYdd+eMbexr5EZeax1FfzIs2Ft6Id8s65ks3ECzIxTDK3uIdTKu6 njwx5EnWteeJx8M5P9xNXSrIdK/WwFeQOzbziO/XzNh78IthUvG3beSF5w6eYTSPlndg 0MdQ== 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=cirh3Kjj/nxbkwXCG/8RgduffnSu2srYvVt4uLgnRrE=; b=Tv5/0Vr+uAIvNpuOJyEye0FLSllE8iTobuP7fedgYpyYSfpzXAi/HlYFvlCSxGDlmo cilAi2OimwCR/qfraYReN58u61LGVDB82o9QrF7Ew/734wVYliMKsIAWUlPye27br9Y5 ZR/35YeYvYZsHgNlnWKTlc1Cw6AF3Gj8srRSHeEq2+6paYAWcT9Cd504OgJwGOfNVL/n brTk4RcdIe+nmml1VB4BZjTkCGIcBccU3AOaDsChw8npx6hxiAPZCMS62eX0p0kHe/jN MNYxCnmMFtG+vEg6+EOXUwHQIs7OQ+vh/NsNYXNwWfhZnpB4XRyJi51RKFQCDIdNfeFA Vl9w== X-Gm-Message-State: ACrzQf2gtqtTI7oWtYayVDLMxRTAcLXgZOq7COVMghB9zX9FDqutNyMq vNi+8g2t4iI4rzipI8accRNlSrt8WAM= X-Google-Smtp-Source: AMsMyM6N6Fcp0G3O/x4bKG4DVLEMSvwWTkmk6XEYF78UsrnX99amI2Asr/MJcJj+w1oI4vF7+loHSg== X-Received: by 2002:a05:6a00:1ad3:b0:548:962b:4c53 with SMTP id f19-20020a056a001ad300b00548962b4c53mr28358782pfv.59.1664276830147; Tue, 27 Sep 2022 04:07:10 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:09 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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 Subject: [PATCH v4 10/54] tests/qtest: generic_fuzz: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:48 +0800 Message-Id: <20220927110632.1973965-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990514 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 01F04C54EE9 for ; Tue, 27 Sep 2022 12:16:36 +0000 (UTC) Received: from localhost ([::1]:51956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9Vs-0005S1-27 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:16:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qr-0002ky-Qv for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:36589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Ql-0004tL-2B for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:18 -0400 Received: by mail-pg1-x52d.google.com with SMTP id s206so9107218pgs.3 for ; Tue, 27 Sep 2022 04:07:14 -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=VeKRFtfMbwkJV5+/CUHC76GDYzCTkisYHlSIHzZHJIo=; b=Q1l+kHWOSGmg8aBAT1XHjB5ku4+aVRgyZYfrGjEfHxIEV1QIv526IA9a/AUNqJtMYb KDmEhd3ee7fa5NHvciO7PrfllZ6m4XZ2Ts7oQDBcqyH/gjXHi0T2Fe5H3xRUa0zcc8bA lOPOYOYzvLJViUNW9ObGLaLBFPK/YNY3QcRE6334c9MOdb5dRyXePDB6UegU8KpWqBaZ phK5KAgFa9rI4AksyPXzIEgSNSoRXVjjaTENOg5vpNID3nWishaoekWQSGqxVyku+DkQ vQV1c1q7MCLpsLfMC56aROZiGrfWJTdpXg0sXkDHqwFmoivi4dXuY5A2dYgJABOXz8Qy 5O9A== 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=VeKRFtfMbwkJV5+/CUHC76GDYzCTkisYHlSIHzZHJIo=; b=BT/eZrkl+XvlRR+0UHEjowXWAgiMbBKYcCi+Py0xdUwtJtMfh0gP7JTj0m1eZ3Rir2 eZIHwNhwJf619hK1hzqYjF3tPsgMo8slLDj++VTfpPoCQvND9lb9NcXY7USysSMieAUP PKGThzxIx1KGJstNZ9Fx8Ri5u2YaVC3/E4gnwJOsdzyn4UUxguKYgrP+fzWG3ykpIkbr Pieng2F/liK2mkhrc+6vcVp6XPvH6I8yQeqDRPKXp4QcMmXKBaYxpVf/isY280/aiNSA yiXkVl1mwDGZTgTfBprzaR5r2zcxOoW0k5lgEN9eFRc3o0qIs93OAiniueh8DAiemYTK hVDQ== X-Gm-Message-State: ACrzQf1zInyh2dYLdVoFZxO1GloQGVVplT5TIAfAx6U68HGmt4FDa7oI fMnskiTWISK3oRIIZISpfkjqgQIbMCU= X-Google-Smtp-Source: AMsMyM4ukLC1A3BD40RmwTlimWF0LfKTTwpG0FSwKSCec+veAVae3X1iuruSc3SGSdnBCZmH7+IW3Q== X-Received: by 2002:a05:6a00:cd6:b0:546:d03:3dd7 with SMTP id b22-20020a056a000cd600b005460d033dd7mr28652071pfv.19.1664276833664; Tue, 27 Sep 2022 04:07:13 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:13 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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 Subject: [PATCH v4 11/54] tests/qtest: virtio_blk_fuzz: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:49 +0800 Message-Id: <20220927110632.1973965-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12990528 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 A1CFBC6FA82 for ; Tue, 27 Sep 2022 12:24:46 +0000 (UTC) Received: from localhost ([::1]:50758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8gt-0003YB-2l for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:23:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qt-0002l4-EI for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:33430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qr-0004tq-2s for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:22 -0400 Received: by mail-pl1-x629.google.com with SMTP id iw17so8800591plb.0 for ; Tue, 27 Sep 2022 04:07: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=XZxuat3Ohybft7pjyhNM9f2+0mg9c8x2r1GRXvNmwH4=; b=QOPgygQaxvdpgq1o6VVnY9DT9UKOH4otcNJKbxEUlbXwXagtNkYa9P3/lyyPCpDa15 Y98QRHsAUUCKzOwQr2SBhkG32qkZ2uu0EFNJxo46BfJ2gTWJW0Cv2ZoliUPNe9dG4J1f wDqtzInIHpHSSYJZbW4EFSgMVBuAz5RmugwRKy2EOIbiu9ryDdTN486GfwtnSir9fcli t8/t9BB+uqK8i4SQ/fUlHtnkmN0ud1LmELLeknhCxgtjWw1i74+sHWwOZbT65z0duYrW gswHi2wFPgbwE08NRjpMaFx5FsHfY/puthnTBYkvHfOGONrH0saQSyPf+iNgN1fH9Rep /LDg== 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=XZxuat3Ohybft7pjyhNM9f2+0mg9c8x2r1GRXvNmwH4=; b=tkbbCWFQD1yk4kHK5KQwnXDzL3gO7KL258I0LpGSPHhd+u/fLKo2Q6hyEflH/2qtu+ JwgiFWXjpQiB5dQv+jdxD1ItcPJYQMgtPU229gzfo73fOQTTmSu7Yye36UUdTKk6g4CP rfT1OtPrymzjwnDU8gdIi4/ism0rO8QgwvxPla/bLyyZUvBShiZnxkCL4V5RFA7l8UMv tXbPOL/vnvHfut0h2DsIEiRhkMrNHRmLLoSZGQHNtBhHDVhww3t4HT9ccFZgdBCaBdaH dmqMg/mZszNP2FJpCJk4slzFKP/FdIh0OMqsiSj/27kHKp3t/0U5k/Vv9VpfclytxZT8 /bBw== X-Gm-Message-State: ACrzQf3Sqp7p6qdlBdA83sw7nhwzcFGU1yfL/Vwv/k9WKnjKB4TqXTuO hmA40ZgUvbP6uYtKgQcnQNypgg209mI= X-Google-Smtp-Source: AMsMyM40MhSKXrIwB27gPEAM0IvBP41eDnG5ufanWtAlaLcV4OVZqE1AfmFVRvEpV5BtxLGsrRAF/Q== X-Received: by 2002:a17:90b:4c8e:b0:202:be8c:518e with SMTP id my14-20020a17090b4c8e00b00202be8c518emr4057360pjb.26.1664276836180; Tue, 27 Sep 2022 04:07:16 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:15 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 12/54] tests/qtest: hd-geo-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:50 +0800 Message-Id: <20220927110632.1973965-13-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x629.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 v4: - Do not use g_autofree and g_steal_pointer 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 | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 413cf964c0..ba772f4d7a 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -27,16 +27,16 @@ static char *create_test_img(int secs) { - char *template = strdup("/tmp/qtest.XXXXXX"); + char *template; 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); + g_free(template); template = NULL; } @@ -422,9 +422,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 +467,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 +477,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 +505,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 +712,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 +865,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 +925,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 +985,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 Tue Sep 27 11:05: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: 12990566 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 E1118C6FA82 for ; Tue, 27 Sep 2022 13:14:49 +0000 (UTC) Received: from localhost ([::1]:56614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od96f-0008Hi-59 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:50:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Qy-0002m0-62; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:35370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qr-0004tx-TI; Tue, 27 Sep 2022 07:07:23 -0400 Received: by mail-pl1-x62b.google.com with SMTP id t3so8779777ply.2; Tue, 27 Sep 2022 04:07: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=2ES1bdpC44vvo250IA1QHz3fUVBs2IlMW4SYoXdEXRo=; b=ir1Pc4xhWUs0IweHL9jcOvQjM+rseMn6YA+fHJUrt/MVSjsaVqo2MyxnV1FsBja8Bo kjNF7k1Wioj8vW6E1lx4DgkVFL/yKMaPrx6FxqcVsyohVVNmWbIX04dPN/qC58RZ/3MY si6T4fBbxZSaOVVWRzLL+rqNNR3i4VaGW7sSIldTZXEe1LAiaVT3GQmOoxd5a9Vbh3sP rsf3f6W4VSA8YQcURhWQaRvQibAYrYaFCtn62xv5j+xZfvm6l1tFm0tE5ZM2hrob7gA4 Z4KuujSX857E63QO/b63/P9/tOSjg4A8gm/q2jeoqazVaEmZSHgAValILw4dy03f5z6l b1zQ== 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=2ES1bdpC44vvo250IA1QHz3fUVBs2IlMW4SYoXdEXRo=; b=OJiSufMG9vp4Evy5hmSxUCPmUO2mBuMkyfxZfrMpqrmJNGaFRO17Zur/crVkTz/Y1z tL4g2/+rOJ1io4zbaWJCTkt81UJyt7Tddu/ef5ym5vZ/EoLTOhkumSbsN9YRWYgWoXPa JICUfGUH5sEt2OcdDrSddiM8UM2tuJGgy0woUWZJmUjZxDgbdRDsdEQuW7W5/E27v2fB Ai7AJA62PljYVu3zpvBET8vRsVj4yixTwgmWNm+BQaS6/kenp4kjxxebEzFFoMBApqI0 yNEBoFX6eF2vDCzMqbdiPKUAEjWI8uPbZ3iGMUKog1rE/I+57WWnKm+GwM59AbHk+8ij rdDQ== X-Gm-Message-State: ACrzQf2diRvxkbg0EJh0B5qc4qPmwNvWAzkMxf35r4++5X0hqoFh4zHm Zm3rqbrgsMZPRlgwQQc5Jp3DAyyiVus= X-Google-Smtp-Source: AMsMyM70WKbPkXbhOBCTl1sV6x4XNxR9KgSXiaWrHaEzvB06B3i95WG8pWqaVAlN+Jm07OrxdblWSg== X-Received: by 2002:a17:90b:4fc8:b0:202:a340:3594 with SMTP id qa8-20020a17090b4fc800b00202a3403594mr4053145pjb.149.1664276838902; Tue, 27 Sep 2022 04:07:18 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:18 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PATCH v4 13/54] tests/qtest: ide-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:51 +0800 Message-Id: <20220927110632.1973965-14-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62b.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 --- (no changes since v3) 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 Tue Sep 27 11:05:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12990465 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 38D75C54EE9 for ; Tue, 27 Sep 2022 11:28:32 +0000 (UTC) Received: from localhost ([::1]:43816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8lL-0001JD-Cu for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:28:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8R3-0002nT-2u for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:36608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qw-0004uP-Bz for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:29 -0400 Received: by mail-pf1-x42c.google.com with SMTP id y136so9383832pfb.3 for ; Tue, 27 Sep 2022 04:07: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=mvrmJ/pQkH1S72jelAHPkbozzUShmbIR4RwdiG3Eq4Q=; b=nXgD+lyQOw5HfOtFgbeBp0Ubs05yfp9oWIKV/Qgx5a3EhiIVl3HOOlt3qmLr6P9Zdh Yhj8P19Iq/hVvX/FjQoNvl/AQusA9Qj4srPMltdfviVvGGVSLzYYxF3L2lAwQ9eFGmVH UxYrsbXORkggAqQnaQhVC7VBDPfdKdR2+ej1MGPyCnlrZPMqDSKJ1zD7O0OjjmsTCFpQ ZVVpxz6+Ek3Or54iKUz049eHjcGIZEn4SZCn5CncEXUOtbo1W/iWhbnfb49lLUKwIjR6 40A2Z9+l0M8CKJuKbK5ASHvbM2++8hiVQanrRoDuNwFDqrkh6rCDf6UDlxVvUHtw/na4 vNog== 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=mvrmJ/pQkH1S72jelAHPkbozzUShmbIR4RwdiG3Eq4Q=; b=I176wBVQzn1DRZLF2Ph+QgnbyizHeDQHnonECIGb4K0aPhc8mYGnEmIi55l1qc0DGA LwruovtiXFgK3I4N1tmP08AJWqUfUX6+AkOWqtgEcSgXrV4SysiMu7YmNk4Ro3Pta5ze JX/eTQl09W964/6Y0nwdjgQ2wxzScbrZTwOptUSvSBnwGd2YCfq7BpXZj5vTlw5tC9Az hm1prXVyo9Nm1+LY29VGM0qqRnQSqixYC/72cZxhkAvDqMGVovgN9YM/ArppapBWJRhR PVAaKJtpEaGnUBBDzGf7T0T79bYj/SoXL1JqOELdfPZKqOp/yg3YwDch175soWXzzA6w og5A== X-Gm-Message-State: ACrzQf1jY2yG2UrgLwgwVOZxRFnEIqLuMBJqkBX8ZeUu/sOAV68kx+4V y8d97FeYOw0AjerdYAXT1WHHwJBsF8c= X-Google-Smtp-Source: AMsMyM6GES5WfCmR0+RxP4XTe/1D7bROhxzR879ic+XAiJL+aH2/PrSj6MtkPFmKig0UAW8Wp4Ku6Q== X-Received: by 2002:a63:e044:0:b0:43b:ddc9:3885 with SMTP id n4-20020a63e044000000b0043bddc93885mr23873968pgj.325.1664276841832; Tue, 27 Sep 2022 04:07:21 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:21 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 14/54] tests/qtest: migration-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:52 +0800 Message-Id: <20220927110632.1973965-15-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42c.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 v4: - Update the error reporting by using the GError "error" argument of g_dir_make_tmp() - Remove the const from tmpfs declaration Changes in v3: - Split to a separate patch tests/qtest/migration-test.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 4728d528bb..f57e07fe2d 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -102,7 +102,7 @@ static bool ufd_version_check(void) #endif -static const char *tmpfs; +static char *tmpfs; /* The boot file modifies memory area in [start_address, end_address) * repeatedly. It outputs a 'B' at a fixed rate while it's still running. @@ -2434,10 +2434,10 @@ 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(); + GError *err = NULL; int ret; g_test_init(&argc, &argv, NULL); @@ -2462,9 +2462,11 @@ int main(int argc, char **argv) return g_test_run(); } - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err); 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, + err->message); + g_error_free(err); } g_assert(tmpfs); @@ -2589,6 +2591,7 @@ int main(int argc, char **argv) g_test_message("unable to rmdir: path (%s): %s", tmpfs, strerror(errno)); } + g_free(tmpfs); return ret; } From patchwork Tue Sep 27 11:05:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12990500 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 B2997C07E9D for ; Tue, 27 Sep 2022 11:53:30 +0000 (UTC) Received: from localhost ([::1]:60880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od99V-0001Jm-QC for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:53:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8R2-0002nS-U4 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:42808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Qx-0004up-R1 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:29 -0400 Received: by mail-pg1-x534.google.com with SMTP id e129so3019276pgc.9 for ; Tue, 27 Sep 2022 04:07: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=9mqqdIfbR4VfPukRzl3JcnaSTQBvLdc6WQpYQIrxNWc=; b=Z4At2N8OPHxqgqyWKrHdzcwcllsFOQvxZwidCkFzDiDK9TEwYl47avpjzqSyLhse4o W4GGPPhhN6aQGmPrRe4AhN80LWq62I5BfqpyYlWi52HI88NWdI6THYADT/HBhKFnrBoX oMeVm7iZ3dRFlslKdx1aruA3KfzcfLmSBF3H2J9+gH4INsqmC+cJJi/TRZu713rqixvt J5FFMoai7CqAwURPLqJoGut9lNYBqc0wU/Kb9WoM6fUnak/J71lMT6lEMxAqqqjY7Kfy bPRHp9jUTT1w/H4q+AWORI8nuy6jnZ17lNeQGxnSLVYkysVnsOcrYjLs50MMjJ3oEzAF 9mjQ== 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=9mqqdIfbR4VfPukRzl3JcnaSTQBvLdc6WQpYQIrxNWc=; b=NQL2KeS1qncgcseUCnMjlX2/gKvgwyAsB6sMsJ6YJhGh3d9qjvDtzSyv8I/HA7HEdp e07J/GMYJx2ytFVL28Lcw4+fghWUCsS3QjRYzHby9ewrkCkg88sEvqeYfDcG59Cpk9p/ FZoj4C5cy1Bh9Lwqmur0yDi8fdx4hgt0xdBwtGubKtqDHlIs5/TxOCaUCWT0JCzZMhcg 2GVBb5qaJxy+f9pnF05XvNHtCJvntebmDTNJEfBv2i+4CNjQ/V5LKDTTMdp+bkM3cCyb 1/6ph4MeRZJTMiytHXAg5oCpA9jBfPyGLjfyuj6mqlF2nI44XpEVXDGSxe6h+fOEhO/Q nQUA== X-Gm-Message-State: ACrzQf3QLLLunay0zARX/p7RLhACz3kQwYpJedn3OQjE+4QN6EgyS15l Zv9+11baycSP0s2hkh+VfFCCLVLM79w= X-Google-Smtp-Source: AMsMyM6EDKJ3Y0lvnHDSAIfpIFI11q0Blyaxc7X1ya1Y1bfSgzxQr4Y36ZnlQuu+Eof8wDj1IEBqAA== X-Received: by 2002:a63:e64f:0:b0:43c:9db1:8096 with SMTP id p15-20020a63e64f000000b0043c9db18096mr11608421pgj.567.1664276844121; Tue, 27 Sep 2022 04:07:24 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:23 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 15/54] tests/qtest: pflash-cfi02-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:53 +0800 Message-Id: <20220927110632.1973965-16-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 v4: - Replace the whole block with a g_assert_no_error() Changes in v3: - Split to a separate patch tests/qtest/pflash-cfi02-test.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/qtest/pflash-cfi02-test.c b/tests/qtest/pflash-cfi02-test.c index 7fce614b64..0b52c2ca5c 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,14 @@ static const FlashConfig configuration[] = { int main(int argc, char **argv) { - int fd = mkstemp(image_path); - if (fd == -1) { - g_printerr("Failed to create temporary file %s: %s\n", image_path, - strerror(errno)); - exit(EXIT_FAILURE); - } + GError *err = NULL; + int fd = g_file_open_tmp("qtest.XXXXXX", &image_path, &err); + g_assert_no_error(err); + 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 Tue Sep 27 11:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12990507 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 BA3DDC6FA82 for ; Tue, 27 Sep 2022 12:04:36 +0000 (UTC) Received: from localhost ([::1]:45924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9KF-0006S7-FY for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:04:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8R4-0002nV-4n for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:53190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8R0-0004vZ-Qw for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:33 -0400 Received: by mail-pj1-x102e.google.com with SMTP id cp18so216830pjb.2 for ; Tue, 27 Sep 2022 04:07:27 -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=gEf1DxePwM+B9CFwwtM7eL8lXoHycHH4Piyf2mfnp6E=; b=fWJTRy3nWJQZOeCqpoUcXY+4hA2HYm63oQPigj9zucsPqyGiWM9D/pkkhNW6zpJS3s /ldqzn8RVcb1uFGUjgaxu7+R2Ip+P1P/JVKeuChK10O10Dh4VWFYMED5Ci3DXR3ddwrq qKuPQOM2rF2L6kKk6Zd4OpmEfByOCAaraQFy5YcqpElOF2Fee7KO1uNmQH7jtHsiuTbd R7JpX9Mc78vw71K1Ky5k7b8lLITTU2NfwjmX2C2cU3UwitXkOSUTYD3XvmKV0bsKNofM I0f6Vd6RuqVaoVt5z8Vk9EADWV8Zh8BNoIKOyhS/edTPrPyxij8lWPhN0S1y8Oeq0q4b lpZQ== 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=gEf1DxePwM+B9CFwwtM7eL8lXoHycHH4Piyf2mfnp6E=; b=uU3QyrMxZlmWC+ssAZp1IqlvqH7rpsXyWeJ7K6Jok9hiRK7c6jMEwHIptdMQ5BxKmu J5CCEt8Kf/MzCsuyWZ59eZoe2UMS8vhI2ReNZvatiLXy05zP3kdJPOTxxTd8ozr3R3sG 2u00qbEcjKTQZ7cZWEKcd1KGo8QZrOUCz8RZmjECNmOxZl8YotPD1MpIcZJ7yZxuvs8L XTSNob9PzvmMp/JYvyfwqwEQBVCTC3QAjkZVE3/9HKCjOsWo2e5JMmZEMF6hBy31ilS3 ap3ma3nF3y0ZbWJtdhHJ5BuJyWAeBtXyZZSoa87W3Q0el76nAe3gxnh0sVUUoH1iY63V Fc3w== X-Gm-Message-State: ACrzQf3D/3IAWXMT4feaUWaZmGo5CBwm2yjoglEvu0KVb2XPn1Ib+Iwh buA5aC39HbMLOOrE6AHc65Z9imSJi5Q= X-Google-Smtp-Source: AMsMyM4CPfbFG5GtpOl2dILO6gcEOIl4WvWKXAqqNcIxkYzkpdV9rGJKZjBoQkvMBcEgdtEUwiflpQ== X-Received: by 2002:a17:90a:d14a:b0:203:7b4b:6010 with SMTP id t10-20020a17090ad14a00b002037b4b6010mr3968021pjw.237.1664276846773; Tue, 27 Sep 2022 04:07:26 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:26 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Markus Armbruster , Paolo Bonzini Subject: [PATCH v4 16/54] tests/qtest: qmp-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:54 +0800 Message-Id: <20220927110632.1973965-17-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 v4: - Replace the error reporting with g_assert_no_error() Changes in v3: - Split to a separate patch tests/qtest/qmp-test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index bf7304c7dc..d2070cb683 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -161,14 +161,15 @@ 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)) { - g_error("g_mkdtemp: %s", strerror(errno)); - } + GError *err = NULL; + tmpdir = g_dir_make_tmp("qmp-test-XXXXXX", &err); + g_assert_no_error(err); + fifo_name = g_strdup_printf("%s/fifo", tmpdir); if (mkfifo(fifo_name, 0666)) { g_error("mkfifo: %s", strerror(errno)); @@ -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 Tue Sep 27 11:05: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: 12990516 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 F3E9AC07E9D for ; Tue, 27 Sep 2022 12:17:31 +0000 (UTC) Received: from localhost ([::1]:46832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9Wl-000748-3H for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:17:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8R5-0002nW-2r for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:40598) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8R2-0004wX-JE for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:34 -0400 Received: by mail-pg1-x52d.google.com with SMTP id s26so9088999pgv.7 for ; Tue, 27 Sep 2022 04:07: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=KL0tmfhCE3HA3lSFZSJgEQPnxsfYzSYvk8Q1ksHvTms=; b=ZZ6FnPa28AgcOrns5HF9Gw7Wj6GyYQsPrv43+Rq9aEWMrfSh7829FbtbuMVrPq2vIV yPLvtHRpAi/U9xxWm1nEJxL8hRv8FrA6QKm+b8MFMqCaJmGdsCC5owEq8AIbdaCi39Km JxCgBuznOu9HU5rhmhlpWGGLa+0eTAF3+XidXg/qEKCGbJeFNL5nmJxLKM3L9cLZcDLZ kNWBtay6hqRJdQbkZQY4QN4z3vJNnl/d6fTEwXYt9bhm3SbYB0qj7qy9mQA3HI/bHRMB TcHrBDPhG4bILEZHzpWTjEbQK45LcxRBVhkEUf2XtRlFmVmfGZwRN6Sx7nONCJyklr2K zEhg== 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=KL0tmfhCE3HA3lSFZSJgEQPnxsfYzSYvk8Q1ksHvTms=; b=mP1CPP6/IQFipe8W/p03oN+aZntgH8ye0NtPoYx4fZ5YNJCYcMbg2p8sYt3J+b7+zP vlD2CUDtDQX/8lQ496IUar12IEbZ0a4uCWqpQccZK6r3WG3n4i1v30df080sBo9kZNXj EtVj/H+rxHv7XlCh1/VVJMbzsPpaAPEURfk4roJ+h42h9Se8nVn3Cn5uBRKUcE+416VO EbW1YbtssQDZV3rpkYVAqxIGiuATvfeRlf3XxL+cyiU5eJD7yWJ8z+16Xm1BGiDCvLdL Po4wevxXE8uoQz3/ral4EcOfjBWlEPR/PLJ2d1cKC/47Jtb0sXDzEBZyGtjg6r0dPdRq INuQ== X-Gm-Message-State: ACrzQf0ox+vzMN9mVY2AJd+JNgSmyQhen2CPkTeI9ZmQSAUHACMJnWo9 yoXu2V0EJL9oiDUoTEQ1Z0HChBbba/k= X-Google-Smtp-Source: AMsMyM6OUiNtQz0yy+AYc9celMNPzVkleT+aZojsrRK6HpdRrwWGAq0d+b9d8ce/S2V/7hLp8Qi61g== X-Received: by 2002:a05:6a00:17a1:b0:542:be09:7b23 with SMTP id s33-20020a056a0017a100b00542be097b23mr28794978pfg.12.1664276849459; Tue, 27 Sep 2022 04:07:29 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:29 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Coiby Xu , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 17/54] tests/qtest: vhost-user-blk-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:55 +0800 Message-Id: <20220927110632.1973965-18-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12990508 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 70969C54EE9 for ; Tue, 27 Sep 2022 12:09:50 +0000 (UTC) Received: from localhost ([::1]:36828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9PI-00009R-3w for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:09:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8R5-0002nX-CY for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:46 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:43863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8R3-0004wc-0y for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:34 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d82so9340206pfd.10 for ; Tue, 27 Sep 2022 04:07:32 -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=Xbly5vz1qBo8k8w0L8MD2gVaN8gjFWYNLEXBptBTNhI=; b=jKjJ/RrFL1NVdKxXfJGGhE18ZjkURJH9m+nRENCzAo9ZXDrbfWOyW1aI6gzhTSL/JO aPmIKbuLHj9baWKsgEfNQBWT9mnIeizOmGaH2ZZTWv7dn12zu/niM+PFGUPxvSwr/KZ4 omIJCECuRKjTa8Xwps9P1jYmp4k2SSHnvjJgarHIRBxiJBjJh/Ir5Qcgk4cV0OqC26S/ gP1JMUrWHNF5PqU70H8tuUOR1TXQSf+AeSFS47tB++JJFTR0idZybmr89BBhO4b09utP CgnILMF9iQhufDan3dxpEMMlE0G0xHRoM1WvUyWi7rILRKiLb0B56nSIG6nkZlwaMO35 DK9A== 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=Xbly5vz1qBo8k8w0L8MD2gVaN8gjFWYNLEXBptBTNhI=; b=werJuibQ+l656XMWE5z3Zmw1gMwmOOfibSvlDrWf7FQQUdQ58FnbihF8w2P/vyxeD+ wm+Vm1BPYICrCFIYd+mkuzOtnQA3+ncC0HSiwZmYHfbVvcBon8a6gfsnR6ViQ9wlTJyo TxEZmQgIk7sF+Xv+gkXkMmaFPflRmYUJUTIvvI2renDHemVCkk5U8/ydV6CsE4WnoE+h zDzVtJk5w8QhKSMyJDKprJlJCC+CxXitg1MUCZ0V2+sz58vIz1WGo6+saXCUKI1S4uTS Jhb31Qx0Boypmn3KG4mIEjgCpjYbZBlx9/sPpN6dZvnXtuexZLMQLDfLBYJSS0eygj8J lp3g== X-Gm-Message-State: ACrzQf1V2NRXO+IeT22//vZ0q83bJbaULWWJqW85N+twBVJbmk6z/o0K LQhMaoRynZ728k3bynv2k99ojFj+yeI= X-Google-Smtp-Source: AMsMyM5mkc57t6bfYzUwVnXsdR82295TNCYDc6622bMq9vpSsusldQe3BAA6WOLYGpwFqhaf3sjNEw== X-Received: by 2002:a05:6a02:43:b0:43c:dbdc:192d with SMTP id az3-20020a056a02004300b0043cdbdc192dmr5022284pgb.449.1664276851735; Tue, 27 Sep 2022 04:07:31 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:31 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 18/54] tests/qtest: vhost-user-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:56 +0800 Message-Id: <20220927110632.1973965-19-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42c.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 v4: - Update error reporting Changes in v3: - Split to a separate patch - Ensure g_autofree variable is initialized tests/qtest/vhost-user-test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d7d6cfc9bd..84498941a6 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -482,8 +482,8 @@ 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; + GError *err = NULL; server->context = g_main_context_new(); server->loop = g_main_loop_new(server->context, FALSE); @@ -491,9 +491,11 @@ 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", &err); 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, + err->message); + g_error_free(err); } g_assert(tmpfs); From patchwork Tue Sep 27 11:05: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: 12990539 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 44430C54EE9 for ; Tue, 27 Sep 2022 12:29:13 +0000 (UTC) Received: from localhost ([::1]:35242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9i4-0001XU-C0 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:29:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RF-0002o0-E1; Tue, 27 Sep 2022 07:07:49 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:45896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8R6-0004xF-S9; Tue, 27 Sep 2022 07:07:40 -0400 Received: by mail-pg1-x535.google.com with SMTP id r62so5261456pgr.12; Tue, 27 Sep 2022 04:07: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=XHDxWl0yKYCxicgHp9QKyyYngaBXpOqvJcPgeDq+rGo=; b=dTghabO161ejNoITJDu0eYJVX4jRVEqP5MM+LlI6NTUD0U319y/i4LLjFrLvksiHC5 Qqtd2liaZS+QnxfAQlHwtENr2bXSD2n+vaLYvOuBYEJ9trBMUDdVHG/r1VpdktYQhnwb LzOBbnitHsnPZtDhj06iUHVH3oTiK8tPtyeWa5ibp0TNlfVFodfq+VaBNznuXkJLD//7 9AqZzZxNOROF4ypnkNTvjfJwFXGxxUOZ4nUrzNuFso5MPwkv3UjfMBswdCMoJI2jjiLr UEU6YSgFxJ8pRlF/YxQqaehzvA4N1wXID83tQ8VNAONnx8gaanhkobU8Dgu4qEQ6wb+v Z4aw== 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=XHDxWl0yKYCxicgHp9QKyyYngaBXpOqvJcPgeDq+rGo=; b=6Iba0pKMy+nzNc2wYn54CfQRUEiKVesO86VnVPNjgyy9emJVYWYs4mo7tZoVm8BpSN dk3ev8+klnHetOvlfpQ8icfR4EzNUWvBP/e2uuzc8T68fKkdcbpa1tQI7Vf4J/Sa5AI8 iRLz0bynpZl0zQNKShzCVth70AsDAUbz0/71vPbNJ9AvpRjll6yKjaSwsSCfbyrOdj7n keaiSiN1pPWFpnHCT085SnGkuWNvTKBjDzLyIU5YnH+igvQWOlpC/npWfKr0ANAvV96w bK2E4LMlvj0WfCX5+6YhsSwXzgh3oJgMWdN5DIjWt7AEdCiTtZYxS4f6Ff7nB8Mmp4Od o7rQ== X-Gm-Message-State: ACrzQf0KLqVQZ/G812Pnld0IyHINGUo6IAEERMpeuS4xtvXrMEkuOOid +y/PRmazX53LTXmDSb6UIP9WlcFgfAg= X-Google-Smtp-Source: AMsMyM7K4Vy0QfPzypkgervWWh/t8VHVFkyzUZfNMT0O5f2Rl0BnXCZCwRbmmzD9QdcgrezrtR5lrQ== X-Received: by 2002:a63:cc4a:0:b0:439:1c48:2fed with SMTP id q10-20020a63cc4a000000b004391c482fedmr24724465pgi.618.1664276854411; Tue, 27 Sep 2022 04:07:34 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:34 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Stefan Hajnoczi , qemu-block@nongnu.org Subject: [PATCH v4 19/54] tests/qtest: virtio-blk-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:57 +0800 Message-Id: <20220927110632.1973965-20-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990538 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 6AC8EC07E9D for ; Tue, 27 Sep 2022 12:26:30 +0000 (UTC) Received: from localhost ([::1]:42830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9fQ-0005KS-Gi for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:26:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RE-0002nx-F6 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:49 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:41644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8R8-0004xW-FL for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:40 -0400 Received: by mail-pf1-x433.google.com with SMTP id l65so9351812pfl.8 for ; Tue, 27 Sep 2022 04:07: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=przXEUDiAX5x8qS3XNpIZJNc/LF/yJyXGJFV6SOntqw=; b=mGkMCRJU4PY2Hmpw7BaNmMzh1W1bvUDhl+22Iuc7jKsC8OJkgvRkiDDCSg+SK5wmvt ejRcCrYAvd6llRXdB0+PlLHuD1gEKrYsT1r562zg4TKbvXwiM52t+0x0kM8H1Wcp0uzJ 3XI4T9d8GEtHrR8jIp4SXDU1BZT9SKA60QVHFOy+siLoqld+Io0duOuGyf7byYJStaX3 4UcyKOHUotGjtYE/wkWyZ4CWDGdwbnk3c1LXgfZ7EVcnVnR1KSnTaJX06NR6sG3YNCTX 7/+3qGw07mmuMF8MlO7ajjwuiSfKyg9hNa9L/kPrgoAgHK2m0+eNw/EzqPGPKFd2rfmr 7I6Q== 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=przXEUDiAX5x8qS3XNpIZJNc/LF/yJyXGJFV6SOntqw=; b=WtezsTb4ZbJgP7+VFlptUtWnoEYsZkfCC1s37L572vKxS7BeoSuCXITJDqy8B3ozPK /8o0Kwwysr77HVdtmF6CqNMQD45HY/X1bzujDMjVzqzKfOiy4fdx0nTnF3gnZGaoPENR 8PuecXqg4AnGR5wM8dEyJGvb/ajNO2yOOkSYQaDAxjPEw0e3MOJrU+7l9uzRj3KSHoG8 RYumowrUteAg3PT7Pdr2a37mmVip55k/3FII8/BUNpROrm9Ju58N8C3cIW+v4nO4I0G2 +J21wDLY9V/0CS/kDPThcnlpvJps5fe0Jrjusaa0HNp9UFj+Sfpms0YHd3+GqV+bidcL W+Hg== X-Gm-Message-State: ACrzQf1JKN3Oe0ZzfkJwMa3iiLDUnUupZKLyED/U9QVN+lh1mu7YvLAX mqX/6eXqCqnccbvrOuiK5lEsd7JUSIw= X-Google-Smtp-Source: AMsMyM7gBHjJKlErDp41PKRa66GP0E8buhVVHzMVVOCOxPvg+YttIiielQ+NOoxNIFybj2edQcaxPA== X-Received: by 2002:a63:982:0:b0:43b:e67b:988c with SMTP id 124-20020a630982000000b0043be67b988cmr24408566pgj.35.1664276857046; Tue, 27 Sep 2022 04:07:37 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:36 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Fam Zheng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 20/54] tests/qtest: virtio-scsi-test: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:58 +0800 Message-Id: <20220927110632.1973965-21-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:05: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: 12990511 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 ADD3CC54EE9 for ; Tue, 27 Sep 2022 12:14:08 +0000 (UTC) Received: from localhost ([::1]:54870 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od8yX-0000UN-4g for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:42:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51568) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RH-0002oK-JN for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:49 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:42818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RE-0004yA-4t for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:47 -0400 Received: by mail-pl1-x632.google.com with SMTP id v1so8742437plo.9 for ; Tue, 27 Sep 2022 04:07:40 -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=pltk4hzB+ifyBuv3+h8PEwxuQX6c0kjc3n3kVoOS+a8=; b=MSJVCCPyFVceRXM2DdX7ECdodI2htDxNU97xdL0n2luqXVEmZsjcVh7GEVptFvq3cX rDz70LATjmuk7tWFtGHXMkS5Vf4mNyKFZobJVoZr4S8KnxU0r8sPLc3LqsBBYwrcPj/p 4Xq1LRma8gcp7AyZcY8PgjpQ13i9c6GakFw3cOdApgm3krhnHyNhbuvQ641KCTr60Gon kwSyBqfyZiFG1h44ucGVbK/ia1uIaeIjUSLVLhMdUgRjzJibdxbFzlcQXts39dWzILqO zqTI/xvv3QZTksuwBg8GBj/j10jWfpvuLdA/SFxXTji4fBUImtPOfPv4qrvlKMx1p2KN FEBg== 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=pltk4hzB+ifyBuv3+h8PEwxuQX6c0kjc3n3kVoOS+a8=; b=5TaI3GJfS2DgRgEdCwIASEBrz229zczs8KWFfoS/avgs6UeVvDCQxrYBdHkvhzfcC9 r7ZAFHx/ZIn/AyOBjGHLeEoYor6zd3Oh5Bf8Lo0bhrp9QbzN+hhmWKB2dZvte+2/Ki9M Xkb2wwXIXAGEQ0XzcMDsPizRJjGg7gb+TyoY72ITFyV/0CxRElCgyk3wCVifLzBiQuju FWppJWRJUE5wzbFil4L1WBfSrvwL/ZvVeSnYnJ6nC2TvPyuaZHwo85UBylM33SL8UW2o 8ZccnAmMl0B7yuaIDG+oVGPpoWmV/1yef9Jo/nATE9V3MAC9V8zHnJ/4fW26Uqe27fmP RcXw== X-Gm-Message-State: ACrzQf1WC8vpQzCkxNs8P+9ifJd5eBTqi+q14xCXEi9jksQrkrnePoYz YqQc9tJxAzpEco7uOQOk0de/64utFLU= X-Google-Smtp-Source: AMsMyM4yUUSFnqwmtcEnWaYEwi0dhTgmUFa2l78gKMYzI4iWzOIzCDk7xvUqdKqFyf6lCjRRzlk8Cg== X-Received: by 2002:a17:90b:1650:b0:205:65db:d6eb with SMTP id il16-20020a17090b165000b0020565dbd6ebmr4037056pjb.246.1664276859357; Tue, 27 Sep 2022 04:07:39 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:39 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 21/54] tests/qtest: libqtest: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:05:59 +0800 Message-Id: <20220927110632.1973965-22-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x632.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 --- (no changes since v3) 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 Tue Sep 27 11:06: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: 12990497 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 5D819C07E9D for ; Tue, 27 Sep 2022 11:48:40 +0000 (UTC) Received: from localhost ([::1]:56368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od94p-0006s1-B1 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:48:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RG-0002oF-Am for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:49 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:41727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RE-0004yI-6D for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:46 -0400 Received: by mail-pl1-x632.google.com with SMTP id d11so8751372pll.8 for ; Tue, 27 Sep 2022 04:07: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=2qELv4fD6lZQNjqoSLTskKNLUucRsODzyqWeHTRxa0M=; b=pII52T+HV6pn8oWQbmQqlwecGHtVKcXojRBG7lPjQdUbIZcVNxkl/rZpvHoxDTExJE nPugh4OxVkFLfusjzyHLt1zwKh3pvVOyo2RICjNuKwtADeDubJV4b2QogAQNsbd1MI32 me+Ex6ukCaamIKMmeinpe7km2LQ3/OCXG3u8ppc8a3gCAwFLUxgI0Z78EA/OpngD4PJH 3Z30HQCF0zPteODiKLPWZcmMQKjBMiBsf0mib4w2e2WIJlzbpVsyUD233k15HsBCu1K8 9jqJJPYa4KYs/rhWakTlZGVZWXoU3M7ZJhWhPWSZIOj27Ee2CoE8HnFLJ5zRGfVCGvY2 rsYA== 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=2qELv4fD6lZQNjqoSLTskKNLUucRsODzyqWeHTRxa0M=; b=2/NPEfWFy+YZkbFrjNiCsdQ/1UKleBcamYD3/3AwJs2Hrpym65IAutXm4ND9GlwtT9 /2xtePCWJs3V5gH18XLwC+SwSGF8dlqrXoV0yiBhcBHOOb33pdc41HxRAwybRIdF5Z65 FLX/9wKOUp8XWvEJJ8r2tojh0H1Gks6zAuzbFXTx6Z+oOP3pWIU6pjFp/box5QFJQqCG iyJjO4uIv/lEVpApnRMVCdFYJS6KLUldaPgca/DyBSwmrlboa0Bh9HdAMiRL2AsU211T EOjY3jFzZOQs/C77rGLW4r7vUGuTVxW8QYcNDHubRPil7elt0nihJ02lPxbOtmxx1su7 mbXg== X-Gm-Message-State: ACrzQf28NtBwCvZDmx8MPuOwwuRIFgU511znwjNc3ixRFcVB7/iy/rLm DOwQoYGrooAGbh5Vva7PMYlPQrZkS3Y= X-Google-Smtp-Source: AMsMyM4ZzmG+HCWrpPUJg5Xpwg7enR4USz8X8wcPhrP1QbrUdtS7s518MvprAno+okthntWLsV4Vsg== X-Received: by 2002:a17:903:245:b0:178:e0ba:e507 with SMTP id j5-20020a170903024500b00178e0bae507mr27653326plh.115.1664276861275; Tue, 27 Sep 2022 04:07:41 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:40 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng Subject: [PATCH v4 22/54] tests/unit: test-image-locking: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:06:00 +0800 Message-Id: <20220927110632.1973965-23-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x632.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 --- (no changes since v3) 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 Tue Sep 27 11:06: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: 12990531 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 846ADC6FA8E for ; Tue, 27 Sep 2022 12:25:26 +0000 (UTC) Received: from localhost ([::1]:46028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9eP-0003X1-LJ for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:25:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RH-0002oP-Og for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:49 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:34550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RF-0004yX-Kx for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:47 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 3so9116298pga.1 for ; Tue, 27 Sep 2022 04:07: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=ccV/jKKm3KL7GmROMpxXjxD/bkKBeUCSA+/tqyLCpI8=; b=KmGLikRmXmQ8Jm1bS7QSFADrmzLH0dhx/sTlCxgign2lBTnzFmTFPu4L5xaP6sWSTm 0Yz28CG4vUQr/fP1LranX3Lzy+ZJnpi1lYTCIe/6qU/00pzR2f0adG6E+0ZlvPVE5mAO cMjuwWIsaft6kjmRR7NEhnD7spr4lR8bto7r2qW8aN53FuH++AtFC8MFYYXEH9nURWDk BxMtUp4C4T5HgFbojeWL6J5rQLMlP2yMxwTgEGrZsDFb1RA0zEdE7EhvZpzIHiS4fcAv N7Uvn40otCj0YbOCssGdrsd4sH6gO4PtrG/U9hUkqtkhyhsABww8Dg7XdhqqOyCqhDnX C+yw== 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=ccV/jKKm3KL7GmROMpxXjxD/bkKBeUCSA+/tqyLCpI8=; b=GYKog9Yto6FRRgx8k0pjiFQEhT3sFjFDUHqnrTQ9Qxp1u4WGOkwvl+jzAGFvBdVIzi bdahoaxAnvMgabUy/qm95vAJLjNSTVkBEb0AmgaOSPlMmdYYYuc8+c7gcREJL8MO64iS IKqi64O9E5IjTau+x327u7Esio9wxFFQ5+JAdqvynRiD8U1sJ+3R7/DBopEO/HvFopcv 6UyaSWZN6Da1gaq5hdMaOuLq/uoh6bmXXsdIi/jWdFqbqmUB/7r407s3YDFWmLonoSZa VFK1sdJUtiOX8YxlkXqtpJmHBF4+FeB490ERFArQiat/DxqL04gEsSIJnlXxMtaAnV8T 0QKw== X-Gm-Message-State: ACrzQf3SeiG9dBZ92ChhEfCE7RZCTbdexgbh8fHwy0Jhlz4p3Ce7gKeQ zQg4MQje5TIqQe6g6zNA2GtRqGbneXM= X-Google-Smtp-Source: AMsMyM4PM62FEe57vDgkazJnBBGRc3hrfWLNFCUHHSVrBr9rCWmgQG2bR/JmuxDonpgPFQ2Nl6Ycjg== X-Received: by 2002:a05:6a02:28b:b0:439:19d6:fad5 with SMTP id bk11-20020a056a02028b00b0043919d6fad5mr24827883pgb.591.1664276863651; Tue, 27 Sep 2022 04:07:43 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:43 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Konstantin Kostiuk , Michael Roth Subject: [PATCH v4 23/54] tests/unit: test-qga: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:06:01 +0800 Message-Id: <20220927110632.1973965-24-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52e; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52e.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 --- (no changes since v3) 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 Tue Sep 27 11:06: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: 12990567 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 7984BC07E9D for ; Tue, 27 Sep 2022 13:14:53 +0000 (UTC) Received: from localhost ([::1]:33364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9Ff-0004wv-RR for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:59:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RJ-0002oZ-1V for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:49 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:37756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RH-0004zA-CP for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:48 -0400 Received: by mail-pj1-x1029.google.com with SMTP id u59-20020a17090a51c100b00205d3c44162so2052580pjh.2 for ; Tue, 27 Sep 2022 04:07: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=N7WNzpDqLE7H3OMBl2IZFeUkBGLBP/FjFmhaXv6SnaY=; b=VgZb5BMs6QduI7bfgVrlZaf+OHqFgrhen5cE35VU5nJTMvj2FkPY13iL7CbsrA31xN PI4ePsyIxJKEgYlycVy1EziJXeZH9lMXPeXk3bPYG+gj8DHNFUVY+7DmSSRTwEZphJaw zO8wikCfiv0kxFzP+k+G9wOhOwm+A2SwyNLbc66m1ea7v7l/f3BF9acXqjJP4qfnFiWB Knz3m2FDxq2h4VngLPVJo6WdICZMeo/WuGgo2UZjd2K00mytN9tGFSVwFsbuta2SeHn8 3t2ZP3MyzV0Xun1Mv7geXA9/lX6DTXyXM8SS8Z31C6rxdL6nRYw28bh8A3oqQrlmpbXv J39w== 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=N7WNzpDqLE7H3OMBl2IZFeUkBGLBP/FjFmhaXv6SnaY=; b=Tmbj9Ws4pTMp7oQDhN1xFSNAKoHg5VSwZm2J1g8ywx7Tl2sON3ezeff3R+uv4nNobp tE8GjHxPyfL5cqe6m358UV0u58D7L1d+KKar+45K/TQiARx0Ic5iUFylUtwTcXzQlmr0 GHbzQWzs3vALrRTSWsWc4U6JDrYgmkL6ngK7KHxP8fOZ86wka1oxEksJFySh3jROtJDU shiQ+GH07Dkep7C/oDqDdLWinrd9rZnmDCi4TfyYctlcPrA0UQJ68Ci4ngMpzefbgkoA HhCTB1Keye9IONSq+kbZ/fdIcssY6eZ6A51msLCi9S2RhsQoui6xaEPX6HY881MKDb1p K2LA== X-Gm-Message-State: ACrzQf1VunWXsropjgPsOMc6zAnlqTEiaknID/L86C62oaNAIiYgkd3U n3bpz8Fm+Jvgsk8nE8h5Qih4Hdl7uig= X-Google-Smtp-Source: AMsMyM7XRV8B85U/b9uNB6LhOi0ea59HbAcUNzk5rI4bgWtr8fU8XpBn8AKsBQ0g8o+62iF4HiOJqA== X-Received: by 2002:a17:902:e841:b0:177:82b6:e6f7 with SMTP id t1-20020a170902e84100b0017782b6e6f7mr27183281plg.66.1664276865857; Tue, 27 Sep 2022 04:07:45 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:45 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Paolo Bonzini Subject: [PATCH v4 24/54] tests: vhost-user-bridge: Avoid using hardcoded /tmp Date: Tue, 27 Sep 2022 19:06:02 +0800 Message-Id: <20220927110632.1973965-25-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1029.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 --- (no changes since v3) 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 Tue Sep 27 11:06: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: 12990495 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 E26B1C54EE9 for ; Tue, 27 Sep 2022 11:43:46 +0000 (UTC) Received: from localhost ([::1]:43576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od905-00021F-S7 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:43:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RM-0002p9-8j; Tue, 27 Sep 2022 07:07:58 -0400 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:35578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RK-0004zz-Bw; Tue, 27 Sep 2022 07:07:51 -0400 Received: by mail-pj1-x102c.google.com with SMTP id q35-20020a17090a752600b002038d8a68fbso15270661pjk.0; Tue, 27 Sep 2022 04:07: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=mASgTbgC1fZZDNGRrUnVCNQGIWuAR0DCWfyrQC7EGTU=; b=UZM/j2lk1sGIINoePExJQWIgZdnFHZL2YFTUPXbY87EmUVwUdw/UBAPQp8HH+dbY1b pHg5Qz/vezWkhxAICUoGhQGlAyDea1ajkrVYRPaHKAuCYz6D8preYRi0l+EX3wCFlAyR TIzxVatDwOK7SmdVIxoSF7tNtrmYlTPCW3C9wNfPHuIyEEsUtc69HZZKDGZ+VOqnmSz0 KHt/qc7sopRe1riJCCmAkJKDXhxEuEmtiDrZOYDyYTQ1343rKwRKCVUWtjklMnu3gCt7 OWM5s1V22i3yqreBdpUzkn2Qkm2C35gWB4B93CGHldz9v8Srga4NM2yz6xE0kaLFHjOT 5W3w== 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=lolZCTaK0Ji8dIW6boVTB/IyOxOA6BM/SZpYGIY/Dg+gKuFI977OoENOc+R2W/+0K4 nPtNWfyKZpaXKVeknIvaHzCscAyRMjc0Z5ml2UBwa9OirBW3+/qHbHMmbS037Aybu/Ea AXZZpDgfO9UuhgIS11O70q5u1zUr/shMROY6V1z4XBBkDOJZsG1MwpSOOyj4Ej13L9/5 OPuZVGhY5rris+1svREY/YPDj0D6m1H6vSBeXSChdG44aTyKK7Vl1mBCIoFvaTHbdQBv yZ2Ac8bmn4Ob2mqqKNm6Ri7HoNOJfo3J/zriXdpGRQrqn4OikPBm+eT4GM/049PYx5zn TIHg== X-Gm-Message-State: ACrzQf2uBAdTpgAuMnAZhSznz/DruswFMpQVYmTpJeuXfpk3W48CRy4s XbfVL5Vlthd+1hPkDOP8N8WRzPnYhno= X-Google-Smtp-Source: AMsMyM5skg2pYPxSEADOlNkBBqcJ8Egrk8huHfPzMR4ocU7lP/0LNnRKldv9w0K6rzULoiojd7KxUg== X-Received: by 2002:a17:903:244b:b0:176:c8ee:a5ee with SMTP id l11-20020a170903244b00b00176c8eea5eemr26039812pls.46.1664276868491; Tue, 27 Sep 2022 04:07:48 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH v4 25/54] block/vvfat: Unify the mkdir() call Date: Tue, 27 Sep 2022 19:06:03 +0800 Message-Id: <20220927110632.1973965-26-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990498 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 3B8F2C6FA8E for ; Tue, 27 Sep 2022 11:49:53 +0000 (UTC) Received: from localhost ([::1]:46626 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od960-0008AC-82 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 07:49:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RO-0002pI-ER for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:00 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:45810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RM-00050q-Ps for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:54 -0400 Received: by mail-pj1-x102d.google.com with SMTP id l9-20020a17090a4d4900b00205e295400eso413360pjh.4 for ; Tue, 27 Sep 2022 04:07: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=gkhXgeI8VVKYUE8bIuW2cVwuIZ0uivwbyCoudHIFJ54=; b=aIL7psVDzTxyXdfGTHyLPIZdEZsdOJKrdrj/Qow4zL77qmUZdW9NEwOaOs6wQW32/M gYkbOf/5Bne0DcUfmqv9NkBsNThq0kRXI0Y4tvgZcW2Y1/dklFiZAu+wgXuSxC6KbrAs boI8eNX1+cE4RlFKJcPnr5+j95AZSNX1SNGzpuBVjBev8gjq/xpwwCmLkNh4NGS28P30 WmbHuUcL2HqobUtZ8LMCwCMJRN3Bds/2Yk4I7UQiXiqDtw2kWIFxKzdTDO7UYUOKUv1L H5r0cbtcpvKklu1USUK34YqIDsL6T+5U3ggveuT4lzSMRTcJOrCQNM0GIxvHN6zsE5x6 gyeA== 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=4T5PQefDnDBK+J1opyxjMxBqrvuUTMfhi0WQxab/EFKGs2V4pPHGxFM8G3XQRyqgQi VklhRIlaHty0NFvhTVmEgbu2G+mSZprDboZ1qSsq8a+2F6znwu/2DOvl3Sh87UioLXXi 6VmY5oTcXMvVc2FeCptbWRYp+F8Guo9TBaZkwlTIE2rPN9a4WEEx3Vpzf7etrSXPktg/ QrihmSnx4KUVvGoShmmQbDAb8t7i714jNU0sj7yd6KzpouXVKopMS5v8SvwWgyajqnQa p3AN669ErzoYRlbg0buuy+Qg+abujPYmJM5dp8JcWOPrtHjY0y4Pg7q++2LyB6gk/ZSX mTGw== X-Gm-Message-State: ACrzQf3Zczs+C4KxEwGCNGhYeft5H8iO85yRs/JfYpHQCPMVs4RYhG6Q GccjlCfWDWKtVWllUySt6c4Kxwr7/rY= X-Google-Smtp-Source: AMsMyM7jzJabzfNLbL2Z4gKunbSd+XQGC8xc4Tck2Q+joN1N7eHzICxOb/CelqSqXv+5hBzcsCC3Qg== X-Received: by 2002:a17:90a:2b0c:b0:203:b7b1:2ba2 with SMTP id x12-20020a17090a2b0c00b00203b7b12ba2mr3990073pjc.34.1664276871226; Tue, 27 Sep 2022 04:07:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:50 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Christian Schoenebeck , Greg Kurz Subject: [PATCH v4 26/54] fsdev/virtfs-proxy-helper: Use g_mkdir() Date: Tue, 27 Sep 2022 19:06:04 +0800 Message-Id: <20220927110632.1973965-27-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990512 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 A006AC6FA82 for ; Tue, 27 Sep 2022 12:14:25 +0000 (UTC) Received: from localhost ([::1]:50514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9Tk-0003pH-Pt for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:14:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RQ-0002qZ-UX for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:00 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:41644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RO-0004xW-Cn for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:55 -0400 Received: by mail-pf1-x433.google.com with SMTP id l65so9352340pfl.8 for ; Tue, 27 Sep 2022 04:07:54 -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=ZH2vmD1Wf5G3PqqtZJ2ie7tTclMP8rHBkHWGAV1ZIlIpzobWKcktUQAH0F6EXI4asP FKplnaqBFk3Q2ZN6pkcTDmUpVcjnY3B4AO6TAFhIc5EY32ThRZmDxja9laZeJ2l2Ocst A3DRK68DqBkFx0SWrBICHlcuusTIDS6J+mUJrR7W7WeWJVehC92GeJ51IZI4fmqRHpzW cuKbv+EoCzQ6/mQtFnHKVFeSTI6Y/+IbYxWjLRuRqIRwfrF1xIcwREe+BMu66HjlNUrb OXZJQeyYd9nqsNoF/BCNuyR9S3t8kA30HMBNSwtS9Lt8l1TXi/vYSPU+OtTDbwCsGwzl 7u6Q== 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=msfvwBd+eXA/2P1oMqJUiLtIafetdkrPVkA3p5G4ykXWkkBiedgbEzak8B8GUq69rr YV4MIS9FsI8wiJVJ4tKeQb1cuGJmwEBugITDmDkDcboWa3i/4j3heqV8cVkx/vz8gE9g OOUBCSSRRdAPtXreGJllQ5C8FjyUtenQjtnI0N1lrvAfmjpTLStKBVUpaQuwJMGlVlSD OqHvln0tAFziHuXwJx809tWhX+6C8bBaknuBSlbFnKxjYK4rP9aW39XWjO/1rPRkA6DA sc9Nj/0lMa74HATFx1WjDx0y8pumYcxGIgUiLvdGMBkVkLPghwI1CAQ6tZp6U3kCoewg YQkg== X-Gm-Message-State: ACrzQf0MvXzlHluuh5DFcs32iMExOlHr2smKUzQiI+U1A2/apgsJ3noy p2N8zC0Od9eJYByXd38dKqjHOZk2njc= X-Google-Smtp-Source: AMsMyM7ootSD71GeBb73+8dniz07/PXoyp5mjwIXqXPFnCBD01r9EH6VF2eDPeoAPsLOdv/XsK7OGw== X-Received: by 2002:a05:6a00:1d82:b0:541:1ea2:e7e with SMTP id z2-20020a056a001d8200b005411ea20e7emr28909637pfw.71.1664276873457; Tue, 27 Sep 2022 04:07:53 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:53 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Gerd Hoffmann Subject: [PATCH v4 27/54] hw/usb: dev-mtp: Use g_mkdir() Date: Tue, 27 Sep 2022 19:06:05 +0800 Message-Id: <20220927110632.1973965-28-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990540 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 1615AC6FA82 for ; Tue, 27 Sep 2022 12:30:50 +0000 (UTC) Received: from localhost ([::1]:53836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9jd-00040n-Sb for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:30:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34730) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RT-0002ri-9f for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:00 -0400 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]:36600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RR-00051Q-LO for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:07:59 -0400 Received: by mail-pg1-x535.google.com with SMTP id s206so9108794pgs.3 for ; Tue, 27 Sep 2022 04:07: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=SZXLVRmmnhtpF37sbXWA0CFlA2zznYKmR2V+rAyp5Mc=; b=EtDxCs+YapOObKwqMS1MBUW4qZb/JqqfPIMmZl3wnyI/9vUS3ey1loyvEObS8iAlLo gw2hd1v71uP48sEn/HD4pgHBS/7uavahEOk+pk62N/MpFyJJSmig6zj8cjYKKilv6K7u A6B/ctv73d7GyGsT7FhMly7cSCkG59hAoGG32yGPK0ThBHugIdIFrPbKx4WEhyh6NiTu WYpVxU89QEse9AXWbcdekogk/KXi3p1RmWeE3+D9fPsOhW9gMCumtMdsFUqI+lM0/hD6 caMTHbRUedVm+slle6pdSxn3sHQU2Zuc6yBzW2CdWfrwkC4O0/5PpsU7SJEucX7b4d5D XvLw== 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=xb8ukLs9w6B2OTbVAcER8150o56FaAuz0i18/UnBf5yLC6xk0fQ5yIYZYh6550Q+ec sRkXUfAotzKcFXBB/Ppl8wFd8zq/ZgDDoKLIHlRlDFkoCVlPyprGf3PwsG63VbrSGSA5 DRpzxkc4OXdQXANeSx7gq6BifV2SRL74kMpjDdmrdRirGWJvEBwOOCLWDetRwDvKQOBd LE1EXGDkbZqmkyIKYkTqBjAW2q3HVLOXtDfrXuJq1Pme05VjvcVeFGfo+WSHkaL+KyjG nLu1xqaP8A94Ca0iQOL61mBpA5k1T/HbqpWMuJlQYEKU0/oqE25gt16j1yaowDimQJWL NXMg== X-Gm-Message-State: ACrzQf16Kzagx4xT89UQgL0CkDA3BR2E/y3saxpEipqh56DtpsXFYrMt jXotCjIi6Sud02kSh6AARz5+Wb3PbZw= X-Google-Smtp-Source: AMsMyM6VpIthGnf60bTjTLaWIytQeBrurWklPUk320H4Zph4dJZODW0qgMNqdYCblhn9+Io1AXqR+w== X-Received: by 2002:a62:a512:0:b0:536:e2bd:e15e with SMTP id v18-20020a62a512000000b00536e2bde15emr29324870pfm.1.1664276876062; Tue, 27 Sep 2022 04:07:56 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:55 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Jason Wang , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 28/54] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32 Date: Tue, 27 Sep 2022 19:06:06 +0800 Message-Id: <20220927110632.1973965-29-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990550 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 AFDDFC07E9D for ; Tue, 27 Sep 2022 12:39:41 +0000 (UTC) Received: from localhost ([::1]:54066 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9sC-0004Gt-Nx for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:39:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34734) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RW-0002xl-Cd for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:02 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:43863) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RT-0004wc-Ky for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:02 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d82so9341129pfd.10 for ; Tue, 27 Sep 2022 04:07: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=bgoeJG+EitAc6steECPvwA+eqgU3ODIY2NLoSDcVQq4=; b=VwLlsuJAW4kiLIJ2F4USgAVVaEFk3w0prwvq02bqZl6n9fib29D9QcuRJe94RBABnj DD1KPKSVzZqUVy70uMKrqzqgpRlAs6lcArol1rJtDZ3WHOXiDR0+9B/iuvh/51c1D5oN 4/x7fam6mkBkEqP2WzE1DLBcbIUVQKqSrG/BxCmnllQIdsemcus8UK1NmIAD7h6fQYps 5VNj+vmADdKecMpIDULVnbU55gjWymukQA4QHtedqd2O7ID57JB7yDuZ7TBx0P2nfXLU E9ovrwBj5WkSDCbmx0sQLiEsOrbURFfgHJMVkfR9gaHma/BDFOQtVBN9NXrLRIVoUK6D seqw== 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=DHH6q91xYFcrHflYsR5KEng5uE3EH1X+f9XcVvGvI5RrZEokV7/1E+dEXlhhNRGSzF DTDpoJNzT4vLRB0HAJJs93pVMSRPjJJ2t6muDXD2L2kM8Re9w1uPpOEXEde3FvFL33rd n6B7KcE+GIR7g5qreAigEWYvevY5Nju2Hhml9x0PWW7w/ztihcxSq5CFb69uv1+FO55/ befXXFrRHNT7IoUrwhsf5hzhWUkXVYJ43GLhlHAAhhm1jAVGEh58e+tOY0WQXJWQ1pOX I48T21etJ3YOBdUubSM4Fn7SRV9Katsg6B2zktjCHWOW1XO2RzOYojN0Zj+6NkrHO+LS DHAA== X-Gm-Message-State: ACrzQf05k8OXDD84GI8LonWD0AZ2GBtKAjvtF/vj8TY905DOED4dkTNB RtfE4YQCKC+R2gmF3uu13OA/giBGQWc= X-Google-Smtp-Source: AMsMyM6HAh79pCHR8+cpzDLacK6of6dNQCibMmmrUV3Vlo1Uwwu+M0hj7N7MOhM5/HGVvS4M4wWx9g== X-Received: by 2002:a62:4e4c:0:b0:53e:22b6:6869 with SMTP id c73-20020a624e4c000000b0053e22b66869mr28253643pfb.29.1664276878526; Tue, 27 Sep 2022 04:07:58 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:07:58 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 29/54] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only Date: Tue, 27 Sep 2022 19:06:07 +0800 Message-Id: <20220927110632.1973965-30-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42c.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 Tue Sep 27 11:06: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: 12990554 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 3652AC07E9D for ; Tue, 27 Sep 2022 12:43:05 +0000 (UTC) Received: from localhost ([::1]:44822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9vU-00021B-85 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:43:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8RY-000320-4l for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:04 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:45810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8RW-00050q-Ba for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:03 -0400 Received: by mail-pj1-x102d.google.com with SMTP id l9-20020a17090a4d4900b00205e295400eso413727pjh.4 for ; Tue, 27 Sep 2022 04:08: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=73Bh6gjqapgnX8a4D+ItufmvDUF4gENdWKOZ0zcuwjU=; b=TYUJaMUFGOWvSZnl8vzXr5OVIF81ks6D0N5GexrbpJJg2IiWjsTqgotBkcxAX7sSU4 I21bIhVXnZs6bIjOYVYQz8YFgGbQsgRdt7l+liulAOiWyn/7CRbQT9Kk0C/FaUylq5Ms Y5mCk80Krhn2j/0RCdiFMj9CSdkwdd2WlFXEEnVwivStC+NjheBhtKzr9H/7HL1sDia1 I+5YuVhwsS/mOPxTQ5286Uc8PeRityT/lsO75P/JRKr/Rtlj5N58NPecsXfofavCt72c ikV2q7lM4PGciKSo3STj/Up3g84CLPOKrT0Bm8cLoIrDo7IW0/YsBY1dgTifIymE6yBB yoRw== 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=73Bh6gjqapgnX8a4D+ItufmvDUF4gENdWKOZ0zcuwjU=; b=y4ODOyYGV+GGzMgiLLPQ6I7CfdyBFNZ/6aY+ysmretGwMzp3UuLLwXSaJQNZkALg9f +aKhblK+cdOOjDKJgGrBzkOx1TEoFmoH8DxySUVHNRmS4FD6o6cHDRcp0kbatZ9IPtdO RJ8Xy3HyossLjVjr+lyRasBLq0aMwjyd0JGQChY10KvHUG+kQF7f93uEB1ij7bZq7VEn kFzT2KdBVkeu0JpRdWqqnhEAXGFHdDZM2QBhAFb8IQmYuV001xEGuNTNcfqRHYQd4YmP SUlxYZ0Ngzg/56zsmS3MgsvWVAyEm2u/5UN6ZJqGhFNGIcRBf4BNw+3DWpmTNc+iO6vx EFQg== X-Gm-Message-State: ACrzQf0x15ODuu4AbekuMM37DaHPoMDIHcQsrR0qm6Vh/XIf22jbeUi8 TnD4IKZ8W2FGJnH1RNjFNqtXgO9DSG8= X-Google-Smtp-Source: AMsMyM5yr62DLe8Kzv8Uvbur+50MZQxRuw1La7woQTfpz1VKC6OwlOOxLJjvC7HWSXCskMrF7KFX5A== X-Received: by 2002:a17:902:d58f:b0:179:b756:6f5e with SMTP id k15-20020a170902d58f00b00179b7566f5emr15372305plh.1.1664276881464; Tue, 27 Sep 2022 04:08:01 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:00 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Markus Armbruster , Paolo Bonzini Subject: [PATCH v4 30/54] tests/qtest: qmp-test: Skip running test_qmp_oob for win32 Date: Tue, 27 Sep 2022 19:06:08 +0800 Message-Id: <20220927110632.1973965-31-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 d2070cb683..22957fa49c 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 Tue Sep 27 11:06: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: 12990529 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 7347EC6FA83 for ; Tue, 27 Sep 2022 12:24:48 +0000 (UTC) Received: from localhost ([::1]:45922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9Jt-0006LE-OD for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:04:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Re-0003DA-09 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:13 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:35765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Ra-00057G-JI for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:09 -0400 Received: by mail-pf1-x42a.google.com with SMTP id i6so5185180pfb.2 for ; Tue, 27 Sep 2022 04:08: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=FodAt/+tlmeyr8mO0vp74otmvfdLkdpAkh8HSKQOwPY=; b=QGrNRpE8in4ec+vRl7yKsXY2h+i466qlHyDC0LRPE7vPjM7fOz3W1E8oey2/iQFBfl 1SW3vmNmDFuM9tg0QNyUtItV7pQCMI6y+f5pSTOyN5zyYaJ+2+g9XZ2JR6rSU5y0hpE0 c00Wy83wHg7VMlr8Tth4fYFAmxawYoNnZ58Fal4DM3Ry2PoOQ9qUT4AEyCdUeuKEzXdK bhyqsGqMUInSbtYCPZugxv5EqFusdViZuo56OJ4uLoBQJqIEpydu8cUqKN9gvR8XeiH9 A4OeQ0u5G4gJCdp6K9Vth5xasgYPX5nB4eG+0nwEHS+991u7egvg7cOrA3K8QEFUC/su bG6g== 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=A8TVgEIoUwxZQ+HSZQvB5eKHpxqy6R3rmE5BiwUVLaE/pwMBAwplJ49fCqAev/PAyo wP5CArBTQ7PMkh/KlZp7lDiI6erywLUX5IMG+YKFhO2MoOzclR4htBodsH10HJHdopQr UhOioTNzS2ZT7eQ2MzpZX1wPw0Pq/McW11D/Ja4vAckDaBgmy0yNCoHQ+5MKMPhc0IlG VGd4TsTNNTkYY/Fmya8uyE1Cdg4QHHcdbUeio1/RBr9ED/t3gNL70aVjeBwpDdspmhB1 bOfjoLGi+en8R+IIzcw5ratXdGZxA7Y22n2+2lDLId3Kc7jK4zAFw+j1K0CMmJ6j3TKO Yf0Q== X-Gm-Message-State: ACrzQf3I2EB4Tyh7gaqVoSi7pLlQE6icMZw4yA/hO5OVCGR8k9W/ayUr PRjMyC5/O/Z+Vboi4McMWAcofkR9c74= X-Google-Smtp-Source: AMsMyM4RSj59VU/nJaAYI021H8mL408buvNJpJlOICBuYL1A+q2tVsV/zuXHquA7D0bDVu1Hs4NQyg== X-Received: by 2002:a05:6a00:3492:b0:540:b30d:8396 with SMTP id cp18-20020a056a00349200b00540b30d8396mr28804282pfb.81.1664276885059; Tue, 27 Sep 2022 04:08:05 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:04 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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 , Yanan Wang Subject: [PATCH v4 31/54] accel/qtest: Implement a portable qtest accelerator Date: Tue, 27 Sep 2022 19:06:09 +0800 Message-Id: <20220927110632.1973965-32-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42a.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 Tue Sep 27 11:06: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: 12990533 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 76BB2C54EE9 for ; Tue, 27 Sep 2022 12:22:57 +0000 (UTC) Received: from localhost ([::1]:48392 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9bv-0002Ls-Ob for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:22:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rf-0003DM-HF for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:13 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:44902) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rd-00059Z-P7 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:11 -0400 Received: by mail-pj1-x102a.google.com with SMTP id i15-20020a17090a4b8f00b0020073b4ac27so9717420pjh.3 for ; Tue, 27 Sep 2022 04:08: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=ZkLkDHlVbQWyL6DGpwTKMEuFbbF5Rn0sqTRRhF8/m18=; b=H3lCe8Cm44UMbXJRWGVb0rugu3eJHn6MlBYMemKpdDWqhDExmHwb/KefP0fsvcsMRD NEHB1nAKq1JPtULj09biSAvmWLFRKrvJDSbcVCcO2X5EdiBAVBliOQ1D1s+QqXwy0x9V vUemA7XfI86BQEI27aWoqeEmU9AjAIk+GbBJJOS+M4umFcY8RViqD1GMadMXAFjuRUEU HpKA+QPeqM1YZSL2wAXaiynM5fW0GHAt56xyLOF39vhtVl/S1/tBxz5dSv6nTA2df/+u s0Y5p1mBFGxdNUbZngRL3tEw0iOLODr3NQ8sD1Jrz6SGgvxtnOqTA6WruJDJ5OF0FNJ1 n1Sg== 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=ZkLkDHlVbQWyL6DGpwTKMEuFbbF5Rn0sqTRRhF8/m18=; b=ffb6ZkjBZFtviWKqeinACGaquDcwhi+EMkv3415kkzO9DE3Hu7d7arAQgyd1yTF9gk D3x1FOGWrAnfGla4M8vgC1gxEsDYLvpUnnCRPKrnGneQCVSxNSYqFLBBcI94QQkciYpM QUzziiVBKhFJgGFt/ba/t3Nyfna3UNlYqb0Uuql+1ZWKeQ1SQdi2KcSQIjTLNsyIdTLf 1ueqZ9BjhPuBNUwmvv7RSZfNGPgQ5QMfFVMlC9EJ4FmdmVV1z2NI0HAhkKyAEggWsuW9 ZGX2AFm+jLgwhLXvlRiVyj040UjAv7DQ4lYpTanUbgYOLWm4rnKJvxj9NgIyzSvP572J KPGw== X-Gm-Message-State: ACrzQf1paMPznZI2jzSYZ77x1OYdl41HTIV7rxgYPMNbg4la8HJEWkTi zJHZWpOK4rReIfLgP7Ek2Z5s/ePLP3Q= X-Google-Smtp-Source: AMsMyM6bVZQl/1QsW5LPcnVpOk/vZxLgVLGrFeRnGliQTT2ym0gNw2ExTkBxb15FLDfbgTkgNbdvRg== X-Received: by 2002:a17:902:6bc8:b0:178:81db:c6d9 with SMTP id m8-20020a1709026bc800b0017881dbc6d9mr26969376plt.56.1664276887619; Tue, 27 Sep 2022 04:08:07 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:07 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 32/54] tests/qtest: libqtest: Adapt global_qtest declaration for win32 Date: Tue, 27 Sep 2022 19:06:10 +0800 Message-Id: <20220927110632.1973965-33-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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: 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 Tue Sep 27 11:06: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: 12990605 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 F2FB4C6FA82 for ; Tue, 27 Sep 2022 13:27:57 +0000 (UTC) Received: from localhost ([::1]:39920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9zn-0008MR-Oy for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:47:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rh-0003Da-0p for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:13 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:35765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rf-00057G-D3 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:12 -0400 Received: by mail-pf1-x42a.google.com with SMTP id i6so5185368pfb.2 for ; Tue, 27 Sep 2022 04:08: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=csOaISwTSwLoJpsFvuVDUfystuDYu8jpDcj/GRjEV6A=; b=pwPHZudPu6BqSuP6Sww9oSFRcGjjk+j3Kycx6gsTfesmgennkeObiG2pnnCE+LeAr7 iEYNZ0eCTV/F3Pos7sc6awbwsv0fCOmF6x+JhAlj06nSGGitYv0mGisu8bYFqK5/l1VR toVnXAR+tw9c/fZOXhGeGiGQ2fF3EHzCJ5rTYFxOR6EX9EQFINaYQqmo1njI6hoyx0Zs rM/p3Scrwt0wIZjXGJVt3Iu6AQSPct70aW2+jG/76xasFmuHIiWpqAdMJ6hXVZr6iigm 6KkJEgf7H4E0uc0Bm1G0I7vEKHNb1+JKFmwuJEZAMdb7puSslxz6sSFx4/YxBERtniVz NuhA== 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=6P3yvCmaTAksycdJETcnTYLmnTDWboxbTcQpYn2Rl+jGqcAFDP/WJHAWODsHHPRrMr eSXmtFtn3cmAGygovRHT0gCDgd9pzugy34spzdQuGZ3x+wg5UcenRNuDNn2PqmgPuuOI 4xz21Y6lz7nrc4i/oOwph2L+pBWP3b25qvrWVuNfmRPUWJWhzYvaYmE35mBpGrLJlBrR OZoMGhrVPq0nEdESt7bbN3XkwTOrMpSMmV87y4FXKE+6wMs66gCaUBLSOVEHNcftgvCk 1V95+n5dFqCsa65wu3Kga4DMm4oSmf/OuX68Z9EfJRGuC9GGFIzltzn1e86QwfDJVL2t KzEQ== X-Gm-Message-State: ACrzQf0PlHKpKQ3aqnK4Bf3WSdeI+9fV13vp9QmaJDxDYUBJvJmVuHt2 FixN7RTJqmOcNXXj+w/AK8VNoxr4ILs= X-Google-Smtp-Source: AMsMyM4xLHbiWKqrua/xJDd805+gcTDRGXnI0dqR01uzYe4Xe7pxirbCoNmSiwZFrPc+HuLf0F0hEw== X-Received: by 2002:a63:e044:0:b0:43b:ddc9:3885 with SMTP id n4-20020a63e044000000b0043bddc93885mr23876873pgj.325.1664276890457; Tue, 27 Sep 2022 04:08:10 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:10 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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 Subject: [PATCH v4 33/54] tests/qtest: Use send/recv for socket communication Date: Tue, 27 Sep 2022 19:06:11 +0800 Message-Id: <20220927110632.1973965-34-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x42a.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 Tue Sep 27 11:06: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: 12990513 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 C177BC54EE9 for ; Tue, 27 Sep 2022 12:16:33 +0000 (UTC) Received: from localhost ([::1]:51820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9Vo-0005HS-RO for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:16:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rj-0003GB-KO for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:17 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]:41727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rh-0004yI-RF for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:15 -0400 Received: by mail-pl1-x632.google.com with SMTP id d11so8752451pll.8 for ; Tue, 27 Sep 2022 04:08: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=p0xLVSd98uOEEzWCz4ddtwbkgDpwCzSvQCc4PqL/v9w=; b=ESHjlXU2uO5XaODWenJSbL+kCMMgJn12N1Qh7NWtLvb2FIA/2Mnmpez+s3wFhofUb4 uZt1SBAIwjHQu8q1/ktsxKxu+Jx0VUAdNwRhIXJJpDcP5cr1qDJsTbjM5awWyuwVbCYV hnGp1DUaTtLLRRpENkJTqzK9kRloBYylGhEVT/OdrD0Brnt1aaOlCGMHbCx7VMXPAcHo AN+lOaldi0wz6aMNdRDlLWYvi9gC0pIiVurzsJ+arwHnRUymsD18FgRXsr6Tx9Ap/aHc IzapIxENeixQSSf+oyWr5zmwQUEn18Hy9ZxxJ6TDkqrJf6Hzlyx0xZjpup25Wcni7P/1 Y3fQ== 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=u236bamEtYRUfm9Ddzy4Q/BXdX2265MIHnQqvZqWIlMGCj9Qsf98yOY03JSw4/05qZ F2T05AqQqA3VZaydl3H4r+58RLeOEyG5lzyyo8mdMYLiCZpizLhHsaPPFuW8DfCLPS3j JCZQayHFjPitnJj13MykdpA2x8gktFfGLZqdicQLr+DnIx5pmv1jTe7AAUHPHErS7hs4 y3rcVEtAcX7q9tFHdAHEWiDOiAkpaySwxBcf/3XrQhPh5DO/bHikICHmQs6je4xex40S b/V0QsgLeF49A5/RcLOKWUKJ/Jd0xNj1pvU+VkSbTdeqfKDTjXZoRfDJj6llI2Ie9EEv Abjw== X-Gm-Message-State: ACrzQf3r6cQEZzgLgX5k+9jG7Qau0IOPZ1yp5bZzmxcHDuX9kamUml0u T3PNFK0whyFFVA3EzBe8HnL6qEPw3Cw= X-Google-Smtp-Source: AMsMyM5aEBemkzCZhYUWYkXptUHD4sGygdmkDJUe221aV8X6HvjO22/yXKPxV3/X4eGv19FRDRXW8Q== X-Received: by 2002:a17:903:110f:b0:178:a07e:e643 with SMTP id n15-20020a170903110f00b00178a07ee643mr25845256plh.41.1664276892880; Tue, 27 Sep 2022 04:08:12 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:12 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 34/54] tests/qtest: libqtest: Exclude the *_fds APIs for win32 Date: Tue, 27 Sep 2022 19:06:12 +0800 Message-Id: <20220927110632.1973965-35-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x632.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 Tue Sep 27 11:06: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: 12990537 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 A2CB8C54EE9 for ; Tue, 27 Sep 2022 12:28:53 +0000 (UTC) Received: from localhost ([::1]:59924 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9hk-0000au-Og for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:28:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rl-0003Gi-QF for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:18 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:37756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rk-0004zA-5p for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:17 -0400 Received: by mail-pj1-x1029.google.com with SMTP id u59-20020a17090a51c100b00205d3c44162so2053729pjh.2 for ; Tue, 27 Sep 2022 04:08: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=csizl2w+78rIPzv75NHpVHqQ4bo3e7STiugOOCph1bA=; b=BOhw1/k+UId/b76hOMZjCDzF9RdMWRcMXMqxAduWaAHrY/PKjLtwYeerLFl1nhriY+ ju11ud3Vc6i/WPogaFMLSncAFi3dZnhbm565pvZkzlcAcj9z8k67PAyNBNgvA6jmBZor W8EeXwpAW7o0a3qC/TBztPYFV6tdy2oDzyg4d47Yx2X/Iwo3rDrAokP+BenZtfhaFLgq Jcj1HCBhf60B7n2xaAzJb36qVMGlvjSFcNBYm2JSGKEy/kyLQIjdRvcHveGqV/tO2qtB 1NgFyD+MayyKuo0F5kumECgWppvgd3EvYjHcox2wPirbYiHrRcj74QdoT+3kSWq/89BB ovJg== 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=csizl2w+78rIPzv75NHpVHqQ4bo3e7STiugOOCph1bA=; b=Z20GBlgx+nqpXhRqtqs1q51vmykIjJ8JyEAy0SuXC4OqCwznEa534TaCfeEa1I7Yvy Yi3Py8Vd/fWmEcvALygR0qx60l98xFweOZBdp0rbrxo/wfqoZEgbXznp044ojjMNcRUm /9t0NbS7EY20GMHSDJCJOmcbHLaSfBlpimY2UQzt2vR6Ng73zls7nlhW18PLxQUjp6TZ IbcMfKRB8QP0A+uFHjjbRtEHNOETzwmnndIOKL831FfN6s5F+wn85WCfe5Xu9o3TFd4q S5DQfthZZPW6aoWlvZF2cdvz7hx4syv+8nhIH7Dr3yNyCnyMbh3YD3Y2zC4wI59JySoq L+lQ== X-Gm-Message-State: ACrzQf3iHizVvsslA0Se2CNdb7pLhJME36rl3b6sOzIhhwhz2epwIeeg ZQAOqoN53t1FgQYIrOSSxc4Sw2lFX9k= X-Google-Smtp-Source: AMsMyM5TPhzuaDAaw83mtYTi2Qs2BQZodFGp+IAFQLlu3ObWU10q2YGVf5TKOj8x5Eyw+CNz+QFdbw== X-Received: by 2002:a17:90a:e7c5:b0:200:ab1a:f32 with SMTP id kb5-20020a17090ae7c500b00200ab1a0f32mr3922567pjb.100.1664276895256; Tue, 27 Sep 2022 04:08:15 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:14 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 35/54] tests/qtest: libqtest: Install signal handler via signal() Date: Tue, 27 Sep 2022 19:06:13 +0800 Message-Id: <20220927110632.1973965-36-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1029.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 Tue Sep 27 11:06: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: 12990530 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 1BFE8C6FA82 for ; Tue, 27 Sep 2022 12:25:19 +0000 (UTC) Received: from localhost ([::1]:48412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9eI-0003Iy-48 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:25:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rq-0003Hk-08 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:27 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:44641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Ro-0005Fu-0B for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:21 -0400 Received: by mail-pl1-x635.google.com with SMTP id w10so8745139pll.11 for ; Tue, 27 Sep 2022 04:08:19 -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=TQ6mPEyLG9/gBGLvDq02jxOOT7//XKsYQXpjtEHWDu/J80QlMyHji8c0EOznxBODZm 3mcLilVMufoKmApOamQWyiZKoS+ivSbyhJlB5yhk3Tk2Qpaoc8xPIaF4JPGzPhqgpy1W ez/OkFg+2XVKYHoMBno3Dh3xKEEGGE0kfVeW+i0Qy2GrnZpPy5iWQ/cLYLP1+1Ywxuqx 1uTjNWxIXmIIIt+fOE2hMAzyUibtRzIRXCR6RdzCGn/E/LO0iFShCegcnigqJGfdDGRG oNqQLGK2mZhtqQsqUtkQ6F2Xvdi6Un2FaZGmt2SuWAY9lCZDlCWYXyTVPYRrtdSd7Naf hC4A== 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=SkmgtSe5UOGd/tBNFIYnOnPwwX2o22MsV0hUI9vsnr9zxfbyfprabqJ0iFJAvW8TgB 92H9Lsv4yxippx2bpR1Yw3o321k+o52HZhR7oxZFO0TzVrl/gI/td0MFI/7mGqcneBfd q95VtKyzI5as+ckznWTil8IRDvjaUUqL5dZTDiQK7Zxk+qK0TQlRAeP6JGuC4x9o1YcK wBy8oSbRaOBMQM+kslY5cVz3taBxXvcfJRZ5/EwdfPx4G0DSny8PI2vpq+/EYnVKxVu1 M4QjyrBFDS5LnQms9fSg4V9v59oQFaawyi1gkHhl/rbtQ/gQRlrV6QriTC62a/2czXWI 4Gaw== X-Gm-Message-State: ACrzQf2ky6rGMeX7hhPS5NiieTz5O917+r8ilymFBgrDULPXiTuslwnk DP7YB9wdRCGr/pM1bOFl8NHdWVvfoZ0= X-Google-Smtp-Source: AMsMyM5FECRbgxkAUynipAfl15sP+JinHA2ckmrk8h2uBmG9gKJnIT/3dYHuCIfkDffw6j1CRRo1EQ== X-Received: by 2002:a17:90b:4d8e:b0:200:73b4:4da2 with SMTP id oj14-20020a17090b4d8e00b0020073b44da2mr4074607pjb.197.1664276897849; Tue, 27 Sep 2022 04:08:17 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:17 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Xuzhou Cheng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 36/54] tests/qtest: Support libqtest to build and run on Windows Date: Tue, 27 Sep 2022 19:06:14 +0800 Message-Id: <20220927110632.1973965-37-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990545 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 0B4C6C6FA82 for ; Tue, 27 Sep 2022 12:33:35 +0000 (UTC) Received: from localhost ([::1]:36496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9mI-0007em-1y for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:33:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rr-0003Hs-WA; Tue, 27 Sep 2022 07:08:27 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:35385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rq-0005G9-CD; Tue, 27 Sep 2022 07:08:23 -0400 Received: by mail-pl1-x635.google.com with SMTP id t3so8781945ply.2; Tue, 27 Sep 2022 04:08:21 -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=WQDx+cZ1kDn23arphhz0GuuPrk4Ga5SEGuDsuw5J2h4=; b=UXHtywOYYf7/ugDY4VALfR8gFQlMM3YBXgFy2c6G4FeXqHdSQgvOYuhuRq6nzQw5s9 U/eoifiKySWFDGhuTAXkMuYWrtKV/7xc7G+jzJ11OVqIPVG5VTuGpENDDQnupDG36BTC DieFa7HXb7hYSclZcI/oKrBMGuWTOpXR7vscqaJkiu8FvBeg/BD48Xv/U4rZu14ztp6g ymk8hhqbVyXDx8kKYUvvTO15CeKeOnMUV0WKL81+ldcjjGg/gYx9uGfyDNiklOiwTgCr 51nxkmfqwjoVbfiPJOiIlcIH1TBQTMsgks+1G+tqWJxERjSd6JqqhQXjXE+NFtxYBfna 2XZQ== 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=WQDx+cZ1kDn23arphhz0GuuPrk4Ga5SEGuDsuw5J2h4=; b=C/E/GsX1kxgeqca9oUFigGLureCfa85Yjo0yU6unctNUD8kkIi/ljKtmsHqSyHz14I /+zJzVys2/8H3bqtGeVgBfc20P6vviOxt1kRTePxbyxagX3OwieD0Ey8zowuuPeK4kAi 7dxce08+WSg9mUwyo7/553p3QOSf+YJnO9eKhVhfj49580XqC2zxGbCpxDANjctTeey1 DaI4TjlwdVhCBrc6zjle/nUIIo173m715kE2Fk4X4i5O0i0V8hChhlujhB8/ZsBvsiBO GTfdnddxv9qWmm2wLDT501uH9gC/wBTVS84PuU3lIO5bd06fm4zFgav+6XIDDnSsKd86 smQQ== X-Gm-Message-State: ACrzQf1eMLpR+Z2iFRsrOXCEajYEO07SHpHNGlSs5cYcZZ9FUD+t4tbk bex7NRiFlxdlkH6JWTXZJPZqK17uMz8= X-Google-Smtp-Source: AMsMyM7Ds0R55xlAo3BUwsBUkGtms6VFpIEejI5d90Rlh/dp/GwLBXjSWgbdup8Xzkv7UTM64CkJRA== X-Received: by 2002:a17:90b:1e02:b0:203:21f3:f233 with SMTP id pg2-20020a17090b1e0200b0020321f3f233mr3918411pjb.189.1664276900579; Tue, 27 Sep 2022 04:08:20 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:20 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PATCH v4 37/54] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32 Date: Tue, 27 Sep 2022 19:06:15 +0800 Message-Id: <20220927110632.1973965-38-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990544 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 44BBAC6FA82 for ; Tue, 27 Sep 2022 12:32:51 +0000 (UTC) Received: from localhost ([::1]:54116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9la-0006OP-Da for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:32:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rv-0003Hx-AI for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:27 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:39914) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rs-0005GZ-IA for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:25 -0400 Received: by mail-pl1-x62b.google.com with SMTP id f23so8758663plr.6 for ; Tue, 27 Sep 2022 04:08:24 -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=DqdUa4ktVoNWFMpBiRKryhldwdqBntUYFZpWemso0qs=; b=C14AyI8HmvE0YgObz2Zw62T9HjGzs3zZUP6EXhhNWG8ZeJbre3AVwQV0OxlVqueXO1 csP4dLBWN6ewNz3RfXzv+ouMXjq+NcR99YrdzipYG2sOGZbglppCkSn1zfPpaAKQWto2 h1HGhkWaFp7kOh4PkD7B6hwGPalhlWztIpjIX0Y6/2Pq9Jew1jEcpFHgl85AZnwXPlho HSw3hogtfQzFxAQKRYu9LHF73FzjbLv7dVr+UdF+CS4lrXL+ezU0ujSspy2iqlYakUbL 6L+U3ih7MmW6wqQjP3l0JFe5GYdM9pZ4Yf2HWNpFjwEdTN+TR/dqMJNkAmxbOeLMVlZq HhHA== 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=DqdUa4ktVoNWFMpBiRKryhldwdqBntUYFZpWemso0qs=; b=uEdDW8ddvvuGqBvvX6mqqHMNOOP1DgPKX0vSYN9sPe0dMR+eLQ+gFnmrqff4ncNCmc n9HA4XQ7Sjul/286al5/p62l7lAdbDvJ/6VE7MGqeWK5R3dEGRLVVdOLTDyiWtrdjbdS Yx+I7WwRldQ6nLQCph1PlhiE5hSMkgrEGlsMX6MzSXaGFMq+P0Ge7bYl21KLN8vx+r6R r4p4vrMuD03iKh/Lg94ilKsvUUwoyCFcr5xTd+yH4NIXRyZdIdhvo7rpZJdTOzSj+OcH yZFdJzCUt7prlDypUU+K0xL470WV7ImdVsg4aMGk8wedq9UPNIxJj1l544i0cPDzNb9N Gu9Q== X-Gm-Message-State: ACrzQf2eQkCYvllhg/aJYtGmY6hhpkrKKm07giz31FYrgd+SuHFHontX ee97ofTw+zmf34kT9h9SibVh0A6wPVw= X-Google-Smtp-Source: AMsMyM5DRkhHFJOoGcYXs6+DTPBwdbpG4JnLbkthCwpx4UA4VQoyp0NuqtEgyBDWHXqZ4aVVqlZ5ow== X-Received: by 2002:a17:90a:d14a:b0:203:7b4b:6010 with SMTP id t10-20020a17090ad14a00b002037b4b6010mr3972462pjw.237.1664276903261; Tue, 27 Sep 2022 04:08:23 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:22 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Michael S . Tsirkin" , Ani Sinha , Igor Mammedov Subject: [PATCH v4 38/54] tests/qtest: bios-tables-test: Adapt the case for win32 Date: Tue, 27 Sep 2022 19:06:16 +0800 Message-Id: <20220927110632.1973965-39-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62b.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 Tue Sep 27 11:06: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: 12990551 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 DFD30C54EE9 for ; Tue, 27 Sep 2022 12:39:58 +0000 (UTC) Received: from localhost ([::1]:35738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9sT-0004XQ-Hb for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:39:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Rw-0003J7-R7 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:34 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:53198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Rv-0005Gk-2s for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:28 -0400 Received: by mail-pj1-x1030.google.com with SMTP id cp18so219211pjb.2 for ; Tue, 27 Sep 2022 04:08:26 -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=teWUKK+iPqgAl9S+lVS0e68MivpBqlPL4Km9qM05Zkg=; b=m8ROKyVG27Yh9vSMPDmTjCxznSgc3NGM0eybi8bQ6DWXhVCjxelZnFMzi0CDhSZPd0 sHoOfP7s4bDMmWb/8jecdJmcxgdMAEU5iVUUZtml7fafc2NSWyHlrCF6GJlKI8QYfpaV nhVaIT6ZJ/8W0PVNd3TDp8EJgl4/4i6ZLGrSfIhmP23WPZHdx5mPpT20GT9rFrQ5Xvb6 Ap+vJhNdM9vGEI+5gUDAhCPqjTcpRfBzjRAhoyrbler2wXOIjTheD5uxpr1gbGH6RpXg SSneTGin3+9UxzV7UhWUPcJYlp7XlZJ9/XAQE7feyhKYRCDqJKqeeE91bRiyQ8qqeEqJ 8r7Q== 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=teWUKK+iPqgAl9S+lVS0e68MivpBqlPL4Km9qM05Zkg=; b=iEFmFmgzm/mfIjCF5W27YPkqPJ3968tdeBdjY0wmPrB4S4CAMBNPJBwVAQWVljr5kG QAW9WHmrHM2NX2oOrwcPx6yMWTs3BS9eBGcNIKPlVqCy+1KWw8cPKUuDkdzPqDN+rwiK w/wlmET9eC7qRhTUuWqWLxb6mgt4gim2HI1KaiDCra3KoVuxzvVj18qmUxUMigH9GtRJ oKzVrar7ZPfyn46rfDRmXBcfbc6rYlXfMhvpYjaGakmZcxmslPtcc/8sRQVub6eELJCb djjQu57d1q1mZJZXgfBeh7OalnkgBA8RPiAMrlpLOALRrHUnyLQ3uT4HItZucboKnmHb UN4A== X-Gm-Message-State: ACrzQf0cit4hD792vzjjHcanjbEyJn5px8nkj6r1UvN8ldt62GrvdM7L HkvUNfq+9WKlEwagHKztjF9AsRVS3u8= X-Google-Smtp-Source: AMsMyM6xYdWpiJdoAfrxaNvrTLkjm5qCr3W83EYvprlDSfCvSneMtw5oTTy/alWDZPavK5fDrjal1Q== X-Received: by 2002:a17:902:d58a:b0:179:ec1d:9ead with SMTP id k10-20020a170902d58a00b00179ec1d9eadmr2559920plh.158.1664276905557; Tue, 27 Sep 2022 04:08:25 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:25 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 39/54] tests/qtest: boot-serial-test: Close the serial file before starting QEMU Date: Tue, 27 Sep 2022 19:06:17 +0800 Message-Id: <20220927110632.1973965-40-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 This 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 on Windows. 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, unless FILE_SHARE_WRITE is passed to the second call. Two processes shouldn't share the same file for writing with a chardev. Let's close the serial file before starting QEMU. [1] https://docs.microsoft.com/en-us/windows/win32/fileio/creating-and-opening-files Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v4: - New patch: "tests/qtest: boot-serial-test: Close the serial file before starting QEMU" tests/qtest/boot-serial-test.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c index 72310ba30e..b216519b62 100644 --- a/tests/qtest/boot-serial-test.c +++ b/tests/qtest/boot-serial-test.c @@ -233,6 +233,7 @@ static void test_machine(const void *data) ser_fd = g_file_open_tmp("qtest-boot-serial-sXXXXXX", &serialtmp, NULL); g_assert(ser_fd != -1); + close(ser_fd); if (test->kernel) { code = test->kernel; @@ -266,6 +267,8 @@ static void test_machine(const void *data) unlink(codetmp); } + ser_fd = open(serialtmp, O_RDONLY); + g_assert(ser_fd != -1); if (!check_guest_output(qts, test, ser_fd)) { g_error("Failed to find expected string. Please check '%s'", serialtmp); From patchwork Tue Sep 27 11:06: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: 12990796 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 A39D3C6FA8E for ; Tue, 27 Sep 2022 15:20:57 +0000 (UTC) Received: from localhost ([::1]:35240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9i0-0001Mt-Ep for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:29:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8S2-0003Jw-FL; Tue, 27 Sep 2022 07:08:34 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:51871) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8Ry-0005HD-JM; Tue, 27 Sep 2022 07:08:31 -0400 Received: by mail-pj1-x102b.google.com with SMTP id u12so793535pjj.1; Tue, 27 Sep 2022 04:08:29 -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=Q17OGBh7nfuPlSvmIeeUDct3SAyQEVpdgKijs0bRcwMB1s1Jsj8uFwKNN3a/CMvEuP Y13usF6KO84Ym8WwRkNQdpNwo6J8MZi326KolbN6M5w+FzD80XaOayZUpDcqdl6edWd7 Vof8inKF6d23kK23IycVoJ2QNdSdDxM2O4gOdBmYTWwaVRIxf5s/ya9Km88box8q9xU3 wSrc3Zcf7GZy6oI3IARYFVPhXZL87ZK2sDRYN5Vf18lkaexOPwVD7dRRU+Rdupr/Pj0i /dxJjlWJzK+jNq/6JWYuXCtOrDjbOBxMY+cO3Zaxr4lKF6tFpYky6OEgGnwPv4zuwFIr Ufzw== 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=bH51eFxwmsvXRpMG5kaGZ5P20m5SPJE8HIb1LmzHXf0GlT7OTMp/KU11TEMT8VUOfN fSvYYkk+nOHaE1F9CnQ+1RzXkreNmJoJIgm5mVJSZUaoA81Itr612fIpLiawN5eTHkAH 3AtWRmSt9UNk5ML5NWwBtjKdNKWhj2WF076LirhsQiXIOSw8+bJqfj/0Fny9DDFMqTbA p23qOq1Wqqx+R0MchySS/5aZ7eVgS1SGjwNQyu5gNoyNo+C6l/vxUJZIdnWSov6TUbR+ sfTj2Qlolmb/Rqzsy0BX0r8ufFVrzB1eciBg7OdRQyeb8mhMxoA/y8xuINC7/9Wq3VVl ly8g== X-Gm-Message-State: ACrzQf3xtx+Wb18aSjgHuuX0OHcFGbvuimFaaPuEpcoyPYdWxInCoOSg wBIb7ipx1h9wjpPvcMG81z9CmZ1LcLc= X-Google-Smtp-Source: AMsMyM7EvQwZ8zC2/tIDNSROHPNehKoiMbC/fOcFObTwZxkcRE5ACS6PAu/EMJRVsraBcrBXh8jVMg== X-Received: by 2002:a17:902:6b8b:b0:178:7cf5:ad62 with SMTP id p11-20020a1709026b8b00b001787cf5ad62mr26219204plk.13.1664276908569; Tue, 27 Sep 2022 04:08:28 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:28 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , qemu-block@nongnu.org Subject: [PATCH v4 40/54] tests/qtest: ide-test: Open file in binary mode Date: Tue, 27 Sep 2022 19:06:18 +0800 Message-Id: <20220927110632.1973965-41-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990606 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 DAA26C6FA82 for ; Tue, 27 Sep 2022 13:28:22 +0000 (UTC) Received: from localhost ([::1]:43876 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odA7e-0007Lk-TC for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:55:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8S4-0003Mx-47; Tue, 27 Sep 2022 07:08:36 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:53198) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8S2-0005Gk-GB; Tue, 27 Sep 2022 07:08:35 -0400 Received: by mail-pj1-x1030.google.com with SMTP id cp18so219446pjb.2; Tue, 27 Sep 2022 04:08:32 -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=RABEUmJw8JGaUOCeN0U+UTu4ceVB12uKJnHa7M1GtXSPS9g2KJ7nCruzCT47MuGKii Po8rfI7GuIYB6f3pGi7XfwIzdzE6p4cdRfro4aKxAV8KQpkJj/3MG6niQmyAKfiLUJfx 2WYL0aPQ4DdnEkF4CObLDh2OtMu0sIPIF767oUYMvL++Um+KaoAi14Vv/Upquqk+ei79 SFtaLzlonVInx3eXBjyg9ZWpFcS77bja2YidN2yXqJoQhFnYh2Gr/xqcFKrLKRtokl+w pKapXjhNO+arEeuCXhogkBfN1C5YXJaK4MeLPmd+FARNts5sOeImEo4hJfSUVSk98uAn 2XvQ== 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=tCxmW0bsrvs3cMAWIJvC48ZndPUPFQx7jqRU01vHE2eVoFk95+OO3Kt4dh7j8UpQA0 4pP4EGcUo0oufFGv7eBb8A8U73uBZw1BgCQqPGcWVCQ4TAmx3umyL+aMdpkJCoG5NNVp 45aj2+vVgjjsoO/qL0ix4rtZDKQWP8IDygO1qSx+DFc5ffQQ0Oh+9dH/LjLi0w6iIDA2 MgbS4xHYFOk+4r09liW4AzmtEDBOcui5Ycjytu0eQ/r1ZKG0I4wZK+vaY9RVfugeztkV lPi7YBkIWO72lPvWH2dSQVtC1NUDJ9BjElYueZRnBu0Yd3rXfkXetVsfp84frBg3Qgy0 eSjA== X-Gm-Message-State: ACrzQf0vdsm6YaNK2U9mOO8m6NYgcEX4bLrDD7svSFpwy67FVL7U4Nyl YAUD03n999gd57xero40Vl9jRXn/3Dc= X-Google-Smtp-Source: AMsMyM55CJdBpyH2tFA/gc6cL6C2trEv4EIBMpqBmNqgqr3sipluyinxoDZWz8T834wtTaB7e3HbPw== X-Received: by 2002:a17:90b:4f8e:b0:202:dd39:c04d with SMTP id qe14-20020a17090b4f8e00b00202dd39c04dmr4101906pjb.66.1664276911603; Tue, 27 Sep 2022 04:08:31 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:31 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Joel Stanley , Laurent Vivier , Paolo Bonzini , Peter Maydell , qemu-arm@nongnu.org Subject: [PATCH v4 41/54] tests/qtest: microbit-test: Fix socket access for win32 Date: Tue, 27 Sep 2022 19:06:19 +0800 Message-Id: <20220927110632.1973965-42-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12990634 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 B80B8C6FA83 for ; Tue, 27 Sep 2022 14:00:07 +0000 (UTC) Received: from localhost ([::1]:48448 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9mq-0008DZ-QB for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:34:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8S5-0003Qs-Hu for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:37 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:51113) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8S3-0005Hg-Qp for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:37 -0400 Received: by mail-pj1-x102d.google.com with SMTP id lx7so2515324pjb.0 for ; Tue, 27 Sep 2022 04:08: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=Gd4IFwSiMUXcAFhlVTo/cHgzPvOGzPOAZZa5JOwEkAY=; b=DJWb0rha1r84tfLJcxqIR1HQ36rxir/ZJfDgKgqzvvC0CDidvfmR1fxqAVSfrdZhrC 6RR1KFaV4owOnIAAtor7mbgztiXPjd1tFIlG/qFmtobqCjizpHhSYjsaFESYYi50iCoR EVBL8r8VHSQnur0rhLyWpLChBHPUmPlE5iNvnlo3OsOSVse25fGptNVEO65pNzqv7pMh GmsrkkHiEqYDiBSgSzHZNejlKFmAUaWBte3hH4U10huYJ46klGLz/DcQq9Yl33LXWqeD l6hd9ojjz+MehD3YR7uw+R3HDZ6Nv3i/0ggmOD4Tk/A0WsNQJAJh0CKBZVuMxPlcgGCs 9tnA== 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=Gd4IFwSiMUXcAFhlVTo/cHgzPvOGzPOAZZa5JOwEkAY=; b=p4VjLqV6jiJ7gQzg1yQq9Rm/kcw98onEJp5pRkOQ/RRoNTOkdZtdTf0dmBXXfIvQ41 9dZrd7uCzNnRUAtCacfhH84b7A8ut7krhVThEi57Zrpe+r8LoWc6bWtUjvu30kbgRZLb 6cHjs1DQo9SSef7H94XCt5cUern/fNMzTLUsIoskl0yB9L6Ph2uYOrOx3AJgzT3fVfuL TJeVFFEih/mi6em6Ak8zXYWII/DKYDiXkl6fANTNxSaQvi4hQh8JnwUJA2aGTdrqPCzS zP9Zgu0rUAJE8W086VxyWTAPYuiFVZUp/LTDCscN0xNwfqKlk1ZzB9CMtNYDT2PrvaAo GvZA== X-Gm-Message-State: ACrzQf0AofbtWD+dWudRdm/suec2Is0PjeMrnTIqXlkvP58/w1OM6nbZ X6PbInKz9h/e27kCYyp1UjMSj+etZbY= X-Google-Smtp-Source: AMsMyM61jm9bG9VDHtdIemgvNSgloRTFcAhcBorrer09rbPKZD97LXKIMkOJz4FIVL9X4lWLVA5++w== X-Received: by 2002:a17:90b:4d07:b0:1ef:521c:f051 with SMTP id mw7-20020a17090b4d0700b001ef521cf051mr4089015pjb.164.1664276914412; Tue, 27 Sep 2022 04:08:34 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:34 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 42/54] tests/qtest: migration-test: Disable IO redirection for win32 Date: Tue, 27 Sep 2022 19:06:20 +0800 Message-Id: <20220927110632.1973965-43-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 f57e07fe2d..45c5f5761b 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 Tue Sep 27 11:06: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: 12990570 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 2493BC6FA82 for ; Tue, 27 Sep 2022 13:15:18 +0000 (UTC) Received: from localhost ([::1]:44122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odAEK-0005ST-RE for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 09:02:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8S8-0003ZN-E1 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:40 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:37385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8S6-0005IG-N6 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:40 -0400 Received: by mail-pl1-x635.google.com with SMTP id d24so8768534pls.4 for ; Tue, 27 Sep 2022 04:08: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=4YlvwwHBUrcNOnSxEFPAUdpBdu13q6q8TiMytRlndpg=; b=cFkWFOU+SLyKxHC8TI5GHsFp3lW+Kro/4tvMMObpv3AzelZkodwoaWDKOOjHXrjaah 7iFVprZg1icIX23Nwadg67K0mpcj7O4T/Cx3vPGPDbT3/4k8XjgJKXNLZwgeY+r9DCRv /OyWiMI+FhJQ1swjcWXULAZ2tv2B/gtd2Xf49okehsgSGFySH7/BX8OiqQz06KASDsxR uF5/K/lCCHcXMXk9rJm40pfjmtlBMwubiM/7lGFyVyB+0Jio9XrB8N1Pr5bn3hl9b99E FSRHhPyhK2E/+2nW8XQmAeXG2z7L4TV85oTUNY0MjKqOVfhAXuxa7+ku/YAWp7VYqZb/ U/Lg== 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=4YlvwwHBUrcNOnSxEFPAUdpBdu13q6q8TiMytRlndpg=; b=R+yz8kYMU4pYnL4i1pIS/YRFTT48Jhwc29c1JIqsuAj3dYywZiGDR60ixOMcakY4RB Px7o1fx54uIWkmr7fCAhXJGIqZhMm2XJDleGCswMUnps7GIFb8m6702JYz5aJJAwYHzH hmL73WKApM+OwTso5UTIsrkK2lbEeOu5seKdWOBMLXNjZdldhnK3L3AbdycIuEij8owk tnzLJlygUjy1ri/XWYhFa0XsK6uMX/mzhh8YaMnPFNYLlYdsMlV4uBDHdI8zLnadLM9h Y45FBRXQsT7EIZi46UiM+3LZr21VQ+LrUi/frGTBQJ5Wv+SnR3fkUt2y6eJahQYzHBO8 ZOQQ== X-Gm-Message-State: ACrzQf1G2Dvy4vCN9xdRsJHrVMhNH76GBA8Dvl3W6/3KaiLeOCJRrPMv rFFd1wOQbfU8sLOTioix2wYPmxfeAWA= X-Google-Smtp-Source: AMsMyM64lL6+ATGpyOXwBOFvneYNwcdWi+2gaV70WlSBdvapqQc3yVRRRTah56lhC7GPE5uGtFmJvg== X-Received: by 2002:a17:902:d2d2:b0:177:4940:cc0f with SMTP id n18-20020a170902d2d200b001774940cc0fmr26459896plc.4.1664276917356; Tue, 27 Sep 2022 04:08:37 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:37 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 43/54] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled Date: Tue, 27 Sep 2022 19:06:21 +0800 Message-Id: <20220927110632.1973965-44-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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: 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 --- (no changes since v3) 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 45c5f5761b..6f9fe13488 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 Tue Sep 27 11:06: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: 12990616 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 A46FFC54EE9 for ; Tue, 27 Sep 2022 13:32:50 +0000 (UTC) Received: from localhost ([::1]:40896 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odANc-0004Bl-1C for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 09:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SC-0003dz-JN for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:45 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:44718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SA-0005Iv-HI for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:44 -0400 Received: by mail-pf1-x42b.google.com with SMTP id v186so9347067pfv.11 for ; Tue, 27 Sep 2022 04:08: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=szrrAWQi57rwmVvkIAS0k/zzBtjmcZYK/YPRpaNr+UQ=; b=YQyXLzawnSLSYQILmjf5mHBwRWoSs8p40UrdsI+qzMeTMwOu3WfYNDF4ZyrRCoJBVi ri4thCv8VvUXhkRa3FmrIxKv+78CWB1MPSszqF18NLawvwDL2YJK4LFI0bL+rPDUQWy1 aMqIJNmw0XSicEkPRggyw1BQqV1IHeznYd7tWBvc7YUraQy00mGqDNnM0ChkOBlMuv+V zTjQME2GYaa7cRh/w17vhzyquRzI2NFr3RQJpLLx6W2NTxuHBn9pP/AAp6+PJ8vaAn1X 9NItBqAdnrZWfCMhlbzZaVq9gKiLMfATcBnmk5O5mHwfW/J9tJmJpRL9GDQ/ba4FA+nm kBnw== 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=AFMx1Q8ZiduV1jAM492bX4nkJa2/ZAGIUXYYANUH4StVnzLAlZnFsb9Gx4IM9EAYtn VBji2IpC2AMKs7ebQ6tEoDSdMLz9NEXi2wfY2XlcBLfIRZqd1W2To1GyGHvAg++VYal0 eExii5crxnSmei9JWE20HyYcgDVVE9Z1kLgcmdCr495FHLPaPzEoHr3N3geIKLWV9wdO xF4EZyYHLClD1wdYP7dxQYtNsDnv3U+JHm5AuN3kZxuzSpsPVyW1XYeV4vYqJxz5Ngzx vxdV6wm9svUPjteXc7eG8StKNL5v0rYbDJigs9UOAV2XsNyq5IRbTsVimXXWaTfdDvCJ NyFw== X-Gm-Message-State: ACrzQf1RXW8Mqok4JMxJLcHVUYc4jb9NLQCTA4Qz3M0exFqtalQxVMb/ bQkZ2IX13hYYvVTDLEogGslv7xV3nPo= X-Google-Smtp-Source: AMsMyM4IxIQjf5RziKhLX6WYKrhS0QCKCXzAWLvp6xePfq2thtnxkvep+eYYHl5EWPbj1t2E2iNF7w== X-Received: by 2002:a05:6a02:43:b0:43c:dbdc:192d with SMTP id az3-20020a056a02004300b0043cdbdc192dmr5026287pgb.449.1664276920057; Tue, 27 Sep 2022 04:08:40 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:39 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 44/54] tests/qtest: virtio-net-failover: Disable migration tests for win32 Date: Tue, 27 Sep 2022 19:06:22 +0800 Message-Id: <20220927110632.1973965-45-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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: 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 Tue Sep 27 11:06: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: 12990568 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 193F5C6FA82 for ; Tue, 27 Sep 2022 13:14:54 +0000 (UTC) Received: from localhost ([::1]:49784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9ud-00087S-Jx for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:42:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SD-0003e0-JO for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:45 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:46956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SC-0005Jw-12 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:45 -0400 Received: by mail-pl1-x629.google.com with SMTP id jm5so8729264plb.13 for ; Tue, 27 Sep 2022 04:08: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=GlznwSHa9K/cOS1FRxJZ04KXhLV4Kvl8Dx3ESYYXk8U=; b=VaFL+Hd7zujksmRda54YrsN4XeeLNjB2z0sbAThf2Psm3M8m+AyvVScRMF2ztXxttw usCXq9z72/ett/U9sCD3oYHKOq38cmW/O03i16CX1kHivlNWXuiTMWH+NWHSkPoPZOZ4 wUAaHprqMUuBtpdsR94Tc01yXhK5+Ysp2Fu+yriil3D/Mvn6NbaUzyS0Ea2nQ4C+0zbb J7DwxZDfcmPWRpCH84azKOf+P+yaAsymsolYJPwSLi7KIqAXsUG3J+puoAh6HUv4rP4w VHls3s35eA4LpD9zsUHGgczoH8hVH6HSAzkKbCSy3GGdVOruP9Kb9sRF0FMihW9YHM+b JDtA== 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=PER8Bwdg8iSFA80Vv1DoQUQGnungROQUnP8YJiZPfp1WmizNVPfmnh//TjiyQKtmlq jfpazVd9Wff3jcEGhjTi9d7uUE37Lr8cg8UCawUGKd4LkIlvWeHo6q9uq2Lhs5Zqwu1l s13QVzcM9DSmWr8SobbvFPT707cvrGnFp5ujx2/b+SKR3OojgioOHnCMQjpB4PbdrC5o VtXWI/ArW+OBFssKxSgj/H5vnC23TmPxXiJjV0NSGSPIrwfrSC3Er8lk0uZCGpFbAnDU 0YkO+YPdAgOR0nJ8FVI+4eeZdZW+MSnhGrJEtsn1WoZwG8jax6u2P/t7kp3ERZM73avN qmgA== X-Gm-Message-State: ACrzQf3e4vzkZQyatpJAkXDmFKzuyy/as8NtD77evH2keX1KKgYvFfux 3zBUlhKLsqJERWjB1S3/arJ8ajwC+vk= X-Google-Smtp-Source: AMsMyM70J8Vtc2GVBRXX5bgn2hxB6IUWKbV84dvALKmbwq/LOgiWtcqp0+Y5gfz4lPh29m3GCoiVyg== X-Received: by 2002:a17:90a:e644:b0:200:2f9a:bd0a with SMTP id ep4-20020a17090ae64400b002002f9abd0amr3978210pjb.88.1664276922469; Tue, 27 Sep 2022 04:08:42 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:42 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 45/54] tests/qtest: libqtest: Replace the call to close a socket with closesocket() Date: Tue, 27 Sep 2022 19:06:23 +0800 Message-Id: <20220927110632.1973965-46-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x629.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 Tue Sep 27 11:06: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: 12990569 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 4594FC07E9D for ; Tue, 27 Sep 2022 13:15:17 +0000 (UTC) Received: from localhost ([::1]:57806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9xI-0005fJ-Ek for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SF-0003kZ-VC for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:47 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:33289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SE-0005KH-A6 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:47 -0400 Received: by mail-pg1-x531.google.com with SMTP id f193so9141072pgc.0 for ; Tue, 27 Sep 2022 04:08:45 -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=boO3ubYK+Uv/TPRG5p6DPUQp9Gqy66MuTKzZtuQ7Cl7uKYa3ouj3sCsU8dQohDbLRL gCb8nVhIvtApB0jm1XWf01GMFCtpZKFlo1JQBge+qGqKRx1hVa6eDu3PEKjOmcKACHxy svD4kKx8/aFRfVy2pc8pKvdHqbzbh6lVHCsLG7JjF/ikQNPu9fOp78tzeVP+W1EznOsR +FDsFBehVSLyVRRzo4X6a+QaJiuZ6WRx8D86lA/AgLsXRqsHMmbLY4pulnxgQ+f39zEx JMG/qahp/9be2uuLPquGK8kqb9X64J8a39ZcUHCYAeB42e5xtkTeuv/03b1CmwPWbBZl Tvzw== 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=2dgpsQXH2oNxFhREP3UwfPsl21udQXylLVXsOdKC8AKWFKxxgo2zlz3pZjcUts100s h1u9qEuFU2I1/RashWD5R7+MXsLNT+HIgpKQSp1TEkBcHailOPuI8gvvb1I+Gb+2oZxJ yAQaVK902tcsEDXDixMd41q7JH/WHX/+TvzN2AKyxYWhat4PlH7+2wYEkn5+Xwc6Up/p ZrFOydgSIgHb+BmfLI9HDvVwfB3stYNhpoYA5Xnn0tOMMzHKcZbDrAnWvs+EnyUFNjVk VCfFIua2QT5/0OkXh98fmDSJH82uJMyrdKFEf2j9dBkLAOTkTrKRBvWaAtPG0JUkI163 0aDg== X-Gm-Message-State: ACrzQf2W3u+0HlkHGEfREjjplxcPFvPf7jPEsDhicBv03yDRkLp79wSx kBQ3PXPZhZrJxBL9Ni5Nd5eN3jCiiT4= X-Google-Smtp-Source: AMsMyM49pVvkjgXFyLFsqPGIkZgpe7L4yPDZqimxcB9M+T5rHLwZ1/IzSiLi04GKIlfu6lQ9ACYh1Q== X-Received: by 2002:a05:6a00:cd6:b0:546:d03:3dd7 with SMTP id b22-20020a056a000cd600b005460d033dd7mr28658305pfv.19.1664276924858; Tue, 27 Sep 2022 04:08:44 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:44 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 46/54] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32 Date: Tue, 27 Sep 2022 19:06:24 +0800 Message-Id: <20220927110632.1973965-47-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12990552 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 F1949C6FA82 for ; Tue, 27 Sep 2022 12:41:05 +0000 (UTC) Received: from localhost ([::1]:46750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9tZ-00066Z-4y for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:41:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SL-0003yL-4P for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:53 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:44641) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SF-0005Fu-VZ for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:52 -0400 Received: by mail-pl1-x635.google.com with SMTP id w10so8746188pll.11 for ; Tue, 27 Sep 2022 04:08: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=wJ46lPbUundlzLry/XhmGks2ORwcj9XXEHBkBSD1tlY=; b=I1eFhY9vXFdkZTsFzPOr6QmlwuNUiINV7kaYQ2M7K5DiXByCM+EC7LNlvrWiat9pCG iPQSfrdZuTyTXmK2+EO6WwGXzRKGbzykz4j8eiG6rkRFZc0yaaK9cYgWwHJl3Q5L0PHc rJlHDjfBMxYTMyxm/DX17Y0yfoErLuMUspMHdaVwqFp0/JJIGuWOHNKadTQA+daORxPj QXsa67ty5GelLqcgNNNFpWeZovmUyZjITGRn/D+nshjc4VG8LL2KkrE2hhV/gTpXfDob ZiwHDz+vG54LGO8r5QPnePpBl7wMm/tDC5RLDsOestzkQgpunQvXZXHkRs1tjxO+irc0 xGUA== 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=gTilqmZQvp8kOD0ONq2J7JKugRkiw4pzkh4uohZNh7Ue0S7Mi+zclkStPLK/xEIk0m UwH+7rhdG2Llu6QbTaDzozggK3ndWusyUZpfVDx+uqdyv4cofTT0FHcusJ7gNkl4zdiG z3VUc2H4u9lxEM5SjLKDoekgxB6omhIpDjL+RY1xYsZglatMHRQ/OkYSFtVvNhIO6LEo uWJfS99v0VHMu2SUjy9vgCdjMQuMXr1oPq6rPE8Bl9fEN+N8LiQvoUK7uL76MHy+pMhB hk3rn3K/0g56y7XiRArOp02VDWf/kjpWeYRodgmIZjCHBC3p5kacToQvUikR9jvAtl55 zmjA== X-Gm-Message-State: ACrzQf3QpCjNydEC7hPsM0p/Jp90X5uoPJWq2rT6TL3KpmmgqqL75gle maPXVLRIVbYVwGMkGnOUmqnZOggmYh4= X-Google-Smtp-Source: AMsMyM5CeURl2MqaM+ZutenTEO43j0R96InZbN7TDvz35MvdEW8YntddL9VSSuWAjSrAnzCJ4yAzyg== X-Received: by 2002:a17:902:f70e:b0:178:8895:d1fb with SMTP id h14-20020a170902f70e00b001788895d1fbmr26650957plo.166.1664276927061; Tue, 27 Sep 2022 04:08:47 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:46 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v4 47/54] io/channel-watch: Drop a superfluous '#ifdef WIN32' Date: Tue, 27 Sep 2022 19:06:25 +0800 Message-Id: <20220927110632.1973965-48-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+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 Tue Sep 27 11:06: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: 12990556 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 C5E29C54EE9 for ; Tue, 27 Sep 2022 12:52:10 +0000 (UTC) Received: from localhost ([::1]:33560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odA4H-0003Vn-OT for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SN-00042X-AF for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:59 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:38650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SK-0005Kb-Kz for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:54 -0400 Received: by mail-pf1-x42e.google.com with SMTP id a29so9377112pfk.5 for ; Tue, 27 Sep 2022 04:08: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=FMvqR5WvHSrhd6FoBOh5bPNiyVgL3g0xwaaD6f1HGpU=; b=eYVp0IzcpRkRm4hHQ6hxqgYHCR+3r8adOWkVxrTjTVRAGdZsxHE5r6KaFWAQ/iX+G7 7jXh8uk+TQjVHDBgWjfUxKjiCPQqIaw05YW7fUof+0P2PcOispOdE5aNoROUab5rFYW8 0CmcsBuvVqD0EvZ9E1Dq4ayj8q31q0bu1AulgH3z/W//7cUYNnlpKvJWtVBM6PbDDuKl kWhVucWfTpe7aqmf0wmfgFR5MAQwxCL8srhMLCqZ9CC2KACa0UBef1E3Vl9BVAK+37YM 42zInMx04dwQX6Luy19GtqavJE5CcVcIv7oBsZfpLDsZWRzYh/P80ZJfTLR+NR/anQ7+ Sg2A== 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=0kJWLmxV9/K5lfPXyOoPFKWmTCHTfcDlII26fn2mc6oiwbmllIBcQZuufqkN2gH/bV 8P2nBX6dcJ752jEtMfpA3pPmd63IYxTS6PAcyZNgh17LzJaG7iQ5gsOXmfObbbmHsojb 2UiRMEmh+KtiH+sx2ZNXjbupllDvxro8H0AxTfc7u7clmBq+950c0NwFDU2r1woGiE5p WCYmlVo8hEr1FQthP0UH+A1HXnqZJ5CKMA4X6tcoZvCWJaCm6h3OmXEU5znxPbQwE/AP 20fNEVTAP3eqtPtgHrZu8BER+KSuHc5+TujRse8eWViEam5QOPfNKv6B4ay1eAWC/akb nhPA== X-Gm-Message-State: ACrzQf0HI5hpYA5s/wA/ZRWr43EHD/GZe+DQhRDmwv8USU4zeHou1paN dhlLwsid7SLuqDyekOivDhpLWxTD9S0= X-Google-Smtp-Source: AMsMyM48oMCL0JvL10DtcKQemOiaxFIdEAO2Nn0XqumtUGLR/bomvEKx5AnK2QUA+2+lFXpZ/iYc3Q== X-Received: by 2002:a05:6a00:1989:b0:546:410f:bdd2 with SMTP id d9-20020a056a00198900b00546410fbdd2mr28293064pfl.83.1664276929264; Tue, 27 Sep 2022 04:08:49 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v4 48/54] io/channel-watch: Drop the unnecessary cast Date: Tue, 27 Sep 2022 19:06:26 +0800 Message-Id: <20220927110632.1973965-49-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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: 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 Tue Sep 27 11:06: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: 12990555 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 04943C6FA83 for ; Tue, 27 Sep 2022 12:44:20 +0000 (UTC) Received: from localhost ([::1]:44556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1od9wh-0003fZ-4n for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:44:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SO-00042h-6b for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:59 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:46818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SM-0005L9-5M for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:55 -0400 Received: by mail-pg1-x533.google.com with SMTP id 78so9063448pgb.13 for ; Tue, 27 Sep 2022 04:08: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=xIwwdkQ/UueIjTq9LmfxXmdWH0OF4K6cF8/Wmny7JFg=; b=VnQl/uqDqGk2stio0h6KU0wZkAKEYr+iY/DCkbSwWcNsQ7ZPkdQt7tDd2RmIEotVw0 NfBvbrBZvOVVTvp2cmlR4M6qcjBvPgi7jq4ZeeCwtCqteGslk4wI2ElWdV4gAu4CWnp2 LIf0g9rGpqwLcDooG3rmpRG146lNnFLJMNZPyX4I+ShVJn8D6NsQG+MVsr3Cs55h9UZ/ DhBE6sJS9UTpyF1jizMBHrD4473e0jIZ+mi9hUPY2Pt8Fl1bQAa/DyzXex86vE3FHMhS /pLsWnEXHE60EK0CqsRaOy1TYh1GoZ7TRgvjMkswBcdbScxhCApyW6JCvBkmQeeSRW+q 5d/A== 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=wTkWKXqJ+eZdykoVhe9WV6fZPZhj6w/z8Q7O6DtEfAEISsEmk0RLS1PFtosBMS2Cjy w+fjMhucaHGIhKi91ujMj1p9m5+OVc0SFBVD538+tnvuh88r+nWTP0GUBbb/QrQy7TWl tMd8b2NuTQX+OkRpHpEid+EjtH7izn6o2S+eb+1OD1qzNuo3DDufm1/S73jmC6VvbUjJ Z2uuhUmjGU6cy6Lcl/H4tQW59uxBzaj1t7PZlA4ZIimDky36kvURL4iwqbIayfJE3kJd wMQxI83s9qkMTyE7E/a6b4reMDIEu+hi/stlwHCogA82g1r+t+tq0Z+5Fu1GblNKhvDm synQ== X-Gm-Message-State: ACrzQf0ImOcDGqCvEUE/fF3Kyc8taELbtOJVs9DTS0lucVIvLLyXwMwK SXG21aJVlZ8pmGKRgf2ERoVcgeH9Xcw= X-Google-Smtp-Source: AMsMyM6fW0RZru0IWqTSjLFFkEbXQlzdc5XLCRVIpnz5d5dhg+gPcKo5L3pZl5sE9wdUZGZRllTjrA== X-Received: by 2002:a05:6a02:20d:b0:430:3886:59e8 with SMTP id bh13-20020a056a02020d00b00430388659e8mr23948641pgb.516.1664276931560; Tue, 27 Sep 2022 04:08:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:51 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v4 49/54] io/channel-watch: Fix socket watch on Windows Date: Tue, 27 Sep 2022 19:06:27 +0800 Message-Id: <20220927110632.1973965-50-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x533.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 Tue Sep 27 11:06: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: 12990577 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 BF1D9C54EE9 for ; Tue, 27 Sep 2022 13:18:34 +0000 (UTC) Received: from localhost ([::1]:52260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odATp-0001s2-RM for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 09:18:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8ST-00045Y-DK for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:01 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:43561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SN-0005MW-UG for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:08:57 -0400 Received: by mail-pj1-x102f.google.com with SMTP id g1-20020a17090a708100b00203c1c66ae3so9752813pjk.2 for ; Tue, 27 Sep 2022 04:08: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=8xQxX3aLwKGUXMI2hUqbIbF5Q3YkMuwq57oZfcmhgr8=; b=Vt3xoFHOj4JRADuFraQKickwsvy/WizFngsnGCQCG9Ae/ynoydE7K1gxowHRWV6u0Z 4Gj6IkhOe5KnZhwgypdAGc6aoCf1nckhSfGnGvMN4sxqw1QdwPkLK/9Yyb45HtunRm0D H2ScADRcJXOuiPB5EI6oSgvhsdsOrM4RwLdUnxSj3n1jdMAAdsfZMMdIs6FloP+Y95EY Dxb4ivTAR+YXEeZSH5aOgxqdBrf0Y+rcjEqCljmMLKNUrqM76Nd3mdUBDsqOtp+DR2AK dY0wCYZt89X/fDDI739o3754SBTPjtnHP9chT0cjPXmDj49im/cC//G+so9EKaOpP0JO wyJg== 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=8xQxX3aLwKGUXMI2hUqbIbF5Q3YkMuwq57oZfcmhgr8=; b=O3JbCAy9GEkn+KfIORyhd+qDMFZ/8bpRWt5uKQJbDSfFSEcg+eTeOuZ+5RqI51jRop xKL0RHjITUi0ooRWI6MPW3ou0Wi51G4zDakb+wFpFmB0NSwBEo/CAx3tx6taObxaZvLr X6EBh1CnCsOKU7UfGF+wgIf9F1XKli4UtKSRbI4Max8zthUH9D2BiiK9j3BHnVH3EKQq LyL91/iO/DxWeKzQfLZdQCXZOjS473LEraSPFC+u/z5JpXzs854W3qvIGCVkPd6Zt7b3 Hg5qAEQ2rR+cOR02qImDAF7aafGAFhb7koOvGkv66MMqTyWGG70ft7tHDx1Xh0odYgl/ PQAQ== X-Gm-Message-State: ACrzQf2CicT5Dp2m9/vPBzRXMEyLjlzRAvhZxTqrztrRuQdCJc6sRW8m NWn4yK/Qcy9NisZtEgH8/ZTm//50UuI= X-Google-Smtp-Source: AMsMyM6MKE/9QBjZ84xBFkmkjef4h4XKNPSr41XfYoeiJOJmWciwp/GR4YAMZNv2zPRZstReI5EvLQ== X-Received: by 2002:a17:902:eb90:b0:176:b24a:e69b with SMTP id q16-20020a170902eb9000b00176b24ae69bmr26414075plg.86.1664276934260; Tue, 27 Sep 2022 04:08:54 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:54 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 50/54] tests/qtest: migration-test: Skip running some TLS cases for win32 Date: Tue, 27 Sep 2022 19:06:28 +0800 Message-Id: <20220927110632.1973965-51-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102f.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 6f9fe13488..5c1aaa700e 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) { @@ -2498,8 +2506,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) { /* @@ -2525,8 +2535,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 @@ -2570,8 +2582,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 Tue Sep 27 11:06: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: 12990600 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 2B2D0C07E9D for ; Tue, 27 Sep 2022 13:23:22 +0000 (UTC) Received: from localhost ([::1]:42194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odA1X-0001Q1-Ml for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:49:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59036) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SU-00048l-MM for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:02 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:38650) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8ST-0005Kb-2G for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:02 -0400 Received: by mail-pf1-x42e.google.com with SMTP id a29so9377333pfk.5 for ; Tue, 27 Sep 2022 04:08: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=WijaFh1+3eGNmoiPADdFaEnlm/n1XUXqlNMKiv/+vQo=; b=n36nXKVb/IXL6NEReR6dAE9DahKOwnDfBKazEoAHJTf7MPdQjYCJx1blYIabO9Sev+ BEspddevJ/uIMV0+l9VmOL7PxQeZkOwXLakVk5BOdbgsOnJEdYOzk3dEZAk0O3VjlJxF ouIm5bN9LQmq21Bcqi1Gb+JyBilk7JceuCeNUwdEM+ZE2phR/s781iaGmFKcjfjAXqFH pVIwxi9ZBluYj5Ld179S6Wg6p60TSVPmQRzOIXkrrGLB7VRqPB6kl3M2pyWiq0ZhMNX0 pvm4oACYv8ftN6CrgkqMDaIeZ35pH5cEIBVM/uAUvWbeSPmssilumN42+67RPcR4o2bE 5Syg== 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=VQ3QeJsfRwaFWoFG3EUmuU9qe6OLTPi4S+PY4fqjrw5lwT15EDdj9n0P+JtJZ79UgX uavM9IyKlbQkhTpCVJu0agLU82ol5m7fMahSL1mD0iyYawReRDZG7eEW6Oo3/r3c4eE9 pve2aSshQy0jumYY2eOC0ts7asdrGJ/cZ05Daxw57cXcDBaKouniZGNTEz7Uion88B+K 0eLBODzEDdFzJf5t00YlcCO6wwVQPxzpkdq2JqW5raLWwp2yenKjqAzKHHrBTyTK7bSq mPGAmjfHWGbvJGwOS0pcJYsulg19Jd+dzx49msko0e8/fBnlx9bArXQRgBjI6oDGqHtq p9EQ== X-Gm-Message-State: ACrzQf1vQvjZpfstQgBScrALYtDG3RUdV/79RcII4nUd/uA5GHoY557q UYc6gcDrEljYHJ3XeKhOS1oxLarJZnw= X-Google-Smtp-Source: AMsMyM6Z7FGCoO2ZQzdzlFcDEYax7b7hzxycNULQgnvWo74F9Yztzsp3TUYFf295aQjdZkNVHU0G+A== X-Received: by 2002:a63:e417:0:b0:43c:2fc6:d60c with SMTP id a23-20020a63e417000000b0043c2fc6d60cmr20932775pgi.436.1664276937017; Tue, 27 Sep 2022 04:08:57 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:56 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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?= , Wainer dos Santos Moschetta Subject: [PATCH v4 51/54] .gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes Date: Tue, 27 Sep 2022 19:06:29 +0800 Message-Id: <20220927110632.1973965-52-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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: 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 Tue Sep 27 11:06: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: 12990608 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 A0F36C6FA8E for ; Tue, 27 Sep 2022 13:30:04 +0000 (UTC) Received: from localhost ([::1]:38880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odAAW-0001oA-RG for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 08:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SV-0004Cy-Tn for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:03 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:41737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8ST-0005PS-71 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:03 -0400 Received: by mail-pl1-x635.google.com with SMTP id d11so8754122pll.8 for ; Tue, 27 Sep 2022 04:09: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=c70GbRwkwSt6AlB5iSFrSG+pSWFEYKzAbLVBITPzdys=; b=K9TzEwlnOqhNSSnMfE+GQk6p64bBvdGp1nxGB+fx8DY6ZgmEeHVGqhx5cerosXdHwm kG0LM8t+FSW/xdNIHC5jV5RlfMbogIPWtZ4iowc91FVPN4kXnaAnHWi6h91++WPcElPp mccYdNGq8X5qeDWBDuKHF04PLwUTAdQ7vRJYVLjXGKcP3SfbiK18ZoVsnrSo756+lT32 lKDI+4D9rBzwLrV8TCSd26yCKevY9aqgO8eO78R23BtIbX8jKHvc131to6KSuzP1vkbC qvJkCB/38trfLaqlYqrmM+NY5XK1NhG2E12bTvZeiMiuvgTPIFgjZIwQ6lW+KCLIy2lM 97Vw== 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=c70GbRwkwSt6AlB5iSFrSG+pSWFEYKzAbLVBITPzdys=; b=xnsZOtqhtEwyNrZduj4Wu69U3dhnEQBriT9NFJ1v6t1yxkXmGZutrp13Xsp45W+lPw Uyxbm7acr7+Y9+V2HA34Wdau5PlURxcXuennvsQqx3VYkYO0iUeIur+Z8UIUUFzdJEwy ZrcJbuJZk8uGOiNHjNqWXSXKPLGaNSYIxitAgmkyKA8Q/ZVxENZwenEZhS5vCWNYdg2l ARgdAuoY9SLPzXuaWVL6cN4DmzDpjQeCVRYeh5UaoV3CU+GIdz22Bm1lSmBHwiOaHQN5 16mHF16+1kNNNYGn00Tl5mNnFpqeWWcCeq5JDYmqCnp2QbPjmrrc5I3WazmXm96qW9JC EPAw== X-Gm-Message-State: ACrzQf3Y3YjTY9mtNiWGt3dfDgPUXc5+fGrHLTCMcygVDAcLtq6j2wHt WXO7cVjZPpcdmF2Mm/JWICcmdca62QM= X-Google-Smtp-Source: AMsMyM5rbECm4iWfp+RQudavKnz0+Du7te7XBYyjOfNhYx/8fdsMe+zLJnI2Oj1dUFCRk9eI3EJ9QA== X-Received: by 2002:a17:902:f807:b0:178:516c:128f with SMTP id ix7-20020a170902f80700b00178516c128fmr26203972plb.77.1664276939854; Tue, 27 Sep 2022 04:08:59 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:08:59 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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?= , Wainer dos Santos Moschetta Subject: [PATCH v4 52/54] .gitlab-ci.d/windows.yml: Display meson test logs Date: Tue, 27 Sep 2022 19:06:30 +0800 Message-Id: <20220927110632.1973965-53-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Tue Sep 27 11:06: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: 12991075 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 60E4FC6FA90 for ; Tue, 27 Sep 2022 18:11:27 +0000 (UTC) Received: from localhost ([::1]:44980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odAab-00008E-MG for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 09:25:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8SX-0004HY-Fk for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:05 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:40614) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SV-0005QU-L9 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:05 -0400 Received: by mail-pg1-x532.google.com with SMTP id s26so9092507pgv.7 for ; Tue, 27 Sep 2022 04:09: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=6vWxOeY7p82uUk8+zkR48MfJ74ST+TkRBLA0VziokAo=; b=d2EHnyCUMjhBzLXvE/j2/megnS2cQCDZv2TVpZYmVvTs3yQjFdz594YRPFWscsWHSn KcgAMZFl5y1yP1ygcNyruqnUaJuxsv0z3DrDNUIReGDRJLpdqRxJK3/oZBTj6ZjDRJFv n4kBq3pHdh+aJ0Uf1EKMM7hCZNsECK5RdIa1b2DO1PRtSb106UG9zKs/WnB1GdmRF5lQ FuH27jstOVdHcuYvZOIH/yV+kGKBof8DbCDlLS5RZBMm1MXnDTrzcSoZ4vUR7sgiO7is 8hre6EkaI71QsXx2XnlffEkBdMzYYzX0osr7Hsr0sEAjylWsITmq1XDCFzwU9LFwWl35 J5Mg== 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=6vWxOeY7p82uUk8+zkR48MfJ74ST+TkRBLA0VziokAo=; b=HyrJxmkjm16ynP5pOrVx8EARhoqM2ycrbLXGgTZBXHeJSPI6SSrz9gCy0kdajN0l4E LaiIHBSAJVLbgdqQtK4M5RjCRrFHGd/P/UgmpASa1vq+XCc7FJ3P4YOy80HzVI5SwtcZ BHzN0GXVftLVxtdzvfgmVdBXCfCh/AVebekLcwtZdDi1afbb6avaifX9/G1+/dPM5K65 LzRTK2/WuWlI5E03S0wjw9lUINHODA2s8iBr47N8rVJaQ1BIoFYU13l66YPJstwxcue6 P2CFunaPxqApxX/AYCiwmXrqcaPF/V0/zOZkgKrX8TZpObrrkMTGZqZ+RPIknte6QqGL Y0cA== X-Gm-Message-State: ACrzQf0S40UoXdngcOTAp9cd9YGCgs15opI0GX5vtYn5uj56F9Smjt2K OkVLVIwTstHXUlQRQUTcOCfXDGU20Xs= X-Google-Smtp-Source: AMsMyM5MXUHYyDK2PK0iDj3F0TKuwI+mtto5ccr6byTJTmdoOmJMqRzH4F5HVZwIWNQr+hLqpW5vkw== X-Received: by 2002:a05:6a02:28b:b0:439:19d6:fad5 with SMTP id bk11-20020a056a02028b00b0043919d6fad5mr24832691pgb.591.1664276942228; Tue, 27 Sep 2022 04:09:02 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.09.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:09:01 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 53/54] tests/qtest: Enable qtest build on Windows Date: Tue, 27 Sep 2022 19:06:31 +0800 Message-Id: <20220927110632.1973965-54-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 --- (no changes since v3) 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 Tue Sep 27 11:06: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: 12990607 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 9586AC6FA83 for ; Tue, 27 Sep 2022 13:28:42 +0000 (UTC) Received: from localhost ([::1]:41058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odAdc-0006Xb-N7 for qemu-devel@archiver.kernel.org; Tue, 27 Sep 2022 09:28:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1od8Sb-0004SG-CE for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:13 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:33369) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1od8SY-0005Rv-H2 for qemu-devel@nongnu.org; Tue, 27 Sep 2022 07:09:09 -0400 Received: by mail-pj1-x102a.google.com with SMTP id bu5-20020a17090aee4500b00202e9ca2182so1281822pjb.0 for ; Tue, 27 Sep 2022 04:09: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=u9y0Bk8UpiQYdx0PAo4T1aykPjEhJnHejAt7vIOrx4Y=; b=I/dQ5UgNRqqYbWyvHcvtzVqiedIGeoPCLRGGZqLqLmzFeR7ruzU7dE2brQ1W9AxaxQ OkzJ3lr+pL6yc3qBKiOV+X0SUhBvtPjfdye6MX6Lgp893mv/IpCZbwf5LdDZlOwOnNwK 9QQWsPiRTxdABao1ZkgdOwu018Qvkfwoiimktb64aqiNRvUTTHYG3ZtD0PovCgjRLmua w3t4AtE1sjNB8rWHJavcXE9ct8o7cJeQn5DwEV+Coy6AyJoPtv9LggOaLsoFYWU5e4et NhV+EiaR4d7au2ixQTGyu0QMOhOeP8fR8cQq0bosNxdg9rKZBKP59l2qBqfY0VqVGKy3 HCMQ== 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=u9y0Bk8UpiQYdx0PAo4T1aykPjEhJnHejAt7vIOrx4Y=; b=6yPLACooB66VeWpH+XXhZ4VOgvR5kPuzNyfdR2CgXHvSUVwgelRXMTq6Hy/El8a6xw 2Dna2WZTRkPx5UYYZ3mTyuY44jhif030zM6xhdlik+uDhX6PDkDR48i4ppOCbl7SYizV VZQiQGEPeuU0o+lss+2imMz3LgOwH0Z/rooYRpCGbE5suI1WV+4J+ExcyLzts3uiM9mt CoQRXxOKbl+weP82r7u11wBDZ9/WcxI27Tiof+WYynmOGUqf7m1G/7TpGKexa6/ZMUEH /aS+GtWkkFzqJnVMUEMwLb9pyXmvX+UUIcKv0YXaJBhRKrMbdRj+A9C6EgIQwioms4x9 QzNg== X-Gm-Message-State: ACrzQf1KiLv82dZe/zb5otVHyScKQwuxlHpGHwzL0Hm5eHjzuH2XD3Vo NhJQng6H5S4Ejqk68GGNMhmo+Ur1foo= X-Google-Smtp-Source: AMsMyM623QEPzCgczNldclwfc5u1VQ8WXFgG/w1sVNca+cOZI0Q32ADW4wkxW/O+XBUBAU/mw+2DzQ== X-Received: by 2002:a17:902:f0d4:b0:176:988a:77fd with SMTP id v20-20020a170902f0d400b00176988a77fdmr26650054pla.25.1664276945129; Tue, 27 Sep 2022 04:09:05 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id i7-20020a626d07000000b00540f2323f67sm1453601pfc.95.2022.09.27.04.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 04:09:04 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org, Thomas Huth 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?= , Willian Rampazzo Subject: [PATCH v4 54/54] docs/devel: testing: Document writing portable test cases Date: Tue, 27 Sep 2022 19:06:32 +0800 Message-Id: <20220927110632.1973965-55-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927110632.1973965-1-bmeng.cn@gmail.com> References: <20220927110632.1973965-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 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 Reviewed-by: Thomas Huth --- Changes in v4: - Move the new text section after the "QTest" section instead - Use plural in both cases: "on POSIX hosts as well as Windows hosts" - Use "The following list shows some best practices" - Fix typo of delimiter (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..fbb98faabe 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -81,6 +81,36 @@ QTest cases can be executed with make check-qtest +Writing portable test cases +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Both unit tests and qtests can run on POSIX hosts as well as Windows hosts. +Care must be taken when writing portable test cases that can be built and run +successfully on various hosts. The following list shows 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 delimiter ":" 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. + QAPI schema tests ~~~~~~~~~~~~~~~~~