All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: "manish.mishra" <manish.mishra@nutanix.com>
Cc: qemu-devel@nongnu.org, berrange@redhat.com,
	prerna.saxena@nutanix.com, quintela@redhat.com,
	dgilbert@redhat.com, lsoaresp@redhat.com
Subject: Re: [PATCH v4 2/2] migration: check magic value for deciding the mapping of channels
Date: Wed, 23 Nov 2022 10:52:01 -0500	[thread overview]
Message-ID: <Y35BoSi9NUmbFoCk@x1n> (raw)
In-Reply-To: <20221123150527.24608-3-manish.mishra@nutanix.com>

On Wed, Nov 23, 2022 at 03:05:27PM +0000, manish.mishra wrote:
> +int migration_channel_read_peek(QIOChannel *ioc,
> +                                const char *buf,
> +                                const size_t buflen,
> +                                Error **errp)
> +{
> +   ssize_t len = 0;
> +   struct iovec iov = { .iov_base = (char *)buf, .iov_len = buflen };
> +
> +   while (len < buflen) {
> +       len = qio_channel_readv_full(ioc, &iov, 1, NULL,
> +                                    NULL, QIO_CHANNEL_READ_FLAG_MSG_PEEK, errp);
> +
> +       if (len == QIO_CHANNEL_ERR_BLOCK) {

This needs to take care of partial len too?

> +            if (qemu_in_coroutine()) {
> +                /* 1ms sleep. */
> +                qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000);
> +            } else {
> +                qio_channel_wait(ioc, G_IO_IN);
> +            }
> +            continue;
> +       }
> +       if (len == 0) {
> +           error_setg(errp,
> +                      "Unexpected end-of-file on channel");
> +           return -1;
> +       }
> +       if (len < 0) {
> +           return -1;
> +       }
> +   }
> +
> +   return 0;
> +}

-- 
Peter Xu



  reply	other threads:[~2022-11-23 15:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 15:05 [PATCH v4 0/2] migration: check magic value for deciding the mapping of channels manish.mishra
2022-11-23 15:05 ` [PATCH v4 1/2] io: Add support for MSG_PEEK for socket channel manish.mishra
2022-11-23 15:42   ` Daniel P. Berrangé
2022-11-23 15:05 ` [PATCH v4 2/2] migration: check magic value for deciding the mapping of channels manish.mishra
2022-11-23 15:52   ` Peter Xu [this message]
2022-11-23 15:58     ` manish.mishra
2022-11-23 16:27       ` Peter Xu
2022-11-23 16:33         ` manish.mishra
2022-11-23 15:58   ` Daniel P. Berrangé
2022-11-23 16:04     ` manish.mishra
2022-11-23 16:19       ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y35BoSi9NUmbFoCk@x1n \
    --to=peterx@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=lsoaresp@redhat.com \
    --cc=manish.mishra@nutanix.com \
    --cc=prerna.saxena@nutanix.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.