From patchwork Tue May 10 16:03:56 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: 9060011 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87A209F1C1 for ; Tue, 10 May 2016 16:09:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E70922012B for ; Tue, 10 May 2016 16:09:44 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 2DAB520123 for ; Tue, 10 May 2016 16:09:44 +0000 (UTC) Received: from localhost ([::1]:47351 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0AEA-0007RQ-Nz for patchwork-qemu-devel@patchwork.kernel.org; Tue, 10 May 2016 12:09:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0A90-0006Vg-Az for qemu-devel@nongnu.org; Tue, 10 May 2016 12:04:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0A8y-0007Af-5S for qemu-devel@nongnu.org; Tue, 10 May 2016 12:04:21 -0400 Received: from mail-qk0-x229.google.com ([2607:f8b0:400d:c09::229]:35096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0A8y-0007Aa-1S for qemu-devel@nongnu.org; Tue, 10 May 2016 12:04:20 -0400 Received: by mail-qk0-x229.google.com with SMTP id n62so8394585qkc.2 for ; Tue, 10 May 2016 09:04:19 -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=3LENwa8Q7V3uYEV2PCQGgkjjjgc/m0YLrmY/qSIC2DA=; b=obYNiorKXFrVAl4BwQcKraa4hEukz9e744liOU1KT7l+beBpALUYuFeRQ1v/cwNnFZ 4w/aKhkOYfVSKSny/jZId191iKLBKCoSTxMyPq+2x6ZM+5tL/fhqgtcIZF1VWJPxCZw+ 4Ci/Ikm8Yi5RJ+zXQKEdFQPY0uOGFBpNyernfLoGRkJxQFU+oho95l+H5MJM63VqWn2W yp0pupx7mE8KWBL6hug0vzj8tbpnU4aCHBPizOq95hZCzRmNsEnPbNfT323gV5QDbF5/ YvghbFdhE82EKt0VSVoi0obmDu5Ndcmgc6TBmXcJjOpKFw4/UmUVAIGfVdUv5l6HrJnX 05RQ== 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=3LENwa8Q7V3uYEV2PCQGgkjjjgc/m0YLrmY/qSIC2DA=; b=YXf90J0ciEK9iiojrmQzxdYuHjw2YK1mUhRlp7u/n76N0OMTo3Q4jFd0I15bzbhcoN wnlE5WfPi22JakgexhC7/k2o27eBt0xX2dA7AwODGFihumpl0kambWxg3RLqV/cL7ItH hJQfSKXt5k9RsiTvLvCYkUBhj1cd0m7wEqlw+hmjb2Y1oUJmGjE1wLLMByFu5ibfpGXJ BzOeCudtzGgfX1J47756rUIwBNu/5NMtC8kl3FcOLvyVZwrQWqtospkKc71DbhbBYUtc ax6W/gtJZX77isWf1BqPd1OZHg9QiwePPCD7beYf8a/dVCc8XZUSdR4pBS7e6fqaean3 i1ng== X-Gm-Message-State: AOPr4FUt3E0FAznH/Y690/y4HnQ9kn/KpXjY5gHEABni0yZTDte9fZ1QZmbTZ7v99EXpXw== X-Received: by 10.55.20.37 with SMTP id e37mr25026870qkh.132.1462896259520; Tue, 10 May 2016 09:04:19 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id a41sm1182899qgf.48.2016.05.10.09.04.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 May 2016 09:04:18 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Tue, 10 May 2016 18:03:56 +0200 Message-Id: <1462896240-30999-7-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462896240-30999-1-git-send-email-marcandre.lureau@redhat.com> References: <1462896240-30999-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::229 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-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org 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 --- 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); }