On 05/04/11 07:45, Sasha Levin wrote: > This is a simple cmdline addition to allow loading multiple images. > perf's cmdline parser doesn't support having multiple args > with the same name (i.e. --image <img1> --image <img2>), so > we have to choose either to extend the parser, or find a diiferent > way to assign multiple images. > > Sample cmdline for loading 2 images: > ./kvm run --image=image1.raw --readonly --image2=image2.raw --readonly2 syntax is getting a bit unwieldy. Why not use a scheme similar to qemu and concatenate related arguments into one and handle multiple usages? e.g., --image=image1.raw,ro --image=image2.raw,ro David > > NOTE NOTE NOTE - If testing, Please take notice of the > --readonly param changes so you won't destroy your image/disk. > > Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx> > --- > tools/kvm/kvm-run.c | 36 ++++++++++++++++++++++++------------ > 1 files changed, 24 insertions(+), 12 deletions(-) > > diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c > index b92232d..5182735 100644 > --- a/tools/kvm/kvm-run.c > +++ b/tools/kvm/kvm-run.c > @@ -42,6 +42,7 @@ > #define MB_SHIFT (20) > #define MIN_RAM_SIZE_MB (64ULL) > #define MIN_RAM_SIZE_BYTE (MIN_RAM_SIZE_MB << MB_SHIFT) > +#define MAX_DISK_IMAGES 4 > > static struct kvm *kvm; > static struct kvm_cpu *kvm_cpus[KVM_NR_CPUS]; > @@ -51,7 +52,7 @@ static u64 ram_size = MIN_RAM_SIZE_MB; > static const char *kernel_cmdline; > static const char *kernel_filename; > static const char *initrd_filename; > -static const char *image_filename; > +static const char *image_filename[MAX_DISK_IMAGES]; > static const char *console; > static const char *kvm_dev; > static const char *network; > @@ -59,7 +60,7 @@ static const char *host_ip_addr; > static const char *guest_mac; > static const char *script; > static bool single_step; > -static bool readonly_image; > +static bool readonly_image[MAX_DISK_IMAGES]; > static bool virtio_rng; > extern bool ioport_debug; > extern int active_console; > @@ -75,8 +76,17 @@ static const struct option options[] = { > OPT_GROUP("Basic options:"), > OPT_INTEGER('\0', "cpus", &nrcpus, "Number of CPUs"), > OPT_U64('m', "mem", &ram_size, "Virtual machine memory size in MiB."), > - OPT_STRING('i', "image", &image_filename, "image", "Disk image"), > - OPT_BOOLEAN('\0', "readonly", &readonly_image, > + OPT_STRING('i', "image", &image_filename[0], "image", "Disk image"), > + OPT_BOOLEAN('\0', "readonly", &readonly_image[0], > + "Don't write changes back to disk image"), > + OPT_STRING('\0', "image2", &image_filename[1], "image", "Disk image"), > + OPT_BOOLEAN('\0', "readonly2", &readonly_image[1], > + "Don't write changes back to disk image"), > + OPT_STRING('\0', "image3", &image_filename[2], "image", "Disk image"), > + OPT_BOOLEAN('\0', "readonly3", &readonly_image[2], > + "Don't write changes back to disk image"), > + OPT_STRING('\0', "image4", &image_filename[3], "image", "Disk image"), > + OPT_BOOLEAN('\0', "readonly4", &readonly_image[3], > "Don't write changes back to disk image"), > OPT_STRING('c', "console", &console, "serial or virtio", > "Console to use"), > @@ -397,23 +407,25 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) > strlcat(real_cmdline, kernel_cmdline, sizeof(real_cmdline)); > > hi = NULL; > - if (!image_filename) { > + if (!image_filename[0]) { > hi = host_image(real_cmdline, sizeof(real_cmdline)); > if (hi) { > - image_filename = hi; > - readonly_image = true; > + image_filename[0] = hi; > + readonly_image[0] = true; > } > } > > if (!strstr(real_cmdline, "root=")) > strlcat(real_cmdline, " root=/dev/vda rw ", sizeof(real_cmdline)); > > - if (image_filename) { > - struct disk_image *disk = disk_image__open(image_filename, readonly_image); > - if (!disk) > - die("unable to load disk image %s", image_filename); > + for (i = 0; i < MAX_DISK_IMAGES; i++) { > + if (image_filename[i]) { > + struct disk_image *disk = disk_image__open(image_filename[i], readonly_image[i]); > + if (!disk) > + die("unable to load disk image %s", image_filename[i]); > > - virtio_blk__init(kvm, disk); > + virtio_blk__init(kvm, disk); > + } > } > free(hi); > -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html