aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2012-03-02 17:47:16 -0700
committerEric Blake <eblake@redhat.com>2012-03-07 18:24:43 -0700
commit73b9977140272cbfd1d5386bb3880419be87a346 (patch)
tree76405fd1e86fe5a12c7d88655ef36dd028c32e38 /src/test
parentxml: drop unenforced minimum memory limit from RNG (diff)
downloadlibvirt-73b9977140272cbfd1d5386bb3880419be87a346.tar.gz
libvirt-73b9977140272cbfd1d5386bb3880419be87a346.tar.bz2
libvirt-73b9977140272cbfd1d5386bb3880419be87a346.zip
xml: use long long internally, to centralize overflow checks
On 64-bit platforms, unsigned long and unsigned long long are identical, so we don't have to worry about overflow checks. On 32-bit platforms, anywhere we narrow unsigned long long back to unsigned long, we have to worry about overflow; it's easier to do this in one place by having most of the code use the same or wider types, and only doing the narrowing at the last minute. Therefore, the memory set commands remain unsigned long, and the memory get command now centralizes the overflow check into libvirt.c, so that drivers don't have to repeat the work. This also fixes a bug where xen returned the wrong value on failure (most APIs return -1 on failure, but getMaxMemory must return 0 on failure). * src/driver.h (virDrvDomainGetMaxMemory): Use long long. * src/libvirt.c (virDomainGetMaxMemory): Raise overflow. * src/test/test_driver.c (testGetMaxMemory): Fix driver. * src/rpc/gendispatch.pl (name_to_ProcName): Likewise. * src/xen/xen_hypervisor.c (xenHypervisorGetMaxMemory): Likewise. * src/xen/xen_driver.c (xenUnifiedDomainGetMaxMemory): Likewise. * src/xen/xend_internal.c (xenDaemonDomainGetMaxMemory): Likewise. * src/xen/xend_internal.h (xenDaemonDomainGetMaxMemory): Likewise. * src/xen/xm_internal.c (xenXMDomainGetMaxMemory): Likewise. * src/xen/xm_internal.h (xenXMDomainGetMaxMemory): Likewise. * src/xen/xs_internal.c (xenStoreDomainGetMaxMemory): Likewise. * src/xen/xs_internal.h (xenStoreDomainGetMaxMemory): Likewise. * src/xenapi/xenapi_driver.c (xenapiDomainGetMaxMemory): Likewise. * src/esx/esx_driver.c (esxDomainGetMaxMemory): Likewise. * src/libxl/libxl_driver.c (libxlDomainGetMaxMemory): Likewise. * src/qemu/qemu_driver.c (qemudDomainGetMaxMemory): Likewise. * src/lxc/lxc_driver.c (lxcDomainGetMaxMemory): Likewise. * src/uml/uml_driver.c (umlDomainGetMaxMemory): Likewise.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test_driver.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 39fd63dea..f03b2fdcc 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2021,10 +2021,10 @@ static char *testGetOSType(virDomainPtr dom ATTRIBUTE_UNUSED) {
return ret;
}
-static unsigned long testGetMaxMemory(virDomainPtr domain) {
+static unsigned long long testGetMaxMemory(virDomainPtr domain) {
testConnPtr privconn = domain->conn->privateData;
virDomainObjPtr privdom;
- unsigned long ret = 0;
+ unsigned long long ret = 0;
testDriverLock(privconn);
privdom = virDomainFindByName(&privconn->domains,