提交 de30c2f7 编写于 作者: L Li Jin

balloon_sc_interrogate:send INTERROGATE signal to balloon service

balloon service should be in running status after send INTERROGATE
signal via windows cmd.
Signed-off-by: NLi Jin <lijin@redhat.com>
上级 eb8c05fd
......@@ -355,6 +355,65 @@ class BallooningTestWin(BallooningTest):
else:
self.test.fail("Failed to get windows guest free memory")
def get_disk_vol(self, session):
"""
Get virtio-win disk volume letter for windows guest.
:param session: VM session.
"""
key = "VolumeName like 'virtio-win%'"
try:
return utils_misc.get_win_disk_vol(session,
condition=key)
except Exception:
self.test.error("Could not get virtio-win disk vol!")
@error_context.context_aware
def operate_balloon_service(self, session, operation):
"""
Run/check/stop/install/uninstall balloon service in windows guest
:param session: shell Object
:param operation: operation against balloon serive, e.g. run/status/
uninstall/stop
:return: cmd execution output
"""
error_context.context("%s Balloon Service in guest." % operation,
logging.info)
drive_letter = self.get_disk_vol(session)
try:
operate_cmd = self.params["%s_balloon_service"
% operation] % drive_letter
if operation == "status":
output = session.cmd_output(operate_cmd)
else:
output = session.cmd(operate_cmd)
except Exception as err:
self.test.error("%s balloon service failed! Error msg is:\n%s"
% (operation, err))
return output
@error_context.context_aware
def configure_balloon_service(self, session):
"""
Check balloon service and install it if it's not running.
:param session: shell Object
:param operation: operation against balloon serive, e.g. run/status/
uninstall/stop
"""
error_context.context("Check Balloon Service status before install"
"service", logging.info)
output = self.operate_balloon_service(session, "status")
if re.search("running", output.lower(), re.M):
logging.info("Balloon service is already running !")
elif re.search("stop", output.lower(), re.M):
logging.info("Balloon service is stopped,start it now")
self.operate_balloon_service(session, "run")
else:
logging.info("Install Balloon Service in guest.")
self.operate_balloon_service(session, "install")
class BallooningTestLinux(BallooningTest):
......
import re
import logging
from virttest import utils_test
from virttest import error_context
from qemu.tests.balloon_check import BallooningTestWin
@error_context.context_aware
def run(test, params, env):
"""
Balloon service should be in running status after sc interrogate it.
1) boot a guest with balloon device.
2) check balloon driver installation status.
3) enable and check driver verifier in guest.
4) install and start balloon service in guest.
5) send INTERROGATE signal to balloon service.
6) check balloon service status again.
"""
def interrogate_balloon_service(session):
"""
Sending INTERROGATE to balloon service.
:param session: VM session.
"""
logging.info("Send INTERROGATE to balloon service")
sc_interrogate_cmd = params["sc_interrogate_cmd"]
status, output = session.cmd_status_output(sc_interrogate_cmd)
if status:
test.error(output)
error_context.context("Boot guest with balloon device", logging.info)
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
session = vm.wait_for_login()
driver_name = params.get("driver_name", "balloon")
utils_test.qemu.windrv_verify_running(session, test, driver_name)
utils_test.qemu.setup_win_driver_verifier(driver_name, vm)
balloon_test = BallooningTestWin(test, params, env)
err = None
try:
# Install and start balloon service in guest
balloon_test.configure_balloon_service(session)
# Send INTERROGATE signal to balloon service
interrogate_balloon_service(session)
# Check ballloon serivce status again
output = balloon_test.operate_balloon_service(session, "status")
if not re.search("running", output.lower(), re.M):
test.fail("Balloon service is not running after sc interrogate!"
"Output is: \n %s" % output)
except Exception as err:
pass
finally:
try:
error_context.context("Clear balloon service in guest", logging.info)
balloon_test.operate_balloon_service(session, "uninstall")
except Exception as uninst_err:
if not err:
err = uninst_err
else:
logging.error(uninst_err)
session.close()
if err:
raise err # pylint: disable=E0702
......@@ -39,3 +39,7 @@
# since qmp cmd 'qom-get' output for the balloon device won't
# change for a long time
mem_check = no
- sc_interrogate:
type = balloon_sc_interrogate
only Windows
sc_interrogate_cmd = "sc interrogate balloonservice"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册