[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v12 19/26] Introduce COLO mode and refactor relevant function
No functional changes. Signed-off-by: Wen Congyang <wency@xxxxxxxxxxxxxx> Signed-off-by: Changlong Xie <xiecl.fnst@xxxxxxxxxxxxxx> --- tools/libxl/libxl_dm.c | 59 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 4aca38e..2226004 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -751,6 +751,45 @@ static int libxl__dm_runas_helper(libxl__gc *gc, const char *username) } } +/* colo mode */ +enum { + LIBXL__COLO_NONE = 0, +}; + +static char *qemu_disk_scsi_drive_string(libxl__gc *gc, const char *pdev_path, + int unit, const char *format, + const libxl_device_disk *disk, + int colo_mode) +{ + char *drive = NULL; + + if (colo_mode == LIBXL__COLO_NONE) + { + drive = libxl__sprintf + (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,cache=writeback", + pdev_path, unit, format); + return drive; + } else + abort(); +} + +static char *qemu_disk_ide_drive_string(libxl__gc *gc, const char *pdev_path, + int unit, const char *format, + const libxl_device_disk *disk, + int colo_mode) +{ + char *drive = NULL; + + if (colo_mode == LIBXL__COLO_NONE) + { + drive = GCSPRINTF + ("file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback", + pdev_path, unit, format); + return drive; + } + abort(); +} + static int libxl__build_device_model_args_new(libxl__gc *gc, const char *dm, int guest_domid, const libxl_domain_config *guest_config, @@ -1164,6 +1203,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, const char *format = qemu_disk_format_string(disks[i].format); char *drive; const char *pdev_path; + int colo_mode; if (dev_number == -1) { LOG(WARN, "unable to determine"" disk number for %s", @@ -1208,10 +1248,13 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, * For other disks we translate devices 0..3 into * hd[a-d] and ignore the rest. */ + + colo_mode = LIBXL__COLO_NONE; if (strncmp(disks[i].vdev, "sd", 2) == 0) { - drive = libxl__sprintf - (gc, "file=%s,if=scsi,bus=0,unit=%d,format=%s,readonly=%s,cache=writeback", - pdev_path, disk, format, disks[i].readwrite ? "off" : "on"); + drive = qemu_disk_scsi_drive_string(gc, pdev_path, disk, + format, + &disks[i], + colo_mode); } else if (strncmp(disks[i].vdev, "xvd", 3) == 0) { /* * Do not add any emulated disk when PV disk are @@ -1234,12 +1277,16 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, LOG(ERROR, "qemu-xen doesn't support read-only IDE disk drivers"); return ERROR_INVAL; } - drive = libxl__sprintf - (gc, "file=%s,if=ide,index=%d,media=disk,format=%s,cache=writeback", - pdev_path, disk, format); + drive = qemu_disk_ide_drive_string(gc, pdev_path, disk, + format, + &disks[i], + colo_mode); } else { continue; /* Do not emulate this disk */ } + + if (!drive) + continue; } flexarray_append(dm_args, "-drive"); -- 1.9.3 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |