@@ -57,10 +57,13 @@ 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_init(struct kvm *kvm)
{
unsigned long alignment;
+ /* Convenience aliases */
+ const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;
+
/*
* Allocate guest memory. We must align our buffer to 64K to
* correlate with the maximum guest page size for virtio-mmio.
@@ -73,7 +76,7 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
alignment = SZ_32M;
else
alignment = SZ_2M;
- kvm->ram_size = min(ram_size, (u64)ARM_MAX_MEMORY(kvm));
+ kvm->ram_size = min(kvm->cfg.ram_size, (u64)ARM_MAX_MEMORY(kvm));
kvm->arch.ram_alloc_size = kvm->ram_size + alignment;
kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path,
kvm->arch.ram_alloc_size);
@@ -104,7 +104,7 @@ 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 *hugetlbfs_path, u64 ram_size);
+void kvm__arch_init(struct kvm *kvm);
void kvm__arch_delete_ram(struct kvm *kvm);
int kvm__arch_setup_firmware(struct kvm *kvm);
int kvm__arch_free_firmware(struct kvm *kvm);
@@ -317,7 +317,7 @@ int kvm__init(struct kvm *kvm)
goto err_vm_fd;
}
- kvm__arch_init(kvm, kvm->cfg.hugetlbfs_path, kvm->cfg.ram_size);
+ kvm__arch_init(kvm);
INIT_LIST_HEAD(&kvm->mem_banks);
kvm__init_ram(kvm);
@@ -57,9 +57,12 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
}
/* Architecture-specific KVM init */
-void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
+void kvm__arch_init(struct kvm *kvm)
{
int ret;
+ /* Convenience aliases */
+ u64 ram_size = kvm->cfg.ram_size;
+ const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;
kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size);
kvm->ram_size = ram_size;
@@ -88,10 +88,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
}
/* Architecture-specific KVM init */
-void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
+void kvm__arch_init(struct kvm *kvm)
{
int cap_ppc_rma;
unsigned long hpt;
+ /* Convenience aliases */
+ u64 ram_size = kvm->cfg.ram_size;
+ const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;
kvm->ram_size = ram_size;
@@ -130,10 +130,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video)
}
/* Architecture-specific KVM init */
-void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
+void kvm__arch_init(struct kvm *kvm)
{
struct kvm_pit_config pit_config = { .flags = 0, };
int ret;
+ /* Convenience aliases */
+ u64 ram_size = kvm->cfg.ram_size;
+ const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path;
ret = ioctl(kvm->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000);
if (ret < 0)
The structure KVM already contains a pointer to the configuration. Both hugetlbfs_path and ram_size are part of the configuration, so is it not necessary to path them again in parameter. Signed-off-by: Julien Grall <julien.grall@arm.com> --- arm/kvm.c | 7 +++++-- include/kvm/kvm.h | 2 +- kvm.c | 2 +- mips/kvm.c | 5 ++++- powerpc/kvm.c | 5 ++++- x86/kvm.c | 5 ++++- 6 files changed, 19 insertions(+), 7 deletions(-)