mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-05 21:21:54 +00:00
kvm tools: Fixes for mptable module
Fixes include: - Error handling - Cleanup - Standard init/uninit Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
This commit is contained in:
@@ -1201,6 +1201,10 @@ static int kvm_cmd_run_init(int argc, const char **argv)
|
||||
kvm__start_timer(kvm);
|
||||
|
||||
kvm__arch_setup_firmware(kvm);
|
||||
if (r < 0) {
|
||||
pr_err("kvm__arch_setup_firmware() failed with error %d\n", r);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
for (i = 0; i < nrcpus; i++) {
|
||||
kvm_cpus[i] = kvm_cpu__init(kvm, i);
|
||||
@@ -1270,6 +1274,10 @@ static void kvm_cmd_run_exit(int guest_ret)
|
||||
if (r < 0)
|
||||
pr_warning("serial8250__exit() failed with error %d\n", r);
|
||||
|
||||
r = kvm__arch_free_firmware(kvm);
|
||||
if (r < 0)
|
||||
pr_warning("kvm__arch_free_firmware() failed with error %d\n", r);
|
||||
|
||||
r = ioport__exit(kvm);
|
||||
if (r < 0)
|
||||
pr_warning("ioport__exit() failed with error %d\n", r);
|
||||
|
||||
@@ -63,6 +63,7 @@ void kvm__arch_set_cmdline(char *cmdline, bool video);
|
||||
void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size);
|
||||
void kvm__arch_delete_ram(struct kvm *kvm);
|
||||
int kvm__arch_setup_firmware(struct kvm *kvm);
|
||||
int kvm__arch_free_firmware(struct kvm *kvm);
|
||||
bool kvm__arch_cpu_supports_vm(void);
|
||||
void kvm__arch_periodic_poll(struct kvm *kvm);
|
||||
|
||||
|
||||
@@ -191,3 +191,8 @@ int kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kvm__arch_free_firmware(struct kvm *kvm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
struct kvm;
|
||||
|
||||
int mptable_setup(struct kvm *kvm, unsigned int ncpus);
|
||||
int mptable__init(struct kvm *kvm);
|
||||
int mptable__exit(struct kvm *kvm);
|
||||
|
||||
#endif /* KVM_MPTABLE_H_ */
|
||||
|
||||
@@ -358,13 +358,27 @@ bool load_bzimage(struct kvm *kvm, int fd_kernel,
|
||||
*/
|
||||
int kvm__arch_setup_firmware(struct kvm *kvm)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* standart minimal configuration */
|
||||
setup_bios(kvm);
|
||||
|
||||
/* FIXME: SMP, ACPI and friends here */
|
||||
|
||||
/* MP table */
|
||||
return mptable_setup(kvm, kvm->nrcpus);
|
||||
r = mptable__init(kvm);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int kvm__arch_free_firmware(struct kvm *kvm)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* MP table */
|
||||
r = mptable__exit(kvm);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void kvm__arch_periodic_poll(struct kvm *kvm)
|
||||
|
||||
+11
-4
@@ -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
|
||||
*/
|
||||
int mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
int mptable__init(struct kvm *kvm)
|
||||
{
|
||||
unsigned long real_mpc_table, real_mpf_intel, size;
|
||||
struct mpf_intel *mpf_intel;
|
||||
@@ -85,7 +85,7 @@ int mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
const int pcibusid = 0;
|
||||
const int isabusid = 1;
|
||||
|
||||
unsigned int i, nentries = 0;
|
||||
unsigned int i, nentries = 0, ncpus = kvm->nrcpus;
|
||||
unsigned int ioapicid;
|
||||
void *last_addr;
|
||||
|
||||
@@ -100,7 +100,7 @@ int mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
|
||||
mpc_table = calloc(1, MPTABLE_MAX_SIZE);
|
||||
if (!mpc_table)
|
||||
die("Out of memory");
|
||||
return -ENOMEM;
|
||||
|
||||
MPTABLE_STRNCPY(mpc_table->signature, MPC_SIGNATURE);
|
||||
MPTABLE_STRNCPY(mpc_table->oem, MPTABLE_OEM);
|
||||
@@ -267,7 +267,8 @@ int mptable_setup(struct kvm *kvm, unsigned int ncpus)
|
||||
size > MPTABLE_MAX_SIZE) {
|
||||
free(mpc_table);
|
||||
pr_err("MP table is too big");
|
||||
return -1;
|
||||
|
||||
return -E2BIG;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -276,5 +277,11 @@ int 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;
|
||||
}
|
||||
|
||||
int mptable__exit(struct kvm *kvm)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user