qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, stefanha@redhat.com, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/2] tests: test rx recovery from cont
Date: Wed, 08 Jul 2015 17:42:32 +0800	[thread overview]
Message-ID: <559CF088.50502@redhat.com> (raw)
In-Reply-To: <20150708054432.GA22926@ad.nay.redhat.com>



On 07/08/2015 01:44 PM, Fam Zheng wrote:
> On Wed, 07/08 13:12, Jason Wang wrote:
>>
>> On 07/08/2015 11:22 AM, Fam Zheng wrote:
>>> On Tue, 07/07 18:58, Jason Wang wrote:
>>>> Rx should be recovered after cont.
>>>>
>>>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>>>> ---
>>>>  tests/virtio-net-test.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>>>>  1 file changed, 48 insertions(+)
>>>>
>>>> diff --git a/tests/virtio-net-test.c b/tests/virtio-net-test.c
>>>> index 97aa442..aeae80c 100644
>>>> --- a/tests/virtio-net-test.c
>>>> +++ b/tests/virtio-net-test.c
>>>> @@ -138,6 +138,45 @@ static void tx_test(const QVirtioBus *bus, QVirtioDevice *dev,
>>>>      g_assert_cmpstr(buffer, ==, "TEST");
>>>>  }
>>>>  
>>>> +static void rx_stop_cont_test(const QVirtioBus *bus, QVirtioDevice *dev,
>>>> +                              QGuestAllocator *alloc, QVirtQueue *vq,
>>>> +                              int socket)
>>>> +{
>>>> +    uint64_t req_addr;
>>>> +    uint32_t free_head;
>>>> +    char test[] = "TEST";
>>>> +    char buffer[64];
>>>> +    int len = htonl(sizeof(test));
>>>> +    struct iovec iov[] = {
>>>> +        {
>>>> +            .iov_base = &len,
>>>> +            .iov_len = sizeof(len),
>>>> +        }, {
>>>> +            .iov_base = test,
>>>> +            .iov_len = sizeof(test),
>>>> +        },
>>>> +    };
>>>> +    int ret;
>>>> +
>>>> +    req_addr = guest_alloc(alloc, 64);
>>>> +
>>>> +    free_head = qvirtqueue_add(vq, req_addr, 64, true, false);
>>>> +    qvirtqueue_kick(bus, dev, vq, free_head);
>>>> +
>>>> +    qmp("{ 'execute' : 'stop'}");
>>>> +
>>>> +    ret = iov_send(socket, iov, 2, 0, sizeof(len) + sizeof(test));
>>>> +    g_assert_cmpint(ret, ==, sizeof(test) + sizeof(len));
>>> Maybe add a small lag here? The next "cont" could be too early that is noticed
>>> earlier than the packet.
>> I'm not sure I get the point of this. But at any case, rx should be
>> recovered. (Btw, current qemu.git will fail in this case).
> If 'cont' and the packet land in main loop in the same qemu_poll_ns(), it's
> possible that the packet is processed before 'stop'.
>
> A trick is using qmp commands as barriers:
>
>     qmp("{ 'execute' : 'stop'}");
>
>     ret = iov_send(socket, iov, 2, 0, sizeof(len) + sizeof(test));
>     g_assert_cmpint(ret, ==, sizeof(test) + sizeof(len));
>
>     /* We could check the status, but this command is more importantly to
>      * ensure the packet data gets queued in QEMU, before we do 'cont'.
>      */
>     qmp("{ 'execute' : 'query-status'}");
>     qmp("{ 'execute' : 'cont'}");
>
> Fam
>
>

Right, this looks fine.

Thanks

  parent reply	other threads:[~2015-07-08  9:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 10:58 [Qemu-devel] [PATCH 1/2] tests: introduce basic pci test for virtio-net Jason Wang
2015-07-07 10:58 ` [Qemu-devel] [PATCH 2/2] tests: test rx recovery from cont Jason Wang
2015-07-08  3:22   ` Fam Zheng
2015-07-08  5:12     ` Jason Wang
2015-07-08  5:44       ` Fam Zheng
2015-07-08  5:48         ` Fam Zheng
2015-07-08  9:42         ` Jason Wang [this message]
2015-07-08  3:19 ` [Qemu-devel] [PATCH 1/2] tests: introduce basic pci test for virtio-net Fam Zheng
2015-07-08  5:02   ` Jason Wang
2015-07-08  5:47     ` Fam Zheng
2015-07-08  9:41       ` Jason Wang

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=559CF088.50502@redhat.com \
    --to=jasowang@redhat.com \
    --cc=famz@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 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).