All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCHv2] virtio-net: unify vhost-net start/stop
Date: Sun, 3 Oct 2010 22:17:15 +0200	[thread overview]
Message-ID: <20101003201715.GA28216@redhat.com> (raw)
In-Reply-To: <1285686994.4951.162.camel@x201>

On Tue, Sep 28, 2010 at 09:16:34AM -0600, Alex Williamson wrote:
> On Mon, 2010-09-27 at 23:52 +0200, Michael S. Tsirkin wrote:
> > On Mon, Sep 27, 2010 at 01:43:11PM -0600, Alex Williamson wrote:
> > > On Mon, 2010-09-27 at 18:41 +0200, Michael S. Tsirkin wrote:
> > > > Move all of vhost-net start/stop logic to a single routine,
> > > > and call it from everywhere.
> > > > 
> > > > Additionally, start/stop vhost-net on link up/down:
> > > > we should not transmit anything if user asked us to
> > > > put the link down.
> > > > 
> > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > > ---
> > > > 
> > > > Sent a wrong version, sorry about the noise.
> > > > 
> > > >  hw/virtio-net.c |   89 ++++++++++++++++++++++++++----------------------------
> > > >  1 files changed, 43 insertions(+), 46 deletions(-)
> > > > 
> > > > diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> > > > index 075f72d..f87c219 100644
> > > > --- a/hw/virtio-net.c
> > > > +++ b/hw/virtio-net.c
> > > > @@ -51,6 +51,7 @@ typedef struct VirtIONet
> > > >      uint8_t nouni;
> > > >      uint8_t nobcast;
> > > >      uint8_t vhost_started;
> > > > +    bool vm_running;
> > > >      VMChangeStateEntry *vmstate;
> > > >      struct {
> > > >          int in_use;
> > > > @@ -95,6 +96,38 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
> > > >      }
> > > >  }
> > > >  
> > > > +static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status)
> > > > +{
> > > > +    VirtIONet *n = to_virtio_net(vdev);
> > > > +    if (!n->nic->nc.peer) {
> > > > +        return;
> > > > +    }
> > > > +    if (n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP) {
> > > > +        return;
> > > > +    }
> > > > +
> > > > +    if (!tap_get_vhost_net(n->nic->nc.peer)) {
> > > > +        return;
> > > > +    }
> > > > +    if (!!n->vhost_started == (status & VIRTIO_CONFIG_S_DRIVER_OK) &&
> > > > +                                (n->status & VIRTIO_NET_S_LINK_UP) &&
> > > > +                                n->vm_running) {
> > > 
> > > I don't think this works...
> > > 
> > > #define VIRTIO_CONFIG_S_DRIVER_OK       4
> > > 
> > > !!(1) == (status & 4)?
> > 
> > The && converts it to a boolean.
> 
> Are you missing a set of parens around everything right of the ==?  ie:
> 
> if (!!n->vhost_started == ((status & VIRTIO_CONFIG_S_DRIVER_OK) &&
>                            (n->status & VIRTIO_NET_S_LINK_UP) &&
>                            n->vm_running)) {...

Yes, that's it. Thanks!

-- 
MST

      reply	other threads:[~2010-10-03 20:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-27 16:41 [Qemu-devel] [PATCHv2] virtio-net: unify vhost-net start/stop Michael S. Tsirkin
2010-09-27 19:43 ` [Qemu-devel] " Alex Williamson
2010-09-27 21:52   ` Michael S. Tsirkin
2010-09-28 15:16     ` Alex Williamson
2010-10-03 20:17       ` Michael S. Tsirkin [this message]

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=20101003201715.GA28216@redhat.com \
    --to=mst@redhat.com \
    --cc=alex.williamson@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.