From 4fc9b49217d669c79abe3025d993f7e7f1463f7e Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Wed, 7 May 2025 20:20:18 +0200 Subject: [PATCH] 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 --- src/bhyve/bhyve_domain.c | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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, }; -- 2.47.2