stubdom: add live migration support
PATCH 1/1 stubdom: add live migration support
stubdom: add live migration support by having ioemu just notify the hypervisor about memory changes.
The impact on disk performance is typically making it from 71.5MBps down to 70.5Mbps during the live migration. The impact on network performance is actually even hard to measure.
tools/ioemu/target-i386-dm/exec-dm.c +13 -2
@@ -483,9 +483,11 @@ }#endif -void cpu_physical_memory_rw (target_phys_addr_t addr,uint8_t *buf, -int len,int is_write) +void cpu_physical_memory_rw (target_phys_addr_t _addr,uint8_t *buf, +int _len,int is_write) { +target_phys_addr_t addr = _addr; +int len = _len;int l, io_index;uint8_t *ptr;uint32_t val;
@@ -520,6 +522,7 @@ }else if ((ptr =phys_ram_addr (addr)) !=NULL ) {/* Writing to RAM */ memcpy_words (ptr, buf, l); +#ifndef CONFIG_STUBDOM if (logdirty_bitmap !=NULL ) {/* Record that we have dirtied this frame */ unsigned long pfn = addr >>TARGET_PAGE_BITS ;
@@ -531,6 +534,7 @@ |= 1UL << pfn % HOST_LONG_BITS; } } +#endif #ifdef __ia64__sync_icache (ptr, l);#endif
@@ -565,6 +569,13 @@ buf += l; addr += l; } + +#ifdef CONFIG_STUBDOM +if (logdirty_bitmap !=NULL ) +xc_hvm_modified_memory (xc_handle, domid, _addr >>TARGET_PAGE_BITS , + (_addr + _len +TARGET_PAGE_SIZE -1 ) >>TARGET_PAGE_BITS + - _addr >>TARGET_PAGE_BITS ); +#endif mapcache_unlock (); }
tools/ioemu/xenstore.c +4 -5
@@ -404,6 +404,10 @@/* No key yet: wait for the next watch */ return ; +#ifdef CONFIG_STUBDOM +/* We pass the writes to hypervisor */ + seg = (void *)1 ; +#else strncpy (key_terminated, key_ascii,16 );free (key_ascii); key = (key_t )strtoull (key_terminated,NULL ,16 );
@@ -419,11 +423,6 @@fprintf (logfile,"%s: key=%16.16llx size=%lu\n" , __FUNCTION__, (unsigned long long )key, logdirty_bitmap_size); -#ifdef CONFIG_STUBDOM -/* XXX we just can't use shm. */ -fprintf (logfile,"Log dirty is not implemented in stub domains!\n" ); -return ; -#else shmid =shmget (key,2 * logdirty_bitmap_size,S_IRUSR |S_IWUSR );if (shmid ==-1 ) { fprintf(logfile, "Log-dirty: shmget failed: segment %16.16llx "
tools/libxc/xc_misc.c +28 -0
@@ -267,6 +267,34 @@return rc; } +int xc_hvm_modified_memory ( +int xc_handle,domid_t dom,uint64_t first_pfn,uint64_t nr) +{ +DECLARE_HYPERCALL ; +struct xen_hvm_modified_memory arg; +int rc; + + hypercall.op = __HYPERVISOR_hvm_op; + hypercall.arg[0 ] = HVMOP_modified_memory; + hypercall.arg[1 ] = (unsigned long )&arg; + + arg.domid = dom; + arg.first_pfn = first_pfn; + arg.nr = nr; + +if ( (rc =lock_pages (&arg,sizeof (arg))) !=0 ) + { +PERROR ("Could not lock memory" ); +return rc; + } + + rc =do_xen_hypercall (xc_handle, &hypercall); + +unlock_pages (&arg,sizeof (arg)); + +return rc; +} +void *xc_map_foreign_pages (int xc_handle,uint32_t dom,int prot,const xen_pfn_t *arr,int num) {
tools/libxc/xenctrl.h +6 -0
@@ -929,6 +929,12 @@ uint64_t first_pfn, uint64_t nr, unsigned long *bitmap); +/* +* Notify that some pages got modified by the Device Model +*/ +int xc_hvm_modified_memory ( +int xc_handle,domid_t dom,uint64_t first_pfn,uint64_t nr); + typedef enum { XC_ERROR_NONE = 0, XC_INTERNAL_ERROR = 1,
xen/arch/ia64/vmx/vmx_hypercall.c +47 -0
53 lines not on this page · raw message
xen/arch/x86/hvm/hvm.c +58 -0
64 lines not on this page · raw message
xen/include/public/hvm/hvm_op.h +13 -0
@@ -92,6 +92,19 @@typedef struct xen_hvm_track_dirty_vram xen_hvm_track_dirty_vram_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_track_dirty_vram_t); +/* Notify that some pages got modified by the Device Model. */ +#define HVMOP_modified_memory 7 +struct xen_hvm_modified_memory { +/* Domain to be updated. */ +domid_t domid; +/* First pfn. */ +uint64_aligned_t first_pfn; +/* Number of pages. */ +uint64_aligned_t nr; +}; +typedef struct xen_hvm_modified_memory xen_hvm_modified_memory_t ; +DEFINE_XEN_GUEST_HANDLE (xen_hvm_modified_memory_t); +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */
Hello,
Quoted 2 lines · Samuel Thibault, le Fri 27 Jun 2008 19:40:45 +0100, a écrit :
stubdom: add live migration support by having ioemu just notify the hypervisor about memory changes.
Tim suggested to use the same approach when qemu is running in dom0, which permits to get rid of all the logdirty stuff between the saver, xenstore and qemu. That would imply dropping the init_qemu_maps and qemu_flip_buffer parameters of xenguest.h's xc_domain_save. Would that API change be acceptable?
Samuel
Quoted 11 lines · Samuel Thibault
Hello,
Quoted 2 lines · Samuel Thibault, le Fri 27 Jun 2008 19:40:45 +0100, a écrit :
stubdom: add live migration support by having ioemu just notify the hypervisor about memory changes.
Tim suggested to use the same approach when qemu is running in dom0, which permits to get rid of all the logdirty stuff between the saver, xenstore and qemu. That would imply dropping the
init_qemu_mapsandqemu_flip_bufferparameters of xenguest.h'sxc_domain_save. Would that API change be acceptable?
Yes, this struck me as a sensible cleanup when I saw this patch. Please make it so.
-- Keir