* Copyright (C) 2006 Daniel P. Berrange
* Copyright (c) 2011 NetApp, Inc.
* Copyright (C) 2020 Fabian Freyer
+ * Copyright (C) 2025 The FreeBSD Foundation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
return -1;
}
+static int
+bhyveParsePCIRND(virDomainDef *def,
+ virDomainXMLOption *xmlopt G_GNUC_UNUSED,
+ unsigned caps G_GNUC_UNUSED,
+ unsigned bus,
+ unsigned slot,
+ unsigned function,
+ const char *config G_GNUC_UNUSED)
+{
+ /* -s slot,virtio-rnd */
+ virDomainRNGDef *rng = g_new0(virDomainRNGDef, 1);
+
+ rng->model = VIR_DOMAIN_RNG_MODEL_VIRTIO;
+ rng->backend = VIR_DOMAIN_RNG_BACKEND_RANDOM;
+
+ rng->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+ rng->info.addr.pci.bus = bus;
+ rng->info.addr.pci.slot = slot;
+ rng->info.addr.pci.function = function;
+ rng->source.file = g_strdup("/dev/random");
+
+ VIR_APPEND_ELEMENT(def->rngs, def->nrngs, rng);
+
+ return 0;
+}
+
static int
bhyveParseBhyvePCIArg(virDomainDef *def,
virDomainXMLOption *xmlopt,
VIR_DOMAIN_NET_MODEL_E1000, conf);
else if (STREQ(emulation, "fbuf"))
bhyveParsePCIFbuf(def, xmlopt, caps, bus, slot, function, conf);
+ else if (STREQ(emulation, "virtio-rnd"))
+ bhyveParsePCIRND(def, xmlopt, caps, bus, slot, function, conf);
VIR_FREE(emulation);
VIR_FREE(slotdef);
--- /dev/null
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type>hvm</type>
+ </os>
+ <clock offset='localtime'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>destroy</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <rng model='virtio'>
+ <backend model='random'>/dev/random</backend>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+ </rng>
+ </devices>
+</domain>