From: Roman Bogorodskiy Date: Wed, 7 May 2025 18:20:18 +0000 (+0200) Subject: bhyve: introduce bhyveDomainDefValidate() X-Git-Tag: v11.4.0-rc1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fc9b49217d669c79abe3025d993f7e7f1463f7e;p=thirdparty%2Flibvirt.git bhyve: introduce bhyveDomainDefValidate() Add the bhyveDomainDefValidate() validation which currently checks whether the requested NVRAM is supported. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index ca5176885a..3e18a462e4 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -267,11 +267,54 @@ bhyveDomainDeviceDefValidate(const virDomainDeviceDef *dev, return 0; } + +static int +bhyveDomainDefValidate(const virDomainDef *def, + void *opaque G_GNUC_UNUSED, + void *parseOpaque G_GNUC_UNUSED) +{ + virStorageSource *src = NULL; + + if (!def->os.loader) + return 0; + + if (!(src = def->os.loader->nvram)) + return 0; + + if (src->type != VIR_STORAGE_TYPE_FILE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", + _("only 'file' type is supported with NVRAM")); + return -1; + } + + if (src->sliceStorage) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("slices are not supported with NVRAM")); + return -1; + } + + if (src->pr) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("persistent reservations are not supported with NVRAM")); + return -1; + } + + if (src->backingStore) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("backingStore is not supported with NVRAM")); + return -1; + } + + return 0; +} + virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = { .devicesPostParseCallback = bhyveDomainDeviceDefPostParse, .domainPostParseCallback = bhyveDomainDefPostParse, .assignAddressesCallback = bhyveDomainDefAssignAddresses, .deviceValidateCallback = bhyveDomainDeviceDefValidate, + .domainValidateCallback = bhyveDomainDefValidate, .features = VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT, };