From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Evans Subject: [PATCH 12/28] kvm tools: Move arch-specific cmdline init into kvm__arch_set_cmdline() Date: Tue, 06 Dec 2011 14:40:29 +1100 Message-ID: <4EDD8EAD.6060307@ozlabs.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Return-path: Received: from ozlabs.org ([203.10.76.45]:43759 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932871Ab1LFDjl (ORCPT ); Mon, 5 Dec 2011 22:39:41 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Different systems will want different base kernel commandlines, e.g. non-x86 systems probably don't need noapic, i8042.* etc., so set the commandline up in arch-specific code. Then, if the resulting commandline is empty, don't strcat a space onto the front. Signed-off-by: Matt Evans --- tools/kvm/builtin-run.c | 12 +++++------- tools/kvm/include/kvm/kvm.h | 1 + tools/kvm/x86/kvm.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 9ef331e..a67bd8c 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -835,13 +835,11 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) vidmode = 0; memset(real_cmdline, 0, sizeof(real_cmdline)); - strcpy(real_cmdline, "noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 " - "i8042.dumbkbd=1 i8042.nopnp=1"); - if (vnc || sdl) { - strcat(real_cmdline, " video=vesafb console=tty0"); - } else - strcat(real_cmdline, " console=ttyS0 earlyprintk=serial i8042.noaux=1"); - strcat(real_cmdline, " "); + kvm__arch_set_cmdline(real_cmdline, vnc || sdl); + + if (strlen(real_cmdline) > 0) + strcat(real_cmdline, " "); + if (kernel_cmdline) strlcat(real_cmdline, kernel_cmdline, sizeof(real_cmdline)); diff --git a/tools/kvm/include/kvm/kvm.h b/tools/kvm/include/kvm/kvm.h index 60842d5..fae2ba9 100644 --- a/tools/kvm/include/kvm/kvm.h +++ b/tools/kvm/include/kvm/kvm.h @@ -53,6 +53,7 @@ int kvm__get_sock_by_instance(const char *name); int kvm__enumerate_instances(int (*callback)(const char *name, int pid)); void kvm__remove_socket(const char *name); +void kvm__arch_set_cmdline(char *cmdline, bool video); void kvm__arch_init(struct kvm *kvm, const char *kvm_dev, u64 ram_size, const char *name); void kvm__arch_setup_firmware(struct kvm *kvm); bool kvm__arch_cpu_supports_vm(void); diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c index 45dcb77..7071dc6 100644 --- a/tools/kvm/x86/kvm.c +++ b/tools/kvm/x86/kvm.c @@ -149,6 +149,17 @@ void kvm__init_ram(struct kvm *kvm) } } +/* Arch-specific commandline setup */ +void kvm__arch_set_cmdline(char *cmdline, bool video) +{ + strcpy(cmdline, "noapic noacpi pci=conf1 reboot=k panic=1 i8042.direct=1 " + "i8042.dumbkbd=1 i8042.nopnp=1"); + if (video) { + strcat(cmdline, " video=vesafb console=tty0"); + } else + strcat(cmdline, " console=ttyS0 earlyprintk=serial i8042.noaux=1"); +} + /* Architecture-specific KVM init */ void kvm__arch_init(struct kvm *kvm, const char *kvm_dev, u64 ram_size, const char *name) {