]>
Commit | Line | Data |
---|---|---|
23102ed6 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
95259824 WB |
2 | From: Wolfgang Bumiller <w.bumiller@proxmox.com> |
3 | Date: Wed, 9 Dec 2015 16:34:41 +0100 | |
53e83913 | 4 | Subject: [PATCH] PVE: [Up] qmp: add get_link_status |
95259824 | 5 | |
b855dce7 | 6 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> |
95259824 | 7 | --- |
53e83913 WB |
8 | net/net.c | 27 +++++++++++++++++++++++++++ |
9 | qapi/net.json | 15 +++++++++++++++ | |
10 | qapi/qapi-schema.json | 1 + | |
11 | 3 files changed, 43 insertions(+) | |
95259824 WB |
12 | |
13 | diff --git a/net/net.c b/net/net.c | |
be901f66 | 14 | index 7d4098254f..c6d5e66bfc 100644 |
95259824 WB |
15 | --- a/net/net.c |
16 | +++ b/net/net.c | |
be901f66 | 17 | @@ -1347,6 +1347,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 | 51 | diff --git a/qapi/net.json b/qapi/net.json |
be901f66 | 52 | index 728990f4fb..d53c66320b 100644 |
6838f038 WB |
53 | --- a/qapi/net.json |
54 | +++ b/qapi/net.json | |
b855dce7 TL |
55 | @@ -34,6 +34,21 @@ |
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 | +## | |
72 | +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'} | |
73 | + | |
b855dce7 | 74 | ## |
6838f038 | 75 | # @netdev_add: |
95259824 | 76 | # |
53e83913 | 77 | diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json |
be901f66 | 78 | index 38af54d6b3..d6a4177935 100644 |
53e83913 WB |
79 | --- a/qapi/qapi-schema.json |
80 | +++ b/qapi/qapi-schema.json | |
81 | @@ -61,6 +61,7 @@ | |
82 | 'query-migrate-cache-size', | |
83 | 'query-tpm-models', | |
84 | 'query-tpm-types', | |
85 | + 'get_link_status', | |
86 | 'ringbuf-read' ], | |
87 | 'name-case-whitelist': [ | |
b855dce7 | 88 | 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status |