[Libvirt-cim] [PATCH] Fix logic for checking UUID conflicts in ModifySystemSettings()

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Sep 1 18:35:10 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1251830061 25200
# Node ID ed4e0bfacffbeded283d2a81d0b0fb0736fb6f5b
# Parent  a0297a6cdac8864acd43c873058beecaf54fca2b
Fix logic for checking UUID conflicts in ModifySystemSettings()

Instead of checking to see if the UUID is in use, we need to make sure the
provider is using the existing UUID.  If the user specifies a UUID that is
different, then an error is returned.  If no UUID (or if an empty string is
specified), the provider will override that value with the original UUID.

This fixes a bug where the user specifies a empty string, which we were passing
to libvirt.

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

diff -r a0297a6cdac8 -r ed4e0bfacffb src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c	Tue Aug 25 13:38:23 2009 -0700
+++ b/src/Virt_VirtualSystemManagementService.c	Tue Sep 01 11:34:21 2009 -0700
@@ -1621,6 +1621,7 @@
         virDomainPtr dom = NULL;
         struct domain *dominfo = NULL;
         char *xml = NULL;
+        const char *uuid = NULL;
 
         ret = cu_get_str_prop(vssd, "VirtualSystemIdentifier", &name);
         if (ret != CMPI_RC_OK) {
@@ -1652,6 +1653,8 @@
                 goto out;
         }
 
+        uuid = strdup(dominfo->uuid);
+
         if (!vssd_to_domain(vssd, dominfo)) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
@@ -1659,9 +1662,18 @@
                 goto out;
         }
 
-        s = check_uuid_in_use(ref, dominfo);
-        if (s.rc != CMPI_RC_OK)
+        if ((dominfo->uuid == NULL) || (STREQ(dominfo->uuid, ""))) {
+                dominfo->uuid = strdup(uuid);
+        } else if (!STREQ(uuid, dominfo->uuid)) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "%s is already defined with UUID %s - cannot change "
+                           "UUID to the UUID specified %s", 
+                           name, 
+                           uuid, 
+                           dominfo->uuid);
                 goto out;
+        } 
 
         xml = system_to_xml(dominfo);
         if (xml != NULL) {




More information about the Libvirt-cim mailing list