diff mbox

[v2,4/6] net: force NetQue opaque to be NetClientState

Message ID 1371114186-8854-5-git-send-email-qemulist@gmail.com
State New
Headers show

Commit Message

pingfan liu June 13, 2013, 9:03 a.m. UTC
From: Liu Ping Fan <pingfanl@linux.vnet.ibm.com>

qemu_net_client_setup() is the only user of qemu_new_net_queue(), which
will pass in NetClientState. By forcing it be a NetClientState, we
can ref/unref NetQueue's owner

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 include/net/queue.h | 2 +-
 net/queue.c         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Stefan Hajnoczi June 18, 2013, 12:47 p.m. UTC | #1
On Thu, Jun 13, 2013 at 05:03:04PM +0800, Liu Ping Fan wrote:
> From: Liu Ping Fan <pingfanl@linux.vnet.ibm.com>
> 
> qemu_net_client_setup() is the only user of qemu_new_net_queue(), which
> will pass in NetClientState. By forcing it be a NetClientState, we
> can ref/unref NetQueue's owner

Please s/opaque/nc/ in net/queue.[hc] since it's no longer "opaque" :).

Also, qemu_deliver_packet()/qemu_deliver_packet_iov() can take an
NetClientState *nc instead of void *opaque.

> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>

pingfank here and pingfanl in the From: header.  Are both okay and which
do you prefer to use?
pingfan liu June 20, 2013, 6:30 a.m. UTC | #2
On Tue, Jun 18, 2013 at 8:47 PM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> On Thu, Jun 13, 2013 at 05:03:04PM +0800, Liu Ping Fan wrote:
>> From: Liu Ping Fan <pingfanl@linux.vnet.ibm.com>
>>
>> qemu_net_client_setup() is the only user of qemu_new_net_queue(), which
>> will pass in NetClientState. By forcing it be a NetClientState, we
>> can ref/unref NetQueue's owner
>
> Please s/opaque/nc/ in net/queue.[hc] since it's no longer "opaque" :).
>
Ok, I will.
> Also, qemu_deliver_packet()/qemu_deliver_packet_iov() can take an
> NetClientState *nc instead of void *opaque.
>
>> Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
>
> pingfank here and pingfanl in the From: header.  Are both okay and which
> do you prefer to use?

Change my disk, totally re-install my system, and mix up with internal
mail address. Will fix it.

Thx & regards,
Pingfan
diff mbox

Patch

diff --git a/include/net/queue.h b/include/net/queue.h
index fc02b33..ddb6d98 100644
--- a/include/net/queue.h
+++ b/include/net/queue.h
@@ -34,7 +34,7 @@  typedef void (NetPacketSent) (NetClientState *sender, ssize_t ret);
 #define QEMU_NET_PACKET_FLAG_NONE  0
 #define QEMU_NET_PACKET_FLAG_RAW  (1<<0)
 
-NetQueue *qemu_new_net_queue(void *opaque);
+NetQueue *qemu_new_net_queue(NetClientState *opaque);
 
 void qemu_del_net_queue(NetQueue *queue);
 
diff --git a/net/queue.c b/net/queue.c
index 7d6c52e..58222b0 100644
--- a/net/queue.c
+++ b/net/queue.c
@@ -49,7 +49,7 @@  struct NetPacket {
 };
 
 struct NetQueue {
-    void *opaque;
+    NetClientState *opaque;
     uint32_t nq_maxlen;
     uint32_t nq_count;
 
@@ -59,7 +59,7 @@  struct NetQueue {
     unsigned delivering : 1;
 };
 
-NetQueue *qemu_new_net_queue(void *opaque)
+NetQueue *qemu_new_net_queue(NetClientState *opaque)
 {
     NetQueue *queue;