From patchwork Tue Sep 20 10:31: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: 12982027 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 66748C54EE9 for ; Tue, 20 Sep 2022 11:50:29 +0000 (UTC) Received: from localhost ([::1]:54046 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oablj-0005aI-K2 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:50:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaY8-0000Sh-Bf for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:20 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:40494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaY6-0004lh-5t for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:19 -0400 Received: by mail-pj1-x1036.google.com with SMTP id q9-20020a17090a178900b0020265d92ae3so10309547pja.5 for ; Tue, 20 Sep 2022 03:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=+1/ByEandD4GHa1nSQmGpBJTye5soxRUQPsqyjhWqFc=; b=SxFYyhHrXDa5p4cKqNw2mNIP4HOqGfZiW4vuSbioLVpLskSsv/ztgzj5xgaxAbfJsY bmC8xbGl0HyHKOF9rbSEOaTPI79W12Qk6qf2BFW+uom2ZY/GfsreIMB2Dy6bKMPNDAyh 8Yjof1iLMqiSh39iac6IDHb/wiHX5DD8XWkW5VdOpLeOInhczHDG9y9BGu+CPRPA9FmL v+N8Jhg/AW5nlUNJToKfHcO1gGRtUehbZ3WCG607R3b0wvRPkU5R8RPbXIEVdiDV7SSy R3zhH0FCGZ3lsTJ2Ejmvm3NpjBgF1BxBercUJj2bqH8QEgV8a3PD8erkOScnixdty3ve 6+2g== 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=+1/ByEandD4GHa1nSQmGpBJTye5soxRUQPsqyjhWqFc=; b=lIRZwNyNA+hucona6ZyQcdc8Kib9fJMPs+0H+ext9eNHLaomVPQc+t6RUe2qFufDKh ot497/T0ZARFvWV2RPr9BQGY5ufqUiHPzIemYEAvraNUfCmvqVyhoqKA7t6QF/fRNHFQ Z9ZK5/onn0V1FUWdqdTN8J9J7YTpSYQu9aumWNfCu8vlePuU9ZJakN0P3mC9VZTO5qmj DBj/Uco9P/gMFU58Y31C7dmh3x5zxRePSLA2J4mBg4mIW5vxeLZAWyU2SNQkiekl8OCz y3CUea76L2eDgJtVKSiOnTrR8sOcJRE8TPAX1XnTn2bpR21donaHLRHD4P391A2TVK2P L0lQ== X-Gm-Message-State: ACrzQf2jYatyhe3hgnsbCsOQW06sgEEO8tfeZVfNG9qO9BpjdZHXyJAX 4tlb1dtcqTCb/5U6+vQo2vzpFlS1fh4= X-Google-Smtp-Source: AMsMyM5T+4bxM5GK/bAQ0eEYtztW0CZOpiYiEZqGPMX2Dd3m0pPqdk2MSaGpYD2+DVlItZ2QMuQUqw== X-Received: by 2002:a17:90b:4ad0:b0:202:e01b:2dec with SMTP id mh16-20020a17090b4ad000b00202e01b2decmr3111378pjb.142.1663669936404; Tue, 20 Sep 2022 03:32:16 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:16 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 01/39] tests: Change to use g_mkdir() Date: Tue, 20 Sep 2022 18:31:21 +0800 Message-Id: <20220920103159.1865256-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_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 413bebc04603 ("tests: Use g_mkdir_with_parents()") replaces the mkdir() call in the test codes with glib's g_mkdir_with_parents(), but the exact portable replacement for mkdir() should be g_mkdir(). I probably was misled by the GTK glib doc [1] before, thinking that g_mkdir() is not a supported API from glib. But the glib sources do not support this statement. It is probably that the GTK documentation was not built to include all APIs. [1] https://docs.gtk.org/glib/?q=mkdir Fixes: 413bebc04603 ("tests: Use g_mkdir_with_parents()") Signed-off-by: Bin Meng --- Changes in v2: - new patch: "tests: Change to use g_mkdir()" tests/migration/stress.c | 3 ++- tests/qtest/migration-test.c | 7 ++++--- tests/unit/test-crypto-tlscredsx509.c | 5 +++-- tests/unit/test-crypto-tlssession.c | 7 ++++--- tests/unit/test-io-channel-tls.c | 7 ++++--- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/migration/stress.c b/tests/migration/stress.c index 88acf8dc25..76b91851ad 100644 --- a/tests/migration/stress.c +++ b/tests/migration/stress.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include +#include #include #include #include @@ -232,7 +233,7 @@ static void stress(unsigned long long ramsizeGB, int ncpus) static int mount_misc(const char *fstype, const char *dir) { - if (g_mkdir_with_parents(dir, 0755) < 0 && errno != EEXIST) { + if (g_mkdir(dir, 0755) < 0 && errno != EEXIST) { fprintf(stderr, "%s (%05d): ERROR: cannot create %s: %s\n", argv0, gettid(), dir, strerror(errno)); return -1; diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 4728d528bb..55892b3798 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -11,6 +11,7 @@ */ #include "qemu/osdep.h" +#include #include "libqtest.h" #include "qapi/error.h" @@ -761,14 +762,14 @@ test_migrate_tls_psk_start_common(QTestState *from, data->workdir = g_strdup_printf("%s/tlscredspsk0", tmpfs); data->pskfile = g_strdup_printf("%s/%s", data->workdir, QCRYPTO_TLS_CREDS_PSKFILE); - g_mkdir_with_parents(data->workdir, 0700); + g_mkdir(data->workdir, 0700); test_tls_psk_init(data->pskfile); if (mismatch) { data->workdiralt = g_strdup_printf("%s/tlscredspskalt0", tmpfs); data->pskfilealt = g_strdup_printf("%s/%s", data->workdiralt, QCRYPTO_TLS_CREDS_PSKFILE); - g_mkdir_with_parents(data->workdiralt, 0700); + g_mkdir(data->workdiralt, 0700); test_tls_psk_init_alt(data->pskfilealt); } @@ -873,7 +874,7 @@ test_migrate_tls_x509_start_common(QTestState *from, data->clientcert = g_strdup_printf("%s/client-cert.pem", data->workdir); } - g_mkdir_with_parents(data->workdir, 0700); + g_mkdir(data->workdir, 0700); test_tls_init(data->keyfile); #ifndef _WIN32 diff --git a/tests/unit/test-crypto-tlscredsx509.c b/tests/unit/test-crypto-tlscredsx509.c index 3c25d75ca1..03fa48a3c5 100644 --- a/tests/unit/test-crypto-tlscredsx509.c +++ b/tests/unit/test-crypto-tlscredsx509.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include #include "crypto-tls-x509-helpers.h" #include "crypto/tlscredsx509.h" @@ -75,7 +76,7 @@ static void test_tls_creds(const void *opaque) QCryptoTLSCreds *creds; #define CERT_DIR "tests/test-crypto-tlscredsx509-certs/" - g_mkdir_with_parents(CERT_DIR, 0700); + g_mkdir(CERT_DIR, 0700); unlink(CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT); if (data->isServer) { @@ -141,7 +142,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); - g_mkdir_with_parents(WORKDIR, 0700); + g_mkdir(WORKDIR, 0700); test_tls_init(KEYFILE); diff --git a/tests/unit/test-crypto-tlssession.c b/tests/unit/test-crypto-tlssession.c index 615a1344b4..356afbadfb 100644 --- a/tests/unit/test-crypto-tlssession.c +++ b/tests/unit/test-crypto-tlssession.c @@ -19,6 +19,7 @@ */ #include "qemu/osdep.h" +#include #include "crypto-tls-x509-helpers.h" #include "crypto-tls-psk-helpers.h" @@ -249,8 +250,8 @@ static void test_crypto_tls_session_x509(const void *opaque) #define CLIENT_CERT_DIR "tests/test-crypto-tlssession-client/" #define SERVER_CERT_DIR "tests/test-crypto-tlssession-server/" - g_mkdir_with_parents(CLIENT_CERT_DIR, 0700); - g_mkdir_with_parents(SERVER_CERT_DIR, 0700); + g_mkdir(CLIENT_CERT_DIR, 0700); + g_mkdir(SERVER_CERT_DIR, 0700); unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT); unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT); @@ -398,7 +399,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); - g_mkdir_with_parents(WORKDIR, 0700); + g_mkdir(WORKDIR, 0700); test_tls_init(KEYFILE); test_tls_psk_init(PSKFILE); diff --git a/tests/unit/test-io-channel-tls.c b/tests/unit/test-io-channel-tls.c index cc39247556..1d95c9f61d 100644 --- a/tests/unit/test-io-channel-tls.c +++ b/tests/unit/test-io-channel-tls.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" +#include #include "crypto-tls-x509-helpers.h" #include "io/channel-tls.h" @@ -125,8 +126,8 @@ static void test_io_channel_tls(const void *opaque) #define CLIENT_CERT_DIR "tests/test-io-channel-tls-client/" #define SERVER_CERT_DIR "tests/test-io-channel-tls-server/" - g_mkdir_with_parents(CLIENT_CERT_DIR, 0700); - g_mkdir_with_parents(SERVER_CERT_DIR, 0700); + g_mkdir(CLIENT_CERT_DIR, 0700); + g_mkdir(SERVER_CERT_DIR, 0700); unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_CA_CERT); unlink(SERVER_CERT_DIR QCRYPTO_TLS_CREDS_X509_SERVER_CERT); @@ -273,7 +274,7 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); g_setenv("GNUTLS_FORCE_FIPS_MODE", "2", 1); - g_mkdir_with_parents(WORKDIR, 0700); + g_mkdir(WORKDIR, 0700); test_tls_init(KEYFILE); From patchwork Tue Sep 20 10:31: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: 12981915 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 0B8CAECAAD8 for ; Tue, 20 Sep 2022 10:58:52 +0000 (UTC) Received: from localhost ([::1]:48160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaaxm-0001bd-Ty for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 06:58:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYA-0000Uf-Cj for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:28 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:39619) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaY8-0004m3-Ig for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:22 -0400 Received: by mail-pg1-x52f.google.com with SMTP id r23so2126555pgr.6 for ; Tue, 20 Sep 2022 03:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=3EiKA0nKWgy4YlkPlu/AU3W7YI8ulagrX1lAIm9vhNc=; b=gNww3WAv7cFZKACCnc0dsWKP1r+HJ+JgTD0o9Amv/k81gjfWD/JqbqlrX6iEY5APu+ 4HUsW04wpq/Ojxe1cuqe37OszDwJ03gwQkBIY0Xk9Q6Fn/vZsEBw/BOULHudBm/Xay+o JTV0zt5tXivjKNlAceNaqR+upa5g8Mv3ARBhLLejMRyAFNMTDZkVvNIVMFH5Mat6V2wB +4HlyFuqvRlWrdz5Dqk8xR/IjyLHeQ9k8G7yTomXRy7T9HZEqPLpck+NAHXEQkikkXdq L/72tHq00ZVaRamFh7s8K8jATJkSnq1PsJD5rsI8gekFiDZ5U1JubiA7o1cPc1fwxisQ GIVg== 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=3EiKA0nKWgy4YlkPlu/AU3W7YI8ulagrX1lAIm9vhNc=; b=7k0Z6Xg5qU1Jnee1r/tNi8/tcwempuszf5az4DAgCggQ9IttZ+pog5RC2MZynoWw4Q xH1Ve105ckQgoOLv5gh6zMGCLLyQYwUX8BfuHg9f/pfVVcBajZC/yFUf+n3/a91CCdbr qTVO0aWmnVlZUZ1Ii3N68qXUquHS67Lz7MtbhaIDmU5Vaa5t6AW00YliTswGIls1Q4Jl BrOXPJVf9P6GJfiQCEnk7MG4EzgS6IORPOiQcA9+MJ5P1wjoOfwwo9pNKMZdDWvUmOB9 Rhuq67gfGSaMSkZiFsCpPhUJ6nn5M21o4SSdnLc77qh/+dT4hcssr0VNe3R433rVk8VH w2TA== X-Gm-Message-State: ACrzQf3aNbBi0ohDXBLpSih0yJxfqAi9twmL1z4IR+lBwPbyDUdUyVca Ce6DZzwcqHUyLO2tQGnuD9kuy+F6gqg= X-Google-Smtp-Source: AMsMyM6hn/K6+U43uthMFPq4hTrjXpk4OPzBnKNCGrlWAd0+8oziWtqtPIXaTE3eXu0tN5GdLtPdgQ== X-Received: by 2002:a05:6a00:1d9b:b0:541:1894:d5db with SMTP id z27-20020a056a001d9b00b005411894d5dbmr23231779pfw.78.1663669939014; Tue, 20 Sep 2022 03:32:19 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:18 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 02/39] tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable Date: Tue, 20 Sep 2022 18:31:22 +0800 Message-Id: <20220920103159.1865256-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x52f.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 --- Changes in v2: - new patch: "tests/qtest: i440fx-test: Rewrite create_blob_file() to be portable" tests/qtest/i440fx-test.c | 53 +++++++++++---------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/tests/qtest/i440fx-test.c b/tests/qtest/i440fx-test.c index 3890f1237c..202bc6022c 100644 --- a/tests/qtest/i440fx-test.c +++ b/tests/qtest/i440fx-test.c @@ -278,8 +278,6 @@ 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)) @@ -290,44 +288,25 @@ static void test_i440fx_pam(gconstpointer opaque) */ static char *create_blob_file(void) { - int ret, fd; + int i, fd; char *pathname; - GError *error = NULL; + GError *error; + g_autofree uint8_t *buf = g_malloc(BLOB_SIZE); - ret = -1; + error = NULL; 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; + error = NULL; + 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 +377,6 @@ static void request_pflash(FirmwareTestFixture *fixture, fixture->is_bios = false; } -#endif /* _WIN32 */ - int main(int argc, char **argv) { TestData data; @@ -410,10 +387,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 20 10:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982056 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 689DBECAAD8 for ; Tue, 20 Sep 2022 12:22:49 +0000 (UTC) Received: from localhost ([::1]:36014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacH1-0004SH-TA for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:22:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYF-0000Uj-7i; Tue, 20 Sep 2022 06:32:29 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:55105) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYB-0004mS-7C; Tue, 20 Sep 2022 06:32:24 -0400 Received: by mail-pj1-x1030.google.com with SMTP id y11so2545343pjv.4; Tue, 20 Sep 2022 03:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=++8A+cTrk8kA5OevUgBZAOwhpsyp4kigQ5hSHOgI1dQ=; b=aIt61akS7rkQwFGGnHSKpJpxh6I9pgtgaoPNSg9RkwBOA4WgDaBb7BQNhwPPZIfPIK tM8oNZrQLp6ERHyzm3y5FCgLv/gL32gUisFV5QKD+LZTZNonfRC6oXeR1P6SYMKQDY0B 3XKOJm2DbqVWZVYufCbNWRwtsEi771zl5AErUkZ5bXPogrQdb/h1TSFVJJ6ZMTB1HQe6 GtNOOHayYNIzc2XpbY4HP08Z5mf+k5hB8ux9Qv0azyVANC1mNaVgn1a/XUdlnKFCdb9X Zz/scClBBI5kCXCE+xgCb76wIgRUyiPfWJdJC7y+UZTPziJmz77A/8Tet27xH2nfk534 pdYw== 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=++8A+cTrk8kA5OevUgBZAOwhpsyp4kigQ5hSHOgI1dQ=; b=hUU/nOT7vZRzRiDk2GwOAMS2q5zDAQ1D6xAWLF58HZ9i6uwtINwFL1vB81TsGolsPY mtfmjTDroS9iGDUPXUhuH3c1lCPT4+17TwYg6lGVp0Lwvg7xde83gs0NebjqEvvj90/5 v+V5wux+Hv4jpahrBasvhfBnT8paeFfTO3n2nC8P5iaN5QGTOjrqnAcMBs723kF8Obva eOqPzx6tW1J9khLEW04kWCgkJ00SR4L4WqUY7O4g/WtakEyZaCVNnM716wc/nPA0VzT/ wW0Q0peGeJ50xJH4vKdjBzQ1UXamqH4kCPH70YUB7rwzrRkC6K7rzs033RMi949yoMh2 KO9Q== X-Gm-Message-State: ACrzQf2TFLjXMakanlqYBTPtSwu4zkw9krjLKWppzT0cTaCs/p/1noXM nu+G2gJhEtuaqkHZ+WDCAGnSRO/mbHw= X-Google-Smtp-Source: AMsMyM4D/o9hXvQKSKCGe9ukUVSF8sp9ppnb1rXe/iJmw97pDPGMzN1GjxrM4n8GyNG47TdZV39TzQ== X-Received: by 2002:a17:90b:3b92:b0:203:a4c6:383c with SMTP id pc18-20020a17090b3b9200b00203a4c6383cmr3104443pjb.92.1663669941413; Tue, 20 Sep 2022 03:32:21 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:21 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH v2 03/39] block: Unify the get_tmp_filename() implementation Date: Tue, 20 Sep 2022 18:31:23 +0800 Message-Id: <20220920103159.1865256-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 At present get_tmp_filename() has platform specific implementations to get the directory to use for temporary files. Switch over to use g_get_tmp_dir() which works on all supported platforms. Signed-off-by: Bin Meng --- (no changes since v1) block.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/block.c b/block.c index bc85f46eed..d06df47f72 100644 --- a/block.c +++ b/block.c @@ -864,21 +864,10 @@ int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo) */ int get_tmp_filename(char *filename, int size) { -#ifdef _WIN32 - char temp_dir[MAX_PATH]; - /* GetTempFileName requires that its output buffer (4th param) - have length MAX_PATH or greater. */ - assert(size >= MAX_PATH); - return (GetTempPath(MAX_PATH, temp_dir) - && GetTempFileName(temp_dir, "qem", 0, filename) - ? 0 : -GetLastError()); -#else int fd; const char *tmpdir; - tmpdir = getenv("TMPDIR"); - if (!tmpdir) { - tmpdir = "/var/tmp"; - } + tmpdir = g_get_tmp_dir(); + if (snprintf(filename, size, "%s/vl.XXXXXX", tmpdir) >= size) { return -EOVERFLOW; } @@ -891,7 +880,6 @@ int get_tmp_filename(char *filename, int size) return -errno; } return 0; -#endif } /* From patchwork Tue Sep 20 10:31: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: 12982064 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 2FCF7C54EE9 for ; Tue, 20 Sep 2022 12:33:17 +0000 (UTC) Received: from localhost ([::1]:60582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacRA-00034n-S8 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:33:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYG-0000Uk-D1 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:29 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]:46004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYE-0004mi-SK for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:28 -0400 Received: by mail-pl1-x62f.google.com with SMTP id w20so1889771ply.12 for ; Tue, 20 Sep 2022 03:32: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=FEdN+sSW27vQj2HqDIPCCe75/V+zg2lWkY7ET+RYfyE=; b=owR0XYtOYHlNcQd6+Ebw8IZhx9l2yCp4nbjMcK2nLeh49qo1ZcixFv981UfXwTQQyF 2YTY/PDa/YYf2I8qEKOe7YjyFAO2TUNfrKSkrsTsMBp8xrLDTnoXoL05IsGlkLm702jB IBk4Il0FhfqcqNmEcMcjI3bhpB3lEd/3q232AEOCH55C1w4HmYulel1gMUUDHR0SOerR ftkp5/P6hvcKK8HFzNMwr6v5gQeQLGLcVLOaIFW8C9aWvNgUSv9+BEqCK53g1M5gg6Vi NahhOTgb/KQ0HzNHjApADlN4qbpfXdpdXlmhxXGKloVOf+cxwlZjc8odu52kEaBxQEuH /n2g== 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=FEdN+sSW27vQj2HqDIPCCe75/V+zg2lWkY7ET+RYfyE=; b=nOHnD4FmDWCm4LNqg8ST7se4vH/pztxgnI9ZUcCbDQG4Nr/iw5+Ye4FnzTrlGQsIQp nGlAHiHpwOKNXoBPbQ55f0z5WfsYxacn3dWRC6KNcTPm9mL2mKhizgXwEPhpG66Xp7Ri RtyUl31yICOl9YBB1dUIn6jLmtgvc6Twc3G79Kfg7w2COFFk/aKk6CYsh4BVhr2lp9E+ cDllGB1qzkHsNsUqNa9Tgu8xu0NAMyGANr4y/ptMkF/OrVIH4kKL7s6TWfwuofXVuna6 heVquFg16ZTMLh0Z8pkUpMWjwxCg1nMfkBg6YVftJ0pPB459VTCNrDJY+avQoTrdH9sP QAWA== X-Gm-Message-State: ACrzQf378qR18JgJJxuHulqs4gIDpR56OmzFM5mbAJ0t9yq/IsHhD9Yc iVNcdJa0vr5Pim0fwIA0g7qF03x7q6M= X-Google-Smtp-Source: AMsMyM5W4zWXP8hNiTidebU3occ8zruOKwoALiDLWG+05L+lC+IAetxU7EA8D+PUjMMVtGnR1sWfIA== X-Received: by 2002:a17:902:da81:b0:178:2663:dc8d with SMTP id j1-20020a170902da8100b001782663dc8dmr4239717plx.49.1663669943220; Tue, 20 Sep 2022 03:32:23 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:22 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 04/39] semihosting/arm-compat-semi: Avoid using hardcoded /tmp Date: Tue, 20 Sep 2022 18:31:24 +0800 Message-Id: <20220920103159.1865256-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Use g_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 20 10:31: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: 12981923 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 38769ECAAD8 for ; Tue, 20 Sep 2022 11:13:02 +0000 (UTC) Received: from localhost ([::1]:52882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabBV-0008Bh-1W for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:13:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYG-0000Uo-HF for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:29 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:44579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYF-0004mq-0N for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:28 -0400 Received: by mail-pl1-x630.google.com with SMTP id w10so1034641pll.11 for ; Tue, 20 Sep 2022 03:32: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=ziUPt4vlu90nlwtr3cIlBDD5brCudcYGA0pu4hMiODs=; b=koArTVPTy8wOD0AbhfeKTNUt0ekfuXQu1JxLmG8fILqfwdLgTYa7ELPJF5CbmjD8rk 0hwALKUedNE7I6luYfmVURA89Qk1VzM9Taoy2TOuHeyRNpfL+peHB/PMCTgqMJp1uXXu OZCps/JeesMLCRmCE/KEF+m3/bUV8j2RxLOxwu7GmtXKkzcggdrZ2AD4ZgC41LXvE8cc AlNjft0+Lw4lRj/iRUXogSXHmCr+7s3jjLc4aW3QkElRj3tTo3xrgZ7xUZCLpOeR4ITb zvbxMH26NMOLe1z6yahgGndxxqtanjZNmouwJFX16Y1sn8dZUnUivXN+4p7zgEMely4e FqfQ== 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=ziUPt4vlu90nlwtr3cIlBDD5brCudcYGA0pu4hMiODs=; b=zHC1lyZ841QEZUf668MnFnxQC7yhSnEvoVBU5T1yxWd3kj8SXzmo3/SgEfpRR4tN35 vcBAQEWHQxnsFpkLwO7A1tL5G+f5WRZgqAaNgWWNkH2WF6P8DeiuzcaSJTgnV3wN9BPD kUV2LGZyEwncQeLS34Rxe+Y/xqN9ghTGsizVNPdFTYkKTG1sXkLcRUf12Ppvsgukydx5 wxgMnxP08rVzVu6NHKlEvOIG5J55Ct7OnIp0MqKMUfrAQzGby5vX+uP82fktTvNtWCaz lk6OZ1VFHn20k2P4NbGQ6raHkXRAPBm23dmu9/O1JxH/nmrguXjWyqZfLoUmmNhMkpzR dOHw== X-Gm-Message-State: ACrzQf1kZL15hi7DLc45X+F9CeiwfcTIL75BHaqjCZfDMuxor3WYOm5j b/JDbGZG/phGg5rRoU5PCwGknU72mhk= X-Google-Smtp-Source: AMsMyM6Cv+FFB4vjb5RWX05dqAlC/jfe8+XQAqXi6ucseF3Gb7BYI+bza5iZANPWBT7NOuGIOcy+tQ== X-Received: by 2002:a17:902:f644:b0:172:b074:d1f5 with SMTP id m4-20020a170902f64400b00172b074d1f5mr4162942plg.29.1663669945255; Tue, 20 Sep 2022 03:32:25 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:24 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Richard Henderson Subject: [PATCH v2 05/39] tcg: Avoid using hardcoded /tmp Date: Tue, 20 Sep 2022 18:31:25 +0800 Message-Id: <20220920103159.1865256-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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: Marc-André Lureau Reviewed-by: Alex Bennée --- 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 20 10:31: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: 12982037 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 ABDEBECAAD8 for ; Tue, 20 Sep 2022 11:55:28 +0000 (UTC) Received: from localhost ([::1]:37390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabqZ-00072N-DG for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:55:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYJ-0000Vu-M6 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:33 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:40870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYG-0004nA-TL for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:30 -0400 Received: by mail-pf1-x429.google.com with SMTP id b75so2323271pfb.7 for ; Tue, 20 Sep 2022 03:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ptPSCcbuG++AcglR+Ify0H9lkcBvjcAqRFsbcccQhHg=; b=YplMeX+AByN6qSLzAHixowvrhYpDa+RxmExjk4LfkOzj11QAlPHZwEZCl90NBT/yar 514KQcFuT/F5yrmeVsvVkzSNhemgo1FdrxZa5XRqLED68EMGJ+FJ5/gPC1eiBTg68rSg tu8/NKuHNQpnXKOtVSyGT9/v7P5eAZfiI/di2tJfCb36NwTgiNOjjy3kn52l5Fh7tBKs HFen8t/9PCyYv97cnRTFiHRF9C5Ck9DCHH1lRi4DWUoIa1NRz46U14ADvXpRk/xrW6EB RgohjhIg2Dav/6q7IcORLpNB2QZAnEWP4OUZ30AjkhbfWCuGkEurJBY0D8CKdzVH2/Bl goNA== 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=jmP9NstlnaNUuqRIbUlaRsQ3RWGBhTK7dPW7875aF1YTlUHHsMvmJfEnWIPdh4KRY7 y1e1ygH2WUGUDdxLRKY4JED2/FU/wa39QQD0EXP12zcpg483/zgffWWh5GH1/EH6srK0 ZOL90GdirrTSEbdsAR8k2z3X5HYkU/kz7MYrANol32E8bqt3LC7lhXbwwaoa5Edgx6zX /kVAh91VR3OJ+qrvGjeayqYcU8YnKIOoUSKQWDIZjLv0x+EgSpPCZv3yuxgeovwI2Pca lRBVGweUEDCaJmGwHro535MCIi8OzP8Q4nNqG1qqo2tM43vK9/VgC/a7vOOtyxkaJgYR r8xQ== X-Gm-Message-State: ACrzQf0ROsA7kMelaZsyCiNz2T0mEJrD7snC/KqQV2HvFQJZoKUZbrt3 5sffesbYqhqa8vRdvyT62/S7c04/U48= X-Google-Smtp-Source: AMsMyM4PGeh14EDoXck/vy0HlLitjYNYhUvF92u8TeMT8KNgQWxy8nOzZViNeJl6KXhww/3GdN9YKQ== X-Received: by 2002:a05:6a00:17a2:b0:540:f501:ab76 with SMTP id s34-20020a056a0017a200b00540f501ab76mr22998246pfg.42.1663669947343; Tue, 20 Sep 2022 03:32:27 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:27 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v2 06/39] util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files Date: Tue, 20 Sep 2022 18:31:26 +0800 Message-Id: <20220920103159.1865256-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x429.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 20 10:31: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: 12982091 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 2B326C54EE9 for ; Tue, 20 Sep 2022 12:52:27 +0000 (UTC) Received: from localhost ([::1]:55726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacjh-0003c4-Vy for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:52:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYS-0000Wt-4W; Tue, 20 Sep 2022 06:32:40 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:55828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYO-0004nn-Cn; Tue, 20 Sep 2022 06:32:38 -0400 Received: by mail-pj1-x102d.google.com with SMTP id fs14so2541684pjb.5; Tue, 20 Sep 2022 03:32:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ZHSXXrvKGvOeBkr3kvmXfRkaYT5BXJ2jlSjdZ0qnFeA=; b=VlyLJxSn617o6HLMczfHDJmTlWKIaPRVsejbgYnV+lH+H3C6Tm2Nf8badiH5dikSMM imeq+11iKNZPoyC10aK8vzRGGgmr/QGX2TpFcP/XKbJFTaweKIM0iWSDLFdeN1/a84dM T2aiLQy8qYaPHbLio/l0xWYlGzPxfs1r3UFsWyhjjyPsEV5GiBgoIyFAVCBm+XKhMnu5 /b/i8R4rlviF3d4bX95eScy+zYgEs5eQDVHB4pHyZp7ydbLhkm9yUq8cuxiFjlPYYzGy isZs+ulUsVoH9qN78MrHJEf3aOxI1PalITsIFv4b2rboAPePKbWbaAXvk73OqUCoEvDE Y5tw== 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=ZHSXXrvKGvOeBkr3kvmXfRkaYT5BXJ2jlSjdZ0qnFeA=; b=ckEvQsOXiHzGBhRfqzMAZZk81AHRv7GPbzfD4ERoCDY6XnRpnZlC5tbid+VNk6iGwu MGlZ9fVEV9n2GLF9GM7hhO9jVLXMxv8GemGd6zijBXDm8PZAx7SiTL9aqUBKu5qFvi6+ gaKBOfWFf2z3O+DPCDUkm/uLpZqTzsogzFbonOy9+a0+o6SWVVwboyDejVjZce9HNZpR qOu2jimtvJUV4ng7ROWJk8ACBzbPTCxW5ub1t7GIa0GDQj++qOlcKfGoXYLvhm+FUqwj BITqozDSbiZ2RdQWDN7CC4FrEhNS8ORI06M4CiVZvtqcdg4x23JCxJCM7hz3sgtUCNvN WZmA== X-Gm-Message-State: ACrzQf1CNgaG36iTURBTMp6EpuTibA6Al9pkMGchqsao930rmPMIhXXN XE8FTbMNAQPuHj3/3y3SnNz4h3lDUj0= X-Google-Smtp-Source: AMsMyM4wKRpA92T5o6nQwX9PfoyS174iiieUHz7fRviLRqF5/pas38C6zrsCTDBTj+Fc1Jx7PCWESg== X-Received: by 2002:a17:90b:254b:b0:200:a860:5bf9 with SMTP id nw11-20020a17090b254b00b00200a8605bf9mr3102015pjb.176.1663669953907; Tue, 20 Sep 2022 03:32:33 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:33 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Alexander Bulekov , Andrew Jeffery , Bandan Das , Coiby Xu , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Darren Kenny , "Dr. David Alan Gilbert" , Fam Zheng , Joel Stanley , John Snow , Juan Quintela , Konstantin Kostiuk , Laurent Vivier , Markus Armbruster , Michael Roth , Paolo Bonzini , Peter Maydell , Qiuhao Li , Stefan Hajnoczi , Thomas Huth , qemu-arm@nongnu.org, qemu-block@nongnu.org Subject: [PATCH v2 07/39] tests: Avoid using hardcoded /tmp in test cases Date: Tue, 20 Sep 2022 18:31:27 +0800 Message-Id: <20220920103159.1865256-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 Lots of test cases were written to use hardcoded /tmp directory for temporary files. To avoid this, we update them to use g_dir_make_tmp() or g_file_open_tmp() when appropriate. Signed-off-by: Bin Meng --- Changes in v2: - Use g_dir_make_tmp(), g_file_open_tmp() when appropriate tests/qtest/fuzz/generic_fuzz_configs.h | 4 ++-- tests/qtest/ahci-test.c | 19 +++++++++++-------- tests/qtest/aspeed_smc-test.c | 5 ++--- tests/qtest/boot-serial-test.c | 9 +++++---- tests/qtest/cxl-test.c | 15 ++++++--------- tests/qtest/fdc-test.c | 5 +++-- tests/qtest/fuzz/virtio_blk_fuzz.c | 4 ++-- tests/qtest/hd-geo-test.c | 24 +++++++++++------------- tests/qtest/ide-test.c | 10 ++++++---- tests/qtest/libqtest.c | 12 ++++++++---- tests/qtest/migration-test.c | 7 ++++--- tests/qtest/pflash-cfi02-test.c | 8 +++++--- tests/qtest/qmp-test.c | 6 ++++-- tests/qtest/vhost-user-blk-test.c | 3 ++- tests/qtest/vhost-user-test.c | 8 ++++---- tests/qtest/virtio-blk-test.c | 4 ++-- tests/qtest/virtio-scsi-test.c | 4 ++-- tests/unit/test-image-locking.c | 8 ++++---- tests/unit/test-qga.c | 2 +- tests/vhost-user-bridge.c | 3 +-- 20 files changed, 85 insertions(+), 75 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 " diff --git a/tests/qtest/ahci-test.c b/tests/qtest/ahci-test.c index f1e510b0ac..00524f14c6 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; 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; } diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c index 05ce941566..5e16b5c9a5 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; 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); diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c index 2f99d71cab..ce6e3d3eb8 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; + char *codetmp; 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); @@ -264,6 +264,7 @@ static void test_machine(const void *data) serialtmp, test->extra); if (code) { unlink(codetmp); + g_free(codetmp); } if (!check_guest_output(qts, test, ser_fd)) { diff --git a/tests/qtest/cxl-test.c b/tests/qtest/cxl-test.c index 2e14da7dee..4f3ea76fa3 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; - 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; - 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; - 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, 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; } 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); diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 413cf964c0..4793954c19 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; + 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]); } } 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; } diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 7c9fc07de4..a0f28ddf8e 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; + 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); diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 55892b3798..9925691ead 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2435,7 +2435,6 @@ static bool kvm_dirty_ring_supported(void) int main(int argc, char **argv) { - char template[] = "/tmp/migration-test-XXXXXX"; const bool has_kvm = qtest_has_accel("kvm"); const bool has_uffd = ufd_version_check(); const char *arch = qtest_get_arch(); @@ -2463,9 +2462,10 @@ int main(int argc, char **argv) return g_test_run(); } - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("migration-test-XXXXXX", NULL); if (!tmpfs) { - g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno)); + g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs, + strerror(errno)); } g_assert(tmpfs); @@ -2590,6 +2590,7 @@ int main(int argc, char **argv) g_test_message("unable to rmdir: path (%s): %s", tmpfs, strerror(errno)); } + g_free((gpointer)tmpfs); return ret; } diff --git a/tests/qtest/pflash-cfi02-test.c b/tests/qtest/pflash-cfi02-test.c index 7fce614b64..55890b7d95 100644 --- a/tests/qtest/pflash-cfi02-test.c +++ b/tests/qtest/pflash-cfi02-test.c @@ -56,7 +56,7 @@ typedef struct { QTestState *qtest; } FlashConfig; -static char image_path[] = "/tmp/qtest.XXXXXX"; +static char *image_path; /* * The pflash implementation allows some parameters to be unspecified. We want @@ -608,6 +608,7 @@ static void test_cfi_in_autoselect(const void *opaque) static void cleanup(void *opaque) { unlink(image_path); + g_free(image_path); } /* @@ -635,16 +636,17 @@ static const FlashConfig configuration[] = { int main(int argc, char **argv) { - int fd = mkstemp(image_path); + int fd = g_file_open_tmp("qtest.XXXXXX", &image_path, NULL); if (fd == -1) { g_printerr("Failed to create temporary file %s: %s\n", image_path, strerror(errno)); + g_free(image_path); exit(EXIT_FAILURE); } if (ftruncate(fd, UNIFORM_FLASH_SIZE) < 0) { int error_code = errno; close(fd); - unlink(image_path); + cleanup(NULL); g_printerr("Failed to truncate file %s to %u MB: %s\n", image_path, UNIFORM_FLASH_SIZE, strerror(error_code)); exit(EXIT_FAILURE); diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index bf7304c7dc..0fa00c12dc 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -161,12 +161,13 @@ static void test_qmp_protocol(void) /* Out-of-band tests */ -char tmpdir[] = "/tmp/qmp-test-XXXXXX"; +char *tmpdir; char *fifo_name; static void setup_blocking_cmd(void) { - if (!g_mkdtemp(tmpdir)) { + tmpdir = g_dir_make_tmp("qmp-test-XXXXXX", NULL); + if (!tmpdir) { g_error("g_mkdtemp: %s", strerror(errno)); } fifo_name = g_strdup_printf("%s/fifo", tmpdir); @@ -179,6 +180,7 @@ static void cleanup_blocking_cmd(void) { unlink(fifo_name); rmdir(tmpdir); + g_free(tmpdir); } static void send_cmd_that_blocks(QTestState *s, const char *id) 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); diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d7d6cfc9bd..4e1aae1794 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -482,8 +482,7 @@ static TestServer *test_server_new(const gchar *name, struct vhost_user_ops *ops) { TestServer *server = g_new0(TestServer, 1); - char template[] = "/tmp/vhost-test-XXXXXX"; - const char *tmpfs; + g_autofree const char *tmpfs; server->context = g_main_context_new(); server->loop = g_main_loop_new(server->context, FALSE); @@ -491,9 +490,10 @@ static TestServer *test_server_new(const gchar *name, /* run the main loop thread so the chardev may operate */ server->thread = g_thread_new(NULL, thread_function, server->loop); - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("vhost-test-XXXXXX", NULL); if (!tmpfs) { - g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno)); + g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs, + strerror(errno)); } g_assert(tmpfs); 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); diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index 8ceb12aacd..073a89d535 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; 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); diff --git a/tests/unit/test-image-locking.c b/tests/unit/test-image-locking.c index ba057bd66c..d09ff43fcb 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; 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; 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; diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c index a05a4628ed..b73d231cd5 100644 --- a/tests/unit/test-qga.c +++ b/tests/unit/test-qga.c @@ -59,7 +59,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); 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 20 10:31:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982140 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 48DF2C54EE9 for ; Tue, 20 Sep 2022 13:05:04 +0000 (UTC) Received: from localhost ([::1]:50356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacvv-0003IG-37 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:05:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYS-0000Wu-CX; Tue, 20 Sep 2022 06:32:40 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:33568) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYQ-0004o1-SB; Tue, 20 Sep 2022 06:32:40 -0400 Received: by mail-pf1-x431.google.com with SMTP id w2so2383018pfb.0; Tue, 20 Sep 2022 03:32:37 -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=WrYLl9/VXe4gyeBTYZXcv9KC/z0Fg3KgFQTbTtkAnvE=; b=mnhR8h4tt7UyaJKmWEVvqB0nEpXrWtZtSQenvqPYfo7KTqqT3YbG3EV3ys2Q71tMqm ykfSAbPrqIVtGep9YMGOUVHyiDWP9BdGpAFviBm0z1w0KfSl4+CgiPwWZwCjffDKRyTP dGdNE7kHDLicHbR/qLMYhboTd8jUIcwUnWQlpGKVmodwA1jMEENFQuAJ0/twOT3OzhcB akecN1dS/SousXPDrvMm4HlE/7herxtlzA/8W4ABNSghc8yIqtY8rW3nOr32m0HlTbBf +B636/mQrpbT7o6SibcSpAusDL37Ys3R9Nmk/rQYfOmG2RbxjmDuJWZOhm/C5Vl2t2Qt HSqA== 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=WrYLl9/VXe4gyeBTYZXcv9KC/z0Fg3KgFQTbTtkAnvE=; b=2z45GSVry/kJ8JpGR8WPGpfI3GAoXi+wmIBJrMX5fBXTzvRuzQneBYJVdKy3u8K12i ACmUKfSzyZkb12N0WLHlX+x4OgAvDtl04A0TxJ67iBMd6pSIfmiOGqqDq4XqxKd+xiRl ksReBhxV1o06C1eo9eWd60l03OGaZTmfigRuwoAmxGrsCXGJd0TVOzqfjd8bHSZwQ8Aa +Bov9bp7uyNtDRba2zFsZDMw4vZPzgWZMrmATZ+WKIz8eYbZMGQXDhMJZFAyWb/O6F9X wsOdfZddle8gT59DmF7N9GkhS9TLS7kSmaHm7eIx6iLfRv5D+qaffYdp8C4ucfDd+qSS BEjg== X-Gm-Message-State: ACrzQf2ndGazBgT3HHh9UvJ2le1W3oFfFb/4af7bB+4RXp34ClS0CyJw o7TEvAKSK6yHbviXQfMErZO3uF4D4Eo= X-Google-Smtp-Source: AMsMyM7Yvah4QZTxSHcmfjAkK41p/oQitXwwpsig9Cbs1BhGp68WgTgcTp2jSCDvexw1t4PUJLi8sw== X-Received: by 2002:a62:7b97:0:b0:551:ab8e:d14 with SMTP id w145-20020a627b97000000b00551ab8e0d14mr1687440pfc.24.1663669956204; Tue, 20 Sep 2022 03:32:36 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:35 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH v2 08/39] block/vvfat: Unify the mkdir() call Date: Tue, 20 Sep 2022 18:31:28 +0800 Message-Id: <20220920103159.1865256-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- 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 20 10:31: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: 12982157 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 E907CECAAD8 for ; Tue, 20 Sep 2022 13:15:15 +0000 (UTC) Received: from localhost ([::1]:51332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oad5n-0002lp-2y for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:15:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47452) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYT-0000Xp-A5 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:42 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:33648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYR-0004o8-T5 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:41 -0400 Received: by mail-pl1-x629.google.com with SMTP id iw17so1960583plb.0 for ; Tue, 20 Sep 2022 03:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=TC94REF6/wVyMzkhGTjrwMtg+rAjCgxxkZ7wM7vEeao=; b=kZdITtmH6gBDVTAwQNPgrxkwsLVjqw0sYPXzTTQq0W7ld9tspaqgrD32K9r9yOTXqU X85q4Cg6j9FoqarltVlv7nwUcgjKR0uluLuadNNUEiYuLQLQxhkJY7+d4IoGmIqgLfQZ dltXpLRnr1PfwnU8J3KCaVCw7yE3g802BMvz5vYgiYAHz0Bo1/ZuUkQPrTjDa9jEDG8Y kYmGm5MUubxWaCtQu4kL2RK0p1RJZs6yL1NDjUbEx3R2BH5bN1+MK576OJpekv9tUupB shspapoB/IKKbOpy8ptoUJayGLZu6Tej0rt874kp8B1ZubjtFJRxpv91yf24c1Ubo7Ym BM2w== 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=TC94REF6/wVyMzkhGTjrwMtg+rAjCgxxkZ7wM7vEeao=; b=vZbyZM1M0Ck5Jj/YAQjZGO+i+9hOyciGX8lCK/ca/z0Ol8uIYrpNe5gMAEQtnizX71 gkHFS7vJZVd57ORJIuPOjMaPqSpoPJhur2dPnUJTPyuzDLhpYyWU0g3lh9XI37n1EbPj O4WA3pTKHkJyIrGIM9qPH4v7b5cSRB7A3Thf5GczDQs0ZLjqmSnoJDZLgHM7enTkvKqL 5wPHuUsGPmznXFsD09j/ROhIpZg0MLffrCKbAB1RpEgYzHDSAKZsZDFoeH8siRfW49JW 1L6jH6UXUfRQlQRJEB8zYpDhDzc6kbt7aqh5e0gCkWv4Q+4aK2bf41rJXQUdWDVRtogi I7cA== X-Gm-Message-State: ACrzQf0ZG5S6dbf7e1PjOttTpwpWRLno4O20ekdMaLVXywwne7EYhfQQ +Qn8FyFctCt2FrSdQOAVjPj9e2GZLkQ= X-Google-Smtp-Source: AMsMyM4BLP85HHCxa0PpeQljz4Jt5sRP5kzSm+G1ffysMEXZMcECgPcAqFIuoS25Lse++yZieX0CXg== X-Received: by 2002:a17:902:e805:b0:178:230b:57e3 with SMTP id u5-20020a170902e80500b00178230b57e3mr4291154plg.102.1663669958268; Tue, 20 Sep 2022 03:32:38 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:37 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Christian Schoenebeck , Greg Kurz Subject: [PATCH v2 09/39] fsdev/virtfs-proxy-helper: Use g_mkdir() Date: Tue, 20 Sep 2022 18:31:29 +0800 Message-Id: <20220920103159.1865256-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 Use g_mkdir() to create a directory on all platforms. Signed-off-by: Bin Meng Reviewed-by: Christian Schoenebeck --- 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 20 10:31: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: 12981931 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 4E03BC54EE9 for ; Tue, 20 Sep 2022 11:19:47 +0000 (UTC) Received: from localhost ([::1]:39826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabI2-0007oE-7n for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:19:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYV-0000ZO-DX for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:43 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:35799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYT-0004oR-TK for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:43 -0400 Received: by mail-pl1-x635.google.com with SMTP id t3so1930208ply.2 for ; Tue, 20 Sep 2022 03:32:41 -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=coJ7ma6necvrJiwyWuFb/EnkyqY+NtHLhvYBYm9zpZc=; b=iMTzXSvWXPotcsxeH6akDVLd38UH/G2zf3h+ctIhMaAVWgkxjqRHDKVa3+dOfxiTcr BMzx4KZfiPH85Lyl19r3QNuHTuqzxfrlSSgSqGUHZGKTlk6hS/h0LAncmEZ7DCQkSea3 9/XRoPzBRwnObZxtceRNBmYY2JlGD7zsGfddwd4ZeCOl55IeBoW3v8QjXzPH2tmxwKL4 +GTbCH6Z8av9r85ouYPMlmZ5k+JadrXRTGe8nEI4qg/wecNZUjTHxYeTcAK5GdTc9Yg4 QLw0832CpB9PoEKbgNGAuf4uBjE2cGVDfoYJ6H9AbcpqxJROgf86NIMicE9QcmP9csco XKXw== 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=coJ7ma6necvrJiwyWuFb/EnkyqY+NtHLhvYBYm9zpZc=; b=IDicGDNxwo/rVYgE6yEjnwPCPVoPaXH4foKjjvb8RN6UOP2H0BonGC6yjAGvDipU93 QIhlEBwNZFSrce/KYCKCZf7Q8p3LSzoJV1OdrYJjYC1Uqz8Ri5iM7s/ostyEZpZzmTto 4zTGRVpF+q0lMWTNh+Fuu5mAyDW8R/kJI9+RZTnINs3xXsfO1OZUmkphn5ozRBAtZSPZ rd4WNUcjLgTG58uU8sqz1Y+NMIGWeikttGr/acmNGhPCHUFnNBsfG0iNXMnd1mvoSra9 LFxZMM97Luk/LN1sCVhwtp5o4+gW+9XHiynUFWfq0hQXHM1mCqGH9ogZD32KSyz5Ba7g h0QQ== X-Gm-Message-State: ACrzQf3V4HrUrmcy5cOV60skIUwzU/qpZCTkXVXUeusu0yJD2ofDZXL3 gJ2b0vg4qzGLNmFNH+lv07i/nH2yZGI= X-Google-Smtp-Source: AMsMyM7gw0KpQMLFYqsUexlQ1HztbHk69BtGqfE5w8O8LWmOi7f9wAfofB/krW+MYrAdYEv8vkDPWQ== X-Received: by 2002:a17:902:7ed6:b0:178:378a:ebbf with SMTP id p22-20020a1709027ed600b00178378aebbfmr4173638plb.117.1663669960126; Tue, 20 Sep 2022 03:32:40 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:39 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Gerd Hoffmann Subject: [PATCH v2 10/39] hw/usb: dev-mtp: Use g_mkdir() Date: Tue, 20 Sep 2022 18:31:30 +0800 Message-Id: <20220920103159.1865256-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 Use g_mkdir() to create a directory on all platforms. Signed-off-by: Bin Meng Acked-by: Gerd Hoffmann --- 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 20 10:31:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982045 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 F07A1ECAAD8 for ; Tue, 20 Sep 2022 12:08:43 +0000 (UTC) Received: from localhost ([::1]:55060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oac3O-00062v-PQ for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:08:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYX-0000en-JS for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:45 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:40870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYV-0004nA-U5 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:45 -0400 Received: by mail-pf1-x429.google.com with SMTP id b75so2323925pfb.7 for ; Tue, 20 Sep 2022 03:32:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=f2VB4QizdnO1ty3hsujAoxHREmmGa+f2YtqepO1IVRc=; b=Ng9Uohh1Nv2V4DYxZ4NokJ9UQExzCzR+nZkmGtYeS0nrdTx5PxiRQKPKgGf/nT2Vhg wfMUaJ4VjF459X1TjtlOywWpDmw7tFVa+H9IzCr3WhF9VXb84AJ0GGHG9H80T59cic+A FTtHDAZQovh+dyN00YMBwCz8myyfETPrmFB/iNRmQHBS8ZFQgiPEYeoOUug/hEyMDaTs xRjTtMQs0qq8OXB6GEkf3OrpcscabCNXqKtjUtiOzpn7mBIcuw/w2fOtJYtuS0elecjI 28TdClVSwbRkNr3cEZEZuy2JbFRbTvH5lXgU6oviQf5He7WIrG/6NPKHuKEXMickAnbF XZeg== 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=f2VB4QizdnO1ty3hsujAoxHREmmGa+f2YtqepO1IVRc=; b=XuIaWyBBjxqtmTmsoX561CfJP2Zjbvq0DfZ2RV4JPKQ7mYkTOQGz9FdtE0Ad3mDPqk yz7HS0auGvvsrgONzBiPqYlQ3TEj3+JoMdT5zwUDoR/9n+U6HLJzKJz8/EyxkmPbohi3 ZgxUH3Z3aRgWC2hs5/iczRmPxMzj59UcEh2cQcP/ZPE1IB4b4DN+Oyx1ksYqOZlrJpIi WEsnaSyU1Q+WHu5ROuxACsccXrHp/ORTikyG+MLbIlTXVb4Y2l/KbMWPBhRT8eKOSApd YCvWYqRySer+OM4leFlx6FjgjneXrGriWKp/EkTaElGfutG7giLxblGXePv+voOWShsp KgHg== X-Gm-Message-State: ACrzQf2B1imwlhGIXuFgTNI0aSBXlThawZzAxzdTs1pHsaZ0H5UWOuQm 7ZCjbt2MYookkYfingLSwWjK55yzpzs= X-Google-Smtp-Source: AMsMyM66QAW/4Larv0SGFfxs0M6Ya7wd9DkpjlCx8OHkWFl5CKjn/bfeIcegOHnH3hknIV+t+Cbv2g== X-Received: by 2002:aa7:88d0:0:b0:542:d98d:bf1f with SMTP id k16-20020aa788d0000000b00542d98dbf1fmr22819961pff.78.1663669963104; Tue, 20 Sep 2022 03:32:43 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:42 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Jason Wang , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 11/39] tests/qtest: Skip running virtio-net-test cases that require socketpair() for win32 Date: Tue, 20 Sep 2022 18:31:31 +0800 Message-Id: <20220920103159.1865256-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x429.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 --- 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 20 10:31: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: 12982063 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 44F23C6FA8B for ; Tue, 20 Sep 2022 12:27:24 +0000 (UTC) Received: from localhost ([::1]:34426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacLT-0006xn-27 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:27:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49936) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYa-0000kn-8T for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:48 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:35799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYY-0004oR-Fu for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:47 -0400 Received: by mail-pl1-x635.google.com with SMTP id t3so1930398ply.2 for ; Tue, 20 Sep 2022 03:32:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=NvXJmEVVDbrEpYS0xV/yTQ9UhV+ab4oZGiarDXwYoFw=; b=oz+n816d2XTEDmC/2FtICQO9l3tfq/gl7aNwwuTjSZTzidgbV71hr1c5f8fNwuOoME TXyhgCL6zBH4VE/k8tiGPm/ZpLme0MuZPjOz4DYKCtTF81a8D82LwCN3V06W/DFRNGil 1mzFLJofjIbjQmzCEMzCrBVT+dGG7tANdJE+muW6r4s37cplCte+0Q0HH1WSHUc/DjWx jlhDG4eEYDPTydGJqyRBSwDWNBkT7xmRa9x0PqqggJwMPH2DpC2vrEAZv9sBPDjHojEq VQ2pJ5matjJE8GyUPHojhd6QWvP9EeFXyI4UrJxac/F0VePzGDHFlCMeYQAgvjyHABu+ qnNw== 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=NvXJmEVVDbrEpYS0xV/yTQ9UhV+ab4oZGiarDXwYoFw=; b=rezqOc15EoPNCN6GJgl0RN/UGTFVm4lQhMwoHWvERIkyrq4rcJ2ICv/PMMFTPEJ4e6 vhEW0JuQf457p9BOaDTjsEh/QxP95i7pL5KxVkNgoyDMuwBDDlVs0HHaKv0UY4ICfMTc FiX0E3h43o1nzFpRtdODASq559BRIHg0vJ3TAlUoHEIaKG3xzixhy7FliJ6l9/Fdkm8T Vw36h1hQg1j6xy14uB9JjgN9Nw6IWQffekt7dT88Pg16OcZqLzLVCmXM9y5cAZdJd+5c 5+3ewUOrHBmVCNeMjuNptmgIbQPQthkOhnPXzJYr6TtD++CdTOtFtKm5I183L+z67v4T d0mg== X-Gm-Message-State: ACrzQf2wBY3hP3mjeuAkErqE6LLYBMjiX4oUSeXAuLnKLhgqR9KfNITX COwiU9JFnTNHlYLfI5Ztx0IvZofitdU= X-Google-Smtp-Source: AMsMyM5JIiHeGT8a4Xj79LwP/QBsA/QxXOaMCX+4/4nb9OaJTfd8bkRTKYcXyHvcNbEO7fqCDIBMoQ== X-Received: by 2002:a17:90b:4c92:b0:202:fcca:60ae with SMTP id my18-20020a17090b4c9200b00202fcca60aemr3256130pjb.52.1663669965646; Tue, 20 Sep 2022 03:32:45 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:45 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 12/39] tests/qtest: Build test-filter-{mirror, redirector} cases for posix only Date: Tue, 20 Sep 2022 18:31:32 +0800 Message-Id: <20220920103159.1865256-13-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 --- 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 20 10:31:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982049 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 06E52C54EE9 for ; Tue, 20 Sep 2022 12:13:50 +0000 (UTC) Received: from localhost ([::1]:45454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oac8L-0006xT-IE for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:13:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYd-0000uQ-GB for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:51 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]:36447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYb-0004p7-R3 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:51 -0400 Received: by mail-pg1-x52e.google.com with SMTP id s206so2134814pgs.3 for ; Tue, 20 Sep 2022 03:32: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=n/8pblQrtAbp24OYjcBCAChq99vs2kPOZwnELezy5us=; b=N12jsS/Ad0YiknumIwkSjmwjEZ2Nvz/Uo1zW1f/IOAI3He/i6tcBobmfPufQfdBUPa PkJ3LiINcb5M4NZ8BrP+VwKLc0dS3leg8OO8SbguZ21TIU9WGQ+W2zEaxMnf7rpQXmpK o+IOjEKiLmiIGdb+hKDRq8EL769NvVNnj//p0RpoZsDR9oTPqX7xcXa8ngvmhEkiC7W/ G3TjRKTZBJlzkxZcyNrF1mCpG/UiTh/iTw+7fFVvZ5I2h6fYPfhDUxFIm25ojTE4OBux HzxIhV0V33jxdOXFfplXTqsoMny7v3piu/kjOrSa6d/NtwIfmcSP+y20XTMMDfkwXuWb 2gZw== 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=n/8pblQrtAbp24OYjcBCAChq99vs2kPOZwnELezy5us=; b=lBf4HreWDMo1tM3EMUc8MAfUrsHetB6GQspKRZ1e/kjtUXq1qxTxFHlU07rzya2PKu 1sLRecBduU7lsTmfTeHunZgCBo8ZvECjb/06lEQhaHm7RqVy15aXA9Ih4JNUcKrrDwoy WPer6dMrEdW0uez42SE8eyfAP7Sjs3e9p8p490EruEGuM08let/QX6cErgTUc1IrnFtH 1EN2nXeDyQiqFZvzwoNVWCtaqHtjls3kSt2QcFmHf6liUZkBppd/PVbrHqUE0sBP5ABw /GKLZiyrqPTc9xmxaVl7A01fuqQaP60+NuroyU8NxdqsTMDqFzbVSV6Kxh/LonCS+xN1 XU9Q== X-Gm-Message-State: ACrzQf0LWGMNuLGnu2OpmVDsRn5wzN4Bs3cGa09U/JSFeEyBbjkfkwZs OXOocAMYpTRvgBb4PnDlIKiRlbllidw= X-Google-Smtp-Source: AMsMyM6MwVsyEdNfiBH8jo5xNzs5kyUK4wYTvSTnMlIopd8u7awgie0gtzozMHgDTsdcNMPRT2Hfeg== X-Received: by 2002:a63:1d1:0:b0:43a:348b:63fd with SMTP id 200-20020a6301d1000000b0043a348b63fdmr6087738pgb.52.1663669968163; Tue, 20 Sep 2022 03:32:48 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:47 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Thomas Huth , Laurent Vivier , Markus Armbruster , Paolo Bonzini Subject: [PATCH v2 13/39] tests/qtest: qmp-test: Skip running test_qmp_oob for win32 Date: Tue, 20 Sep 2022 18:31:33 +0800 Message-Id: <20220920103159.1865256-14-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 --- Changes in v2: - Add a comment in the code to explain why test_qmp_oob test case is skipped on win32 tests/qtest/qmp-test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index 0fa00c12dc..074953fdf0 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -159,6 +159,8 @@ static void test_qmp_protocol(void) qtest_quit(qts); } +#ifndef _WIN32 + /* Out-of-band tests */ char *tmpdir; @@ -279,6 +281,8 @@ static void test_qmp_oob(void) qtest_quit(qts); } +#endif /* _WIN32 */ + /* Preconfig tests */ static void test_qmp_preconfig(void) @@ -338,7 +342,10 @@ int main(int argc, char *argv[]) g_test_init(&argc, &argv, NULL); qtest_add_func("qmp/protocol", test_qmp_protocol); +#ifndef _WIN32 + /* This case calls mkfifo() which does not exist on win32 */ qtest_add_func("qmp/oob", test_qmp_oob); +#endif qtest_add_func("qmp/preconfig", test_qmp_preconfig); qtest_add_func("qmp/missing-any-arg", test_qmp_missing_any_arg); From patchwork Tue Sep 20 10:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12981932 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 85670C54EE9 for ; Tue, 20 Sep 2022 11:26:28 +0000 (UTC) Received: from localhost ([::1]:34604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabOV-0005iz-EE for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:26:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYk-00012K-PT for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:00 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:34592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYf-0004qa-Fd for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:54 -0400 Received: by mail-pf1-x434.google.com with SMTP id e68so2348834pfe.1 for ; Tue, 20 Sep 2022 03:32: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=coajynULDWAZNTjpgIFLrJ318DUJeq2ShOj+5RVWOfU=; b=d+IiRzmYuYKe2hrRuikwivDRvOiQdahdViwE9HTaaKgB1467f7gTCC3rampmnvY1bu kKGXJq6jwkC39mcTNlIuJL7QIPLPyoiDRW75e2UEx4+rC1THVJCN24320vr+vQTsbIh3 CUJdGjIq6UDI2MQNs2KOScMQEvSxHVRrqXObNlQt7z5SaVptddDCNwcBg8wIkcYo9i0/ gWry0Uv62KfbGuFAnIdLRhN0Iz94Cw3XR/PRXD6qYyP6R4jKxv95fjcI38zK1Wy5fEjk whyHEUWRxaUcIAUJn1MOlnBjhx+dh3fXQcmjNZmwNkqWCFcCGi3kFVm0V+M8sskt5BPL LPvg== 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=coajynULDWAZNTjpgIFLrJ318DUJeq2ShOj+5RVWOfU=; b=Htn1yC5d5g+Amj39DlVZNaZCJDQGdmxYw5uPjy3Kc/cjGYDfF8ZwTj00K6cEPJ6IgR 9+Ui32XkPT4A5Cy+v2xx4fpQObo8A3PKcsEFbkURzucshV4+yuI2u6I0SkS77H4u/Dr9 GnaorWCY1v7DHwQZ3s9V5T/O42o2T04S8SW9+g+Yqme/kXQbQdqx603RmD/lc8HkiZ8Z gfHnlLOKRxpWs/Ti1q6jLP6F4+D590lzsteXf1xbo+kHvDKkRfn10dPi+E3LiKhBhD3V mf0WoXqQasSJcCOE+GMxrT2BZiDBdEqptCjs+p2wdwftwYO0X1yMASFRWSzV0fzSRHF7 AJ4g== X-Gm-Message-State: ACrzQf2Uqamsw0rovljIIXITQD5c6DVoX1TEr0vzVv7LUth6QC4St3Jh jn+u0sRsqIsZ96RRy9ceIBhNh+vDrD0= X-Google-Smtp-Source: AMsMyM4OdfXFzQy493NueRy/+P0k9lvDYLNVo6xMITTPPug0KBUzlpoiJi+wrsZpNVt0dKAr3GBNyA== X-Received: by 2002:a63:e306:0:b0:42c:414a:95e9 with SMTP id f6-20020a63e306000000b0042c414a95e9mr20352222pgh.139.1663669971978; Tue, 20 Sep 2022 03:32:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:51 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Eduardo Habkost , Laurent Vivier , Marcel Apfelbaum , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth , Yanan Wang Subject: [PATCH v2 14/39] accel/qtest: Implement a portable qtest accelerator Date: Tue, 20 Sep 2022 18:31:34 +0800 Message-Id: <20220920103159.1865256-15-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: 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 --- 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 20 10:31:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12981940 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 CB3E3C6FA8B for ; Tue, 20 Sep 2022 11:31:30 +0000 (UTC) Received: from localhost ([::1]:57504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabTN-00039x-I7 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:31:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYm-00012X-DL for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:01 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:38737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYk-0004qr-GR for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:32:59 -0400 Received: by mail-pf1-x42a.google.com with SMTP id a29so2324862pfk.5 for ; Tue, 20 Sep 2022 03:32:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nlrLQubH0zzQT8NxHWeyyJtYXWvWCKu12s8Ktk8w2tQ=; b=ftKgyd3PlC5XPMzRVRca1T6EI+6fMn/Ww5us72GqSb3RmEv4AZvWY4Tn8X4Fz7GYO6 FKzc1AXv0O+4viqCEdi2Eyoqz3xmkwTlL4USrKyscMa1BHq4Y3AvNwE2a31QesABsmGS X5pY9GERrwcI9p5FRy5lx2gMfvU2Y2j+UI4W0CH1y15zbtxgKj2d8p1ufVr3wBdP9to1 NiZknwF/s5xXDgoOBR+cOI342PO47SIMSS3G/cgteJjgZdeMcRoMkz7q95zf3XIk8p6L gSGSLruR7OtlBtpYHMAaOWVPw8+JQkgniQCydW667ji2JTbmB8CIwLPA6nwgoUrDBQWX 5dEA== 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=nlrLQubH0zzQT8NxHWeyyJtYXWvWCKu12s8Ktk8w2tQ=; b=NbIk0vni4DXi6iuxwUDdKtOWhB6RtmerOgoiNALB7hh/SP7kudljMDr8332F5Sj0UD +PC2kMKUVBYC++cW7PTBhl04aYoDMTX5gLxY2TYK1a1/zFkJ4cvRllzYpQ6skyFZXg+Y AGVyduUo93keAJKYQb2lh8RFYxbu9yse+9xjZ1FsK13x5wNquv6aOYVx349v8lDyqAm7 mRbXqORuIAM9dFO05HmZQ38mm+hzR6AezCr75bcU/8XHepbNBQOthifVISm+E2unTcRT 0zdKKcxLktzfiPOc8htVX80drWw2R/KQXz7j0pWtg9yul1sPHB3bk2ogKGDOfaG27ezr Iazw== X-Gm-Message-State: ACrzQf3/Qsz48ubiDQpVbmNlQG8OTrjC59H6/Ajbs2fYoIy881HrL7vs ck6RjWfB6/XIJypR4WSc4YtY6uQpLkM= X-Google-Smtp-Source: AMsMyM73Insw5mptND8kRsavJ5yKVouk+byOUbBQmpLul8jAW21PyL6jaE1fNiSX0arvDO1KuNFANg== X-Received: by 2002:a05:6a00:1781:b0:53a:8572:4453 with SMTP id s1-20020a056a00178100b0053a85724453mr23578849pfg.76.1663669974560; Tue, 20 Sep 2022 03:32:54 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:54 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 15/39] tests/qtest: libqtest: Adapt global_qtest declaration for win32 Date: Tue, 20 Sep 2022 18:31:35 +0800 Message-Id: <20220920103159.1865256-16-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 --- 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 20 10:31:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982057 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 1E65DC54EE9 for ; Tue, 20 Sep 2022 12:24:55 +0000 (UTC) Received: from localhost ([::1]:35394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacJ3-0005d1-VL for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:24:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYo-00014Q-HY for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:02 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:44906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYl-0004qz-5I for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:01 -0400 Received: by mail-pj1-x102d.google.com with SMTP id i15-20020a17090a4b8f00b0020073b4ac27so2015147pjh.3 for ; Tue, 20 Sep 2022 03:32:58 -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=bbLaeaUcnrqs4G10jLV3MgXG0ekzESqKda4qvIcsJ/k=; b=etzPEDtbVhhxtaj79nNwWJ57RmyzdvePZmYI1xTzzLyfGGBh4orgwNPlkuzTaGJ9nL iyU3l1Q5YNGBYOFktvgN9fZxIIVdK/7gPtibyDmNzUKaAoqpmtDbT1sPfJXZm+mITMgM aX+qEZLArRSvsUCVHsyx15OCZsx6yKBAjwsW29mrSMqZymmH2M4wSviJoaoo2y+ZM8H6 FbjubL1czpwVi7/LcXX1LI+BAP6yj6LlzVTLXWvjQLGRa1dACfUyp0mWPlT4vcXbMBC/ vn9m/o/axqNYepQTSyEIKk0nIn0KWtsu45YizO0PMKakR8RxYXzN8+kQQGbWc+GH4iiC iWBw== 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=bbLaeaUcnrqs4G10jLV3MgXG0ekzESqKda4qvIcsJ/k=; b=kOkpfyUJU37RxKaiclkocABy9zqs6sbRPAEedNGYF1bjtXz+RzC8qqIOXiDD9ZfWSv GVNb36Cj9Rp4rXyXEoTczyZP9pigQ5zhqHCeiJv6JazYCs15bkeR9ckH28h879PNPG8c ab6QSv17FjGr9RpE7L3Kyq6XVoO7GjKAQYSmcOhI3x+ZwypNh9a9/LcjgxvrZ0CtTM1j OtQf9sjmNRnYlojJ9AKunCbkr2ARxG5D7UaAurVthEGq6nU8xYIPWmb5pTsKefba+nC8 TW2+YbBD3GKRce8LRU0T/5x0H8jZFE7Z49v3qXaQ4yFhY+DzGTPFQaveTUovvEVCFklD yPYA== X-Gm-Message-State: ACrzQf2BmNoy6GZFT9NKs2cwOz8xdi5DmRU8bnFUbTKQo3zzwPaLyhg2 4iTa3MYtODI0SXFvvchpNlYDw20/zjk= X-Google-Smtp-Source: AMsMyM5XGfzNbPHgQlVsfWMnwlnAj71cBW+jiHY2n+0/KfgDWc6tJN/r3RvpdB3JRjVhozKdIPBtLQ== X-Received: by 2002:a17:90b:1c07:b0:200:9728:b8cd with SMTP id oc7-20020a17090b1c0700b002009728b8cdmr3211788pjb.139.1663669977530; Tue, 20 Sep 2022 03:32:57 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:57 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 16/39] tests/qtest: Use send/recv for socket communication Date: Tue, 20 Sep 2022 18:31:36 +0800 Message-Id: <20220920103159.1865256-17-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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: 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 --- 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 a0f28ddf8e..a25a8b47d0 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 20 10:31:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982050 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 47327C54EE9 for ; Tue, 20 Sep 2022 12:14:56 +0000 (UTC) Received: from localhost ([::1]:58078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oac9P-0007or-2h for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:14:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZ4-0001HV-Sx for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:24 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:40935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYo-0004rK-MZ for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:17 -0400 Received: by mail-pl1-x62c.google.com with SMTP id b21so1907530plz.7 for ; Tue, 20 Sep 2022 03:33: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=3+yjqfv6z1umkAWfalloUAoEl8FsRBb1xm1eNDtEso0=; b=L1nAIht+b9lFj0xxHkiUDxNNOH4b8FTSbuSy5qBeiwkxOlR1ETpuvFB4HRPzSnEpO6 oAmSVauzlhCaJV4Na0e43zaVQkeB3Q31VRZ1qEIBsRoTfMps+4KqI/Zaov1G3MdC/HsU 4aE6r/86UBCfAw9G4qxqMtsuDgcFcURXlU6sXHJP13JVKq28iIgdROuanWWBbEajN+1G gsfQ8RDplTQ2Oax3d5Ef9JnyD9sUqFLS+89og8845/xppemKv58FiXRNN0F350Xv7PX3 y304OczfpSdZlfcJ8uMvn0iFlaKE3vbKQpQRTXDxkHlhqQVjGpAiXCiX47Xtv7IEF8yl EoKA== 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=3+yjqfv6z1umkAWfalloUAoEl8FsRBb1xm1eNDtEso0=; b=dw84hAAV3AYj2iNG0QRzi8UMcjJNG3+R/JIVzNH+JxzzWEmkv9qn0/pxGpL0u/nBK2 8ikKIZH+9rnQdCMH+G1X0Qu0KRXYab5V5NxQWZ7uf1l4zF+Dm4/va87UwFr8UyVSz6Ht 07C0GHt9QdUVLVRKvlYSwYc4+hi0AMkSbFxV1Q/k/rwsP+H75JYyRDYIQbsTYFcWOUWt pZU5H3b99sJWvxolR4lceEvvart0nPECqpDYgnFalU/HgFWmuuwsEeFJhoBnWzSHDgu/ J0f9+P4hZCR3O074mhreY/hcwzgtIbIwH7XB6bHti7hfWZLw8OpjdtGdwzxohdQDLfyV cNNA== X-Gm-Message-State: ACrzQf0ZTWgTFWC9xR86VYGmfM9mC1c5YJTv687nvo9UzbgrCU70alsu cnP84/189roT+Tk6sWWWAK+6xMKX2sc= X-Google-Smtp-Source: AMsMyM7A8MNTwdwHpbK3Ege3oHVhcCDSU5MeEI4CWrMDr/Z/5L1jGSVPSgOp7uYc7lV/k4t7w5T4AQ== X-Received: by 2002:a17:90b:3615:b0:202:a996:c9a3 with SMTP id ml21-20020a17090b361500b00202a996c9a3mr3181461pjb.111.1663669980115; Tue, 20 Sep 2022 03:33:00 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.32.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:32:59 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 17/39] tests/qtest: libqtest: Exclude the *_fds APIs for win32 Date: Tue, 20 Sep 2022 18:31:37 +0800 Message-Id: <20220920103159.1865256-18-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, 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 a25a8b47d0..8b804faade 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 20 10:31:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982067 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 269E1C54EE9 for ; Tue, 20 Sep 2022 12:41:08 +0000 (UTC) Received: from localhost ([::1]:45226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacYl-000735-0z for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:41:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYr-00019R-Rf for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:05 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:50918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYq-0004rp-3Q for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:05 -0400 Received: by mail-pj1-x1033.google.com with SMTP id fv3so2613936pjb.0 for ; Tue, 20 Sep 2022 03:33: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=UN6281p/RMPF4xkeiz72JCfUX7VJgvaymIo+YvmfI5M=; b=Pl4nL+OROspIT4xVNOd6xGli+Lr0M7xBeE2hrpktOPNeTY0irRCNx1/9e0Y1P/y81O hTiXv4+ZMq9LybX8LCeQGRQ8u+FKzAR6QvaBg2kv1fJ3ZSPKw/ITSHRFUCMScLHQAwMk lmLrwjKKJbNgkoIgTNpwOEEYDcLmAGTjcq6xcs3SJlHfQGQFBqUK0ZJCPO1CuQ/9X/KW PEwAcTsSnPGRf43ynfLPLTSo9ZmGfx125kp3FyHJLk8W5FLYzxdErA5+s6Z+dNtnPHZ1 oQXv/KAlHO/aIzFyOvj1ab5PBOlFc4iaLYlBez7HyRBkG8OFqKbmZXxsUhSYxTqGjfSL 7+qw== 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=UN6281p/RMPF4xkeiz72JCfUX7VJgvaymIo+YvmfI5M=; b=BNiObB4WU81eE8RNRrXuqDobpJBVRPUMNwftjrcGASlRQBy7AThiGBLdNiMrU8noAs 3JOpFR13O32HGAwDrqzAY8BIHsJy3As8AMikdiDf0wzKG0/W1gHEcmxRRuEhkQuz5Sdy FlRBkpTHa/ow0YjEL/iY6fA5HMHnXjimcEZXApzQeGooeD1DrqKJnWQ9FroKbZnLo1sF bncfxPZfKZGwfO1KGqLLdUBK09hw1QumaT1TmA4LDEoRaLQZ7aeDOpPP2rQuTTovP6sF 36BRoKE6gANapwq7cAE5zDW/hQaolEn07QE/RqklJgZtWOIp/QdFsRP7/Q62I4YO5JbB tveQ== X-Gm-Message-State: ACrzQf0PMN2exqh50pXclNHWwRyMiZsgWjFUaoV1iaYpWgxN3URNSziG 3srCXcgEX5eIFJUQ2tQULetmx/6rEJU= X-Google-Smtp-Source: AMsMyM7T07HrEX1URbETQF4vnxogIO1duWPZvZYCOmemqDQFK/QTHJRXqKDN3I4OotXh8dpYaATRQA== X-Received: by 2002:a17:90b:4fc8:b0:202:a340:3594 with SMTP id qa8-20020a17090b4fc800b00202a3403594mr3250965pjb.149.1663669982463; Tue, 20 Sep 2022 03:33:02 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:02 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 18/39] tests/qtest: libqtest: Install signal handler via signal() Date: Tue, 20 Sep 2022 18:31:38 +0800 Message-Id: <20220920103159.1865256-19-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 --- (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 8b804faade..f46a21fa45 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 20 10:31: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: 12982013 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 16496ECAAD8 for ; Tue, 20 Sep 2022 11:44:42 +0000 (UTC) Received: from localhost ([::1]:39000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabg8-0002TS-V5 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:44:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYu-0001F5-0c for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:14 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:35799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYs-0004oR-2V for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:07 -0400 Received: by mail-pl1-x635.google.com with SMTP id t3so1931109ply.2 for ; Tue, 20 Sep 2022 03:33: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=WYQlajQUVwXtj6f4EUMSJptSU8tvZHrRokVsALeNJ8E=; b=JEb52/bFKhQWzytjZZsOpVdlS0LnP/k4bOSWPJefXry/wH3atR030NDpmSbgSlftug TVL+WNWrP16bVvu+jgq/1c3yigUhyxonUQlbpZOJC3aiHNftCQZ1J2e4fWvwzyBM41OD U92LFHg9PSf6cf5WAPn4vZ32onsjDIdp82gbsMJbp9GcyCviK4mKwkozht6VRjCEDkuZ WhFFYhoi1dlt4L+fb00qEhrYz43yOfFjAh8Dq1pgjUpFibaQyQQLoV8WcFlLrYh3Inlb VMpNQsBKT4Y3gFYOnTXh7Mu/7kvUrqQOO18wioYFKf10i8JVYQQiB+j7jrEKDPu9ZYPZ vfdA== 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=WYQlajQUVwXtj6f4EUMSJptSU8tvZHrRokVsALeNJ8E=; b=pC67oCJy3PlZ6bm2LlxqQa13NrJerIUya4nJDfbpQDYbZO0J0DwV328/liW3oAOF4m LS3ncXYIqdGfG40x4TiV/lPW/roxONAEN3//FVWyBwTqAK9ZUiNt1m5WUemEaQBzHJV8 6qUfsuc4wUKWq5j51t2VHVb4hNikouBoS2tDae6upMuQQGgnpHKyt4rVFSqp30rVUpSk mH/iGVddEEeC585qF4fZdYeS9azmVRke5L2HuvwMrAElHW3kU9dyD0pilv1IY0HGiYSY PEDpWXYNbX0G7qB0peaWjPvbvL8hDxqtNKn940xQFSk9BCjSDpWIMHhPSXmC2A0JCmD8 zrgA== X-Gm-Message-State: ACrzQf1aqnZEn74LQgfVZZauEJMwHuSRtuqiS9S6OQzX2NjRLMQt0p0I NBy2s0qI5SkE8yCDXRqn9mGZ/VTbLLs= X-Google-Smtp-Source: AMsMyM7xt35lkmXBio+D9fZN3QXwkkH8YRo2Fhf05ogJAz2N4YwamOIgrojAbQ3Xm8NRY+Foy8gbgg== X-Received: by 2002:a17:90b:1b4c:b0:202:c1a3:25ce with SMTP id nv12-20020a17090b1b4c00b00202c1a325cemr3258708pjb.232.1663669984960; Tue, 20 Sep 2022 03:33:04 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:04 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Xuzhou Cheng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 19/39] tests/qtest: Support libqtest to build and run on Windows Date: Tue, 20 Sep 2022 18:31:39 +0800 Message-Id: <20220920103159.1865256-20-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 --- 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 f46a21fa45..5d15e39289 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 20 10:31: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: 12982041 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 3A1D1C54EE9 for ; Tue, 20 Sep 2022 11:57:59 +0000 (UTC) Received: from localhost ([::1]:33700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oabsz-0000Kt-Qo for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 07:57:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYw-0001Fc-UB; Tue, 20 Sep 2022 06:33:14 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:39743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYv-0004td-Az; Tue, 20 Sep 2022 06:33:10 -0400 Received: by mail-pl1-x62c.google.com with SMTP id f23so1913371plr.6; Tue, 20 Sep 2022 03:33: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=jtL1ld++/OCzVIJFT5yXHbwI8YvWyRv4L77Tp9zf/fk=; b=DZJqdhk2/vkAabipbG1uAo4xyZ6BxFx01vgh9Tx5/6ascDRXRiEpULaTUGQQW44wa4 rXa1wwwmaIYZAUwz13HuTrK6gR8oI8oQR91M8vKX3v5suUikAjYY1Tr5Qs/cgoSjMrs9 cWY8f2Ts/WUlQcSJvUO3QuzEfa26nf7U0kPkO/WZCokRokLqAFU/eZ8M37oC7Aai6KYP q6DdBhSuqHwfiuY9VFyrptHkAh7uJNWZ/A7pdKR1OCu4Sq4jVlNZpraWrCrq0jbCZMgA aVeqS0IpGpjTzgwtnijrZhaV5VY0H5YUZasHYoSmTqHZmtlhpYOHgqAoKZFMdVHZhAWD rBFg== 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=jtL1ld++/OCzVIJFT5yXHbwI8YvWyRv4L77Tp9zf/fk=; b=UYmTb25YN50XHqH1IxNeLaOpQqWFh9qlCwMeLXmARjmoeDR3IDk5NEazQO293adAjV qJ5u/WskvMOlDenMY5sOZeKoUH9N3YRxNXp2NY02+iB1JgubqOfZm8sLRX5u3AzxH8Yk djBJfERcqXvHgCEMg1gI2YUJbVZ82Tv8YqHo4YaL9YKPv3CIOWXaKwDCd/6TXhG9dZG6 2CkKTRpVqoZFI33fSGehQSB//fQ6KVaKQAquNXloojCnmrVsy35B4x2QA2/PtPI4a65q Ft9uucvw6ryjv1uB+FB4f+wqAU3yD3ScJTdGgF6lak7NysUGBQTuVU/5Jv6Zn/QzFp2z HdjQ== X-Gm-Message-State: ACrzQf1pJKiWX+1C1+F5653EqBmuCWE1uZIrR7ahkuUUUk7hzw6bpbuj buAw3f09/aIL/LmNglFuybTkAY/FH7I= X-Google-Smtp-Source: AMsMyM5NIvKu94KAxcTzy3EWsvZ8C/wOaspT0bpoQ8hHV9aEC5W/zCr3OFmRSEJccWBhxjp2b74P/A== X-Received: by 2002:a17:90a:8688:b0:202:91d7:6a53 with SMTP id p8-20020a17090a868800b0020291d76a53mr3187724pjn.153.1663669987724; Tue, 20 Sep 2022 03:33:07 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:07 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v2 20/39] tests/qtest: {ahci, ide}-test: Use relative path for temporary files for win32 Date: Tue, 20 Sep 2022 18:31:40 +0800 Message-Id: <20220920103159.1865256-21-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (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 00524f14c6..c57576b08c 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 20 10:31: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: 12982127 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 62AB1ECAAD8 for ; Tue, 20 Sep 2022 12:57:21 +0000 (UTC) Received: from localhost ([::1]:52258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacoS-0006zL-3i for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaYz-0001Fd-9U for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:14 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:43545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaYx-0004vn-Nk for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:13 -0400 Received: by mail-pf1-x434.google.com with SMTP id d82so2302946pfd.10 for ; Tue, 20 Sep 2022 03:33: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=9tH0XQelG4h53nQLUxLgD/rlhScUl0glQjhN+BQBZaE=; b=may/k8VT5aBSFNfh67EyWDnZwzgnB1td1Ar8yB26DGXiPmtDrAZNSaO5dDl9QWfsos oMX1nexrH9zoUeQkYQIuK7ZBitIB71YO3YN9xR5M99tYa3P2tee1GEb8T/PQ51Vejzyo yX0Sl7ZhSu0vCS0i0IfIOPuisRHAGZf0pOUk7MYOO01EYHm00wiPeQ8Ct3mz/050ujq+ 6P9qnwnTGH0ShK8EGI1PxMPT8RmZAfx99Ug/kFK18jjSIboj2GCqlKCbhZ1TjgfZUl6h IzEBG4AU9ZBuo43NakBFNUg+Rl9aWy6Wf9CPw4uwfB6PhnCLiye+Ng+CHmA/gFnVVW/j Cfug== 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=9tH0XQelG4h53nQLUxLgD/rlhScUl0glQjhN+BQBZaE=; b=hreY2ayKo8KBqp2AeN4OP25IBKYVGE/QhrPR1NmRr9/K+7seG3p7gO5J8zqNjC1yx/ naeA9HEGACWWJOUO1zAC8nDKh4TOgFJz/XW9GWs3dN1JYAI5p8DgFdkR7wrKgaR0d9b4 e2WvVd6TEd/D/twck0eZyhkTS1VwfRp9UuM8LgogAQQfxrvVWn/l9xWcMduv8UgKQR8k vb0rFV/OKaDeYIA3DCcUtIDNXO+TSDoVSz1wgvf6JApp9OPhxk9xLeb0BppIbtm7fUK2 RHg4w7XSHgk4AtfBBDJAlj7cVMoCYDkQuXU/n9R+aen/fCBfDt8yADtjtkpy2rRiCFl/ W5Xg== X-Gm-Message-State: ACrzQf2zpdJQ50H1xcTyLDoARBQfkQy86wejlpiV1tzq8YpQlWpmDKVT mDDUfv5quoVsnnuojsIEdfkIbDsRhHM= X-Google-Smtp-Source: AMsMyM4Mzda9R1mKBREDPqLQu4ZEU0ih/QKcxvJ9cHfZj0PsqWgpKMqviNwx252QeHjDSY0kbHOh0Q== X-Received: by 2002:a63:67c1:0:b0:42c:366f:e8fe with SMTP id b184-20020a6367c1000000b0042c366fe8femr20029441pgc.198.1663669990460; Tue, 20 Sep 2022 03:33:10 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:09 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Ani Sinha , Igor Mammedov , "Michael S. Tsirkin" Subject: [PATCH v2 21/39] tests/qtest: bios-tables-test: Adapt the case for win32 Date: Tue, 20 Sep 2022 18:31:41 +0800 Message-Id: <20220920103159.1865256-22-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- (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 36783966b0..0148ce388c 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 20 10:31: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: 12982150 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 42638ECAAD8 for ; Tue, 20 Sep 2022 13:11:34 +0000 (UTC) Received: from localhost ([::1]:44114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oad2D-0005zU-2g for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:11:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZ2-0001HF-EM for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:17 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:41820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZ0-0004xP-Kb for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:15 -0400 Received: by mail-pl1-x635.google.com with SMTP id p18so1908593plr.8 for ; Tue, 20 Sep 2022 03:33: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=NRgpn8UKlLeZRK3O++E8fem4Ty/tJxVKgPqLLc5aG4c=; b=glAD/IZhxEcFnpja1UtXQZLuIViM9IvgwUNhPHqgzVWzJXSJ/13PGhSfLa+73QjYpn xdBFbyZXifD8VUhY2ZoNqh1Y5/HZzH8ulQQ51ezg3FWjn6ym0sK4DIT7WDaBXTUcD52u o5qw+ob+0wKzTDWEeqoAUEOseJkwHRxCej2rPaRJjLYKogvdS+dAMfFJQuz5eHanc8FE RdI0kgQXt9ha56+2eEgPCjUovXyD5mU0BH2l3rMBsRpCyS79xXpP4mA3xrVloHCPgDEo 1j8GBmksVHBGrg7KWpyDblO6y31QL5e/WoNlYCmeKIM3N5vt+RVGSiu0UjP0riGhLz+Z t/ZA== 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=NRgpn8UKlLeZRK3O++E8fem4Ty/tJxVKgPqLLc5aG4c=; b=JkC//52HkRjcYIGqfms9eUpbKouzjrQSb5BTZMPldg83eREdRH2z8+73xfKbq84JxQ Amc0+1o+aTyGOD257rOdFWdhfhIEzYVV9k3C0lm5R2xKV7OaVeqUUodXKC3jUYsKFW32 q3ouRFnxQoqOgHpMxA056ioabtHh1PF18gFoQRFn4aCU+XFRXq0VJz4XO5WpgzOEwSPq CmWRSReK/WtolAgeQLXvKhyIEx40ISsUdBpaxyFbUgnjZQeyPbSgtkOykuh5/gLW9kH3 c5XTOEvKyzGuwp0/1uHenELg2ECBWZVCnGaexAiaf1ggAuTItx8q7xWtTNyhSAmFRvI6 odjA== X-Gm-Message-State: ACrzQf3iR0qc4dZx0o2YidcXyk/bz2FouBINNVKZz0a5nHdtRZWdx2OU a2MeJWShh/TFnRoN91+vdGnXZ01iGZA= X-Google-Smtp-Source: AMsMyM69UDXr/woFpJVFapBPB7NQ70ZJMwYOzBUPqvn728D4q++c0jvUj3aRZeoliKnsVYBh2Aj3gQ== X-Received: by 2002:a17:90b:14d2:b0:202:dd9c:4e98 with SMTP id jz18-20020a17090b14d200b00202dd9c4e98mr3148067pjb.62.1663669993180; Tue, 20 Sep 2022 03:33:13 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:12 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 22/39] tests/qtest: migration-test: Disable IO redirection for win32 Date: Tue, 20 Sep 2022 18:31:42 +0800 Message-Id: <20220920103159.1865256-23-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 --- 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 9925691ead..c87afad9e8 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -648,7 +648,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 20 10:31:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982170 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 59FE8ECAAD8 for ; Tue, 20 Sep 2022 13:25:21 +0000 (UTC) Received: from localhost ([::1]:38184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadFY-0000by-Ez for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:25:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZ6-0001HW-9k; Tue, 20 Sep 2022 06:33:24 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:46823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZ4-0004yf-Hf; Tue, 20 Sep 2022 06:33:19 -0400 Received: by mail-pf1-x434.google.com with SMTP id c198so2286036pfc.13; Tue, 20 Sep 2022 03:33: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=awzAMIJYKF7cu7o7r8nJlieLkv87kMXItIakOVnPH/c=; b=blStzgLayCuQDhLDYUk1259pcgLRKrsM5b8rslWM2S/MNQuLITgNoaYp0UP1QHPhh+ L7XEe2ICMVCNC4Y0tpKhh7PE33duLRdkoGBL7alYQZbfsIzVwznHS5bhY7RzNzfMgkrj Kd422nUwTABhZ35HKeSwpg/fQCPx5wxC3CJO3yrDh4Lm6cBNdUEmP1ycCc3jB3S2xBOO o5hyFEVigMpTnfsw9BBlRNDOAaI2yIYIQujSr6vvilGAWUUoRkT0Z3iw1gnaoW5JgYzw 7+th69B7BZ8Uob1BKPwvcCU4Z94Yfy/ZvKtk7awo1Jju7760d+Vu9QFwUaNtI4ex2sQv 6ADg== 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=awzAMIJYKF7cu7o7r8nJlieLkv87kMXItIakOVnPH/c=; b=BTRT+CU+z/rWOKt34WQ4UzuBqV/1VN5Zj4tpebhnr2s4OA05X4r9mwJI+PjDuClYbv IH4JXNSjeHpezErAQkSbWjHEYeatmGoZiDAG3P7F2/B7snujD24joVm3B6GL7w6ABbcg SzNMaoLjB2e/gk1cv9AbSuNnCrUTiScjzvB3UsvF6jPuYw43p+pIUJkA0EjM7GBHWL8P EzZGd+5tnXW2H9JrahkNaoXzdhL/SO9ivX2rlH4fH+fCCx0I4qUc9QV0gEsftxXkSXmB KTtAG2012dCuueuwosOia3r/dWjR/fFYTnYH6ThD6RmKbboU87Q2XAdOYhrA1OXuIYHn aaXw== X-Gm-Message-State: ACrzQf2O0qOPCOvEd9MhXN/RZOqsVTQNvywBUfpLoRKPNrFEtOi0LSgy ajrFy8IBLV2NatsiffDqXZdJn4UDc8U= X-Google-Smtp-Source: AMsMyM62c82JH7BgmvavokMPLnsy5RD1mi4J/HqKY0BPSUce56sAON8irFvr1KGzMGzDckRgUpSLpA== X-Received: by 2002:a63:d309:0:b0:439:a5df:c64f with SMTP id b9-20020a63d309000000b00439a5dfc64fmr19966790pgg.278.1663669996380; Tue, 20 Sep 2022 03:33:16 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:16 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , John Snow , Laurent Vivier , Paolo Bonzini , Thomas Huth , qemu-block@nongnu.org Subject: [PATCH v2 23/39] tests/qtest: ide-test: Open file in binary mode Date: Tue, 20 Sep 2022 18:31:43 +0800 Message-Id: <20220920103159.1865256-24-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: 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 --- 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 20 10:31: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: 12982173 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 50E93C54EE9 for ; Tue, 20 Sep 2022 13:30:49 +0000 (UTC) Received: from localhost ([::1]:38688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadKq-0007Cr-54 for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:30:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZE-0001I4-NT for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:28 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:35488) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZ9-0004z1-4X for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:24 -0400 Received: by mail-pg1-x536.google.com with SMTP id u69so2141992pgd.2 for ; Tue, 20 Sep 2022 03:33: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=bEwOXOJ9Zq3iyxOAwW3me2XI/Y7DXiJdYrVP5pYxEfc=; b=nwDCQ7dknbqKRyq4oqh1GsGFjx/JhszMKRX6pmCjn5wbUu9BQKXfeA2ExPGCZupijR lF2ik3qeSEdRwPS2IvmHmwAtFGGSOE6qRwsn6NWHgroGVoE9QfH0q9oJg5vkmEDs53h+ UAvwFYmwf9yBTvzL74TyOW3NX47MV8O1MPdkeT2SFawlfE4ODahnmuSbSdNOSrbzBLrF gRDZEjXDgCV9tnQc3P/pyiueYZ1CT6JxMwnXUsywqRoIt5c9lotw0PSMQbyOTFn2FZgl 1HGK7Cszz0U8c/7q24Nh0QNuWZLK+bwTDqfyER1+fTAOSu1F7bss9wXjYu/dJ4LmIQ+z 80sw== 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=bEwOXOJ9Zq3iyxOAwW3me2XI/Y7DXiJdYrVP5pYxEfc=; b=rHejCfNCupdyolJdrbmH53v/fHFwjw1H7cxdAghWZm7f53d16GZ/ss0YpbPX+vq4Bm /it6iduCvosDAH02CZZZUJfiGodA0eBnWCx16W7UpHAyAJMjt5ukxZq4L6BOCUwkGn43 IBKF2J+KdYT+QCz/gFxALHq54yBeInkp1GcGOM1ep/xBhTUDpmq+cjiwQqZrSRW7Ndc/ GW7kg1Ct5abDZEZHCwWAnYPY47n6ht7YY1ZcAsiCqvw3+hqqj2Gc0Q3npRyehDt8yX8g dWUVuEWK2sgacf8uwxRMEhEZ1KVpHSkpnlJQop8LnHS1YLk2YDXaOF0qCf5Ll/5xtgu6 TalQ== X-Gm-Message-State: ACrzQf1BAkbZE3EGWmg0eGLtjBaRKetoZ9E5bidf7o0FNY6Hn/H2Sj1X DMeDQDB7XDT9BOv8icS6wIZUy1w2zlo= X-Google-Smtp-Source: AMsMyM61t+RNs6Q0+/fgC1UQzTtIY6EGfFAEeXsqxyXUiG37qMrYg9Fh1M4c8wBZFl0RWxEVcsGj8Q== X-Received: by 2002:a05:6a00:4c91:b0:543:646e:9 with SMTP id eb17-20020a056a004c9100b00543646e0009mr23030881pfb.40.1663669998878; Tue, 20 Sep 2022 03:33:18 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:18 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 24/39] tests/qtest: virtio-net-failover: Disable migration tests for win32 Date: Tue, 20 Sep 2022 18:31:44 +0800 Message-Id: <20220920103159.1865256-25-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x536.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 20 10:31: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: 12982065 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 8F460C54EE9 for ; Tue, 20 Sep 2022 12:36:35 +0000 (UTC) Received: from localhost ([::1]:59598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacUM-0004GJ-Er for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:36:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZE-0001I5-NW for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:28 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:33585) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZ9-0004zF-4b for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:25 -0400 Received: by mail-pg1-x531.google.com with SMTP id f193so2171122pgc.0 for ; Tue, 20 Sep 2022 03:33: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=I4w8ZLcZpvp8/NNOmL2eCZPj1DbnvXOQyYE4DsQCU8c=; b=Ro01hkOaAa6m0bCs8g1QaKxd116SNNMZkiljZruAsnDqW07aK0mazXd7xMXPABV0RC ez6y2ApS3ds6Hj578bY4hsFsNCxRH3uLnecH2qHhvH25oCMfrQRj3ScGmVCTDdus4abr KPQvZURldiVx+8Gn3ADTsUgk5pexSuFjC3KmqqrPdtl3YDOgw1CVf/BCGv4CzHai4IJL Q8k45/scufAl13L2ILkrhdopIEuJNVDDrnQYS5S3p3PfW5xB4qZANbS2DyoO7QoAdHFd 9SLvJ9Jc9EN+/SzwOws1dzioWvC8/09dykNoKoerfJc+7KnAGJJh8sC2IQ0qbqxYW9aZ q6RA== 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=I4w8ZLcZpvp8/NNOmL2eCZPj1DbnvXOQyYE4DsQCU8c=; b=6ePceuab8mLaAYfMPDVpo0cdA8Hu6RglEx1N2xZLTqyHVf6HYJ4DiTavGYpDCgwUAf 6yZ5PzWy8FbACd2208CVp3jrAtmKFkJ6Ta5DJKH3JFUCziP5OG6fiNdVJ0m1ZptzecFw GgObHRQmjvimcGHo1AYDUxMkmVXmTymSE8z2BDZNLir5gCpreVOVLqg9BKDJZ0xNugn3 wVin0ckmBLH7K3qwoBYUiUfcD0RIlMOcu5NlWJgjJ66lhTf2iJlX6ED8Sn2dYMsiytQa wZ83L7vg+uJAoGba13Hp/pwJMpZax+kTTXM3DvEWvDdIVMJaxjk9KmpIhovpyJnPKzUP kVyg== X-Gm-Message-State: ACrzQf1+7FJ7/Kn49QktE6nDYO+cuNQqwlif/bHhi6275VJ2/3jR2zd8 tOZ80fePcPnHZRJHp6tJTuq1Y3YsHyU= X-Google-Smtp-Source: AMsMyM5CdY/o+YHFx8y1h5MDJEhAJ5M+Tc7Wb9zDBZep7oy+un1N/ds6xK3U+YCbgvFT+MnxOA3AUQ== X-Received: by 2002:a05:6a00:1823:b0:544:b4db:50c with SMTP id y35-20020a056a00182300b00544b4db050cmr22275547pfa.33.1663670001159; Tue, 20 Sep 2022 03:33:21 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:20 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini Subject: [PATCH v2 25/39] chardev/char-file: Add FILE_SHARE_WRITE when openning the file for win32 Date: Tue, 20 Sep 2022 18:31:45 +0800 Message-Id: <20220920103159.1865256-26-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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: Xuzhou Cheng The combination of GENERIC_WRITE and FILE_SHARE_READ options does not allow the same file to be opened again by CreateFile() from another QEMU process with the same options when the previous QEMU process still holds the file handle opened. This was triggered by running the test_multifd_tcp_cancel() case on Windows, which cancels the migration, and launches another QEMU process to migrate with the same file opened for write. Chances are that the previous QEMU process does not quit before the new QEMU process runs hence the old one still holds the file handle that does not allow shared write permission then the new QEMU process will fail. As per [1] we should add FILE_SHARE_WRITE to the share mode to allow such use case. This change makes the behavior be consistent with the POSIX platforms. [1] https://docs.microsoft.com/en-us/windows/win32/fileio/creating-and-opening-files Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- Changes in v2: - Update commit message to include the use case why we should set FILE_SHARE_WRITE when openning the file for win32 chardev/char-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chardev/char-file.c b/chardev/char-file.c index 2fd80707e5..66385211eb 100644 --- a/chardev/char-file.c +++ b/chardev/char-file.c @@ -60,8 +60,8 @@ static void qmp_chardev_open_file(Chardev *chr, flags = CREATE_ALWAYS; } - out = CreateFile(file->out, accessmode, FILE_SHARE_READ, NULL, flags, - FILE_ATTRIBUTE_NORMAL, NULL); + out = CreateFile(file->out, accessmode, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, flags, FILE_ATTRIBUTE_NORMAL, NULL); if (out == INVALID_HANDLE_VALUE) { error_setg(errp, "open %s failed", file->out); return; From patchwork Tue Sep 20 10:31: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: 12982160 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 A9269C54EE9 for ; Tue, 20 Sep 2022 13:21:40 +0000 (UTC) Received: from localhost ([::1]:54754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadBz-0005Pw-NV for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:21:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZG-0001IL-2x for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:34 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:39743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZC-0004td-OF for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:28 -0400 Received: by mail-pl1-x62c.google.com with SMTP id f23so1913932plr.6 for ; Tue, 20 Sep 2022 03:33: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=5JX7sGU3bhekd0+rl8Pgr+ORxrbUqYd0iNFII92cHyo=; b=kr+z9l8g3SvLJBwnCGpAxOiAMYCgCZG4eh+lDcL4FkyqE6RAFIpzMBjP0ASS0i2XAj J19mSKiRsW13dokt34Z4iBbzJIkS+DwLn5CaxIRxy+rS26Kf4xZK3fbqfvHLjvW1bMFW neAuQ2tgiLg46ZRih29o4upOLzXsyReR1BTQGBHMG7Qp6GjSyAWl889Tc5bVqmqIWkQQ X934lzb5CODXuSwWPQIPpwtdpUgN9lHoCaewwUQuWzdgg0lx3NRefxKN3jIomhEcTDs1 p87Puwh0EJelZieKhVz/1DfRtEFp+BwOnOZZb3LN0vT2Ci8ZiSarCk3OrmxbibqxQpE8 c5Zg== 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=5JX7sGU3bhekd0+rl8Pgr+ORxrbUqYd0iNFII92cHyo=; b=CaYNxOkOFFWdBc1ZpN/FH0s7WVhc58YtDQNvm3kGIP+6MfoqhxGlAbCf8pBX3Q/pJC l1PMwx6pfxqx7IF4p7eqC/+nGAs7mS8zzqTnthkimq9iRHtKMO5eELJXZU6Qzsb6coqI Mgm3Kd89S0GP3AvwYf4Ax9/tIYF4xH7ZHJ00QOlpZsYCQDRjd2DAmQ10t9z70HjHIoGm aorjGtDSpjntG8qQt0L1PgrFK2oOfr8b9rO7kZm8JzsOn0Z+QzXyLjHYok+E1fM35yga X+A68LbjNtn0OKnIyO2Xczlo31Qil/YyIAwG0VxwvM2rkVlnweDtk7FCcnqJStlBm7MF Kh4A== X-Gm-Message-State: ACrzQf2tljysK2SRCLzCpFd/5o9gmQz+0uElPJvgmGh+vDiMnLiOK8mQ beCgPSgzw5zXuOG72hizGdSzId5CFrg= X-Google-Smtp-Source: AMsMyM4wrPWxE3W7DvLeomr/HDEMpAKL3E65agxKDiw/0zL7BDwbnotRl/uY9HdOOgIHpUMG1emIgw== X-Received: by 2002:a17:902:7c11:b0:178:a6ca:4850 with SMTP id x17-20020a1709027c1100b00178a6ca4850mr4264056pll.111.1663670004271; Tue, 20 Sep 2022 03:33:24 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:24 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 26/39] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled Date: Tue, 20 Sep 2022 18:31:46 +0800 Message-Id: <20220920103159.1865256-27-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: 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 Reviewed-by: Marc-André Lureau --- 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 c87afad9e8..aedd9ddb72 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2133,6 +2133,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)) { + ; + } args = (MigrateStart){ .only_target = true, From patchwork Tue Sep 20 10:31: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: 12982058 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 9CEAEC6FA8B for ; Tue, 20 Sep 2022 12:25:59 +0000 (UTC) Received: from localhost ([::1]:54138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacK6-0006GO-Kf for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:25:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZK-0001Ij-Dv; Tue, 20 Sep 2022 06:33:34 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:53812) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZG-0004zb-5a; Tue, 20 Sep 2022 06:33:32 -0400 Received: by mail-pj1-x102d.google.com with SMTP id q3so2551558pjg.3; Tue, 20 Sep 2022 03:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=qGPOmRjHbysKyb7HVYrvLwoOgzN+2O9KcPhD9XmRvHs=; b=ZLZSHLQDLV+j6k7eLKXqDsWNRvtkZqa+QtewK6V2COplApxkZDHojNZ6frhCoMLcv/ pVqtLdpOthwJ9gzBG6N9UIh9PAasFEsPMJ+3qrPNS836mT2VY94HRWX4s/lqWXS+J/i6 drhx1vyBHLQQeC/oSpeS8jqAqJUtAQDV0Y9OjKEU3I7irZPSYsP3Zoc5ye58SrtOK+RV e9AqV7x6LGcksg2CTHn5E1+CbddSOZRAiExm3+dQ4JRBpHU5NEoWIAzsIozgL1v0qbNO IfB224xGNceNI+vMCYRDP94azz5Al0TGhqhuUEI1HIZasGWu0jZTfyU3o1Yx9117XEdB JPhg== 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=qGPOmRjHbysKyb7HVYrvLwoOgzN+2O9KcPhD9XmRvHs=; b=vbOA/MQTOJ4CzVc6liSWAuUHaZE4Vw7SNs5Lg6Ww64xkuO+x1r6Ln6T+o0GrpeH7r4 VFmbZFRpH45XghsU2QHcrQip/Ds4hhrpe+k9HFGFzA5zKVA7uCNyMaeeDmh+0EK++XG9 FRyfRI6zGT7tPIZ9v5RHn66bB6KIvNwI2YxphS/+liIw4Wx9ZXQzVMysY8dRvbBgRUIB g8O7MAYNWYxPPreieLiotWKG6I/tSoxG2C5vHUP6f98Cm/yAzz2Ma72hLUm3Mwr7icGa ZvAjghyD7m7NAOROXIUhhzDNzG0RzypNawcrYJx3TwTlncsek5IKHK+OtvPLrN88QhP5 zmjg== X-Gm-Message-State: ACrzQf1p93MwKOxQ+47i0MXAKIlLR/t/y1/tEwPVoeksDGoM9SPhSqBL b+NBNub78DFaNDXEzxkW6pXw5tiZA+U= X-Google-Smtp-Source: AMsMyM5ERaS4WjHPrFxwZnf6Cgh1ktv2Eo3pu9bZYs9yyr8TrrfO/exGbSv0jyBLg516WnwVrVIPsQ== X-Received: by 2002:a17:902:ea0e:b0:178:3d49:45ad with SMTP id s14-20020a170902ea0e00b001783d4945admr4156024plg.103.1663670007450; Tue, 20 Sep 2022 03:33:27 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:27 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , Daniel Henrique Barboza , =?utf-8?q?Marc-Andr=C3=A9_?= =?utf-8?q?Lureau?= , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , David Gibson , Greg Kurz , qemu-ppc@nongnu.org Subject: [PATCH v2 27/39] hw/ppc: spapr: Use qemu_vfree() to free spapr->htab Date: Tue, 20 Sep 2022 18:31:47 +0800 Message-Id: <20220920103159.1865256-28-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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: Xuzhou Cheng spapr->htab is allocated by qemu_memalign(), hence we should use qemu_vfree() to free it. Fixes: c5f54f3e31bf ("pseries: Move hash page table allocation to reset time") Fixes: b4db54132ffe ("target/ppc: Implement H_REGISTER_PROCESS_TABLE H_CALL"") Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Daniel Henrique Barboza Reviewed-by: Marc-André Lureau --- (no changes since v1) hw/ppc/spapr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index fb790b61e4..cc1adc23fa 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1522,7 +1522,7 @@ int spapr_hpt_shift_for_ramsize(uint64_t ramsize) void spapr_free_hpt(SpaprMachineState *spapr) { - g_free(spapr->htab); + qemu_vfree(spapr->htab); spapr->htab = NULL; spapr->htab_shift = 0; close_htab_fd(spapr); From patchwork Tue Sep 20 10:31: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: 12982066 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 F0761C54EE9 for ; Tue, 20 Sep 2022 12:38:56 +0000 (UTC) Received: from localhost ([::1]:40364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacWd-0005vx-IK for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:38:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZK-0001Il-Jm; Tue, 20 Sep 2022 06:33:34 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:41848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZI-000508-0c; Tue, 20 Sep 2022 06:33:34 -0400 Received: by mail-pg1-x531.google.com with SMTP id q9so2113840pgq.8; Tue, 20 Sep 2022 03:33: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=5vK7I12SbKOcFn43HOIKWmaFBkxVao5CvM3jde8q4IE=; b=FugxP0xmy4YDguSzwfMpySA31bnFASSySGjghOCIyELK/Hy/alZ3hk1lZ7wye8hQg+ 6yg4FtbYjcBZIgEOCI9VIpU1sUh3FDTstf1J+YgskJT/IxSX5iFzXBaevOfcPVT1Cp66 HHicqD4lBqs9HE8HN8J2CnntBgs2oS7qFRJ7tJ6ypZi092U3WcQzxxkB6QgYuVj2Hl/Y FYFZYMISU2z4xEa+AnKiuVo0+PHv2o7000tVdh7rGwFS9jXPhAq9PyrNzzJ898Or5Q15 n21BqsDe5rFrlUspr/8BSMQytbQSt9nXzpdPojxRYqC16jf52KQ0qLx3/O6+O5WIbG6W Gq7A== 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=5vK7I12SbKOcFn43HOIKWmaFBkxVao5CvM3jde8q4IE=; b=RS84u6WtLgqW0zKu9WRsRSa5kcPSzOv6/WAHUZenZdxDuXdIhMZWlXEl2mJYcVMC5E 8XrtcaId0sT5cOVt9MAHJ5lhn0Wo+XjTZFRUojbZbHQKgM8KmLMDAA2wNmKobV4F2jRf Gi6qjF+3sycZNtptKlHJu3u2LVUMtSZv5IiW3q1qH4B7+BVLWmzDu2cKzupA8rYwM4JC XjAXugGDusK6PMLPAG6tz2TyJqrq8CURYE71mfXk60Qa5mTPIKZH7/OYy8pcbCk5ypAL BJjrRTpdMiI/rINVfEUmvG9CC3uEWhjwrH9wkefer63NkW00NNgSyFUU45NLPDtid5pd 7eHg== X-Gm-Message-State: ACrzQf0zCctcxcCHkquc1lFpqSiFPPct76QVFSh/2zrexUNjy91HS8KR RRk1TTJV0QoYQoCpL+v2PG/5A2yXkTc= X-Google-Smtp-Source: AMsMyM7l9zO8A8g0ecjDG77EC05caPdNd9Dzmydc09GCwKUkwhuzEJCaCSWfw8QUZ6A3X5v9yDx/Xw== X-Received: by 2002:a63:560a:0:b0:42a:7b1d:4e08 with SMTP id k10-20020a63560a000000b0042a7b1d4e08mr19951452pgb.594.1663670009694; Tue, 20 Sep 2022 03:33:29 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:29 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-ppc@nongnu.org Subject: [PATCH v2 28/39] hw/pci-host: pnv_phb{3, 4}: Fix heap out-of-bound access failure Date: Tue, 20 Sep 2022 18:31:48 +0800 Message-Id: <20220920103159.1865256-29-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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: Xuzhou Cheng pnv_phb3_root_bus_info and pnv_phb4_root_bus_info are missing the instance_size initialization. This results in accessing out-of-bound memory when setting 'chip-id' and 'phb-id', and eventually crashes glib's malloc functionality with the following message: "qemu-system-ppc64: GLib: ../glib-2.72.3/glib/gmem.c:131: failed to allocate 3232 bytes" This issue was noticed only when running qtests with QEMU Windows 32-bit executable. Windows 64-bit, Linux 32/64-bit do not expose this bug though. Fixes: 9ae1329ee2fe ("ppc/pnv: Add models for POWER8 PHB3 PCIe Host bridge") Fixes: 4f9924c4d4cf ("ppc/pnv: Add models for POWER9 PHB4 PCIe Host bridge") Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Cédric Le Goater --- Changes in v2: - new patch: "hw/pci-host: pnv_phb{3,4}: Fix heap out-of-bound access failure" hw/pci-host/pnv_phb3.c | 1 + hw/pci-host/pnv_phb4.c | 1 + 2 files changed, 2 insertions(+) diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c index af8575c007..9054c393a2 100644 --- a/hw/pci-host/pnv_phb3.c +++ b/hw/pci-host/pnv_phb3.c @@ -1169,6 +1169,7 @@ static void pnv_phb3_root_bus_class_init(ObjectClass *klass, void *data) static const TypeInfo pnv_phb3_root_bus_info = { .name = TYPE_PNV_PHB3_ROOT_BUS, .parent = TYPE_PCIE_BUS, + .instance_size = sizeof(PnvPHB3RootBus), .class_init = pnv_phb3_root_bus_class_init, }; diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 824e1a73fb..ccbde841fc 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1773,6 +1773,7 @@ static void pnv_phb4_root_bus_class_init(ObjectClass *klass, void *data) static const TypeInfo pnv_phb4_root_bus_info = { .name = TYPE_PNV_PHB4_ROOT_BUS, .parent = TYPE_PCIE_BUS, + .instance_size = sizeof(PnvPHB4RootBus), .class_init = pnv_phb4_root_bus_class_init, }; From patchwork Tue Sep 20 10:31: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: 12982092 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 BC6B9C54EE9 for ; Tue, 20 Sep 2022 12:53:23 +0000 (UTC) Received: from localhost ([::1]:39900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oackY-0005P2-Qi for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:53:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZM-0001Lo-CX; Tue, 20 Sep 2022 06:33:37 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:35501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZK-00050J-Rn; Tue, 20 Sep 2022 06:33:36 -0400 Received: by mail-pj1-x102a.google.com with SMTP id q35-20020a17090a752600b002038d8a68fbso6330010pjk.0; Tue, 20 Sep 2022 03:33:34 -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=Z4owo7vrx89r1gRzYcIT4A5Mhg6AIFeduPasKpaIp6TH3zpWkVKjDgAUXNfv8NX+SZ 6MtdQJ8qL30RCqAnjElvVnyMyxmXxuoxpkFDrQzHEdrU9kiLF5EN7dthAeAj4rHpcHGn cABxHPo3mV45NZGGDy2bUTfh3ksyskG0NxkyV1bUYQyjxh1o2LdKEhtBBdkLDrHLpJVo VKOZsXM+KrWWfcS73eqrxwZBV/SqHw1SNatT1D4Im7gedVMzI7JRnmr0cODelrqL03EN Ts1OIK1qT+b+q725/EQHmxAvgQVXie9sYmn+uQbhiLLOvrTILZ1qpkkAZc5WLXH3UB5B iESg== 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=XRPRhu0fhaTKBFXs+1OZWjr4eCPKv7gPiT+p6aYFRlRQ4/+vfLdVtYIFFa14Ir8K4W pgpRmlzBXCcXmSxrNkC+N6dvcS6eWgsXeBCFCkqD93VsCzMe2aOMDYMkiohNJGQkR9R4 KwlkhD7/xb8h/8WFmz8A2gVgfBvfRN1r6HwzjREL4QSXXnBqdW1Hx5hpdtultZ9PE1ME q+kpvZzS8HyNhJAGP0EcbK4wqfW/H10vuV5zJ5BPv4ql3YwhTpQweV4m+VNcqcosW+fm rhBvmbE5KEip7Cw8IqiX+SlB7RiqNgyOj7uMETyXDadWecQVVvwwhVJE0fb0vXLRbOPA IP+Q== X-Gm-Message-State: ACrzQf3M2bKSMWh7boo1Hi25YFyG/RACK42EZZyQqIEU8RHeSiDB6Uf3 /BL8l5Nn4DRAUnQuRcmlIv9x+7hUId8= X-Google-Smtp-Source: AMsMyM7jveWXzUDw4xGD+YxsHD9EC4ar4wzRHYsndHgDsfFVgSTVVAxgrQKsG3Y0XlrqX6rAZlPzpA== X-Received: by 2002:a17:90b:1b4d:b0:202:c05f:6ea0 with SMTP id nv13-20020a17090b1b4d00b00202c05f6ea0mr3193274pjb.7.1663670012840; Tue, 20 Sep 2022 03:33:32 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:32 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Joel Stanley , Laurent Vivier , Paolo Bonzini , Peter Maydell , Thomas Huth , qemu-arm@nongnu.org Subject: [PATCH v2 29/39] tests/qtest: microbit-test: Fix socket access for win32 Date: Tue, 20 Sep 2022 18:31:49 +0800 Message-Id: <20220920103159.1865256-30-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 20 10:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982149 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 E0B49C6FA8B for ; Tue, 20 Sep 2022 13:08:50 +0000 (UTC) Received: from localhost ([::1]:39616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oaczZ-00049F-LD for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZO-0001Nj-5W for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:38 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:38574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZM-00050i-JI for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:37 -0400 Received: by mail-pj1-x102a.google.com with SMTP id x1-20020a17090ab00100b001fda21bbc90so10320080pjq.3 for ; Tue, 20 Sep 2022 03:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/IRfRlUZ8PHyxDl3ny4yy2ispddiqfXne/7ixyNzdlE=; b=Fon+t1eYCQtRz0Q7E+Sg6H1dWmaLaD57FbtpKg8An272UU3Cnl90+zc6L3NEnqIq/h DMcSC3jPaeV75mdH3NVQcF+DXSdOuFi/Gov8350QT//8PMHYmF2Zt5hgKgqydP37wZIl 4eBG+SATJxt0oIOjoYlKmBU5Y4cVr4vdTDUrDapcA2rOVnTP6acUoqTlsQfdJN7xl+JT pk9beRrnumkOUjPOWFphw5f0Mzzv+lD9Sdm/4nGveZMeT4HGaBex0VI/52aInvXZXNkb ntz3sjf9hg0Ssxr6RhFbKtpzkDKLwn8Q50Jo1X4f2XCI1R8eOOOrp9WdDeLt3Dz9kbOB BUrw== 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=/IRfRlUZ8PHyxDl3ny4yy2ispddiqfXne/7ixyNzdlE=; b=eYLZKPIgvFVmLKZffHzuWVmBYO15IffncxPge4zwnBsEK4k7dtF8t1U2eUYLs6p16J WK16fnvqXXoA7W++aiiMNqEl4qEL4y/zgEMhK3IML8crYA2ASwq/SIUWcHLjEAhRmKGr DXH5FThmaP8cSlzORetedhqV+ThCnubRDKjeCodhnx62N4DxENchOkfmt3R/fqujpWcJ e3e9m55OpEqva0J9QAcAFH+UzA3o8AbgkyAuhUrH5SKvDwoYYr3i7ROcKmmwMnhV09JZ WFBL92EFUtlq/QHs2eeclw8lswFrbvKBwG4i0KUFbSjM2f5GS5vXJsVE6Tya4h5hs0LL H+qQ== X-Gm-Message-State: ACrzQf26Dv6uTB525f13itZT9/QcOLH9ml2LL4lS54GxmXWWScRLkHin vIYsBwl943i2Tt5g683X0EH8FYE4v1M= X-Google-Smtp-Source: AMsMyM7jw86x7d9INGsbihOntsTC2aaGqQbJ59KUOAw95lNLu03Aqp/rGem2UQG4KfIyokBIRcpZlQ== X-Received: by 2002:a17:902:7c0d:b0:178:a6ca:1dbc with SMTP id x13-20020a1709027c0d00b00178a6ca1dbcmr4220287pll.115.1663670015312; Tue, 20 Sep 2022 03:33:35 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:35 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 30/39] tests/qtest: libqtest: Replace the call to close a socket with closesocket() Date: Tue, 20 Sep 2022 18:31:50 +0800 Message-Id: <20220920103159.1865256-31-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 5d15e39289..08c4e76ffe 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 20 10:31: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: 12982171 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 D2994C54EE9 for ; Tue, 20 Sep 2022 13:27:49 +0000 (UTC) Received: from localhost ([::1]:57694 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadHw-0003HZ-VU for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:27:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZV-0001RF-Fj for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:47 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:46008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZR-000519-MN for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:43 -0400 Received: by mail-pl1-x62c.google.com with SMTP id w20so1892299ply.12 for ; Tue, 20 Sep 2022 03:33: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=hZ5BeVWIEmvZSQc//vOc1hMlcaYTXrE6w6t1vRdBzGs=; b=GHS4zEbZxBY1c5gFN2zEzR+RmGE8jPrJJS6t9mvCY2FS74VKBficA0DnA8rIMPt8wy hR4CMo1WXz3AE9hv8Ha6/vYPcjtzl4DgrAXrnseENZ23xvcCfDvboZlMREu1Nh1wndYm zv4lM2FD8clSxm+udggtJI6bIdVD0Dib5JFXWPwumPozJlympGvEo1Yc3SIJ8FNHOkCv VJpl9mJhKab+gIWQASus8lUOqnce7HoWXnZv5jykq6bRPvifAq2zfGf/5cqIu0XG0zpE GZNxNOehAQK+St7C3pc42wHqYBmI031PEm38wDE8MzrHPTpWfoJXpsE7enyqZ/vOAIkf 4Vwg== 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=hZ5BeVWIEmvZSQc//vOc1hMlcaYTXrE6w6t1vRdBzGs=; b=sNQpZsOkL1FHwRTe/WBKozZYd6RMjH7biuO/742KnGWl1hpa2EIul63u/EBATYce5y Y/eU6OiLzwDYs93LOVS1l9MAi/MtNokU9PMMUGPIq6oPWY/72+LwbwqnKsWHCYq+Tq92 Rn3Jv+XkZQNdOVEThW2MMkZzskfr2Xxj6k3lPNQgqd+HJckT0XPV+xsMEdPzGGvWyDVn 2Hs8NQ1Wu0Ia/GO68aMKjBTXg+t15GMQDT2PO133I4XY/124eByGl98YTgVnjj6NJow0 Ni3CB/1IUSlqFCGtTMVApZN6KnopaxbXNNiS20Q0PIxCa9Gl7sj9iDwb/Sou7RBiweD7 c1UA== X-Gm-Message-State: ACrzQf33GZni8MaraCxELw0P9jwFPPTablR8BktERWQCBM5WlJqZmQGU C0hkd2C42RhRmyR5ultP0RnxWaEFBPk= X-Google-Smtp-Source: AMsMyM5qoZpCGAQpa84tMURG8knRZZNVb36ikUmTOZtCU4mwxzxcKcRJH8628yJWJNlhi3pjIYS/RQ== X-Received: by 2002:a17:903:2104:b0:176:a9ef:418b with SMTP id o4-20020a170903210400b00176a9ef418bmr4136738ple.134.1663670017770; Tue, 20 Sep 2022 03:33:37 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:37 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 31/39] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32 Date: Tue, 20 Sep 2022 18:31:51 +0800 Message-Id: <20220920103159.1865256-32-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 08c4e76ffe..f6df0e35ac 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 20 10:31: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: 12982187 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 52225ECAAD8 for ; Tue, 20 Sep 2022 13:33:46 +0000 (UTC) Received: from localhost ([::1]:36230 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadNa-0001P5-FX for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:33:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZV-0001RH-G0 for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:48 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:40502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZR-00051N-MY for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:43 -0400 Received: by mail-pj1-x1036.google.com with SMTP id q9-20020a17090a178900b0020265d92ae3so10313227pja.5 for ; Tue, 20 Sep 2022 03:33: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=wJ46lPbUundlzLry/XhmGks2ORwcj9XXEHBkBSD1tlY=; b=GRBlej2hJQEo6TVMxvrEPHNQLJL+YFENFMB3tcerc5lTZ2kDXMTwgACAP5TPmQz9tv OmKnkUKhgCn0p80DU+e0GMxI+ZQ5YuqiaC8W0FglsSNBn7w43TYBwRwZEubnLLbolzUS I0rf5qz1+wdd2hM1mW3uMWM8XyQ3CTjBqRkn8EpGYQrAKAIpCIbZbfhBkjKQHEkf6lYR kVZVWAU52mXGHmtLTUZnKCFaFiKc+0ryn1n+SdZLMa316eJBVckVEoFcTjmOZ6A9l0wr 96LCVCt4FIXRKfjA9Sm1jbCscBsfosnIAdnnj7tqDFjlrQXUve/XOWbpO7dYYQO2B4kH mG1g== 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=oeExa+Ufc4UN0LZ/7z5/q/Qr/UXSN3cznOhdDtqx4Xm4fkn4yDPevQCLZyKAqYNn4Z nhhxdi65WUbvzCQinJaRH83FjMeN36qeu76v7dMwNYsQMLM0UTVG2OFA1RivwetnL5kL b5JyqQhGIj/BWX7I8uH/qv4+SmloZcluOAEI8ewdr7eeFvF2WqNyvC1OwoKKgUYqMMlU mgS103CFW4ZhKDND5NGWa/hVYhfZXh2VQjT84vHTN6i38gTKrO3xWEPiXiA+W8navWo9 OLgOHhaUN+tvTYlhM1lkIxoZmFUG/1PJO14/tTfHbWEt+HK0VwScPsEKq/F5BLj49avh P0iQ== X-Gm-Message-State: ACrzQf33ZcKXRbtpvUql9Rqpi1mWmblEH7DOLicTfnYjJVMSlKQfwdlW l1q4gQ7JMenrOr7GzkNT2PMWYi2drYY= X-Google-Smtp-Source: AMsMyM5LGDwMNTpgZQ7ONMdOHVuCrA8nrn/NDpVItHFKLXBLnQP2MO4aBFamAwMihETzo0uNZGplxA== X-Received: by 2002:a17:902:f782:b0:173:1206:cee0 with SMTP id q2-20020a170902f78200b001731206cee0mr4156957pln.130.1663670019901; Tue, 20 Sep 2022 03:33:39 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:39 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v2 32/39] io/channel-watch: Drop a superfluous '#ifdef WIN32' Date: Tue, 20 Sep 2022 18:31:52 +0800 Message-Id: <20220920103159.1865256-33-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1036.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng In the win32 version qio_channel_create_socket_watch() body there is no need to do a '#ifdef WIN32'. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v1) io/channel-watch.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/io/channel-watch.c b/io/channel-watch.c index 0289b3647c..89f3c8a88a 100644 --- a/io/channel-watch.c +++ b/io/channel-watch.c @@ -285,11 +285,9 @@ GSource *qio_channel_create_socket_watch(QIOChannel *ioc, GSource *source; QIOChannelSocketSource *ssource; -#ifdef WIN32 WSAEventSelect(socket, ioc->event, FD_READ | FD_ACCEPT | FD_CLOSE | FD_CONNECT | FD_WRITE | FD_OOB); -#endif source = g_source_new(&qio_channel_socket_source_funcs, sizeof(QIOChannelSocketSource)); From patchwork Tue Sep 20 10:31: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: 12982128 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 4FB96ECAAD8 for ; Tue, 20 Sep 2022 12:58:57 +0000 (UTC) Received: from localhost ([::1]:47918 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oacq0-0008HM-9b for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 08:58:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZV-0001RG-Fn for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:47 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:37699) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZT-00051V-9U for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:44 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d24so1923894pls.4 for ; Tue, 20 Sep 2022 03:33: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=UPIr/jdQcVynaJFJUgSyu3ZQ6HyOdiYQ9iafROMaepc=; b=OWstQa3zPBq62FQVUaJMU8X9JyMhbgKdTNYm/OLp/o/vsRaCoBqPy9Gy2i8yjwejV1 4TBmRBORkg2+Wok1IlkodVRJohBHcQ8SteLAvHkVFv0mlaOTe7ESAiE9A600fVRg74uL DB59JS3VuJt1mgipuDme94qOtwA9YBvYxNgKNSquuJ1oonFY/rSj+w63PuK3UdMPVoti gMvTMHpLugtFtLIPZHWMkpGCRH48jX11AdXghTNNEl40jWV97HIj3gpSFBhotM1G2eo9 WR0tpbpXehVc0iGVdu/+6HwNwj8NNjFEqtbOd2vNy34DkN//9Q3+b9kkYdq1MMKxbk9a IZYA== 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=UPIr/jdQcVynaJFJUgSyu3ZQ6HyOdiYQ9iafROMaepc=; b=wtLaL5tmimWkjip/6aRBlBNc+FbRvfV52pRT1sXz8iXMLfNIgigEL6CgIGO08n+ysz SMJMIyx0hNLu8TOS/DyIhK4BgZD9Lmg31uBhXy9xQkx7GdqvM33qBp64gI+t19ZonW1n Flb6FNblkvc7eoblukn6zSq0hqjEVjHQIjxEoQ5+pQ0MdSyer3P9nuemUSTf+GsaFnAG RRqdlaGi3nBHcQjQ/ZkK3RZgiDwTLoPF0upOx1ZpIP49TC6Xdq07mBOl4FtLv9yjXeEh sZX2IyDNPt37g9VDj8N7Yjq/sEvXRGjBgQZGYGOuf0/kqOy3Wy9xemM6omcTs/bA0Gig 2Vjg== X-Gm-Message-State: ACrzQf1ux5vXlFnhKIDCI8MTciwxHV356g5xrpPaD/29Swy+gek3Qu/l lkXoyU6KE2k/7Y3AgAu+dFxN3vMAyPM= X-Google-Smtp-Source: AMsMyM4CxzegpuGvFycylOR6YBVEuCyIinpt0iGLb7YyYkUu7XzUYvz6P8SGPK2ds7Nin+atRp2kuQ== X-Received: by 2002:a17:902:aa83:b0:178:9818:dff with SMTP id d3-20020a170902aa8300b0017898180dffmr4145837plr.1.1663670021968; Tue, 20 Sep 2022 03:33:41 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:41 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v2 33/39] io/channel-watch: Drop the unnecessary cast Date: Tue, 20 Sep 2022 18:31:53 +0800 Message-Id: <20220920103159.1865256-34-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 --- 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 20 10:31:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982196 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 03245C54EE9 for ; Tue, 20 Sep 2022 13:41:07 +0000 (UTC) Received: from localhost ([::1]:37880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadUo-00084p-Ob for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:41:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZX-0001RN-2I for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:48 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:36517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZV-00051h-Er for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:46 -0400 Received: by mail-pf1-x433.google.com with SMTP id y136so2347521pfb.3 for ; Tue, 20 Sep 2022 03:33: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=xIwwdkQ/UueIjTq9LmfxXmdWH0OF4K6cF8/Wmny7JFg=; b=br4BW6okOefvORkIs0aIO+nDgCNzk1px8msHqMm8mwlp3kJsAcsDb2DyF9a5lq5O0Y 4p4wdZZXz9wP1UCa5neRdf08g7jwwWKx+LUL0bC50Dv2QAAR2P8Ajlk1Q6BIucOok0Rc dhDnCauNfVNM1duHTDm6G+Ryc9nXNJHhVkUpG9sWig9Y41jJ39Ii00QDgV5kQAxAgTaR vb2ughF06xNCw3lk4FKhGiUNGb+t86MSb0uLnufq4sa+1L2tbWBmYCj++d9dqBPg2wGZ mMjfkNxoHkPSw5KU8ukpeUGEFRtJidQq4ge0f9amNkZqN8TjaVvbC6gxrVniKOBtnqp9 R3Uw== 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=cILZKK5IiSJ/ZliKqGorMq4BF+mbOV6LwBF73S3EZQH7dU1Bc8nKf8ikDLEMhtVY9f e6hi0ZUugRWLvGgx3oKm8DvQLmxPgfkMvNPKtRuGlpTowOwsqyKUGTdm+HqzlbLwWf3e LVm6I/vxbpDHeBpgseoIvCVjUe0bi3vxyPaCHaAFzWwtUJO+egxE9ZAzaa5dILVsH+7A jRCkm0fEy2if0LV8FnbyxIXImOpH4AD9o256Qpppei5ZJgRW1HEWqZxXrDdxoeFTTZ9F yQLbGDpRCgd5bt5DxnWwHV5ov2gB/EgHSYnv7QD4Ql+XUZAOEkDvJUz0Y/Yr2wX81zgz Inxw== X-Gm-Message-State: ACrzQf0WNXPq7qLNYDV0NmM8bHta7d1FrmYfU9tQZHSsaSJ7NV8lw1aJ VAyyxTHnKwG9aBmNupr2xFbYl5MYOR4= X-Google-Smtp-Source: AMsMyM5M1TMFwFfiuHQrlrpeLoHsKz0RLBRueVCvKT1jTgg8qwa6WHMngssaTKRbZ2H3FBqvu8BIqw== X-Received: by 2002:a65:464b:0:b0:42c:b0:9643 with SMTP id k11-20020a65464b000000b0042c00b09643mr20221531pgr.232.1663670023781; Tue, 20 Sep 2022 03:33:43 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:43 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH v2 34/39] io/channel-watch: Fix socket watch on Windows Date: Tue, 20 Sep 2022 18:31:54 +0800 Message-Id: <20220920103159.1865256-35-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 20 10:31:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982156 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 C6988C6FA8E for ; Tue, 20 Sep 2022 13:12:23 +0000 (UTC) Received: from localhost ([::1]:54356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oad30-0007Ej-Rw for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:12:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZa-0001SE-CK for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:51 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:34648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZY-000522-0Q for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:49 -0400 Received: by mail-pg1-x532.google.com with SMTP id 3so2143397pga.1 for ; Tue, 20 Sep 2022 03:33: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=xmrffeAJpAZ7oRzdU9cwoCFcPUSltVboEjy+YD7LlIE=; b=O2F2rNnO6//5wU5+WZidqqaoBRZa7YhAZCT+gUPM6MVJ6ov74Ql/2AgtmDV9bB3SqF 97MofwFHjPQwF4XhFmu5+wYg13YxocqA6vPdGUiK657jiutCU2pLVUlt8WKMovj+/NZo 1fgMLuc/qil1vwn19L/+c9F8K8QQLHyEsgYzzfS+vNEbC0uEuRP4zmDA/2hhCZdcdOng U0XJsNAQ2CogDHJhrytrTZm2mwcmFdk1b96Q9w6oFKyiJd6iM9wp6y2K0WeBWHGSPaC8 6eSwgpbrxU+SUGi3n4CEO3WeQZqT0jDr4hFEQYHHy5edqLPfGN40Fl6f8UgVnLCMONVl Ru/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=xmrffeAJpAZ7oRzdU9cwoCFcPUSltVboEjy+YD7LlIE=; b=5kGUZc/QBAoKdmS+hbfz5HEhYt6vPzV3fTT+537jCk/SLLx+9ZLpSfCOrjTwkOBhFk JmHJmgTvr+h663+ahlVgYHDbgd7HLietPVQ5y4KJWf0J0/HaOOHZQnStpRo43MSB4y9G xr0vjI/pw32ozrn4227RW3VQj7m4y3WAJ68jPll4Ci/7Yyz5vmV1C8DYnb2zGkzhrQ6C gyTOK8BANnuEoc0W0c11CQKngeyziYbd+qu7dFBV7t1FGCSrFMMG5k++0mXk1jcQL/89 vkf8p3JeP9GYlbkg4o4/FSMgYL75Rdqn0l/1ruHh9/hHL5aKdVeK0QJ/v7QHARAfZWCD tC/A== X-Gm-Message-State: ACrzQf0QrURhZmsOHh4DMYEyFq+cvJ5JsLNITYK/CAqjkZW4/3DcD8y8 b1E3Fk/xc/fCykdtrQakkRIXazDH7w0= X-Google-Smtp-Source: AMsMyM4HgUGSsMnGr8wPOw6wT/fG3Q0vYUKHqSrlXdT9pTAjqwrpC878R/YHNqIXzv/SrbDM3EKZJw== X-Received: by 2002:a65:68c8:0:b0:438:744d:b340 with SMTP id k8-20020a6568c8000000b00438744db340mr19296035pgt.142.1663670026484; Tue, 20 Sep 2022 03:33:46 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:46 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 35/39] tests/qtest: migration-test: Skip running some TLS cases for win32 Date: Tue, 20 Sep 2022 18:31:55 +0800 Message-Id: <20220920103159.1865256-36-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 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 aedd9ddb72..dbee9b528a 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -1403,6 +1403,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); @@ -1415,6 +1416,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) @@ -1523,6 +1525,7 @@ static void test_precopy_tcp_plain(void) } #ifdef CONFIG_GNUTLS +#ifndef _WIN32 static void test_precopy_tcp_tls_psk_match(void) { MigrateCommon args = { @@ -1533,6 +1536,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) { @@ -1930,6 +1934,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) @@ -1937,6 +1942,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, @@ -1988,6 +1994,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 = { @@ -1997,6 +2004,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) { @@ -2497,8 +2505,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) { /* @@ -2524,8 +2534,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 @@ -2569,8 +2581,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 20 10:31:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982204 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 AD6A8C54EE9 for ; Tue, 20 Sep 2022 13:45:27 +0000 (UTC) Received: from localhost ([::1]:56342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadZ0-0005t2-PE for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:45:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZc-0001Um-HO for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:54 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:41709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZb-000527-0r for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:52 -0400 Received: by mail-pf1-x434.google.com with SMTP id l65so2312433pfl.8 for ; Tue, 20 Sep 2022 03:33: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=TUsOJQnvJjC5OLNKVEVXq4E1NZhuCvF9KTJRvGMNaas=; b=fAQut5FG7k+vX/K+84SOyBUhKU2ziyp3XHW5qv9z22sE/9tUQhqXwK91ob2kLkNhVs Ev+nY5PtL+DpqDidF+m/fzIOvoja5sE3Sc4H/NvQP75qpKn9GKKZGJ2uyKqi9ZFeQhHX TtJggo0677WGmyro719DQ3kTspe7Ca9HckmuE+9rPshqNpS/VuqLIFjjk4IwV40YgeoX yjfox/Jd7py79bRqNgcntpWtaTFgKKm+l31udziQI29ZV1KNozhnngwbAzHafPfNfA2h 0YkM+c2QhDvgeLZNmyzpn1VtaE+3mqxLHUKCwyP40g8Yow3qz7d3olZrwH3m/9RCKhLk 62EA== 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=TUsOJQnvJjC5OLNKVEVXq4E1NZhuCvF9KTJRvGMNaas=; b=vyvXINp0bVC9Zw9osbsZQNtsCnFu5pa0zrAR+TeJ4incElhIyDWycg7G9ho+zMKtOr 3WxwSvET+cdj3CKoR2lqgOximb6f8pgL+4T8RdWoTkWeP1NFRFYU2/bP8s1asGDt2aMZ livo7aP3aM2hzX1xEBRXqJAVW8M0NpbH1TKJiZQp28WHMV5YOfOuoVxuXAyZsoJ1pKOq NwK+1fW5pmHwv9O5pOeXN8iPx9KRl0b5jMYabbhk/i9OoQfLTn9nAOlyR0FiBh/7ekFY MeLp8WJPL1xYbOnbvOpTTEx4RxrtwSbIAttspYgIVBjs+f20rS2IBFtI3BCFywl+N+yG Dx4w== X-Gm-Message-State: ACrzQf0mjpCwTAjsdZSdCNIkKu8RaG1K9iuYuH/0jWZOJKEh74+3Mlz8 YdEMz/Ou6TupRSooStwjhkD1g8BMCHo= X-Google-Smtp-Source: AMsMyM4wuM9SL0nLhaihitJCdsXA3OFYI8AZRPGogtrEcNGHNfVABBijbl3z1ZZuouYRRUrzeCx96Q== X-Received: by 2002:a63:698a:0:b0:41c:8dfa:e622 with SMTP id e132-20020a63698a000000b0041c8dfae622mr19434840pgc.465.1663670029159; Tue, 20 Sep 2022 03:33:49 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta Subject: [PATCH v2 36/39] .gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes Date: Tue, 20 Sep 2022 18:31:56 +0800 Message-Id: <20220920103159.1865256-37-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=bmeng.cn@gmail.com; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- 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 da6013904a..818676662a 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 "sed -i '/^ROMS=/d' build/config-host.mak" - .\msys64\usr\bin\bash -lc 'make' - .\msys64\usr\bin\bash -lc 'make check' From patchwork Tue Sep 20 10:31:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982211 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 7124FC54EE9 for ; Tue, 20 Sep 2022 13:53:40 +0000 (UTC) Received: from localhost ([::1]:34764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadgx-00041h-EP for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:53:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZf-0001V2-0T for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:55 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]:44745) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZd-00053Y-ET for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:54 -0400 Received: by mail-pg1-x52d.google.com with SMTP id c7so2108063pgt.11 for ; Tue, 20 Sep 2022 03:33: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=woEWPjt3NdjCcAder2sEnEPZ1q9JhhvK0Jn4vXhCEIE=; b=aSFVetRgNBBvuOwGXI+POb0ZmW2LdxmAvdUNtzugvSg3W7bJftbHsr0rEoL+rhcMXW JrcnF3kxSAR1OcVyzS7Vgab7ZosfoWRTn9GCfpZfo4igas7FsbHWdlhIYQKEJCaO1ADP dVowYJTMJdQc3znK1CVZoypXeM1R/sUlP4vlk7O5ExpPZLQcGQizVDorH6ULlhNILAU/ zTl3OSBM1lCY/058o2645EMDvn4W/dD6tx9k6TzMk/NscHVg95sehkJHquByAR57Jafi yfnCNH1539LhzWuhoKDV4TVDoY9KDiSQl+KC4yoPlQgnEfcNvyS+6Y8Xh0/8IGx+QWbU 7r+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=woEWPjt3NdjCcAder2sEnEPZ1q9JhhvK0Jn4vXhCEIE=; b=rjaF2g46ztK5ZR/z+bBkOu5bPqhnBW2Q6GSBcRo5H8au3t6SPOPKo+PPuXIxpD0s90 yICe49z4YxBmbOEkA7euVbW98ffGNn80KPQRws0RRct7dZ7V3spUAZ/tmv1ycjaDeCWW dqnTKG7PTKJy0/vUaIsutO3Qr42qXkdWLeb4qxp5nR94eEnuiM0U6ITmL+mIdCOlwZPv 5iRJrX2vo6nDiGhD7z42hNCGRYYk3R/jikKdLX+yvUBH9CW/KyY9og26a5szH4YYRNMN 8DMNNqdrXMirxQ1bs88emvckCJnCTsCiW9uLzOpdWLTOI693d5F3E7ITTLlaZ1y5bvcE PZBQ== X-Gm-Message-State: ACrzQf0hD17gExdkzb/KRe0oUmpwU0dOdQTvhx8jA6XCHHCCH9fVyXUO fMudvAknH6y6SAftM31jMlEQQUCEAQo= X-Google-Smtp-Source: AMsMyM4fqYjR/Xnxl8yVkmnxEbEn2f0obEYjGOoNhWmDce+zyqjzTGCI/8GyTipunovGO+ZMtpsb3A== X-Received: by 2002:a63:8149:0:b0:439:f66e:23c0 with SMTP id t70-20020a638149000000b00439f66e23c0mr10969579pgd.11.1663670031891; Tue, 20 Sep 2022 03:33:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:51 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta Subject: [PATCH v2 37/39] .gitlab-ci.d/windows.yml: Display meson test logs Date: Tue, 20 Sep 2022 18:31:57 +0800 Message-Id: <20220920103159.1865256-38-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 When CI fails we don't know what causes the failure. Displaying the meson test logs can be helpful. Signed-off-by: Bin Meng --- 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 818676662a..dcd553a081 100644 --- a/.gitlab-ci.d/windows.yml +++ b/.gitlab-ci.d/windows.yml @@ -62,7 +62,7 @@ msys2-64bit: --enable-capstone' - .\msys64\usr\bin\bash -lc "sed -i '/^ROMS=/d' build/config-host.mak" - .\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 @@ -95,4 +95,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 20 10:31:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12982194 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 C7057ECAAD8 for ; Tue, 20 Sep 2022 13:40:25 +0000 (UTC) Received: from localhost ([::1]:47892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadU8-0007TJ-Lp for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:40:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZh-0001Vx-Lt for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:59 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:33662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZf-00053f-LD for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:56 -0400 Received: by mail-pl1-x630.google.com with SMTP id iw17so1963295plb.0 for ; Tue, 20 Sep 2022 03:33: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=Jt136OWsjti3Zpu3h4MXfORTFkV12nnDiDA1HXBO+Xk=; b=E/2vQAkyGF4Fz4XkDMYm7Xm66TNx1VIYbCcCf4g8nhXRgA/Q7pD9AbNbrtiifryHru zWKy2Tr277+tvxsiX+qndf1DABa1ny+CZwpuEYG9f/0pxO/fIuN7WAmIjJnGMjvSq7cB QjF6dqatgkIJxN9XFZ8g3VKl7IqgCkMQDVP2sns+eJL3RNHEoI0vGvzvyw5LeV+wwnlp bJLQgzmQvkBoKO1wuXim3RF9zl1B3FuwgpK8xG9Z239L6e+/kxM0SAU9742+ivcVkXwU fUYyVlKeyEJhjMHUsjVCjLoTe7AzGu2guq8r139yLcGtw0erAfx48p1WrsI4DCAMSiYK Z98Q== 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=Jt136OWsjti3Zpu3h4MXfORTFkV12nnDiDA1HXBO+Xk=; b=MzWSK049INC0ht13phXXIflax3uXL67+R4WHg67Bpxo0nIhkS8UB0TP99lz3tRWOHU Jy7Cwq3uz7iHOzhj+BR4/02QtY2ixvq7qurIC8cYzIX0VCj2VcHXuoNa7S5R6vFPcdrI v9V6MDkxr/dp5p4PSMgZjVmOgjhvDVb5vO/y31v4d2aIZKPCWO5DZPRxMJFEr6iRryg9 gGxL4yldNJGukwRyAjZhnEMlZVI8pEOoLHn7jQwKib0TR9RC0gTIA4ax/aKL9iaZyVUv gzCCAapIgKP85FBmFzxTckaaZnbyLHcDOI8WTEIRpvzQMc7CMDX6oqGckmL1wa+nZyx2 D7IA== X-Gm-Message-State: ACrzQf3jA1n5ZwMbQjGG5H6MnRlZWScuGIwSlp5YtQKQ5ENo8JlgHHvn v/Hc2IOJzx/JpYcXhnOU5aDEXId5hiI= X-Google-Smtp-Source: AMsMyM5qoOuwyLoV9iQxA+wL0iWPNeGw5oC5ZV4yBkJ22MZX31YGHXDJ8wg2YAixl/N488JqPIh1kg== X-Received: by 2002:a17:90b:1c07:b0:200:9728:b8cd with SMTP id oc7-20020a17090b1c0700b002009728b8cdmr3215995pjb.139.1663670034210; Tue, 20 Sep 2022 03:33:54 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:53 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH v2 38/39] tests/qtest: Enable qtest build on Windows Date: Tue, 20 Sep 2022 18:31:58 +0800 Message-Id: <20220920103159.1865256-39-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-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 Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows. Signed-off-by: Bin Meng --- Changes in v2: - new patch: "tests/qtest: Enable qtest build on Windows" tests/qtest/meson.build | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 455f1bbb7e..ceab141824 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -1,6 +1,5 @@ -# 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') +# Build all QTests for POSIX and Windows +if not config_host.has_key('CONFIG_POSIX') and not config_host.has_key('CONFIG_WIN32') subdir_done() endif From patchwork Tue Sep 20 10:31: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: 12982169 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 6DAFBC54EE9 for ; Tue, 20 Sep 2022 13:23:00 +0000 (UTC) Received: from localhost ([::1]:37520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oadDH-00062G-CL for qemu-devel@archiver.kernel.org; Tue, 20 Sep 2022 09:22:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oaaZk-0001Xo-5r for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:34:00 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:38419) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oaaZi-00053v-GQ for qemu-devel@nongnu.org; Tue, 20 Sep 2022 06:33:59 -0400 Received: by mail-pl1-x62c.google.com with SMTP id x1so1917401plv.5 for ; Tue, 20 Sep 2022 03:33:58 -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=CeqCs+fhJTq9ubJJCHLWPqSHezBqKxEmHRY/t8v7R8c=; b=l1w6aH1yb78q5GBCs+Uy2kG71s9gacPQyvIJuj3jXOuv4+8/BbeiywNONijxQygMAE uP3HOrzDAYTlpeXmVI57ZRxxQp994rZoiPsj8tUzyvgngIIzdhT5RLKti8essKL6Pmi0 NFdww8a8c+2/riFxwCK/Wn+PRS00hv/nwh7Spbfg6wuYQgvSbGuZBVyuvGqtyLEZRmwD 3GhZIKU1yVqmp9BiHhYwOqoMuab7d0WNVWtn44bqjNGEn3e6ni/hHAZ1sAxzj0FtqaSF B2LcxKM8MZEVEdxbsaFVm1PGY2FgTSiIbGNu3FtvKIWmopNqaWXRzw/q9rOH/Ldp9cS/ rGhQ== 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=CeqCs+fhJTq9ubJJCHLWPqSHezBqKxEmHRY/t8v7R8c=; b=yp3Fag+OdL4X6DqRYuEzewjEXawL3sFD0SXobYXVGn4SsL+2FfZCmuphZ8E2rN9poO YENI/wX6Lpz9IEBT6IdA1AZaHtm10MwCnboeLSyp/GD+7IkFjW9CNqICywn2zVN3UMD4 ZLyU5pqbwynPD3tNT7ZtuCr0QWxOjrq27TqLQ0Ub5yOvR1FYBEjkBK/8syZVL2FyCGN9 +Gya7Ufy7QteOxkwfGRn0q0Q59Rx4o7aYIdvEX2rSMkqMFmbYp3V/dqgqkDFmZYHMjYQ ASXWv15ESr7ZdcNuIjLBN5SB7Ayio57hbs00M+8ZC1dPM2hYeUvhlLXbrHhoAwjUgNo3 wr6Q== X-Gm-Message-State: ACrzQf2RdU+O0YtcHP7X+xIbHHQdYcWf52PE5b982I4p1EC3BxJazHZx uzrifdcNM+A0XM1avYZuE19oNNgKAlo= X-Google-Smtp-Source: AMsMyM5rZjZs+JNFOuxRZqeCRyLeFBkRkJYpCAPVhcp+LeG17wIy/QKTC2UTIrRrQPjR6GcLX/wJWg== X-Received: by 2002:a17:90a:ec0f:b0:200:b4b5:c352 with SMTP id l15-20020a17090aec0f00b00200b4b5c352mr3210974pjy.205.1663670037209; Tue, 20 Sep 2022 03:33:57 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id n2-20020aa79842000000b00551fa0e2b2dsm699573pfq.206.2022.09.20.03.33.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Sep 2022 03:33:56 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Bin Meng , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Willian Rampazzo Subject: [PATCH v2 39/39] docs/devel: testing: Document writing portable test cases Date: Tue, 20 Sep 2022 18:31:59 +0800 Message-Id: <20220920103159.1865256-40-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220920103159.1865256-1-bmeng.cn@gmail.com> References: <20220920103159.1865256-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 --- Changes in v2: - Minor wording changes docs/devel/testing.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index f35f117d95..eb65401ad2 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -115,6 +115,36 @@ check-block are in the "auto" group). See the "QEMU iotests" section below for more information. +Writing portable test cases +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Both unit tests and qtests can run on POSIX hosts as well as a Windows host. +Care must be taken when writing portable test cases that can be built and run +successfully on various hosts. The following are some best practices: + +* Use portable APIs from glib whenever necessary, e.g.: g_setenv(), + g_mkdtemp(), g_mkdir(). +* Avoid using hardcoded /tmp for temporary file directory. + Use g_get_tmp_dir() instead. +* Bear in mind that Windows has different special string representation for + stdin/stdout/stderr and null devices. For example if your test case uses + "/dev/fd/2" and "/dev/null" on Linux, remember to use "2" and "nul" on + Windows instead. Also IO redirection does not work on Windows, so avoid + using "2>nul" whenever necessary. +* If your test cases uses the blkdebug feature, use relative path to pass + the config and image file paths in the command line as Windows absolute + path contains the delimeter ":" which will confuse the blkdebug parser. +* Use double quotes in your extra QEMU commmand line in your test cases + instead of single quotes, as Windows does not drop single quotes when + passing the command line to QEMU. +* Windows opens a file in text mode by default, while a POSIX compliant + implementation treats text files and binary files the same. So if your + test cases opens a file to write some data and later wants to compare the + written data with the original one, be sure to pass the letter 'b' as + part of the mode string to fopen(), or O_BINARY flag for the open() call. +* If a certain test case can only run on POSIX or Linux hosts, use a proper + #ifdef in the codes. If the whole test suite cannot run on Windows, disable + the build in the meson.build file. + QEMU iotests ------------