From patchwork Mon Mar 12 18:34:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey G X-Patchwork-Id: 10277001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7E6C602C2 for ; Mon, 12 Mar 2018 18:37:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B995F28A96 for ; Mon, 12 Mar 2018 18:37:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE3B128BE7; Mon, 12 Mar 2018 18:37:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 30EBC28A96 for ; Mon, 12 Mar 2018 18:37:08 +0000 (UTC) Received: from localhost ([::1]:33868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSJn-00014u-Ci for patchwork-qemu-devel@patchwork.kernel.org; Mon, 12 Mar 2018 14:37:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evSIL-000835-Ke for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:35:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evSIK-0005Ir-Go for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:35:37 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:43792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1evSIK-0005Ic-90 for qemu-devel@nongnu.org; Mon, 12 Mar 2018 14:35:36 -0400 Received: by mail-pg0-x241.google.com with SMTP id e9so6864016pgs.10 for ; Mon, 12 Mar 2018 11:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6T+owXqu2De7dt5lXxGUpnFw9eoKo6Nm2sMPpm3ln7I=; b=kh911zWoHqL/DuzjGZAO40+HxKvNfvfyZMI/nwrE8EymNJPP4GJNEQlL2XpSRk0pkb OIKrCYeGccKDllim4jL+cfW0Pt0aDKjXk94zbnqvtDTziYICdiCgD0YA47cF0/Hg826k wh6eBUMEUx3fGJE5YP74cB3MR7/RASyjRnSu0EoAvchGopU9cr+xQ7uLYt4c9GZWO8/o LLvcEGf60Af+RC1e5va+Zp8TYQl9aDvWpBpM0fRwviRm+U25LB3lJFB/onwONwaKmbXt b/B1RxHVsAPbaC29FyFsuedZw976QpOb7dtXIYBxIwyCbupHmErrXnnC1kiSwVcD+YWN cAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=6T+owXqu2De7dt5lXxGUpnFw9eoKo6Nm2sMPpm3ln7I=; b=h/1M37eEiNerptq8UWpoYMATS5VEevA92jMAJuDqQbNYTfQn43UyZ6aNnSvBJp4/EY t+TMxcXVFtswTm/03bAkay1DulxeGcYUzStcuNKPWVVYsWH/Nh5OkRx6VNVEEvFsUCdz iQMgv07dhMNMwFi7XCqg4MyuWGB7XWCuflYQXdBTWNMbCUT0gXu7VNqjA2grQ4XGbcFR 1BzypiLE6L2VPFUhq0COHtJJwGya0J+10AOjyK4mdobM0TxGlfnYriNWUgCQ0DRYKbKr xsHY/5rtYWMq5ogj5/739UijIHRyTC6Z+j+amvLcE3rhMSCz9bzBptxZtMjyPX7Y0nYq KW1w== X-Gm-Message-State: AElRT7EjRNuPzGkwRL+74Wwdp3DdOF3h4spUwcsVXO7YDqVKSapydqy4 fkzAlWXQK8U/f2gYgLiWSqg= X-Google-Smtp-Source: AG47ELvejB94kDJ221FZy+1STBl2TxkNyWwYAMSFGUXwbhIGnIccO4fA1gT/T3UJyhZOFzvoXpRqYQ== X-Received: by 10.98.159.209 with SMTP id v78mr8846920pfk.49.1520879735367; Mon, 12 Mar 2018 11:35:35 -0700 (PDT) Received: from localhost.localdomain ([217.150.73.25]) by smtp.gmail.com with ESMTPSA id w10sm14468666pgr.57.2018.03.12.11.35.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 11:35:34 -0700 (PDT) From: Alexey Gerasimenko To: xen-devel@lists.xenproject.org Date: Tue, 13 Mar 2018 04:34:01 +1000 Message-Id: <4a65e8b30fe9d2a6c1c53b85ef2697f02e01d13f.1520867956.git.x1917x@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::241 Subject: [Qemu-devel] [RFC PATCH 16/30] q35/xen: Add Xen platform device support for Q35 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: Eduardo Habkost , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Alexey Gerasimenko , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Current Xen/QEMU method to control Xen Platform device on i440 is a bit odd -- enabling/disabling Xen platform device actually modifies the QEMU emulated machine type, namely xenfv <--> pc. In order to avoid multiplying machine types, use a new way to control Xen Platform device for QEMU -- "xen-platform-dev" machine property (bool). To maintain backward compatibility with existing Xen/QEMU setups, this is only applicable to q35 machine currently. i440 emulation still uses the old method (i.e. xenfv/pc machine selection) to control Xen Platform device, this may be changed later to xen-platform-dev property as well. This way we can use a single machine type (q35) and change just xen-platform-dev value to on/off to control Xen platform device. Signed-off-by: Alexey Gerasimenko --- hw/core/machine.c | 21 +++++++++++++++++++++ hw/i386/pc_q35.c | 14 ++++++++++++++ include/hw/boards.h | 1 + qemu-options.hx | 1 + 4 files changed, 37 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 5e2bbcdace..205e7da3ce 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -290,6 +290,20 @@ static void machine_set_igd_gfx_passthru(Object *obj, bool value, Error **errp) ms->igd_gfx_passthru = value; } +static bool machine_get_xen_platform_dev(Object *obj, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + return ms->xen_platform_dev; +} + +static void machine_set_xen_platform_dev(Object *obj, bool value, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + ms->xen_platform_dev = value; +} + static char *machine_get_firmware(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -595,6 +609,13 @@ static void machine_class_init(ObjectClass *oc, void *data) object_class_property_set_description(oc, "igd-passthru", "Set on/off to enable/disable igd passthrou", &error_abort); + object_class_property_add_bool(oc, "xen-platform-dev", + machine_get_xen_platform_dev, + machine_set_xen_platform_dev, &error_abort); + object_class_property_set_description(oc, "xen-platform-dev", + "Set on/off to enable/disable Xen Platform device", + &error_abort); + object_class_property_add_str(oc, "firmware", machine_get_firmware, machine_set_firmware, &error_abort); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0db670f6d7..62caf924cf 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -56,6 +56,18 @@ /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 +static void q35_xen_hvm_init(MachineState *machine) +{ + PCMachineState *pcms = PC_MACHINE(machine); + + if (xen_enabled()) { + /* check if Xen Platform device is enabled */ + if (machine->xen_platform_dev) { + pci_create_simple(pcms->bus, -1, "xen-platform"); + } + } +} + /* PC hardware initialisation */ static void pc_q35_init(MachineState *machine) { @@ -207,6 +219,8 @@ static void pc_q35_init(MachineState *machine) if (xen_enabled()) { pci_bus_irqs(host_bus, xen_cmn_set_irq, xen_cmn_pci_slot_get_pirq, ich9_lpc, ICH9_XEN_NUM_IRQ_SOURCES); + + q35_xen_hvm_init(machine); } else { pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc_map_irq, ich9_lpc, ICH9_LPC_NB_PIRQS); diff --git a/include/hw/boards.h b/include/hw/boards.h index efb0a9edfd..f35fc1cc03 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -238,6 +238,7 @@ struct MachineState { bool usb; bool usb_disabled; bool igd_gfx_passthru; + bool xen_platform_dev; char *firmware; bool iommu; bool suppress_vmdesc; diff --git a/qemu-options.hx b/qemu-options.hx index 6585058c6c..cee0b92028 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -38,6 +38,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " dump-guest-core=on|off include guest memory in a core dump (default=on)\n" " mem-merge=on|off controls memory merge support (default: on)\n" " igd-passthru=on|off controls IGD GFX passthrough support (default=off)\n" + " xen-platform-dev=on|off controls Xen Platform device (default=off)\n" " aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n" " dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n" " suppress-vmdesc=on|off disables self-describing migration (default=off)\n"