qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>,
	lersek@redhat.com, Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 1/4] net: add public qemu_net_poll() function
Date: Mon,  2 Jul 2012 11:56:50 +0100	[thread overview]
Message-ID: <1341226613-15577-2-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1341226613-15577-1-git-send-email-stefanha@linux.vnet.ibm.com>

The NetClientInfo .poll() callback is being called directly by
hw/vhost_net.c.  Create a public net.c function so callers do not
depend on internals.

This change is useful because later patches change net internals.  Those
changes shouldn't affect .poll() callers.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 hw/vhost_net.c |    6 +++---
 net.c          |    7 +++++++
 net.h          |    2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/hw/vhost_net.c b/hw/vhost_net.c
index c2d90df..ac3e616 100644
--- a/hw/vhost_net.c
+++ b/hw/vhost_net.c
@@ -160,7 +160,7 @@ int vhost_net_start(struct vhost_net *net,
         goto fail_start;
     }
 
-    net->nc->info->poll(net->nc, false);
+    qemu_net_poll(net->nc, false);
     qemu_set_fd_handler(net->backend, NULL, NULL, NULL);
     file.fd = net->backend;
     for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
@@ -177,7 +177,7 @@ fail:
         int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
         assert(r >= 0);
     }
-    net->nc->info->poll(net->nc, true);
+    qemu_net_poll(net->nc, true);
     vhost_dev_stop(&net->dev, dev);
     if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
         tap_set_vnet_hdr_len(net->nc, sizeof(struct virtio_net_hdr));
@@ -197,7 +197,7 @@ void vhost_net_stop(struct vhost_net *net,
         int r = ioctl(net->dev.control, VHOST_NET_SET_BACKEND, &file);
         assert(r >= 0);
     }
-    net->nc->info->poll(net->nc, true);
+    qemu_net_poll(net->nc, true);
     vhost_dev_stop(&net->dev, dev);
     if (net->dev.acked_features & (1 << VIRTIO_NET_F_MRG_RXBUF)) {
         tap_set_vnet_hdr_len(net->nc, sizeof(struct virtio_net_hdr));
diff --git a/net.c b/net.c
index 6bbc9fc..5e4957f 100644
--- a/net.c
+++ b/net.c
@@ -450,6 +450,13 @@ qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, int iovcnt)
     return qemu_sendv_packet_async(nc, iov, iovcnt, NULL);
 }
 
+void qemu_net_poll(NetClientState *nc, bool enable)
+{
+    if (nc->info->poll) {
+        nc->info->poll(nc, enable);
+    }
+}
+
 NetClientState *qemu_find_netdev(const char *id)
 {
     NetClientState *nc;
diff --git a/net.h b/net.h
index 0256ff9..64d5d0e 100644
--- a/net.h
+++ b/net.h
@@ -124,6 +124,8 @@ ssize_t qemu_deliver_packet_iov(NetClientState *sender,
                             int iovcnt,
                             void *opaque);
 
+void qemu_net_poll(NetClientState *nc, bool enable);
+
 void print_net_client(Monitor *mon, NetClientState *vc);
 void do_info_network(Monitor *mon);
 
-- 
1.7.10

  reply	other threads:[~2012-07-02 10:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-02 10:56 [Qemu-devel] [PATCH 0/4] net: convert NetClientState to QOM Stefan Hajnoczi
2012-07-02 10:56 ` Stefan Hajnoczi [this message]
2012-07-02 10:56 ` [Qemu-devel] [PATCH 2/4] net: add net_is_tap_client() Stefan Hajnoczi
2012-07-02 10:56 ` [Qemu-devel] [PATCH 3/4] net: extract notify_link_status_changed() function Stefan Hajnoczi
2012-07-02 10:56 ` [Qemu-devel] [PATCH 4/4] net: convert NetClientState to QOM Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2012-10-18 14:56 [Qemu-devel] [PATCH 0/4] " Stefan Hajnoczi
2012-10-18 14:56 ` [Qemu-devel] [PATCH 1/4] net: add public qemu_net_poll() function Stefan Hajnoczi
2012-11-16 13:40 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
2012-11-16 13:40 ` [Qemu-devel] [PATCH 1/4] net: add public qemu_net_poll() function Stefan Hajnoczi

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=1341226613-15577-2-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=lersek@redhat.com \
    --cc=pbonzini@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).