From nobody Wed May 15 05:10:53 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548768082626244.47484868798324; Tue, 29 Jan 2019 05:21:22 -0800 (PST) Received: from localhost ([127.0.0.1]:49394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTKH-0004af-Ed for importer@patchew.org; Tue, 29 Jan 2019 08:21:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTIp-0003nX-BN for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goTIn-0003oH-1J for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46606) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goTIl-0003mU-Bf for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08744C07224C; Tue, 29 Jan 2019 13:19:42 +0000 (UTC) Received: from gigantic.usersys.redhat.com (helium.bos.redhat.com [10.18.17.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D5EC1B468; Tue, 29 Jan 2019 13:19:41 +0000 (UTC) From: Bandan Das To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 08:19:06 -0500 Message-Id: <20190129131908.27924-2-bsd@redhat.com> In-Reply-To: <20190129131908.27924-1-bsd@redhat.com> References: <20190129131908.27924-1-bsd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 29 Jan 2019 13:19:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 1/3] usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This is a "pre-patch" to breaking up the write buffer for MTP writes. Instead of allocating a mtp buffer equal to size sent by the initiator, we start with a small size and reallocate multiples (of that small size) as needed. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 68c5eb8eaa..ad681145ce 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -25,6 +25,7 @@ #include "trace.h" #include "hw/usb.h" #include "desc.h" +#include "qemu/units.h" =20 /* -----------------------------------------------------------------------= */ =20 @@ -152,7 +153,6 @@ struct MTPData { bool first; /* Used for >4G file sizes */ bool pending; - uint64_t cached_length; int fd; }; =20 @@ -244,6 +244,7 @@ typedef struct { =20 #define MTP_MANUFACTURER "QEMU" #define MTP_PRODUCT "QEMU filesharing" +#define MTP_WRITE_BUF_SZ (512 * KiB) =20 enum { STR_MANUFACTURER =3D 1, @@ -1658,7 +1659,7 @@ static void usb_mtp_write_data(MTPState *s) d->fd =3D mkdir(path, mask); goto free; } - if ((s->dataset.size !=3D 0xFFFFFFFF) && (s->dataset.size < d->len= gth)) { + if ((s->dataset.size !=3D 0xFFFFFFFF) && (s->dataset.size !=3D d->= offset)) { usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, 0, 0, 0, 0); goto done; @@ -1776,17 +1777,21 @@ static void usb_mtp_get_data(MTPState *s, mtp_conta= iner *container, total_len =3D cpu_to_le32(container->length) - sizeof(mtp_containe= r); /* Length of data in this packet */ data_len -=3D sizeof(mtp_container); - usb_mtp_realloc(d, total_len); - d->length +=3D total_len; + if (total_len < MTP_WRITE_BUF_SZ) { + usb_mtp_realloc(d, total_len); + d->length +=3D total_len; + } else { + usb_mtp_realloc(d, MTP_WRITE_BUF_SZ - sizeof(mtp_container= )); + d->length +=3D MTP_WRITE_BUF_SZ - sizeof(mtp_container); + } d->offset =3D 0; - d->cached_length =3D total_len; d->first =3D false; d->pending =3D false; } =20 if (d->pending) { - usb_mtp_realloc(d, d->cached_length); - d->length +=3D d->cached_length; + usb_mtp_realloc(d, MTP_WRITE_BUF_SZ); + d->length +=3D MTP_WRITE_BUF_SZ; d->pending =3D false; } =20 @@ -1794,12 +1799,6 @@ static void usb_mtp_get_data(MTPState *s, mtp_contai= ner *container, dlen =3D data_len; } else { dlen =3D d->length - d->offset; - /* Check for cached data for large files */ - if ((s->dataset.size =3D=3D 0xFFFFFFFF) && (dlen < p->iov.size)) { - usb_mtp_realloc(d, p->iov.size - dlen); - d->length +=3D p->iov.size - dlen; - dlen =3D p->iov.size; - } } =20 switch (d->code) { @@ -1821,7 +1820,7 @@ static void usb_mtp_get_data(MTPState *s, mtp_contain= er *container, d->offset +=3D dlen; if ((p->iov.size % 64) || !p->iov.size) { assert((s->dataset.size =3D=3D 0xFFFFFFFF) || - (s->dataset.size =3D=3D d->length)); + (s->dataset.size =3D=3D d->offset)); =20 usb_mtp_write_data(s); usb_mtp_data_free(s->data_out); --=20 2.19.2 From nobody Wed May 15 05:10:53 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548768215813100.10428405794312; Tue, 29 Jan 2019 05:23:35 -0800 (PST) Received: from localhost ([127.0.0.1]:49416 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTMU-0006Fv-OS for importer@patchew.org; Tue, 29 Jan 2019 08:23:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTIp-0003nW-BN for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goTIn-0003oq-BB for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goTIm-0003mz-GT for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4F69C079C4B; Tue, 29 Jan 2019 13:19:42 +0000 (UTC) Received: from gigantic.usersys.redhat.com (helium.bos.redhat.com [10.18.17.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2ABA21B468; Tue, 29 Jan 2019 13:19:42 +0000 (UTC) From: Bandan Das To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 08:19:07 -0500 Message-Id: <20190129131908.27924-3-bsd@redhat.com> In-Reply-To: <20190129131908.27924-1-bsd@redhat.com> References: <20190129131908.27924-1-bsd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 29 Jan 2019 13:19:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 2/3] usb-mtp: breakup MTP write into smaller chunks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" For every MTP_WRITE_BUF_SZ copied, this patch writes it to file before getting the next block of data. The file is kept opened for the duration of the operation but the sanity checks on the write operation are performed only once when the write operation starts. Additionally, we also update the file size in the object metadata once the file has completely been written. Suggested-by: Gerd Hoffman Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 134 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 91 insertions(+), 43 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index ad681145ce..1204a61cba 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -36,6 +36,13 @@ enum mtp_container_type { TYPE_EVENT =3D 4, }; =20 +/* MTP write stage, for internal use only */ +enum mtp_write_status { + WRITE_START =3D 1, + WRITE_CONTINUE =3D 2, + WRITE_END =3D 3, +}; + enum mtp_code { /* command codes */ CMD_GET_DEVICE_INFO =3D 0x1001, @@ -154,6 +161,9 @@ struct MTPData { /* Used for >4G file sizes */ bool pending; int fd; + uint8_t write_status; + /* Internal pointer per every MTP_WRITE_BUF_SZ */ + uint64_t data_offset; }; =20 struct MTPObject { @@ -1619,10 +1629,14 @@ static char *utf16_to_str(uint8_t len, uint16_t *ar= r) } =20 /* Wrapper around write, returns 0 on failure */ -static uint64_t write_retry(int fd, void *buf, uint64_t size) +static uint64_t write_retry(int fd, void *buf, uint64_t size, off_t offset) { uint64_t bytes_left =3D size, ret; =20 + if (lseek(fd, offset, SEEK_SET) < 0) { + goto done; + } + while (bytes_left > 0) { ret =3D write(fd, buf, bytes_left); if ((ret =3D=3D -1) && (errno !=3D EINTR || errno !=3D EAG= AIN || @@ -1633,9 +1647,20 @@ static uint64_t write_retry(int fd, void *buf, uint6= 4_t size) buf +=3D ret; } =20 +done: return size - bytes_left; } =20 +static void usb_mtp_update_object(MTPObject *parent, char *name) +{ + MTPObject *o =3D + usb_mtp_object_lookup_name(parent, name, strlen(name)); + + if (o) { + lstat(o->path, &o->stat); + } +} + static void usb_mtp_write_data(MTPState *s) { MTPData *d =3D s->data_out; @@ -1647,48 +1672,56 @@ static void usb_mtp_write_data(MTPState *s) =20 assert(d !=3D NULL); =20 - if (parent =3D=3D NULL || !s->write_pending) { - usb_mtp_queue_result(s, RES_INVALID_OBJECTINFO, d->trans, - 0, 0, 0, 0); + switch (d->write_status) { + case WRITE_START: + if (!parent || !s->write_pending) { + usb_mtp_queue_result(s, RES_INVALID_OBJECTINFO, d->trans, + 0, 0, 0, 0); return; - } - - if (s->dataset.filename) { - path =3D g_strdup_printf("%s/%s", parent->path, s->dataset.filenam= e); - if (s->dataset.format =3D=3D FMT_ASSOCIATION) { - d->fd =3D mkdir(path, mask); - goto free; - } - if ((s->dataset.size !=3D 0xFFFFFFFF) && (s->dataset.size !=3D d->= offset)) { - usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, - 0, 0, 0, 0); - goto done; - } - d->fd =3D open(path, O_CREAT | O_WRONLY | O_CLOEXEC | O_NOFOLLOW, = mask); - if (d->fd =3D=3D -1) { - usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, - 0, 0, 0, 0); - goto done; } =20 - /* - * Return success if initiator sent 0 sized data - */ - if (!s->dataset.size) { - goto success; - } + if (s->dataset.filename) { + path =3D g_strdup_printf("%s/%s", parent->path, s->dataset.fil= ename); + if (s->dataset.format =3D=3D FMT_ASSOCIATION) { + d->fd =3D mkdir(path, mask); + goto free; + } + d->fd =3D open(path, O_CREAT | O_WRONLY | + O_CLOEXEC | O_NOFOLLOW, mask); + if (d->fd =3D=3D -1) { + usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, + 0, 0, 0, 0); + goto done; + } =20 - rc =3D write_retry(d->fd, d->data, d->offset); - if (rc !=3D d->offset) { + /* Return success if initiator sent 0 sized data */ + if (!s->dataset.size) { + goto success; + } + if (d->length !=3D MTP_WRITE_BUF_SZ && !d->pending) { + d->write_status =3D WRITE_END; + } + } + /* fall through */ + case WRITE_CONTINUE: + case WRITE_END: + rc =3D write_retry(d->fd, d->data, d->data_offset, + d->offset - d->data_offset); + if (rc !=3D d->data_offset) { usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, 0, 0, 0, 0); goto done; + } + if (d->write_status !=3D WRITE_END) { + return; + } else { + /* Only for < 4G file sizes */ + if (s->dataset.size !=3D 0xFFFFFFFF && d->offset !=3D s->datas= et.size) { + usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans, + 0, 0, 0, 0); + goto done; } - /* Only for < 4G file sizes */ - if (s->dataset.size !=3D 0xFFFFFFFF && rc !=3D s->dataset.size) { - usb_mtp_queue_result(s, RES_INCOMPLETE_TRANSFER, d->trans, - 0, 0, 0, 0); - goto done; + usb_mtp_update_object(parent, s->dataset.filename); } } =20 @@ -1787,25 +1820,33 @@ static void usb_mtp_get_data(MTPState *s, mtp_conta= iner *container, d->offset =3D 0; d->first =3D false; d->pending =3D false; + d->data_offset =3D 0; + d->write_status =3D WRITE_START; } =20 if (d->pending) { - usb_mtp_realloc(d, MTP_WRITE_BUF_SZ); - d->length +=3D MTP_WRITE_BUF_SZ; + memset(d->data, 0, d->length); + if (d->length !=3D MTP_WRITE_BUF_SZ) { + usb_mtp_realloc(d, MTP_WRITE_BUF_SZ - d->length); + d->length +=3D (MTP_WRITE_BUF_SZ - d->length); + } d->pending =3D false; + d->write_status =3D WRITE_CONTINUE; + d->data_offset =3D 0; } =20 - if (d->length - d->offset > data_len) { + if (d->length - d->data_offset > data_len) { dlen =3D data_len; } else { - dlen =3D d->length - d->offset; + dlen =3D d->length - d->data_offset; } =20 switch (d->code) { case CMD_SEND_OBJECT_INFO: - usb_packet_copy(p, d->data + d->offset, dlen); + usb_packet_copy(p, d->data + d->data_offset, dlen); d->offset +=3D dlen; - if (d->offset =3D=3D d->length) { + d->data_offset +=3D dlen; + if (d->data_offset =3D=3D d->length) { /* The operation might have already failed */ if (!s->result) { usb_mtp_write_metadata(s, dlen); @@ -1816,19 +1857,26 @@ static void usb_mtp_get_data(MTPState *s, mtp_conta= iner *container, } break; case CMD_SEND_OBJECT: - usb_packet_copy(p, d->data + d->offset, dlen); + usb_packet_copy(p, d->data + d->data_offset, dlen); d->offset +=3D dlen; + d->data_offset +=3D dlen; if ((p->iov.size % 64) || !p->iov.size) { assert((s->dataset.size =3D=3D 0xFFFFFFFF) || (s->dataset.size =3D=3D d->offset)); =20 + if (d->length =3D=3D MTP_WRITE_BUF_SZ) { + d->write_status =3D WRITE_END; + } else { + d->write_status =3D WRITE_START; + } usb_mtp_write_data(s); usb_mtp_data_free(s->data_out); s->data_out =3D NULL; return; } - if (d->offset =3D=3D d->length) { + if (d->data_offset =3D=3D d->length) { d->pending =3D true; + usb_mtp_write_data(s); } break; default: --=20 2.19.2 From nobody Wed May 15 05:10:53 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548768218362151.07379028042476; Tue, 29 Jan 2019 05:23:38 -0800 (PST) Received: from localhost ([127.0.0.1]:49418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTMX-0006Hp-BJ for importer@patchew.org; Tue, 29 Jan 2019 08:23:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTIr-0003oo-6N for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goTIp-0003pv-D3 for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goTIn-0003om-VM for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2741987649; Tue, 29 Jan 2019 13:19:45 +0000 (UTC) Received: from gigantic.usersys.redhat.com (helium.bos.redhat.com [10.18.17.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1158D1B468; Tue, 29 Jan 2019 13:19:42 +0000 (UTC) From: Bandan Das To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 08:19:08 -0500 Message-Id: <20190129131908.27924-4-bsd@redhat.com> In-Reply-To: <20190129131908.27924-1-bsd@redhat.com> References: <20190129131908.27924-1-bsd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 29 Jan 2019 13:19:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 3/3] usb-mtp: replace the homebrew write with qemu_write_full X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" qemu_write_full takes care of partial blocking writes, as in cases of larger file sizes Suggested-by: Peter Maydell Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 1204a61cba..2ccbce8794 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1631,24 +1631,16 @@ static char *utf16_to_str(uint8_t len, uint16_t *ar= r) /* Wrapper around write, returns 0 on failure */ static uint64_t write_retry(int fd, void *buf, uint64_t size, off_t offset) { - uint64_t bytes_left =3D size, ret; + uint64_t ret =3D 0; =20 if (lseek(fd, offset, SEEK_SET) < 0) { goto done; } =20 - while (bytes_left > 0) { - ret =3D write(fd, buf, bytes_left); - if ((ret =3D=3D -1) && (errno !=3D EINTR || errno !=3D EAG= AIN || - errno !=3D EWOULDBLOCK)) { - break; - } - bytes_left -=3D ret; - buf +=3D ret; - } + ret =3D qemu_write_full(fd, buf, size); =20 done: - return size - bytes_left; + return ret; } =20 static void usb_mtp_update_object(MTPObject *parent, char *name) --=20 2.19.2