public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: Anthony Liguori
	<aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Subject: [PATCH 2/2] Allow memory to be specified in kvmctl
Date: Tue,  9 Oct 2007 16:31:54 -0500	[thread overview]
Message-ID: <11919655153228-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <11919655141141-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

This patch adds a --memory option to kvmctl to allow the memory size of the
guest to be specified.

Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

diff --git a/user/main.c b/user/main.c
index 9a57a24..7fc0924 100644
--- a/user/main.c
+++ b/user/main.c
@@ -57,6 +57,7 @@ static __thread int vcpu;
 static int apic_ipi_vector = 0xff;
 static sigset_t kernel_sigmask;
 static sigset_t ipi_sigmask;
+static uint64_t memory_size = 128 * 1024 * 1024;
 
 struct vcpu_info {
 	pid_t tid;
@@ -147,7 +148,7 @@ static int test_inl(void *opaque, uint16_t addr, uint32_t *value)
 
 	switch (addr) {
 	case 0xd1:
-		*value = 128 * 1024 * 1024;
+		*value = memory_size;
 		break;
 	default:
 		printf("inl 0x%x\n", addr);
@@ -328,14 +329,16 @@ static void start_vcpu(int n)
 static void usage(const char *progname)
 {
 	fprintf(stderr,
-		"Usage: %s [OPTIONS] [bootstrap] flatfile\n"
-		"KVM test harness.\n"
-		"\n"
-		"  -s, --smp=NUM          create a VM with NUM virtual CPUs\n"
-		"  -p, --protected-mode   start VM in protected mode\n"
-		"  -h, --help             display this help screen and exit\n"
-		"\n"
-		"Report bugs to <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>.\n"
+"Usage: %s [OPTIONS] [bootstrap] flatfile\n"
+"KVM test harness.\n"
+"\n"
+"  -s, --smp=NUM          create a VM with NUM virtual CPUs\n"
+"  -p, --protected-mode   start VM in protected mode\n"
+"  -m, --memory=NUM[GMKB] allocate NUM memory for virtual machine.  A suffix\n"
+"                         can be used to change the unit (default: `M')\n"
+"  -h, --help             display this help screen and exit\n"
+"\n"
+"Report bugs to <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>.\n"
 		, progname);
 }
 
@@ -348,16 +351,18 @@ int main(int argc, char **argv)
 {
 	void *vm_mem;
 	int i;
-	const char *sopts = "s:ph";
+	const char *sopts = "s:phm:";
 	struct option lopts[] = {
 		{ "smp", 1, 0, 's' },
 		{ "protected-mode", 0, 0, 'p' },
+		{ "memory", 1, 0, 'm' },
 		{ "help", 0, 0, 'h' },
 		{ 0 },
 	};
 	int opt_ind, ch;
 	bool enter_protected_mode = false;
 	int nb_args;
+	char *endptr;
 
 	while ((ch = getopt_long(argc, argv, sopts, lopts, &opt_ind)) != -1) {
 		switch (ch) {
@@ -367,6 +372,24 @@ int main(int argc, char **argv)
 		case 'p':
 			enter_protected_mode = true;
 			break;
+		case 'm':
+			memory_size = strtoull(optarg, &endptr, 0);
+			switch (*endptr) {
+			case 'G': case 'g':
+				memory_size <<= 10;
+			case '\0':
+			case 'M': case 'm':
+				memory_size <<= 10;
+			case 'K': case 'k':
+				memory_size <<= 10;
+				break;
+			default:
+				fprintf(stderr,
+					"Unrecongized memory suffix: %c\n",
+					*endptr);
+				exit(1);
+			}
+			break;
 		case 'h':
 			usage(argv[0]);
 			exit(0);
@@ -401,7 +424,7 @@ int main(int argc, char **argv)
 		fprintf(stderr, "kvm_init failed\n");
 		return 1;
 	}
-	if (kvm_create(kvm, 128 * 1024 * 1024, &vm_mem) < 0) {
+	if (kvm_create(kvm, memory_size, &vm_mem) < 0) {
 		kvm_finalize(kvm);
 		fprintf(stderr, "kvm_create failed\n");
 		return 1;

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

  parent reply	other threads:[~2007-10-09 21:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-09 21:31 [PATCH 1/2] Remove memory size from linker script Anthony Liguori
     [not found] ` <11919655141141-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-09 21:31   ` Anthony Liguori [this message]
     [not found]     ` <11919655153228-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-09 21:54       ` [PATCH 2/2] Allow memory to be specified in kvmctl Muli Ben-Yehuda
     [not found]         ` <20071009215449.GM4335-WD1JZD8MxeCTrf4lBMg6DdBPR1lH4CV8@public.gmane.org>
2007-10-09 22:09           ` Anthony Liguori
     [not found]             ` <470BFC0F.5040707-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-10-09 22:14               ` Muli Ben-Yehuda
     [not found]                 ` <20071009221404.GO4335-WD1JZD8MxeCTrf4lBMg6DdBPR1lH4CV8@public.gmane.org>
2007-10-09 22:18                   ` Anthony Liguori

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=11919655153228-git-send-email-aliguori@us.ibm.com \
    --to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
    --cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
    --cc=jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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