From: Roman Bogorodskiy Date: Sun, 6 Apr 2025 13:34:18 +0000 (+0200) Subject: bhyve: argv2xml: support virtio-rnd devices X-Git-Tag: v11.3.0-rc1~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0464a9462cbe90e2444c3095709b1313c22e96a9;p=thirdparty%2Flibvirt.git bhyve: argv2xml: support virtio-rnd devices Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index 29d3a678bf..7a4e48fbf8 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -5,6 +5,7 @@ * 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 @@ -639,6 +640,32 @@ bhyveParsePCIFbuf(virDomainDef *def, 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, @@ -703,6 +730,8 @@ bhyveParseBhyvePCIArg(virDomainDef *def, 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); diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-rnd.args b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-rnd.args new file mode 100644 index 0000000000..7e4b27eb77 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-rnd.args @@ -0,0 +1,8 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 1:0,virtio-rnd \ +bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-rnd.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-rnd.xml new file mode 100644 index 0000000000..c6b2620f9e --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-virtio-rnd.xml @@ -0,0 +1,20 @@ + + bhyve + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + destroy + destroy + + + /dev/random +
+ + + diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c index 92189a2e58..82abce5b8f 100644 --- a/tests/bhyveargv2xmltest.c +++ b/tests/bhyveargv2xmltest.c @@ -188,6 +188,7 @@ mymain(void) DO_TEST("vnc-vga-io"); DO_TEST("vnc-resolution"); DO_TEST("vnc-password"); + DO_TEST("virtio-rnd"); virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt);