]> git.proxmox.com Git - qemu.git/commitdiff
net: introduce qemu_find_net_clients_except()
authorJason Wang <jasowang@redhat.com>
Wed, 30 Jan 2013 11:12:25 +0000 (19:12 +0800)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 1 Feb 2013 17:03:01 +0000 (11:03 -0600)
In multiqueue, all NetClientState that belongs to the same netdev or nic has the
same id. So this patches introduces an helper qemu_find_net_clients_except()
which finds all NetClientState with the same id. This will be used by multiqueue
networking.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
include/net/net.h
net/net.c

index f0d1aa21173b8d4f81a4c8b869a3456e0de92019..995df5c1ef6431ac211d50a75d84cf0d52ad9443 100644 (file)
@@ -68,6 +68,8 @@ typedef struct NICState {
 } NICState;
 
 NetClientState *qemu_find_netdev(const char *id);
+int qemu_find_net_clients_except(const char *id, NetClientState **ncs,
+                                 NetClientOptionsKind type, int max);
 NetClientState *qemu_new_net_client(NetClientInfo *info,
                                     NetClientState *peer,
                                     const char *model,
index 47d56e3a143ddb8adda5f1595b62a5b30129f835..16dd327782f0f1ac195fedd3551cedee2b52f667 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -508,6 +508,27 @@ NetClientState *qemu_find_netdev(const char *id)
     return NULL;
 }
 
+int qemu_find_net_clients_except(const char *id, NetClientState **ncs,
+                                 NetClientOptionsKind type, int max)
+{
+    NetClientState *nc;
+    int ret = 0;
+
+    QTAILQ_FOREACH(nc, &net_clients, next) {
+        if (nc->info->type == type) {
+            continue;
+        }
+        if (!strcmp(nc->name, id)) {
+            if (ret < max) {
+                ncs[ret] = nc;
+            }
+            ret++;
+        }
+    }
+
+    return ret;
+}
+
 static int nic_get_free_idx(void)
 {
     int index;