From patchwork Mon Jun 6 16:45:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9158787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6CFEB60573 for ; Mon, 6 Jun 2016 16:47:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C05028349 for ; Mon, 6 Jun 2016 16:47:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E6F12834C; Mon, 6 Jun 2016 16:47:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B551D28349 for ; Mon, 6 Jun 2016 16:47:21 +0000 (UTC) Received: from localhost ([::1]:43779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9xgK-0005K4-3h for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Jun 2016 12:47:16 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=joal4+ZISxD/7iIFef44w95z7ICGDUPpTzNGJig6DQs=; b=w1Y8z6Rk9nLc6tG35wLrsgh7sIOWxV0WKrhwZfPhiOywpB8YR+A6wHocSNHfp3+SDa VogBMDNbB/W18Q6OiOUhma0Bu82rLIM/2h2VlQcqIWy+aHeHCL+1m34/XF57Trdu0s9G vyMu3e84J0cmbt79l0xjLnNcBmkT3UQOvL0Y/GZtP90TwpyNT+/dIcXQWxh+lMU7mp/a HWXNghj4Z8m6rJUOO11ozwPu1M2UQuH1PfnmpnskYAq9vvoSWPnuKDriv69q37DIGzHN HZ1DxKTmMX5/rsZb9I5BKdAcRieZuvmgo2uGhKR+QWAUQqV6OrmpeMdCj7uh4t4Kirua mVzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=joal4+ZISxD/7iIFef44w95z7ICGDUPpTzNGJig6DQs=; b=Hhcxd21a+RbZbX/GUPTggBedFtlAk2aMCO7t7dkrPVh3y0rRvc4mp25A3DM19rNZF2 ED0fQWZeC7FRLv8KWuGg9Oyia8fI9KKVFefNnjGc8I7nrbj/ExZf6UDp9RYLAj8ea3dk 825lJH9fljWruwnRwGru17aZj2J0Nj5cMSkrXmyXUF3NDvJcJYqM4uJZQyfPAVBq11Q6 sXqu4rPHBi2FM46jEpq7Ov+QDWtjwYKJBw0pjz3Afs2Ly19ZBuWXgyaRezDEIT3heChz 3jyuFDvFM1dBac6OUcxzyiTkOFRNtQDYiA7kiXaPIAq3vCxCGvCNiyD7dFt2LPQ+53br twDg== X-Gm-Message-State: ALyK8tKvCULpC4KuRqo6/TLIlJbg/qX+eOR/lYAri44GtHl4URDvIaZi+gvT9GStU62U+Q== X-Received: by 10.55.12.12 with SMTP id 12mr16729110qkm.8.1465231533324; Mon, 06 Jun 2016 09:45:33 -0700 (PDT) Received: from localhost (APoitiers-110-1-1-130.w193-248.abo.wanadoo.fr. [193.248.103.130]) by smtp.gmail.com with ESMTPSA id i63sm5360088qkd.13.2016.06.06.09.45.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2016 09:45:32 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Mon, 6 Jun 2016 18:45:04 +0200 Message-Id: <1465231508-30183-7-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.7.4 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::242 Subject: [Qemu-devel] [PATCH 06/10] vhost-net: do not crash if backend is not present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuanhan Liu , "Michael S . Tsirkin" , Ilya Maximets , jonshin@cisco.com, Tetsuya Mukawa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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); }