Skip to content

Commit

Permalink
qemu_guest_agent: Add logic to get specific rpm from url
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
6-dehan committed Dec 6, 2024
1 parent bcd89cd commit b27c68f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
2 changes: 2 additions & 0 deletions qemu/tests/cfg/qemu_guest_agent.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
qga_rpm_path = "/qemu-guest-agent"
# Please update your file share web server url before test
download_root_url = <your_server_url>
gagentrpm_tem_path = "/var/tmp/"
gagentrpm_guest_dir = "/var/"
Windows:
check_vioser = yes
gagent_src_type = url
Expand Down
49 changes: 45 additions & 4 deletions qemu/tests/qemu_guest_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")):
Expand Down

0 comments on commit b27c68f

Please sign in to comment.