From nobody Sun May 5 13:47:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1495451203248553.7304904853946; Mon, 22 May 2017 04:06:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 065B94E4F5; Mon, 22 May 2017 11:06:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9536F782A6; Mon, 22 May 2017 11:06:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 81AB7180BAF1; Mon, 22 May 2017 11:06:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v4MB6cXl012493 for ; Mon, 22 May 2017 07:06:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E7B77DE0A; Mon, 22 May 2017 11:06:38 +0000 (UTC) Received: from localhost.localdomain (ovpn-204-24.brq.redhat.com [10.40.204.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id C48C67DE02 for ; Mon, 22 May 2017 11:06:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 065B94E4F5 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 065B94E4F5 From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 22 May 2017 13:06:26 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virStreamSparseSendAll: Reset @want in each iteration X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 22 May 2017 11:06:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There's a slight problem with the current function. Assume we are currently in a data section and we have say 42 bytes until next section (okay, in reality sections are capped to the sector size, but bear with me). Therefore, just before (handler) is called to fill up the buffer with data, @want is changed to 42 to match the amount of data left in the current section. However, after hole is processed, we are back in data section but with incredibly small @want size. Nobody will ever reset it back. This results in incredible data fragmentation. Signed-off-by: Michal Privoznik --- src/libvirt-stream.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c index ed0ed7325..d7a8f5816 100644 --- a/src/libvirt-stream.c +++ b/src/libvirt-stream.c @@ -698,7 +698,7 @@ int virStreamSparseSendAll(virStreamPtr stream, void *opaque) { char *bytes =3D NULL; - size_t want =3D VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX; + size_t bufLen =3D VIR_NET_MESSAGE_LEGACY_PAYLOAD_MAX; int ret =3D -1; unsigned long long dataLen =3D 0; =20 @@ -718,12 +718,13 @@ int virStreamSparseSendAll(virStreamPtr stream, goto cleanup; } =20 - if (VIR_ALLOC_N(bytes, want) < 0) + if (VIR_ALLOC_N(bytes, bufLen) < 0) goto cleanup; =20 for (;;) { int inData, got, offset =3D 0; long long sectionLen; + size_t want =3D bufLen; const unsigned int skipFlags =3D 0; =20 if (!dataLen) { --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list