mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-08-25 15:36:20 +00:00
kvm tools: Make kvm__arch_setup_firmware to return error code
If some of subsequent calls fails we better to return error code instead of dying with a message. This is a first step in getting rid of number of die() calls we have in code. Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
ee8b14567e
commit
f7f9d02bfa
+4
-1
@@ -1123,7 +1123,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
|
||||
|
||||
kvm__start_timer(kvm);
|
||||
|
||||
kvm__arch_setup_firmware(kvm);
|
||||
exit_code = kvm__arch_setup_firmware(kvm);
|
||||
if (exit_code)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < nrcpus; i++) {
|
||||
kvm_cpus[i] = kvm_cpu__init(kvm, i);
|
||||
@@ -1153,6 +1155,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
|
||||
exit_code = 1;
|
||||
}
|
||||
|
||||
err:
|
||||
compat__print_all_messages();
|
||||
|
||||
fb__stop();
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ 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, const char *hugetlbfs_path, u64 ram_size, const char *name);
|
||||
void kvm__arch_setup_firmware(struct kvm *kvm);
|
||||
int kvm__arch_setup_firmware(struct kvm *kvm);
|
||||
bool kvm__arch_cpu_supports_vm(void);
|
||||
void kvm__arch_periodic_poll(struct kvm *kvm);
|
||||
|
||||
|
||||
+3
-1
@@ -175,7 +175,7 @@ static void setup_fdt(struct kvm *kvm)
|
||||
/**
|
||||
* kvm__arch_setup_firmware
|
||||
*/
|
||||
void kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
int kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
{
|
||||
/* Load RTAS */
|
||||
|
||||
@@ -183,4 +183,6 @@ void kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
|
||||
/* Init FDT */
|
||||
setup_fdt(kvm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
struct kvm;
|
||||
|
||||
void mptable_setup(struct kvm *kvm, unsigned int ncpus);
|
||||
int mptable_setup(struct kvm *kvm, unsigned int ncpus);
|
||||
|
||||
#endif /* KVM_MPTABLE_H_ */
|
||||
|
||||
@@ -348,7 +348,7 @@ bool load_bzimage(struct kvm *kvm, int fd_kernel,
|
||||
* This function is a main routine where we poke guest memory
|
||||
* and install BIOS there.
|
||||
*/
|
||||
void kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
int kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
{
|
||||
/* standart minimal configuration */
|
||||
setup_bios(kvm);
|
||||
@@ -356,7 +356,7 @@ void kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
/* FIXME: SMP, ACPI and friends here */
|
||||
|
||||
/* MP table */
|
||||
mptable_setup(kvm, kvm->nrcpus);
|
||||
return mptable_setup(kvm, kvm->nrcpus);
|
||||
}
|
||||
|
||||
void kvm__arch_periodic_poll(struct kvm *kvm)
|
||||
|
||||
+7
-3
@@ -71,7 +71,7 @@ static void mptable_add_irq_src(struct mpc_intsrc *mpc_intsrc,
|
||||
/**
|
||||
* mptable_setup - create mptable and fill guest memory with it
|
||||
*/
|
||||
void mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
int mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
{
|
||||
unsigned long real_mpc_table, real_mpf_intel, size;
|
||||
struct mpf_intel *mpf_intel;
|
||||
@@ -264,8 +264,11 @@ void mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
*/
|
||||
|
||||
if (size > (unsigned long)(MB_BIOS_END - bios_rom_size) ||
|
||||
size > MPTABLE_MAX_SIZE)
|
||||
die("MP table is too big");
|
||||
size > MPTABLE_MAX_SIZE) {
|
||||
free(mpc_table);
|
||||
pr_err("MP table is too big");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* OK, it is time to move it to guest memory.
|
||||
@@ -273,4 +276,5 @@ void mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
memcpy(guest_flat_to_host(kvm, real_mpc_table), mpc_table, size);
|
||||
|
||||
free(mpc_table);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user