[libvirt] [PATCH 0/3] fsfreeze and fsthaw API testing

Added guest agent conf to domain xml in order to test API fsfreeze and fsthaw. Jincheng Miao (3): add guest agent configuration to domain xml Add domain fsfreeze and fsthaw API testing Add fsfreeze fsthaw test case to linux_domain cases/linux_domain.conf | 18 +++++ repos/domain/domain_fsfreeze.py | 76 ++++++++++++++++++++ repos/domain/domain_fsthaw.py | 49 +++++++++++++ .../domain/xmls/kvm_linux_guest_install_cdrom.xml | 4 + repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 +++-- 5 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py

Signed-off-by: Jincheng Miao <jmiao@redhat.com> --- .../domain/xmls/kvm_linux_guest_install_cdrom.xml | 4 ++++ repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml index cb59e76..8f398bb 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml @@ -35,5 +35,9 @@ <console/> <input bus="ps2" type="mouse"/> <graphics keymap="en-us" port="-1" type="vnc"/> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + </channel> </devices> </domain> diff --git a/repos/domain/xmls/kvm_linux_guest_install_net.xml b/repos/domain/xmls/kvm_linux_guest_install_net.xml index c4a7de7..5fad3a7 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_net.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_net.xml @@ -24,13 +24,17 @@ <source file='DISKPATH'/> <target bus='HDDRIVER' dev='DEV'/> </disk> - <interface type="network"> - <source network="default"/> - <mac address='MACADDR'/> - <model type='NICDRIVER'/> - </interface> - <console/> - <input bus="ps2" type="mouse"/> - <graphics keymap="en-us" port="-1" type="vnc"/> + <interface type="network"> + <source network="default"/> + <mac address='MACADDR'/> + <model type='NICDRIVER'/> + </interface> + <console/> + <input bus="ps2" type="mouse"/> + <graphics keymap="en-us" port="-1" type="vnc"/> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + </channel> </devices> </domain> -- 1.7.1

hi Jmiao Don't forget to add "[libvirt][libvirt-test-API]" to your patch summary. Thanks Hongming On 02/04/2015 05:26 PM, Jincheng Miao wrote:
Signed-off-by: Jincheng Miao <jmiao@redhat.com> --- .../domain/xmls/kvm_linux_guest_install_cdrom.xml | 4 ++++ repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml index cb59e76..8f398bb 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_cdrom.xml @@ -35,5 +35,9 @@ <console/> <input bus="ps2" type="mouse"/> <graphics keymap="en-us" port="-1" type="vnc"/> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + </channel> </devices> </domain> diff --git a/repos/domain/xmls/kvm_linux_guest_install_net.xml b/repos/domain/xmls/kvm_linux_guest_install_net.xml index c4a7de7..5fad3a7 100644 --- a/repos/domain/xmls/kvm_linux_guest_install_net.xml +++ b/repos/domain/xmls/kvm_linux_guest_install_net.xml @@ -24,13 +24,17 @@ <source file='DISKPATH'/> <target bus='HDDRIVER' dev='DEV'/> </disk> - <interface type="network"> - <source network="default"/> - <mac address='MACADDR'/> - <model type='NICDRIVER'/> - </interface> - <console/> - <input bus="ps2" type="mouse"/> - <graphics keymap="en-us" port="-1" type="vnc"/> + <interface type="network"> + <source network="default"/> + <mac address='MACADDR'/> + <model type='NICDRIVER'/> + </interface> + <console/> + <input bus="ps2" type="mouse"/> + <graphics keymap="en-us" port="-1" type="vnc"/> + <channel type='unix'> + <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/GUESTNAME.agent'/> + <target type='virtio' name='org.qemu.guest_agent.0'/> + </channel> </devices> </domain>

On 02/04/2015 02:36 AM, hongming wrote:
hi Jmiao
Don't forget to add "[libvirt][libvirt-test-API]" to your patch summary.
The '[libvirt] portion is added by the list server. It is sufficient to do: git config format.subjectprefix 'test-API PATCH' -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Signed-off-by: Jincheng Miao <jmiao@redhat.com> --- repos/domain/domain_fsfreeze.py | 76 +++++++++++++++++++++++++++++++++++++++ repos/domain/domain_fsthaw.py | 49 +++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 0 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py diff --git a/repos/domain/domain_fsfreeze.py b/repos/domain/domain_fsfreeze.py new file mode 100644 index 0000000..f91cd46 --- /dev/null +++ b/repos/domain/domain_fsfreeze.py @@ -0,0 +1,76 @@ +#!/usr/bin/evn python +# To test domain fsfreeze + +import time +import libvirt +from libvirt import libvirtError + +from src import sharedmod + +required_params = ('guestname',) +optional_params = {'mountpoint': ''} + + +def check_frozen_num(mp, num): + """check the number of frozen fs""" + if mp == None: + return True + + if len(mp) == num: + return True + else: + return False + + +def parse_mountpoint(mp): + """parse the argument mountpoint""" + if mp == None: + return None + + return [p.strip() for p in mp.split(',')] + + +def check_guest_status(domobj): + """Check guest current status""" + state = domobj.info()[0] + if state == libvirt.VIR_DOMAIN_SHUTOFF or \ + state == libvirt.VIR_DOMAIN_SHUTDOWN: + # add check function + return False + else: + return True + + +def domain_fsfreeze(params): + """domain fsfreeze test function""" + logger = params['logger'] + guestname = params['guestname'] + mountpoint = parse_mountpoint(params.get('mountpoint')) + + conn = sharedmod.libvirtobj['conn'] + + domobj = conn.lookupByName(guestname) + + # Check domain block status + if check_guest_status(domobj): + pass + else: + domobj.create() + time.sleep(90) + + try: + num = domobj.fsFreeze(mountpoint, 0) + logger.info("freeze %s fs" % num) + + if check_frozen_num(mountpoint, num): + logger.info("Check frozen fs num: pass") + else: + logger.error("Check frozen fs num: failed") + return 1 + + except libvirtError, e: + logger.error("API error message: %s, error code is %s" + % (e.message, e.get_error_code())) + return 1 + + return 0 diff --git a/repos/domain/domain_fsthaw.py b/repos/domain/domain_fsthaw.py new file mode 100644 index 0000000..cebbe22 --- /dev/null +++ b/repos/domain/domain_fsthaw.py @@ -0,0 +1,49 @@ +#!/usr/bin/evn python +# To test domain fsthaw + +import time +import libvirt +from libvirt import libvirtError + +from src import sharedmod + +required_params = ('guestname',) +optional_params = {} + + +def check_guest_status(domobj): + """Check guest current status""" + state = domobj.info()[0] + if state == libvirt.VIR_DOMAIN_SHUTOFF or \ + state == libvirt.VIR_DOMAIN_SHUTDOWN: + # add check function + return False + else: + return True + + +def domain_fsthaw(params): + """domain fsthaw test function""" + logger = params['logger'] + guestname = params['guestname'] + + conn = sharedmod.libvirtobj['conn'] + + domobj = conn.lookupByName(guestname) + + # Check domain block status + if check_guest_status(domobj): + pass + else: + domobj.create() + time.sleep(90) + + try: + num = domobj.fsThaw() + logger.info("fsThaw %s fs" % num) + except libvirtError, e: + logger.error("API error message: %s, error code is %s" + % (e.message, e.get_error_code())) + return 1 + + return 0 -- 1.7.1

Signed-off-by: Jincheng Miao <jmiao@redhat.com> --- cases/linux_domain.conf | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf index 515858a..371111d 100644 --- a/cases/linux_domain.conf +++ b/cases/linux_domain.conf @@ -139,6 +139,24 @@ domain:cpu_affinity vcpu $defaultvcpu +domain:domain_fsfreeze + guestname + $defaultname + +domain:domain_fsthaw + guestname + $defaultname + +domain:domain_fsfreeze + guestname + $defaultname + mountpoint + / + +domain:domain_fsthaw + guestname + $defaultname + domain:destroy guestname $defaultname -- 1.7.1

On 02/04/2015 05:26 PM, Jincheng Miao wrote:
Signed-off-by: Jincheng Miao <jmiao@redhat.com> --- cases/linux_domain.conf | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf index 515858a..371111d 100644 --- a/cases/linux_domain.conf +++ b/cases/linux_domain.conf @@ -139,6 +139,24 @@ domain:cpu_affinity vcpu $defaultvcpu
+domain:domain_fsfreeze + guestname + $defaultname + +domain:domain_fsthaw + guestname + $defaultname + +domain:domain_fsfreeze + guestname + $defaultname + mountpoint + / + +domain:domain_fsthaw + guestname + $defaultname + domain:destroy guestname $defaultname Thanks ACK and Pushed

Sorry, this is for libvirt-test-API. I should add it to title next time. ----- Original Message -----
Added guest agent conf to domain xml in order to test API fsfreeze and fsthaw.
Jincheng Miao (3): add guest agent configuration to domain xml Add domain fsfreeze and fsthaw API testing Add fsfreeze fsthaw test case to linux_domain
cases/linux_domain.conf | 18 +++++ repos/domain/domain_fsfreeze.py | 76 ++++++++++++++++++++ repos/domain/domain_fsthaw.py | 49 +++++++++++++ .../domain/xmls/kvm_linux_guest_install_cdrom.xml | 4 + repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 +++-- 5 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py

On 04/02/15 17:16, Jincheng Miao wrote:
Added guest agent conf to domain xml in order to test API fsfreeze and fsthaw.
Jincheng Miao (3): add guest agent configuration to domain xml Here is a conflict with your former commit 9d0feb81224075daa82, please check it again. Add domain fsfreeze and fsthaw API testing Please remove extra spaces from above patch Add fsfreeze fsthaw test case to linux_domain
cases/linux_domain.conf | 18 +++++ repos/domain/domain_fsfreeze.py | 76 ++++++++++++++++++++ repos/domain/domain_fsthaw.py | 49 +++++++++++++ .../domain/xmls/kvm_linux_guest_install_cdrom.xml | 4 + repos/domain/xmls/kvm_linux_guest_install_net.xml | 20 +++-- 5 files changed, 159 insertions(+), 8 deletions(-) create mode 100644 repos/domain/domain_fsfreeze.py create mode 100644 repos/domain/domain_fsthaw.py
I try to run it in fedora 21 with below packages, qemu did not freeze the given mountpoint path. If I used a wrong version, what versions did you test during coding this API? [root@hp-dl320eg8-07 libvirt-test-API]# rpm -q libvirt-python qemu libvirt-python-1.2.7-2.fc21.x86_64 qemu-2.1.3-2.fc21.x86_64 Scripts ouput: ++++++++++++++++++++++++++++++++++++++++++++++++++++++ [root@hp-dl320eg8-07 libvirt-test-API]# python libvirt-test-api -c ff.conf -l 0 Checking Testing Environment... Linux hp-dl320eg8-07.qe.lab.eng.nay.redhat.com 3.16.1-301.fc21.x86_64 #1 SMP Mon Aug 25 13:06:39 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux Virsh command line tool of libvirt: 1.2.7 libvirtd (libvirt) 1.2.7 Default URI: qemu:///system QEMU emulator version 2.1.3 (qemu-2.1.3-2.fc21), Copyright (c) 2003-2008 Fabrice Bellard Start Testing: Case Count: 4 Log File: log/20150213164835/libvirt_test001 domain:domain_fsfreeze 16:48:36|INFO |freeze 2 fs 16:48:36|INFO |Check frozen fs num: pass Result: OK domain:domain_fsthaw 16:48:36|INFO |fsThaw 2 fs Result: OK domain:domain_fsfreeze 16:48:36|INFO |freeze 2 fs 16:48:36|ERROR |Check frozen fs num: failed Result: FAIL domain:domain_fsthaw 16:48:36|INFO |fsThaw 2 fs Result: OK Summary: Total:4 [Pass:3 Fail:1 Skip:0] +++++++++++++++++++++++++++++++++++++++++++++++++++ For the rest, it's OK for me. BR, Jianwei
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (4)
-
Eric Blake
-
hongming
-
hujianwei
-
Jincheng Miao