1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 9 Dec 2015 16:34:41 +0100
4 Subject: [PATCH] PVE: [Up] qmp: add get_link_status
7 net/net.c | 27 +++++++++++++++++++++++++++
8 qapi/net.json | 15 +++++++++++++++
9 qapi/qapi-schema.json | 1 +
10 3 files changed, 43 insertions(+)
12 diff --git a/net/net.c b/net/net.c
13 index f8275843fb..8c8e100afa 100644
16 @@ -1342,6 +1342,33 @@ void hmp_info_network(Monitor *mon, const QDict *qdict)
20 +int64_t qmp_get_link_status(const char *name, Error **errp)
22 + NetClientState *ncs[MAX_QUEUE_NUM];
27 + queues = qemu_find_net_clients_except(name, ncs,
28 + NET_CLIENT_DRIVER__MAX,
32 + error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
33 + "Device '%s' not found", name);
34 + return (int64_t) -1;
38 + ret = ncs[0]->link_down;
40 + if (nc->peer->info->type == NET_CLIENT_DRIVER_NIC) {
41 + ret = ncs[0]->peer->link_down;
44 + return (int64_t) ret ? 0 : 1;
47 void qmp_set_link(const char *name, bool up, Error **errp)
49 NetClientState *ncs[MAX_QUEUE_NUM];
50 diff --git a/qapi/net.json b/qapi/net.json
51 index c86f351161..9a69a3b0f7 100644
55 { 'command': 'set_link', 'data': {'name': 'str', 'up': 'bool'} }
60 +# Get the current link state of the nics or nic.
62 +# @name: name of the nic you get the state of
64 +# Return: If link is up 1
66 +# If an error occure an empty string.
68 +# Notes: this is an Proxmox VE extension and not offical part of Qemu.
70 +{ 'command': 'get_link_status', 'data': {'name': 'str'}, 'returns': 'int'}
75 # Add a network backend.
76 diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
77 index 65b6dc2f6f..4bc906bc7c 100644
78 --- a/qapi/qapi-schema.json
79 +++ b/qapi/qapi-schema.json
81 'query-migrate-cache-size',
86 'name-case-whitelist': [
87 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status