+1

Sharad Mishra
System x Enablement
Linux Technology Center
IBM

Inactive hide details for Kaitlin Rupert ---11/09/2009 02:02:54 PM---# HG changeset patchKaitlin Rupert ---11/09/2009 02:02:54 PM---# HG changeset patch

          Kaitlin Rupert <kaitlin@linux.vnet.ibm.com>
          Sent by: libvirt-cim-bounces@redhat.com

          11/09/2009 02:08 PM
          Please respond to
          List for discussion and development of libvirt CIM <libvirt-cim@redhat.com>


To

libvirt-cim@redhat.com

cc


Subject

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

# HG changeset patch
# User Kaitlin Rupert <karupert@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@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@redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim