1 From 759fdd7b7ea2f90a463d4bc766f9c53053498c58 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 16:34:41 +0100
4 Subject: [PATCH 24/48] qmp: add get_link_status
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi-schema.json | 16 ++++++++++++++++
9 2 files changed, 43 insertions(+)
11 diff --git a/net/net.c b/net/net.c
12 index 0ac3b9e..7410c1e 100644
15 @@ -1373,6 +1373,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
19 +int64_t qmp_get_link_status(const char *name, Error **errp)
21 + NetClientState *ncs[MAX_QUEUE_NUM];
26 + queues = qemu_find_net_clients_except(name, ncs,
27 + NET_CLIENT_DRIVER__MAX,
31 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
32 + "Device '%s' not found", name);
33 + return (int64_t) -1;
37 + ret = ncs[0]->link_down;
39 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
40 + ret = ncs[0]->peer->link_down;
43 + return (int64_t) ret ? 0 : 1;
46 void qmp_set_link(const char *name, bool up, Error **errp)
48 NetClientState *ncs[MAX_QUEUE_NUM];
49 diff --git a/qapi-schema.json b/qapi-schema.json
50 index c33ebb3..79bfd97 100644
51 --- a/qapi-schema.json
52 +++ b/qapi-schema.json
55 # Commands allowed to return a non-dictionary:
56 'returns-whitelist': [
58 'human-monitor-command',
60 'query-migrate-cache-size',
61 @@ -2627,6 +2628,21 @@
62 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
67 +# Get the current link state of the nics or nic.
69 +# @name: name of the nic you get the state of
71 +# Return: If link is up 1
73 +# If an error occure an empty string.
75 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
77 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
82 # Request the balloon driver to change its balloon size.