[Libvirt-cim] [PATCH] Fix a few bugs in the reset() call in CS

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Wed Jul 23 20:10:23 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1216843816 25200
# Node ID 695e6e7fb85f14e7e7685b94832b0fc73027e405
# Parent  427e74d2c45881820ee33b8b6cdeb9cff57a68c0
Fix a few bugs in the reset() call in CS.

This fixes the following issues:
  -After the destroy call, the domain pointer is no longer valid.  We need to get a new one to use for the Create call.
  -In the situation where the guest was created without being defined, we need to get the XML and then define the before calling the create call.

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

diff -r 427e74d2c458 -r 695e6e7fb85f src/Virt_ComputerSystem.c
--- a/src/Virt_ComputerSystem.c	Mon Jul 21 13:28:13 2008 -0700
+++ b/src/Virt_ComputerSystem.c	Wed Jul 23 13:10:16 2008 -0700
@@ -673,12 +673,45 @@
 static int domain_reset(virDomainPtr dom)
 {
         int ret;
+        virConnectPtr conn = NULL;
+        virDomainInfo info;
+        char *xml = NULL;
+
+        conn = virDomainGetConnect(dom);
+        if (conn == NULL) {
+                CU_DEBUG("Unable to get connection from domain");
+                return 1;
+        }
+
+        xml = virDomainGetXMLDesc(dom, 0);
+        if (xml == NULL) {
+                CU_DEBUG("Unable to retrieve domain XML");
+                return 1;
+        }
 
         ret = virDomainDestroy(dom);
         if (ret)
-                return ret;
+                goto out;
+
+        dom = virDomainLookupByName(virDomainGetConnect(dom),
+                                     virDomainGetName(dom));
+
+        if (dom == NULL) {
+            dom = virDomainDefineXML(conn, xml);
+            if (dom == NULL) {
+                CU_DEBUG("Failed to define domain from XML");
+                ret = 1;
+                goto out;
+            }
+        }
+
+        if (!domain_online(dom))
+            CU_DEBUG("Guest is now offline");
 
         ret = virDomainCreate(dom);
+
+ out:
+        free(xml);
 
         return ret;
 }




More information about the Libvirt-cim mailing list