From patchwork Thu Oct 6 15:11:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000472 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 8E516C433F5 for ; Thu, 6 Oct 2022 15:14:04 +0000 (UTC) Received: from localhost ([::1]:36560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSZX-0005jv-M6 for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXP-0002jI-Mu for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:51 -0400 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]:43704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXM-0004Yh-4b for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:50 -0400 Received: by mail-pg1-x531.google.com with SMTP id a23so2104454pgi.10 for ; Thu, 06 Oct 2022 08:11: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 :message-id:reply-to; bh=RLZhLFQlc54ZoIwBF61gB7xfiWSNWDubi3/EBtm1pD4=; b=h8TAhedq6QL7BV+UjYNB227gHjBflLULoL5RhbffiuipiNlDzpFqIgGJsgWUlz4NLT OhJgYg/REiJEi0GpDDslmxa7L9f85C8LmUUtqmvCL34QbxCuOrNeubxTEEJR5ebGZEF7 re/RY3c0wkyW63NgVgVfl5TkAmiTyJP4H4AAufj17p766CnQ4bQFI5HeTP/7w92u70wX andbDq/kFCwvPCFZh8S2WeppugPyzCrHXpW6YU8vNXUl0qKpMpQ+fJB2wafDq5/0UTQm BNI53d1qZbekb/PKpl2/mPfmWCIb/Olr6qrdLR7k6qllM8R2uRKMDWTvEiyfgnfZIsPB Q6Uw== 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:message-id:reply-to; bh=RLZhLFQlc54ZoIwBF61gB7xfiWSNWDubi3/EBtm1pD4=; b=36+x9AcFfueivZlePXR01yx+YcdcJ1ddJ4HVXBd5OykjipFpsBHcE6r76kUm3Ga/Gq CUvzOslOuJD0lQPNmXEEA3eQfwxasdBfP+1d6RtsOPvfmd8ps+/27JILwN+65I2f5mOf 8/1SMefjaaLl3GwhpQt11VFwAn6l2EPQ5KLx5Z84gMtszjIlzxap7YIGlGkFypX5LpvB m5qCTBXU8OG1DNEg7OV+cmaGbFpSePB1MPh69jN+IdQDoGhP8HIAVlhc0N9bLoOCqy0t Hlf9TFTopEmWCzYaTd9bJKLQqSrG/C9t3ZP1p+qe3RKX7riZ7BNSWvTsIp+vpGR+Llzz dltQ== X-Gm-Message-State: ACrzQf1rNsBaWONKu/adm14+oB548CKum7JbLdnaJZQMxiiTCdzVZJ90 9r32oIV42wHZJ3Ouo2Q3ODjNcr/0c4w= X-Google-Smtp-Source: AMsMyM7KdUGJL1u43GiQbVswha2ZDEF7XfJKXM0bpXbA6aUcXE+h2HtHFqA2DGjt9KLsZI9L7AsAlA== X-Received: by 2002:a63:d613:0:b0:45a:654:cf16 with SMTP id q19-20020a63d613000000b0045a0654cf16mr284281pgg.611.1665069106338; Thu, 06 Oct 2022 08:11:46 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:11:45 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 01/18] semihosting/arm-compat-semi: Avoid using hardcoded /tmp Date: Thu, 6 Oct 2022 23:11:18 +0800 Message-Id: <20221006151135.2078908-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::531; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 bfea9e9337..62d8bae97f 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 Thu Oct 6 15:11:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000473 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 72728C433FE for ; Thu, 6 Oct 2022 15:16:56 +0000 (UTC) Received: from localhost ([::1]:47216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogScJ-0000Uj-C5 for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:16:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXR-0002nX-3J for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:53 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]:35818) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXP-0004Z3-H2 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:52 -0400 Received: by mail-pf1-x431.google.com with SMTP id i6so2336325pfb.2 for ; Thu, 06 Oct 2022 08:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gs5GKe8FO5KCXA2mO1WuiuwajzHIA5xIM/tzyVScXS0=; b=DVmkL+zfyMu/eIRh34gX6yjpCDSISmfihDm/RlA+HpoT+YUDQh5u7cFTXsEitIS/aD hyFRR2KDpX9l3bAh8GQVwKa0Pqkxl4sRJnrJe9dI4tLJxA+EvwbgZxqi4sFSVnkS5fAZ 3C/GZTNcYKlnFqltyn+2LJ7ezAmQNNq2+HeX3lT7v8kgKrnClh2YCq2NSYgT+zDZ8CzN ZYV0cxCPeFyZyfz0P+idKMjoQ2QoaNHlIQHyBEMCjNnd0zzK1uENsVXRldSPltZMEHKq G8bcaQX6VUybuZu2J9bb/u+hVQ1GqaPn+cZLkDcqLB0KLQrwcAz+ChiUvZlWBlDSCPn4 BFyw== 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:message-id:reply-to; bh=Gs5GKe8FO5KCXA2mO1WuiuwajzHIA5xIM/tzyVScXS0=; b=KvmR0BTs5MiPV7m/MWcJ5i2ZcktXDVAIaMpXQJMf11bHta2/P85EdnsMQBSViQS4nX aA3OFybrDxXW1rnPtP0b/SPiFaZE2VdJknlxz5rPWW2ub8xvz7t7jVMDNtzJyhMNAZh1 KmXN0K/G/5p1cE10jCnONJItbGOUuZh/nVd0JbfIqZ6Qw7iqTFeqng8PcyAm5BxAA4mA eBjoViNatMUwkjMECP7LgWIfxF80anaNmG+eO72gSDJXbnra3tAh9m9DzPCvYYQA3/uQ d+dw6svc+DQ0aUmTbgIaOoXI7SDgQPwWJFja8xEc6jmgFzky0ZBrplf9Q5RrIBVkwEsJ o5cA== X-Gm-Message-State: ACrzQf3O7tZ8eQ2VZ/7v5hUTPkBuYbgIRbOZaFdjt9CzrH48bSvymMmE DEu/7yQFb9d+eKgSU79+nhj0zCn06wA= X-Google-Smtp-Source: AMsMyM7yKftyic7lbPoKHr8fIOzk3xvK7LV1SMgxer/c1vI3S5mXHcOzTcJQ5SEBRpOkkneOsvm0Ow== X-Received: by 2002:a63:1b0e:0:b0:44b:97e8:1020 with SMTP id b14-20020a631b0e000000b0044b97e81020mr285141pgb.519.1665069108739; Thu, 06 Oct 2022 08:11:48 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.11.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:11:48 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Subject: [PATCH 02/18] tcg: Avoid using hardcoded /tmp Date: Thu, 6 Oct 2022 23:11:19 +0800 Message-Id: <20221006151135.2078908-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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 Use g_get_tmp_dir() to get the directory to use for temporary files. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau Reviewed-by: Alex Bennée --- (no changes since v2) Changes in v2: - Use g_autofree to declare the variable tcg/tcg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 612a12f58f..84921b64f7 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 Thu Oct 6 15:11:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000481 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 E2677C433F5 for ; Thu, 6 Oct 2022 15:23:49 +0000 (UTC) Received: from localhost ([::1]:42532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSiy-0006fV-V5 for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:23:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXS-0002t4-H0 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:54 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:43549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXQ-0004ZE-UU for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:54 -0400 Received: by mail-pj1-x1031.google.com with SMTP id g1-20020a17090a708100b00203c1c66ae3so2045544pjk.2 for ; Thu, 06 Oct 2022 08:11: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 :message-id:reply-to; bh=ptPSCcbuG++AcglR+Ify0H9lkcBvjcAqRFsbcccQhHg=; b=mzKd3Md0Xjn7z54cmD+ZGV6/gK7BzhJKiTmjtMq6Ied4FZKH+Ze0krCBmKVM37YrNH cETVp1L4uuqhanjfKBFMAqTgDkq18JIM7wCJPMbDqJcRmYQ/w9xvFx0VXXYAR+i9Iamc qHVgyd905KmtC2ep4aTFeHWAG2TLq2f1aptuC9UyTqpmt+gqa0Qecah2kDzuv3/4a2DX n76QQOnzu6Lv6yWQTu/iXQneRpQaXF5WQa3tjbZqs3zkUezQ4BpQHbVJYNCfUmOD8c3K CugWVn5IlUvKaswVBGMt3vvTsUHeiwwb05m4hWwPFMPk60LbagOtqWliXeFKKaICkgZM 0Ldg== 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:message-id:reply-to; bh=ptPSCcbuG++AcglR+Ify0H9lkcBvjcAqRFsbcccQhHg=; b=twgKYTMh3TIV/lKF3cbfRz97sxOwMBih7aA1wLCLQQMW+4vDROp+rYxD4mxrTpSEYj A3dclVjf1JSDtbit4EY5WLPnA0KuAibHzZEa4DUo0zbAFyJEKgaBAg2yjRYTERHFgoHy nJJ4RIueBpYJBnkC7aFeB4myQqHBZeGKc04RrUFoZ13U4TjQXWzlM2HU0Uc3sSIFvBdO kWoRkl6W4wEW6oGkj7Pw5GgNeCMK8j5eYARHOSZXEvVAYvvCaekGFhVekB1/2AOHykGC tCCTup3LwYIr5+27Nao2kLNENzq/K4xk+DY7nohXt1eXdfCdMiatO0txr/2K1SCc28gy Xr0A== X-Gm-Message-State: ACrzQf3scsOGNnwIMY+b3IIfO6HDqylXgDfdOLvdCNdrFxqogwV+LClM hSvY0NaN71qrvW6yiD7ki+jSahy+xNY= X-Google-Smtp-Source: AMsMyM4nSzOGDQOYXl0oOEJzitAl9bRUu1CW+8LEx8qQYdrVHNpPCduYGknXMJQN6tC4kkurUWCbiw== X-Received: by 2002:a17:90a:a512:b0:209:9b31:5f2f with SMTP id a18-20020a17090aa51200b002099b315f2fmr222594pjq.146.1665069111444; Thu, 06 Oct 2022 08:11:51 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:11:50 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH 03/18] util/qemu-sockets: Use g_get_tmp_dir() to get the directory for temporary files Date: Thu, 6 Oct 2022 23:11:20 +0800 Message-Id: <20221006151135.2078908-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1031.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 Thu Oct 6 15:11:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000479 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 38FBDC433FE for ; Thu, 6 Oct 2022 15:20:02 +0000 (UTC) Received: from localhost ([::1]:52508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSfI-0003Dd-DF for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:20:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXX-000347-1n for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:59 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]:38775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXV-0004ZX-G2 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:11:58 -0400 Received: by mail-pl1-x630.google.com with SMTP id x1so1984555plv.5 for ; Thu, 06 Oct 2022 08:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EgL4d6VdvWsoCo8DlQTj5egD3vl1ynzfG1/OtpHXHWg=; b=GBWSjRPcpug53/ozuo2QBqNKU9Bmg8y4oGUU32jYgjEfG6m6kKtmnICwfKTrfDJqmW Fxog+8XJW84HfVPmoCwFmzk1Szf68ljBQR/y4vyAGQ9bLP72c8j1wbyXUbqlo67G4K6A 5JMdT7edGOYiYJ9m1OToaZLpeZC33DNUCcNeNU/i7z3dqOr54kz+ugAAXHhh7Fz8p5lS n7EHdIOuf5kmP1OH2jwoMOTMbp7rer7oYLYVhxj8tbY1bgNm8uC3asnIptsF9QSl990i +GLtw4gvYcUDzWQEflnJSy6bmPYkSwBFPq6tjC3IObz2XD3cli+09tSNA/J/q6PDotFg plCg== 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:message-id:reply-to; bh=EgL4d6VdvWsoCo8DlQTj5egD3vl1ynzfG1/OtpHXHWg=; b=f1wA8xkCbyocvBX0kCc3C8e73ruUL+kCLA10PcxlyVksER0JrSfAVct+JNzdRjxtZk QJ8qfgChXtSyjCffDba9Twa8N8IA8N+IgWIHF7S5V9S5yjwGf1eZTA2zHi5JQ4ElJXW9 FxkIM7PfbtqkTQBP+t1BFVOaXtTJ/eTK7CJUcv6dI0hb4Y8ihNkF7Tk6ym/1orTNSwSB 2+HDX9Bqi19UUlgd0eehpvI2iA7l3zEmQjhbT89w8vX7Nt81aXS7d4XwAT2s2+KJfrfm QeLOyuktCMkArx3aJTdbKti5mgNnWWGd/gRQnObdEJCevryeHgTv8fNUt+71NFxJqWCh VKxw== X-Gm-Message-State: ACrzQf3iuiyr9hc+09Hy2mCEqOvBgsYZgy+ri+az2cqJAuZKd1Z5cLIL o1MgF7DdI3biXDlZ9OVwzOb3tuB0BNg= X-Google-Smtp-Source: AMsMyM7eTeb3VSA6H7VAYzaXxJWl464rGpQH6QZ1tyl/ptKEpFAs+q0Ou+cS8K/APIYgBqxlZaY9Pg== X-Received: by 2002:a17:90b:4d8b:b0:20a:e256:fdd8 with SMTP id oj11-20020a17090b4d8b00b0020ae256fdd8mr11207554pjb.4.1665069114467; Thu, 06 Oct 2022 08:11:54 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.11.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:11:54 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 04/18] tests/qtest: migration-test: Avoid using hardcoded /tmp Date: Thu, 6 Oct 2022 23:11:21 +0800 Message-Id: <20221006151135.2078908-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng This case was written to use hardcoded /tmp directory for temporary files. Update to use g_dir_make_tmp() for a portable implementation. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v5: - Use g_autoptr(GError) Changes in v4: - Update the error reporting by using the GError "error" argument of g_dir_make_tmp() - Remove the const from tmpfs declaration Changes in v3: - Split to a separate patch tests/qtest/migration-test.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0d153d6b5e..ef4427ff4d 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -102,7 +102,7 @@ static bool ufd_version_check(void) #endif -static const char *tmpfs; +static char *tmpfs; /* The boot file modifies memory area in [start_address, end_address) * repeatedly. It outputs a 'B' at a fixed rate while it's still running. @@ -2451,10 +2451,10 @@ static bool kvm_dirty_ring_supported(void) int main(int argc, char **argv) { - char template[] = "/tmp/migration-test-XXXXXX"; const bool has_kvm = qtest_has_accel("kvm"); const bool has_uffd = ufd_version_check(); const char *arch = qtest_get_arch(); + g_autoptr(GError) err = NULL; int ret; g_test_init(&argc, &argv, NULL); @@ -2479,9 +2479,10 @@ int main(int argc, char **argv) return g_test_run(); } - tmpfs = g_mkdtemp(template); + tmpfs = g_dir_make_tmp("migration-test-XXXXXX", &err); if (!tmpfs) { - g_test_message("g_mkdtemp on path (%s): %s", template, strerror(errno)); + g_test_message("g_dir_make_tmp on path (%s): %s", tmpfs, + err->message); } g_assert(tmpfs); @@ -2612,6 +2613,7 @@ int main(int argc, char **argv) g_test_message("unable to rmdir: path (%s): %s", tmpfs, strerror(errno)); } + g_free(tmpfs); return ret; } From patchwork Thu Oct 6 15:11: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: 13000490 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 2BB18C433FE for ; Thu, 6 Oct 2022 15:29:35 +0000 (UTC) Received: from localhost ([::1]:39126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSoY-0005Sr-3G for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:29:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXY-000393-OM; Thu, 06 Oct 2022 11:12:00 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:54032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXX-0004Zm-6T; Thu, 06 Oct 2022 11:12:00 -0400 Received: by mail-pj1-x102d.google.com with SMTP id fw14so1994165pjb.3; Thu, 06 Oct 2022 08:11: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 :message-id:reply-to; bh=mASgTbgC1fZZDNGRrUnVCNQGIWuAR0DCWfyrQC7EGTU=; b=TkiKcW7X9R/0lTL6npTDE04kdSi+VqU2sQRyS5vINubLom5afweUGnMqeyLOe7ME9e xdFoo3uPaHn9S1QQAwMfmT//5ithqO9GsAkB6M54JbHAeMUdPr0cmI4Um1t1fNPzDhSx DUD+dZRGzSaLwQ2248LwOLBbW1ASKe8fatDDm+lSGAqs8CfDj0rBaW8YrrFulkTDrSoN LFn174UwDSLz04CiJ20/aLScyk1TfNcqNIJy4rx3TfSLHvU5T4G8Jjzg4TADPSE1P5hJ zzWRuzl1wi+ymAorZx1aGUAL8S9Oz5s1hWKI1kEi1kzXxMXj/gP9th7o5yRZxg4O5Tdn BAeg== 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:message-id:reply-to; bh=mASgTbgC1fZZDNGRrUnVCNQGIWuAR0DCWfyrQC7EGTU=; b=Kthqc4UE2qbV5fVGfQrXnJ6aIV3pX7Ym8sSRFd4Ez10MIwYe+0ELwfFEEzYI52Xe9b klDPY/Y61Ch1OUmM3OhqduHrAeg+DVOasgki70Ci6kVElPj0hJ0f9JSctYwx+7317OiT 257Nf+blZplun4aZUYgZjaq3EvDWlYEbqVCyBWr64v2xvmZICuwF1jV7K6vh7OXSGq8d OEM3UA+ZRW1u/CeOhkxQnOo8FrNZFb9XqieMyts/lVONrhJBHrA3OXr1iUm8b/VlITeZ mxd83EF9PhzE2e1L3r3QXMptIl2pVJfeqw+d0jfiVnQNv/VFdg0Odydcxhe12EdXMQeG Vr4w== X-Gm-Message-State: ACrzQf2lnuvWNR/E2zEaWduHEtMbzKYwYqslXF5EovpZliU1FtASip5R zebTgwffcktc7Ba+wLb85jdyEBHlk+M= X-Google-Smtp-Source: AMsMyM7hHc/srnZOYT1GLI7DoLI8tynuRrFglLG6qa7XvfW6/5OOCu0lPmhH2GJ2jSkoOZyzvAjQgg== X-Received: by 2002:a17:902:bd46:b0:17e:8ee5:7b61 with SMTP id b6-20020a170902bd4600b0017e8ee57b61mr406732plx.44.1665069117189; Thu, 06 Oct 2022 08:11:57 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:11:56 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Hanna Reitz , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH 05/18] block/vvfat: Unify the mkdir() call Date: Thu, 6 Oct 2022 23:11:22 +0800 Message-Id: <20221006151135.2078908-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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 There is a difference in the mkdir() call for win32 and non-win32 platforms, and currently is handled in the codes with #ifdefs. glib provides a portable g_mkdir() API and we can use it to unify the codes without #ifdefs. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Change to use g_mkdir() block/vvfat.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index d6dd919683..723beef025 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include +#include #include "qapi/error.h" #include "block/block_int.h" #include "block/qdict.h" @@ -2726,13 +2727,9 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s) mapping_t* mapping; int j, parent_path_len; -#ifdef __MINGW32__ - if (mkdir(commit->path)) + if (g_mkdir(commit->path, 0755)) { return -5; -#else - if (mkdir(commit->path, 0755)) - return -5; -#endif + } mapping = insert_mapping(s, commit->param.mkdir.cluster, commit->param.mkdir.cluster + 1); From patchwork Thu Oct 6 15:11: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: 13000478 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 BE45AC433F5 for ; Thu, 6 Oct 2022 15:17:20 +0000 (UTC) Received: from localhost ([::1]:55368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSch-0000tI-DR for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:17:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXb-0003JC-J3 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:03 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:44858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXZ-0004aE-VP for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:03 -0400 Received: by mail-pl1-x631.google.com with SMTP id x6so1954957pll.11 for ; Thu, 06 Oct 2022 08:12: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 :message-id:reply-to; bh=gkhXgeI8VVKYUE8bIuW2cVwuIZ0uivwbyCoudHIFJ54=; b=VbRlBhMB5HBvUlMnhYO8Ym/YuSbpF9W1XM5y0faNHJ4BVEjFp+KBZ4L1yHEAELw5cs VnBxM18+XJ5LZ8US1WE9bP/zWs0rtR7JXNFC14Emdngsb4eu9AvwBtTeV/2FbusRSM// W93LMry6UFLbWnsdSKt/ZNBnD6g4HMBl5EyeWS0m7OmqAefxi0fnj6yCpL2IIrCPvEPu sV2w141xtCac1MNwlAr9wHFPoKUWBJ6Us+hwPVCo42OmKyvk7jQbyI6xZWwweEKvYj1G v0BA2ThRNKwWkBKMku2YvgwLGsNoZL7ekloO162csveIv4/RPV9jdGGgT2lVqKObuVax oFmw== 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:message-id:reply-to; bh=gkhXgeI8VVKYUE8bIuW2cVwuIZ0uivwbyCoudHIFJ54=; b=mvwbU+0uhJ6mvNdwA3jrzTrvPFn97KzLQgS/PO/NFyE0uSa8sKtK1eq2Ne8rzqxjg5 hMQxtHFvNAWLLzBf3x/koZ/W56InCEBfG7uLUye9sVaFe2ZVZq27j9/K+/k1jUciHRp9 0LOu4mm9Icb05rqcyRmRsp2iN53SOQblR4Ov4bxHU7pLihZ4dOq8bqqU34iJ2maZsKWX UMDlUK4/zm0a+2hpclv8nRt++64WYmE4kOsqtlMd0421MpXyJI5In/++4wNwOKLNepjF aFdwKjnFfZiWajsTT5WZuKdEt48LYExnFJaEvY23gt0eRK5eCVFrQzX3iF68TNYn8nv0 oUSQ== X-Gm-Message-State: ACrzQf3shi2X2YYOKQEXQbaMvWaCMwWEhyDJ5bZxEt4DaYeBx8ADWv5F 5caSruAslueKPgD1NE5CdYqwPYkmW/s= X-Google-Smtp-Source: AMsMyM5gsAoFAh9L0VkiTKJ3cSx8Leuc0bPM5bJddMQpYKhLRHTHD1XQ6grIR5CViDxzoTiyiHLXUQ== X-Received: by 2002:a17:90b:4f87:b0:20b:12e3:32ae with SMTP id qe7-20020a17090b4f8700b0020b12e332aemr205892pjb.236.1665069120405; Thu, 06 Oct 2022 08:12:00 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.11.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:11:59 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Christian Schoenebeck , Greg Kurz Subject: [PATCH 06/18] fsdev/virtfs-proxy-helper: Use g_mkdir() Date: Thu, 6 Oct 2022 23:11:23 +0800 Message-Id: <20221006151135.2078908-7-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng Use g_mkdir() to create a directory on all platforms. Signed-off-by: Bin Meng Reviewed-by: Christian Schoenebeck --- (no changes since v2) Changes in v2: - Change to use g_mkdir() fsdev/virtfs-proxy-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c index 2dde27922f..5cafcd7703 100644 --- a/fsdev/virtfs-proxy-helper.c +++ b/fsdev/virtfs-proxy-helper.c @@ -10,6 +10,7 @@ */ #include "qemu/osdep.h" +#include #include #include #include @@ -639,7 +640,7 @@ static int do_create_others(int type, struct iovec *iovec) if (retval < 0) { goto err_out; } - retval = mkdir(path.data, mode); + retval = g_mkdir(path.data, mode); break; case T_SYMLINK: retval = proxy_unmarshal(iovec, offset, "ss", &oldpath, &path); From patchwork Thu Oct 6 15:11:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000500 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 3DD99C4332F for ; Thu, 6 Oct 2022 15:39:43 +0000 (UTC) Received: from localhost ([::1]:51222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSyL-0004vV-H2 for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:39:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXf-0003VN-H2 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:09 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]:34735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXd-0004aW-OO for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:07 -0400 Received: by mail-pl1-x62c.google.com with SMTP id n7so2010173plp.1 for ; Thu, 06 Oct 2022 08:12: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 :message-id:reply-to; bh=gBbYIR+cYUeZZvc5gKxNpLwekX68RaD7k9jxuyBt2nM=; b=dOtjr+W9rvmyqtKz6l2crngvck7euHxBG5gUR2GqvnviZ6Elk08zP2lyJ3uHgXjZjP /SPY6MhBRHfZaPdDjI57Y6tcm6JHX+him/vmrhK7eqnMsfBuYBUs0kcX0DEoU3wBoEiy vEaaUJ1LZrva3wUIJNN9uy+r7DEOQ/R6EtQLNRGKyVc4G7uQKG571sm89DhrYHxWCM9K J7JjFjwmHiqM2AUs9zypA8OgBGbopEY2AgGWS2vMP7ukICkTTPzAoc68iQ4KKs+kFKi7 Syth1ziVN7SD4GdJu2ihHiRzmLRl55UEC8Kmf0gWC1+fL9NspXgGthACed9L3Tl5FhLm lFiQ== 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:message-id:reply-to; bh=gBbYIR+cYUeZZvc5gKxNpLwekX68RaD7k9jxuyBt2nM=; b=Ptv0YwnxUpTDuFBQXKpOl/uhEpl4e3tNYmwBgtgU/8i7RhSuf9lTwTUsBnWw7GGfv+ LkJQijB8q6luflI8aY2ZPSz87MeC9M06PiMhGveYkm9TN56xn1RxPpnIczpLWrzZ3u7k bsH/B3xSLOzBnshI7xruPS/uOkuKPQeZXnQGpbaOXNmZHmw8rY5c4Ute1mmbxeF4Hd4E 8W7zAEnC7T5Kl3q9LKNZj9SYCtYplOxyX4hU263zEcilbP/debnANp+o1Wl23YBeZYF0 cNL+pkaUoou6sCY2yglLS28mU/afsP6zrZJtzFckC21LyFt1vRbwPlGSzmnS320DPjr7 wzXw== X-Gm-Message-State: ACrzQf124oSfFDjIWMRaSfTvDqMtXDmy5hvTjPmgyFbOSGDsLnLl8ajI UVGMlXVIvfzr5wgiWa7LEiS0fb0P/sc= X-Google-Smtp-Source: AMsMyM6lHX5vqRv2pv2goAod23xQoZVDzsSYwJDqbEDs0lvCZkyBw9mvp8Vqvnc2Cuos51mxzBP9vw== X-Received: by 2002:a17:902:c40c:b0:17f:7f60:47ff with SMTP id k12-20020a170902c40c00b0017f7f6047ffmr360994plk.101.1665069122950; Thu, 06 Oct 2022 08:12:02 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:02 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Gerd Hoffmann Subject: [PATCH 07/18] hw/usb: dev-mtp: Use g_mkdir() Date: Thu, 6 Oct 2022 23:11:24 +0800 Message-Id: <20221006151135.2078908-8-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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 Use g_mkdir() to create a directory on all platforms. Signed-off-by: Bin Meng Acked-by: Gerd Hoffmann --- (no changes since v2) Changes in v2: - Change to use g_mkdir() hw/usb/dev-mtp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 5831395cef..1cac1cd435 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -14,7 +14,7 @@ #include "qemu/error-report.h" #include #include - +#include #include @@ -1622,7 +1622,7 @@ static void usb_mtp_write_data(MTPState *s, uint32_t handle) if (s->dataset.filename) { path = g_strdup_printf("%s/%s", parent->path, s->dataset.filename); if (s->dataset.format == FMT_ASSOCIATION) { - ret = mkdir(path, mask); + ret = g_mkdir(path, mask); if (!ret) { usb_mtp_queue_result(s, RES_OK, d->trans, 3, QEMU_STORAGE_ID, From patchwork Thu Oct 6 15:11: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: 13000503 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 9B0FEC433F5 for ; Thu, 6 Oct 2022 15:44:19 +0000 (UTC) Received: from localhost ([::1]:37316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogT2o-0002OD-KL for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:44:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39114) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXi-0003YC-32 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:10 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]:46599) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXg-0004ak-Db for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:09 -0400 Received: by mail-pl1-x635.google.com with SMTP id l1so1946283pld.13 for ; Thu, 06 Oct 2022 08:12: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 :message-id:reply-to; bh=jlh3NcGL14udoTSs2qKNoQECkhWg9Im/R612Y2w5/+E=; b=FN52SnVoXtMFI80iWqxxxMETAmZewY1k7wLV1ETouCaq7xkE2AxVa/oBHy9mrrj00q MH6Q0ucrdWbI3AtwJOhWx51yJ8/MnIO9rkM0dG/V8PruVmCQJ4jypJWS7HfvFoRFgHaQ GKOTNkRyg7FuR7FJ/wHAxFUsYGyJAst+iH0p/rAn3hyECIlC9vh24BF/ZG5TtQfSUMMv vc2pWjYcNbDQUlH6dIP+QqOeouLKYPfFi4HZXKxtsI3N7czi/Boa0uy36EjPqZKSeYK0 nvbNYbUb9w6TWFTt9Mc67ekViA6v4gsl1lH7eR5a5PjmELw7k3MPjczMThiOlghhDvdF DlvA== 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:message-id:reply-to; bh=jlh3NcGL14udoTSs2qKNoQECkhWg9Im/R612Y2w5/+E=; b=slfiv9vd20d9gcxTEteX2IPdPYe/68727VNH12aNP6oUG1XWO0bkLL2Z4EErkzHeSC TlhT3EzNpod/b8RZhth4QuNyGagTwUOLCZ4fJ5SRPrud6vz7xKxC2k6q7INHs+jHVX6D 2/YqZBr1rfQKw9g2Lk28iVPc8e8zdOhXSM6EC4VXEoeMak2ioT47QmR2jvphOk0R085W 1nYS6xKru53utLVL2Ea1i8HdFWXwdPwLAZJLzs6x9nDGVbrB0BFTVwV8ntg5eKggX3xB kPgNq5vKp6ODg1CZFfIzZSiRfPHgahXiWyx0DKdHTJaEAvPBFkEVkwDgWCa7xjYORHEY yqUw== X-Gm-Message-State: ACrzQf3IfAL2NVxWkrh0BWQIOJ2OOf89mUUYt9fLWJKT84kQB1UMRDxy 4J+/rHQ9PxIVEuQQdTify/gjLzz2kQ0= X-Google-Smtp-Source: AMsMyM7qoXz2uzSxWmqHeQj6GD0psf/OLcIGduXFONDf8P6SGYNgDvVrSdDAs84tC25sbJ5sU/pLKg== X-Received: by 2002:a17:90b:3890:b0:20a:9ab0:6fa2 with SMTP id mu16-20020a17090b389000b0020a9ab06fa2mr11296238pjb.49.1665069126816; Thu, 06 Oct 2022 08:12:06 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:06 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , Eduardo Habkost , Laurent Vivier , Marcel Apfelbaum , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Thomas Huth , Yanan Wang Subject: [PATCH 08/18] accel/qtest: Support qtest accelerator for Windows Date: Thu, 6 Oct 2022 23:11:25 +0800 Message-Id: <20221006151135.2078908-9-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Xuzhou Cheng 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 for Windows. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v5: - restore to v1 version which does not touch the posix implementation include/hw/core/cpu.h | 1 + accel/dummy-cpus.c | 14 ++++++++++++-- softmmu/cpus.c | 9 +++++---- accel/meson.build | 1 + accel/qtest/meson.build | 1 + 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index f9b58773f7..8830546121 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -333,6 +333,7 @@ struct CPUState { struct QemuThread *thread; #ifdef _WIN32 HANDLE hThread; + QemuSemaphore sem; #endif int thread_id; bool running, has_waiter; diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c index 10429fdfb2..d6a1b8d0a2 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,8 +30,13 @@ static void *dummy_cpu_thread_fn(void *arg) cpu->can_do_io = 1; current_cpu = cpu; +#ifndef _WIN32 + sigset_t waitset; + int r; + sigemptyset(&waitset); sigaddset(&waitset, SIG_IPI); +#endif /* signal CPU creation */ cpu_thread_signal_created(cpu); @@ -41,6 +44,7 @@ static void *dummy_cpu_thread_fn(void *arg) do { qemu_mutex_unlock_iothread(); +#ifndef _WIN32 do { int sig; r = sigwait(&waitset, &sig); @@ -49,6 +53,9 @@ static void *dummy_cpu_thread_fn(void *arg) perror("sigwait"); exit(1); } +#else + qemu_sem_wait(&cpu->sem); +#endif qemu_mutex_lock_iothread(); qemu_wait_io_event(cpu); } while (!cpu->unplug); @@ -69,4 +76,7 @@ void dummy_start_vcpu_thread(CPUState *cpu) cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu, QEMU_THREAD_JOINABLE); +#ifdef _WIN32 + qemu_sem_init(&cpu->sem, 0); +#endif } diff --git a/softmmu/cpus.c b/softmmu/cpus.c index 61b27ff59d..9dd1a4dc17 100644 --- a/softmmu/cpus.c +++ b/softmmu/cpus.c @@ -437,18 +437,19 @@ 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); + +#ifndef _WIN32 + int err = pthread_kill(cpu->thread->thread, SIG_IPI); if (err && err != ESRCH) { fprintf(stderr, "qemu:%s: %s", __func__, strerror(err)); exit(1); } +#else + qemu_sem_post(&cpu->sem); #endif } 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 Thu Oct 6 15:11: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: 13000488 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 E233BC433F5 for ; Thu, 6 Oct 2022 15:29:22 +0000 (UTC) Received: from localhost ([::1]:45824 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSoK-0004mj-S3 for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:29:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXl-0003c9-AH for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:18 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]:43521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXj-0004aw-M0 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:13 -0400 Received: by mail-pl1-x62e.google.com with SMTP id z20so1962831plb.10 for ; Thu, 06 Oct 2022 08:12: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 :message-id:reply-to; bh=80QFJRGf2wqHzaA7G6Y+Ei2sJ8fs6MA6Mk2vEP9/Fec=; b=Z6o5Co1LADEeRzG/RFDZRVSoD7FQ05SLgsL3y7Zclc0mP78gpD6oG7drzDr2jpdg8n DtqkLktl6bEYaIy1rpQ2B+DhIIm49L8uZ37bdBGNQXQi/jFYj8Z/4Kho+3ccoCtiHHhb tYZfPqQz440cCPe3soVexSivtOO5R3S8gZgFC95qryesSKdlnR2Oc12e7NwcXH6CMaWV s83Wxhu4+EVlxyoKOXVRd3/FUn7egCClDmWqL612HHE7+aTd5zgKZOXEfL0kp71IZIL1 ST0sXUdTp4vLXfNu9EnfgVdhUIdxmEF2ajYoPnknLJbx0fX6wQ3mg5nGrmhm9g/B3jmm JsSg== 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:message-id:reply-to; bh=80QFJRGf2wqHzaA7G6Y+Ei2sJ8fs6MA6Mk2vEP9/Fec=; b=m9gp2KqDivPFid8N1EI8sQAbtXXDww/BWv7v425OEtSxM0C32yAmtIJAl48e6WidiJ TdPgLeUPKkJeUTDzLetLH/ks9mTcKLPdEEbZ7stDvU7q3GytST4HlrQPUXcJ/6agyPZA OHLquVy9+GtLue/iYVmxYGJrWS6FtzEpNfTpqiBbXh7zWouwNzTYPlqIR+hvC3k7hmDJ DbW+wKuRqepEbuurQKGSIJoVcnWikz0M+KMLRuQwhOBIzcDLxZ6xZhvDiQQJ4ycJJ16r 1Vn8HdqNbmxlLckmieI1AJNak9FJ7Kc074s8MCSVaENmZ+O9XIVHK45zs9AFWd8wddeZ PppQ== X-Gm-Message-State: ACrzQf2HWPm0GZa6w0x4HqxBslUEye2aTgl9mNsyc3iR5cd5+fEox/cq TKq9gw9muXISJVJIsD5ImpuiXs8/3RY= X-Google-Smtp-Source: AMsMyM6TKW0jM992tAl9XpyLPC8caZY6fzA2ujmthmKvGTAPPsIwq5gJnfMM4XKPYnT7FdLqMkbQHQ== X-Received: by 2002:a17:902:7c91:b0:17f:6711:1fac with SMTP id y17-20020a1709027c9100b0017f67111facmr381487pll.118.1665069129883; Thu, 06 Oct 2022 08:12:09 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:09 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 09/18] tests/qtest: Use send/recv for socket communication Date: Thu, 6 Oct 2022 23:11:26 +0800 Message-Id: <20221006151135.2078908-10-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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: Xuzhou Cheng Socket communication in the libqtest and libqmp codes uses read() and write() which work on any file descriptor on *nix, and sockets in *nix are an example of a file descriptor. However sockets on Windows do not use *nix-style file descriptors, so read() and write() cannot be used on sockets on Windows. Switch over to use send() and recv() instead which work on both Windows and *nix. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Introduce qemu_send_full() and use it include/qemu/sockets.h | 2 ++ tests/qtest/libqmp.c | 5 +++-- tests/qtest/libqtest.c | 4 ++-- util/osdep.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 036745e586..adf2b21bd9 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -33,6 +33,8 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2]); #endif 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 4f4b2d6477..8228262938 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 Thu Oct 6 15:11:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000482 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 1431BC433FE for ; Thu, 6 Oct 2022 15:23:59 +0000 (UTC) Received: from localhost ([::1]:38264 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSj8-00078h-0j for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:23:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXn-0003cC-PJ for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:18 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:45014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXm-0004b8-7w for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:15 -0400 Received: by mail-pj1-x102f.google.com with SMTP id t10-20020a17090a4e4a00b0020af4bcae10so2019177pjl.3 for ; Thu, 06 Oct 2022 08:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x1FTgrQXR6uNMn6KBsxmdWGkHMmBa5ff+i5f1cGTWhw=; b=h8d7PBKABPESlh9PuRVZ/fUcpqKe9alWw4fi8huTY32EboIcDylcl8t7xBZHnqOYUz M09GkdtgcTRiGLm9OicK/9HSgcVYj/MvDZ6m9LyQGhGfJoX9rRdzF8lu1gI79dRoY5bT kk5phn+TbBbsmXLDF226+ZDzDvM2LLfQ7lvxo0uxyGiOFRAvCT9IF/9Sgc+9FS9iyHTN u0vvWtEv8YgM8a0TaatHtMoNF6eefBPmPH7vMKgJr4yMlUA2o2moFxcm3MEsWFY2dNMb vJo4apmGAofa64FX7LrIyvndWhhFEDsH8uODlpVe18EDwoyWwVb4ftUqKgUHFJ6zr0hm 3aYA== 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:message-id:reply-to; bh=x1FTgrQXR6uNMn6KBsxmdWGkHMmBa5ff+i5f1cGTWhw=; b=qxXZafQpieZqwiIpFYswJJbWaWzksywZbWRh8cWkU5r4zI/0VDIFSbWK4cRzWNuJIP mlExM8lKICfc+WcvRvP7y6v7OoXY/OG4TLj1QUVpkFsx1A+40nUfL3hc7gBTRkfpJKHs n6aIIJ7XRqG5H4Hb1nfhv2IV3msL5rXl1Us7/pKHGfav3ZKhHKz7QLmFDPbDrNjZFT1Q KSr2TAvegbSaZ5ED9V6xrZug/NGhlL+L8HFi8981plxsVUbuohu4vw8qssDqwbLePNec bwGj7j26Xng5rGk22k9Ctu/GJngC2+y/xc4hHX0hEtNdWu31jqPw6euZCa+4IwWPRXUh KaeA== X-Gm-Message-State: ACrzQf1gLu5pNgoeJFh0SIkYwKWChhfgpRFuKyv2xYnHIw7jEkDThGuO Me7IYDxyWMfXRBldrsXTmEwvgybCQdQ= X-Google-Smtp-Source: AMsMyM65XrASXH7AA3KnXulWigEt2iCLnfMIGd8rFsq6a9WtyGtMA/jHB7+KfDZfFhn1L38nZxnasQ== X-Received: by 2002:a17:902:b415:b0:178:2835:29e7 with SMTP id x21-20020a170902b41500b00178283529e7mr35767plr.86.1665069132505; Thu, 06 Oct 2022 08:12:12 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:12 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 10/18] tests/qtest: libqtest: Install signal handler via signal() Date: Thu, 6 Oct 2022 23:11:27 +0800 Message-Id: <20221006151135.2078908-11-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng At present the codes uses sigaction() to install signal handler with a flag SA_RESETHAND. Such usage can be covered by the signal() API that is a simplified interface to the general sigaction() facility. Update to use signal() to install the signal handler, as it is available on Windows which we are going to support. Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- Changes in v5: - Replace sighandler_t with its actual definition, since it is not available on BSD hosts 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 8228262938..54e5f64f20 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 void (*sighandler_old)(int); 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 Thu Oct 6 15:11: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: 13000484 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 92F10C433FE for ; Thu, 6 Oct 2022 15:26:36 +0000 (UTC) Received: from localhost ([::1]:41018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSlf-00011m-NP for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:26:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXr-0003dZ-6i for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:21 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:43844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXp-0004bN-65 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:18 -0400 Received: by mail-pf1-x433.google.com with SMTP id 204so2293379pfx.10 for ; Thu, 06 Oct 2022 08:12:16 -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 :message-id:reply-to; bh=AKumlSHvcb7ZyxfM85hH84PZtR+gkhdH2/Ps48kqWsY=; b=PMymZLyi7rFXVIvYjTMhGD+jOPJFUmkTWWW+umT8ITVNdiJ20JTQXrGE8sriLJOtI0 OyS4aRtVyqrMTnZQ1S7kNv+o0eO7Mqa4Ew1hlGXqqy1Rx6FVmRv8kPofkIF/YBjaNY7t 1cP6WSgVyEq4ncS2uxabtGOkEI2E7FNb3KR15VssQd8gTXFQ2aACWA3AqAYXh/BIKDVX pygP5n7yluCPvsWTJrikgh/waXuA6yQnEgy0eCOF5T3X22wr4EUWXtm/nK1WJpWCwncF 4sEMEyADxtvFPfWwoUgxnSqapNs9L7gLTnj+D5cuTLZcTLZAFLACcBfvdJODxnKqIqgu nGDg== 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:message-id:reply-to; bh=AKumlSHvcb7ZyxfM85hH84PZtR+gkhdH2/Ps48kqWsY=; b=uDHtyEM0izXzdj2KSiAfUeebHy1YDBDI6Zsu2b4esrK46hgqeorz6MqVjgnl1evkkW faECHOAfz0GDDI9ngzt66DDPX1r2LKZiv72JIyjvIGuvODb/VEgTWffE24BzXWqVVulm QzoV8++7iZ+ejs9ETP8BPbUGuIuyzinlbN+b8Jq12qbt5krMQeLq8TvhytzOgqfB4PJe LbfDjhSgCKGLxHjRt7Uy0xaA2jH4VHZqvpEjHcbT82PxJ0nIgHkp6JY93LkysgOSaOdq cW8hgLqHGcJ9lBldgefozd4TfVyefuw+NgJKl/vlUbMxojEN8lPGJ930kvnb/Sa7aGqU j6HA== X-Gm-Message-State: ACrzQf3brXXom8XAVEYvyVQTYeu46vinUJHQNI6li2uGLaS19rf8kTjR xEp/G1WrKlKvDIV/V7QtYUS/qmlqC70= X-Google-Smtp-Source: AMsMyM5WsY3+TYxfy1BpUVq5I/i6ddGhHWN3QfkFJwPqCnxz/KmJzsFmQwHWhalaYwdXFBB2VndeAg== X-Received: by 2002:a63:1308:0:b0:440:5517:c99d with SMTP id i8-20020a631308000000b004405517c99dmr322760pgl.550.1665069135373; Thu, 06 Oct 2022 08:12:15 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:14 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Xuzhou Cheng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 11/18] tests/qtest: Support libqtest to build and run on Windows Date: Thu, 6 Oct 2022 23:11:28 +0800 Message-Id: <20221006151135.2078908-12-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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 At present the libqtest codes were written to depend on several POSIX APIs, including fork(), kill() and waitpid(). Unfortunately these APIs are not available on Windows. This commit implements the corresponding functionalities using win32 native APIs. With this change, all qtest cases can build successfully on a Windows host, and we can start qtest testing on Windows now. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - Move the enabling of building qtests on Windows to a separate patch to keep bisectablity - Call socket_init() unconditionally - Add a missing CloseHandle() call tests/qtest/libqtest.c | 95 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 54e5f64f20..ecd22cdb11 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 *); @@ -118,10 +131,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 +157,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 +181,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 +198,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 +286,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 +345,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 +354,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 +363,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 +372,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 +395,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 +416,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 +482,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 Thu Oct 6 15:11: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: 13000489 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 6D1D3C433F5 for ; Thu, 6 Oct 2022 15:29:27 +0000 (UTC) Received: from localhost ([::1]:45830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSoQ-00050y-EX for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:29:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58134) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXv-0003fZ-3d for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:25 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]:42541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXt-0004cj-LZ for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:22 -0400 Received: by mail-pl1-x629.google.com with SMTP id c24so1962636pls.9 for ; Thu, 06 Oct 2022 08:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9AFisMEhPtudU5rqA28QSZ0J20KCJlzzQQR7vCLusZI=; b=qDj61fpMDU7ofxInZN8Iixa2HVBIJr0J5QKjAIWQ4k2mLUczR9SgLKEFxnrHYfUwDK OBIVT7q/OhlTayxdY8tSqT9IB3rELdDvh9SnoJRW7+LZkuUwyAKsCor1i7ggdvfEFFfd YTja1gEFnZ7dNVC8c2wypZRV2uDRrPsig2PrMwXdx7WlqCcaBO/fwy758sqOJUW9KL+W gFaDVb5kSmnGj8SDj86RubV2KtmPGds1fHM/ZSbpO+ri/W2g69YMq2htG1Mcg1g3TC/1 lEUyw+aXJXvUFgE4ndo+WaRTM4jiiu3ssVdc492XUPypSh5jpqiEjtQPbc3wVeKwEUMd MpKA== 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:message-id:reply-to; bh=9AFisMEhPtudU5rqA28QSZ0J20KCJlzzQQR7vCLusZI=; b=NsrjdBeN9hO6Vlf+/iso5wrHxM7KksiMgbjWbnA26gbimNB5ZAqlNwd+P9gUguZcM6 224tESqcyp/g/H4UOoKvw17lD+uvJekSJ1/gl3JkQtISUJlUP9O+IyzToWV8NqsGkk8Y ai0UlNkwG5wUZRgTw5JjUAU+ikWD0rjuQSAMgUSrZEvzYfAND2YwmQtWHvdcMj0JnevJ rxh03cbdrdsGNOmKavoGtZ7AkCtxGkL4UoHnzwlIA0TPf5GJdoen1sgT4rjmMzMZhe82 ho7oqdNiAC6DyklMUjVu0DVHjb8JzxTR65zvlY0h58+jN4pBcAIWle/HM3S+up2xWijU 0iFw== X-Gm-Message-State: ACrzQf2i68QnvM28ma2UliYbbOrhrHCxvgPmV3NGdynWbFPkliBm4ChD Gtj6h1b9sunh7TWbsYIYdqudfIxC868= X-Google-Smtp-Source: AMsMyM6yuSErXZB296yjwbTq1quK825gRVrj3DXZRMmfUv85l0CXTCuk8G/NIwKr89mcFJ/DcG+uvw== X-Received: by 2002:a17:902:7295:b0:17d:5176:fe6e with SMTP id d21-20020a170902729500b0017d5176fe6emr5041766pll.147.1665069139036; Thu, 06 Oct 2022 08:12:19 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:18 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Xuzhou Cheng , Bin Meng , "Dr. David Alan Gilbert" , Juan Quintela , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 12/18] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled Date: Thu, 6 Oct 2022 23:11:29 +0800 Message-Id: <20221006151135.2078908-13-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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: Xuzhou Cheng Make sure QEMU process "to" exited before launching another target for migration in the test_multifd_tcp_cancel case. Signed-off-by: Xuzhou Cheng Signed-off-by: Bin Meng --- (no changes since v3) Changes in v3: - Add a usleep(1) in the busy wait loop Changes in v2: - Change to a busy wait after migration is canceled tests/qtest/migration-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index ef4427ff4d..e5ba0e21d2 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2140,6 +2140,10 @@ static void test_multifd_tcp_cancel(void) wait_for_migration_pass(from); migrate_cancel(from); + /* Make sure QEMU process "to" exited */ + while (qtest_probe_child(to)) { + usleep(1); + } args = (MigrateStart){ .only_target = true, From patchwork Thu Oct 6 15:11:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000499 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 D84D7C433F5 for ; Thu, 6 Oct 2022 15:39:36 +0000 (UTC) Received: from localhost ([::1]:56820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSyF-0004bF-Pk for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:39:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXx-0003fl-3P for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:26 -0400 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]:45894) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXv-0004cq-GQ for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:24 -0400 Received: by mail-pj1-x1036.google.com with SMTP id o9-20020a17090a0a0900b0020ad4e758b3so2011503pjo.4 for ; Thu, 06 Oct 2022 08:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KikajeV1rfLr6F/ZMb4ysQ02AJPYh5p4ZSc7N5x5QVQ=; b=RAC8wIjtAM3cMEQui3qfpU8HWGF9gyfeCq4zEp4gn0021S8/CgcWO5Fu0YZtAJUED2 zqt+q41WPHkBDtyr11hV6mLIOMAvhKNWrcuPjYWsOXlLJliAyK2tmUFJn1TsTazA7EYW 230XCV5DKs6osnokNwOvI6MO91uKgFUdC6MeAnzsCkIISXHRX2t/Tl7kqGQ9Ehb0agej IRfl6xuSWvJ3FEf8b1wZMeGXhe7UpgbdgjDwIsW93YKuhS01hwEACTagroN4dAD0xLRJ OxGPhSLmwH1Vj8O89Dh1yBKR74N2j9NmTKVeAV+UQEDPZGA4RWb2TP0o6f5bvO8rgH2a L6zw== 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:message-id:reply-to; bh=KikajeV1rfLr6F/ZMb4ysQ02AJPYh5p4ZSc7N5x5QVQ=; b=24hSfh0VYSQE2c18VRRPbQLjjqowWRhrIEJfjVh5g/lNimt6mIrxwNonSg9PEHkjdD gJ/phUyWSasGWL4P3WioYXLizs2ldiB+/+77efL0RbUPv+et0JHTb1Xt9s+9m4y1GqUo d9rKtWgViBxLsaW6LUkTWj+avRm2a8f09Oc1gXa0iuden5ZyfCyn1KY516/ivcfROm/l a/Iu5UOvQFR2lJIMZKXD/V5eM5o+yEbsiu5uOMzWEkm0nb3oEWCDi8gd9c4mkwShCGR9 rBTpSVoeER2TzJkw3fijqek8LgeqtttEi44ESQysOgyV2LPq3Krna+jvlWH8rEyQ63HG hZ+Q== X-Gm-Message-State: ACrzQf02stH5U7Eitj0ZYh6O6TfTYHhOfBU+Q0DL6EGLHKxDaUZ8485L dG7NzOQzoW+vTt8MUiwq5spr3eAd9Bs= X-Google-Smtp-Source: AMsMyM4T2HM5SyE6oQT2g0AZOgdCKKdsgmNLlodob/Vnit5zx7gp0BoGrFIXhGeXc/4ZBLp1F6NYMw== X-Received: by 2002:a17:903:41c2:b0:178:5ddd:c75b with SMTP id u2-20020a17090341c200b001785dddc75bmr411936ple.22.1665069141809; Thu, 06 Oct 2022 08:12:21 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:21 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 13/18] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32 Date: Thu, 6 Oct 2022 23:11:30 +0800 Message-Id: <20221006151135.2078908-14-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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 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 ecd22cdb11..d52883c361 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" @@ -103,8 +104,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 Thu Oct 6 15:11: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: 13000491 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 CE930C433F5 for ; Thu, 6 Oct 2022 15:31:43 +0000 (UTC) Received: from localhost ([::1]:59618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSqc-0007C6-Hn for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:31:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSXz-0003gD-6a for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:27 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:43549) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXx-0004ZE-Db for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:26 -0400 Received: by mail-pj1-x1031.google.com with SMTP id g1-20020a17090a708100b00203c1c66ae3so2047492pjk.2 for ; Thu, 06 Oct 2022 08:12: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 :message-id:reply-to; bh=wJ46lPbUundlzLry/XhmGks2ORwcj9XXEHBkBSD1tlY=; b=Rna0mLkdKWhgCJ/ONS7qgZETjRrCNSF0mes0fnT3xScgmTvdcsaWZKimDyemjd/XZm VVjK0YAtUXXdqg9Zbhfyt28k2+Jnr1U0L3kbtgxzBGOprCE1tn6cQoJ7Jfb/P6juvF1e Kura/+LoPsBOYJhvacPp2ezEE3T/OMZkCZLY9nSMSZqdJgNIDLQCc49jUBlThOAvDs3m Ovg3UhdteuopH/8lPINOtRvZkoxG9ue6Pad1QvkjYg6ttgVxR7eOjwJjUDjW2bdj3iWp 3YJoFeG+wDIZjuhPVHoFV9aIgn2bX4qFtbhD6LECm9A6CJJ2F+dOv5BKHtZbXNBQ4ai1 Embg== 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:message-id:reply-to; bh=wJ46lPbUundlzLry/XhmGks2ORwcj9XXEHBkBSD1tlY=; b=WZ/KtYq0qCtvyCswak39oViJM0nMQFnsB6YHwZDvyPHyoag8/R1sRoBhEcq10MLWt+ sSaRDFAsrYtCfyZXVdm+gfqbSfeW583XLEX7URB2fjNvVpVkYTyxKTYAkdxlx5AjtRum PanNd/6StFKVxJmlSbx+RPkqqgwzSrkGPDsj1qkCOemFc4N96SXEKYuz0My6YqXb4NbU SXu/o8UvfMYmov0BCbq9CWL0mTIHkUsk7PD/0HeOC9OKDIt0MOE/4P6GLgeGgJK1cuub GkK5aRpM/1lLnUp0QkF/sd3AX543cLxsuH6io7WrEGG9m5sASlaOSi0kiHzqf2WOhADs qA2Q== X-Gm-Message-State: ACrzQf16K/EzYElVSzX/AbXffkgx2kQyB2ubY/lvfGyVDZe/cy2QWVaz pRaaGtEf6OXmujOgWEL7+WRb3+T2eXA= X-Google-Smtp-Source: AMsMyM5pH0SKJ9BQvbGqcZ7pdz46nmFYY0yZsgSgVi04VaBCJyIRP3c/p+5AH3T2R202+oueYq2ahA== X-Received: by 2002:a17:90b:3b47:b0:202:d9d4:23f7 with SMTP id ot7-20020a17090b3b4700b00202d9d423f7mr11030675pjb.56.1665069144081; Thu, 06 Oct 2022 08:12:24 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:23 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH 14/18] io/channel-watch: Drop a superfluous '#ifdef WIN32' Date: Thu, 6 Oct 2022 23:11:31 +0800 Message-Id: <20221006151135.2078908-15-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1031.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 Thu Oct 6 15:11: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: 13000498 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 C0899C433FE for ; Thu, 6 Oct 2022 15:39:31 +0000 (UTC) Received: from localhost ([::1]:54604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSy9-0004Tb-BB for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:39:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSY1-0003gO-CR for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:31 -0400 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]:39459) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSXz-0004dD-QQ for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:29 -0400 Received: by mail-pj1-x102e.google.com with SMTP id v10-20020a17090a634a00b00205e48cf845so4598239pjs.4 for ; Thu, 06 Oct 2022 08:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FMvqR5WvHSrhd6FoBOh5bPNiyVgL3g0xwaaD6f1HGpU=; b=DHx779G3S85pf5a8Ust8Zyz34MSSTB3Q8SpXdN/VEjCZqeB+yHPRKX+Rj4elVQIxoG OWU1nWiNJDLXJ/cgUb3enKnd2K3HoIMUxan0zAzEmugXPvGey/Gwc0K2RsyNaJzWHXUY HMdYmij8Mi8GidT68vGjUe+Xf/VOnFhNcELiL+KxSBvSVv338S/w4jrWEEFk1LBMsdeG aw7WWdoJZeC4Ehc+bdUqgtACAKFnDv3cm+C4NO717qW+0biARg3QGciqykeO1Xv4tkSv xWgyriVM+oiY7jo71Wz4xsbqAUxWRSHzX6jGdgpasDUnZa5xhmt6hmAex+UJ76s8acx+ T9jQ== 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:message-id:reply-to; bh=FMvqR5WvHSrhd6FoBOh5bPNiyVgL3g0xwaaD6f1HGpU=; b=7Q7TsN6Zz7dIg8Cdncq3+0AHpLLuk657t7rESmoH5KVjwaLige4ETjbE39TPaaoZKg uIDCEy2OmKINuDMzM5NGymt535wgS5g5lrnuS+xDcl77vNO/ov8iY5OiermYNZlWSi3v 6OvgoU2SmwJHukcdvKtSMuGDzOwD4lPjF+WCvGsTC7qAYGz3qGu0fBQMyKGrcLrWooTD 2KMFuQf0+4RErNzavTSimC8hLp1FLvYKxGCHAXPF5xYRjLcvDMjqxtHGhRB57dNLQiMy qyM8m/guT9ZbUwpu3tgy8ZUFhTXieOPixTCJzF3itrmdurItoinFl+iSzV/WARN2yCgC w6Hw== X-Gm-Message-State: ACrzQf2t8zj3uvVbCV1pHZrthESr7E4ULYaglF4YSTLJ6pL7aKc8xSya n3tDkd6s2+DxdfwRfDKq0UIbkLdPvsY= X-Google-Smtp-Source: AMsMyM5F3E7TReYXhBylrX09pIoyAiiA9WEu0XzzOGhuKDb3K/mQZCTuhPj7Li+UzxmljRp5exuF/w== X-Received: by 2002:a17:90b:38d1:b0:200:8178:1c94 with SMTP id nn17-20020a17090b38d100b0020081781c94mr11207237pjb.219.1665069146237; Thu, 06 Oct 2022 08:12:26 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:25 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH 15/18] io/channel-watch: Drop the unnecessary cast Date: Thu, 6 Oct 2022 23:11:32 +0800 Message-Id: <20221006151135.2078908-16-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng There is no need to do a type cast on ssource->socket as it is already declared as a SOCKET. Suggested-by: Marc-André Lureau Signed-off-by: Bin Meng Reviewed-by: Marc-André Lureau --- (no changes since v2) Changes in v2: - new patch: "io/channel-watch: Drop the unnecessary cast" io/channel-watch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/channel-watch.c b/io/channel-watch.c index 89f3c8a88a..43d38494f7 100644 --- a/io/channel-watch.c +++ b/io/channel-watch.c @@ -130,13 +130,13 @@ qio_channel_socket_source_check(GSource *source) FD_ZERO(&wfds); FD_ZERO(&xfds); if (ssource->condition & G_IO_IN) { - FD_SET((SOCKET)ssource->socket, &rfds); + FD_SET(ssource->socket, &rfds); } if (ssource->condition & G_IO_OUT) { - FD_SET((SOCKET)ssource->socket, &wfds); + FD_SET(ssource->socket, &wfds); } if (ssource->condition & G_IO_PRI) { - FD_SET((SOCKET)ssource->socket, &xfds); + FD_SET(ssource->socket, &xfds); } ssource->revents = 0; if (select(0, &rfds, &wfds, &xfds, &tv0) == 0) { From patchwork Thu Oct 6 15:11: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: 13000502 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 AA933C433F5 for ; Thu, 6 Oct 2022 15:44:16 +0000 (UTC) Received: from localhost ([::1]:37314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogT2h-0002M9-MG for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:44:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSY5-0003hr-V4 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:34 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]:33639) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSY3-0004dR-O7 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:33 -0400 Received: by mail-pl1-x631.google.com with SMTP id 10so2049876pli.0 for ; Thu, 06 Oct 2022 08:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xIwwdkQ/UueIjTq9LmfxXmdWH0OF4K6cF8/Wmny7JFg=; b=ptjH96eZLcOPZIa89aXnOna4fjBx+XdIXzRoKJYPVSb5+JOPAdfLboRINLsamvzI4w C6shwD/eEmKzJG6s4LgG4aHBvc10M/ClolM7Aaw5Rt1FA6aNnRlcttjwn0hbgZ+83xIb i62wPyGLdKMlII0V6mGRQFmgGa3Pf5Zr3/WgQBrmo6wGhqFBW/YGqxgITHZkwwxs7WjM sBUDrZvYtZh6biqGVtrWZECtq2WUxi0vKLmPyhtuGd49XC5AJfFuae8bZq7NBANZKdcT EpjTwJkch9h7QGE9FC+Fd7OzuI5Y9fEEDq6SczCJpf9D9fHnnO3imlUPUrgqXooc2MMp TjzA== 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:message-id:reply-to; bh=xIwwdkQ/UueIjTq9LmfxXmdWH0OF4K6cF8/Wmny7JFg=; b=WrqtrYkjww6eEKJVNSq7UKPnnj+cMOXVlOL6eKrnbaOtVa4dxNyFzxUvMBI+zOgYIk Vvz3E+HH2A+0kRA2n3sCml0ldQbM3JAu2Qx6MtRCIFDogYzHqBAfGKNqKpwNaARfstHp CLhhbebpeQR+3Hf0cQWs8IfeVRzzzWJmUeZo4rFcXiHBR+utlY97u21zt6YfP5ky4XRt ChZLWagDnmfVCpOQ/SF8K429KuAPAlEG7thbSe8kNecb08nRx0hc7WeMmblRRXhuEYF0 Gm95z++ZwB1HPTIas45kGsxBDie28qy6g4Fnhie4fB2YMu7icwfxH+H4EiUlQjpczEUT EZpQ== X-Gm-Message-State: ACrzQf1ZHW+EhGb2KBKoxYgboxVN1IuJhevfYVtYDMAbG2J+uDv7w17m z4j793J18rmlkDZ7X8oB6dGbsaQ8tus= X-Google-Smtp-Source: AMsMyM7QkylIpN/Rw0Sa9lka17lluY0zgdKUv1quQUllwRo8JObz309J9UrHTvdSutDcqygEh+9CKg== X-Received: by 2002:a17:90b:1c88:b0:203:8400:13a9 with SMTP id oo8-20020a17090b1c8800b00203840013a9mr237936pjb.46.1665069148469; Thu, 06 Oct 2022 08:12:28 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:28 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= Subject: [PATCH 16/18] io/channel-watch: Fix socket watch on Windows Date: Thu, 6 Oct 2022 23:11:33 +0800 Message-Id: <20221006151135.2078908-17-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=bmeng.cn@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng 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 Thu Oct 6 15:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 13000504 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 DCA28C433FE for ; Thu, 6 Oct 2022 15:51:59 +0000 (UTC) Received: from localhost ([::1]:54144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogTAE-0008QM-QX for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:51:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSY7-0003iv-06 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:35 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:52765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSY5-0004dc-DG for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:34 -0400 Received: by mail-pj1-x1034.google.com with SMTP id pq16so2014083pjb.2 for ; Thu, 06 Oct 2022 08:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NCD0OoweK2TuN+Pq4vH+vNDBt5GFzsQ5yHOp5dnrTlM=; b=F5X/2N/rWtMDYx/WvEnIuaPQo+YKXUC89n58/WZ3vFWn43ebFcXAuMvjxFQbdFJF7e WFicPCJIMeEJwc63+ONlOjCj/dCo5V6Mcte5b0wu/KxEn4+ch+imj5N+0IMmczF3iOIk tlgxjDFpBo4Uh7S0LRO1iD4etLK0B0tHOwoybOzlFq/NrWNjKA4zT1ybHCuoDSXwBQkW jJiWWdh1jMi0ulmajBeSOHSTKOINUJBqxFJS6JitoF7Y0Ui5P9aVbsJxdOVk2pQLNYMK qri5+GgxVTpUa3W0pBpcNoBgi7gimEZICILyqPxzW4kRiHNiiG637DIazJQHt5KMriEp BTmQ== 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:message-id:reply-to; bh=NCD0OoweK2TuN+Pq4vH+vNDBt5GFzsQ5yHOp5dnrTlM=; b=ImjxB/DJuJ24anaJhRSHaHdPpduUSnc6kFGcETaxig0PQt2htUktwob9SwSd6T11t/ PyuGGVD83ATntVCcVVbSzsJwQr/LeY29Zd7uGv34lPf33wVV/pBVvYy5oPNLqgZnG13L ZkrEiwd41yidCsDJJ2EFUqKzoXfCxzKgYDup5Me87lXM8OmJ5v2yD6VOFGDa4JWXwIgx p4OO63kyFoXX48CUHMBPfNK/QEfZmogxE+Sa95NT7GErcQt6dbveljELKvSP/gjCIWRG Ej7OQWKehcIFFc/tMHYjOGyMT59eAoUE1W9kEebzo8GCpCIe1w3uHqUuDrC95J1XGoUG QgYg== X-Gm-Message-State: ACrzQf1NsveFfFJKfRfbYJ7uNBtkJ2ousHTbJafnLhToYwdCBbxmR2bO Rh7X2luwkVLfkC8vQiD2IjiAqGWxa1U= X-Google-Smtp-Source: AMsMyM63ycZXVFnhinYaES9biplx1D/d2pwLAMMvDjiz7NTkcFdwowBgDH8f0JtqWLpF6VW33Naa3g== X-Received: by 2002:a17:903:18b:b0:178:1c0d:da22 with SMTP id z11-20020a170903018b00b001781c0dda22mr359154plg.95.1665069151742; Thu, 06 Oct 2022 08:12:31 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:31 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Thomas Huth , Wainer dos Santos Moschetta Subject: [PATCH 17/18] .gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes Date: Thu, 6 Oct 2022 23:11:34 +0800 Message-Id: <20221006151135.2078908-18-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Bin Meng commit 9f8e6cad65a6 ("gitlab-ci: Speed up the msys2-64bit job by using --without-default-devices" changed to compile QEMU with the --without-default-devices switch for the msys2-64bit job, due to the build could not complete within the project timeout (1h), and also mentioned that a bigger timeout was getting ignored on the shared Gitlab-CI Windows runners. However as of today it seems the shared Gitlab-CI Windows runners does honor the job timeout, and the runner has the timeout limit of 2h, so let's increase the timeout to 90 minutes and drop the configure switch "--without-default-devices" to get a larger build coverage. Signed-off-by: Bin Meng --- (no changes since v2) Changes in v2: - Change the timeout limit to 90 minutes .gitlab-ci.d/windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.d/windows.yml b/.gitlab-ci.d/windows.yml index a3e7a37022..093276ddbc 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 @@ -60,7 +60,7 @@ msys2-64bit: - $env:MSYSTEM = 'MINGW64' # Start a 64 bit Mingw environment - $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu - --enable-capstone --without-default-devices' + --enable-capstone' - .\msys64\usr\bin\bash -lc 'make' - .\msys64\usr\bin\bash -lc 'make check || { cat build/meson-logs/testlog.txt; exit 1; } ;' From patchwork Thu Oct 6 15:11: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: 13000501 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 CF0D8C433FE for ; Thu, 6 Oct 2022 15:41:04 +0000 (UTC) Received: from localhost ([::1]:37236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogSzf-0006rF-HD for qemu-devel@archiver.kernel.org; Thu, 06 Oct 2022 11:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogSYA-0003k4-Bb for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:38 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]:44642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ogSY8-0004du-6l for qemu-devel@nongnu.org; Thu, 06 Oct 2022 11:12:37 -0400 Received: by mail-pg1-x536.google.com with SMTP id c7so2100887pgt.11 for ; Thu, 06 Oct 2022 08:12: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 :message-id:reply-to; bh=WkoA3/IdgkFbPFM7JOrL7Fwi0zdak8HIGCewrWVpcWg=; b=UXducB6WIlPHbBbEwxzKyEAsQyjAYTnngzjFpmvuF08AizvF9HTSGbdPlE4PAVxyqa 12vIFLK5+8EKr3w2J0Dt9NyJucakRuviQLFG9uM+YZC47z8HnECWoBNsWMRuxj807I7m l+HrYxLAaGE6XEMsCFPH8RQBEriT9Yvq1zF3aZQmKhHrWBj/yAAb1nTLDX3yS7f7Mjzu QL92KkNLQq5YZfTBC4UlK+rCcaysMVpnWMPxybFeFVy+vo0RgKhO9ibPV1U8aMunMYak jtVy4Nwt1spFyQdVOtge4joW0Hz51kLZi+fcVUQug9ydzIdOYa7yuWLyj5iNPKMtf7wn 7New== 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:message-id:reply-to; bh=WkoA3/IdgkFbPFM7JOrL7Fwi0zdak8HIGCewrWVpcWg=; b=N3SRyVH48z+pffzd7ZT1NHUzy7tayjqA5PmLD21po5ViB/z5luVgxEf9Gta5c9mtHL GRVrW1JXKm6/IzQnM/UAqJgxHLsuscq9V1uTfMLjAGMGXZVHv+Oxm68vxNGfHsFzG4Nt YeXetuXxft2+60Oe8UnAJpc9bp2RKsm5AXK2m9oyJMbKDsBBJBKPxWw8LpWEHbYZF83H SD8+M2hB8mvQLzap2iaCLRKD276zmEB3kXjR3zgMwy+Mmc/2p9WW7GFjPGx6iPTa42CZ tmECSqQDvp7wGeTyPZFavNhMNiVzSkE6/rKxXThF/NWQE3vwcSKzPybzLybHKn86jenP pNzw== X-Gm-Message-State: ACrzQf21EzjE+4s0tWHkO3x5XdI9f3X64UuyN3xtp+a7x9T2rMSLAiV6 AKFjnFLKl9G83QDiU4ccaAYLzxDaIqc= X-Google-Smtp-Source: AMsMyM4jETCHZxXBwjGwCJa0zoIlWOe9kh3+CKs2RNPaOV0XvYTl+I4nil3sZzMnoVmA+2M3VbEezQ== X-Received: by 2002:a63:e442:0:b0:438:7919:adf with SMTP id i2-20020a63e442000000b0043879190adfmr347912pgk.4.1665069154525; Thu, 06 Oct 2022 08:12:34 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id 135-20020a62148d000000b00540c8ed61ddsm8589067pfu.150.2022.10.06.08.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 08:12:34 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Bin Meng , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH 18/18] tests/qtest: Enable qtest build on Windows Date: Thu, 6 Oct 2022 23:11:35 +0800 Message-Id: <20221006151135.2078908-19-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221006151135.2078908-1-bmeng.cn@gmail.com> References: <20221006151135.2078908-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: 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 Reviewed-by: Thomas Huth --- Changes in v3: - Drop the host test Changes in v2: - new patch: "tests/qtest: Enable qtest build on Windows" tests/qtest/meson.build | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 455f1bbb7e..8701c3a8e7 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -1,9 +1,3 @@ -# All QTests for now are POSIX-only, but the dependencies are -# really in libqtest, not in the testcases themselves. -if not config_host.has_key('CONFIG_POSIX') - subdir_done() -endif - slow_qtests = { 'ahci-test' : 60, 'bios-tables-test' : 120,