HVM save/restore clean up: change max_pfn format
PATCH 3/4 HVM save/restore clean up: change max_pfn format
[PATCH 3/4] HVM save/restore clean up: change max_pfn format
Signed-off-by Zhai Edwin <[email protected]>
change from unsigned long to int for 32 guest saved on 64 and restore on 32 in future. seems 2^32 pages is big enough.
tools/libxc/ia64/xc_ia64_linux_save.c +1 -1
@@ -223,7 +223,7 @@ xc_linux_save(int xc_handle, int io_fd, }/* This is expected by xm restore. */ -if (!write_exact (io_fd, &max_pfn,sizeof (unsigned long ))) { +if (!write_exact (io_fd, &max_pfn,sizeof (unsigned int ))) {ERROR ("write: max_pfn" ); goto out; }
tools/libxc/xc_hvm_save.c +1 -1
@@ -468,7 +468,7 @@ int xc_hvm_save(int xc_handle, int io_fd }/* Start writing out the saved-domain record. */ -if (!write_exact (io_fd, &max_pfn,sizeof (unsigned long ))) { +if (!write_exact (io_fd, &max_pfn,sizeof (unsigned int ))) {ERROR ("write: max_pfn" ); goto out; }
tools/libxc/xc_linux_save.c +1 -1
@@ -822,7 +822,7 @@ int xc_linux_save(int xc_handle, int io_/* Start writing out the saved-domain record. */ -if (!write_exact (io_fd, &max_pfn,sizeof (unsigned long ))) { +if (!write_exact (io_fd, &max_pfn,sizeof (unsigned int ))) {ERROR ("write: max_pfn" ); goto out; }
tools/python/xen/xend/XendCheckpoint.py +6 -11
@@ -189,24 +189,19 @@ def restore(xd, fd, dominfo = None, paus dominfo.domid, hvm, apic, pae) try: - if hvm: - l = read_exact(fd, sizeof_unsigned_int, - "not a valid hvm guest state file: pfn count read") - nr_pfns = unpack("I", l)[0] # native sizeof int - else: - l = read_exact(fd, sizeof_unsigned_long, - "not a valid guest state file: pfn count read") - - max_pfn = unpack("L", l)[0] # native sizeof long + l = read_exact(fd, sizeof_unsigned_int, + "not a valid hvm guest state file: pfn count read") + max_pfn = unpack("I", l)[0] # native sizeof int + if max_pfn > 16*1024*1024: # XXX raise XendError( "not a valid guest state file: pfn count out of range") shadow = dominfo.info['shadow_memory'] log.debug("restore:shadow=0x%x, _static_max=0x%x, _static_min=0x%x, " - "nr_pfns=0x%x.", dominfo.info['shadow_memory'], + "nr_pfns=0x%x, max_pfn=0x%x.", dominfo.info['shadow_memory'], dominfo.info['memory_static_max'], - dominfo.info['memory_static_min'], nr_pfns) + dominfo.info['memory_static_min'], nr_pfns, max_pfn) balloon.free(xc.pages_to_kib(nr_pfns) + shadow * 1024)