From: Stefan Hajnoczi <stefanha@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: peter.maydell@linaro.org,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
mst@redhat.com, luonengjun@huawei.com, qemu-devel@nongnu.org,
peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH] net: Forbid dealing with packets when VM is not running
Date: Fri, 22 Aug 2014 11:08:41 +0100 [thread overview]
Message-ID: <20140822100841.GB11330@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <53F41364.3020302@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2642 bytes --]
On Wed, Aug 20, 2014 at 11:17:56AM +0800, Jason Wang wrote:
> On 08/19/2014 08:29 PM, Stefan Hajnoczi wrote:
> > On Mon, Aug 18, 2014 at 04:32:42PM +0800, zhanghailiang wrote:
> >> On 2014/8/18 14:55, Jason Wang wrote:
> >>> On 08/18/2014 12:46 PM, zhanghailiang wrote:
> >>>> diff --git a/net/net.c b/net/net.c
> >>>> index 6d930ea..21f0d48 100644
> >>>> --- a/net/net.c
> >>>> +++ b/net/net.c
> >>>> @@ -242,6 +242,29 @@ NetClientState *qemu_new_net_client(NetClientInfo *info,
> >>>> return nc;
> >>>> }
> >>>>
> >>>> +static void nic_vmstate_change_handler(void *opaque,
> >>>> + int running,
> >>>> + RunState state)
> >>>> +{
> >>>> + NICState *nic = opaque;
> >>>> + NetClientState *nc;
> >>>> + int i, queues;
> >>>> +
> >>>> + if (!running) {
> >>>> + return;
> >>>> + }
> >>>> +
> >>>> + queues = MAX(1, nic->conf->peers.queues);
> >>>> + for (i = 0; i< queues; i++) {
> >>>> + nc =&nic->ncs[i];
> >>>> + if (nc->receive_disabled
> >>>> + || (nc->info->can_receive&& !nc->info->can_receive(nc))) {
> >>>> + continue;
> >>>> + }
> >>>> + qemu_flush_queued_packets(nc);
> >>> How about simply purge the receive queue during stop? If ok, there's no
> >>> need to introduce extra vmstate change handler.
> >>>
> >> I don't know whether it is OK to purge the receive packages, it was
> >> suggested by Stefan Hajnoczi, and i am waiting for his opinion .:)
> >>
> >> I think we still need the extra vmstate change handler, Without the
> >> change handler, we don't know if the VM will go to stop and the time
> >> when to call qemu_purge_queued_packets.
> > qemu_flush_queued_packets() sets nc->received_disabled = 0. This may be
> > needed to get packets flowing again if ->receive() previously returned 0.
> >
> > Purging the queue does not clear nc->received_disabled so it is not
> > enough.
>
> Confused.
>
> virtio_net_receive() only returns 0 when it does not have enough rx
> buffers. In this case, it just wait for the guest to refill and kick
> again. Its rx kick handler will call qemu_flush_queued_packets() to
> clear nc->received_disabled. So does usbnet and others.
>
> If nic_received_disabled is 1, it means the no available rx buffer. We
> need wait guest to do the processing and refilling. Then why need clear
> it after vm was started?
I took a look at other emulated NICs, they don't use return 0 in
->receive().
I think you are right, we don't need to worry about flushing.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-08-22 10:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-18 4:46 [Qemu-devel] [PATCH] net: Forbid dealing with packets when VM is not running zhanghailiang
2014-08-18 6:55 ` Jason Wang
2014-08-18 8:32 ` zhanghailiang
2014-08-18 9:14 ` Jason Wang
2014-08-20 1:59 ` zhanghailiang
2014-08-19 12:29 ` Stefan Hajnoczi
2014-08-20 2:19 ` zhanghailiang
2014-08-20 3:17 ` Jason Wang
2014-08-22 10:08 ` Stefan Hajnoczi [this message]
2014-08-18 12:27 ` Dr. David Alan Gilbert
2014-08-19 6:46 ` zhanghailiang
2014-08-19 8:48 ` Dr. David Alan Gilbert
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=20140822100841.GB11330@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=jasowang@redhat.com \
--cc=luonengjun@huawei.com \
--cc=mst@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--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).