[PATCH 1/3] qemu_domain: introduce qemuDomainPostParseDataDefEmulator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: zhangjl02 <zhangjl02@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux