[tip:tools/kvm] kvm tools: Improve 'lkvm sandbox' syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  f1a441f7fa50f78666618981bccbef551286097b
Gitweb:     http://git.kernel.org/tip/f1a441f7fa50f78666618981bccbef551286097b
Author:     Sasha Levin <levinsasha928@xxxxxxxxx>
AuthorDate: Fri, 13 Jan 2012 11:42:05 +0200
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Sun, 15 Jan 2012 15:01:33 +0200

kvm tools: Improve 'lkvm sandbox' syntax

This patch adds the possibility to run commands using the default parameter
in 'lkvm sandbox'. For example, a user would now be able to run:

	'lkvm sandbox firefox'

And have a sandboxed firefox instance start in the guest.

For commands with parameters, we still need to use dashdash to pass the
parameters (similar to 'git bisect run'). For example:

	'lkvm sandbox -- ls -al /bin

Suggested-by: Ingo Molnar <mingo@xxxxxxx>
Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/builtin-run.c |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
index 249cf82..802449c 100644
--- a/tools/kvm/builtin-run.c
+++ b/tools/kvm/builtin-run.c
@@ -114,6 +114,7 @@ static const char * const run_usage[] = {
 };
 
 enum {
+	KVM_RUN_DEFAULT,
 	KVM_RUN_SANDBOX,
 };
 
@@ -904,16 +905,27 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 				}
 			}
 
-			if (kernel_filename) {
+			if ((kvm_run_wrapper == KVM_RUN_DEFAULT && kernel_filename) ||
+				(kvm_run_wrapper == KVM_RUN_SANDBOX && sandbox)) {
 				fprintf(stderr, "Cannot handle parameter: "
 						"%s\n", argv[0]);
 				usage_with_options(run_usage, options);
 				return EINVAL;
 			}
-			/* first unhandled parameter is treated as a kernel
-			   image
-			 */
-			kernel_filename = argv[0];
+			if (kvm_run_wrapper == KVM_RUN_SANDBOX) {
+				/*
+				 * first unhandled parameter is treated as
+				 * sandbox command
+				 */
+				sandbox = DEFAULT_SANDBOX_FILENAME;
+				kvm_run_write_sandbox_cmd(argv, argc);
+			} else {
+				/*
+				 * first unhandled parameter is treated as a kernel
+				 * image
+				 */
+				kernel_filename = argv[0];
+			}
 			argv++;
 			argc--;
 		}
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux