qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Ben Chaney <bchaney@akamai.com>
Cc: qemu-devel@nongnu.org, "Peter Xu" <peterx@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Jason Wang" <jasowang@redhat.com>,
	"Alex Williamson" <alex@shazbot.org>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Stefan Weil" <sw@weilnetz.de>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Hamza Khan" <hamza.khan@nutanix.com>,
	"Mark Kanda" <mark.kanda@oracle.com>,
	"Joshua Hunt" <johunt@akamai.com>,
	"Max Tottenham" <mtottenh@akamai.com>,
	"Steve Sistare" <steven.sistare@oracle.com>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@yandex-team.ru>
Subject: Re: [PATCH v3 8/8] tap: cpr fixes
Date: Thu, 4 Dec 2025 17:59:41 +0000	[thread overview]
Message-ID: <aTHMDQihX3ywKdlH@redhat.com> (raw)
In-Reply-To: <20251203-cpr-tap-v3-8-3c12e0a61f8e@akamai.com>

On Wed, Dec 03, 2025 at 01:51:25PM -0500, Ben Chaney wrote:
> From: Steve Sistare <steven.sistare@oracle.com>
> 
> Fix "virtio_net_set_queue_pairs: Assertion `!r' failed."
> Fix "virtio-net: saved image requires vnet_hdr=on"
> Do not change blocking mode of incoming cpr fd's.
> 
> Reported-by: Ben Chaney <bchaney@akamai.com>
> Reported-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> Signed-off-by: Ben Chaney <bchaney@akamai.com>
> ---
>  hw/net/virtio-net.c | 6 ++++++
>  io/channel-socket.c | 4 +++-
>  net/tap.c           | 2 ++
>  stubs/cpr.c         | 8 ++++++++
>  stubs/meson.build   | 1 +
>  5 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 38ec7ac109..fd6b30b296 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -37,6 +37,7 @@
>  #include "qapi/qapi-types-migration.h"
>  #include "qapi/qapi-events-migration.h"
>  #include "hw/virtio/virtio-access.h"
> +#include "migration/cpr.h"
>  #include "migration/misc.h"
>  #include "standard-headers/linux/ethtool.h"
>  #include "system/system.h"
> @@ -789,6 +790,11 @@ static void virtio_net_set_queue_pairs(VirtIONet *n)
>      int i;
>      int r;
>  
> +    if (cpr_is_incoming()) {
> +        /* peers are already attached, do nothing */
> +        return;
> +    }
> +
>      if (n->nic->peer_deleted) {
>          return;
>      }
> diff --git a/io/channel-socket.c b/io/channel-socket.c
> index 3053b35ad8..443ca8cb7c 100644
> --- a/io/channel-socket.c
> +++ b/io/channel-socket.c
> @@ -24,6 +24,7 @@
>  #include "io/channel-socket.h"
>  #include "io/channel-util.h"
>  #include "io/channel-watch.h"
> +#include "migration/cpr.h"
>  #include "trace.h"
>  #include "qapi/clone-visitor.h"
>  #ifdef CONFIG_LINUX
> @@ -521,7 +522,8 @@ static bool qio_channel_handle_fds(int *fds, size_t nfds,
>  
>          if (!preserve_blocking) {
>              /* O_NONBLOCK is preserved across SCM_RIGHTS so reset it */
> -            if (!qemu_set_blocking(*fd, true, errp)) {
> +              if (!cpr_is_incoming() &&
> +                  qemu_set_blocking(*fd, true, errp)) {
>                  return false;
>              }
>          }

This is wrong - we added the QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING
flag precisely so that we don't need to add CPR hacks into QIOChannelSocket
code.

Whatever cares about this blocking state being preserved needs to pass
that QIO_CHANNEL flag when reading from the channel.

> diff --git a/net/tap.c b/net/tap.c
> index 5acda81146..5e04099c87 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -1050,6 +1050,8 @@ free_fail:
>                  if (cpr && fd >= 0) {
>                      cpr_save_fd(name, TAP_FD_INDEX(i), fd);
>                  }
> +            } else {
> +                vnet_hdr = tap->has_vnet_hdr ? tap->vnet_hdr : 1;
>              }
>              if (fd == -1) {
>                  ret = -1;
> diff --git a/stubs/cpr.c b/stubs/cpr.c
> new file mode 100644
> index 0000000000..1a4dbbb2d7
> --- /dev/null
> +++ b/stubs/cpr.c
> @@ -0,0 +1,8 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +#include "qemu/osdep.h"
> +#include "migration/cpr.h"
> +
> +bool cpr_is_incoming(void)
> +{
> +    return false;
> +}
> diff --git a/stubs/meson.build b/stubs/meson.build
> index 0b2778c568..87af733528 100644
> --- a/stubs/meson.build
> +++ b/stubs/meson.build
> @@ -10,6 +10,7 @@ stub_ss.add(files('is-daemonized.c'))
>  stub_ss.add(files('monitor-core.c'))
>  stub_ss.add(files('replay-mode.c'))
>  stub_ss.add(files('trace-control.c'))
> +stub_ss.add(files('cpr.c'))
>  
>  if have_block
>    stub_ss.add(files('bdrv-next-monitor-owned.c'))
> 
> -- 
> 2.34.1
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-12-04 18:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-03 18:51 [PATCH v3 0/8] Live update: tap and vhost Ben Chaney
2025-12-03 18:51 ` [PATCH v3 1/8] migration: stop vm earlier for cpr Ben Chaney
2025-12-03 18:51 ` [PATCH v3 2/8] migration: cpr setup notifier Ben Chaney
2025-12-03 18:51 ` [PATCH v3 3/8] vhost: reset vhost devices for cpr Ben Chaney
2025-12-03 18:51 ` [PATCH v3 4/8] cpr: delete all fds Ben Chaney
2025-12-03 18:51 ` [PATCH v3 5/8] tap: common return label Ben Chaney
2025-12-03 18:51 ` [PATCH v3 6/8] tap: cpr support Ben Chaney
2025-12-04  8:09   ` Markus Armbruster
2025-12-05  0:51     ` Jason Wang
2025-12-05  6:46       ` Markus Armbruster
2025-12-04 17:46   ` Cédric Le Goater
2025-12-04 17:56   ` Daniel P. Berrangé
2025-12-03 18:51 ` [PATCH v3 7/8] tap: postload fix for cpr Ben Chaney
2025-12-03 18:51 ` [PATCH v3 8/8] tap: cpr fixes Ben Chaney
2025-12-04 17:59   ` Daniel P. Berrangé [this message]
2025-12-04 12:52 ` [PATCH v3 0/8] Live update: tap and vhost Vladimir Sementsov-Ogievskiy
2025-12-08 21:03   ` Chaney, Ben
2025-12-09  7:27     ` Vladimir Sementsov-Ogievskiy
2025-12-08 10:08 ` Cédric Le Goater
2025-12-08 14:22   ` Mark Kanda
2025-12-08 14:42     ` Cédric Le Goater
2025-12-09 18:36   ` Chaney, Ben
  -- strict thread matches above, loose matches on Subject: below --
2025-12-03 18:43 Ben Chaney
2025-12-03 18:43 ` [PATCH v3 8/8] tap: cpr fixes Ben Chaney

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=aTHMDQihX3ywKdlH@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex@shazbot.org \
    --cc=armbru@redhat.com \
    --cc=bchaney@akamai.com \
    --cc=clg@redhat.com \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --cc=hamza.khan@nutanix.com \
    --cc=jasowang@redhat.com \
    --cc=johunt@akamai.com \
    --cc=mark.kanda@oracle.com \
    --cc=mst@redhat.com \
    --cc=mtottenh@akamai.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sgarzare@redhat.com \
    --cc=steven.sistare@oracle.com \
    --cc=sw@weilnetz.de \
    --cc=vsementsov@yandex-team.ru \
    /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 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).