From f014e68a0b07fd03685c228e98fb75be42c19b8a Mon Sep 17 00:00:00 2001 From: Heinrich Kuhn Date: Fri, 26 Nov 2021 09:18:42 +0200 Subject: [PATCH] Add ability to return data in a PortControlResponse message This commit adds a string field to the PortControlResponse message that can be used to return data from virtio-forwarder when requested by the port control script. The string field is meant to be generic and future "query" operations can make use of this field to return requested data to the user. Signed-off-by: Heinrich Kuhn Signed-off-by: Simon Horman --- scripts/python2/virtioforwarder_port_control.py | 3 +++ scripts/python3/virtioforwarder_port_control.py | 3 +++ virtioforwarder.proto | 3 +++ 3 files changed, 9 insertions(+) diff --git a/scripts/python2/virtioforwarder_port_control.py b/scripts/python2/virtioforwarder_port_control.py index 5af9016..635a485 100755 --- a/scripts/python2/virtioforwarder_port_control.py +++ b/scripts/python2/virtioforwarder_port_control.py @@ -161,6 +161,9 @@ def main(): if reply.status != reply.OK: print(reply) return 1 + # If the reply contains a generic string response then output it here + if reply.query_string != '': + print(reply.query_string) return 0 diff --git a/scripts/python3/virtioforwarder_port_control.py b/scripts/python3/virtioforwarder_port_control.py index 08f13aa..e938055 100755 --- a/scripts/python3/virtioforwarder_port_control.py +++ b/scripts/python3/virtioforwarder_port_control.py @@ -161,6 +161,9 @@ def main(): if reply.status != reply.OK: print(reply) return 1 + # If the reply contains a generic string response then output it here + if reply.query_string != '': + print(reply.query_string) return 0 diff --git a/virtioforwarder.proto b/virtioforwarder.proto index 48f5b1c..01e5698 100644 --- a/virtioforwarder.proto +++ b/virtioforwarder.proto @@ -86,6 +86,9 @@ message PortControlResponse { // Source of @a error_code. optional string error_code_source = 6; + + // Generic query string to be used when data should be returned + optional string query_string = 7; } // State of an individual relay, including statistics.