diff mbox series

tools/libs/ctrl: fix dumping of ballooned guest

Message ID 20201020085143.21303-1-jgross@suse.com (mailing list archive)
State Superseded
Headers show
Series tools/libs/ctrl: fix dumping of ballooned guest | expand

Commit Message

Jürgen Groß Oct. 20, 2020, 8:51 a.m. UTC
A guest with memory < maxmem can't be dumped via xl dump-core without
an error message today:

xc: info: exceeded nr_pages (262144) losing pages

In case the last page of the guest isn't allocated the loop in
xc_domain_dumpcore_via_callback() will always spit out this message,
as the number of already dumped pages is tested before the next page
is checked to be valid.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
Unfortunately this patch isn't a complete fix, while I believe it is
needed. There is still a mismatch of exactly 1 page. I have no idea
where this could come from.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/libs/ctrl/xc_core.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/tools/libs/ctrl/xc_core.c b/tools/libs/ctrl/xc_core.c
index e8c6fb96f9..d83e3726b6 100644
--- a/tools/libs/ctrl/xc_core.c
+++ b/tools/libs/ctrl/xc_core.c
@@ -818,16 +818,6 @@  xc_domain_dumpcore_via_callback(xc_interface *xch,
         {
             uint64_t gmfn;
             void *vaddr;
-            
-            if ( j >= nr_pages )
-            {
-                /*
-                 * When live dump-mode (-L option) is specified,
-                 * guest domain may increase memory.
-                 */
-                IPRINTF("exceeded nr_pages (%ld) losing pages", nr_pages);
-                goto copy_done;
-            }
 
             if ( !auto_translated_physmap )
             {
@@ -847,6 +837,12 @@  xc_domain_dumpcore_via_callback(xc_interface *xch,
                        continue;
                 }
 
+                if ( j >= nr_pages )
+                {
+                    j++;
+                    continue;
+                }
+
                 p2m_array[j].pfn = i;
                 p2m_array[j].gmfn = gmfn;
             }
@@ -855,6 +851,12 @@  xc_domain_dumpcore_via_callback(xc_interface *xch,
                 if ( !xc_core_arch_gpfn_may_present(&arch_ctxt, i) )
                     continue;
 
+                if ( j >= nr_pages )
+                {
+                    j++;
+                    continue;
+                }
+
                 gmfn = i;
                 pfn_array[j] = i;
             }
@@ -879,7 +881,15 @@  xc_domain_dumpcore_via_callback(xc_interface *xch,
         }
     }
 
-copy_done:
+    if ( j > nr_pages )
+    {
+        /*
+         * When live dump-mode (-L option) is specified,
+         * guest domain may increase memory.
+         */
+        IPRINTF("exceeded nr_pages (%ld) losing %ld pages", nr_pages, j - nr_pages);
+    }
+
     sts = dump_rtn(xch, args, dump_mem_start, dump_mem - dump_mem_start);
     if ( sts != 0 )
         goto out;