DPDK patches and discussions
 help / color / mirror / Atom feed
From: Kyle Larose <klarose@sandvine.com>
To: huawei.xie@intel.com, yuanhan.liu@linux.intel.com
Cc: dev@dpdk.org, Kyle Larose <klarose@sandvine.com>
Subject: [dpdk-dev] [PATCH] net/virtio: fix qemu exit on device stop/start
Date: Fri,  2 Sep 2016 10:39:12 -0400	[thread overview]
Message-ID: <1472827152-4321-1-git-send-email-klarose@sandvine.com> (raw)

Starting with DPDK 16.04, performing a start, then stop followed by a
start on a virtio NIC sending traffic can cause qemu to exit.

Qemu exits with a message like:
    2016-09-01T15:45:32.119059Z qemu-kvm: Guest moved used index from 5
    to 1

This appears to occur because virtio_dev_start will always reinitialize
the virtio queues if virtio_dev_stop has been called. Prior to the
patch that introduced the regression, virtio_dev_stop did not mark the
device as stopped, so start would not actually reinitialize the queues.

This fix reintroduces that behaviour by tracking whether or not the
queues require initialization separately from whether or not the device
has been stopped. It does this by introducing an "opened" flag to the
device.

A simple test with testpmd can reproduce the problem.

1. Set up two virtio ports, ideally connecting two devices which can
ping one-another.
2. Start pinging between the devices
3. Start testpmd in interactive mode on the two virtio ports
    e.g. testpmd -w 0000:00:05.0 -w 0000:00:06.0 -- -i
4. Run the following commands a few times:
    start
    stop
    port stop 0
    port stop 1
    port start 0
    port start 1
    start
5. Qemu should exit with a "Guest moved ..." message.

After applying this patch, I can no longer reproduce this problem.
The ping resumes every time I start the ports back up.

Test environment:

- CPU: Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz
- Host OS: CentOS Linux release 7.1.1503 (Core)
- Guest OS: CentOS Linux release 7.2.1511 (Core)
- Qemu-kvm version: 1.5.3-86.el7_1.6

Fixes: 9a0615af7746 ("virtio: fix restart")

Signed-off-by: Kyle Larose <klarose@sandvine.com>
---
 drivers/net/virtio/virtio_ethdev.c | 10 ++++++++--
 drivers/net/virtio/virtio_pci.h    |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 07d6449..da796cb 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -558,6 +558,9 @@ virtio_dev_close(struct rte_eth_dev *dev)
 	vtpci_reset(hw);
 	virtio_dev_free_mbufs(dev);
 	virtio_free_queues(dev);
+
+	hw->opened = 0;
+
 }
 
 static void
@@ -1393,9 +1396,10 @@ virtio_dev_start(struct rte_eth_dev *dev)
 	virtio_dev_link_update(dev, 0);
 
 	/* On restart after stop do not touch queues */
-	if (hw->started)
+	if (hw->opened) {
+		hw->started = 1;
 		return 0;
-
+	}
 	/* Do final configuration before rx/tx engine starts */
 	virtio_dev_rxtx_start(dev);
 	vtpci_reinit_complete(hw);
@@ -1431,6 +1435,8 @@ virtio_dev_start(struct rte_eth_dev *dev)
 		VIRTQUEUE_DUMP(txvq->vq);
 	}
 
+	hw->opened = 1;
+
 	return 0;
 }
 
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index dd7693f..52911af 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -252,6 +252,7 @@ struct virtio_hw {
 	uint8_t	    vlan_strip;
 	uint8_t	    use_msix;
 	uint8_t     started;
+	uint8_t     opened;
 	uint8_t     modern;
 	uint8_t     mac_addr[ETHER_ADDR_LEN];
 	uint32_t    notify_off_multiplier;
-- 
1.8.3.1

                 reply	other threads:[~2016-09-02 14:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1472827152-4321-1-git-send-email-klarose@sandvine.com \
    --to=klarose@sandvine.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@intel.com \
    --cc=yuanhan.liu@linux.intel.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).