* [Qemu-devel] [PATCH] virtio-9p: don't break device on marshaling fail
@ 2017-09-13 14:16 Jan Dakinevich
2017-09-13 14:59 ` Greg Kurz
0 siblings, 1 reply; 2+ messages in thread
From: Jan Dakinevich @ 2017-09-13 14:16 UTC (permalink / raw)
To: Greg Kurz, qemu-devel
Cc: Michael S. Tsirkin, Aneesh Kumar K.V, Jan Dakinevich
Fix regression from commit 8d37de41cab145cbba250a8f1f1372b0a5cdf26f.
The situation when pdu_marshal returns an error should be considered
valid. At least `v9fs_do_readdir_with_stat' relies on that to place in
responce buffer as much data as can fit.
Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>
---
hw/9pfs/virtio-9p-device.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 62650b0..c3e5935 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -146,16 +146,8 @@ static ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
V9fsState *s = pdu->s;
V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
VirtQueueElement *elem = v->elems[pdu->idx];
- ssize_t ret;
- ret = v9fs_iov_vmarshal(elem->in_sg, elem->in_num, offset, 1, fmt, ap);
- if (ret < 0) {
- VirtIODevice *vdev = VIRTIO_DEVICE(v);
-
- virtio_error(vdev, "Failed to encode VirtFS reply type %d",
- pdu->id + 1);
- }
- return ret;
+ return v9fs_iov_vmarshal(elem->in_sg, elem->in_num, offset, 1, fmt, ap);
}
static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
@@ -164,15 +156,8 @@ static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
V9fsState *s = pdu->s;
V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
VirtQueueElement *elem = v->elems[pdu->idx];
- ssize_t ret;
- ret = v9fs_iov_vunmarshal(elem->out_sg, elem->out_num, offset, 1, fmt, ap);
- if (ret < 0) {
- VirtIODevice *vdev = VIRTIO_DEVICE(v);
-
- virtio_error(vdev, "Failed to decode VirtFS request type %d", pdu->id);
- }
- return ret;
+ return v9fs_iov_vunmarshal(elem->out_sg, elem->out_num, offset, 1, fmt, ap);
}
static void virtio_init_in_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] virtio-9p: don't break device on marshaling fail
2017-09-13 14:16 [Qemu-devel] [PATCH] virtio-9p: don't break device on marshaling fail Jan Dakinevich
@ 2017-09-13 14:59 ` Greg Kurz
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kurz @ 2017-09-13 14:59 UTC (permalink / raw)
To: Jan Dakinevich; +Cc: qemu-devel, Michael S. Tsirkin, Aneesh Kumar K.V
[-- Attachment #1: Type: text/plain, Size: 2425 bytes --]
On Wed, 13 Sep 2017 17:16:43 +0300
Jan Dakinevich <jan.dakinevich@gmail.com> wrote:
> Fix regression from commit 8d37de41cab145cbba250a8f1f1372b0a5cdf26f.
>
> The situation when pdu_marshal returns an error should be considered
> valid. At least `v9fs_do_readdir_with_stat' relies on that to place in
> responce buffer as much data as can fit.
>
Indeed, that's embarrassing... but since v9fs_do_readdir_with_stat() is the
only guy that does that, I'd prefer you send a patch to handle this special
case instead of reverting 8d37de41ca. Please add a new transport operation
for this.
Thanks!
> Signed-off-by: Jan Dakinevich <jan.dakinevich@gmail.com>
> ---
> hw/9pfs/virtio-9p-device.c | 19 ++-----------------
> 1 file changed, 2 insertions(+), 17 deletions(-)
>
> diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
> index 62650b0..c3e5935 100644
> --- a/hw/9pfs/virtio-9p-device.c
> +++ b/hw/9pfs/virtio-9p-device.c
> @@ -146,16 +146,8 @@ static ssize_t virtio_pdu_vmarshal(V9fsPDU *pdu, size_t offset,
> V9fsState *s = pdu->s;
> V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
> VirtQueueElement *elem = v->elems[pdu->idx];
> - ssize_t ret;
>
> - ret = v9fs_iov_vmarshal(elem->in_sg, elem->in_num, offset, 1, fmt, ap);
> - if (ret < 0) {
> - VirtIODevice *vdev = VIRTIO_DEVICE(v);
> -
> - virtio_error(vdev, "Failed to encode VirtFS reply type %d",
> - pdu->id + 1);
> - }
> - return ret;
> + return v9fs_iov_vmarshal(elem->in_sg, elem->in_num, offset, 1, fmt, ap);
> }
>
> static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
> @@ -164,15 +156,8 @@ static ssize_t virtio_pdu_vunmarshal(V9fsPDU *pdu, size_t offset,
> V9fsState *s = pdu->s;
> V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);
> VirtQueueElement *elem = v->elems[pdu->idx];
> - ssize_t ret;
>
> - ret = v9fs_iov_vunmarshal(elem->out_sg, elem->out_num, offset, 1, fmt, ap);
> - if (ret < 0) {
> - VirtIODevice *vdev = VIRTIO_DEVICE(v);
> -
> - virtio_error(vdev, "Failed to decode VirtFS request type %d", pdu->id);
> - }
> - return ret;
> + return v9fs_iov_vunmarshal(elem->out_sg, elem->out_num, offset, 1, fmt, ap);
> }
>
> static void virtio_init_in_iov_from_pdu(V9fsPDU *pdu, struct iovec **piov,
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-13 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 14:16 [Qemu-devel] [PATCH] virtio-9p: don't break device on marshaling fail Jan Dakinevich
2017-09-13 14:59 ` Greg Kurz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).