[PATCH 3/3] domain_conf: set default emulator into def if it fails to alloc

zhangjl02 jx8zjs at 126.com
Sat May 7 09:40:16 UTC 2022


From: zhangjl02 <zhangjl02 at inspur.com>

When emulator is not found on host, domainPostParseDataAlloc will return 1,
and the domain will fail to start. Call domainPostParseDataDefEmulator to
replace emulator with the default one of guest's arch, and try to alloc again
after domainPostParseDataAlloc's failure. This will increase error tolerance,
if emulator defined in xml is not found on host.

Signed-off-by: zhangjl02 <zhangjl02 at inspur.com>
---
 src/conf/domain_conf.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bd2884088c..485f66357c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6266,7 +6266,15 @@ virDomainDefPostParse(virDomainDef *def,
         ret = xmlopt->config.domainPostParseDataAlloc(def, parseFlags,
                                                       xmlopt->config.priv,
                                                       &data.parseOpaque);
-
+        if (ret == 1){
+            int to_default = 0;
+            to_default = xmlopt->config.domainPostParseDataDefEmulator(def);
+            if (to_default) {
+                ret = xmlopt->config.domainPostParseDataAlloc(def, parseFlags,
+                                                              xmlopt->config.priv,
+                                                              &data.parseOpaque);
+            }
+        }
         if (virDomainDefPostParseCheckFailure(def, parseFlags, ret) < 0)
             goto cleanup;
         localParseOpaque = true;
-- 
2.35.1.windows.2



More information about the libvir-list mailing list