]> git.proxmox.com Git - pve-qemu-kvm.git/blob - debian/patches/add-qmp-get-link-status.patch
remove tcmalloc default memory allocator
[pve-qemu-kvm.git] / debian / patches / add-qmp-get-link-status.patch
1 Index: new/qapi-schema.json
2 ===================================================================
3 --- new.orig/qapi-schema.json 2014-12-10 09:15:50.890262765 +0100
4 +++ new/qapi-schema.json 2014-12-11 09:20:31.072561486 +0100
5 @@ -1366,6 +1366,22 @@
6 ##
7 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
8
9 +
10 +##
11 +# @get_link_status
12 +#
13 +# Get the current link state of the nics or nic.
14 +#
15 +# @name: name of the nic you get the state of
16 +#
17 +# Return: If link is up 1
18 +# If link is down 0
19 +# If an error occure an empty string.
20 +#
21 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
22 +##
23 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
24 +
25 ##
26 # @balloon:
27 #
28 Index: new/net/net.c
29 ===================================================================
30 --- new.orig/net/net.c 2014-12-10 10:24:39.790496356 +0100
31 +++ new/net/net.c 2014-12-11 09:37:55.971321170 +0100
32 @@ -1141,6 +1141,32 @@
33 }
34 }
35
36 +int64_t qmp_get_link_status(const char *name, Error **errp)
37 +{
38 + NetClientState *ncs[MAX_QUEUE_NUM];
39 + NetClientState *nc;
40 + int queues;
41 + bool ret;
42 +
43 + queues = qemu_find_net_clients_except(name, ncs,
44 + NET_CLIENT_OPTIONS_KIND_MAX,
45 + MAX_QUEUE_NUM);
46 +
47 + if (queues == 0) {
48 + error_set(errp, QERR_DEVICE_NOT_FOUND, name);
49 + return (int64_t) -1;
50 + }
51 +
52 + nc = ncs[0];
53 + ret = ncs[0]->link_down;
54 +
55 + if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
56 + ret = ncs[0]->peer->link_down;
57 + }
58 +
59 + return (int64_t) ret ? 0 : 1;
60 +}
61 +
62 void qmp_set_link(const char *name, bool up, Error **errp)
63 {
64 NetClientState *ncs[MAX_QUEUE_NUM];
65 Index: new/qmp-commands.hx
66 ===================================================================
67 --- new.orig/qmp-commands.hx 2014-12-10 09:15:50.891262737 +0100
68 +++ new/qmp-commands.hx 2014-12-11 08:36:26.583532314 +0100
69 @@ -1473,6 +1473,29 @@
70 EQMP
71
72 {
73 + .name = "get_link_status",
74 + .args_type = "name:s",
75 + .mhandler.cmd_new = qmp_marshal_input_get_link_status,
76 + },
77 +
78 +SQMP
79 +get_link_status
80 +--------
81 +
82 +Get the link status of a network adapter.
83 +
84 +Arguments:
85 +
86 +- "name": network device name (json-string)
87 +
88 +Example:
89 +
90 +-> { "execute": "set_link", "arguments": { "name": "e1000.0" } }
91 +<- { "return": {1} }
92 +
93 +EQMP
94 +
95 + {
96 .name = "getfd",
97 .args_type = "fdname:s",
98 .params = "getfd name",