[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] XendDomainInfo.py, XendDomain.py, xc.c, xc_linux_restore.c, xc.h:
ChangeSet 1.1488.1.1, 2005/05/20 20:25:46+01:00, cl349@xxxxxxxxxxxxxxxxxxxx XendDomainInfo.py, XendDomain.py, xc.c, xc_linux_restore.c, xc.h: Implement the parts of vm restore which need interaction with xend as part of xend, instead of using xfrd. The restore functionality using xfrd was broken anyway since xend didn't handle the callback channel from xfrd correctly. xen_domain.c: Disable restore in xfrd. Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx> libxc/xc.h | 3 libxc/xc_linux_restore.c | 281 ++++++++++++-------------------------- python/xen/lowlevel/xc/xc.c | 62 ++------ python/xen/xend/XendDomain.py | 71 ++++++++- python/xen/xend/XendDomainInfo.py | 7 xfrd/xen_domain.c | 2 6 files changed, 190 insertions(+), 236 deletions(-) diff -Nru a/tools/libxc/xc.h b/tools/libxc/xc.h --- a/tools/libxc/xc.h 2005-05-20 16:02:07 -04:00 +++ b/tools/libxc/xc.h 2005-05-20 16:02:07 -04:00 @@ -244,7 +244,8 @@ * @parm ioctxt the IO context to restore a domain from * @return 0 on success, -1 on failure */ -int xc_linux_restore(int xc_handle, struct XcIOContext *ioctxt); +int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns, + unsigned char *pfn2mfn); int xc_linux_build(int xc_handle, u32 domid, diff -Nru a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c --- a/tools/libxc/xc_linux_restore.c 2005-05-20 16:02:08 -04:00 +++ b/tools/libxc/xc_linux_restore.c 2005-05-20 16:02:08 -04:00 @@ -13,59 +13,34 @@ #define DEBUG 0 +#if 1 +#define ERR(_f, _a...) fprintf ( stderr, _f , ## _a ) +#else +#define ERR(_f, _a...) ((void)0) +#endif + #if DEBUG -#define DPRINTF(_f, _a...) printf ( _f , ## _a ) +#define DPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a ) #else #define DPRINTF(_f, _a...) ((void)0) #endif -/** Read the vmconfig string from the state input. - * It is stored as a 4-byte count 'n' followed by n bytes. - * The config data is stored in a new string in 'ioctxt->vmconfig', - * and is null-terminated. The count is stored in 'ioctxt->vmconfig_n'. - * - * @param ioctxt i/o context - * @return 0 on success, non-zero on error. - */ -static int read_vmconfig(XcIOContext *ioctxt) -{ - int err = -1; - - if ( xcio_read(ioctxt, &ioctxt->vmconfig_n, sizeof(ioctxt->vmconfig_n)) ) - goto exit; - - ioctxt->vmconfig = malloc(ioctxt->vmconfig_n + 1); - if ( ioctxt->vmconfig == NULL ) - goto exit; - - if ( xcio_read(ioctxt, ioctxt->vmconfig, ioctxt->vmconfig_n) ) - goto exit; - - ioctxt->vmconfig[ioctxt->vmconfig_n] = '\0'; - err = 0; - - exit: - if ( err ) - { - if ( ioctxt->vmconfig != NULL ) - free(ioctxt->vmconfig); - ioctxt->vmconfig = NULL; - ioctxt->vmconfig_n = 0; - } - return err; -} +#define PROGRESS 0 +#if PROGRESS +#define PPRINTF(_f, _a...) fprintf ( stderr, _f , ## _a ) +#else +#define PPRINTF(_f, _a...) +#endif -int xc_linux_restore(int xc_handle, XcIOContext *ioctxt) +int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns, + unsigned char *pfn2mfn) { dom0_op_t op; int rc = 1, i, n, k; unsigned long mfn, pfn, xpfn; unsigned int prev_pc, this_pc; - u32 dom = 0; - int verify = 0; - - /* Number of page frames in use by this Linux session. */ - unsigned long nr_pfns; + int verify = 0; + int err; /* The new domain's shared-info frame number. */ unsigned long shared_info_frame; @@ -75,9 +50,6 @@ /* A copy of the CPU context of the guest. */ vcpu_guest_context_t ctxt; - /* First 16 bytes of the state file must contain 'LinuxGuestRecord'. */ - char signature[16]; - /* A table containg the type of each PFN (/not/ MFN!). */ unsigned long *pfn_type = NULL; @@ -88,7 +60,7 @@ unsigned long *ppage = NULL; /* A copy of the pfn-to-mfn table frame list. */ - unsigned long pfn_to_mfn_frame_list[1024]; + unsigned long *pfn_to_mfn_frame_list = (void *)pfn2mfn; // [1024]; /* A table mapping each PFN to its new MFN. */ unsigned long *pfn_to_mfn_table = NULL; @@ -110,126 +82,68 @@ struct mmuext_op pin[MAX_PIN_BATCH]; unsigned int nr_pins = 0; - xcio_info(ioctxt, "xc_linux_restore start\n"); + DPRINTF("xc_linux_restore start\n"); - if ( mlock(&ctxt, sizeof(ctxt) ) ) - { + if (mlock(&ctxt, sizeof(ctxt))) { /* needed for when we do the build dom0 op, but might as well do early */ - PERROR("Unable to mlock ctxt"); + ERR("Unable to mlock ctxt"); return 1; } - /* Start reading the saved-domain record. */ - if ( xcio_read(ioctxt, signature, 16) || - (memcmp(signature, "LinuxGuestRecord", 16) != 0) ) - { - xcio_error(ioctxt, "Unrecognised state format -- no signature found"); - goto out; - } - - if ( xcio_read(ioctxt, &nr_pfns, sizeof(unsigned long)) || - xcio_read(ioctxt, pfn_to_mfn_frame_list, PAGE_SIZE) ) - { - xcio_error(ioctxt, "Error reading header"); - goto out; - } - - if ( read_vmconfig(ioctxt) ) - { - xcio_error(ioctxt, "Error writing vmconfig"); - goto out; - } - - if ( nr_pfns > 1024*1024 ) - { - xcio_error(ioctxt, "Invalid state file -- pfn count out of range"); - goto out; - } - /* We want zeroed memory so use calloc rather than malloc. */ - pfn_to_mfn_table = calloc(1, 4 * nr_pfns); - pfn_type = calloc(1, 4 * nr_pfns); - region_mfn = calloc(1, 4 * MAX_BATCH_SIZE); - - if ( (pfn_to_mfn_table == NULL) || - (pfn_type == NULL) || - (region_mfn == NULL) ) - { + pfn_to_mfn_table = calloc(4, nr_pfns); + pfn_type = calloc(4, nr_pfns); + region_mfn = calloc(4, MAX_BATCH_SIZE); + + if ((pfn_to_mfn_table == NULL) || (pfn_type == NULL) || + (region_mfn == NULL)) { + ERR("memory alloc failed"); errno = ENOMEM; goto out; } - if ( mlock(region_mfn, 4 * MAX_BATCH_SIZE ) ) - { - xcio_error(ioctxt, "Could not mlock region_mfn"); + if (mlock(region_mfn, 4 * MAX_BATCH_SIZE)) { + ERR("Could not mlock region_mfn"); goto out; } - /* Create domain on CPU -1 so that it may auto load-balance in future. */ - if ( xc_domain_create(xc_handle, &dom) ) - { - xcio_error(ioctxt, "Could not create domain."); - goto out; - } - if ( xc_domain_setcpuweight(xc_handle, dom, 1) ) - { - xcio_error(ioctxt, "Could not set domain cpuweight."); - goto out; - } - if ( xc_domain_setmaxmem(xc_handle, dom, nr_pfns * (PAGE_SIZE / 1024)) ) - { - xcio_error(ioctxt, "Could not set domain maxmem. pfns=%ld, %ldKB", - nr_pfns, nr_pfns * (PAGE_SIZE / 1024)); - goto out; - } - if ( xc_domain_memory_increase_reservation(xc_handle, dom, - nr_pfns * (PAGE_SIZE / 1024)) ) - { - xcio_error(ioctxt, - "Could not increase domain memory reservation. pfns=%ld", - nr_pfns); - goto out; - } - - ioctxt->domain = dom; - xcio_info(ioctxt, "Created domain %u\n", dom); - /* Get the domain's shared-info frame. */ op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)dom; - if ( do_dom0_op(xc_handle, &op) < 0 ) - { - xcio_error(ioctxt, "Could not get information on new domain"); + if (do_dom0_op(xc_handle, &op) < 0) { + ERR("Could not get information on new domain"); goto out; } shared_info_frame = op.u.getdomaininfo.shared_info_frame; - if(ioctxt->flags & XCFLAGS_CONFIGURE) - { - if(xcio_configure_domain(ioctxt)) - { - xcio_error(ioctxt, "Configuring domain failed"); - goto out; - } + err = xc_domain_setmaxmem(xc_handle, dom, nr_pfns * PAGE_SIZE / 1024); + if (err != 0) { + errno = ENOMEM; + goto out; + } + + err = xc_domain_memory_increase_reservation(xc_handle, dom, + nr_pfns * PAGE_SIZE / 1024); + if (err != 0) { + errno = ENOMEM; + goto out; } /* Build the pfn-to-mfn table. We choose MFN ordering returned by Xen. */ - if ( xc_get_pfn_list(xc_handle, dom, - pfn_to_mfn_table, nr_pfns) != nr_pfns ) - { - xcio_error(ioctxt, "Did not read correct number of frame " _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |