aboutsummaryrefslogtreecommitdiff
path: root/net/vhost-user.c
diff options
context:
space:
mode:
authorAlexey Kirillov <lekiravi@yandex-team.ru>2021-03-03 12:59:06 +0300
committerJason Wang <jasowang@redhat.com>2021-03-15 16:41:22 +0800
commitd32ad10a14d46dfe9304e3ed5858a11dcd5c71a0 (patch)
treee56aaddf5e86dd29209ce958e94c0d91ad950778 /net/vhost-user.c
parent3aa1b7af0f5fbfdf1b4759658e1445bda680b40d (diff)
qapi: net: Add query-netdev command
The query-netdev command is used to get the configuration of the current network device backends (netdevs). This is the QMP analog of the HMP command "info network" but only for netdevs (i.e. excluding NIC and hubports). The query-netdev command returns an array of objects of the NetdevInfo type, which are an extension of Netdev type. It means that response can be used for netdev-add after small modification. This can be useful for recreate the same netdev configuration. Information about the network device is filled in when it is created or modified and is available through the NetClientState->stored_config. Signed-off-by: Alexey Kirillov <lekiravi@yandex-team.ru> Acked-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net/vhost-user.c')
-rw-r--r--net/vhost-user.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/net/vhost-user.c b/net/vhost-user.c
index ffbd94d944..5b7056be25 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -311,14 +311,15 @@ static void net_vhost_user_event(void *opaque, QEMUChrEvent event)
}
static int net_vhost_user_init(NetClientState *peer, const char *device,
- const char *name, Chardev *chr,
- int queues)
+ const char *name, const char *chardev,
+ Chardev *chr, int queues)
{
Error *err = NULL;
NetClientState *nc, *nc0 = NULL;
NetVhostUserState *s = NULL;
VhostUserState *user;
int i;
+ NetdevVhostUserOptions *stored;
assert(name);
assert(queues > 0);
@@ -355,6 +356,16 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,
assert(s->vhost_net);
+ /* Store startup parameters */
+ nc0->stored_config = g_new0(NetdevInfo, 1);
+ nc0->stored_config->type = NET_BACKEND_VHOST_USER;
+ stored = &nc0->stored_config->u.vhost_user;
+
+ stored->chardev = g_strdup(chardev);
+
+ stored->has_queues = true;
+ stored->queues = queues;
+
return 0;
err:
@@ -446,5 +457,6 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,
return -1;
}
- return net_vhost_user_init(peer, "vhost_user", name, chr, queues);
+ return net_vhost_user_init(peer, "vhost_user", name,
+ vhost_user_opts->chardev, chr, queues);
}