qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/5] vhost-net-user: add stubs for when no virtio-net device is present
Date: Mon, 26 Nov 2018 17:43:55 -0500	[thread overview]
Message-ID: <20181126174340-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <de2b36ae-7445-2a85-7187-7748d5f77baa@redhat.com>

On Mon, Nov 26, 2018 at 05:45:47PM +0100, Philippe Mathieu-Daudé wrote:
> On 26/11/18 14:20, Paolo Bonzini wrote:
> > hw/net/vhost_net.c needs functions that are declared in net/vhost-user.c: the
> > 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.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>

whic hosts/targets and how did you test exactly?

> > ---
> >  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 0a3c6a7..cda17ef 100755
> > --- a/configure
> > +++ b/configure
> > @@ -6513,7 +6513,7 @@ if test "$vhost_scsi" = "yes" ; then
> >    echo "CONFIG_VHOST_SCSI=y" >> $config_host_mak
> >  fi
> >  if test "$vhost_net" = "yes" -a "$vhost_user" = "yes"; then
> > -  echo "CONFIG_VHOST_NET_USED=y" >> $config_host_mak
> > +  echo "CONFIG_VHOST_NET_USER=y" >> $config_host_mak
> >  fi
> >  if test "$vhost_crypto" = "yes" ; then
> >    echo "CONFIG_VHOST_CRYPTO=y" >> $config_host_mak
> > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > index b901306..fe6202a 100644
> > --- a/hw/net/vhost_net.c
> > +++ b/hw/net/vhost_net.c
> > @@ -193,6 +193,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
> >      }
> >  
> >      /* Set sane init value. Override when guest acks. */
> > +#ifdef CONFIG_VHOST_USER
> >      if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) {
> >          features = vhost_user_get_acked_features(net->nc);
> >          if (~net->dev.features & features) {
> > @@ -202,6 +203,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
> >              goto fail;
> >          }
> >      }
> > +#endif
> >  
> >      vhost_net_ack_features(net, features);
> >  
> > @@ -413,10 +415,12 @@ VHostNetState *get_vhost_net(NetClientState *nc)
> >      case NET_CLIENT_DRIVER_TAP:
> >          vhost_net = tap_get_vhost_net(nc);
> >          break;
> > +#ifdef CONFIG_VHOST_NET_USER
> >      case NET_CLIENT_DRIVER_VHOST_USER:
> >          vhost_net = 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 += socket.o
> >  common-obj-y += dump.o
> >  common-obj-y += eth.o
> >  common-obj-$(CONFIG_L2TPV3) += l2tpv3.o
> > -common-obj-$(CONFIG_POSIX) += vhost-user.o
> > +common-obj-$(call land,$(CONFIG_VIRTIO_NET),$(CONFIG_VHOST_NET_USER)) += vhost-user.o
> > +common-obj-$(call land,$(call lnot,$(CONFIG_VIRTIO_NET)),$(CONFIG_VHOST_NET_USER)) += vhost-user-stub.o
> > +common-obj-$(CONFIG_ALL) += vhost-user-stub.o
> >  common-obj-$(CONFIG_SLIRP) += slirp.o
> >  common-obj-$(CONFIG_VDE) += vde.o
> >  common-obj-$(CONFIG_NETMAP) += netmap.o
> > diff --git a/net/net.c b/net/net.c
> > index 07c194a..95a74ad 100644
> > --- a/net/net.c
> > +++ b/net/net.c
> > @@ -955,7 +955,7 @@ static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
> >          [NET_CLIENT_DRIVER_BRIDGE]    = net_init_bridge,
> >  #endif
> >          [NET_CLIENT_DRIVER_HUBPORT]   = net_init_hubport,
> > -#ifdef CONFIG_VHOST_NET_USED
> > +#ifdef CONFIG_VHOST_NET_USER
> >          [NET_CLIENT_DRIVER_VHOST_USER] = 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 later.
> > + * 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;
> > +}
> > 

  reply	other threads:[~2018-11-26 22:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 13:20 [Qemu-devel] [PATCH 0/5] vhost: enable for all targets Paolo Bonzini
2018-11-26 13:20 ` [Qemu-devel] [PATCH 1/5] vhost-net: move stubs to a separate file Paolo Bonzini
2018-11-26 13:20 ` [Qemu-devel] [PATCH 2/5] vhost-net-user: add stubs for when no virtio-net device is present Paolo Bonzini
2018-11-26 16:45   ` Philippe Mathieu-Daudé
2018-11-26 22:43     ` Michael S. Tsirkin [this message]
2018-11-26 22:52       ` Philippe Mathieu-Daudé
2018-11-26 13:20 ` [Qemu-devel] [PATCH 3/5] vhost: restrict Linux dependency to kernel vhost Paolo Bonzini
2018-11-26 16:51   ` Philippe Mathieu-Daudé
2018-11-26 13:20 ` [Qemu-devel] [PATCH 4/5] vhost-net: compile it on all targets that have virtio-net Paolo Bonzini
2018-11-26 16:55   ` Philippe Mathieu-Daudé
2018-11-26 13:20 ` [Qemu-devel] [PATCH 5/5] vhost-net: revamp configure logic Paolo Bonzini
2018-11-26 17:00   ` Philippe Mathieu-Daudé
2018-11-26 22:43 ` [Qemu-devel] [PATCH 0/5] vhost: enable for all targets Michael S. Tsirkin
2018-11-27  9:04   ` Paolo Bonzini
2018-11-27 16:27     ` Michael S. Tsirkin
2018-11-27 17:00       ` Paolo Bonzini
  -- strict thread matches above, loose matches on Subject: below --
2019-01-15 17:33 [Qemu-devel] [PATCH v2 " Paolo Bonzini
2019-01-15 17:33 ` [Qemu-devel] [PATCH 2/5] vhost-net-user: add stubs for when no virtio-net device is present Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181126174340-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).