[Pkg-libvirt-commits] [libguestfs] 04/29: daemon: add get_random_uuid

Hilko Bengen bengen at moszumanska.debian.org
Sun Nov 1 17:15:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag upstream/1.29.49
in repository libguestfs.

commit d0c067df8709206b494bb7ea0b2548671d50b0a9
Author: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
Date:   Tue Jun 30 19:23:12 2015 +0800

    daemon: add get_random_uuid
    
    Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 appliance/packagelist.in |  1 +
 daemon/daemon.h          |  2 ++
 daemon/guestfsd.c        | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+)

diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index 76c7293..d218a37 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -97,6 +97,7 @@ dnl iproute has been renamed to iproute2
   vim-tiny
   xz-utils
   zfs-fuse
+  uuid-runtime
 )
 
 ifelse(ARCHLINUX,1,
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 0e6efdd..fce7b57 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -152,6 +152,8 @@ extern void udev_settle (void);
 
 extern int random_name (char *template);
 
+extern char *get_random_uuid (void);
+
 /* This just stops gcc from giving a warning about our custom printf
  * formatters %Q and %R.  See guestfs(3)/EXTENDING LIBGUESTFS for more
  * info about these.  In GCC 4.8.0 the warning is even harder to
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 584c685..7f4b2f2 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -57,6 +57,7 @@
 #include "daemon.h"
 
 GUESTFSD_EXT_CMD(str_udevadm, udevadm);
+GUESTFSD_EXT_CMD(str_uuidgen, uuidgen);
 
 #ifndef MAX
 # define MAX(a,b) ((a)>(b)?(a):(b))
@@ -1509,6 +1510,24 @@ udev_settle (void)
     fprintf (stderr, "warning: udevadm command failed\n");
 }
 
+char *
+get_random_uuid (void)
+{
+  int r;
+  char *out;
+  CLEANUP_FREE char *err = NULL;
+
+  r = command (&out, &err, str_uuidgen, NULL);
+  if (r == -1) {
+    reply_with_error ("%s", err);
+    return NULL;
+  }
+
+  /* caller free */
+  return out;
+
+}
+
 /* Use by the CLEANUP_* macros.  Do not call these directly. */
 void
 cleanup_free (void *ptr)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list