kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm tools: Fix rootfs name resolving when specified with image
@ 2011-12-15 12:15 Sasha Levin
  2011-12-15 12:15 ` [PATCH 2/2] kvm tools: Submit multiple virtio-blk requests in parallel Sasha Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2011-12-15 12:15 UTC (permalink / raw)
  To: penberg; +Cc: mingo, gorcunov, asias.hejun, kvm, Sasha Levin

Fix the case when using a rootfs combined with a virtio-blk disk.

Also, simplify custon rootfs name lookup.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/builtin-run.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 0879ab9..e6751aa 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -87,6 +87,7 @@ static const char *script;
 static const char *guest_name;
 static const char *sandbox;
 static const char *hugetlbfs_path;
+static const char *custom_rootfs_name = "default";
 static struct virtio_net_params *net_params;
 static bool single_step;
 static bool readonly_image[MAX_DISK_IMAGES];
@@ -151,6 +152,7 @@ static int img_name_parser(const struct option *opt, const char *arg, int unset)
 			die("Unable to initialize virtio 9p");
 		kvm_setup_resolv(arg);
 		using_rootfs = custom_rootfs = 1;
+		custom_rootfs_name = arg;
 		return 0;
 	}
 
@@ -738,18 +740,13 @@ void kvm_run_help(void)
 static int kvm_custom_stage2(void)
 {
 	char tmp[PATH_MAX], dst[PATH_MAX], *src;
-	const char *rootfs;
+	const char *rootfs = custom_rootfs_name;
 	int r;
 
 	src = realpath("guest/init_stage2", NULL);
 	if (src == NULL)
 		return -ENOMEM;
 
-	if (image_filename[0] == NULL)
-		rootfs = "default";
-	else
-		rootfs = image_filename[0];
-
 	snprintf(tmp, PATH_MAX, "%s%s/virt/init_stage2", kvm__get_dir(), rootfs);
 	remove(tmp);
 
@@ -762,12 +759,9 @@ static int kvm_custom_stage2(void)
 
 static int kvm_run_set_sandbox(void)
 {
-	const char *guestfs_name = "default";
+	const char *guestfs_name = custom_rootfs_name;
 	char path[PATH_MAX], script[PATH_MAX], *tmp;
 
-	if (image_filename[0])
-		guestfs_name = image_filename[0];
-
 	snprintf(path, PATH_MAX, "%s%s/virt/sandbox.sh", kvm__get_dir(), guestfs_name);
 
 	remove(path);
@@ -976,8 +970,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 	if (!using_rootfs && !image_filename[0]) {
 		char tmp[PATH_MAX];
 
-		kvm_setup_create_new("default");
-		kvm_setup_resolv("default");
+		kvm_setup_create_new(custom_rootfs_name);
+		kvm_setup_resolv(custom_rootfs_name);
 
 		snprintf(tmp, PATH_MAX, "%s%s", kvm__get_dir(), "default");
 		if (virtio_9p__register(kvm, tmp, "/dev/root") < 0)
-- 
1.7.8


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-18 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-15 12:15 [PATCH 1/2] kvm tools: Fix rootfs name resolving when specified with image Sasha Levin
2011-12-15 12:15 ` [PATCH 2/2] kvm tools: Submit multiple virtio-blk requests in parallel Sasha Levin
2011-12-16 14:57   ` Asias He
2011-12-18 19:42     ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).