]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Always format CPU topology
authorJiri Denemark <jdenemar@redhat.com>
Tue, 16 Oct 2012 19:11:29 +0000 (21:11 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 13 Nov 2012 15:19:46 +0000 (16:19 +0100)
When libvirt cannot find a suitable CPU model for host CPU (easily
reproducible by running libvirt in a guest), it would not provide CPU
topology in capabilities XML either. Even though CPU topology is known
and can be queried by virNodeGetInfo. With this patch, CPU topology will
always be provided in capabilities XML regardless on the presence of CPU
model.
(cherry picked from commit f1c70100409562c3f402392aa667732e5f89a2c4)

Conflicts:

    src/qemu/qemu_capabilities.c
    src/qemu/qemu_command.c

    The new code uses capabilities caching.

src/qemu/qemu_capabilities.c
src/qemu/qemu_domain.c
src/qemu/qemu_driver.c

index 37f1a2b1fc4295b8920b917c453d1b0dd373cb2e..b1ef1b98fb9c7e76b71cc6e07273a31ec1e5bfce 100644 (file)
@@ -844,6 +844,7 @@ qemuCapsInitGuest(virCapsPtr caps,
     guest->arch.defaultInfo.emulator_mtime = binary_mtime;
 
     if (caps->host.cpu &&
+        caps->host.cpu->model &&
         qemuCapsProbeCPUModels(binary, NULL, info->arch, &ncpus, NULL) == 0 &&
         ncpus > 0 &&
         !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
@@ -973,12 +974,11 @@ qemuCapsInitCPU(virCapsPtr caps,
     cpu->sockets = nodeinfo.sockets;
     cpu->cores = nodeinfo.cores;
     cpu->threads = nodeinfo.threads;
+    caps->host.cpu = cpu;
 
     if (!(data = cpuNodeData(arch))
         || cpuDecode(cpu, data, NULL, 0, NULL) < 0)
-        goto error;
-
-    caps->host.cpu = cpu;
+        goto cleanup;
 
     ret = 0;
 
index 17ae3b9297bd03e7532ff575d43d681bd84521c6..e23ff11879155442859f9a9c62a6d812b71705d4 100644 (file)
@@ -1233,7 +1233,9 @@ qemuDomainDefFormatBuf(struct qemud_driver *driver,
     if ((flags & VIR_DOMAIN_XML_UPDATE_CPU) &&
         def_cpu &&
         (def_cpu->mode != VIR_CPU_MODE_CUSTOM || def_cpu->model)) {
-        if (!driver->caps || !driver->caps->host.cpu) {
+        if (!driver->caps ||
+            !driver->caps->host.cpu ||
+            !driver->caps->host.cpu->model) {
             virReportError(VIR_ERR_OPERATION_FAILED,
                            "%s", _("cannot get host CPU capabilities"));
             goto cleanup;
index 0258dbbfb960f742551052970c22f5ccc88aa82f..c1c8fa4fef7f4719315944003d4435d470a0b6db 100644 (file)
@@ -10083,7 +10083,8 @@ qemuCPUCompare(virConnectPtr conn,
     if (!driver->caps) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("cannot get host capabilities"));
-    } else if (!driver->caps->host.cpu) {
+    } else if (!driver->caps->host.cpu ||
+               !driver->caps->host.cpu->model) {
         VIR_WARN("cannot get host CPU capabilities");
         ret = VIR_CPU_COMPARE_INCOMPATIBLE;
     } else {