guest-random header

The documentation of QEMU’s qemu/guest-random.h header.

int qemu_guest_random_seed_main(const char * optarg, Error ** errp)

Parameters

const char * optarg
a non-NULL pointer to a C string
Error ** errp
an error indicator

Description

The optarg value is that which accompanies the -seed argument. This forces qemu_guest_getrandom into deterministic mode.

Returns 0 on success, < 0 on failure while setting *errp.

uint64_t qemu_guest_random_seed_thread_part1(void)

Parameters

void
no arguments

Description

If qemu_getrandom is in deterministic mode, returns an independent seed for the new thread. Otherwise returns 0.

void qemu_guest_random_seed_thread_part2(uint64_t seed)

Parameters

uint64_t seed
a value for the new thread.

Description

If qemu_guest_getrandom is in deterministic mode, this stores an independent seed for the new thread. Otherwise a no-op.

int qemu_guest_getrandom(void * buf, size_t len, Error ** errp)

Parameters

void * buf
a buffer of bytes to be written
size_t len
the number of bytes in buf
Error ** errp
an error indicator

Description

Fills len bytes in buf with random data. This should only be used for data presented to the guest. Host-side crypto services should use qcrypto_random_bytes.

Returns 0 on success, < 0 on failure while setting *errp.

void qemu_guest_getrandom_nofail(void * buf, size_t len)

Parameters

void * buf
a buffer of bytes to be written
size_t len
the number of bytes in buf

Description

Like qemu_guest_getrandom, but will assert for failure. Use this when there is no reasonable recovery.