
On 08/19/2016 02:33 PM, John Ferlan wrote:
[...]
+/** + * qemuMonitorGetCPUInfoHotplug: + * + * This function stitches together data retrieved via query-hotpluggable-cpus + * which returns entities on the hotpluggable level (which may describe more + * than one guest logical vcpu) with the output of query-cpus, having an entry + * per enabled guest logical vcpu. + * + * query-hotpluggable-cpus conveys following information: + * - topology information and number of logical vcpus this entry creates + * - device type name of the entry that needs to be used when hotplugging + * - qom path in qemu which can be used to map the entry against query-cpus + * + * query-cpus conveys following information: + * - thread id of a given guest logical vcpu + * - order in which the vcpus were inserted + * - qom path to allow mapping the two together + * + * The libvirt's internal structure has an entry for each possible (even + * disabled) guest vcpu. The purpose is to map the data together so that we are + * certain of the thread id mapping and the information required for vcpu + * hotplug. + * + * This function returns 0 on success and -1 on error, but does not report + * libvirt errors so that fallback approach can be used. + */ +static int +qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotplugvcpus, + size_t nhotplugvcpus, + struct qemuMonitorQueryCpusEntry *cpuentries, + size_t ncpuentries, + qemuMonitorCPUInfoPtr vcpus, + size_t maxvcpus) +{ + int order = 1; + size_t totalvcpus = 0; + size_t i; + size_t j; + + /* ensure that the total vcpu count reported by query-hotpluggable-cpus equals + * to the libvirt maximum cpu count */ + for (i = 0; i < nhotplugvcpus; i++) + totalvcpus += hotplugvcpus[i].vcpus; + + if (totalvcpus != maxvcpus) { + VIR_DEBUG("expected '%zu' total vcpus got '%zu'", maxvcpus, totalvcpus); + return -1; + }
Still trying to come to grips with 'nhotplugvcpus', 'ncpuentries', and 'maxvcpus'
+ + /* Note the order in which the hotpluggable entities are inserted by + * matching them to the query-cpus entries */ + for (i = 0; i < ncpuentries; i++) { + for (j = 0; j < nhotplugvcpus; j++) { + if (!cpuentries[i].qom_path || + !hotplugvcpus[j].qom_path || + !STRPREFIX(cpuentries[i].qom_path, hotplugvcpus[j].qom_path)) + continue; + + /* add ordering info for hotpluggable entries */ + if (hotplugvcpus[j].enable_id == 0) + hotplugvcpus[j].enable_id = order++; + + break;
So enable_id always == 1 (or 0 I supposed) and order never gets beyond 2? Or am I missing something not obvious.
UGH - face palm Friday... break the inner loop. John
I guess I thought you were trying to figure out the order of nhotplugvcpus so that you could fill in vcpus in the correct order, but that doesn't match the subsequent algorithm.
John
+ } + } + [...]