Received: from eggs.gnu.org ([2001:4830:134:3::10]:49624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xel-0004Qh-SR for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9xef-0005b7-T5 for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:39 -0400 Received: from mail-qk0-x242.google.com ([2607:f8b0:400d:c09::242]:33493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xef-0005au-Ou for qemu-devel@nongnu.org; Mon, 06 Jun 2016 12:45:33 -0400 Received: by mail-qk0-x242.google.com with SMTP id u63so4025313qkh.0 for ; Mon, 06 Jun 2016 09:45:33 -0700 (PDT) Sender: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= From: marcandre.lureau@redhat.com Date: Mon, 6 Jun 2016 18:45:04 +0200 Message-Id: <1465231508-30183-7-git-send-email-marcandre.lureau@redhat.com> In-Reply-To: <1465231508-30183-1-git-send-email-marcandre.lureau@redhat.com> References: <1465231508-30183-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 06/10] vhost-net: do not crash if backend is not present List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Tetsuya Mukawa , jonshin@cisco.com, Ilya Maximets , Yuanhan Liu , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= From: Marc-André Lureau Do not crash when backend is not present while enabling the ring. A following patch will save the enabled state so it can be restored once the backend is started. Signed-off-by: Marc-André Lureau Tested-by: Yuanhan Liu Reviewed-by: Yuanhan Liu --- hw/net/vhost_net.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6e1032f..805a0df 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -401,8 +401,13 @@ VHostNetState *get_vhost_net(NetClientState *nc) int vhost_set_vring_enable(NetClientState *nc, int enable) { VHostNetState *net = get_vhost_net(nc); - const VhostOps *vhost_ops = net->dev.vhost_ops; + const VhostOps *vhost_ops; + + if (!net) { + return 0; + } + vhost_ops = net->dev.vhost_ops; if (vhost_ops->vhost_set_vring_enable) { return vhost_ops->vhost_set_vring_enable(&net->dev, enable); } -- 2.7.4