mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
xen: clean up the mess with cpumap
Commit8b55992f
added some Coverity comments to silence what was a real bug in the code. Since then, we've had a miserable run of trying to fix the underlying problem (commitsc059cde
andba5193c
), and still have a problem on 32-bit machines. This fixes the problem for once and for all, by realizing that on older xen, cpumap_t is identical to uint64_t, and using the new virendian.h to do the transformation from the API (documented to be little-endian) to the host structure. * src/xen/xen_hypervisor.c (virXen_setvcpumap): Do the conversion correctly. Finally.
This commit is contained in:
parent
731ad69240
commit
069b5c5a58
@ -80,6 +80,7 @@
|
|||||||
#include "virfile.h"
|
#include "virfile.h"
|
||||||
#include "virnodesuspend.h"
|
#include "virnodesuspend.h"
|
||||||
#include "virtypedparam.h"
|
#include "virtypedparam.h"
|
||||||
|
#include "virendian.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_XEN
|
#define VIR_FROM_THIS VIR_FROM_XEN
|
||||||
|
|
||||||
@ -1773,18 +1774,13 @@ virXen_setvcpumap(int handle,
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
} else {
|
} else {
|
||||||
cpumap_t xen_cpumap; /* limited to 64 CPUs in old hypervisors */
|
cpumap_t xen_cpumap; /* limited to 64 CPUs in old hypervisors */
|
||||||
uint64_t *pm = &xen_cpumap;
|
char buf[8] = "";
|
||||||
int j;
|
|
||||||
|
|
||||||
if ((maplen > (int)sizeof(cpumap_t)) || (sizeof(cpumap_t) & 7))
|
if (maplen > sizeof(cpumap_t) || sizeof(cpumap_t) != sizeof(uint64_t))
|
||||||
return -1;
|
return -1;
|
||||||
|
/* Supply trailing 0s if user's input array was short */
|
||||||
memset(&xen_cpumap, 0, sizeof(cpumap_t));
|
memcpy(buf, cpumap, maplen);
|
||||||
for (j = 0; j < maplen; j++) {
|
xen_cpumap = virReadBufInt64LE(buf);
|
||||||
if ((j & 7) == 0)
|
|
||||||
pm = (uint64_t *)((uint64_t)&xen_cpumap + (j & ~0x7UL));
|
|
||||||
*pm |= (uint64_t)cpumap[j] << (8 * (j & 7));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hv_versions.hypervisor == 1) {
|
if (hv_versions.hypervisor == 1) {
|
||||||
xen_op_v1 op;
|
xen_op_v1 op;
|
||||||
|
Loading…
Reference in New Issue
Block a user