From: David Ahern <dsahern@gmail.com>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: penberg@kernel.org, kvm@vger.kernel.org, mingo@elte.hu,
asias.hejun@gmail.com, gorcunov@gmail.com,
prasadjoshi124@gmail.com
Subject: Re: [PATCH 3/3 V2] kvm tools: Add cmdline options for loading multiple images
Date: Wed, 04 May 2011 08:51:17 -0600 [thread overview]
Message-ID: <4DC167E5.1020707@gmail.com> (raw)
In-Reply-To: <1304516717-24512-4-git-send-email-levinsasha928@gmail.com>
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@gmail.com>
> ---
> 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);
>
next prev parent reply other threads:[~2011-05-04 14:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-04 13:45 [PATCH 0/3 V2] kvm tools: Support for multiple virtio-blk Sasha Levin
2011-05-04 13:45 ` [PATCH 1/3 V2] kvm tools: Move disk_image into virtio-blk Sasha Levin
2011-05-04 13:45 ` [PATCH 2/3 V2] kvm tools: Add support for multiple virtio-blk Sasha Levin
2011-05-04 13:56 ` Ingo Molnar
2011-05-04 14:32 ` Avi Kivity
2011-05-04 14:40 ` Asias He
2011-05-04 14:44 ` Sasha Levin
2011-05-04 14:51 ` Cyrill Gorcunov
2011-05-04 13:45 ` [PATCH 3/3 V2] kvm tools: Add cmdline options for loading multiple images Sasha Levin
2011-05-04 14:51 ` David Ahern [this message]
2011-05-04 15:03 ` Sasha Levin
2011-05-04 15:33 ` David Ahern
2011-05-04 19:38 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DC167E5.1020707@gmail.com \
--to=dsahern@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox