]> git.proxmox.com Git - pve-qemu-kvm.git/blame - debian/patches/pve/0024-qmp-add-get_link_status.patch
fix backup jobs
[pve-qemu-kvm.git] / debian / patches / pve / 0024-qmp-add-get_link_status.patch
CommitLineData
e9ee6d7c 1From 15ff34173785bc8cf7ffa7b8146aea46d534e004 Mon Sep 17 00:00:00 2001
ca0fe5f5
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Wed, 9 Dec 2015 16:34:41 +0100
9c3bec39 4Subject: [PATCH 24/47] qmp: add get_link_status
ca0fe5f5
WB
5
6---
7 net/net.c | 27 +++++++++++++++++++++++++++
1a91ab45
WB
8 qapi-schema.json | 16 ++++++++++++++++
9 2 files changed, 43 insertions(+)
ca0fe5f5
WB
10
11diff --git a/net/net.c b/net/net.c
1a91ab45 12index 0ac3b9e..7410c1e 100644
ca0fe5f5
WB
13--- a/net/net.c
14+++ b/net/net.c
1a91ab45 15@@ -1373,6 +1373,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
ca0fe5f5
WB
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,
68a30562 27+ NET_CLIENT_DRIVER__MAX,
ca0fe5f5
WB
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+
68a30562 39+ if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
ca0fe5f5
WB
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];
49diff --git a/qapi-schema.json b/qapi-schema.json
1a91ab45 50index c33ebb3..79bfd97 100644
ca0fe5f5
WB
51--- a/qapi-schema.json
52+++ b/qapi-schema.json
1a91ab45
WB
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 @@
ca0fe5f5
WB
62 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
63
64 ##
1a91ab45 65+# @get_link_status:
ca0fe5f5
WB
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.
ca0fe5f5
WB
83--
842.1.4
85