[PATCH] conf: add validation of potential dependencies

Adam Julis posted 1 patch 2 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/07e3c9272c3a82366431feb473b4b9f36d81f8f4.1718632227.git.ajulis@redhat.com
src/qemu/qemu_driver.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] conf: add validation of potential dependencies
Posted by Adam Julis 2 months, 3 weeks ago
Although existing virDomainDefPostParse is called after modifying
the XML and it contains validating process for changed device,
the virDomainDefValidate function performs a more comprehensive
check. It should detect errors resulting from dependencies
between devices. Therefore, the virDomainDefValidate is added at
the end.

Signed-off-by: Adam Julis <ajulis@redhat.com>
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e2698c7924..67b9778c67 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6869,6 +6869,9 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef,
     if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0)
         return -1;
 
+    if (virDomainDefValidate(vmdef, parse_flags, xmlopt, qemuCaps) < 0)
+        return -1;
+
     return 0;
 }
 
-- 
2.44.0
Re: [PATCH] conf: add validation of potential dependencies
Posted by Michal Prívozník 2 months, 3 weeks ago
On 6/17/24 15:51, Adam Julis wrote:
> Although existing virDomainDefPostParse is called after modifying
> the XML and it contains validating process for changed device,
> the virDomainDefValidate function performs a more comprehensive
> check. It should detect errors resulting from dependencies
> between devices. Therefore, the virDomainDefValidate is added at
> the end.
> 

PostParse should refrain from doing any validation. I believe what you
meant to say is: virDomainDeviceDefParse() calls
virDomainDeviceDefValidate().

I'm changing the commit message a bit and merging.

> Signed-off-by: Adam Julis <ajulis@redhat.com>
> ---
>  src/qemu/qemu_driver.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal