Signed-off-by: Yang Hongyang <yan...@cn.fujitsu.com> --- include/net/net.h | 2 ++ net/net.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+)
diff --git a/include/net/net.h b/include/net/net.h index 250f365..10927e1 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -108,6 +108,8 @@ char *qemu_mac_strdup_printf(const uint8_t *macaddr); NetClientState *qemu_find_netdev(const char *id); int qemu_find_net_clients_except(const char *id, NetClientState **ncs, NetClientOptionsKind type, int max); +int qemu_find_net_clients_by_model(const char *model, NetClientState **ncs, + int max); NetClientState *qemu_new_net_client(NetClientInfo *info, NetClientState *peer, const char *model, diff --git a/net/net.c b/net/net.c index 856a0fe..7b62e52 100644 --- a/net/net.c +++ b/net/net.c @@ -780,6 +780,24 @@ int qemu_find_net_clients_except(const char *id, NetClientState **ncs, return ret; } +int qemu_find_net_clients_by_model(const char *model, NetClientState **ncs, + int max) +{ + NetClientState *nc; + int ret = 0; + + QTAILQ_FOREACH(nc, &net_clients, next) { + if (!strcmp(nc->model, model)) { + if (ret < max) { + ncs[ret] = nc; + } + ret++; + } + } + + return ret; +} + static int nic_get_free_idx(void) { int index; -- 1.9.1