Signed-off-by: Chen Hanxiao <chenhanx...@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 d8a5e0b..f8441d1 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) -- 2.1.0 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs