qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 28/87] kvm: introduce kvm_kernel_irqchip_* functions
Date: Wed, 18 Dec 2019 13:01:54 +0100	[thread overview]
Message-ID: <1576670573-48048-29-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1576670573-48048-1-git-send-email-pbonzini@redhat.com>

The KVMState struct is opaque, so provide accessors for the fields
that will be moved from current_machine to the accelerator.  For now
they just forward to the machine object, but this will change.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 accel/kvm/kvm-all.c  | 23 +++++++++++++++++++----
 hw/ppc/e500.c        |  5 ++---
 hw/ppc/spapr_irq.c   | 16 ++++------------
 include/sysemu/kvm.h |  7 +++++--
 target/arm/kvm.c     |  8 ++++----
 target/i386/kvm.c    |  4 ++--
 target/mips/kvm.c    |  2 +-
 target/ppc/kvm.c     |  2 +-
 target/s390x/kvm.c   |  2 +-
 9 files changed, 39 insertions(+), 30 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 4770dd8..34e8f26 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1774,7 +1774,7 @@ void kvm_irqchip_set_qemuirq_gsi(KVMState *s, qemu_irq irq, int gsi)
     g_hash_table_insert(s->gsimap, irq, GINT_TO_POINTER(gsi));
 }
 
-static void kvm_irqchip_create(MachineState *machine, KVMState *s)
+static void kvm_irqchip_create(KVMState *s)
 {
     int ret;
 
@@ -1792,9 +1792,9 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)
 
     /* First probe and see if there's a arch-specific hook to create the
      * in-kernel irqchip for us */
-    ret = kvm_arch_irqchip_create(machine, s);
+    ret = kvm_arch_irqchip_create(s);
     if (ret == 0) {
-        if (machine_kernel_irqchip_split(machine)) {
+        if (kvm_kernel_irqchip_split()) {
             perror("Split IRQ chip mode not supported.");
             exit(1);
         } else {
@@ -2066,7 +2066,7 @@ static int kvm_init(MachineState *ms)
     }
 
     if (machine_kernel_irqchip_allowed(ms)) {
-        kvm_irqchip_create(ms, s);
+        kvm_irqchip_create(s);
     }
 
     if (kvm_eventfds_allowed) {
@@ -2983,6 +2983,21 @@ static void kvm_set_kvm_shadow_mem(Object *obj, Visitor *v,
     s->kvm_shadow_mem = value;
 }
 
+bool kvm_kernel_irqchip_allowed(void)
+{
+    return machine_kernel_irqchip_allowed(current_machine);
+}
+
+bool kvm_kernel_irqchip_required(void)
+{
+    return machine_kernel_irqchip_required(current_machine);
+}
+
+bool kvm_kernel_irqchip_split(void)
+{
+    return machine_kernel_irqchip_split(current_machine);
+}
+
 static void kvm_accel_instance_init(Object *obj)
 {
     KVMState *s = KVM_STATE(obj);
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 91cd4c2..12b6a5b 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -793,7 +793,6 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
                                       MemoryRegion *ccsr,
                                       IrqLines *irqs)
 {
-    MachineState *machine = MACHINE(pms);
     const PPCE500MachineClass *pmc = PPCE500_MACHINE_GET_CLASS(pms);
     DeviceState *dev = NULL;
     SysBusDevice *s;
@@ -801,10 +800,10 @@ static DeviceState *ppce500_init_mpic(PPCE500MachineState *pms,
     if (kvm_enabled()) {
         Error *err = NULL;
 
-        if (machine_kernel_irqchip_allowed(machine)) {
+        if (kvm_kernel_irqchip_allowed()) {
             dev = ppce500_init_mpic_kvm(pmc, irqs, &err);
         }
-        if (machine_kernel_irqchip_required(machine) && !dev) {
+        if (kvm_kernel_irqchip_required() && !dev) {
             error_reportf_err(err,
                               "kernel_irqchip requested but unavailable: ");
             exit(1);
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index 07e08d6..373505d 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -75,12 +75,11 @@ int spapr_irq_init_kvm(SpaprInterruptControllerInitKvm fn,
                        uint32_t nr_servers,
                        Error **errp)
 {
-    MachineState *machine = MACHINE(qdev_get_machine());
     Error *local_err = NULL;
 
-    if (kvm_enabled() && machine_kernel_irqchip_allowed(machine)) {
+    if (kvm_enabled() && kvm_kernel_irqchip_allowed()) {
         if (fn(intc, nr_servers, &local_err) < 0) {
-            if (machine_kernel_irqchip_required(machine)) {
+            if (kvm_kernel_irqchip_required()) {
                 error_prepend(&local_err,
                               "kernel_irqchip requested but unavailable: ");
                 error_propagate(errp, local_err);
@@ -185,7 +184,7 @@ static int spapr_irq_check(SpaprMachineState *spapr, Error **errp)
      */
     if (kvm_enabled() &&
         spapr->irq == &spapr_irq_dual &&
-        machine_kernel_irqchip_required(machine) &&
+        kvm_kernel_irqchip_required() &&
         xics_kvm_has_broken_disconnect(spapr)) {
         error_setg(errp, "KVM is too old to support ic-mode=dual,kernel-irqchip=on");
         return -1;
@@ -288,20 +287,13 @@ uint32_t spapr_irq_nr_msis(SpaprMachineState *spapr)
 
 void spapr_irq_init(SpaprMachineState *spapr, Error **errp)
 {
-    MachineState *machine = MACHINE(spapr);
     SpaprMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
 
-    if (machine_kernel_irqchip_split(machine)) {
+    if (kvm_enabled() && kvm_kernel_irqchip_split()) {
         error_setg(errp, "kernel_irqchip split mode not supported on pseries");
         return;
     }
 
-    if (!kvm_enabled() && machine_kernel_irqchip_required(machine)) {
-        error_setg(errp,
-                   "kernel_irqchip requested but only available with KVM");
-        return;
-    }
-
     if (spapr_irq_check(spapr, errp) < 0) {
         return;
     }
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 9fe233b..aaf2a50 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -519,10 +519,13 @@ void kvm_pc_gsi_handler(void *opaque, int n, int level);
 void kvm_pc_setup_irq_routing(bool pci_enabled);
 void kvm_init_irq_routing(KVMState *s);
 
+bool kvm_kernel_irqchip_allowed(void);
+bool kvm_kernel_irqchip_required(void);
+bool kvm_kernel_irqchip_split(void);
+
 /**
  * kvm_arch_irqchip_create:
  * @KVMState: The KVMState pointer
- * @MachineState: The MachineState pointer
  *
  * Allow architectures to create an in-kernel irq chip themselves.
  *
@@ -530,7 +533,7 @@ void kvm_init_irq_routing(KVMState *s);
  *            0: irq chip was not created
  *          > 0: irq chip was created
  */
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s);
+int kvm_arch_irqchip_create(KVMState *s);
 
 /**
  * kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
index 5b82cef..b87b59a 100644
--- a/target/arm/kvm.c
+++ b/target/arm/kvm.c
@@ -741,11 +741,11 @@ void kvm_arch_init_irq_routing(KVMState *s)
 {
 }
 
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s)
 {
-     if (machine_kernel_irqchip_split(ms)) {
-         perror("-machine kernel_irqchip=split is not supported on ARM.");
-         exit(1);
+    if (kvm_kernel_irqchip_split()) {
+        perror("-machine kernel_irqchip=split is not supported on ARM.");
+        exit(1);
     }
 
     /* If we can create the VGIC using the newer device control API, we
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 62ce681..ef63f3a 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -4494,10 +4494,10 @@ void kvm_arch_init_irq_routing(KVMState *s)
     }
 }
 
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s)
 {
     int ret;
-    if (machine_kernel_irqchip_split(ms)) {
+    if (kvm_kernel_irqchip_split()) {
         ret = kvm_vm_enable_cap(s, KVM_CAP_SPLIT_IRQCHIP, 0, 24);
         if (ret) {
             error_report("Could not enable split irqchip mode: %s",
diff --git a/target/mips/kvm.c b/target/mips/kvm.c
index 578bc14..de3e26e 100644
--- a/target/mips/kvm.c
+++ b/target/mips/kvm.c
@@ -57,7 +57,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     return 0;
 }
 
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s)
 {
     return 0;
 }
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index 7406d18..f7e187c 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -152,7 +152,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     return 0;
 }
 
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s)
 {
     return 0;
 }
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index ad6e38c..15260ae 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -374,7 +374,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     return 0;
 }
 
-int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s)
 {
     return 0;
 }
-- 
1.8.3.1




  parent reply	other threads:[~2019-12-18 12:28 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 12:01 [PULL 00/87] Misc patches for 2019-12-18 Paolo Bonzini
2019-12-18 12:01 ` [PULL 01/87] kvm: Reallocate dirty_bmap when we change a slot Paolo Bonzini
2019-12-18 12:01 ` [PULL 02/87] migration-test: Create cmd_soure and cmd_target Paolo Bonzini
2019-12-18 12:01 ` [PULL 03/87] migration-test: Move hide_stderr to common commandline Paolo Bonzini
2019-12-18 12:01 ` [PULL 04/87] migration-test: Move -machine " Paolo Bonzini
2019-12-18 12:01 ` [PULL 05/87] migration-test: Move memory size " Paolo Bonzini
2019-12-18 12:01 ` [PULL 06/87] migration-test: Move shmem handling " Paolo Bonzini
2019-12-18 12:01 ` [PULL 07/87] migration-test: Move -name " Paolo Bonzini
2019-12-18 12:01 ` [PULL 08/87] migration-test: Move -serial " Paolo Bonzini
2019-12-18 12:01 ` [PULL 09/87] migration-test: Move -incomming " Paolo Bonzini
2019-12-18 12:01 ` [PULL 10/87] migration-test: Rename cmd_src/dst to arch_source/arch_target Paolo Bonzini
2019-12-18 12:01 ` [PULL 11/87] migration-test: Use a struct for test_migrate_start parameters Paolo Bonzini
2019-12-18 12:01 ` [PULL 12/87] memory: do not look at current_machine->accel Paolo Bonzini
2019-12-18 12:01 ` [PULL 13/87] vl: move icount configuration earlier Paolo Bonzini
2019-12-18 12:01 ` [PULL 14/87] tcg: move qemu_tcg_configure to accel/tcg/tcg-all.c Paolo Bonzini
2019-12-18 12:01 ` [PULL 15/87] vl: extract accelerator option processing to a separate function Paolo Bonzini
2019-12-18 12:01 ` [PULL 16/87] vl: merge -accel processing into configure_accelerators Paolo Bonzini
2019-12-18 12:01 ` [PULL 17/87] accel: compile accel/accel.c just once Paolo Bonzini
2019-12-18 12:01 ` [PULL 18/87] vl: introduce object_parse_property_opt Paolo Bonzini
2019-12-18 12:01 ` [PULL 19/87] vl: configure accelerators from -accel options Paolo Bonzini
2019-12-18 12:01 ` [PULL 20/87] vl: warn for unavailable accelerators, clarify messages Paolo Bonzini
2020-01-16 14:50   ` Laurent Vivier
2020-01-16 15:10     ` Paolo Bonzini
2019-12-18 12:01 ` [PULL 21/87] qom: introduce object_register_sugar_prop Paolo Bonzini
2019-12-18 12:01 ` [PULL 22/87] qom: add object_new_with_class Paolo Bonzini
2019-12-18 12:01 ` [PULL 23/87] accel: pass object to accel_init_machine Paolo Bonzini
2019-12-18 12:01 ` [PULL 24/87] tcg: convert "-accel threads" to a QOM property Paolo Bonzini
2019-12-18 12:01 ` [PULL 25/87] tcg: add "-accel tcg,tb-size" and deprecate "-tb-size" Paolo Bonzini
2019-12-18 12:01 ` [PULL 26/87] xen: convert "-machine igd-passthru" to an accelerator property Paolo Bonzini
2019-12-18 12:01 ` [PULL 27/87] kvm: convert "-machine kvm_shadow_mem" " Paolo Bonzini
2019-12-18 12:01 ` Paolo Bonzini [this message]
2019-12-18 12:01 ` [PULL 29/87] kvm: convert "-machine kernel_irqchip" " Paolo Bonzini
2020-01-07 14:46   ` Peter Maydell
2020-01-07 16:18     ` Paolo Bonzini
2019-12-18 12:01 ` [PULL 30/87] Makefile: remove unused variables Paolo Bonzini
2019-12-18 12:01 ` [PULL 31/87] object: Improve documentation of interfaces Paolo Bonzini
2019-12-18 12:01 ` [PULL 32/87] build-sys: build vhost-user-gpu only if CONFIG_TOOLS Paolo Bonzini
2019-12-18 12:01 ` [PULL 33/87] build-sys: do not include Windows SLIRP dependencies in $LIBS Paolo Bonzini
2019-12-18 12:02 ` [PULL 34/87] migration: fix maybe-uninitialized warning Paolo Bonzini
2019-12-18 12:02 ` [PULL 35/87] monitor: fix maybe-uninitialized Paolo Bonzini
2019-12-18 12:02 ` [PULL 36/87] vhost-user-scsi: fix printf format warning Paolo Bonzini
2019-12-18 12:02 ` [PULL 37/87] os-posix: simplify os_find_datadir Paolo Bonzini
2019-12-18 12:02 ` [PULL 38/87] tests: skip block layer tests if !CONFIG_TOOLS Paolo Bonzini
2019-12-18 12:02 ` [PULL 39/87] libvixl: remove per-target compiler flags Paolo Bonzini
2019-12-18 12:02 ` [PULL 40/87] crypto: move common bits for all emulators to libqemuutil Paolo Bonzini
2019-12-18 12:02 ` [PULL 41/87] stubs: replace stubs with lnot if applicable Paolo Bonzini
2019-12-18 12:02 ` [PULL 42/87] configure: set $PYTHON to a full path Paolo Bonzini
2019-12-18 12:02 ` [PULL 43/87] configure: simplify vhost condition with Kconfig Paolo Bonzini
2019-12-18 12:02 ` [PULL 44/87] i386: conditionally compile more files Paolo Bonzini
2019-12-18 12:02 ` [PULL 45/87] fw_cfg: allow building without other devices Paolo Bonzini
2019-12-18 12:02 ` [PULL 46/87] hw: replace hw/i386/pc.h with a header just for the i8259 Paolo Bonzini
2019-12-18 12:02 ` [PULL 47/87] pci-stub: add more MSI functions Paolo Bonzini
2019-12-18 12:02 ` [PULL 48/87] x86: move SMM property to X86MachineState Paolo Bonzini
2019-12-23 11:28   ` Michal Prívozník
2019-12-23 11:33     ` Daniel P. Berrangé
2019-12-23 11:40       ` Michal Prívozník
2019-12-23 13:38         ` Paolo Bonzini
2019-12-23 14:46           ` Michal Prívozník
2019-12-18 12:02 ` [PULL 49/87] hw/i386/pc: Convert DPRINTF() to trace events Paolo Bonzini
2019-12-18 12:02 ` [PULL 50/87] x86: move more x86-generic functions out of PC files Paolo Bonzini
2019-12-18 12:02 ` [PULL 51/87] acpi: move PC stubs out of stubs/ Paolo Bonzini
2019-12-18 12:02 ` [PULL 52/87] pc: stubify x86 iommu Paolo Bonzini
2019-12-18 12:02 ` [PULL 53/87] hw/i386: De-duplicate gsi_handler() to remove kvm_pc_gsi_handler() Paolo Bonzini
2019-12-18 12:02 ` [PULL 54/87] hw/i386: Simplify ioapic_init_gsi() Paolo Bonzini
2019-12-18 12:02 ` [PULL 55/87] hw/isa/isa-bus: cleanup irq functions Paolo Bonzini
2019-12-18 12:02 ` [PULL 56/87] hw/i386/pc: Use TYPE_PORT92 instead of hardcoded string Paolo Bonzini
2019-12-18 12:02 ` [PULL 57/87] hw/i386/pc: Inline port92_init() Paolo Bonzini
2019-12-18 12:02 ` [PULL 58/87] hw/i386/pc: Extract the port92 device Paolo Bonzini
2019-12-18 12:02 ` [PULL 59/87] hyperv: Use auto rcu_read macros Paolo Bonzini
2019-12-18 12:02 ` [PULL 60/87] qsp: Use WITH_RCU_READ_LOCK_GUARD Paolo Bonzini
2019-12-18 12:02 ` [PULL 61/87] memory: use RCU_READ_LOCK_GUARD Paolo Bonzini
2019-12-18 12:02 ` [PULL 62/87] colo: fix return without releasing RCU Paolo Bonzini
2019-12-18 12:02 ` [PULL 63/87] build: rename CONFIG_LIBCAP to CONFIG_LIBCAP_NG Paolo Bonzini
2019-12-18 12:02 ` [PULL 64/87] docs: import Linux kernel-doc script and extension Paolo Bonzini
2019-12-18 12:02 ` [PULL 65/87] docs: tweak kernel-doc for QEMU coding standards Paolo Bonzini
2019-12-18 12:02 ` [PULL 66/87] docs/conf.py: Enable use of kerneldoc sphinx extension Paolo Bonzini
2019-12-18 12:02 ` [PULL 67/87] Makefile: disable Sphinx nitpicking Paolo Bonzini
2019-12-18 12:02 ` [PULL 68/87] bitops.h: Silence kernel-doc complaints Paolo Bonzini
2019-12-18 12:02 ` [PULL 69/87] docs: Create bitops.rst as example of kernel-docs Paolo Bonzini
2019-12-18 12:02 ` [PULL 70/87] memory.h: Silence kernel-doc complaints Paolo Bonzini
2019-12-18 12:02 ` [PULL 71/87] docs: add memory API reference Paolo Bonzini
2019-12-18 12:02 ` [PULL 72/87] memory: include MemoryListener documentation and some missing function parameters Paolo Bonzini
2019-12-18 12:02 ` [PULL 73/87] migration: check length directly to make sure the range is aligned Paolo Bonzini
2019-12-18 12:02 ` [PULL 74/87] WHPX: refactor load library Paolo Bonzini
2019-12-18 12:02 ` [PULL 75/87] target/i386: remove unused pci-assign codes Paolo Bonzini
2019-12-18 12:02 ` [PULL 76/87] Fix some comment spelling errors Paolo Bonzini
2019-12-18 12:02 ` [PULL 77/87] hw/pci-host/i440fx: Correct the header description Paolo Bonzini
2019-12-18 12:02 ` [PULL 78/87] hw/pci-host/i440fx: Extract PCII440FXState to "hw/pci-host/i440fx.h" Paolo Bonzini
2019-12-18 12:02 ` [PULL 79/87] hw/pci-host/i440fx: Use size_t to iterate over ARRAY_SIZE() Paolo Bonzini
2019-12-18 12:02 ` [PULL 80/87] hw/pci-host/i440fx: Use definitions instead of magic values Paolo Bonzini
2019-12-18 12:02 ` [PULL 81/87] hw/pci-host/i440fx: Extract the IGD passthrough host bridge device Paolo Bonzini
2019-12-18 12:02 ` [PULL 82/87] hw/pci-host: Add Kconfig entry to select the IGD Passthrough Host Bridge Paolo Bonzini
2019-12-18 12:02 ` [PULL 83/87] hw/i386: Remove the deprecated machines 0.12 up to 0.15 Paolo Bonzini
2019-12-18 12:02 ` [PULL 84/87] hw/audio: Remove the "use_broken_id" hack from the AC97 device Paolo Bonzini
2019-12-18 12:02 ` [PULL 85/87] hw/pci: Remove the "command_serr_enable" property Paolo Bonzini
2019-12-18 12:02 ` [PULL 86/87] hw/display: Remove "rombar" hack from vga-pci and vmware_vga Paolo Bonzini
2019-12-18 12:02 ` [PULL 87/87] vga: cleanup mapping of VRAM for non-PCI VGA Paolo Bonzini
2019-12-20 12:45 ` [PULL 00/87] Misc patches for 2019-12-18 Peter Maydell

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=1576670573-48048-29-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@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).