update to 2.7
[pve-qemu-kvm.git] / debian / patches / pve / 0024-qmp-add-get_link_status.patch
blobfa88704a15923e8cfc0eba618fce8ccf8ca4f3f0
1 From 7e58a86c836514745590e4f4d280841c4808a022 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/41] qmp: add get_link_status
6 ---
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi-schema.json | 15 +++++++++++++++
9 qmp-commands.hx | 23 +++++++++++++++++++++++
10 scripts/qapi.py | 2 ++
11 4 files changed, 67 insertions(+)
13 diff --git a/net/net.c b/net/net.c
14 index d51cb29..c94d93d 100644
15 --- a/net/net.c
16 +++ b/net/net.c
17 @@ -1362,6 +1362,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
21 +int64_t qmp_get_link_status(const char *name, Error **errp)
23 + NetClientState *ncs[MAX_QUEUE_NUM];
24 + NetClientState *nc;
25 + int queues;
26 + bool ret;
28 + queues = qemu_find_net_clients_except(name, ncs,
29 + NET_CLIENT_DRIVER__MAX,
30 + MAX_QUEUE_NUM);
32 + if (queues == 0) {
33 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
34 + "Device '%s' not found", name);
35 + return (int64_t) -1;
36 + }
38 + nc = ncs[0];
39 + ret = ncs[0]->link_down;
41 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
42 + ret = ncs[0]->peer->link_down;
43 + }
45 + return (int64_t) ret ? 0 : 1;
48 void qmp_set_link(const char *name, bool up, Error **errp)
50 NetClientState *ncs[MAX_QUEUE_NUM];
51 diff --git a/qapi-schema.json b/qapi-schema.json
52 index 0c0faf7..d75e932 100644
53 --- a/qapi-schema.json
54 +++ b/qapi-schema.json
55 @@ -1786,6 +1786,21 @@
56 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
59 +# @get_link_status
61 +# Get the current link state of the nics or nic.
63 +# @name: name of the nic you get the state of
65 +# Return: If link is up 1
66 +# If link is down 0
67 +# If an error occure an empty string.
69 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
70 +##
71 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
73 +##
74 # @balloon:
76 # Request the balloon driver to change its balloon size.
77 diff --git a/qmp-commands.hx b/qmp-commands.hx
78 index 6342cd2..a84932a 100644
79 --- a/qmp-commands.hx
80 +++ b/qmp-commands.hx
81 @@ -1883,6 +1883,29 @@ Example:
82 EQMP
85 + .name = "get_link_status",
86 + .args_type = "name:s",
87 + .mhandler.cmd_new = qmp_marshal_get_link_status,
88 + },
90 +SQMP
91 +get_link_status
92 +--------
94 +Get the link status of a network adapter.
96 +Arguments:
98 +- "name": network device name (json-string)
100 +Example:
102 +-> { "execute": "get_link_status", "arguments": { "name": "e1000.0" } }
103 +<- { "return": {1} }
105 +EQMP
108 .name = "getfd",
109 .args_type = "fdname:s",
110 .params = "getfd name",
111 diff --git a/scripts/qapi.py b/scripts/qapi.py
112 index 21bc32f..f900659 100644
113 --- a/scripts/qapi.py
114 +++ b/scripts/qapi.py
115 @@ -39,6 +39,8 @@ builtin_types = {
117 # Whitelist of commands allowed to return a non-dictionary
118 returns_whitelist = [
119 + 'get_link_status',
121 # From QMP:
122 'human-monitor-command',
123 'qom-get',
125 2.1.4