qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Tokarev <mjt@tls.msk.ru>
To: qemu-devel@nongnu.org
Cc: qemu-stable@nongnu.org,
	"Akihiko Odaki" <akihiko.odaki@daynix.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Michael Tokarev" <mjt@tls.msk.ru>
Subject: [Stable-7.2.6 16/37] kvm: Introduce kvm_arch_get_default_type hook
Date: Sat,  9 Sep 2023 16:04:46 +0300	[thread overview]
Message-ID: <20230909130511.354171-16-mjt@tls.msk.ru> (raw)
In-Reply-To: <qemu-stable-7.2.6-20230909160328@cover.tls.msk.ru>

From: Akihiko Odaki <akihiko.odaki@daynix.com>

kvm_arch_get_default_type() returns the default KVM type. This hook is
particularly useful to derive a KVM type that is valid for "none"
machine model, which is used by libvirt to probe the availability of
KVM.

For MIPS, the existing mips_kvm_type() is reused. This function ensures
the availability of VZ which is mandatory to use KVM on the current
QEMU.

Cc: qemu-stable@nongnu.org
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Message-id: 20230727073134.134102-2-akihiko.odaki@daynix.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
[PMM: added doc comment for new function]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
(cherry picked from commit 5e0d65909c6f335d578b90491e165440c99adf81)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index f99b0becd8..0a127ece11 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2294,7 +2294,7 @@ static int kvm_init(MachineState *ms)
     KVMState *s;
     const KVMCapabilityInfo *missing_cap;
     int ret;
-    int type = 0;
+    int type;
     uint64_t dirty_log_manual_caps;
 
     qemu_mutex_init(&kml_slots_lock);
@@ -2358,6 +2358,8 @@ static int kvm_init(MachineState *ms)
         type = mc->kvm_type(ms, kvm_type);
     } else if (mc->kvm_type) {
         type = mc->kvm_type(ms, NULL);
+    } else {
+        type = kvm_arch_get_default_type(ms);
     }
 
     do {
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index 25534288dd..b4f6bff1b8 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -29,7 +29,6 @@
 #include "qemu/datadir.h"
 #include "qapi/error.h"
 #include "elf.h"
-#include "kvm_mips.h"
 #include "hw/char/serial.h"
 #include "hw/intc/loongson_liointc.h"
 #include "hw/mips/mips.h"
@@ -617,7 +616,6 @@ static void loongson3v_machine_class_init(ObjectClass *oc, void *data)
     mc->max_cpus = LOONGSON_MAX_VCPUS;
     mc->default_ram_id = "loongson3.highram";
     mc->default_ram_size = 1600 * MiB;
-    mc->kvm_type = mips_kvm_type;
     mc->minimum_page_bits = 14;
 }
 
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index e9a97eda8c..c4ff7d9a4c 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -369,6 +369,8 @@ int kvm_arch_get_registers(CPUState *cpu);
 
 int kvm_arch_put_registers(CPUState *cpu, int level);
 
+int kvm_arch_get_default_type(MachineState *ms);
+
 int kvm_arch_init(MachineState *ms, KVMState *s);
 
 int kvm_arch_init_vcpu(CPUState *cpu);
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 84da49332c..34bc329b5b 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -247,6 +247,11 @@ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
     return ret > 0 ? ret : 40;
 }
 
+int kvm_arch_get_default_type(MachineState *ms)
+{
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     int ret = 0;
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index a213209379..002b699030 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -2455,6 +2455,11 @@ static void register_smram_listener(Notifier *n, void *unused)
                                  &smram_address_space, 1, "kvm-smram");
 }
 
+int kvm_arch_get_default_type(MachineState *ms)
+{
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     uint64_t identity_base = 0xfffbc000;
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index bcb8e06b2c..27cf4e8c1b 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -1266,7 +1266,7 @@ int kvm_arch_msi_data_to_gsi(uint32_t data)
     abort();
 }
 
-int mips_kvm_type(MachineState *machine, const char *vm_type)
+int kvm_arch_get_default_type(MachineState *machine)
 {
 #if defined(KVM_CAP_MIPS_VZ) || defined(KVM_CAP_MIPS_TE)
     int r;
diff --git a/target/mips/kvm_mips.h b/target/mips/kvm_mips.h
index 171d53dbe1..c711269d0a 100644
--- a/target/mips/kvm_mips.h
+++ b/target/mips/kvm_mips.h
@@ -25,13 +25,4 @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu);
 int kvm_mips_set_interrupt(MIPSCPU *cpu, int irq, int level);
 int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level);
 
-#ifdef CONFIG_KVM
-int mips_kvm_type(MachineState *machine, const char *vm_type);
-#else
-static inline int mips_kvm_type(MachineState *machine, const char *vm_type)
-{
-    return 0;
-}
-#endif
-
 #endif /* KVM_MIPS_H */
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 7c25348b7b..4bcda6e2dc 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -108,6 +108,11 @@ static int kvm_ppc_register_host_cpu_type(void);
 static void kvmppc_get_cpu_characteristics(KVMState *s);
 static int kvmppc_get_dec_bits(void);
 
+int kvm_arch_get_default_type(MachineState *ms)
+{
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     cap_interrupt_unset = kvm_check_extension(s, KVM_CAP_PPC_UNSET_IRQ);
diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c
index 30f21453d6..d28d5241f9 100644
--- a/target/riscv/kvm.c
+++ b/target/riscv/kvm.c
@@ -426,6 +426,11 @@ int kvm_arch_add_msi_route_post(struct kvm_irq_routing_entry *route,
     return 0;
 }
 
+int kvm_arch_get_default_type(MachineState *ms)
+{
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     return 0;
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 3ac7ec9acf..8ffe140513 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -340,6 +340,11 @@ static void ccw_machine_class_foreach(ObjectClass *oc, void *opaque)
     mc->default_cpu_type = S390_CPU_TYPE_NAME("host");
 }
 
+int kvm_arch_get_default_type(MachineState *ms)
+{
+    return 0;
+}
+
 int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     object_class_foreach(ccw_machine_class_foreach, TYPE_S390_CCW_MACHINE,
-- 
2.39.2



  parent reply	other threads:[~2023-09-09 13:17 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-09 13:04 [Stable-7.2.6 00/37] Patch Round-up for stable 7.2.6, freeze on 2023-09-19 Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 01/37] machine: Add helpers to get cores/threads per socket Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 02/37] hw/smbios: Fix smbios_smp_sockets caculation Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 03/37] hw/smbios: Fix thread count in type4 Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 04/37] hw/smbios: Fix core " Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 05/37] dump: kdump-zlib data pages not dumped with pvtime/aarch64 Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 06/37] hw/nvme: fix CRC64 for guard tag Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 07/37] linux-user/elfload: Set V in ELF_HWCAP for RISC-V Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 08/37] include/exec/user: Set ABI_LLONG_ALIGNMENT to 4 for microblaze Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 09/37] include/exec/user: Set ABI_LLONG_ALIGNMENT to 4 for nios2 Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 10/37] Fixed incorrect LLONG alignment for openrisc and cris Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 11/37] target/s390x: Fix the "ignored match" case in VSTRS Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 12/37] target/s390x: Use a 16-bit immediate in VREP Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 13/37] target/s390x: Fix VSTL with a large length Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 14/37] target/s390x: Check reserved bits of VFMIN/VFMAX's M5 Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 15/37] include/hw/virtio/virtio-gpu: Fix virtio-gpu with blob on big endian hosts Michael Tokarev
2023-09-09 13:04 ` Michael Tokarev [this message]
2023-09-09 13:04 ` [Stable-7.2.6 17/37] accel/kvm: Specify default IPA size for arm64 Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 18/37] target/arm: Fix SME ST1Q Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 19/37] target/arm: Fix 64-bit SSRA Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 20/37] docs/about/license: Update LICENSE URL Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 21/37] block-migration: Ensure we don't crash during migration cleanup Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 22/37] hw/ppc/e500: fix broken snapshot replay Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 23/37] ppc/vof: Fix missed fields in VOF cleanup Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 24/37] target/ppc: Flush inputs to zero with NJ in ppc_store_vscr Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 25/37] hw/ide/core: set ERR_STAT in unsupported command completion Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 26/37] hw/ide/ahci: write D2H FIS when processing NCQ command Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 27/37] hw/ide/ahci: simplify and document PxCI handling Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 28/37] hw/ide/ahci: PxSACT and PxCI is cleared when PxCMD.ST is cleared Michael Tokarev
2023-09-09 13:04 ` [Stable-7.2.6 29/37] hw/ide/ahci: PxCI should not get cleared when ERR_STAT is set Michael Tokarev
2023-09-10 21:07   ` Michael Tokarev
2023-09-11 13:34     ` Niklas Cassel
2023-09-09 13:05 ` [Stable-7.2.6 30/37] hw/ide/ahci: fix ahci_write_fis_sdb() Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 31/37] hw/ide/ahci: fix broken SError handling Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 32/37] hw/i2c/aspeed: Fix Tx count and Rx size error in buffer pool mode Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 33/37] hw/i2c/aspeed: Fix TXBUF transmission start position error Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 34/37] qemu-options.hx: Rephrase the descriptions of the -hd* and -cdrom options Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 35/37] docs tests: Fix use of migrate_set_parameter Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 36/37] hw/net/vmxnet3: Fix guest-triggerable assert() Michael Tokarev
2023-09-09 13:05 ` [Stable-7.2.6 37/37] qxl: don't assert() if device isn't yet initialized Michael Tokarev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230909130511.354171-16-mjt@tls.msk.ru \
    --to=mjt@tls.msk.ru \
    --cc=akihiko.odaki@daynix.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).