dagwieers / vmguestlib

Python API for interacting with VMware's VMGuestLib SDK
GNU General Public License v2.0
28 stars 12 forks source link

Segmentation fault on Ubuntu 18.04 #7

Closed arvan-pritchard closed 4 years ago

arvan-pritchard commented 6 years ago

If I work around the ctypes dependency issue to install on Ubuntu 18.04 I get a Segmentation fault when I try to use vmguestlib:

$ git clone git://github.com/dagwieers/vmguestlib
$ cd vmguestlib/
$ vi setup.py 
$ sudo python setup.py install
< output omitted...>
$ python
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import vmguestlib
>>> gl = vmguestlib.VMGuestLib()
Segmentation fault

The edit was

$ git diff
diff --git a/setup.py b/setup.py
index 6ee9ea4..ab6e73c 100755
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,6 @@ if __name__ == '__main__':
         download_url='http://github.com/dagwieers/vmguestlib/archive/0.1.2.tar.gz',
         description='Python API for interacting with VMware\'s VMGuestLib SDK',
         license = 'GPLv2',
-        install_requires=['ctypes', ],
         py_modules = ['vmguestlib', ],
         scripts=[ 'vmguest-stats', ],
         keywords = ['Virtual', 'vmware', 'ESX', 'ESXi', 'VMGuestLib', 'SDK', 'API'],
adiospeds commented 5 years ago

More Updates on the issue:

I get that its coming from line nu 149 (actually line nu 146 - i had added a few lines for debugging)

root@foreman-test-sc-01:~/vmguestlib# python -i vmguestlib.py
>>> VMGuestLib()
Fatal Python error: Segmentation fault

Current thread 0x00007f182d13a740 <python> (most recent call first):
  File "vmguestlib.py", line 149 in UpdateInfo
  File "vmguestlib.py", line 100 in __init__
  File "<stdin>", line 1 in <module>
Segmentation fault

We wrote a script to reproduce the same with a smaller example(saved as sampa.py) :

from ctypes import CDLL, c_void_p, byref
from ctypes.util import find_library

lib = CDLL(find_library('guestlib'))
handle = c_void_p()
ret = lib.VMGuestLib_OpenHandle(byref(handle))
if ret != 0:
    raise RuntimeError("failed to get handle")
ret = lib.VMGuestLib_UpdateInfo(handle.value)
if ret != 0:
    raise RuntimeError("unable to update guest information")

After running minimal failing example of same issue (saved as sampa.py), I ran lldb and attached to the pid of the process, then with pdb on other terminal I was able to debug one line at a time and I found that when the ret = lib.VMGuestLib_UpdateInfo(handle.value) line executes >>> lldb throws:

* thread #1, name = 'python', stop reason = signal SIGSEGV: invalid address (fault address: 0x69da8c80)
    frame #0: 0x00007ff897c75f12 libguestlib.so.0`VMGuestLib_UpdateInfo + 50

Just incase this helps:

lldb
(lldb) attach --pid 25613
Process 25613 stopped
* thread #1, name = 'python', stop reason = signal SIGSTOP
    frame #0: 0x00007ff89a7a0081 libc.so.6`__GI___libc_read(fd=0, buf=0x00007ff8984c1c34, nbytes=1) at read.c:27

Executable module set to "/usr/bin/python2.7".
Architecture set to: x86_64-pc-linux.
(lldb) continue
Process 25613 resuming
Process 25613 stopped and restarted: thread 1 received signal: SIGCHLD
Process 25613 stopped
* thread #1, name = 'python', stop reason = signal SIGSEGV: invalid address (fault address: 0x69da8c80)
    frame #0: 0x00007ff897c75f12 libguestlib.so.0`VMGuestLib_UpdateInfo + 50
libguestlib.so.0`VMGuestLib_UpdateInfo:
->  0x7ff897c75f12 <+50>: movl   (%rdi), %eax
    0x7ff897c75f14 <+52>: movl   $0x3, %edx
    0x7ff897c75f19 <+57>: leaq   0x60(%rsp), %rbx
    0x7ff897c75f1e <+62>: leaq   0x28(%rsp), %r13
(lldb) n
Process 25613 exited with status = 11 (0x0000000b)

python -i sampa.py
[0] > /root/sampa.py(7)<module>()
-> lib = CDLL(find_library('guestlib'))
(Pdb++) n
[0] > /root/sampa.py(8)<module>()
-> handle = c_void_p()
(Pdb++) n
[0] > /root/sampa.py(9)<module>()
-> ret = lib.VMGuestLib_OpenHandle(byref(handle))
(Pdb++) n
[0] > /root/sampa.py(10)<module>()
-> if ret != 0:
(Pdb++) n
[0] > /root/sampa.py(12)<module>()
-> ret = lib.VMGuestLib_UpdateInfo(handle.value)
(Pdb++) n
Segmentation fault
john275 commented 4 years ago

Seem to have also hit this issue :

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff5e9bf12 in VMGuestLib_UpdateInfo () from /usr/lib/libguestlib.so.0
(gdb) backtrace
#0  0x00007ffff5e9bf12 in VMGuestLib_UpdateInfo () from /usr/lib/libguestlib.so.0
#1  0x00007ffff67f6dae in ffi_call_unix64 () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#2  0x00007ffff67f671f in ffi_call () from /usr/lib/x86_64-linux-gnu/libffi.so.6
#3  0x00007ffff6a09b04 in _ctypes_callproc () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#4  0x00007ffff6a09505 in ?? () from /usr/lib/python2.7/lib-dynload/_ctypes.x86_64-linux-gnu.so
#5  0x000055555564ee30 in PyEval_EvalFrameEx ()
#6  0x000055555564ebe2 in PyEval_EvalFrameEx ()
#7  0x000055555564752a in PyEval_EvalCodeEx ()
#8  0x0000555555662d99 in ?? ()
#9  0x000055555567b95e in ?? ()
#10 0x000055555567b56a in ?? ()
#11 0x000055555563805b in ?? ()
#12 0x000055555564ee30 in PyEval_EvalFrameEx ()
#13 0x000055555564752a in PyEval_EvalCodeEx ()
#14 0x0000555555646fb9 in PyEval_EvalCode ()
#15 0x0000555555677e7f in ?? ()
#16 0x0000555555672c12 in PyRun_FileExFlags ()
#17 0x000055555567209d in PyRun_SimpleFileExFlags ()
#18 0x0000555555620d6b in Py_Main ()
#19 0x00007ffff7a05b97 in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#20 0x00005555556205ea in _start ()
(gdb)
jepio commented 4 years ago

I found the cause: without declared argtypes, ctypes converts numerical arguments to int. The segfault is caused by pointer to int trucation. self.handle.value needs to be replaced with self.handle for the handle to be passed correctly. Here's a full patch:

diff --git a/vmguestlib.py b/vmguestlib.py
index 24b42c8..8f34ce6 100644
--- a/vmguestlib.py
+++ b/vmguestlib.py
@@ -128,7 +128,7 @@ class VMGuestLib(Structure):
     def CloseHandle(self):
         '''Releases a handle acquired with VMGuestLib_OpenHandle'''
         if hasattr(self, 'handle'):
-            ret = vmGuestLib.VMGuestLib_CloseHandle(self.handle.value)
+            ret = vmGuestLib.VMGuestLib_CloseHandle(self.handle)
             if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
             del(self.handle)

@@ -143,7 +143,7 @@ class VMGuestLib(Structure):
            If your program uses multiple threads, each thread must use a different handle.
            Otherwise, you must implement a locking scheme around update calls. The vSphere
            Guest API does not implement internal locking around access with a handle.'''
-        ret = vmGuestLib.VMGuestLib_UpdateInfo(self.handle.value)
+        ret = vmGuestLib.VMGuestLib_UpdateInfo(self.handle)
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)

     def GetSessionId(self):
@@ -151,7 +151,7 @@ class VMGuestLib(Structure):
            VMGuestLib_UpdateInfo. If VMGuestLib_UpdateInfo has never been called,
            VMGuestLib_GetSessionId returns VMGUESTLIB_ERROR_NO_INFO.'''
         sid = c_void_p()
-        ret = vmGuestLib.VMGuestLib_GetSessionId(self.handle.value, byref(sid))
+        ret = vmGuestLib.VMGuestLib_GetSessionId(self.handle, byref(sid))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return sid

@@ -160,7 +160,7 @@ class VMGuestLib(Structure):
            machine. For information about setting the CPU limit, see "Limits and
            Reservations" on page 14.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetCpuLimitMHz(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetCpuLimitMHz(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -169,7 +169,7 @@ class VMGuestLib(Structure):
            machine. For information about setting a CPU reservation, see "Limits and
            Reservations" on page 14.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetCpuReservationMHz(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetCpuReservationMHz(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -178,7 +178,7 @@ class VMGuestLib(Structure):
            information about how an ESX server uses CPU shares to manage virtual
            machine priority, see the vSphere Resource Management Guide.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetCpuShares(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetCpuShares(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -186,7 +186,7 @@ class VMGuestLib(Structure):
         '''Retrieves the number of milliseconds that the virtual machine was in a
            ready state (able to transition to a run state), but was not scheduled to run.'''
         counter = c_uint64()
-        ret = vmGuestLib.VMGuestLib_GetCpuStolenMs(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetCpuStolenMs(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -198,7 +198,7 @@ class VMGuestLib(Structure):
            (VMGuestLib_GetElapsedMs) to estimate the effective virtual machine
            CPU speed. This value is a subset of elapsedMs.'''
         counter = c_uint64()
-        ret = vmGuestLib.VMGuestLib_GetCpuUsedMs(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetCpuUsedMs(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -213,7 +213,7 @@ class VMGuestLib(Structure):
            (VMGuestLib_GetCpuUsedMs) to estimate the effective virtual machine
            CPU speed. cpuUsedMs is a subset of this value.'''
         counter = c_uint64()
-        ret = vmGuestLib.VMGuestLib_GetElapsedMs(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetElapsedMs(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -221,7 +221,7 @@ class VMGuestLib(Structure):
     def GetHostCpuUsedMs(self):
         '''Undocumented.'''
         counter = c_uint64()
-        ret = vmGuestLib.VMGuestLib_GetHostCpuUsedMs(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostCpuUsedMs(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -229,7 +229,7 @@ class VMGuestLib(Structure):
     def GetHostMemKernOvhdMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemKernOvhdMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemKernOvhdMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -237,7 +237,7 @@ class VMGuestLib(Structure):
     def GetHostMemMappedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemMappedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemMappedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -245,7 +245,7 @@ class VMGuestLib(Structure):
     def GetHostMemPhysFreeMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemPhysFreeMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemPhysFreeMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -253,7 +253,7 @@ class VMGuestLib(Structure):
     def GetHostMemPhysMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemPhysMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemPhysMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -261,7 +261,7 @@ class VMGuestLib(Structure):
     def GetHostMemSharedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemSharedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemSharedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -269,7 +269,7 @@ class VMGuestLib(Structure):
     def GetHostMemSwappedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemSwappedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemSwappedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -277,7 +277,7 @@ class VMGuestLib(Structure):
     def GetHostMemUnmappedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemUnmappedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemUnmappedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -285,7 +285,7 @@ class VMGuestLib(Structure):
     def GetHostMemUsedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostMemUsedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostMemUsedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -293,14 +293,14 @@ class VMGuestLib(Structure):
     def GetHostNumCpuCores(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostNumCpuCores(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostNumCpuCores(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

     def GetHostProcessorSpeed(self):
         '''Retrieves the speed of the ESX system's physical CPU in MHz.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetHostProcessorSpeed(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetHostProcessorSpeed(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -308,7 +308,7 @@ class VMGuestLib(Structure):
         '''Retrieves the amount of memory the virtual machine is actively using its
            estimated working set size.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemActiveMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemActiveMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -317,7 +317,7 @@ class VMGuestLib(Structure):
            machine by the vSphere memory balloon driver (also referred to as the
            "vmmemctl" driver).'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemBalloonedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemBalloonedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -325,7 +325,7 @@ class VMGuestLib(Structure):
     def GetMemBalloonMaxMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemBalloonMaxMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemBalloonMaxMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -333,7 +333,7 @@ class VMGuestLib(Structure):
     def GetMemBalloonTargetMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemBalloonTargetMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemBalloonTargetMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -342,7 +342,7 @@ class VMGuestLib(Structure):
            machine. For information about setting a memory limit, see "Limits and
            Reservations" on page 14.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemLimitMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemLimitMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -350,7 +350,7 @@ class VMGuestLib(Structure):
     def GetMemLLSwappedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemLLSwappedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemLLSwappedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -359,7 +359,7 @@ class VMGuestLib(Structure):
            Memory that is ballooned, swapped, or has never been accessed is
            excluded.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemMappedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemMappedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -369,7 +369,7 @@ class VMGuestLib(Structure):
            memory is additional memory that is reserved for data structures required
            by the virtualization layer.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemOverheadMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemOverheadMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -378,7 +378,7 @@ class VMGuestLib(Structure):
            machine. For information about setting a memory reservation, see "Limits
            and Reservations" on page 14.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemReservationMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemReservationMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -386,7 +386,7 @@ class VMGuestLib(Structure):
         '''Retrieves the amount of physical memory associated with this virtual
            machine that is copy-on-write (COW) shared on the host.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemSharedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemSharedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -394,7 +394,7 @@ class VMGuestLib(Structure):
         '''Retrieves the estimated amount of physical memory on the host saved
            from copy-on-write (COW) shared guest physical memory.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemSharedSavedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemSharedSavedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -403,7 +403,7 @@ class VMGuestLib(Structure):
            For information about how an ESX server uses memory shares to manage
            virtual machine priority, see the vSphere Resource Management Guide.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemShares(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemShares(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -411,7 +411,7 @@ class VMGuestLib(Structure):
         '''Retrieves the amount of memory that has been reclaimed from this virtual
            machine by transparently swapping guest memory to disk.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemSwappedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemSwappedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -419,14 +419,14 @@ class VMGuestLib(Structure):
     def GetMemSwapTargetMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemSwapTargetMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemSwapTargetMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

     def GetMemTargetSizeMB(self):
         '''Retrieves the size of the target memory allocation for this virtual machine.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemTargetSizeMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemTargetSizeMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -434,7 +434,7 @@ class VMGuestLib(Structure):
         '''Retrieves the estimated amount of physical host memory currently
            consumed for this virtual machine's physical memory.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemUsedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemUsedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -442,7 +442,7 @@ class VMGuestLib(Structure):
     def GetMemZippedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemZippedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemZippedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

@@ -450,8 +450,8 @@ class VMGuestLib(Structure):
     def GetMemZipSavedMB(self):
         '''Undocumented.'''
         counter = c_uint()
-        ret = vmGuestLib.VMGuestLib_GetMemZipSavedMB(self.handle.value, byref(counter))
+        ret = vmGuestLib.VMGuestLib_GetMemZipSavedMB(self.handle, byref(counter))
         if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
         return counter.value

-# vim:ts=4:sw=4:et
\ No newline at end of file
+# vim:ts=4:sw=4:et
dagwieers commented 4 years ago

@jepio Thanks !