From: "Christoph Egger" Subject: [PATCH][TOOLS] libxc: make error path more verbose Date: Tue, 13 Nov 2007 14:50:15 +0100 Message-ID: <200711131450.15446.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_XuaOH+G72MfIspg" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_XuaOH+G72MfIspg Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi! Attached patch makes qemu's output more verbose on failures. Signed-off-by: Christoph Egger The qemu process seems to leak memory by performing more mmap() calls than= =20 munmap()'s. When a HVM guest with a 12GB image runs fsck, then the guest=20 window disappears when the qemu process dies. Then /var/log/qemu-dm-.log shows this: I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0 xc_map_foreign_batch error 12 With the attached patch you see this: I/O request not ready: 0, ptr: 0, port: 0, data: 0, count: 0, size: 0 xc_map_foreign_batch: mmap failed: Cannot allocate memory xc_map_foreign_batch error 12 =46or short: The patch makes it easier to figure out when you triggered the resource exhausting bug. =2D-=20 AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Gesch=E4ftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplement=E4r: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Gesch=E4ftsf=FChrer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy --Boundary-00=_XuaOH+G72MfIspg Content-Type: text/plain; charset=us-ascii; name=tools_libxc.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=tools_libxc.diff diff -r dfca1120813f tools/libxc/xc_linux.c --- a/tools/libxc/xc_linux.c Sun Nov 11 18:28:57 2007 +0000 +++ b/tools/libxc/xc_linux.c Tue Nov 13 16:46:35 2007 +0100 @@ -67,8 +67,10 @@ void *xc_map_foreign_batch(int xc_handle privcmd_mmapbatch_t ioctlx; void *addr; addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0); - if ( addr == MAP_FAILED ) - return NULL; + if ( addr == MAP_FAILED ) { + perror("xc_map_foreign_batch: mmap failed"); + return NULL; + } ioctlx.num=num; ioctlx.dom=dom; @@ -77,7 +79,7 @@ void *xc_map_foreign_batch(int xc_handle if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 ) { int saved_errno = errno; - perror("XXXXXXXX"); + perror("xc_map_foreign_batch: ioctl failed"); (void)munmap(addr, num*PAGE_SIZE); errno = saved_errno; return NULL; @@ -94,8 +96,10 @@ void *xc_map_foreign_range(int xc_handle privcmd_mmap_entry_t entry; void *addr; addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0); - if ( addr == MAP_FAILED ) - return NULL; + if ( addr == MAP_FAILED ) { + perror("xc_map_foreign_range: mmap failed"); + return NULL; + } ioctlx.num=1; ioctlx.dom=dom; @@ -106,6 +110,7 @@ void *xc_map_foreign_range(int xc_handle if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 ) { int saved_errno = errno; + perror("xc_map_foreign_range: ioctl failed"); (void)munmap(addr, size); errno = saved_errno; return NULL; @@ -402,6 +407,7 @@ void *xc_gnttab_map_grant_ref(int xcg_ha int saved_errno = errno; struct ioctl_gntdev_unmap_grant_ref unmap_grant; /* Unmap the driver slots used to store the grant information. */ + perror("xc_gnttab_map_grant_ref: mmap failed"); unmap_grant.index = map.index; unmap_grant.count = 1; ioctl(xcg_handle, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant); @@ -445,6 +451,7 @@ void *xc_gnttab_map_grant_refs(int xcg_h int saved_errno = errno; struct ioctl_gntdev_unmap_grant_ref unmap_grant; /* Unmap the driver slots used to store the grant information. */ + perror("xc_gnttab_map_grant_refs: mmap failed"); unmap_grant.index = map->index; unmap_grant.count = count; ioctl(xcg_handle, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant); diff -r dfca1120813f tools/libxc/xc_netbsd.c --- a/tools/libxc/xc_netbsd.c Sun Nov 11 18:28:57 2007 +0000 +++ b/tools/libxc/xc_netbsd.c Tue Nov 13 16:46:35 2007 +0100 @@ -63,8 +63,10 @@ void *xc_map_foreign_batch(int xc_handle privcmd_mmapbatch_t ioctlx; void *addr; addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0); - if ( addr == MAP_FAILED ) - return NULL; + if ( addr == MAP_FAILED ) { + perror("xc_map_foreign_batch: mmap failed"); + return NULL; + } ioctlx.num=num; ioctlx.dom=dom; @@ -73,7 +75,7 @@ void *xc_map_foreign_batch(int xc_handle if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 ) { int saved_errno = errno; - perror("XXXXXXXX"); + perror("xc_map_foreign_batch: ioctl failed"); (void)munmap(addr, num*PAGE_SIZE); errno = saved_errno; return NULL; @@ -90,8 +92,10 @@ void *xc_map_foreign_range(int xc_handle privcmd_mmap_entry_t entry; void *addr; addr = mmap(NULL, size, prot, MAP_ANON | MAP_SHARED, -1, 0); - if ( addr == MAP_FAILED ) - return NULL; + if ( addr == MAP_FAILED ) { + perror("xc_map_foreign_range: mmap failed"); + return NULL; + } ioctlx.num=1; ioctlx.dom=dom; @@ -102,6 +106,7 @@ void *xc_map_foreign_range(int xc_handle if ( ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx) < 0 ) { int saved_errno = errno; + perror("xc_map_foreign_range: ioctl failed"); (void)munmap(addr, size); errno = saved_errno; return NULL; --Boundary-00=_XuaOH+G72MfIspg Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_XuaOH+G72MfIspg--