From patchwork Fri Apr 1 11:16:23 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: 8723061 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06DABC0553 for ; Fri, 1 Apr 2016 11:22:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF3F5203B6 for ; Fri, 1 Apr 2016 11:22:38 +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 4685F20390 for ; Fri, 1 Apr 2016 11:22:38 +0000 (UTC) Received: from localhost ([::1]:43555 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx9x-0006kH-KR for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Apr 2016 07:22:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx4i-00065q-4a for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:17:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alx4d-0001pc-5R for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:17:12 -0400 Received: from mail-qk0-x232.google.com ([2607:f8b0:400d:c09::232]:36004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx4c-0001pR-P8 for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:17:07 -0400 Received: by mail-qk0-x232.google.com with SMTP id i4so36573069qkc.3 for ; Fri, 01 Apr 2016 04:17:06 -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=9ip7gBz8HyCUf24mPzv7R/dfB5E0dRGmrEt/L2XVMXg=; b=XjD1OoBb4Bb7g3sL09nLRMYgLIcfucAC/5wDMfwXSPI6qEsBJEZ7qs7IAa+rLAqc6E 1EqgDDxrkKniI6ktNzctXDQS/Uo1/HJr2n3zKZJHz4HIu6+e+wniwccaK8PY1MfOr/bo trqzQKYj8YQWNAOR92sQTMq/7B9IFyE5d9/Ml5AfKdnYK6GA5kE6mg+KoC8BXFZmY6MS fEVDwt+GCgxI/ZWLG4dlqji/xmTroULyV/8O5ojtKf0Xx/EgC3arMFCYqPhKhcrhC0Et MeE0Mv19VW+pmqRObzgmRMWfkyUBPNOVHpXka5usCeOar3u9hVFzOHeD0dY32cGjAKIT 6V3Q== 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=9ip7gBz8HyCUf24mPzv7R/dfB5E0dRGmrEt/L2XVMXg=; b=ZEKP5zeARWwcEvFE3JTXjANqG7FSKcOeVjtsNIuJe4QI7/7hob0F0uzT175ZjE5wgZ ntiuW9Xj68cXHq4mswfQibAHLGo5pwCiIVINt0IkVbG5GWS1Los+fcfxv72+HDVRPQmc q9QOJ2i4voadEC0dZ1WGb+J4/k9NK+2+ILLv1hcNWCwlKXXVlYDVEzcxITPh/KzkThp/ wXlgRnETWFjJpkWYXm2HXTNJGry/plQJ/nOCVeNlBJxk4P7u5x7dIe2nmr+rUkJ2YuIa 09GZvegpx1M2PpHWNOQ1SjzI4hvyeUla8lL9KQol6x8j1qw7HcSRi5eJHHgslxuhpB/h eEbQ== X-Gm-Message-State: AD7BkJIxVv8xzkZGtqVMUozJ49drgkr8TJnjvtA/WDoK+NbX8WqUgL2OQd9VP8YJp1yUOg== X-Received: by 10.55.204.91 with SMTP id r88mr456379qki.21.1459509426536; Fri, 01 Apr 2016 04:17:06 -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 b74sm5884158qge.22.2016.04.01.04.17.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Apr 2016 04:17:05 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 1 Apr 2016 13:16:23 +0200 Message-Id: <1459509388-6185-14-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459509388-6185-1-git-send-email-marcandre.lureau@redhat.com> References: <1459509388-6185-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::232 Cc: Yuanhan Liu , "Michael S. Tsirkin" , Ilya Maximets , jonshin@cisco.com, Tetsuya Mukawa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH 13/18] vhost-net: do not crash if backend is not present X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org 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 1e4710d..6c40c4e 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -415,8 +415,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); }