tests/docker: remove mingw packages from Fedora
[qemu.git] / include / qemu / guest-random.h
blob09ff9c22369fb8f2477db9e43a03f105523bfdbd
1 /*
2 * QEMU guest-visible random functions
4 * Copyright 2019 Linaro, Ltd.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
12 #ifndef QEMU_GUEST_RANDOM_H
13 #define QEMU_GUEST_RANDOM_H
15 /**
16 * qemu_guest_random_seed_main(const char *optarg, Error **errp)
17 * @optarg: a non-NULL pointer to a C string
18 * @errp: an error indicator
20 * The @optarg value is that which accompanies the -seed argument.
21 * This forces qemu_guest_getrandom into deterministic mode.
23 * Returns 0 on success, < 0 on failure while setting *errp.
25 int qemu_guest_random_seed_main(const char *optarg, Error **errp);
27 /**
28 * qemu_guest_random_seed_thread_part1(void)
30 * If qemu_getrandom is in deterministic mode, returns an
31 * independent seed for the new thread. Otherwise returns 0.
33 uint64_t qemu_guest_random_seed_thread_part1(void);
35 /**
36 * qemu_guest_random_seed_thread_part2(uint64_t seed)
37 * @seed: a value for the new thread.
39 * If qemu_guest_getrandom is in deterministic mode, this stores an
40 * independent seed for the new thread. Otherwise a no-op.
42 void qemu_guest_random_seed_thread_part2(uint64_t seed);
44 /**
45 * qemu_guest_getrandom(void *buf, size_t len, Error **errp)
46 * @buf: a buffer of bytes to be written
47 * @len: the number of bytes in @buf
48 * @errp: an error indicator
50 * Fills len bytes in buf with random data. This should only be used
51 * for data presented to the guest. Host-side crypto services should
52 * use qcrypto_random_bytes.
54 * Returns 0 on success, < 0 on failure while setting *errp.
56 int qemu_guest_getrandom(void *buf, size_t len, Error **errp);
58 /**
59 * qemu_guest_getrandom_nofail(void *buf, size_t len)
60 * @buf: a buffer of bytes to be written
61 * @len: the number of bytes in @buf
63 * Like qemu_guest_getrandom, but will assert for failure.
64 * Use this when there is no reasonable recovery.
66 void qemu_guest_getrandom_nofail(void *buf, size_t len);
68 #endif /* QEMU_GUEST_RANDOM_H */