On 09/04/22 8:19 pm, Ani Sinha wrote:
On Fri, Apr 8, 2022 at 11:19 PM Rohit Kumar <rohit.kum...@nutanix.com> wrote:
Remote store NVRAM feature is being enabled only
if it supports 'blockdev' capability.

Signed-off-by: Prerna Saxena <prerna.sax...@nutanix.com>
Signed-off-by: Florian Schmidt <flo...@nutanix.com>
Signed-off-by: Rohit Kumar <rohit.kum...@nutanix.com>
Please add negative unit tests to check the validation along with this
patch. Prefix the patch with "qemu:".
Thanks for pointing this out, Ani. Sure, I will add it the next patch series.

---
  src/qemu/qemu_validate.c | 22 ++++++++++++++++++++++
  1 file changed, 22 insertions(+)

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 96f5427678..2a961b1f50 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -611,6 +611,25 @@ qemuValidateDomainDefBoot(const virDomainDef *def)
  }


+static int
+qemuValidateDomainDefNvram(const virDomainDef *def,
+                           virQEMUCaps *qemuCaps)
+{
+    if (def->os.loader && def->os.loader->nvram) {
+        if (def->os.loader->nvram->type !=  VIR_STORAGE_TYPE_FILE &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("This Qemu does not support 'blockdev' capability 
"
+                             "for remote store NVRAM. NVRAM type other than "
+                             "'file' is not supported with this QEMU"));
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
  /**
   * qemuValidateDefGetVcpuHotplugGranularity:
   * @def: domain definition
@@ -1185,6 +1204,9 @@ qemuValidateDomainDef(const virDomainDef *def,
      if (qemuValidateDomainDefBoot(def) < 0)
          return -1;

+    if (qemuValidateDomainDefNvram(def, qemuCaps) < 0)
+        return -1;
+
      if (qemuValidateDomainVCpuTopology(def, qemuCaps) < 0)
          return -1;

--
2.25.1


Reply via email to