From b27c68ffd710299e5c6427d37be400d5a3e05ece Mon Sep 17 00:00:00 2001 From: Dehan Meng Date: Sat, 12 Oct 2024 11:41:31 +0800 Subject: [PATCH] qemu_guest_agent: Add logic to get specific rpm from url The Qemu rebase test requires the latest qemu-guest-agent package, but the guest would not install the latest version of the series of Qemu at the beginning. sometimes will be delayed for a while. Plus I have to run qga test frequently in the future, so it's necessary to add a piece of logic to install the specific package of qga from url. Signed-off-by: Dehan Meng --- qemu/tests/cfg/qemu_guest_agent.cfg | 2 ++ qemu/tests/qemu_guest_agent.py | 49 ++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/qemu/tests/cfg/qemu_guest_agent.cfg b/qemu/tests/cfg/qemu_guest_agent.cfg index e56f0789c7..b58a2e5a3d 100644 --- a/qemu/tests/cfg/qemu_guest_agent.cfg +++ b/qemu/tests/cfg/qemu_guest_agent.cfg @@ -27,6 +27,8 @@ qga_rpm_path = "/qemu-guest-agent" # Please update your file share web server url before test download_root_url = + gagentrpm_tem_path = "/var/tmp/" + gagentrpm_guest_dir = "/var/" Windows: check_vioser = yes gagent_src_type = url diff --git a/qemu/tests/qemu_guest_agent.py b/qemu/tests/qemu_guest_agent.py index e278f17437..62a5bf9aad 100644 --- a/qemu/tests/qemu_guest_agent.py +++ b/qemu/tests/qemu_guest_agent.py @@ -362,11 +362,52 @@ def setup(self, test, params, env): test.fail("Failed to get qga, details: %s" % output) else: self.qga_pkg_path = params["qga_rpm_path"] - if self._check_ga_pkg(session, params.get("gagent_pkg_check_cmd")): - LOG_JOB.info("qemu-ga is already installed.") + if self.params["gagent_src_type"] != "url": + if self._check_ga_pkg(session, params.get("gagent_pkg_check_cmd")): + LOG_JOB.info("qemu-ga is already installed.") + else: + LOG_JOB.info("qemu-ga is not installed or need to update.") + self.gagent_install(session, self.vm) else: - LOG_JOB.info("qemu-ga is not installed or need to update.") - self.gagent_install(session, self.vm) + error_context.context( + "Download qemu-guest-agent package from " + "website and copy it to guest", + logging.info, + ) + gagentrpm_download_url = self.params["gagent_download_url"] + gagentrpm_guest_dir = self.params["gagentrpm_guest_dir"] + gagentrpm_tem_path = self.params["gagentrpm_tem_path"] + rpm_name = re.search(r"([^/]+\.rpm)$", gagentrpm_download_url).group(1) + process.system( + f"wget -qP {gagentrpm_tem_path} {gagentrpm_download_url}" + ) + s, gagentrpm_tem_path = process.getstatusoutput( + f"ls {gagentrpm_tem_path}/{rpm_name}" + ) + if s != 0: + self.test.error( + "qemu-guest-agent rpm is not exist, " + "maybe it is not successfully " + "downloaded, please take a look " + ) + else: + self.vm.copy_files_to(gagentrpm_tem_path, gagentrpm_guest_dir) + s = session.cmd_status( + f"rpm -Uvh --nodeps --force {gagentrpm_guest_dir}/{rpm_name}" + ) + if s != 0: + self.test.error( + "qemu-guest-agent rpm couldn't be installed " + "successfully, please take a look" + ) + else: + restart_cmd = self.params["gagent_restart_cmd"] + s_rst, o_rst = session.cmd_status_output(restart_cmd) + if s_rst != 0: + self.test.fail( + "qemu-guest-agent service restart failed," + " the detailed info:\n%s." % o_rst + ) error_context.context("Check qga service running status", LOG_JOB.info) if self._check_ga_service(session, params.get("gagent_status_cmd")):