]> git.ipfire.org Git - thirdparty/qemu.git/commit
net: Define net_client_set_link()
authorLaurent Vivier <lvivier@redhat.com>
Wed, 9 Jul 2025 08:24:16 +0000 (10:24 +0200)
committerJason Wang <jasowang@redhat.com>
Mon, 14 Jul 2025 05:27:09 +0000 (13:27 +0800)
commit9b5b45c7173b0447ec19aed4b901fd22db83d7eb
tree761b3056ace16ee43c945affa133f0bc0a568e37
parentadf684ce6908e2d2883946ffe1790c4ddfcf3ce0
net: Define net_client_set_link()

The code to set the link status is currently located in
qmp_set_link(). This function identifies the device by name,
searches for the corresponding NetClientState, and then updates
the link status.

In some parts of the code, such as vhost-user.c, the
NetClientState are already available. Calling qmp_set_link()
from these locations leads to a redundant search for the clients.

This patch refactors the logic by introducing a new function,
net_client_set_link(), which accepts a NetClientState array
directly. qmp_set_link() is simplified to be a wrapper that
performs the client search and then calls the new function.
The vhost-user implementation is updated to use net_client_set_link()
directly, thereby eliminating the unnecessary client lookup.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
include/net/net.h
net/net.c
net/vhost-user.c