]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/pve/0024-qmp-add-get_link_status.patch
ada205344aabf05c57ee6dceb7c6889576655aea
[pve-qemu-kvm.git] / debian / patches / pve / 0024-qmp-add-get_link_status.patch
1 From 15ff34173785bc8cf7ffa7b8146aea46d534e004 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/47] qmp: add get_link_status
5
6 ---
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi-schema.json | 16 ++++++++++++++++
9 2 files changed, 43 insertions(+)
10
11 diff --git a/net/net.c b/net/net.c
12 index 0ac3b9e..7410c1e 100644
13 --- a/net/net.c
14 +++ b/net/net.c
15 @@ -1373,6 +1373,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
16 }
17 }
18
19 +int64_t qmp_get_link_status(const char *name, Error **errp)
20 +{
21 + NetClientState *ncs[MAX_QUEUE_NUM];
22 + NetClientState *nc;
23 + int queues;
24 + bool ret;
25 +
26 + queues = qemu_find_net_clients_except(name, ncs,
27 + NET_CLIENT_DRIVER__MAX,
28 + MAX_QUEUE_NUM);
29 +
30 + if (queues == 0) {
31 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
32 + "Device '%s' not found", name);
33 + return (int64_t) -1;
34 + }
35 +
36 + nc = ncs[0];
37 + ret = ncs[0]->link_down;
38 +
39 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
40 + ret = ncs[0]->peer->link_down;
41 + }
42 +
43 + return (int64_t) ret ? 0 : 1;
44 +}
45 +
46 void qmp_set_link(const char *name, bool up, Error **errp)
47 {
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
53 @@ -56,6 +56,7 @@
54 { 'pragma': {
55 # Commands allowed to return a non-dictionary:
56 'returns-whitelist': [
57 + 'get_link_status',
58 'human-monitor-command',
59 'qom-get',
60 'query-migrate-cache-size',
61 @@ -2627,6 +2628,21 @@
62 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
63
64 ##
65 +# @get_link_status:
66 +#
67 +# Get the current link state of the nics or nic.
68 +#
69 +# @name: name of the nic you get the state of
70 +#
71 +# Return: If link is up 1
72 +# If link is down 0
73 +# If an error occure an empty string.
74 +#
75 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
76 +##
77 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
78 +
79 +##
80 # @balloon:
81 #
82 # Request the balloon driver to change its balloon size.
83 --
84 2.1.4
85