From: zhangjl02 <zhangjl02(a)inspur.com>
qemuDomainPostParseDataDefEmulator will try to get default emulator based on
guest's arch from capabilities, and replace the emulator in definition.
Signed-off-by: zhangjl02 <zhangjl02(a)inspur.com>
---
src/qemu/qemu_domain.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 7974cdb00b..98a4070226 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5972,6 +5972,23 @@ qemuDomainPostParseDataAlloc(const virDomainDef *def,
}
+static int
+qemuDomainPostParseDataDefEmulator(virDomainDef *def)
+{
+ char *emulator = NULL;
+ struct stat sb;
+ virArch hostArch = virArchFromHost();
+ emulator = virQEMUCapsGetDefaultEmulator(hostArch, def->os.arch);
+ if (stat(emulator, &sb) < 0) {
+ virReportSystemError(errno, _("Cannot check QEMU binary %s"),
+ emulator);
+ return 0;
+ }
+ def->emulator = emulator;
+ return 1;
+}
+
+
static void
qemuDomainPostParseDataFree(void *parseOpaque)
{
@@ -5984,6 +6001,7 @@ qemuDomainPostParseDataFree(void *parseOpaque)
virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
.domainPostParseBasicCallback = qemuDomainDefPostParseBasic,
.domainPostParseDataAlloc = qemuDomainPostParseDataAlloc,
+ .domainPostParseDataDefEmulator = qemuDomainPostParseDataDefEmulator,
.domainPostParseDataFree = qemuDomainPostParseDataFree,
.devicesPostParseCallback = qemuDomainDeviceDefPostParse,
.domainPostParseCallback = qemuDomainDefPostParse,
--
2.35.1.windows.2