* Copyright (C) 2014 Roman Bogorodskiy
* Copyright (C) 2014 Semihalf
* 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
}
+static int
+bhyveProbeCapsVirtioRnd(unsigned int *caps, char *binary)
+{
+ return bhyveProbeCapsDeviceHelper(caps, binary,
+ "-s",
+ "0,virtio-rnd",
+ "pci slot 0:0: unknown device \"virtio-rnd\"",
+ BHYVE_CAP_VIRTIO_RND);
+}
+
+
int
virBhyveProbeCaps(unsigned int *caps)
{
if ((ret = bhyveProbeCapsVirtio9p(caps, binary)))
goto out;
+ if ((ret = bhyveProbeCapsVirtioRnd(caps, binary)))
+ goto out;
+
out:
VIR_FREE(binary);
return ret;
* bhyve_capabilities.h: bhyve capabilities module
*
* Copyright (C) 2014 Semihalf
+ * 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
BHYVE_CAP_SOUND_HDA = 1 << 7,
BHYVE_CAP_VNC_PASSWORD = 1 << 8,
BHYVE_CAP_VIRTIO_9P = 1 << 9,
+ BHYVE_CAP_VIRTIO_RND = 1 << 10,
} virBhyveCapsFlags;
int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps);
* bhyve_command.c: bhyve command generation
*
* Copyright (C) 2014 Roman Bogorodskiy
+ * 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 0;
}
+static int
+bhyveBuildRNGArgStr(const virDomainDef *def G_GNUC_UNUSED,
+ virDomainRNGDef *rng,
+ virCommand *cmd)
+{
+ if (rng->backend != VIR_DOMAIN_RNG_BACKEND_RANDOM) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("RNG backend is not supported"));
+ return -1;
+ }
+
+ virCommandAddArg(cmd, "-s");
+ virCommandAddArgFormat(cmd, "%d:%d,virtio-rnd",
+ rng->info.addr.pci.slot,
+ rng->info.addr.pci.function);
+ return 0;
+}
+
static int
bhyveBuildAHCIControllerArgStr(const virDomainDef *def,
virDomainControllerDef *controller,
if (bhyveBuildConsoleArgStr(def, cmd) < 0)
return NULL;
+ for (i = 0; i < def->nrngs; i++)
+ if (bhyveBuildRNGArgStr(def, def->rngs[i], cmd) < 0)
+ return NULL;
+
if (def->namespaceData) {
bhyveDomainCmdlineDef *bhyvecmd;
* bhyve_device.c: bhyve device management
*
* Copyright (C) 2014 Roman Bogorodskiy
+ * 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;
}
+ for (i = 0; i < def->nrngs; i++) {
+ if (!virDeviceInfoPCIAddressIsWanted(&def->rngs[i]->info))
+ continue;
+ if (virDomainPCIAddressReserveNextAddr(addrs,
+ &def->rngs[i]->info,
+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
+ -1) < 0)
+ return -1;
+ }
+
return 0;
}
--- /dev/null
+bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 2:0,ahci,hd:/tmp/freebsd.img \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
+-s 4:0,virtio-rnd \
+bhyve
--- /dev/null
+bhyveload \
+-m 214 \
+-d /tmp/freebsd.img \
+bhyve
--- /dev/null
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <disk type='file'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <interface type='bridge'>
+ <mac address='52:54:00:b9:94:02'/>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <rng model='virtio'>
+ <backend model='random'/>
+ </rng>
+ </devices>
+</domain>
DO_TEST_FAILURE("fs-9p-unsupported-accessmode");
driver.bhyvecaps &= ~BHYVE_CAP_VIRTIO_9P;
DO_TEST_FAILURE("fs-9p");
+ DO_TEST("virtio-rnd");
+ driver.bhyvecaps &= ~BHYVE_CAP_VIRTIO_RND;
+ DO_TEST_FAILURE("virtio-rnd");
/* Address allocation tests */
DO_TEST("addr-single-sata-disk");
--- /dev/null
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='file' type='raw'/>
+ <source file='/tmp/freebsd.img'/>
+ <target dev='hda' bus='sata'/>
+ <address type='drive' controller='0' bus='0' target='2' unit='0'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='sata' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </controller>
+ <interface type='bridge'>
+ <mac address='52:54:00:b9:94:02'/>
+ <source bridge='virbr0'/>
+ <model type='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ <rng model='virtio'>
+ <backend model='random'>/dev/random</backend>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </rng>
+ </devices>
+</domain>
DO_TEST_DIFFERENT("sound");
DO_TEST_DIFFERENT("isa-controller");
DO_TEST_DIFFERENT("fs-9p");
+ DO_TEST_DIFFERENT("virtio-rnd");
/* Address allocation tests */
DO_TEST_DIFFERENT("addr-single-sata-disk");