]> xenbits.xensource.com Git - libvirt.git/commitdiff
Probe machine types from kvm binary too
authorMark McLoughlin <markmc@redhat.com>
Mon, 7 Sep 2009 11:52:12 +0000 (12:52 +0100)
committerMark McLoughlin <markmc@redhat.com>
Thu, 10 Sep 2009 11:37:42 +0000 (12:37 +0100)
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

index 0d498c2ed6c195a0f3b193dffef0168c63009eb4..ddf7348e641749d25ea744c1b0561abdc0a7fd64 100644 (file)
@@ -710,14 +710,48 @@ qemudCapsInitGuest(virCapsPtr caps,
                                           NULL) == NULL)
             return -1;
 
-        if (haskvm &&
-            virCapabilitiesAddGuestDomain(guest,
-                                          "kvm",
-                                          kvmbin,
-                                          NULL,
-                                          0,
-                                          NULL) == NULL)
-            return -1;
+        if (haskvm) {
+            virCapsGuestDomainPtr dom;
+
+            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;
+            }
+
+            machines = NULL;
+            nmachines = 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 ((dom = 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;
+            }
+
+            dom->info.emulator_mtime = binary_mtime;
+        }
     } else {
         if (virCapabilitiesAddGuestDomain(guest,
                                           "kvm",