On Fri, Aug 14, 2026 at 09:19:29 +0100, John Levon wrote:
For NVRAM storage specifically, the guest-visible size is critical to correct handling of the OVMF address space. Allow specifying storage slices for NVRAM storage when the underlying block may be larger due to alignment/allocation restrictions.
As qemuPrepareNVRAMBlock() does not support it, disallow slices with non-raw formats, and slice offsets.
Signed-off-by: John Levon <john.levon@nutanix.com> --- src/qemu/qemu_validate.c | 32 ++++++++++---- ...ual-efi-nvram-dev-slice.x86_64-latest.args | 35 ++++++++++++++++ ...nual-efi-nvram-dev-slice.x86_64-latest.xml | 42 +++++++++++++++++++ .../firmware-manual-efi-nvram-dev-slice.xml | 25 +++++++++++ tests/qemuxmlconftest.c | 1 + 5 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxmlconfdata/firmware-manual-efi-nvram-dev-slice.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/firmware-manual-efi-nvram-dev-slice.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/firmware-manual-efi-nvram-dev-slice.xml
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 61f3bd3278..ae70eb89f0 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -707,8 +707,32 @@ qemuValidateDomainDefNvram(const virDomainDef *def,
switch (src->type) { case VIR_STORAGE_TYPE_FILE: - case VIR_STORAGE_TYPE_BLOCK: case VIR_STORAGE_TYPE_NETWORK: + if (src->sliceStorage) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("slices are not supported with non-block NVRAM")); + return -1; + } + break; + + case VIR_STORAGE_TYPE_BLOCK: + if (src->sliceStorage) { + if (src->sliceStorage->offset != 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("offset slices are not supported with NVRAM"));
Missing 'return -1;'
+ } + + switch (src->format) { + case VIR_STORAGE_FILE_RAW: + case VIR_STORAGE_FILE_NONE: + break; + + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("NVRAM slices are not supported with format '%1$s'"), + virStorageFileFormatTypeToString(src->format));
Missing 'return -1'. Also we normally prefer enum statements with a proper type which are then forced by the compiler to cover all cases. Since 'src->format' wasn't converted to proper type yet I think we can leave it as-is.
+ } + } break;
case VIR_STORAGE_TYPE_DIR: @@ -728,12 +752,6 @@ qemuValidateDomainDefNvram(const virDomainDef *def, 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"));
I'll add the missing code and: Reviewed-by: Peter Krempa <pkrempa@redhat.com> and push this soon