aboutsummaryrefslogtreecommitdiffstats
path: root/tools/internal
diff options
context:
space:
mode:
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-11-07 16:37:15 +0000
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>2003-11-07 16:37:15 +0000
commit51620845044bc2a79a36ee2ca62e111345cf31ab (patch)
tree2a1a5d95ca893ad39ffe33f39766d8d28edd7027 /tools/internal
parent4ab922b1a7e6e19c260799f56912bcedf51fa725 (diff)
downloadxen-51620845044bc2a79a36ee2ca62e111345cf31ab.tar.gz
xen-51620845044bc2a79a36ee2ca62e111345cf31ab.tar.bz2
xen-51620845044bc2a79a36ee2ca62e111345cf31ab.zip
bitkeeper revision 1.572 (3fabca3boPogE8eX_8H6P5qlR4SCEQ)
memory.c, xi_save_linux.c, xi_restore_linux.c: Moire fixes. Save/restore now works.
Diffstat (limited to 'tools/internal')
-rw-r--r--tools/internal/xi_restore_linux.c39
-rw-r--r--tools/internal/xi_save_linux.c20
2 files changed, 53 insertions, 6 deletions
diff --git a/tools/internal/xi_restore_linux.c b/tools/internal/xi_restore_linux.c
index bd42e62952..8ccd145d93 100644
--- a/tools/internal/xi_restore_linux.c
+++ b/tools/internal/xi_restore_linux.c
@@ -15,6 +15,13 @@ static char *argv0 = "internal_restore_linux";
/* A table mapping each PFN to its new MFN. */
static unsigned long *pfn_to_mfn_table;
+/* This may allow us to create a 'quiet' command-line option, if necessary. */
+#define verbose_printf(_f, _a...) \
+ do { \
+ printf( _f , ## _a ); \
+ fflush(stdout); \
+ } while ( 0 )
+
static int get_pfn_list(
int domain_id, unsigned long *pfn_buf, unsigned long max_pfns)
{
@@ -126,6 +133,7 @@ int main(int argc, char **argv)
dom0_op_t op;
int rc = 1, i, j;
unsigned long mfn, pfn, dom = 0;
+ unsigned int prev_pc, this_pc;
/* Number of page frames in use by this XenoLinux session. */
unsigned long nr_pfns;
@@ -256,12 +264,22 @@ int main(int argc, char **argv)
goto out;
}
+ verbose_printf("Reloading memory pages: 0%%");
+
/*
* Now simply read each saved frame into its new machine frame.
* We uncanonicalise page tables as we go.
*/
+ prev_pc = 0;
for ( i = 0; i < nr_pfns; i++ )
{
+ this_pc = (i * 100) / nr_pfns;
+ if ( (this_pc - prev_pc) >= 5 )
+ {
+ verbose_printf("\b\b\b\b%3d%%", this_pc);
+ prev_pc = this_pc;
+ }
+
mfn = pfn_to_mfn_table[i];
if ( !checked_read(fd, page, PAGE_SIZE) )
@@ -348,6 +366,8 @@ int main(int argc, char **argv)
if ( flush_mmu_updates() )
goto out;
+ verbose_printf("\b\b\b\b100%%\nMemory reloaded.\n");
+
/* Uncanonicalise the suspend-record frame number and poke resume rec. */
pfn = ctxt.i386_ctxt.esi;
if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NONE) )
@@ -446,13 +466,20 @@ int main(int argc, char **argv)
rc = do_dom0_op(&op);
out:
- /* If we experience an error then kill the half-constructed domain. */
- if ( (rc != 0) && (dom != 0) )
+ if ( rc != 0 )
+ {
+ if ( dom != 0 )
+ {
+ op.cmd = DOM0_DESTROYDOMAIN;
+ op.u.destroydomain.domain = dom;
+ op.u.destroydomain.force = 1;
+ (void)do_dom0_op(&op);
+ }
+ }
+ else
{
- op.cmd = DOM0_DESTROYDOMAIN;
- op.u.destroydomain.domain = dom;
- op.u.destroydomain.force = 1;
- (void)do_dom0_op(&op);
+ /* Success: print the domain id. */
+ printf("DOM=%ld\n", dom);
}
return !!rc;
diff --git a/tools/internal/xi_save_linux.c b/tools/internal/xi_save_linux.c
index 54d0a40550..bbefaa1fb3 100644
--- a/tools/internal/xi_save_linux.c
+++ b/tools/internal/xi_save_linux.c
@@ -17,6 +17,13 @@ static unsigned long *pfn_to_mfn_table;
/* A table mapping each current MFN to its canonical PFN. */
static unsigned long *mfn_to_pfn_table;
+/* This may allow us to create a 'quiet' command-line option, if necessary. */
+#define verbose_printf(_f, _a...) \
+ do { \
+ printf( _f , ## _a ); \
+ fflush(stdout); \
+ } while ( 0 )
+
static int devmem_fd;
static int init_pfn_mapper(void)
@@ -100,6 +107,7 @@ int main(int argc, char **argv)
dom0_op_t op;
int rc = 1, i, j;
unsigned long mfn, dom;
+ unsigned int prev_pc, this_pc;
/* Remember if we stopped the guest, so we can restart it on exit. */
int we_stopped_it = 0;
@@ -319,9 +327,19 @@ int main(int argc, char **argv)
}
unmap_pfn(ppage);
+ verbose_printf("Saving memory pages: 0%%");
+
/* Now write out each data page, canonicalising page tables as we go... */
+ prev_pc = 0;
for ( i = 0; i < srec.nr_pfns; i++ )
{
+ this_pc = (i * 100) / srec.nr_pfns;
+ if ( (this_pc - prev_pc) >= 5 )
+ {
+ verbose_printf("\b\b\b\b%3d%%", this_pc);
+ prev_pc = this_pc;
+ }
+
mfn = pfn_to_mfn_table[i];
ppage = map_pfn(mfn);
@@ -354,6 +372,8 @@ int main(int argc, char **argv)
}
}
+ verbose_printf("\b\b\b\b100%%\nMemory saved.\n");
+
/* Success! */
rc = 0;