]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
saving UUID of new OpenVZ domains
authorDaniel Veillard <veillard@redhat.com>
Tue, 5 Aug 2008 10:53:05 +0000 (10:53 +0000)
committerDaniel Veillard <veillard@redhat.com>
Tue, 5 Aug 2008 10:53:05 +0000 (10:53 +0000)
* src/openvz_conf.c src/openvz_conf.h src/openvz_driver.c: patch
  from Evgeniy Sokolov saving the UUID when creating or defining
  a domain.
Daniel

ChangeLog
src/openvz_conf.c
src/openvz_conf.h
src/openvz_driver.c

index 133bde6c15ceb965d1d839372a27c0984c6ce34a..318a9f09e82c0018846bfbb27454b6bc3c6ea8da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Aug  5 12:51:11 CEST 2008 Daniel Veillard <veillard@redhat.com>
+
+       * src/openvz_conf.c src/openvz_conf.h src/openvz_driver.c: patch
+         from Evgeniy Sokolov saving the UUID when creating or defining
+         a domain.
+
 Tue Aug  5 10:43:42 CEST 2008 Jim Meyering  <meyering@redhat.com>
 
        make distclean: remove generated source files
index 45de36b806b0bafcf25c503adad5333559a77a3d..4628c8e884680f205d4bee5b145ab999f0cff233 100644 (file)
@@ -736,13 +736,14 @@ openvzGetVPSUUID(int vpsid, char *uuidstr)
 /* Do actual checking for UUID presence in conf file,
  * assign if not present.
  */
-
-static int
-openvzSetUUID(int vpsid)
+int
+openvzSetDefinedUUID(int vpsid, unsigned char *uuid)
 {
     char conf_file[PATH_MAX];
     char uuidstr[VIR_UUID_STRING_BUFLEN];
-    unsigned char uuid[VIR_UUID_BUFLEN];
+
+    if (uuid == NULL)
+        return -1;
 
    if (openvzLocateConfFile(vpsid, conf_file, PATH_MAX)<0)
        return -1;
@@ -755,7 +756,6 @@ openvzSetUUID(int vpsid)
         if (fp == NULL)
           return -1;
 
-        virUUIDGenerate(uuid);
         virUUIDFormat(uuid, uuidstr);
 
         /* Record failure if fprintf or fclose fails,
@@ -768,6 +768,15 @@ openvzSetUUID(int vpsid)
     return 0;
 }
 
+static int
+openvzSetUUID(int vpsid){
+    unsigned char uuid[VIR_UUID_BUFLEN];
+
+    virUUIDGenerate(uuid);
+
+    return openvzSetDefinedUUID(vpsid, uuid);
+}
+
 /*
  * Scan VPS config files and see if they have a UUID.
  * If not, assign one. Just append one to the config
index 5f0d3a461c6296803765c8be889044ab1f92e1bc..da18407985fdfc9c4933544d79a9f14e1288c3e9 100644 (file)
@@ -119,5 +119,6 @@ void openvzFreeVMDef(struct openvz_vm_def *def);
 int strtoI(const char *str);
 int openvzCheckEmptyMac(const unsigned char *mac);
 char *openvzMacToString(const unsigned char *mac);
+int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
 
 #endif /* OPENVZ_CONF_H */
index 981fd8a2a9a4f591c87afd3c6da7402d04b2a3bd..e09b093ee1a6bf2c10a905916534072f0692bf8a 100644 (file)
@@ -459,6 +459,12 @@ openvzDomainDefineXML(virConnectPtr conn, const char *xml)
         goto exit;
     }
 
+    if (openvzSetDefinedUUID(strtoI(vmdef->name), vmdef->uuid) < 0) {
+        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+               _("Could not set UUID"));
+        goto exit;
+    }
+
     dom = virGetDomain(conn, vm->vmdef->name, vm->vmdef->uuid);
     if (dom)
         dom->id = vm->vpsid;
@@ -514,6 +520,12 @@ openvzDomainCreateLinux(virConnectPtr conn, const char *xml,
         goto exit;
     }
 
+    if (openvzSetDefinedUUID(strtoI(vmdef->name), vmdef->uuid) < 0) {
+        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+               _("Could not set UUID"));
+        goto exit;
+    }
+
     if (openvzDomainSetNetwork(conn, vmdef->name, vmdef->net) < 0) {
        openvzError(conn, VIR_ERR_INTERNAL_ERROR,
                   _("Could not configure network"));