qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: zhang.zhanghailiang@huawei.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] net: prevent sending packets while guest is stopped
Date: Thu, 4 Sep 2014 09:48:45 +0300	[thread overview]
Message-ID: <20140904064845.GA10061@redhat.com> (raw)
In-Reply-To: <5407F0CA.1090403@redhat.com>

On Thu, Sep 04, 2014 at 12:55:38PM +0800, Jason Wang wrote:
> On 09/02/2014 10:23 PM, Stefan Hajnoczi wrote:
> > Do not modify guest memory or devices when the guest is stopped.
> > Currently the netdevs still send packets while the guest is stopped if
> > their file descriptor was being monitored for write (e.g. the socket
> > write buffer filled before the guest was stopped).
> >
> > Netdevs call qemu_flush_queued_packets() when the file descriptor
> > becomes writable again.  Don't resume packet processing when this
> > happens.
> >
> > Instead we flush queues when the guest resumes.
> >
> > Cc: qemu-stable@nongnu.org
> > Reported-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> > Note this fixes the transmit side.  The receive side was recently fixed in
> > "net: Forbid dealing with packets when VM is not running".
> >
> >  net/net.c | 30 ++++++++++++++++++++++++++++++
> >  1 file changed, 30 insertions(+)
> >
> > diff --git a/net/net.c b/net/net.c
> > index 6d930ea..74ec07a 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -47,6 +47,7 @@
> >  # define CONFIG_NET_BRIDGE
> >  #endif
> >  
> > +static VMChangeStateEntry *net_change_state_entry;
> >  static QTAILQ_HEAD(, NetClientState) net_clients;
> >  
> >  const char *host_net_devices[] = {
> > @@ -506,6 +507,11 @@ void qemu_purge_queued_packets(NetClientState *nc)
> >  
> >  void qemu_flush_queued_packets(NetClientState *nc)
> >  {
> > +    /* Guest memory and devices must not be modified while stopped */
> > +    if (!runstate_is_running()) {
> > +        return;
> > +    }
> > +
> 
> Consider migration case, this will prevent
> sent_cb(virtio_net_tx_complete) from being called at source. Since we
> don't migrate queue and async_tx. This may lead a interrupt lost in
> destination after migration?
> 
> (Looks like virtio_net is the only user that uses async sending, not
> sure why this is needed)

Good point, I noticed this too.
Sorry about missing this the first time around.

      reply	other threads:[~2014-09-04  6:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-02 14:23 [Qemu-devel] [PATCH] net: prevent sending packets while guest is stopped Stefan Hajnoczi
2014-09-02 14:25 ` Michael S. Tsirkin
2014-09-04  6:28   ` Michael S. Tsirkin
2014-09-04  4:55 ` Jason Wang
2014-09-04  6:48   ` Michael S. Tsirkin [this message]

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=20140904064845.GA10061@redhat.com \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=zhang.zhanghailiang@huawei.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 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).