Patchwork [kvmtool,3/6] builtin-run: Do not look for default kernel when firmware is provided

login
register
mail settings
Submitter Julien Thierry
Date Dec. 4, 2018, 11:14 a.m.
Message ID <1543922073-55530-4-git-send-email-julien.thierry@arm.com>
Download mbox | patch
Permalink /patch/671809/
State New
Headers show

Comments

Julien Thierry - Dec. 4, 2018, 11:14 a.m.
When a firmware file is provided, kvmtool is not responsible for loading
a kernel image.

There is no reason for looking for a default kernel image when loading
a firmware.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
---
 builtin-run.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
Andre Przywara - Dec. 12, 2018, 6:16 p.m.
On Tue,  4 Dec 2018 11:14:30 +0000
Julien Thierry <julien.thierry@arm.com> wrote:

Hi,

> When a firmware file is provided, kvmtool is not responsible for
> loading a kernel image.
> 
> There is no reason for looking for a default kernel image when loading
> a firmware.
> 
> Signed-off-by: Julien Thierry <julien.thierry@arm.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Just wondering whether we actually need this unconditional printf in
the first place ...

Cheers,
Andre.

> ---
>  builtin-run.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> diff --git a/builtin-run.c b/builtin-run.c
> index 443c10b..82e2b2e 100644
> --- a/builtin-run.c
> +++ b/builtin-run.c
> @@ -512,12 +512,13 @@ static struct kvm *kvm_cmd_run_init(int argc,
> const char **argv) 
>  	kvm->nr_disks = kvm->cfg.image_count;
>  
> -	if (!kvm->cfg.kernel_filename)
> +	if (!kvm->cfg.kernel_filename
> && !kvm->cfg.firmware_filename) { kvm->cfg.kernel_filename =
> find_kernel(); 
> -	if (!kvm->cfg.kernel_filename) {
> -		kernel_usage_with_options();
> -		return ERR_PTR(-EINVAL);
> +		if (!kvm->cfg.kernel_filename) {
> +			kernel_usage_with_options();
> +			return ERR_PTR(-EINVAL);
> +		}
>  	}
>  
>  	kvm->cfg.vmlinux_filename = find_vmlinux();
> @@ -639,10 +640,17 @@ static struct kvm *kvm_cmd_run_init(int argc,
> const char **argv) 
>  	kvm->cfg.real_cmdline = real_cmdline;
>  
> -	printf("  # %s run -k %s -m %Lu -c %d --name %s\n",
> KVM_BINARY_NAME,
> -		kvm->cfg.kernel_filename,
> -		(unsigned long long)kvm->cfg.ram_size / 1024 / 1024,
> -		kvm->cfg.nrcpus, kvm->cfg.guest_name);
> +	if (kvm->cfg.kernel_filename) {
> +		printf("  # %s run -k %s -m %Lu -c %d --name %s\n",
> KVM_BINARY_NAME,
> +		       kvm->cfg.kernel_filename,
> +		       (unsigned long long)kvm->cfg.ram_size /
> 1024 / 1024,
> +		       kvm->cfg.nrcpus, kvm->cfg.guest_name);
> +	} else if (kvm->cfg.firmware_filename) {
> +		printf("  # %s run --firmware %s -m %Lu -c %d --name
> %s\n", KVM_BINARY_NAME,
> +		       kvm->cfg.firmware_filename,
> +		       (unsigned long long)kvm->cfg.ram_size /
> 1024 / 1024,
> +		       kvm->cfg.nrcpus, kvm->cfg.guest_name);
> +	}
>  
>  	if (init_list__init(kvm) < 0)
>  		die ("Initialisation failed");

Patch

diff --git a/builtin-run.c b/builtin-run.c
index 443c10b..82e2b2e 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -512,12 +512,13 @@  static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
 
 	kvm->nr_disks = kvm->cfg.image_count;
 
-	if (!kvm->cfg.kernel_filename)
+	if (!kvm->cfg.kernel_filename && !kvm->cfg.firmware_filename) {
 		kvm->cfg.kernel_filename = find_kernel();
 
-	if (!kvm->cfg.kernel_filename) {
-		kernel_usage_with_options();
-		return ERR_PTR(-EINVAL);
+		if (!kvm->cfg.kernel_filename) {
+			kernel_usage_with_options();
+			return ERR_PTR(-EINVAL);
+		}
 	}
 
 	kvm->cfg.vmlinux_filename = find_vmlinux();
@@ -639,10 +640,17 @@  static struct kvm *kvm_cmd_run_init(int argc, const char **argv)
 
 	kvm->cfg.real_cmdline = real_cmdline;
 
-	printf("  # %s run -k %s -m %Lu -c %d --name %s\n", KVM_BINARY_NAME,
-		kvm->cfg.kernel_filename,
-		(unsigned long long)kvm->cfg.ram_size / 1024 / 1024,
-		kvm->cfg.nrcpus, kvm->cfg.guest_name);
+	if (kvm->cfg.kernel_filename) {
+		printf("  # %s run -k %s -m %Lu -c %d --name %s\n", KVM_BINARY_NAME,
+		       kvm->cfg.kernel_filename,
+		       (unsigned long long)kvm->cfg.ram_size / 1024 / 1024,
+		       kvm->cfg.nrcpus, kvm->cfg.guest_name);
+	} else if (kvm->cfg.firmware_filename) {
+		printf("  # %s run --firmware %s -m %Lu -c %d --name %s\n", KVM_BINARY_NAME,
+		       kvm->cfg.firmware_filename,
+		       (unsigned long long)kvm->cfg.ram_size / 1024 / 1024,
+		       kvm->cfg.nrcpus, kvm->cfg.guest_name);
+	}
 
 	if (init_list__init(kvm) < 0)
 		die ("Initialisation failed");