]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
* src/openvz_conf.c src/libvirt.c: cleanup, avoid some warnings,
authorDaniel Veillard <veillard@redhat.com>
Tue, 17 Jul 2007 14:40:26 +0000 (14:40 +0000)
committerDaniel Veillard <veillard@redhat.com>
Tue, 17 Jul 2007 14:40:26 +0000 (14:40 +0000)
  and reuse the existing uuid generation function.
Daniel

ChangeLog
src/libvirt.c
src/openvz_conf.c

index fa164717b17ed7699a3dbcfff2f2ea87894b9d7a..598f884c7f2331438a4b00eae816a91fab78ecec 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Jul 17 16:39:18 CEST 2007 Daniel Veillard <veillard@redhat.com>
+
+       * src/openvz_conf.c src/libvirt.c: cleanup, avoid some warnings,
+         and reuse the existing uuid generation function.
+
 Tue Jul 17 15:24:27 CEST 2007 Daniel Veillard <veillard@redhat.com>
 
        * configure.in src/Makefile.am src/driver.h src/libvirt.c:
index cc750e0643f22026bdb58339e336be076ef8182b..542825a4e5b2ebcf77e49d710a34635016e88a1f 100644 (file)
@@ -30,6 +30,9 @@
 #include "xen_unified.h"
 #include "remote_internal.h"
 #include "qemu_driver.h"
+#ifdef WITH_OPENVZ
+#include "openvz_driver.h"
+#endif
 
 /*
  * TODO:
index ad4bb73bdc631bf3842770bc1dbaa8b66735ab51..3f57bdb1e7ba4b6fbbeb30a649039b6723d2b1c7 100644 (file)
@@ -331,6 +331,7 @@ char *openvzLocateConfDir(void)
 
 /* Richard Steven's classic readline() function */
 
+static
 int openvz_readline(int fd, char *ptr, int maxlen)
 {
     int n, rc;
@@ -355,27 +356,6 @@ int openvz_readline(int fd, char *ptr, int maxlen)
     return n;
 }
 
-void openvzGenerateUUID(unsigned char *uuid)
-{
-    unsigned int i;
-    int fd;
-    
-    /* seed rand() with kernel entrophy */
-    fd =  open("/dev/urandom", O_RDONLY);
-    if(fd != -1) {
-        read(fd, &i, sizeof(int));
-        srand(i);
-        close(fd);
-    }
-    else {
-        srand((int) time(NULL));
-    }
-
-    for (i = 0 ; i < VIR_UUID_BUFLEN ; i++) {
-        uuid[i] = (unsigned char)(1 + (int) (256.0 * (rand() / (RAND_MAX + 1.0))));
-    }
-}
-
 int openvzGetVPSUUID(int vpsid, char *uuidbuf)
 {
     char conf_file[PATH_MAX];
@@ -437,7 +417,7 @@ int openvzSetUUID(int vpsid)
         return -1;
 
     if(uuid[0] == (int)NULL) {
-        openvzGenerateUUID(new_uuid);
+        virUUIDGenerate(new_uuid);
         bzero(uuid, (VIR_UUID_BUFLEN * 2) + 1);
         for(i = 0; i < VIR_UUID_BUFLEN; i ++)
             sprintf(uuid + (i * 2), "%02x", (unsigned char)new_uuid[i]);