From nobody Mon Feb 9 17:59:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661337118; cv=none; d=zohomail.com; s=zohoarc; b=O5PDh3jtaaR9rsONjlrC4qV+p0xlQHJsdhUI8s3iUNzxA1hwUbz+pAcNS6FlqMoPhhoMdhk108qqt8ifEhO4eu+1uT+kiTq2s9Mn3cQR0MJpLdLxdQxTzZuKrXFigA1FfYKC7c8J8yG3NMmi92smYxjqPQHZCno7RGCZRbctNuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661337118; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IfI/qWhUWiZQhG5XwWjV6xjarmHg12V73Blb6zZFpuQ=; b=a8LTmOA/AXjEOnoVG8DbfsT1rY4fYnhjeXaYi3z7QT/8G8FSg0ekVKQsRt/fLD9BgtrIdMo8tQ7isHMQB8CTEZUBvbPtztkd3zaMTfNfxm7EUU2VlL2OiBmn3SbTAtGBq08M/W/iP/bin4dFPSpqAHZzYrl5XjQQuHAnrwTETt8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661337118437614.7787399792603; Wed, 24 Aug 2022 03:31:58 -0700 (PDT) Received: from localhost ([::1]:56818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQnfo-0001HW-AQ for importer@patchew.org; Wed, 24 Aug 2022 06:31:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45852) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQmuP-00046t-O0 for qemu-devel@nongnu.org; Wed, 24 Aug 2022 05:42:50 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]:41956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oQmuO-0001bT-0Y for qemu-devel@nongnu.org; Wed, 24 Aug 2022 05:42:49 -0400 Received: by mail-pg1-x533.google.com with SMTP id 202so14542886pgc.8 for ; Wed, 24 Aug 2022 02:42:47 -0700 (PDT) Received: from ubuntu.. (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id b14-20020a170903228e00b001728eb339e2sm12165972plh.286.2022.08.24.02.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 02:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=IfI/qWhUWiZQhG5XwWjV6xjarmHg12V73Blb6zZFpuQ=; b=lgIvNYS2uxagdXZauE9C99i9XdDYqd8KPAc1aWEHEl3QH9uGAj8wgzNykpP7DX0YqY 2dE5eJBC9O5CBWv7EJpLMcAVgqCbzQ8bz3m4MEiqbBr1KnkOwxT3sz8Yw70UJ7WNtsSz 31CuFlzqfgxQkQ6jdHUxfZhQmwkGiLyBdnezlzyDeJoNIwFRQHoyUd3zfAbwPmyqcEjJ D+dAeGva2CA5hZ54wRfOunVGapRIkhtNzrzB8QgAE+tQu2/SPMk9R1fR4hfB0uGFBw2t lAndgigtdIBo24kYN/5FxUZQpu/VAXhH1/lLRswBCZTFuy0fgFUAf4hXiuBk2X77xKTn j3Iw== 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; bh=IfI/qWhUWiZQhG5XwWjV6xjarmHg12V73Blb6zZFpuQ=; b=kP4xGPpnuDqoy3H3j1rpXPV49UrjfS/rjeaLbi9HGv31ehdDKfi/pGrqy+yJBvy2Cn 0AqPha+yZ2RZ9SFnpACRxpPXzptitilGJLns+qk3T5D7mi9YNBd1kcCNBXkNx0E9YVKf b7LR4DgrIbKyvHJ/J4p2Yd5eFhD11s/5VcT8pQnp24py/pOFGf1NgFp3tSa3QlSUARvm ili3KJQ6ZZkK/qryVHjyCalVXA1lZuXoTwgGnwez1u/7rUM/yQuA4o3nISRkgWvqJ7/J Z7yHKkWGaqUnAtiDUHDPe0ut2oFyMVLgo1a316IsButDkMOcHSIlbZkPapxIpLhmHmXF 0Odg== X-Gm-Message-State: ACgBeo0O4eFTyluYeXR9Om9vTZR78TaLZB32yovel4Y6O6GcLeduztxN 0uGCRyE+fWPoB/B86bKBbWOgmrLfBVM= X-Google-Smtp-Source: AA6agR5sJ9C0HFPuKJAG/c6z7BkLhItFVTK2K80PhDjyHaoJLFMEwWfHP7cOEBwuVq2W0Jw+keLmNw== X-Received: by 2002:a05:6a00:1410:b0:528:5a5a:d846 with SMTP id l16-20020a056a00141000b005285a5ad846mr29523999pfu.9.1661334166406; Wed, 24 Aug 2022 02:42:46 -0700 (PDT) From: Bin Meng To: qemu-devel@nongnu.org Cc: Xuzhou Cheng , Bin Meng , Laurent Vivier , Paolo Bonzini , Thomas Huth Subject: [PATCH 27/51] tests/qtest: Use send/recv for socket communication Date: Wed, 24 Aug 2022 17:40:05 +0800 Message-Id: <20220824094029.1634519-28-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220824094029.1634519-1-bmeng.cn@gmail.com> References: <20220824094029.1634519-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661337119765100001 Content-Type: text/plain; charset="utf-8" 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 --- tests/qtest/libqmp.c | 4 ++-- tests/qtest/libqtest.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqmp.c b/tests/qtest/libqmp.c index ade26c15f0..995a39c1f8 100644 --- a/tests/qtest/libqmp.c +++ b/tests/qtest/libqmp.c @@ -36,7 +36,7 @@ typedef struct { =20 static void socket_send(int fd, const char *buf, size_t size) { - size_t res =3D qemu_write_full(fd, buf, size); + ssize_t res =3D send(fd, buf, size, 0); =20 assert(res =3D=3D size); } @@ -69,7 +69,7 @@ QDict *qmp_fd_receive(int fd) ssize_t len; char c; =20 - len =3D read(fd, &c, 1); + len =3D recv(fd, &c, 1, 0); if (len =3D=3D -1 && errno =3D=3D EINTR) { continue; } diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 909583dad3..b7b7c9c541 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -438,7 +438,7 @@ void qtest_quit(QTestState *s) =20 static void socket_send(int fd, const char *buf, size_t size) { - size_t res =3D qemu_write_full(fd, buf, size); + ssize_t res =3D send(fd, buf, size, 0); =20 assert(res =3D=3D size); } @@ -470,7 +470,7 @@ static GString *qtest_client_socket_recv_line(QTestStat= e *s) ssize_t len; char buffer[1024]; =20 - len =3D read(s->fd, buffer, sizeof(buffer)); + len =3D recv(s->fd, buffer, sizeof(buffer), 0); if (len =3D=3D -1 && errno =3D=3D EINTR) { continue; } --=20 2.34.1