[libvirt] [test-API][PATCH v2 1/4] Add init module under libvirtd

* repos/libvirtd/__init__.py --- 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/__init__.py diff --git a/repos/libvirtd/__init__.py b/repos/libvirtd/__init__.py new file mode 100644 index 0000000..e69de29 -- 1.7.1

* repos/libvirtd/restart.py libvirtd restart should not affect the running domains. This test check the libvirtd status before and after libvirtd restart, and also by checking the domain pid to confirm the domain is not affected. --- repos/libvirtd/restart.py | 180 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 180 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/restart.py diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py new file mode 100644 index 0000000..7ccbb38 --- /dev/null +++ b/repos/libvirtd/restart.py @@ -0,0 +1,180 @@ +#!/usr/bin/evn python +""" Restart libvirtd testing. A running guest is required in this test. + During libvirtd restart, the guest remains running and not affected + by libvirtd restart. + libvirtd:restart + guestname + #GUESTNAME# +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Aug 4, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['restart'] + +import os +import re +import sys + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from lib import connectAPI +from lib import domainAPI +from utils.Python import utils + +VIRSH_LIST = "virsh list --all" +RESTART_CMD = "service libvirtd restart" + +def check_params(params): + """Verify inputing parameter dictionary""" + logger = params['logger'] + keys = ['guestname'] + for key in keys: + if key not in params: + logger.error("%s is required" %key) + return 1 + return 0 + +def check_domain_running(domobj, guestname, logger): + """ check if the domain exists, may or may not be active """ + guest_names = domobj.get_list() + + if guestname not in guest_names: + logger.error("%s doesn't exist or not running" % guestname) + return 1 + else: + return 0 + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def get_domain_pid(util, logger, guestname): + """get the pid of running domain""" + logger.info("get the pid of running domain %s" % guestname) + get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname + ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + if ret: + logger.error("fail to get the pid of runnings domain %s" % \ + guestname) + return 1, "" + else: + logger.info("the pid of domain %s is %s" % \ + (guestname, pid[0])) + return 0, pid[0] + +def restart(params): + """restart libvirtd test""" + # Initiate and check parameters + params_check_result = check_params(params) + if params_check_result: + return 1 + + logger = params['logger'] + guestname = params['guestname'] + util = utils.Utils() + uri = util.get_uri('127.0.0.1') + + conn = connectAPI.ConnectAPI() + virconn = conn.open(uri) + domobj = domainAPI.DomainAPI(virconn) + + logger.info("check the domain state") + ret = check_domain_running(domobj, guestname, logger) + if ret: + return 1 + + conn.close() + + logger.info("check the libvirtd status:") + ret = libvirtd_check(util, logger) + if ret: + return 1 + + # Get domain ip + logger.info("get the mac address of domain %s" % guestname) + mac = util.get_dom_mac_addr(guestname) + logger.info("the mac address of domain %s is %s" % (guestname, mac)) + logger.info("get ip by mac address") + ip = util.mac_to_ip(mac, 180) + logger.info("the ip address of domain %s is %s" % (guestname, ip)) + timeout = 600 + + logger.info("ping to domain %s" % guestname) + if util.do_ping(ip, 0): + logger.info("Success ping domain %s" % guestname) + else: + logger.error("fail to ping domain %s" % guestname) + return 1 + + ret, pid_before = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + logger.info("restart libvirtd service:") + ret, out = util.exec_cmd(RESTART_CMD, shell=True) + if ret != 0: + logger.error("failed to restart libvirtd") + for i in range(len(out)): + logger.error(out[i]) + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + logger.info("recheck libvirtd status:") + ret = libvirtd_check(util, logger) + if ret: + return 1 + + logger.info("ping to domain %s again" % guestname) + if util.do_ping(ip, 0): + logger.info("Success ping domain %s" % guestname) + else: + logger.error("fail to ping domain %s" % guestname) + return 1 + + ret, pid_after = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + if pid_before != pid_after: + logger.error("%s pid changed during libvirtd restart" % \ + guestname) + return 1 + else: + logger.info("domain pid not change, %s keeps running during \ + libvirtd restart" % guestname) + + return 0 + +def restart_clean(params): + """ clean testing environment """ + pass + -- 1.7.1

On 09/14/2011 06:31 PM, Wayne Sun wrote:
* repos/libvirtd/restart.py
libvirtd restart should not affect the running domains. This test check the libvirtd status before and after libvirtd restart, and also by checking the domain pid to confirm the domain is not affected. --- repos/libvirtd/restart.py | 180 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 180 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/restart.py
diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py new file mode 100644 index 0000000..7ccbb38 --- /dev/null +++ b/repos/libvirtd/restart.py @@ -0,0 +1,180 @@ +#!/usr/bin/evn python +""" Restart libvirtd testing. A running guest is required in this test. + During libvirtd restart, the guest remains running and not affected + by libvirtd restart. + libvirtd:restart + guestname + #GUESTNAME# +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Aug 4, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['restart'] + +import os +import re +import sys + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from lib import connectAPI +from lib import domainAPI +from utils.Python import utils + +VIRSH_LIST = "virsh list --all" +RESTART_CMD = "service libvirtd restart" + +def check_params(params): + """Verify inputing parameter dictionary""" + logger = params['logger'] + keys = ['guestname'] + for key in keys: + if key not in params: + logger.error("%s is required" %key) + return 1 + return 0 + +def check_domain_running(domobj, guestname, logger): + """ check if the domain exists, may or may not be active """ + guest_names = domobj.get_list() + + if guestname not in guest_names: + logger.error("%s doesn't exist or not running" % guestname) + return 1 + else: + return 0 + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def get_domain_pid(util, logger, guestname): + """get the pid of running domain""" + logger.info("get the pid of running domain %s" % guestname) + get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname + ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + if ret: + logger.error("fail to get the pid of runnings domain %s" % \ + guestname) + return 1, "" + else: + logger.info("the pid of domain %s is %s" % \ + (guestname, pid[0])) + return 0, pid[0] + +def restart(params): + """restart libvirtd test""" + # Initiate and check parameters + params_check_result = check_params(params) + if params_check_result: + return 1 + + logger = params['logger'] + guestname = params['guestname'] + util = utils.Utils() + uri = util.get_uri('127.0.0.1') + + conn = connectAPI.ConnectAPI() + virconn = conn.open(uri) + domobj = domainAPI.DomainAPI(virconn) + + logger.info("check the domain state") + ret = check_domain_running(domobj, guestname, logger) + if ret: + return 1 + + conn.close() + + logger.info("check the libvirtd status:") + ret = libvirtd_check(util, logger) + if ret: + return 1 + + # Get domain ip + logger.info("get the mac address of domain %s" % guestname) + mac = util.get_dom_mac_addr(guestname) + logger.info("the mac address of domain %s is %s" % (guestname, mac)) + logger.info("get ip by mac address") + ip = util.mac_to_ip(mac, 180) + logger.info("the ip address of domain %s is %s" % (guestname, ip)) + timeout = 600 Assigning 600 to timeout variable, but unused variable 'timeout'. + + logger.info("ping to domain %s" % guestname) + if util.do_ping(ip, 0): + logger.info("Success ping domain %s" % guestname) + else: + logger.error("fail to ping domain %s" % guestname) + return 1 + + ret, pid_before = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + logger.info("restart libvirtd service:") + ret, out = util.exec_cmd(RESTART_CMD, shell=True) + if ret != 0: + logger.error("failed to restart libvirtd") + for i in range(len(out)): + logger.error(out[i]) + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + logger.info("recheck libvirtd status:") + ret = libvirtd_check(util, logger) + if ret: + return 1 + + logger.info("ping to domain %s again" % guestname) + if util.do_ping(ip, 0): + logger.info("Success ping domain %s" % guestname) + else: + logger.error("fail to ping domain %s" % guestname) + return 1 + + ret, pid_after = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + if pid_before != pid_after: + logger.error("%s pid changed during libvirtd restart" % \ + guestname) + return 1 + else: + logger.info("domain pid not change, %s keeps running during \ + libvirtd restart" % guestname) + + return 0 + +def restart_clean(params): + """ clean testing environment """ + pass +

On 09/15/2011 10:59 AM, Alex Jia wrote:
On 09/14/2011 06:31 PM, Wayne Sun wrote:
* repos/libvirtd/restart.py
libvirtd restart should not affect the running domains. This test check the libvirtd status before and after libvirtd restart, and also by checking the domain pid to confirm the domain is not affected. --- repos/libvirtd/restart.py | 180 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 180 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/restart.py
diff --git a/repos/libvirtd/restart.py b/repos/libvirtd/restart.py new file mode 100644 index 0000000..7ccbb38 --- /dev/null +++ b/repos/libvirtd/restart.py @@ -0,0 +1,180 @@ +#!/usr/bin/evn python +""" Restart libvirtd testing. A running guest is required in this test. + During libvirtd restart, the guest remains running and not affected + by libvirtd restart. + libvirtd:restart + guestname + #GUESTNAME# +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Aug 4, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['restart'] + +import os +import re +import sys + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from lib import connectAPI +from lib import domainAPI +from utils.Python import utils + +VIRSH_LIST = "virsh list --all" +RESTART_CMD = "service libvirtd restart" + +def check_params(params): + """Verify inputing parameter dictionary""" + logger = params['logger'] + keys = ['guestname'] + for key in keys: + if key not in params: + logger.error("%s is required" %key) + return 1 + return 0 + +def check_domain_running(domobj, guestname, logger): + """ check if the domain exists, may or may not be active """ + guest_names = domobj.get_list() + + if guestname not in guest_names: + logger.error("%s doesn't exist or not running" % guestname) + return 1 + else: + return 0 + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def get_domain_pid(util, logger, guestname): + """get the pid of running domain""" + logger.info("get the pid of running domain %s" % guestname) + get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname + ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + if ret: + logger.error("fail to get the pid of runnings domain %s" % \ + guestname) + return 1, "" + else: + logger.info("the pid of domain %s is %s" % \ + (guestname, pid[0])) + return 0, pid[0] + +def restart(params): + """restart libvirtd test""" + # Initiate and check parameters + params_check_result = check_params(params) + if params_check_result: + return 1 + + logger = params['logger'] + guestname = params['guestname'] + util = utils.Utils() + uri = util.get_uri('127.0.0.1') + + conn = connectAPI.ConnectAPI() + virconn = conn.open(uri) + domobj = domainAPI.DomainAPI(virconn) + + logger.info("check the domain state") + ret = check_domain_running(domobj, guestname, logger) + if ret: + return 1 + + conn.close() + + logger.info("check the libvirtd status:") + ret = libvirtd_check(util, logger) + if ret: + return 1 + + # Get domain ip + logger.info("get the mac address of domain %s" % guestname) + mac = util.get_dom_mac_addr(guestname) + logger.info("the mac address of domain %s is %s" % (guestname, mac)) + logger.info("get ip by mac address") + ip = util.mac_to_ip(mac, 180) + logger.info("the ip address of domain %s is %s" % (guestname, ip)) + timeout = 600 Assigning 600 to timeout variable, but unused variable 'timeout'. + + logger.info("ping to domain %s" % guestname) + if util.do_ping(ip, 0): + logger.info("Success ping domain %s" % guestname) + else: + logger.error("fail to ping domain %s" % guestname) + return 1 + + ret, pid_before = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + logger.info("restart libvirtd service:") + ret, out = util.exec_cmd(RESTART_CMD, shell=True) + if ret != 0: + logger.error("failed to restart libvirtd") + for i in range(len(out)): + logger.error(out[i]) + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + logger.info("recheck libvirtd status:") + ret = libvirtd_check(util, logger) + if ret: + return 1 + + logger.info("ping to domain %s again" % guestname) + if util.do_ping(ip, 0): + logger.info("Success ping domain %s" % guestname) + else: + logger.error("fail to ping domain %s" % guestname) + return 1 + + ret, pid_after = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + if pid_before != pid_after: + logger.error("%s pid changed during libvirtd restart" % \ + guestname) + return 1 + else: + logger.info("domain pid not change, %s keeps running during \ + libvirtd restart" % guestname) + + return 0 + +def restart_clean(params): + """ clean testing environment """ + pass +
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
ACK and pushed with this fixed. Guannan Ren

* repos/libvirtd/upstart.py After set libvirtd upstart, libvirtd could restarted after force kill libvirtd process --- repos/libvirtd/upstart.py | 213 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 213 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/upstart.py diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py new file mode 100644 index 0000000..904baa9 --- /dev/null +++ b/repos/libvirtd/upstart.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +"""Upstart libvirtd testing +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Aug 4, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['upstart'] + +import os +import re +import sys +import time + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from utils.Python import utils +from shutil import copy + +VIRSH_LIST = "virsh list --all" +UPSTART_CONF = "rpm -ql libvirt|grep upstart" +INITCTL_CMD = "/sbin/initctl" +SYSTEMCTL_CMD = "/bin/systemctl" +INITCTL_RELOAD_CMD = "initctl reload-configuration" +SYSTEMCTL_RELOAD_CMD = "systemctl daemon-reload" +INIT_CONF = "/etc/init/libvirtd.conf" + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def upstart(params): + """Set libvirtd upstart""" + logger = params['logger'] + util = utils.Utils() + + logger.info("chkconfig libvirtd off:") + cmd = "chkconfig libvirtd off" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed") + return 1 + else: + logger.info("succeed") + + cmd = "service libvirtd stop" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to stop libvirtd service") + return 1 + else: + logger.info(out[0]) + + logger.info("find libvirtd.upstart file in libvirt package:") + ret, conf = util.exec_cmd(UPSTART_CONF, shell=True) + if ret != 0: + logger.error("can't find libvirtd.upstart as part of libvirt package") + return 1 + elif conf[0]: + logger.info("succeed") + logger.info("copy %s to %s" % (conf[0], INIT_CONF)) + copy(conf[0], INIT_CONF) + + if os.path.exists(INITCTL_CMD): + logger.info(INITCTL_RELOAD_CMD) + ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + if ret != 0: + logger.error("failed to reload configuration") + return 1 + else: + logger.info("succeed") + + cmd = "initctl start libvirtd" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to start libvirtd by initctl") + return 1 + else: + logger.info(out[0]) + + cmd = "initctl status libvirtd" + logger.info("get libvirtd status by initctl:") + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: + logger.info("failed to get libvirtd status by initctl") + return 1 + else: + logger.info(out[0]) + + elif os.path.exists(SYSTEMCTL_CMD): + logger.info(SYSTEMCTL_RELOAD_CMD) + ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + if ret != 0: + logger.error("failed to reload systemd manager configuration") + return 1 + else: + logger.info("succeed") + + cmd = "systemctl start libvirtd.service" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to start libvirtd.service by systemctl") + return 1 + else: + logger.info(out[0]) + + cmd = "systemctl status libvirtd.service" + logger.info("get libvirtd.service status by systemctl:") + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: + logger.info("failed to get libvirtd.service status by systemctl") + return 1 + else: + logger.info(out[0]) + else: + return 1 + + time.sleep(5) + + logger.info("check the libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + + cmd = "killall -9 libvirtd" + logger.info("kill libvirtd process") + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to kill libvirtd process") + return 1 + else: + logger.info("succeed") + + time.sleep(5) + + logger.info("recheck libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + else: + logger.info("the libvirtd process successfully restarted after kill") + + return 0 + +def upstart_clean(params): + """clean testing environment""" + logger = params['logger'] + util = utils.Utils() + + if os.path.exists(INITCTL_CMD): + cmd = "initctl stop libvirtd" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: + logger.error("failed to stop libvirtd by initctl") + + if os.path.exists(INIT_CONF): + os.remove(INIT_CONF) + + ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + if ret !=0: + logger.error("failed to reload init confituration") + + elif os.path.exists(SYSTEMCTL_CMD): + cmd = "systemctl stop libvirtd.service" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: + logger.error("failed to stop libvirtd.service by systemctl") + + if os.path.exists(INIT_CONF): + os.remove(INIT_CONF) + + ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + if ret !=0: + logger.error("failed to reload systemd manager confituration") + + cmd = "service libvirtd restart" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: + logger.error("failed to restart libvirtd") + + cmd = "chkconfig --level 345 libvirtd on" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: + logger.error("failed to set chkconfig") -- 1.7.1

On 09/14/2011 06:31 PM, Wayne Sun wrote:
* repos/libvirtd/upstart.py
After set libvirtd upstart, libvirtd could restarted after force kill libvirtd process --- repos/libvirtd/upstart.py | 213 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 213 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/upstart.py
diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py new file mode 100644 index 0000000..904baa9 --- /dev/null +++ b/repos/libvirtd/upstart.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +"""Upstart libvirtd testing +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Aug 4, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['upstart'] + +import os +import re +import sys +import time + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from utils.Python import utils +from shutil import copy + +VIRSH_LIST = "virsh list --all" +UPSTART_CONF = "rpm -ql libvirt|grep upstart" +INITCTL_CMD = "/sbin/initctl" +SYSTEMCTL_CMD = "/bin/systemctl" +INITCTL_RELOAD_CMD = "initctl reload-configuration" +SYSTEMCTL_RELOAD_CMD = "systemctl daemon-reload" +INIT_CONF = "/etc/init/libvirtd.conf" + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def upstart(params): + """Set libvirtd upstart""" + logger = params['logger'] + util = utils.Utils() + + logger.info("chkconfig libvirtd off:") + cmd = "chkconfig libvirtd off" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed") + return 1 + else: + logger.info("succeed") + + cmd = "service libvirtd stop" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to stop libvirtd service") + return 1 + else: + logger.info(out[0]) + + logger.info("find libvirtd.upstart file in libvirt package:") + ret, conf = util.exec_cmd(UPSTART_CONF, shell=True) + if ret != 0: + logger.error("can't find libvirtd.upstart as part of libvirt package") + return 1 + elif conf[0]: + logger.info("succeed") + logger.info("copy %s to %s" % (conf[0], INIT_CONF)) + copy(conf[0], INIT_CONF) + + if os.path.exists(INITCTL_CMD): + logger.info(INITCTL_RELOAD_CMD) + ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + if ret != 0: + logger.error("failed to reload configuration") + return 1 + else: + logger.info("succeed") + + cmd = "initctl start libvirtd" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to start libvirtd by initctl") + return 1 + else: + logger.info(out[0]) + + cmd = "initctl status libvirtd" + logger.info("get libvirtd status by initctl:") + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Operator not followed by a space. + logger.info("failed to get libvirtd status by initctl") + return 1 + else: + logger.info(out[0]) + + elif os.path.exists(SYSTEMCTL_CMD): + logger.info(SYSTEMCTL_RELOAD_CMD) + ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + if ret != 0: + logger.error("failed to reload systemd manager configuration") + return 1 + else: + logger.info("succeed") + + cmd = "systemctl start libvirtd.service" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to start libvirtd.service by systemctl") + return 1 + else: + logger.info(out[0]) + + cmd = "systemctl status libvirtd.service" + logger.info("get libvirtd.service status by systemctl:") + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.info("failed to get libvirtd.service status by systemctl") + return 1 + else: + logger.info(out[0]) + else: + return 1 + + time.sleep(5) + + logger.info("check the libvirtd status:") + result = libvirtd_check(util, logger) Redefining name 'result' from outer scope. + if result: + return 1 + + cmd = "killall -9 libvirtd" + logger.info("kill libvirtd process") + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to kill libvirtd process") + return 1 + else: + logger.info("succeed") + + time.sleep(5) + + logger.info("recheck libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + else: + logger.info("the libvirtd process successfully restarted after kill") + + return 0 + +def upstart_clean(params): + """clean testing environment""" + logger = params['logger'] + util = utils.Utils() + + if os.path.exists(INITCTL_CMD): + cmd = "initctl stop libvirtd" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.error("failed to stop libvirtd by initctl") + + if os.path.exists(INIT_CONF): + os.remove(INIT_CONF) + + ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + if ret !=0: Same as above. + logger.error("failed to reload init confituration") + + elif os.path.exists(SYSTEMCTL_CMD): + cmd = "systemctl stop libvirtd.service" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.error("failed to stop libvirtd.service by systemctl") + + if os.path.exists(INIT_CONF): + os.remove(INIT_CONF) + + ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + if ret !=0: Same as above. + logger.error("failed to reload systemd manager confituration") + + cmd = "service libvirtd restart" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.error("failed to restart libvirtd") + + cmd = "chkconfig --level 345 libvirtd on" + ret, out = util.exec_cmd(cmd, shell=True) Unused variable 'out'. + if ret !=0: Same as above. + logger.error("failed to set chkconfig")

On 09/15/2011 11:04 AM, Alex Jia wrote:
On 09/14/2011 06:31 PM, Wayne Sun wrote:
* repos/libvirtd/upstart.py
After set libvirtd upstart, libvirtd could restarted after force kill libvirtd process --- repos/libvirtd/upstart.py | 213 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 213 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/upstart.py
diff --git a/repos/libvirtd/upstart.py b/repos/libvirtd/upstart.py new file mode 100644 index 0000000..904baa9 --- /dev/null +++ b/repos/libvirtd/upstart.py @@ -0,0 +1,213 @@ +#!/usr/bin/env python +"""Upstart libvirtd testing +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Aug 4, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['upstart'] + +import os +import re +import sys +import time + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from utils.Python import utils +from shutil import copy + +VIRSH_LIST = "virsh list --all" +UPSTART_CONF = "rpm -ql libvirt|grep upstart" +INITCTL_CMD = "/sbin/initctl" +SYSTEMCTL_CMD = "/bin/systemctl" +INITCTL_RELOAD_CMD = "initctl reload-configuration" +SYSTEMCTL_RELOAD_CMD = "systemctl daemon-reload" +INIT_CONF = "/etc/init/libvirtd.conf" + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def upstart(params): + """Set libvirtd upstart""" + logger = params['logger'] + util = utils.Utils() + + logger.info("chkconfig libvirtd off:") + cmd = "chkconfig libvirtd off" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed") + return 1 + else: + logger.info("succeed") + + cmd = "service libvirtd stop" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to stop libvirtd service") + return 1 + else: + logger.info(out[0]) + + logger.info("find libvirtd.upstart file in libvirt package:") + ret, conf = util.exec_cmd(UPSTART_CONF, shell=True) + if ret != 0: + logger.error("can't find libvirtd.upstart as part of libvirt package") + return 1 + elif conf[0]: + logger.info("succeed") + logger.info("copy %s to %s" % (conf[0], INIT_CONF)) + copy(conf[0], INIT_CONF) + + if os.path.exists(INITCTL_CMD): + logger.info(INITCTL_RELOAD_CMD) + ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + if ret != 0: + logger.error("failed to reload configuration") + return 1 + else: + logger.info("succeed") + + cmd = "initctl start libvirtd" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to start libvirtd by initctl") + return 1 + else: + logger.info(out[0]) + + cmd = "initctl status libvirtd" + logger.info("get libvirtd status by initctl:") + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Operator not followed by a space. + logger.info("failed to get libvirtd status by initctl") + return 1 + else: + logger.info(out[0]) + + elif os.path.exists(SYSTEMCTL_CMD): + logger.info(SYSTEMCTL_RELOAD_CMD) + ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + if ret != 0: + logger.error("failed to reload systemd manager configuration") + return 1 + else: + logger.info("succeed") + + cmd = "systemctl start libvirtd.service" + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to start libvirtd.service by systemctl") + return 1 + else: + logger.info(out[0]) + + cmd = "systemctl status libvirtd.service" + logger.info("get libvirtd.service status by systemctl:") + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.info("failed to get libvirtd.service status by systemctl") + return 1 + else: + logger.info(out[0]) + else: + return 1 + + time.sleep(5) + + logger.info("check the libvirtd status:") + result = libvirtd_check(util, logger) Redefining name 'result' from outer scope. + if result: + return 1 + + cmd = "killall -9 libvirtd" + logger.info("kill libvirtd process") + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to kill libvirtd process") + return 1 + else: + logger.info("succeed") + + time.sleep(5) + + logger.info("recheck libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + else: + logger.info("the libvirtd process successfully restarted after kill") + + return 0 + +def upstart_clean(params): + """clean testing environment""" + logger = params['logger'] + util = utils.Utils() + + if os.path.exists(INITCTL_CMD): + cmd = "initctl stop libvirtd" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.error("failed to stop libvirtd by initctl") + + if os.path.exists(INIT_CONF): + os.remove(INIT_CONF) + + ret, out = util.exec_cmd(INITCTL_RELOAD_CMD, shell=True) + if ret !=0: Same as above. + logger.error("failed to reload init confituration") + + elif os.path.exists(SYSTEMCTL_CMD): + cmd = "systemctl stop libvirtd.service" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.error("failed to stop libvirtd.service by systemctl") + + if os.path.exists(INIT_CONF): + os.remove(INIT_CONF) + + ret, out = util.exec_cmd(SYSTEMCTL_RELOAD_CMD, shell=True) + if ret !=0: Same as above. + logger.error("failed to reload systemd manager confituration") + + cmd = "service libvirtd restart" + ret, out = util.exec_cmd(cmd, shell=True) + if ret !=0: Same as above. + logger.error("failed to restart libvirtd") + + cmd = "chkconfig --level 345 libvirtd on" + ret, out = util.exec_cmd(cmd, shell=True) Unused variable 'out'. + if ret !=0: Same as above. + logger.error("failed to set chkconfig")
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
ACK with these code problem fixed. Guannan Ren

* repos/libvirtd/qemu_hang.py qemu process get hang should not cause libvirtd hang or dead --- repos/libvirtd/qemu_hang.py | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/qemu_hang.py diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py new file mode 100644 index 0000000..f377df3 --- /dev/null +++ b/repos/libvirtd/qemu_hang.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +""" QEMU get hang should not cause libvirtd hang or dead. This test stop + a qemu process and check whether libvird get hang. For doing this + test, a running domain is required. + libvirtd:qemu_hang + guestname + #GUESTNAME# +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Sep 2, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['qemu_hang'] + +import os +import re +import sys + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from lib import connectAPI +from lib import domainAPI +from utils.Python import utils + +VIRSH_LIST = "virsh list --all" +RESTART_CMD = "service libvirtd restart" + +def check_params(params): + """Verify inputing parameter dictionary""" + logger = params['logger'] + keys = ['guestname'] + for key in keys: + if key not in params: + logger.error("%s is required" %key) + return 1 + return 0 + +def check_domain_running(domobj, guestname, logger): + """ check if the domain exists, may or may not be active """ + guest_names = domobj.get_list() + + if guestname not in guest_names: + logger.error("%s doesn't exist or not running" % guestname) + return 1 + else: + return 0 + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def get_domain_pid(util, logger, guestname): + """get the pid of running domain""" + logger.info("get the pid of running domain %s" % guestname) + get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname + ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + if ret: + logger.error("fail to get the pid of runnings domain %s" % \ + guestname) + return 1, "" + else: + logger.info("the pid of domain %s is %s" % \ + (guestname, pid[0])) + return 0, pid[0] + +def qemu_hang(params): + """Hang qemu process, check libvirtd status""" + # Initiate and check parameters + params_check_result = check_params(params) + if params_check_result: + return 1 + + logger = params['logger'] + guestname = params['guestname'] + util = utils.Utils() + uri = util.get_uri('127.0.0.1') + + conn = connectAPI.ConnectAPI() + virconn = conn.open(uri) + domobj = domainAPI.DomainAPI(virconn) + + logger.info("check the domain state") + ret = check_domain_running(domobj, guestname, logger) + if ret: + return 1 + + conn.close() + + logger.info("check the libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + + ret, pid = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + cmd = "kill -STOP %s" % pid + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret: + logger.error("failed to stop qemu process of %s" % guestname) + return 1 + + logger.info("recheck libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + + return 0 + +def qemu_hang_cleanup(params): + """ clean testing environment """ + pass + + -- 1.7.1

On 09/14/2011 06:31 PM, Wayne Sun wrote:
* repos/libvirtd/qemu_hang.py
qemu process get hang should not cause libvirtd hang or dead --- repos/libvirtd/qemu_hang.py | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/qemu_hang.py
diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py new file mode 100644 index 0000000..f377df3 --- /dev/null +++ b/repos/libvirtd/qemu_hang.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +""" QEMU get hang should not cause libvirtd hang or dead. This test stop + a qemu process and check whether libvird get hang. For doing this + test, a running domain is required. + libvirtd:qemu_hang + guestname + #GUESTNAME# +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Sep 2, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['qemu_hang'] + +import os +import re +import sys + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from lib import connectAPI +from lib import domainAPI +from utils.Python import utils + +VIRSH_LIST = "virsh list --all" +RESTART_CMD = "service libvirtd restart" + +def check_params(params): + """Verify inputing parameter dictionary""" + logger = params['logger'] + keys = ['guestname'] + for key in keys: + if key not in params: + logger.error("%s is required" %key) + return 1 + return 0 + +def check_domain_running(domobj, guestname, logger): + """ check if the domain exists, may or may not be active """ + guest_names = domobj.get_list() + + if guestname not in guest_names: + logger.error("%s doesn't exist or not running" % guestname) + return 1 + else: + return 0 + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) Unused variable 'out' + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def get_domain_pid(util, logger, guestname): + """get the pid of running domain""" + logger.info("get the pid of running domain %s" % guestname) + get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname + ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + if ret: + logger.error("fail to get the pid of runnings domain %s" % \ + guestname) + return 1, "" + else: + logger.info("the pid of domain %s is %s" % \ + (guestname, pid[0])) + return 0, pid[0] + +def qemu_hang(params): + """Hang qemu process, check libvirtd status""" + # Initiate and check parameters + params_check_result = check_params(params) + if params_check_result: + return 1 + + logger = params['logger'] + guestname = params['guestname'] + util = utils.Utils() + uri = util.get_uri('127.0.0.1') + + conn = connectAPI.ConnectAPI() + virconn = conn.open(uri) + domobj = domainAPI.DomainAPI(virconn) + + logger.info("check the domain state") + ret = check_domain_running(domobj, guestname, logger) + if ret: + return 1 + + conn.close() + + logger.info("check the libvirtd status:") + result = libvirtd_check(util, logger) Redefining name 'result' from outer scope. + if result: + return 1 + + ret, pid = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + cmd = "kill -STOP %s" % pid + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) Unused variable 'out' + if ret: + logger.error("failed to stop qemu process of %s" % guestname) + return 1 + + logger.info("recheck libvirtd status:") + result = libvirtd_check(util, logger) Same as above. + if result: + return 1 + + return 0 + +def qemu_hang_cleanup(params): + """ clean testing environment """ + pass + +

On 09/14/2011 06:31 PM, Wayne Sun wrote:
* repos/libvirtd/qemu_hang.py
qemu process get hang should not cause libvirtd hang or dead --- repos/libvirtd/qemu_hang.py | 142 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) create mode 100644 repos/libvirtd/qemu_hang.py
diff --git a/repos/libvirtd/qemu_hang.py b/repos/libvirtd/qemu_hang.py new file mode 100644 index 0000000..f377df3 --- /dev/null +++ b/repos/libvirtd/qemu_hang.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +""" QEMU get hang should not cause libvirtd hang or dead. This test stop + a qemu process and check whether libvird get hang. For doing this + test, a running domain is required. + libvirtd:qemu_hang + guestname + #GUESTNAME# +""" + +__author__ = 'Wayne Sun: gsun@redhat.com' +__date__ = 'Thu Sep 2, 2011' +__version__ = '0.1.0' +__credits__ = 'Copyright (C) 2011 Red Hat, Inc.' +__all__ = ['qemu_hang'] + +import os +import re +import sys + +def append_path(path): + """Append root path of package""" + if path not in sys.path: + sys.path.append(path) + +pwd = os.getcwd() +result = re.search('(.*)libvirt-test-API', pwd) +append_path(result.group(0)) + +from lib import connectAPI +from lib import domainAPI +from utils.Python import utils + +VIRSH_LIST = "virsh list --all" +RESTART_CMD = "service libvirtd restart" + +def check_params(params): + """Verify inputing parameter dictionary""" + logger = params['logger'] + keys = ['guestname'] + for key in keys: + if key not in params: + logger.error("%s is required" %key) + return 1 + return 0 + +def check_domain_running(domobj, guestname, logger): + """ check if the domain exists, may or may not be active """ + guest_names = domobj.get_list() + + if guestname not in guest_names: + logger.error("%s doesn't exist or not running" % guestname) + return 1 + else: + return 0 + +def libvirtd_check(util, logger): + """check libvirtd status + """ + cmd = "service libvirtd status" + ret, out = util.exec_cmd(cmd, shell=True) + if ret != 0: + logger.error("failed to get libvirtd status") + return 1 + else: + logger.info(out[0]) + + logger.info(VIRSH_LIST) + ret, out = util.exec_cmd(VIRSH_LIST, shell=True) + if ret != 0: + logger.error("failed to get virsh list result") + return 1 + else: + for i in range(len(out)): + logger.info(out[i]) + + return 0 + +def get_domain_pid(util, logger, guestname): + """get the pid of running domain""" + logger.info("get the pid of running domain %s" % guestname) + get_pid_cmd = "cat /var/run/libvirt/qemu/%s.pid" % guestname + ret, pid = util.exec_cmd(get_pid_cmd, shell=True) + if ret: + logger.error("fail to get the pid of runnings domain %s" % \ + guestname) + return 1, "" + else: + logger.info("the pid of domain %s is %s" % \ + (guestname, pid[0])) + return 0, pid[0] + +def qemu_hang(params): + """Hang qemu process, check libvirtd status""" + # Initiate and check parameters + params_check_result = check_params(params) + if params_check_result: + return 1 + + logger = params['logger'] + guestname = params['guestname'] + util = utils.Utils() + uri = util.get_uri('127.0.0.1') + + conn = connectAPI.ConnectAPI() + virconn = conn.open(uri) + domobj = domainAPI.DomainAPI(virconn) + + logger.info("check the domain state") + ret = check_domain_running(domobj, guestname, logger) + if ret: + return 1 + + conn.close() + + logger.info("check the libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + + ret, pid = get_domain_pid(util, logger, guestname) + if ret: + return 1 + + cmd = "kill -STOP %s" % pid + logger.info(cmd) + ret, out = util.exec_cmd(cmd, shell=True) + if ret: + logger.error("failed to stop qemu process of %s" % guestname) + return 1 +
It should be "kill -SIGSTOP $pid" The better to check the state of a process is by "ps aufx | grep qemu" In the ps output, the stopped processes will have a status containing "T" like; qemu 28653 0.2 0.5 771468 21596 ? Tl Sep13 7:17 /usr/libexec/qemu-kvm ...
+ logger.info("recheck libvirtd status:") + result = libvirtd_check(util, logger) + if result: + return 1 + + return 0 + +def qemu_hang_cleanup(params): + """ clean testing environment """ + pass + +
ACK and pushed with these fixed.
participants (3)
-
Alex Jia
-
Guannan Ren
-
Wayne Sun