[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v18 08/20] io: add qio_channel_readv_full_all_eof & qio_chann
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v18 08/20] io: add qio_channel_readv_full_all_eof & qio_channel_readv_full_all helpers |
Date: |
Thu, 14 Jan 2021 13:49:04 +0000 |
On Wed, Jan 13, 2021 at 03:53:27PM -0500, Jagannathan Raman wrote:
> while (nlocal_iov > 0) {
> ssize_t len;
> - len = qio_channel_readv(ioc, local_iov, nlocal_iov, errp);
> + len = qio_channel_readv_full(ioc, local_iov, nlocal_iov, local_fds,
> + local_nfds, errp);
> if (len == QIO_CHANNEL_ERR_BLOCK) {
> if (qemu_in_coroutine()) {
> qio_channel_yield(ioc, G_IO_IN);
> @@ -112,20 +140,41 @@ int qio_channel_readv_all_eof(QIOChannel *ioc,
> qio_channel_wait(ioc, G_IO_IN);
> }
> continue;
> - } else if (len < 0) {
> - goto cleanup;
> - } else if (len == 0) {
> - if (partial) {
> + }
> +
> + if (len <= 0) {
> + if ((len == 0) && partial) {
> + size_t fd_idx = 0;
> +
> error_setg(errp,
> "Unexpected end-of-file before all bytes were
> read");
> - } else {
> +
> + if (nfds) {
> + fd_idx = *nfds;
> + *nfds = 0;
> + }
> +
> + while (fds && fd_idx) {
> + close((*fds)[fd_idx - 1]);
> + fd_idx--;
> + }
> +
> + if (fds) {
> + g_free(*fds);
> + *fds = NULL;
> + }
> + } else if (len == 0) {
> ret = 0;
> }
The len < 0 case is missing. This function will return -1 and errp has
been set by qio_channel_readv_full(). However, we may have received fds
in a previous loop iteration (partial == true), so it is necessary to
close, free, and reset fds/nfds before returning.
signature.asc
Description: PGP signature
- [PATCH v18 17/20] multi-process: Synchronize remote memory, (continued)
- [PATCH v18 17/20] multi-process: Synchronize remote memory, Jagannathan Raman, 2021/01/13
- [PATCH v18 16/20] multi-process: PCI BAR read/write handling for proxy & remote endpoints, Jagannathan Raman, 2021/01/13
- [PATCH v18 18/20] multi-process: create IOHUB object to handle irq, Jagannathan Raman, 2021/01/13
- [PATCH v18 19/20] multi-process: Retrieve PCI info from remote process, Jagannathan Raman, 2021/01/13
- [PATCH v18 20/20] multi-process: perform device reset in the remote process, Jagannathan Raman, 2021/01/13
- [PATCH v18 02/20] multi-process: add configure and usage information, Jagannathan Raman, 2021/01/13
- [PATCH v18 01/20] multi-process: add the concept description to docs/devel/qemu-multiprocess, Jagannathan Raman, 2021/01/13
- [PATCH v18 05/20] multi-process: setup PCI host bridge for remote device, Jagannathan Raman, 2021/01/13
- [PATCH v18 04/20] multi-process: Add config option for multi-process QEMU, Jagannathan Raman, 2021/01/13
- [PATCH v18 08/20] io: add qio_channel_readv_full_all_eof & qio_channel_readv_full_all helpers, Jagannathan Raman, 2021/01/13
- Re: [PATCH v18 08/20] io: add qio_channel_readv_full_all_eof & qio_channel_readv_full_all helpers,
Stefan Hajnoczi <=
- [PATCH v18 11/20] multi-process: Associate fd of a PCIDevice with its object, Jagannathan Raman, 2021/01/13