From 6871876012cc39d870d032ee501d975300108c70 Mon Sep 17 00:00:00 2001 From: Dehan Meng Date: Tue, 6 Aug 2024 23:03:49 +0800 Subject: [PATCH] qemu_guest_agent: Add new api support 'guest-network-get-route' Add new api 'guest-network-get-route' to support qga query route info of Guest. Signed-off-by: Dehan Meng --- qemu/tests/cfg/qemu_guest_agent.cfg | 3 +++ qemu/tests/qemu_guest_agent.py | 30 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/qemu/tests/cfg/qemu_guest_agent.cfg b/qemu/tests/cfg/qemu_guest_agent.cfg index d7553a109e..e98effc37d 100644 --- a/qemu/tests/cfg/qemu_guest_agent.cfg +++ b/qemu/tests/cfg/qemu_guest_agent.cfg @@ -223,6 +223,9 @@ image_snapshot = no cmd_disable_network = wmic path win32_networkadapter where "NetConnectionID='%s'" call disable cmd_enable_network = wmic path win32_networkadapter where "NetConnectionID='%s'" call enable + - check_get_network_route: + only Linux + gagent_check_type = get_network_route - check_fsfreeze: gagent_fs_test_cmd = "echo foo > %s/foo" delete_temp_file = "rm -rf ${mountpoint_def}/foo" diff --git a/qemu/tests/qemu_guest_agent.py b/qemu/tests/qemu_guest_agent.py index cf7a94b4b4..7d417bdd66 100644 --- a/qemu/tests/qemu_guest_agent.py +++ b/qemu/tests/qemu_guest_agent.py @@ -1698,6 +1698,36 @@ def ip_addr_check(session, mac_addr, ret_list, if_index, if_name): if session_serial: session_serial.close() + @error_context.context_aware + def gagent_check_get_network_route(self, test, params, env): + """ + Execute "guest-network-get-route" command to guest agent + + Steps: + 1) login guest with serial session + 2) get the available interface name via mac address + 3) check the available interface name is the same with guest + 4) check ip address is the same with guest + 5) create a bridge interface for linux guest and check it + from guest agent; + disable interface for windows guest and check it + from guest agent + 6) check "guest-network-get-interfaces" result + 7) recover the interfaces + 8) change ip address + 9) check "guest-network-get-interfaces" result + + :param test: kvm test object + :param params: Dictionary with the test parameters + :param env: Dictionary with test environment. + """ + session = self._get_session(params, self.vm) + self._open_session_list.append(session) + + error_context.context("Check network route info of guest.", LOG_JOB.info) + route_info_qga = self.gagent.get_network_interface() + print("type of route info: {}; route info: {}".format(type(route_info_qga), route_info_qga)) + @error_context.context_aware def gagent_check_reboot_shutdown(self, test, params, env): """