Received: from eggs.gnu.org ([2001:4830:134:3::10]:46083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCYdl-0002mJ-JE for qemu-devel@nongnu.org; Mon, 13 Jun 2016 16:39:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCYdj-0002VX-Ix for qemu-devel@nongnu.org; Mon, 13 Jun 2016 16:39:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCYdj-0002VP-DZ for qemu-devel@nongnu.org; Mon, 13 Jun 2016 16:39:19 -0400 Date: Mon, 13 Jun 2016 23:39:15 +0300 From: "Michael S. Tsirkin" Message-ID: <20160613233915-mutt-send-email-mst@redhat.com> References: <1465850292-10726-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1465850292-10726-1-git-send-email-mst@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 07/32] 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: Peter Maydell , =?iso-8859-1?Q?Marc-Andr=E9?= Lureau , Yuanhan Liu , Victor Kaplansky , Jason Wang From: Marc-Andr=E9 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=E9 Lureau Tested-by: Yuanhan Liu Reviewed-by: Yuanhan Liu Reviewed-by: Victor Kaplansky Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 =3D get_vhost_net(nc); - const VhostOps *vhost_ops =3D net->dev.vhost_ops; + const VhostOps *vhost_ops; + + if (!net) { + return 0; + } =20 + vhost_ops =3D net->dev.vhost_ops; if (vhost_ops->vhost_set_vring_enable) { return vhost_ops->vhost_set_vring_enable(&net->dev, enable); } --=20 MST