]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Always format CPU topology
authorJiri Denemark <jdenemar@redhat.com>
Tue, 16 Oct 2012 19:11:29 +0000 (21:11 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 18 Oct 2012 12:57:08 +0000 (14:57 +0200)
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.

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

index 985d4def3ba1a3e3b930ef7125e8934aec134930..7c391b32ea3d4c74074d8712a7d2ad58a7d06b8b 100644 (file)
@@ -685,6 +685,7 @@ qemuCapsInitGuest(virCapsPtr caps,
     nmachines = 0;
 
     if (caps->host.cpu &&
+        caps->host.cpu->model &&
         qemuCapsGetCPUDefinitions(qemubinCaps, NULL) > 0 &&
         !virCapabilitiesAddGuestFeature(guest, "cpuselection", 1, 0))
         goto error;
@@ -781,12 +782,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 9c72c10a9a53109606803d532062c909a647adac..9096b3c6da72d4d35ecc1a01aeb276b302a22b41 100644 (file)
@@ -4100,6 +4100,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
         int hasSVM;
 
         if (!host ||
+            !host->model ||
             (ncpus = qemuCapsGetCPUDefinitions(caps, &cpus)) == 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                            _("CPU specification not supported by hypervisor"));
index 427258d4a589ea5b4813329c1f7b5273d7737cd6..cbc621f1a00d1590c4e6cc9b6c8f314a52711187 100644 (file)
@@ -1227,7 +1227,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 adfbfa6acf0d3d3fb776a8feca407f1baf341c48..76730c66d165d3719e6a270d0e14f12527f4f481 100644 (file)
@@ -10180,7 +10180,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 {