[libvirt] [PATCH 3/4] Probe machine types from kvm binary too

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

 



Currently we only probe the main qemu binary for machine types, but we
should also probe the kvm binary.

* src/qemu_conf.c: probe kvm binary machines in qemudCapsInitGuest()
---
 src/qemu_conf.c |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 9993065..1e579a6 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -716,14 +716,44 @@ qemudCapsInitGuest(virCapsPtr caps,
                                           NULL) == NULL)
             return -1;
 
-        if (haskvm &&
-            virCapabilitiesAddGuestDomain(guest,
-                                          "kvm",
-                                          kvmbin,
-                                          NULL,
-                                          0,
-                                          NULL) == NULL)
-            return -1;
+        if (haskvm) {
+            machines = NULL;
+            nmachines = 0;
+
+            if (stat(kvmbin, &st) == 0) {
+                binary_mtime = st.st_mtime;
+            } else {
+                char ebuf[1024];
+                VIR_WARN(_("Failed to stat %s, most peculiar : %s"),
+                         binary, virStrerror(errno, ebuf, sizeof(ebuf)));
+                binary_mtime = 0;
+            }
+
+            if (!STREQ(binary, kvmbin)) {
+                int probe = 1;
+                if (old_caps && binary_mtime)
+                    probe = !qemudGetOldMachines("hvm", info->arch, info->wordsize,
+                                                 kvmbin, binary_mtime,
+                                                 old_caps, &machines, &nmachines);
+                if (probe &&
+                    qemudProbeMachineTypes(kvmbin, &machines, &nmachines) < 0)
+                    return -1;
+            }
+
+            if (virCapabilitiesAddGuestDomain(guest,
+                                              "kvm",
+                                              kvmbin,
+                                              NULL,
+                                              nmachines,
+                                              machines) == NULL) {
+                for (i = 0; i < nmachines; i++) {
+                    VIR_FREE(machines[i]->name);
+                    VIR_FREE(machines[i]);
+                }
+                VIR_FREE(machines);
+                return -1;
+            }
+        }
     } else {
         if (virCapabilitiesAddGuestDomain(guest,
                                           "kvm",
-- 
1.6.2.5

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[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]