From nobody Tue Feb 10 07:43:14 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1665056688; cv=none; d=zohomail.com; s=zohoarc; b=MzWExKK5zE+6XeBT1EXaHvdhtvgDajOGdEKOaFoWfqIDJs6AhOlJsfFuv43LRgpVMqpkNtX/69PmWZq/tgViNm2vXcepul9G+OTfIGO8L6aSGB+gYfTblioMOPw19HdALm2S3V2UYQRjFmuoa6Ph6d8Ir2M3GXR/Fb/Cl7cT/bc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665056688; h=Content-Type: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=NkOORsYWNnkKOl4yWuSB0pKUtZT0PTBRUW29bBje2oY=; b=M+HJQw+pCuoQapmku+td6F5uR7fXtIugFqIOGnQjCW+gVymyPpajxtPcP9ayd9rRqWpt/19xLjjXill+VJDrnyIehe7SfAgM5hCC6G2P1NryT+he+tLtM+gck19cVjCCSOnsXIf8Apmi3VKsGITAlSO5wsCgPIqjq56FxM2y9bc= 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 166505668876516.422268456166535; Thu, 6 Oct 2022 04:44:48 -0700 (PDT) Received: from localhost ([::1]:56542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogPJ0-0008E6-VU for importer@patchew.org; Thu, 06 Oct 2022 07:44:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogPBf-0003JV-R9 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 07:37:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogPBc-0000tm-H4 for qemu-devel@nongnu.org; Thu, 06 Oct 2022 07:37:11 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-569-1FTNQyj5PN-Tq64-jHHSlw-1; Thu, 06 Oct 2022 07:37:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C9F085A59D for ; Thu, 6 Oct 2022 11:37:06 +0000 (UTC) Received: from localhost (unknown [10.39.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F5191402BFE; Thu, 6 Oct 2022 11:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665056227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NkOORsYWNnkKOl4yWuSB0pKUtZT0PTBRUW29bBje2oY=; b=UJgPVifXTX3T4v/0RbwWp+WpMkzAPE2Nk3pv46vYrAV1NW8wNv6IpmpXm55oxTTji2m3Kp iRONOR+HCGgZMVoGKmhN6Fpu1GRGjiWG6y7vF6Ui00p6n0l0LOKuFPalO1IQf6VqAZn3BP it9azPq90fZvVOxSQgvy5e/cZMmaUyw= X-MC-Unique: 1FTNQyj5PN-Tq64-jHHSlw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: berrange@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v4 1/6] osdep: make readv_writev() work with partial read/write Date: Thu, 6 Oct 2022 15:36:52 +0400 Message-Id: <20221006113657.2656108-2-marcandre.lureau@redhat.com> In-Reply-To: <20221006113657.2656108-1-marcandre.lureau@redhat.com> References: <20221006113657.2656108-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665056691781100001 From: Marc-Andr=C3=A9 Lureau With a pipe or other reasons, read/write may return less than the requested bytes. This happens with the test-io-channel-command test on Windows. glib spawn code uses a binary pipe of 4096 bytes, and the first read returns that much (although more are requested), for some unclear reason... Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- util/osdep.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/util/osdep.c b/util/osdep.c index 60fcbbaebe..746d5f7d71 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -538,18 +538,22 @@ int socket_init(void) =20 =20 #ifndef CONFIG_IOVEC -/* helper function for iov_send_recv() */ static ssize_t readv_writev(int fd, const struct iovec *iov, int iov_cnt, bool do_write) { unsigned i =3D 0; ssize_t ret =3D 0; + ssize_t off =3D 0; while (i < iov_cnt) { ssize_t r =3D do_write - ? write(fd, iov[i].iov_base, iov[i].iov_len) - : read(fd, iov[i].iov_base, iov[i].iov_len); + ? write(fd, iov[i].iov_base + off, iov[i].iov_len - off) + : read(fd, iov[i].iov_base + off, iov[i].iov_len - off); if (r > 0) { ret +=3D r; + off +=3D r; + if (off < iov[i].iov_len) { + continue; + } } else if (!r) { break; } else if (errno =3D=3D EINTR) { @@ -562,6 +566,7 @@ readv_writev(int fd, const struct iovec *iov, int iov_c= nt, bool do_write) } break; } + off =3D 0; i++; } return ret; --=20 2.37.3