1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Mon, 6 Apr 2020 12:16:37 +0200
4 Subject: [PATCH] PVE: [Up] qmp: add get_link_status
6 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 net/net.c | 27 +++++++++++++++++++++++++++
9 qapi/net.json | 15 +++++++++++++++
10 qapi/pragma.json | 1 +
11 3 files changed, 43 insertions(+)
13 diff --git a/net/net.c b/net/net.c
14 index 76bbb7c31b..82e0a768b4 100644
17 @@ -1314,6 +1314,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];
28 + queues = qemu_find_net_clients_except(name, ncs,
29 + NET_CLIENT_DRIVER__MAX,
33 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
34 + "Device '%s' not found", name);
35 + return (int64_t) -1;
39 + ret = ncs[0]->link_down;
41 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
42 + ret = ncs[0]->peer->link_down;
45 + return (int64_t) ret ? 0 : 1;
48 void colo_notify_filters_event(int event, Error **errp)
51 diff --git a/qapi/net.json b/qapi/net.json
52 index 7fab2e7cd8..74c9a6109e 100644
57 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
62 +# Get the current link state of the nics or nic.
64 +# @name: name of the nic you get the state of
66 +# Return: If link is up 1
68 +# If an error occure an empty string.
70 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
72 +{ 'command': 'get_link_status', 'data': {'name': 'str'} , 'returns': 'int' }
77 diff --git a/qapi/pragma.json b/qapi/pragma.json
78 index 3bc0335d1f..7c91ea3685 100644
79 --- a/qapi/pragma.json
80 +++ b/qapi/pragma.json
84 'command-returns-exceptions': [
86 'human-monitor-command',