From patchwork Wed Dec 19 08:50:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1015909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43KTG03m2zz9s8r for ; Wed, 19 Dec 2018 19:54:00 +1100 (AEDT) Received: from localhost ([::1]:58338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZXc5-0002A2-Hu for incoming@patchwork.ozlabs.org; Wed, 19 Dec 2018 03:53:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZXZ7-0008Q3-2P for qemu-devel@nongnu.org; Wed, 19 Dec 2018 03:50:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZXZ5-0004BQ-Iy for qemu-devel@nongnu.org; Wed, 19 Dec 2018 03:50:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34680) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZXZ5-0004Ac-9S for qemu-devel@nongnu.org; Wed, 19 Dec 2018 03:50:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56B862D2BF5 for ; Wed, 19 Dec 2018 08:50:50 +0000 (UTC) Received: from xz-x1.nay.redhat.com (dhcp-14-128.nay.redhat.com [10.66.14.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 171131001F50; Wed, 19 Dec 2018 08:50:47 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Wed, 19 Dec 2018 16:50:35 +0800 Message-Id: <20181219085038.7729-2-peterx@redhat.com> In-Reply-To: <20181219085038.7729-1-peterx@redhat.com> References: <20181219085038.7729-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 19 Dec 2018 08:50:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/4] kvm: let split be optional for kvm_arch_irqchip_create X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , Paolo Bonzini , Eduardo Habkost , peterx@redhat.com, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch allows the kvm_arch_irqchip_create() to return 0 if the split irqchip is specified but not forced by the user. Also, modify kvm_irqchip_create() similiarly. This patch should have no functional change for existing code since currently if split is specified it must be forced by the user so we'll always have machine_kernel_irqchip_required() returns true. However it could potentially be used in follow up patches when we want to turn split kernel irqchip as default for QEMU 4.0 which could trigger the case that kernel_irqchip_required=N while kernel_irqchip_split=Y. When with that, we'll first try with split irqchip, and falls back to normal kernel irqchip when split capability is not provided by the kernel. This brings us benefit that we can even run a default QEMU 4.0 on old kernels that does not support split irqchip (<4.4) but at the same time enable split irqchip for new kernels (>=4.4) as default. Signed-off-by: Peter Xu --- accel/kvm/kvm-all.c | 3 ++- target/i386/kvm.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 4880a05399..b008364041 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1468,7 +1468,8 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s) * in-kernel irqchip for us */ ret = kvm_arch_irqchip_create(machine, s); if (ret == 0) { - if (machine_kernel_irqchip_split(machine)) { + if (machine_kernel_irqchip_required(machine) && + machine_kernel_irqchip_split(machine)) { perror("Split IRQ chip mode not supported."); exit(1); } else { diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 739cf8c8ea..8f919f8f9f 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -3685,9 +3685,9 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s) if (machine_kernel_irqchip_split(ms)) { ret = kvm_vm_enable_cap(s, KVM_CAP_SPLIT_IRQCHIP, 0, 24); if (ret) { - error_report("Could not enable split irqchip mode: %s", - strerror(-ret)); - exit(1); + assert(ret < 0); + /* If split not required, return 0 instead to retry */ + return machine_kernel_irqchip_required(ms) ? ret : 0; } else { DPRINTF("Enabled KVM_CAP_SPLIT_IRQCHIP\n"); kvm_split_irqchip = true;