diff --git a/qemu/tests/cfg/qemu_guest_agent.cfg b/qemu/tests/cfg/qemu_guest_agent.cfg index d7553a109e..d18d306364 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 cf7a94b4b4..cdd1b8be11 100644 --- a/qemu/tests/qemu_guest_agent.py +++ b/qemu/tests/qemu_guest_agent.py @@ -343,11 +343,35 @@ 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)$', 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)