]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0007-PVE-Up-qmp-add-get_link_status.patch
update submodule and patches to 7.1.0
[pve-qemu.git] / debian / patches / pve / 0007-PVE-Up-qmp-add-get_link_status.patch
CommitLineData
23102ed6 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
95259824 2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
83faa3fe
TL
3Date: Mon, 6 Apr 2020 12:16:37 +0200
4Subject: [PATCH] PVE: [Up] qmp: add get_link_status
95259824 5
b855dce7 6Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
95259824 7---
83faa3fe
TL
8 net/net.c | 27 +++++++++++++++++++++++++++
9 qapi/net.json | 15 +++++++++++++++
10 qapi/pragma.json | 1 +
53e83913 11 3 files changed, 43 insertions(+)
95259824
WB
12
13diff --git a/net/net.c b/net/net.c
5b15e2ec 14index 2db160e063..8329347891 100644
95259824
WB
15--- a/net/net.c
16+++ b/net/net.c
5b15e2ec 17@@ -1343,6 +1343,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
95259824
WB
18 }
19 }
20
21+int64_t qmp_get_link_status(const char *name, Error **errp)
22+{
23+ NetClientState *ncs[MAX_QUEUE_NUM];
24+ NetClientState *nc;
25+ int queues;
26+ bool ret;
27+
28+ queues = qemu_find_net_clients_except(name, ncs,
29+ NET_CLIENT_DRIVER__MAX,
30+ MAX_QUEUE_NUM);
31+
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+ }
37+
38+ nc = ncs[0];
39+ ret = ncs[0]->link_down;
40+
41+ if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
42+ ret = ncs[0]->peer->link_down;
43+ }
44+
45+ return (int64_t) ret ? 0 : 1;
46+}
47+
b855dce7 48 void colo_notify_filters_event(int event, Error **errp)
95259824 49 {
b855dce7 50 NetClientState *nc;
6838f038 51diff --git a/qapi/net.json b/qapi/net.json
5b15e2ec 52index 75ba2cb989..a3c93ab88f 100644
6838f038
WB
53--- a/qapi/net.json
54+++ b/qapi/net.json
60ae3775 55@@ -35,6 +35,21 @@
b855dce7 56 ##
95259824
WB
57 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
58
b855dce7 59+##
a544966d 60+# @get_link_status:
95259824
WB
61+#
62+# Get the current link state of the nics or nic.
63+#
64+# @name: name of the nic you get the state of
65+#
66+# Return: If link is up 1
67+# If link is down 0
68+# If an error occure an empty string.
69+#
70+# Notes: this is an Proxmox VE extension and not offical part of Qemu.
71+##
83faa3fe 72+{ 'command': 'get_link_status', 'data': {'name': 'str'} , 'returns': 'int' }
95259824 73+
b855dce7 74 ##
6838f038 75 # @netdev_add:
95259824 76 #
83faa3fe 77diff --git a/qapi/pragma.json b/qapi/pragma.json
5b15e2ec 78index 7f810b0e97..a2358e303a 100644
83faa3fe
TL
79--- a/qapi/pragma.json
80+++ b/qapi/pragma.json
5b15e2ec 81@@ -26,6 +26,7 @@
8dca018b 82 'system_wakeup' ],
5b15e2ec 83 # Commands allowed to return a non-dictionary
8dca018b
SR
84 'command-returns-exceptions': [
85+ 'get_link_status',
83faa3fe
TL
86 'human-monitor-command',
87 'qom-get',
8dca018b 88 'query-tpm-models',