Re: [PATCH kvmtool 04/16] kvmtool: Add helper to sanitize arch specific KVM configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/09/2019 14:35, Alexandru Elisei wrote:
kvmtool accepts generic and architecture specific parameters. When creating
a virtual machine, only the generic parameters are checked against sane
values. Add a function to sanitize the architecture specific configuration
options and call it before the initialization routines.

This patch was inspired by Julien Grall's patch.

Signed-off-by: Julien Grall <julien.grall@xxxxxxx>
Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx>
---
  arm/aarch64/include/kvm/kvm-arch.h |  2 +-
  arm/include/arm-common/kvm-arch.h  |  4 ++++
  arm/kvm.c                          | 11 +++++++++--
  builtin-run.c                      |  2 ++
  mips/include/kvm/kvm-arch.h        |  4 ++++
  mips/kvm.c                         |  5 +++++
  powerpc/include/kvm/kvm-arch.h     |  4 ++++
  powerpc/kvm.c                      |  5 +++++
  x86/include/kvm/kvm-arch.h         |  4 ++++
  x86/kvm.c                          | 24 ++++++++++++------------
  10 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h
index 9de623ac6cb9..1b3d0a5fb1b4 100644
--- a/arm/aarch64/include/kvm/kvm-arch.h
+++ b/arm/aarch64/include/kvm/kvm-arch.h
@@ -5,7 +5,7 @@
  				0x8000				:	\
  				0x80000)
-#define ARM_MAX_MEMORY(kvm) ((kvm)->cfg.arch.aarch32_guest ? \
+#define ARM_MAX_MEMORY(cfg)	((cfg)->arch.aarch32_guest	?	\
  				ARM_LOMAP_MAX_MEMORY		:	\
  				ARM_HIMAP_MAX_MEMORY)
diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h
index b9d486d5eac2..965978d7cfb5 100644
--- a/arm/include/arm-common/kvm-arch.h
+++ b/arm/include/arm-common/kvm-arch.h
@@ -74,4 +74,8 @@ struct kvm_arch {
  	u64	dtb_guest_start;
  };
+struct kvm_config;
+
+void kvm__arch_sanitize_cfg(struct kvm_config *cfg);

minor nit: We could have passed "struct kvm", which could

1) avoid the hunk above for ARM_MAX_MEMORY()
2) make better use of the other info available in KVM for
   anything that we could potentially do.

But hey, we don't change the kvmtool that much. So, feel free
to ignore this.

Either way:

Reviewed-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux