[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v7 02/11] libxl: libxl__device_disk_local_attach return a new libxl_device_disk
Introduce a new libxl_device_disk* parameter to libxl__device_disk_local_attach, the parameter is allocated by the caller. libxl__device_disk_local_attach is going to fill the new disk with informations about the new locally attached disk. The new libxl_device_disk should be passed to libxl_device_disk_local_detach afterwards. Changes in v7: - rename tmpdisk to localdisk; - add a comment in libxl__bootloader_state about localdisk. Changes in v6: - return error in case pdev_path is NULL; - libxl__device_disk_local_attach update the new disk, the caller allocates it; - remove \n from logs. Changes in v5: - rename disk to in_disk; - rename tmpdisk to disk; - copy disk to new_disk only on success; - remove check on libxl__zalloc success. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> --- tools/libxl/libxl_bootloader.c | 6 ++++-- tools/libxl/libxl_internal.c | 17 ++++++++++++++--- tools/libxl/libxl_internal.h | 10 +++++++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c index 60863e4..87dfed7 100644 --- a/tools/libxl/libxl_bootloader.c +++ b/tools/libxl/libxl_bootloader.c @@ -228,7 +228,9 @@ static void bootloader_cleanup(libxl__egc *egc, libxl__bootloader_state *bl) if (bl->outputdir) libxl__remove_directory(gc, bl->outputdir); if (bl->diskpath) { - libxl__device_disk_local_detach(gc, bl->disk); + libxl__device_disk_local_detach(gc, &bl->localdisk); + free(bl->localdisk.pdev_path); + free(bl->localdisk.script); free(bl->diskpath); bl->diskpath = 0; } @@ -330,7 +332,7 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl) goto out; } - bl->diskpath = libxl__device_disk_local_attach(gc, bl->disk); + bl->diskpath = libxl__device_disk_local_attach(gc, bl->disk, &bl->localdisk); if (!bl->diskpath) { rc = ERROR_FAIL; goto out; diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index fc771ff..5e5083b 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -323,13 +323,24 @@ out: return rc; } -char * libxl__device_disk_local_attach(libxl__gc *gc, libxl_device_disk *disk) +char * libxl__device_disk_local_attach(libxl__gc *gc, + const libxl_device_disk *in_disk, + libxl_device_disk *disk) { libxl_ctx *ctx = gc->owner; char *dev = NULL; char *ret = NULL; int rc; + if (in_disk->pdev_path == NULL) + return NULL; + + memcpy(disk, in_disk, sizeof(libxl_device_disk)); + disk->pdev_path = strdup(in_disk->pdev_path); + if (in_disk->script != NULL) + disk->script = strdup(in_disk->script); + disk->vdev = NULL; + rc = libxl__device_disk_setdefault(gc, disk); if (rc) goto out; @@ -367,8 +378,8 @@ char * libxl__device_disk_local_attach(libxl__gc *gc, libxl_device_disk *disk) " attach a qdisk image if the format is not raw"); break; } - LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "locally attaching qdisk %s\n", - disk->pdev_path); + LIBXL__LOG(ctx, LIBXL__LOG_DEBUG, "locally attaching qdisk %s", + in_disk->pdev_path); dev = disk->pdev_path; break; default: diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 343752b..bdd3303 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1241,7 +1241,8 @@ _hidden void libxl__device_destroy_tapdisk(libxl__gc *gc, char *be_path); * a device. */ _hidden char * libxl__device_disk_local_attach(libxl__gc *gc, - libxl_device_disk *disk); + const libxl_device_disk *in_disk, + libxl_device_disk *new_disk); _hidden int libxl__device_disk_local_detach(libxl__gc *gc, libxl_device_disk *disk); @@ -1775,6 +1776,13 @@ struct libxl__bootloader_state { libxl__bootloader_console_callback *console_available; libxl_domain_build_info *info; /* u.pv.{kernel,ramdisk,cmdline} updated */ libxl_device_disk *disk; + /* Should be zeroed by caller on entry. Will be filled in by + * bootloader machinery; represents the local attachment of the + * disk for the benefit of the bootloader. Must be detached by + * the caller using libxl__device_disk_local_detach, but only + * after the domain's kernel and initramfs have been loaded into + * memory and the file references disposed of. */ + libxl_device_disk localdisk; uint32_t domid; /* private to libxl__run_bootloader */ char *outputpath, *outputdir, *logfile; -- 1.7.2.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |