clean: remove buildinfo/changes
[pve-qemu-kvm.git] / debian / patches / old / add-qmp-get-link-status.patch
blob83df2138ff2388d2843c04064a57d2e4a6c27892
1 Index: new/scripts/qapi.py
2 ===================================================================
3 --- new.orig/scripts/qapi.py 2015-07-13 10:00:00.000000000 +0100
4 +++ new/scripts/qapi.py 2015-07-13 15:50:00.000000000 +0100
5 @@ -37,6 +37,8 @@
7 # Whitelist of commands allowed to return a non-dictionary
8 returns_whitelist = [
9 + 'get_link_status',
11 # From QMP:
12 'human-monitor-command',
13 'query-migrate-cache-size',
14 Index: new/qapi-schema.json
15 ===================================================================
16 --- new.orig/qapi-schema.json 2014-12-10 09:15:50.890262765 +0100
17 +++ new/qapi-schema.json 2014-12-11 09:20:31.072561486 +0100
18 @@ -1366,6 +1366,21 @@
20 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
22 +##
23 +# @get_link_status
25 +# Get the current link state of the nics or nic.
27 +# @name: name of the nic you get the state of
29 +# Return: If link is up 1
30 +# If link is down 0
31 +# If an error occure an empty string.
33 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
34 +##
35 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
38 # @balloon:
40 Index: new/net/net.c
41 ===================================================================
42 --- new.orig/net/net.c 2014-12-10 10:24:39.790496356 +0100
43 +++ new/net/net.c 2014-12-11 09:37:55.971321170 +0100
44 @@ -1141,6 +1141,33 @@
48 +int64_t qmp_get_link_status(const char *name, Error **errp)
50 + NetClientState *ncs[MAX_QUEUE_NUM];
51 + NetClientState *nc;
52 + int queues;
53 + bool ret;
55 + queues = qemu_find_net_clients_except(name, ncs,
56 + NET_CLIENT_OPTIONS_KIND_MAX,
57 + MAX_QUEUE_NUM);
59 + if (queues == 0) {
60 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
61 + "Device '%s' not found", name);
62 + return (int64_t) -1;
63 + }
65 + nc = ncs[0];
66 + ret = ncs[0]->link_down;
68 + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
69 + ret = ncs[0]->peer->link_down;
70 + }
72 + return (int64_t) ret ? 0 : 1;
75 void qmp_set_link(const char *name, bool up, Error **errp)
77 NetClientState *ncs[MAX_QUEUE_NUM];
78 Index: new/qmp-commands.hx
79 ===================================================================
80 --- new.orig/qmp-commands.hx 2014-12-10 09:15:50.891262737 +0100
81 +++ new/qmp-commands.hx 2014-12-11 08:36:26.583532314 +0100
82 @@ -1473,6 +1473,29 @@
83 EQMP
86 + .name = "get_link_status",
87 + .args_type = "name:s",
88 + .mhandler.cmd_new = qmp_marshal_input_get_link_status,
89 + },
91 +SQMP
92 +get_link_status
93 +--------
95 +Get the link status of a network adapter.
97 +Arguments:
99 +- "name": network device name (json-string)
101 +Example:
103 +-> { "execute": "get_link_status", "arguments": { "name": "e1000.0" } }
104 +<- { "return": {1} }
106 +EQMP
109 .name = "getfd",
110 .args_type = "fdname:s",
111 .params = "getfd name",