From nobody Mon Feb 9 15:10:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550167663149369.7066721694067; Thu, 14 Feb 2019 10:07:43 -0800 (PST) Received: from localhost ([127.0.0.1]:52675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guLQB-00027j-WD for importer@patchew.org; Thu, 14 Feb 2019 13:07:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guL4L-0002MK-KX for qemu-devel@nongnu.org; Thu, 14 Feb 2019 12:45:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1guKvY-0003Fr-TB for qemu-devel@nongnu.org; Thu, 14 Feb 2019 12:36:01 -0500 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:38037) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1guKvY-0003EA-Kv for qemu-devel@nongnu.org; Thu, 14 Feb 2019 12:36:00 -0500 Received: by mail-wm1-x344.google.com with SMTP id v26so6926006wmh.3 for ; Thu, 14 Feb 2019 09:36:00 -0800 (PST) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id s3sm1906796wmj.23.2019.02.14.09.35.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 09:35:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1AxkKgHzbIrTn7/20KQBIiQCEIwsSnkeQY2SKPZNUho=; b=aeuA9o9Mro2huxENIyT/ZoH0D3Xj5YDD0GxKR6mKkJcPFA1AqWcVSPnWBymnWV8dKA 4HWnT+m7/WdsaLzX55J/St8qQ8IQkmcBC7jTLsAv2I1lXb0jJICvKz2eIwW9j5NSPnj1 VuKWDhQEAwORpwPXEZuly7igRNfNeEL9xeQFzCdbF/pM1eR9E7XPMFfUNzQsDvTqIFNf 6XoMYcschjlwFUjkwH0/3QcOZvDZUZ0oIMOTE++L2xNL8xDUhUeM+qVV7JzI9tm3/jmL S4PRB1i6dn6fb1+excgIm8hEe455K6EamyaCc/y+pGj9NWQNNR1HO/Eo4ILwAGWaxj7p OFIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1AxkKgHzbIrTn7/20KQBIiQCEIwsSnkeQY2SKPZNUho=; b=bGhlZ8hfmzikDhAKmLOzeuVBiFTRDH7KZRZpNsMOnFDbwVYtHkOhA/CpqwCtLbar5M 1TusAT8Co9DwB1+qeQJpPbJTzNpvpiB/SM8Rkzf7iI32m2TMz2dpPiwiQe48jlzexUzH Esk1o3xc3t/naQqKvO3PulP+xjImiCcaKVcVa5EN/12S95nzXJBo0m6v1yYWVdBdiN/U lxdPQlhOhjBwmrct27EcDPjSKSr+VBkny+GmfctoOLRrcVUVIvfI4DLFIwulxMVUxv7a 2bDhp2Aq0jBij4ZFK/f6N5dwm28TCLfHGElj/ABqhelBj9L5mCJ72bl4q+fTHidA9JYE uC4g== X-Gm-Message-State: AHQUAub5Uc5ENuwJtLzF899uLuOjsaK48Yr5NwCLQaa0xFFZD9lxZOqR 544OW01U/k+/3mt4arU+ouwYjuAi X-Google-Smtp-Source: AHgI3IY4aYlnQjbuSrXvLbjFse4nZlJSkkzeySlq/WHohgJA8pGoKKcd4nXYYj+tRYHcW0lsS6XhyQ== X-Received: by 2002:a7b:cf3a:: with SMTP id m26mr1538314wmg.144.1550165759360; Thu, 14 Feb 2019 09:35:59 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 14 Feb 2019 18:35:49 +0100 Message-Id: <1550165756-21617-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550165756-21617-1-git-send-email-pbonzini@redhat.com> References: <1550165756-21617-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH 2/9] vhost-net-user: add stubs for when no virtio-net device is 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: thuth@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) hw/net/vhost_net.c needs functions that are declared in net/vhost-user.c: t= he vhost-user code is always compiled into QEMU, only the constructor net_init_vhost_user is unreachable. Also, net/vhost-user.c needs functions declared in hw/virtio/vhost-stub.c even if no virtio device exists. Break this dependency. First, add a minimal version of net/vhost-user.c, with no functionality and no dependency on vhost code. Second, #ifdef out the calls back to net/vhost-user.c from hw/net/vhost_net.c. While at it, this patch fixes the CONFIG_VHOST_NET_USE*D* typo. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <1543851204-41186-3-git-send-email-pbonzini@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Paolo Bonzini --- configure | 2 +- hw/net/vhost_net.c | 4 ++++ net/Makefile.objs | 4 +++- net/net.c | 2 +- net/vhost-user-stub.c | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 net/vhost-user-stub.c diff --git a/configure b/configure index fbd0825..7ac76ec 100755 --- a/configure +++ b/configure @@ -6579,7 +6579,7 @@ if test "$vhost_scsi" =3D "yes" ; then echo "CONFIG_VHOST_SCSI=3Dy" >> $config_host_mak fi if test "$vhost_net" =3D "yes" && test "$vhost_user" =3D "yes"; then - echo "CONFIG_VHOST_NET_USED=3Dy" >> $config_host_mak + echo "CONFIG_VHOST_NET_USER=3Dy" >> $config_host_mak fi if test "$vhost_crypto" =3D "yes" ; then echo "CONFIG_VHOST_CRYPTO=3Dy" >> $config_host_mak diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index b901306..2a300ee 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) } =20 /* Set sane init value. Override when guest acks. */ +#ifdef CONFIG_VHOST_NET_USER if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { features =3D vhost_user_get_acked_features(net->nc); if (~net->dev.features & features) { @@ -202,6 +203,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) goto fail; } } +#endif =20 vhost_net_ack_features(net, features); =20 @@ -413,10 +415,12 @@ VHostNetState *get_vhost_net(NetClientState *nc) case NET_CLIENT_DRIVER_TAP: vhost_net =3D tap_get_vhost_net(nc); break; +#ifdef CONFIG_VHOST_NET_USER case NET_CLIENT_DRIVER_VHOST_USER: vhost_net =3D vhost_user_get_vhost_net(nc); assert(vhost_net); break; +#endif default: break; } diff --git a/net/Makefile.objs b/net/Makefile.objs index b2bf88a..df2b409 100644 --- a/net/Makefile.objs +++ b/net/Makefile.objs @@ -3,7 +3,9 @@ common-obj-y +=3D socket.o common-obj-y +=3D dump.o common-obj-y +=3D eth.o common-obj-$(CONFIG_L2TPV3) +=3D l2tpv3.o -common-obj-$(CONFIG_POSIX) +=3D vhost-user.o +common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET_USER)) +=3D= vhost-user.o +common-obj-$(call land,$(call lnot,$(CONFIG_VIRTIO_NET)),$(CONFIG_VHOST_NE= T_USER)) +=3D vhost-user-stub.o +common-obj-$(CONFIG_ALL) +=3D vhost-user-stub.o common-obj-$(CONFIG_SLIRP) +=3D slirp.o common-obj-$(CONFIG_VDE) +=3D vde.o common-obj-$(CONFIG_NETMAP) +=3D netmap.o diff --git a/net/net.c b/net/net.c index 5dcff7f..f3a3c54 100644 --- a/net/net.c +++ b/net/net.c @@ -961,7 +961,7 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIV= ER__MAX])( [NET_CLIENT_DRIVER_BRIDGE] =3D net_init_bridge, #endif [NET_CLIENT_DRIVER_HUBPORT] =3D net_init_hubport, -#ifdef CONFIG_VHOST_NET_USED +#ifdef CONFIG_VHOST_NET_USER [NET_CLIENT_DRIVER_VHOST_USER] =3D net_init_vhost_user, #endif #ifdef CONFIG_L2TPV3 diff --git a/net/vhost-user-stub.c b/net/vhost-user-stub.c new file mode 100644 index 0000000..52ab4e1 --- /dev/null +++ b/net/vhost-user-stub.c @@ -0,0 +1,23 @@ +/* + * vhost-user-stub.c + * + * Copyright (c) 2018 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "clients.h" +#include "net/vhost_net.h" +#include "net/vhost-user.h" +#include "qemu/error-report.h" +#include "qapi/error.h" + +int net_init_vhost_user(const Netdev *netdev, const char *name, + NetClientState *peer, Error **errp) +{ + error_setg(errp, "vhost-user requires frontend driver virtio-net-*"); + return -1; +} --=20 1.8.3.1