[Libvirt-cim] [PATCH] [TEST] Fix VSMS 15 to work with KVM guests and old providers

Sharad Mishra snmishra at us.ibm.com
Tue Nov 17 21:24:53 UTC 2009


+1

Sharad Mishra
System x Enablement
Linux Technology Center
IBM


                                                                           
             Kaitlin Rupert                                                
             <kaitlin at linux.vn                                             
             et.ibm.com>                                                To 
             Sent by:                  libvirt-cim at redhat.com              
             libvirt-cim-bounc                                          cc 
             es at redhat.com                                                 
                                                                   Subject 
                                       [Libvirt-cim] [PATCH] [TEST] Fix    
             11/09/2009 02:08          VSMS 15 to work with KVM guests     
             PM                        and old providers                   
                                                                           
                                                                           
             Please respond to                                             
                 List for                                                  
              discussion and                                               
              development of                                               
                libvirt CIM                                                
             <libvirt-cim at redh                                             
                  at.com>                                                  
                                                                           
                                                                           




# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1257801892 28800
# Node ID 9b3156cd8d1a72573531f23cd3e0907d71685c34
# Parent  72072bf8e9b0511d69dc308f2174dea3cb797a6c
[TEST] Fix VSMS 15 to work with KVM guests and old providers

The cimtest image doesn't support reboot; older versions of libvirt-cim
attempted to reboot guests on a disable call (instead of powering them down
immediately).  This fix does a virsh destroy on the guest (for older
provider
sets only).

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 72072bf8e9b0 -r 9b3156cd8d1a
suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py

---
a/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
             Mon Nov 09 13:24:52 2009 -0800
+++
b/suites/libvirt-cim/cimtest/VirtualSystemManagementService/15_mod_system_settings.py
             Mon Nov 09 13:24:52 2009 -0800
@@ -31,7 +31,8 @@
 from XenKvmLib.enumclass import GetInstance
 from XenKvmLib.common_util import poll_for_state_change
 from XenKvmLib.const import get_provider_version
-from XenKvmLib.xm_virt_util import domain_list, active_domain_list
+from XenKvmLib.xm_virt_util import domain_list, active_domain_list, \
+                                   destroy_domain

 sup_types = ['Xen', 'KVM', 'XenFV', 'LXC']
 default_dom = 'rstest_domain'
@@ -42,6 +43,7 @@
 f9_bug = "00010"
 libvirt_f9_revision=613
 libvirt_modify_setting_changes = 694
+disable_change_rev = 945

 def get_vssd(ip, virt, get_cim_inst):
     cn = get_typed_class(virt, "VirtualSystemSettingData")
@@ -63,6 +65,26 @@

     return PASS, inst

+def power_down_guest(ip, virt, dom):
+    rev, changeset = get_provider_version(virt, ip)
+
+    if rev < disable_change_rev and virt == "KVM":
+        rc = destroy_domain(ip, dom, virt)
+        if rc != 0:
+            return FAIL
+    else:
+        status = cxml.cim_disable(ip)
+        if status != PASS:
+            logger.error("Failed to disable %s", dom)
+            return FAIL
+
+    status, cs = poll_for_state_change(ip, virt, dom, CIM_DISABLE)
+    if status != PASS:
+        logger.error("Failed to destroy %s", dom)
+        return FAIL
+
+    return PASS
+
 @do_main(sup_types)
 def main():
     options = main.options
@@ -103,14 +125,9 @@
                     raise Exception("Failed to modify dom: %s" %
default_dom)

             if case == "start":
-                status = cxml.cim_disable(options.ip)
+                status = power_down_guest(options.ip, options.virt,
default_dom)
                 if status != PASS:
-                    raise Exception("Failed to disable %s" % default_dom)
-
-                status, cs = poll_for_state_change(options.ip,
options.virt,
-                                                   default_dom,
CIM_DISABLE)
-                if status != PASS:
-                    raise Exception("Failed to destroy %s" % default_dom)
+                        raise Exception("Unable to disable %s" %
default_dom)

             status, inst = get_vssd(options.ip, options.virt, False)
             if status != PASS:
diff -r 72072bf8e9b0 -r 9b3156cd8d1a
suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py
--- a/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py             Mon Nov
09 13:24:52 2009 -0800
+++ b/suites/libvirt-cim/lib/XenKvmLib/xm_virt_util.py             Mon Nov
09 13:24:52 2009 -0800
@@ -92,6 +92,17 @@

     return int(mfm)

+def destroy_domain(server, dom, virt="Xen"):
+    """Function to destroy given domain"""
+    if virt == "XenFV":
+       virt = "Xen"
+
+    cmd = "virsh -c %s destroy %s" %  (virt2uri(virt), dom)
+    ret, out = utils.run_remote(server, cmd)
+    print cmd, ret, out
+
+    return ret
+
 def domain_list(server, virt="Xen"):
     """Function to list all domains"""
     if virt == "XenFV":

_______________________________________________
Libvirt-cim mailing list
Libvirt-cim at redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/b1bde5dd/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/b1bde5dd/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pic00242.gif
Type: image/gif
Size: 1255 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/b1bde5dd/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20091117/b1bde5dd/attachment-0002.gif>


More information about the Libvirt-cim mailing list