[Qemu-devel] [PATCH v3 3/5] usb-mtp: Support delete of mtp objects

2018-02-15 Thread Bandan Das
Write of existing objects by the initiator is acheived by making a temporary buffer with the new changes, deleting the old file and then writing a new file with the same name. Also, add a "readonly" property which needs to be set to false for deletion to work. Signed-off-by: Bandan Da

[Qemu-devel] [PATCH v3 2/5] usb-mtp: print parent path in IN_IGNORED trace fn

2018-02-15 Thread Bandan Das
Fix a possible null dereference when deleting a folder and its contents. An ignored event might be received for its contents after the parent folder is deleted which will return a null object. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions

[Qemu-devel] [PATCH v3 0/5] Initial write support for MTP objects

2018-02-15 Thread Bandan Das
ng. Depending on the MTP client, it may choose not to implement it (such as simple-mtpfs that runs on top of fuse). - Needs more testing :) Bandan Das (5): usb-mtp: Add one more argument when building results usb-mtp: print parent path in IN_IGNORED trace fn usb-mtp: Support delete o

Re: [Qemu-devel] [PULL 4/5] usb-mtp: Introduce write support for MTP objects

2018-02-20 Thread Bandan Das
Eric Blake writes: > On 02/20/2018 09:28 AM, Gerd Hoffmann wrote: >> From: Bandan Das >> >> Allow write operations on behalf of the initiator. The >> precursor to write is the sending of the write metadata >> that consists of the ObjectInfo dataset. This patch

[Qemu-devel] [PATCH v4 1/5] usb-mtp: Add one more argument when building results

2018-02-20 Thread Bandan Das
The response to a SendObjectInfo consists of the storageid, parent obejct handle and the handle reserved for the new incoming object Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 50 +++--- 1 file changed, 27 insertions(+), 23 deletions(-) diff

[Qemu-devel] [PATCH v4 4/5] usb-mtp: Introduce write support for MTP objects

2018-02-20 Thread Bandan Das
initiator (The SendObjectInfo implementation is in a later patch) Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 152 ++- 1 file changed, 150 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 5ef77f3e9f

[Qemu-devel] [PATCH v4 2/5] usb-mtp: print parent path in IN_IGNORED trace fn

2018-02-20 Thread Bandan Das
Fix a possible null dereference when deleting a folder and its contents. An ignored event might be received for its contents after the parent folder is deleted which will return a null object. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions

[Qemu-devel] [PATCH v4 0/5] Initial write support for MTP objects

2018-02-20 Thread Bandan Das
more testing :) Bandan Das (5): usb-mtp: Add one more argument when building results usb-mtp: print parent path in IN_IGNORED trace fn usb-mtp: Support delete of mtp objects usb-mtp: Introduce write support for MTP objects usb-mtp: Advertise SendObjectInfo for write support hw/usb/de

[Qemu-devel] [PATCH v4 3/5] usb-mtp: Support delete of mtp objects

2018-02-20 Thread Bandan Das
Write of existing objects by the initiator is acheived by making a temporary buffer with the new changes, deleting the old file and then writing a new file with the same name. Also, add a "readonly" property which needs to be set to false for deletion to work. Signed-off-by: Bandan Da

[Qemu-devel] [PATCH v4 5/5] usb-mtp: Advertise SendObjectInfo for write support

2018-02-20 Thread Bandan Das
igned-off-by: Bandan Das --- hw/usb/dev-mtp.c | 132 ++- 1 file changed, 130 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 9b51708614..086296f415 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -47,6

Re: [Qemu-devel] [PATCH v4 4/5] usb-mtp: Introduce write support for MTP objects

2018-02-21 Thread Bandan Das
Daniel P. Berrangé writes: >> #define TYPE_USB_MTP "usb-mtp" >> @@ -804,6 +815,7 @@ static MTPData *usb_mtp_get_device_info(MTPState *s, >> MTPControl *c) >> CMD_GET_OBJECT_HANDLES, >> CMD_GET_OBJECT_INFO, >> CMD_DELETE_OBJECT, >> +CMD_SEND_OBJECT, > > Seems w

[Qemu-devel] [PATCH v5 4/5] usb-mtp: Introduce write support for MTP objects

2018-02-22 Thread Bandan Das
initiator (The SendObjectInfo implementation is in a later patch) Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 157 ++- 1 file changed, 155 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 5ef77f3e9f

[Qemu-devel] [PATCH v5 0/5] Initial write support for MTP objects

2018-02-22 Thread Bandan Das
implement it (such as simple-mtpfs that runs on top of fuse). - Needs more testing :) Bandan Das (5): usb-mtp: Add one more argument when building results usb-mtp: print parent path in IN_IGNORED trace fn usb-mtp: Support delete of mtp objects usb-mtp: Introduce write support for MTP

[Qemu-devel] [PATCH v5 2/5] usb-mtp: print parent path in IN_IGNORED trace fn

2018-02-22 Thread Bandan Das
Fix a possible null dereference when deleting a folder and its contents. An ignored event might be received for its contents after the parent folder is deleted which will return a null object. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions

[Qemu-devel] [PATCH v5 1/5] usb-mtp: Add one more argument when building results

2018-02-22 Thread Bandan Das
The response to a SendObjectInfo consists of the storageid, parent obejct handle and the handle reserved for the new incoming object Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 50 +++--- 1 file changed, 27 insertions(+), 23 deletions(-) diff

[Qemu-devel] [PATCH v5 5/5] usb-mtp: Advertise SendObjectInfo for write support

2018-02-22 Thread Bandan Das
igned-off-by: Bandan Das --- hw/usb/dev-mtp.c | 136 ++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 6372c11e81..a6ba57 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -47,6

[Qemu-devel] [PATCH v5 3/5] usb-mtp: Support delete of mtp objects

2018-02-22 Thread Bandan Das
Write of existing objects by the initiator is acheived by making a temporary buffer with the new changes, deleting the old file and then writing a new file with the same name. Also, add a "readonly" property which needs to be set to false for deletion to work. Signed-off-by: Bandan Da

[Qemu-devel] [PATCH v6 4/5] usb-mtp: Introduce write support for MTP objects

2018-02-23 Thread Bandan Das
initiator (The SendObjectInfo implementation is in a later patch) Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 157 ++- 1 file changed, 155 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 5ef77f3e9f

[Qemu-devel] [PATCH v6 3/5] usb-mtp: Support delete of mtp objects

2018-02-23 Thread Bandan Das
Write of existing objects by the initiator is acheived by making a temporary buffer with the new changes, deleting the old file and then writing a new file with the same name. Also, add a "readonly" property which needs to be set to false for deletion to work. Signed-off-by: Bandan Da

[Qemu-devel] [PATCH v6 2/5] usb-mtp: print parent path in IN_IGNORED trace fn

2018-02-23 Thread Bandan Das
Fix a possible null dereference when deleting a folder and its contents. An ignored event might be received for its contents after the parent folder is deleted which will return a null object. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions

[Qemu-devel] [PATCH v6 1/5] usb-mtp: Add one more argument when building results

2018-02-23 Thread Bandan Das
The response to a SendObjectInfo consists of the storageid, parent obejct handle and the handle reserved for the new incoming object Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 50 +++--- 1 file changed, 27 insertions(+), 23 deletions(-) diff

[Qemu-devel] [PATCH v6 0/5] Initial write support for MTP objects

2018-02-23 Thread Bandan Das
un fsync when saving. Depending on the MTP client, it may choose not to implement it (such as simple-mtpfs that runs on top of fuse). - Needs more testing :) Bandan Das (5): usb-mtp: Add one more argument when building results usb-mtp: print parent path in IN_IGNORED trace fn usb-mtp: Supp

[Qemu-devel] [PATCH v6 5/5] usb-mtp: Advertise SendObjectInfo for write support

2018-02-23 Thread Bandan Das
igned-off-by: Bandan Das --- hw/usb/dev-mtp.c | 136 ++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index ecb37828d5..6ecf70a79b 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -47,6

Re: [Qemu-devel] [PATCH] usb-mtp: Fix build with gcc 9

2019-03-01 Thread Bandan Das
Greg Kurz writes: ... >> >> I think there's an underlying problem with this code which we >> should deal with differently. The 'dataset' local in this >> file is (I think) pointing at on-the-wire information from >> the USB device, but we're treating it as an array of >> host-order uint16_t value

[Qemu-devel] [PATCH v2 0/3] usb-mtp coverity fixes

2019-03-06 Thread Bandan Das
v2: Rebase Prevent a null dereference when deleting objects Fix some coverity issues and a few others pointed out by Peter Bandan Das (3): usb-mtp: return incomplete transfer on a lstat failure usb-mtp: fix some usb_mtp_write_data return paths usb-mtp: prevent null dereference while

[Qemu-devel] [PATCH v2 1/3] usb-mtp: return incomplete transfer on a lstat failure

2019-03-06 Thread Bandan Das
MTP writes objects in small chunks and at the end gets the real file size to update the object metadata. If this fails for any reason, return an INCOMPLETE_TRANSFER to the initiator Spotted by Coverity: CID 1398651 Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 19 ++- 1 file

[Qemu-devel] [PATCH v2 3/3] usb-mtp: prevent null dereference while deleting objects

2019-03-06 Thread Bandan Das
Spotted by Coverity: CID 1399144 Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 1f22284949..06e376bcd2 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1177,9 +1177,7

[Qemu-devel] [PATCH v2 2/3] usb-mtp: fix some usb_mtp_write_data return paths

2019-03-06 Thread Bandan Das
During a write, free up the "path" before getting more data. Also, while we at it, remove the confusing usage of d->fd for storing mkdir status Spotted by Coverity: CID 1398642 Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 18 ++ 1 file changed, 10 insertions(+)

Re: [Qemu-devel] [PULL 7/8] usb-mtp: breakup MTP write into smaller chunks

2019-02-15 Thread Bandan Das
Peter Maydell writes: > On Fri, 15 Feb 2019 at 18:45, Bandan Das wrote: >> ... >> I believe this is a false positive, there's still more data incoming >> and we have successfully written the data we got this time, so we return >> without freeing up any of the

Re: [Qemu-devel] [PULL 7/8] usb-mtp: breakup MTP write into smaller chunks

2019-02-15 Thread Bandan Das
Peter Maydell writes: > On Wed, 30 Jan 2019 at 07:41, Gerd Hoffmann wrote: >> >> From: Bandan Das >> >> 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

[Qemu-devel] [PATCH] usb-mtp: add sanity checks on rootdir

2019-08-28 Thread Bandan Das
n absolute path. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 38 -- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 9846e4b513..7c07295519 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -2

[Qemu-devel] [PATCH v4 2/3] usb-mtp: remove usb_mtp_object_free_one

2019-04-01 Thread Bandan Das
This function is used in the delete path only and can be replaced by a call to usb_mtp_object_free. Reviewed-by: Peter Maydell Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c

[Qemu-devel] [PATCH v4 1/3] usb-mtp: fix return status of delete

2019-04-01 Thread Bandan Das
, only READ_ONLY can be returned. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 62 ++-- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 06e376bcd2..91b820baaf 100644 --- a/hw/usb/dev-mtp.c

Re: [Qemu-devel] [PATCH 1/2 v3] usb-mtp: remove usb_mtp_object_free_one

2019-04-01 Thread Bandan Das
Gerd Hoffmann writes: > On Thu, Mar 28, 2019 at 01:37:21PM -0400, Bandan Das wrote: >> This function is used in the delete path only and can >> be replaced by a call to usb_mtp_object_free. >> >> Reviewed-by: Peter Maydell >> Signed-off-by: Bandan Das > >

[Qemu-devel] [PATCH v4 0/3] misc usb-mtp fixes

2019-04-01 Thread Bandan Das
make it less confusing. Applies on top of [PATCH v3] usb-mtp: fix return status of delete Message-ID: Bandan Das (3): usb-mtp: fix return status of delete usb-mtp: remove usb_mtp_object_free_one usb-mtp: refactor the flow of usb_mtp_write_data hw/usb/dev-mtp.c | 133

[Qemu-devel] [PATCH v4 3/3] usb-mtp: refactor the flow of usb_mtp_write_data

2019-04-01 Thread Bandan Das
There's no functional change but the flow is (hopefully) more consistent for both file and folder object types. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 57 +--- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/usb/dev-

[Qemu-devel] [PATCH] usb-mtp: change default to success for usb_mtp_update_object

2019-04-15 Thread Bandan Das
go and there won't be an object for it. Fixes: c5ead51f90cf Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index ebf210fbf8..5de22738ce 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-

Re: [Qemu-devel] [PATCH] usb-mtp: change default to success for usb_mtp_update_object

2019-04-15 Thread Bandan Das
Forgot to cc people ... Bandan Das writes: > Commit c5ead51f90cf (usb-mtp: return incomplete transfer on a lstat > failure) checks if lstat succeeded when updating attributes of a > file. However, it also changed behavior to return an error by > default. This is incorrect because

Re: [Qemu-devel] [PATCH 0/3] usb-mtp: fix ObjectInfo request handling

2019-04-15 Thread Bandan Das
Daniel P. Berrangé writes: > Two previous attempts to fix this due to GCC 9 highlighting > unaligned data access. My attempt: > > https://lists.gnu.org/archive/html/qemu-devel/2019-03/msg07763.html > > And a previous one: > > https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg07923.html

Re: [Qemu-devel] [PATCH 1/3] usb-mtp: fix string length for filename when writing metadata

2019-04-15 Thread Bandan Das
Daniel P. Berrangé writes: > The ObjectInfo 'length' field provides the length of the > wide character string filename. This is then converted to > a multi-byte character string. This may have a different > byte count to the wide character string. We should use the > C string length of the multi-

[Qemu-devel] [PATCH 2/2] usb-mtp: fix some usb_mtp_write_data return paths

2019-02-22 Thread Bandan Das
During a write, free up the "path" before getting more data. Also, while we at it, remove the confusing usage of d->fd for storing mkdir status Spotted by Coverity: CID 1398642 Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 18 ++ 1 file changed, 10 insertions(+)

[Qemu-devel] [PATCH 0/2] usb-mtp coverity fixes

2019-02-22 Thread Bandan Das
Fix some coverity issues and a few others pointed out by Peter Bandan Das (2): usb-mtp: return incomplete transfer on a lstat failure usb-mtp: fix some usb_mtp_write_data return paths hw/usb/dev-mtp.c | 38 +- 1 file changed, 25 insertions(+), 13

[Qemu-devel] [PATCH 1/2] usb-mtp: return incomplete transfer on a lstat failure

2019-02-22 Thread Bandan Das
MTP writes objects in small chunks and at the end gets the real file size to update the object metadata. If this fails for any reason, return an INCOMPLETE_TRANSFER to the initiator Spotted by Coverity: CID 1398651 Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 20 +++- 1

Re: [Qemu-devel] [PATCH 0/3] usb-mtp: fix ObjectInfo request handling

2019-04-16 Thread Bandan Das
Daniel P. Berrangé writes: ... >> > The store is read only by default. Are you trying something like: >> > -device usb-mtp,rootdir=/code/mtpshare,readonly=false ? >> >> Ah ha, I didn't realize I had to enable write support explicitly. Will >> retry with that. > > Even after setting readonly=fal

Re: [Qemu-devel] [PATCH 0/3] usb-mtp: fix ObjectInfo request handling

2019-04-16 Thread Bandan Das
Daniel P. Berrangé writes: > On Tue, Apr 16, 2019 at 12:10:16PM -0400, Bandan Das wrote: >> Daniel P. Berrangé writes: >> ... >> >> > The store is read only by default. Are you trying something like: >> >> > -device usb-mtp,rootdir=/code/mtpshare,

Re: [Qemu-devel] [PATCH 0/3] usb-mtp: fix ObjectInfo request handling

2019-04-16 Thread Bandan Das
Daniel P. Berrangé writes: >> I can't find usb-mtp sending a "I/O error" on an error condition >> for the objectinfo phase. It might be libmtp or even the command itself >> failing for some reason. For incomplete transfer, I just checked, it's >> spitting out the error message correctly as INCOMP

Re: [Qemu-devel] [PATCH 2/3] usb-mtp: fix bounds check for guest provided filename

2019-04-16 Thread Bandan Das
ename = utf16_to_str(MIN(dataset->length, > -dlen - offsetof(ObjectInfo, filename)), > +filename = utf16_to_str(MIN(dataset->length, filename_chars), > dataset->filename); > > if (strchr(filename, '/')) { Reviewed-by: Bandan Das

Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths

2019-03-15 Thread Bandan Das
Peter Maydell writes: > On Fri, 8 Mar 2019 at 19:39, Bandan Das wrote: >> >> Peter Maydell writes: >> > But the two places in usb_mtp_get_data() that call >> > usb_mtp_write_metadata() still don't check its return >> > value: don't they need

Re: [Qemu-devel] [PATCH 2/2] filemon: ensure watch IDs are unique to QFileMonitor scope

2019-03-15 Thread Bandan Das
filemonitor-inotify.c b/util/filemonitor-inotify.c > index 3a72be037f..3eb29f860b 100644 > --- a/util/filemonitor-inotify.c > +++ b/util/filemonitor-inotify.c > @@ -29,7 +29,7 @@ > > struct QFileMonitor { > int fd; > - > +int nextid; /* watch ID counter */ > QemuMutex lock; /* protects dirs & idmap */ > GHashTable *dirs; /* dirname => QFileMonitorDir */ > GHashTable *idmap; /* inotify ID => dirname */ > @@ -47,7 +47,6 @@ typedef struct { > typedef struct { > char *path; > int id; /* inotify ID */ > -int nextid; /* watch ID counter */ > GArray *watches; /* QFileMonitorWatch elements */ > } QFileMonitorDir; > > @@ -277,7 +276,7 @@ qemu_file_monitor_add_watch(QFileMonitor *mon, > } > } > > -watch.id = dir->nextid++; > +watch.id = mon->nextid++; > watch.filename = g_strdup(filename); > watch.cb = cb; > watch.opaque = opaque; Thanks, this fixes it! I had a related question about the way qemu_file_monitor_add_watch works. Am I correct in understanding that if there is already a watch on a dir, we return back mon->nextid++ i.e the next free id. Why don't we return back the originally assigned watchid ? Reviewed-and-tested-by: Bandan Das

Re: [Qemu-devel] [PATCH 2/2] filemon: ensure watch IDs are unique to QFileMonitor scope

2019-03-15 Thread Bandan Das
Daniel P. Berrangé writes: ... >> Thanks, this fixes it! I had a related question about the way >> qemu_file_monitor_add_watch works. >> >> Am I correct in understanding that if there is already a watch on a dir, >> we return back mon->nextid++ i.e the next free id. Why don't we return >> back th

Re: [Qemu-devel] [PULL 2/4] usb-mtp: fix some usb_mtp_write_data return paths

2019-03-18 Thread Bandan Das
Peter Maydell writes: ... >> +} else { >> +usb_mtp_queue_result(s, RES_STORE_FULL, d->trans, >> + 0, 0, 0, 0); >> +} > > Presumably one of these should be RES_OK of some kind ? > Ah, yes, that's a typo. >

Re: [Qemu-devel] [PATCH 2/2] filemon: ensure watch IDs are unique to QFileMonitor scope

2019-03-18 Thread Bandan Das
Daniel P. Berrangé writes: > On Fri, Mar 15, 2019 at 01:24:42PM -0400, Bandan Das wrote: >> Daniel P. Berrangé writes: >> ... >> >> Thanks, this fixes it! I had a related question about the way >> >> qemu_file_monitor_add_watch works. >> >> &

Re: [Qemu-devel] [PATCH] filemon: fix watch IDs to avoid potential wraparound issues

2019-03-19 Thread Bandan Das
y sets watches on the directory as a > whole, not files within, so there is no risk of guest > triggered wrap around on the low 32 bits. > > Signed-off-by: Daniel P. Berrangé > --- > > Depends: <20190314151527.25533-1-berra...@redhat.com> > Reviewed-by: Bandan Da

[Qemu-devel] [PATCH 1/2] usb-mtp: remove usb_mtp_object_free_one

2019-03-19 Thread Bandan Das
This function is used in the delete path only and can be replaced by a call to usb_mtp_object_free. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 91b820baaf..4dc1317e2e

[Qemu-devel] [PATCH 2/2] usb-mtp: refactor the flow of usb_mtp_write_data

2019-03-19 Thread Bandan Das
There's no functional change but the flow is (hopefully) more consistent for both file and folder object types. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 58 +--- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/hw/usb/dev-

[Qemu-devel] [PATCH 0/2] misc usb-mtp fixes

2019-03-19 Thread Bandan Das
The first patch removes a unnecessary function and the second is just a code reorg of usb_mtp_write_data to make it less confusing. Applies on top of [PATCH v3] usb-mtp: fix return status of delete Message-ID: Bandan Das (2): usb-mtp: remove usb_mtp_object_free_one usb-mtp: refactor the flow

[Qemu-devel] [PATCH 2/2 v2] usb-mtp: refactor the flow of usb_mtp_write_data

2019-03-26 Thread Bandan Das
There's no functional change but the flow is (hopefully) more consistent for both file and folder object types. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 53 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/hw/usb/dev-

[Qemu-devel] [PATCH 1/2 v2] usb-mtp: remove usb_mtp_object_free_one

2019-03-26 Thread Bandan Das
This function is used in the delete path only and can be replaced by a call to usb_mtp_object_free. Reviewed-by: Peter Maydell Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c

[Qemu-devel] [PATCH 0/2 v2] misc usb-mtp fixes

2019-03-26 Thread Bandan Das
Message-ID: Bandan Das (2): usb-mtp: remove usb_mtp_object_free_one usb-mtp: refactor the flow of usb_mtp_write_data hw/usb/dev-mtp.c | 67 1 file changed, 28 insertions(+), 39 deletions(-) -- 2.19.2

Re: [Qemu-devel] [PATCH 2/2 v2] usb-mtp: refactor the flow of usb_mtp_write_data

2019-03-28 Thread Bandan Das
Peter Maydell writes: > On Tue, 26 Mar 2019 at 17:58, Bandan Das wrote: >> > ... > Doesn't this mean you're no longer sending the RES_OK result > for this case ? > Ugh, I messed up this version. I will send a v3 and fix the indentation to

[Qemu-devel] [PATCH 0/2 v3] misc usb-mtp fixes

2019-03-28 Thread Bandan Das
confusing. Applies on top of [PATCH v3] usb-mtp: fix return status of delete Message-ID: Bandan Das (2): usb-mtp: remove usb_mtp_object_free_one usb-mtp: refactor the flow of usb_mtp_write_data hw/usb/dev-mtp.c | 71 ++-- 1 file changed, 32 insertions

[Qemu-devel] [PATCH 2/2 v3] usb-mtp: refactor the flow of usb_mtp_write_data

2019-03-28 Thread Bandan Das
There's no functional change but the flow is (hopefully) more consistent for both file and folder object types. Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 57 +--- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/hw/usb/dev-

[Qemu-devel] [PATCH 1/2 v3] usb-mtp: remove usb_mtp_object_free_one

2019-03-28 Thread Bandan Das
This function is used in the delete path only and can be replaced by a call to usb_mtp_object_free. Reviewed-by: Peter Maydell Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 14 ++ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c

Re: [Qemu-devel] [Bug 1798780] [NEW] hw/usb/dev-mtp.c:1616: bad test ?

2019-01-22 Thread Bandan Das
Peter Maydell writes: > On Fri, 19 Oct 2018 at 10:22, dcb <1798...@bugs.launchpad.net> wrote: >> hw/usb/dev-mtp.c:1616:52: warning: logical ‘or’ of collectively >> exhaustive tests is always true [-Wlogical-op] >> >> Source code is >> >> if ((ret == -1) && (errno != EINTR || errno

[Qemu-devel] [PATCH] usb-mtp: replace the homebrew write with qemu_write_full

2019-01-22 Thread Bandan Das
qemu_write_full takes care of partial blocking writes, as in cases of larger file sizes Suggested-by: Peter Maydell Signed-off-by: Bandan --- 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 31fa8358

Re: [Qemu-devel] [PATCH] usb-mtp: replace the homebrew write with qemu_write_full

2019-01-24 Thread Bandan Das
Gerd Hoffmann writes: > On Tue, Jan 22, 2019 at 07:41:16AM -0500, Bandan Das wrote: >> >> qemu_write_full takes care of partial blocking writes, >> as in cases of larger file sizes >> >> Suggested-by: Peter Maydell >> Signed-off-by: Bandan > > H

[Qemu-devel] [PATCH v3 0/3] Break down the MTP write operation

2019-01-28 Thread Bandan Das
buffer again instead of reallocating to a larger buffer size. Tested with different file sizes on a Linux guest. Bandan Das (3): usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ usb-mtp: breakup MTP write into smaller chunks usb-mtp: replace the homebrew write with qemu_write_full

[Qemu-devel] [PATCH v3 1/3] usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ

2019-01-28 Thread Bandan Das
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-

[Qemu-devel] [PATCH v3 3/3] usb-mtp: replace the homebrew write with qemu_write_full

2019-01-28 Thread Bandan Das
qemu_write_full takes care of partial blocking writes, as in cases of larger file sizes 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 b607c7be05..f4d9470493 100644

[Qemu-devel] [PATCH v3 2/3] usb-mtp: breakup MTP write into smaller chunks

2019-01-28 Thread Bandan Das
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

[Qemu-devel] [PATCH v4 0/3] Break down the MTP write operation

2019-01-29 Thread Bandan Das
file upto a certain data size we have received so far and second, reuse the buffer again instead of reallocating to a larger buffer size. Tested with different file sizes on a Linux guest. Bandan Das (3): usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ usb-mtp: breakup MTP write

[Qemu-devel] [PATCH v4 1/3] usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ

2019-01-29 Thread Bandan Das
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-

Re: [Qemu-devel] [PATCH v3 1/3] usb-mtp: Reallocate buffer in multiples of MTP_WRITE_BUF_SZ

2019-01-29 Thread Bandan Das
Eric Blake writes: > On 1/28/19 8:24 AM, Bandan Das wrote: >> 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 >> mul

[Qemu-devel] [PATCH v4 3/3] usb-mtp: replace the homebrew write with qemu_write_full

2019-01-29 Thread Bandan Das
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

[Qemu-devel] [PATCH v4 2/3] usb-mtp: breakup MTP write into smaller chunks

2019-01-29 Thread Bandan Das
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

<    1   2   3   4