Commit 021fadcc8d for qemu.org

commit 021fadcc8da866547429a2c91334eb1ff2c4ab34
Author: Stacey Son <sson@FreeBSD.org>
Date:   Mon Feb 2 16:41:28 2026 -0700

    bsd-user: Add do_bsd_uuidgen implementation

    Add implementation of uuidgen(2) syscall that generates UUIDs and
    converts them to target ABI format.

    Signed-off-by: Stacey Son <sson@FreeBSD.org>
    Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
    Signed-off-by: Warner Losh <imp@bsdimp.com>

diff --git a/bsd-user/bsd-misc.h b/bsd-user/bsd-misc.h
index 7587ffd605..9f1cc8a0cd 100644
--- a/bsd-user/bsd-misc.h
+++ b/bsd-user/bsd-misc.h
@@ -32,6 +32,39 @@ static inline abi_long do_bsd_reboot(abi_long how)
     return -TARGET_ENOSYS;
 }

+/* uuidgen(2) */
+static inline abi_long do_bsd_uuidgen(abi_ulong target_addr, int count)
+{
+    int i;
+    abi_long ret;
+    g_autofree struct uuid *host_uuid = NULL;
+
+    /*
+     * 2048 is the kernel limit, but there's no #define for it, nor any sysctl
+     * to query it.
+     */
+    if (count < 1 || count > 2048) {
+        return -TARGET_EINVAL;
+    }
+
+    host_uuid = g_malloc(count * sizeof(struct uuid));
+
+    ret = get_errno(uuidgen(host_uuid, count));
+    if (is_error(ret)) {
+        goto out;
+    }
+    for (i = 0; i < count; i++) {
+        ret = host_to_target_uuid(target_addr +
+            (abi_ulong)(sizeof(struct target_uuid) * i), &host_uuid[i]);
+        if (is_error(ret)) {
+            break;
+        }
+    }
+
+out:
+    return ret;
+}
+
 /* getdtablesize(2) */
 static inline abi_long do_bsd_getdtablesize(void)
 {