From patchwork Wed Oct 21 20:56:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15DAA14B4 for ; Wed, 21 Oct 2020 20:58:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0E2B24182 for ; Wed, 21 Oct 2020 20:58:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TLL5ZrM1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0E2B24182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLBh-0007Nj-Hz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 16:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAy-0005Yi-ET for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58640) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAh-0006ef-Jf for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WGr2zrfGyqftWBpF5ZVoBd91ihPhB/CBzX/ru9n2bC4=; b=TLL5ZrM1g2j3FVydkMu+fHMHGPHoHYzDqcjZ0gkT6F1UBq7zL7dHrZdhqpnEXzSqTe7yxf qZq4hajUI7U6ujQ8ty9f3G+pKkZypKo85Bd581Kj/7hzJB/FEvlaDp2Gs6tDuap71ij4nh 5gVANsH6YGKP5ZWuVnqeVtSeTzQRl8s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-194--r_UCunkMG27L25kcetI_w-1; Wed, 21 Oct 2020 16:57:19 -0400 X-MC-Unique: -r_UCunkMG27L25kcetI_w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F0801868431 for ; Wed, 21 Oct 2020 20:57:18 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 321066EF62; Wed, 21 Oct 2020 20:57:18 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/22] semihosting: fix order of initialization functions Date: Wed, 21 Oct 2020 16:56:55 -0400 Message-Id: <20201021205716.2359430-2-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" qemu_semihosting_console_init uses semihosting.chardev which is set by qemu_semihosting_connect_chardevs. Thus qemu_semihosting_connect_chardevs has to be called first. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 6f5b000f07..42314e6ff9 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4288,7 +4288,8 @@ void qemu_init(int argc, char **argv, char **envp) qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); - /* connect semihosting console input if requested */ + /* now chardevs have been created we may have semihosting to connect */ + qemu_semihosting_connect_chardevs(); qemu_semihosting_console_init(); if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) @@ -4298,9 +4299,6 @@ void qemu_init(int argc, char **argv, char **envp) if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) exit(1); - /* now chardevs have been created we may have semihosting to connect */ - qemu_semihosting_connect_chardevs(); - /* If no default VGA is requested, the default is "none". */ if (default_vga) { vga_model = get_default_vga_model(machine_class); From patchwork Wed Oct 21 20:56:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849733 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9569A61C for ; Wed, 21 Oct 2020 21:01:55 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44D052080D for ; Wed, 21 Oct 2020 21:01:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YtFAfj61" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44D052080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLF4-0002St-9Z for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:01:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40306) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0005UW-Lc for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25262) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAh-0006ei-Jq for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Bk7OcrGv2Bhi0vHJasD1ougOCtytCjn0scl9nnODkDg=; b=YtFAfj61ir8r1zaLGhL6GlBJ3Li0I/ZUBSQAmjnmdH+bB/rRxvXu4+B5AqfOkHIIM5KOLA Q9etWYtImlEUvMt+04EYU/c6TCBhKIAuxOPbsd1aoRrfDeOihibGHj12wGPaK3WGY+q1wY TEoHUwWVcXb35ExRPy9zpm62Fz3/m0A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-306-f2KVkNySMQK-kTyEs2icIg-1; Wed, 21 Oct 2020 16:57:20 -0400 X-MC-Unique: f2KVkNySMQK-kTyEs2icIg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 498AA800050 for ; Wed, 21 Oct 2020 20:57:19 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D04CD6EF62; Wed, 21 Oct 2020 20:57:18 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/22] machine: remove deprecated -machine enforce-config-section option Date: Wed, 21 Oct 2020 16:56:56 -0400 Message-Id: <20201021205716.2359430-3-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Deprecated since 3.1 and complicates the initialization sequence, remove it. Signed-off-by: Paolo Bonzini Reviewed-by: Thomas Huth --- docs/system/deprecated.rst | 12 ++++++------ hw/core/machine.c | 24 +----------------------- include/hw/boards.h | 1 - migration/migration.c | 10 ---------- qemu-options.hx | 8 -------- 5 files changed, 7 insertions(+), 48 deletions(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 895433c356..0ebce37a19 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -21,12 +21,6 @@ deprecated. System emulator command line arguments -------------------------------------- -``-machine enforce-config-section=on|off`` (since 3.1) -'''''''''''''''''''''''''''''''''''''''''''''''''''''' - -The ``enforce-config-section`` parameter is replaced by the -``-global migration.send-configuration={on|off}`` option. - ``-usbdevice`` (since 2.10.0) ''''''''''''''''''''''''''''' @@ -689,6 +683,12 @@ Support for invalid topologies is removed, the user must ensure topologies described with -smp include all possible cpus, i.e. *sockets* * *cores* * *threads* = *maxcpus*. +``-machine enforce-config-section=on|off`` (removed 5.2) +'''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +The ``enforce-config-section`` property was replaced by the +``-global migration.send-configuration={on|off}`` option. + Block devices ------------- diff --git a/hw/core/machine.c b/hw/core/machine.c index d740a7e963..80a918895a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -26,6 +26,7 @@ #include "sysemu/qtest.h" #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +#include "migration/misc.h" #include "migration/vmstate.h" GlobalProperty hw_compat_5_1[] = { @@ -411,24 +412,6 @@ static bool machine_get_suppress_vmdesc(Object *obj, Error **errp) return ms->suppress_vmdesc; } -static void machine_set_enforce_config_section(Object *obj, bool value, - Error **errp) -{ - MachineState *ms = MACHINE(obj); - - warn_report("enforce-config-section is deprecated, please use " - "-global migration.send-configuration=on|off instead"); - - ms->enforce_config_section = value; -} - -static bool machine_get_enforce_config_section(Object *obj, Error **errp) -{ - MachineState *ms = MACHINE(obj); - - return ms->enforce_config_section; -} - static char *machine_get_memory_encryption(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -857,11 +840,6 @@ static void machine_class_init(ObjectClass *oc, void *data) object_class_property_set_description(oc, "suppress-vmdesc", "Set on to disable self-describing migration"); - object_class_property_add_bool(oc, "enforce-config-section", - machine_get_enforce_config_section, machine_set_enforce_config_section); - object_class_property_set_description(oc, "enforce-config-section", - "Set on to enforce configuration section migration"); - object_class_property_add_str(oc, "memory-encryption", machine_get_memory_encryption, machine_set_memory_encryption); object_class_property_set_description(oc, "memory-encryption", diff --git a/include/hw/boards.h b/include/hw/boards.h index bf53e8a16e..a49e3a6b44 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -268,7 +268,6 @@ struct MachineState { char *firmware; bool iommu; bool suppress_vmdesc; - bool enforce_config_section; bool enable_graphics; char *memory_encryption; char *ram_memdev_id; diff --git a/migration/migration.c b/migration/migration.c index 0575ecb379..deb6005b8d 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -145,7 +145,6 @@ static void migrate_fd_cancel(MigrationState *s); void migration_object_init(void) { - MachineState *ms = MACHINE(qdev_get_machine()); Error *err = NULL; /* This can only be called once. */ @@ -170,15 +169,6 @@ void migration_object_init(void) error_report_err(err); exit(1); } - - /* - * We cannot really do this in migration_instance_init() since at - * that time global properties are not yet applied, then this - * value will be definitely replaced by something else. - */ - if (ms->enforce_config_section) { - current_migration->send_configuration = true; - } } void migration_shutdown(void) diff --git a/qemu-options.hx b/qemu-options.hx index 9e1ace04f7..2c83390504 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -34,7 +34,6 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " 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" " nvdimm=on|off controls NVDIMM support (default=off)\n" - " enforce-config-section=on|off enforce configuration section migration (default=off)\n" " memory-encryption=@var{} memory encryption object to use (default=none)\n" " hmat=on|off controls ACPI HMAT support (default=off)\n", QEMU_ARCH_ALL) @@ -91,13 +90,6 @@ SRST ``nvdimm=on|off`` Enables or disables NVDIMM support. The default is off. - ``enforce-config-section=on|off`` - If ``enforce-config-section`` is set to on, force migration code - to send configuration section even if the machine-type sets the - ``migration.send-configuration`` property to off. NOTE: this - parameter is deprecated. Please use ``-global`` - ``migration.send-configuration``\ =on\|off instead. - ``memory-encryption=`` Memory encryption object to use. The default is none. From patchwork Wed Oct 21 20:56:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 273F414B4 for ; Wed, 21 Oct 2020 20:58:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9E6D324182 for ; Wed, 21 Oct 2020 20:58:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ba4oPfaW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E6D324182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLBa-00075S-Uu for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 16:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAq-0005Su-1v for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42284) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAh-0006eq-Jq for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xsRFiIN1PeYLuXwm9621UgCML5X3cOzx9xwX2BS2mAE=; b=Ba4oPfaWilcaqkokQtV7Uc1E84jUeHLxY1LXEfys167oMgSo/VpLEzIVjSMsa8oSz7NM5j x0UYqSNFJr2oLpZ/0b0YobaEKxzdTxbsY/W6zH+uaP1M6KMLy9wZvOR+Chjt9CleuKbxbc esGLRCzdMDgX/shAmINiAaYWEqPFvrU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-BHO0pe9vOmuQh3IbwJ3g7Q-1; Wed, 21 Oct 2020 16:57:20 -0400 X-MC-Unique: BHO0pe9vOmuQh3IbwJ3g7Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF757835B92 for ; Wed, 21 Oct 2020 20:57:19 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 729E96EF62; Wed, 21 Oct 2020 20:57:19 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/22] machine: move UP defaults to class_base_init Date: Wed, 21 Oct 2020 16:56:57 -0400 Message-Id: <20201021205716.2359430-4-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Clean up vl.c, default min/max/default_cpus to uniprocessor directly in the QOM class initialization code. Signed-off-by: Paolo Bonzini Reviewed-by: Thomas Huth --- hw/core/machine.c | 6 +++++- softmmu/vl.c | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 80a918895a..d3a8450b1f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -854,8 +854,12 @@ static void machine_class_init(ObjectClass *oc, void *data) static void machine_class_base_init(ObjectClass *oc, void *data) { + MachineClass *mc = MACHINE_CLASS(oc); + mc->max_cpus = mc->max_cpus ?: 1; + mc->min_cpus = mc->min_cpus ?: 1; + mc->default_cpus = mc->default_cpus ?: 1; + if (!object_class_is_abstract(oc)) { - MachineClass *mc = MACHINE_CLASS(oc); const char *cname = object_class_get_name(oc); assert(g_str_has_suffix(cname, TYPE_MACHINE_SUFFIX)); mc->name = g_strndup(cname, diff --git a/softmmu/vl.c b/softmmu/vl.c index 42314e6ff9..75bc686397 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3966,11 +3966,6 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); } - /* machine_class: default to UP */ - machine_class->max_cpus = machine_class->max_cpus ?: 1; - machine_class->min_cpus = machine_class->min_cpus ?: 1; - machine_class->default_cpus = machine_class->default_cpus ?: 1; - /* default to machine_class->default_cpus */ current_machine->smp.cpus = machine_class->default_cpus; current_machine->smp.max_cpus = machine_class->default_cpus; From patchwork Wed Oct 21 20:56:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 905BB14B4 for ; Wed, 21 Oct 2020 21:01:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A1D42080D for ; Wed, 21 Oct 2020 21:01:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="C8GLzaNJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A1D42080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLEy-0002PC-Q3 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:01:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAt-0005TV-Hd for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27535) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAm-0006ew-NS for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FDqH/sBJn/80Lhr0h8LxhXgjheMXH4gfSukABjUgxwA=; b=C8GLzaNJ4gIPoXbeG42RiSYIduq39gj6mjvEDzcFR1PMTbWu1rNf10Eo5x52tGN7Zf3N3R rSqzFeehyYSRVS8Q5BUK19k5KVSRwrO6IcQbEcL1kKSygWF7rjWdKq18XECX9CxpDbwuEi WYuK6jPG5SMiSMf54ueubjNnjDfVGms= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-ltO41byjPdKAzKWcsGoTAQ-1; Wed, 21 Oct 2020 16:57:21 -0400 X-MC-Unique: ltO41byjPdKAzKWcsGoTAQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 71256186843A for ; Wed, 21 Oct 2020 20:57:20 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04ED16EF6B; Wed, 21 Oct 2020 20:57:19 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/22] machine: move SMP initialization from vl.c Date: Wed, 21 Oct 2020 16:56:58 -0400 Message-Id: <20201021205716.2359430-5-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Initialize the object's values from the class when the object is created, no need to have vl.c do it for us. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé --- hw/core/machine.c | 7 +++++++ softmmu/vl.c | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index d3a8450b1f..7efeac03b3 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -908,6 +908,13 @@ static void machine_initfn(Object *obj) /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify; qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); + + /* default to mc->default_cpus */ + ms->smp.cpus = mc->default_cpus; + ms->smp.max_cpus = mc->default_cpus; + ms->smp.cores = 1; + ms->smp.threads = 1; + ms->smp.sockets = 1; } static void machine_finalize(Object *obj) diff --git a/softmmu/vl.c b/softmmu/vl.c index 75bc686397..05422a15ee 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3966,13 +3966,6 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); } - /* default to machine_class->default_cpus */ - current_machine->smp.cpus = machine_class->default_cpus; - current_machine->smp.max_cpus = machine_class->default_cpus; - current_machine->smp.cores = 1; - current_machine->smp.threads = 1; - current_machine->smp.sockets = 1; - machine_class->smp_parse(current_machine, qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); From patchwork Wed Oct 21 20:56:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849735 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 065DB14B4 for ; Wed, 21 Oct 2020 21:01:59 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A365F2080D for ; Wed, 21 Oct 2020 21:01:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="a6/8k5kj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A365F2080D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:45822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLF7-0002Wc-Gf for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:01:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0005Xa-Qr for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:42915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAs-0006f1-3D for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UxOaKWQIo5EvktT7G1cSMndSN819NS7u5edOwbE8ebw=; b=a6/8k5kjCP0BB+TCUaYXCCCpbQg3elev/jsbKkSaR17/VrvF7guP+S98nwGI/3KilmxAFM VujX5tG6Ddf2ySXhHYVs14lOj3WBK6ZVjn7mqUPh6WDtDCkWiRnq1saddxg58sP3eSIh5a 5lpnOXhSlKK+HaDSzVDlVtvxfQb+lCU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406-nFGCVHw3M-mwFNTuH2dT8Q-1; Wed, 21 Oct 2020 16:57:21 -0400 X-MC-Unique: nFGCVHw3M-mwFNTuH2dT8Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03DE4804B62 for ; Wed, 21 Oct 2020 20:57:21 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AF3F6EF62; Wed, 21 Oct 2020 20:57:20 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/22] vl: extract validation of -smp to machine.c Date: Wed, 21 Oct 2020 16:56:59 -0400 Message-Id: <20201021205716.2359430-6-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Once smp_parse is done, the validation operates on the MachineState. There is no reason for that code to be in vl.c. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 23 +++++++++++++++++++++++ include/hw/boards.h | 1 + softmmu/vl.c | 20 ++------------------ 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 7efeac03b3..70b1e5e8e8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1073,6 +1073,29 @@ MemoryRegion *machine_consume_memdev(MachineState *machine, return ret; } +bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) +{ + MachineClass *mc = MACHINE_GET_CLASS(ms); + + mc->smp_parse(ms, opts); + + /* sanity-check smp_cpus and max_cpus against mc */ + if (ms->smp.cpus < mc->min_cpus) { + error_setg(errp, "Invalid SMP CPUs %d. The min CPUs " + "supported by machine '%s' is %d", + ms->smp.cpus, + mc->name, mc->min_cpus); + return false; + } else if (ms->smp.max_cpus > mc->max_cpus) { + error_setg(errp, "Invalid SMP CPUs %d. The max CPUs " + "supported by machine '%s' is %d", + current_machine->smp.max_cpus, + mc->name, mc->max_cpus); + return false; + } + return true; +} + void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); diff --git a/include/hw/boards.h b/include/hw/boards.h index a49e3a6b44..4537cfb5c6 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -26,6 +26,7 @@ OBJECT_DECLARE_TYPE(MachineState, MachineClass, MACHINE) extern MachineState *current_machine; void machine_run_board_init(MachineState *machine); +bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp); bool machine_usb(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); diff --git a/softmmu/vl.c b/softmmu/vl.c index 05422a15ee..8a7d11ef05 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3966,24 +3966,8 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); } - machine_class->smp_parse(current_machine, - qemu_opts_find(qemu_find_opts("smp-opts"), NULL)); - - /* sanity-check smp_cpus and max_cpus against machine_class */ - if (current_machine->smp.cpus < machine_class->min_cpus) { - error_report("Invalid SMP CPUs %d. The min CPUs " - "supported by machine '%s' is %d", - current_machine->smp.cpus, - machine_class->name, machine_class->min_cpus); - exit(1); - } - if (current_machine->smp.max_cpus > machine_class->max_cpus) { - error_report("Invalid SMP CPUs %d. The max CPUs " - "supported by machine '%s' is %d", - current_machine->smp.max_cpus, - machine_class->name, machine_class->max_cpus); - exit(1); - } + machine_smp_parse(current_machine, + qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal); if (mem_prealloc) { char *val; From patchwork Wed Oct 21 20:57:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DA391580 for ; Wed, 21 Oct 2020 20:58:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0EE0E24182 for ; Wed, 21 Oct 2020 20:58:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XWn1GzUl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0EE0E24182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:37404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLBd-0007Dp-Tk for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 16:58:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAy-0005YN-9Q for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43410) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006f4-8y for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lbX2ReBca6guWuzIMmhC8r3u3SrTIY1t9q1oICrcSw0=; b=XWn1GzUlyWX+Wb9ToLc/WnooUM1FqfQklByNdc626YArIVnaNOpb+s4AyEJmf//oF9UbkQ UDGZIJw11FnWstdeci6G/fLkGzhR7A73YHFnUULmb5e0XZUvTul5Frh4FqjTeoK5hs/YrX 8NL+Yqe2b1rjAgmW7lY6B9vNqnNjtQ0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-8HH49Ct2MM2Kd2QUXpfr0Q-1; Wed, 21 Oct 2020 16:57:22 -0400 X-MC-Unique: 8HH49Ct2MM2Kd2QUXpfr0Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B9971006C9E for ; Wed, 21 Oct 2020 20:57:21 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1E2BB6EF62; Wed, 21 Oct 2020 20:57:21 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/22] vl: remove bogus check Date: Wed, 21 Oct 2020 16:57:00 -0400 Message-Id: <20201021205716.2359430-7-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" There is no reason to prevent -preconfig -daemonize. Of course if no monitor is defined there will be no way to start the VM, but that is a user error. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 8a7d11ef05..3def5f3688 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4022,12 +4022,6 @@ void qemu_init(int argc, char **argv, char **envp) } if (is_daemonized()) { - if (!preconfig_exit_requested) { - error_report("'preconfig' and 'daemonize' options are " - "mutually exclusive"); - exit(EXIT_FAILURE); - } - /* According to documentation and historically, -nographic redirects * serial port, parallel port and monitor to stdio, which does not work * with -daemonize. We can redirect these to null instead, but since From patchwork Wed Oct 21 20:57:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1ABD214B4 for ; Wed, 21 Oct 2020 21:04:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 813FB21481 for ; Wed, 21 Oct 2020 21:04:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="jOT67r4n" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 813FB21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLHr-0005vB-8P for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:04:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0005XN-NN for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49271) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAo-0006fC-O1 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZO1IFZ7TKMg2Fkr7uEyDIP7zNsvkOq/AXngsVSUhMPU=; b=jOT67r4n2U5m78R+cG3I9t4lULl5MWRgWr5hU9Vx69riLHQbS9gu+0F/GftVbcR4M3NcZN CrMJ1SDr/YxmV5hriACJFgwoj24DKrVp/l1j96MmxwC6oYZimDB3Jfjb073R/81S1tMlgn R/q0Ewnisr2lupGyxawd+P4YTlyRBVI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-184-oV5YPEkzMla2ASY0BwkM3Q-1; Wed, 21 Oct 2020 16:57:23 -0400 X-MC-Unique: oV5YPEkzMla2ASY0BwkM3Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E035835B91 for ; Wed, 21 Oct 2020 20:57:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A53486EF62; Wed, 21 Oct 2020 20:57:21 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/22] trace: remove argument from trace_init_file Date: Wed, 21 Oct 2020 16:57:01 -0400 Message-Id: <20201021205716.2359430-8-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" It is not needed, all the callers are just saving what was retrieved from -trace and trace_init_file can retrieve it on its own. Signed-off-by: Paolo Bonzini --- bsd-user/main.c | 6 ++---- linux-user/main.c | 6 ++---- qemu-img.c | 6 ++---- qemu-io.c | 6 ++---- qemu-nbd.c | 6 ++---- scsi/qemu-pr-helper.c | 6 ++---- softmmu/vl.c | 6 ++---- storage-daemon/qemu-storage-daemon.c | 9 +++------ trace/control.c | 10 ++++------ trace/control.h | 12 +++--------- 10 files changed, 24 insertions(+), 49 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index ac40d79bfa..0a918e8f74 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -745,7 +745,6 @@ int main(int argc, char **argv) const char *gdbstub = NULL; char **target_environ, **wrk; envlist_t *envlist = NULL; - char *trace_file = NULL; bsd_type = target_openbsd; if (argc <= 1) @@ -851,8 +850,7 @@ int main(int argc, char **argv) } else if (!strcmp(r, "strace")) { do_strace = 1; } else if (!strcmp(r, "trace")) { - g_free(trace_file); - trace_file = trace_opt_parse(optarg); + trace_opt_parse(optarg); } else { usage(); } @@ -880,7 +878,7 @@ int main(int argc, char **argv) if (!trace_init_backends()) { exit(1); } - trace_init_file(trace_file); + trace_init_file(); /* Zero out regs */ memset(regs, 0, sizeof(struct target_pt_regs)); diff --git a/linux-user/main.c b/linux-user/main.c index 75c9785157..24d1eb73ad 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -386,11 +386,9 @@ static void handle_arg_version(const char *arg) exit(EXIT_SUCCESS); } -static char *trace_file; static void handle_arg_trace(const char *arg) { - g_free(trace_file); - trace_file = trace_opt_parse(arg); + trace_opt_parse(arg); } #if defined(TARGET_XTENSA) @@ -672,7 +670,7 @@ int main(int argc, char **argv, char **envp) if (!trace_init_backends()) { exit(1); } - trace_init_file(trace_file); + trace_init_file(); if (qemu_plugin_load_list(&plugins)) { exit(1); } diff --git a/qemu-img.c b/qemu-img.c index 2103507936..ccfdf1f48d 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -5434,7 +5434,6 @@ int main(int argc, char **argv) const img_cmd_t *cmd; const char *cmdname; Error *local_error = NULL; - char *trace_file = NULL; int c; static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -5484,8 +5483,7 @@ int main(int argc, char **argv) printf(QEMU_IMG_VERSION); return 0; case 'T': - g_free(trace_file); - trace_file = trace_opt_parse(optarg); + trace_opt_parse(optarg); break; } } @@ -5503,7 +5501,7 @@ int main(int argc, char **argv) if (!trace_init_backends()) { exit(1); } - trace_init_file(trace_file); + trace_init_file(); qemu_set_log(LOG_TRACE); /* find the command */ diff --git a/qemu-io.c b/qemu-io.c index 7cc832b3d6..ac88d8bd40 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -536,7 +536,6 @@ int main(int argc, char **argv) Error *local_error = NULL; QDict *opts = NULL; const char *format = NULL; - char *trace_file = NULL; bool force_share = false; #ifdef CONFIG_POSIX @@ -601,8 +600,7 @@ int main(int argc, char **argv) } break; case 'T': - g_free(trace_file); - trace_file = trace_opt_parse(optarg); + trace_opt_parse(optarg); break; case 'V': printf("%s version " QEMU_FULL_VERSION "\n" @@ -653,7 +651,7 @@ int main(int argc, char **argv) if (!trace_init_backends()) { exit(1); } - trace_init_file(trace_file); + trace_init_file(); qemu_set_log(LOG_TRACE); /* initialize commands */ diff --git a/qemu-nbd.c b/qemu-nbd.c index bc644a0670..37adeb0596 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -573,7 +573,6 @@ int main(int argc, char **argv) const char *tlscredsid = NULL; bool imageOpts = false; bool writethrough = true; - char *trace_file = NULL; bool fork_process = false; bool list = false; int old_stderr = -1; @@ -767,8 +766,7 @@ int main(int argc, char **argv) imageOpts = true; break; case 'T': - g_free(trace_file); - trace_file = trace_opt_parse(optarg); + trace_opt_parse(optarg); break; case QEMU_NBD_OPT_TLSAUTHZ: tlsauthz = optarg; @@ -815,7 +813,7 @@ int main(int argc, char **argv) if (!trace_init_backends()) { exit(1); } - trace_init_file(trace_file); + trace_init_file(); qemu_set_log(LOG_TRACE); socket_activation = check_socket_activation(); diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c index d26faaf91e..2733d92f2d 100644 --- a/scsi/qemu-pr-helper.c +++ b/scsi/qemu-pr-helper.c @@ -884,7 +884,6 @@ int main(int argc, char **argv) int quiet = 0; int ch; Error *local_err = NULL; - char *trace_file = NULL; bool daemonize = false; bool pidfile_specified = false; bool socket_path_specified = false; @@ -968,8 +967,7 @@ int main(int argc, char **argv) ++loglevel; break; case 'T': - g_free(trace_file); - trace_file = trace_opt_parse(optarg); + trace_opt_parse(optarg); break; case 'V': version(argv[0]); @@ -992,7 +990,7 @@ int main(int argc, char **argv) if (!trace_init_backends()) { exit(EXIT_FAILURE); } - trace_init_file(trace_file); + trace_init_file(); qemu_set_log(LOG_TRACE); #ifdef CONFIG_MPATH diff --git a/softmmu/vl.c b/softmmu/vl.c index 3def5f3688..05e661abb8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2883,7 +2883,6 @@ void qemu_init(int argc, char **argv, char **envp) int display_remote = 0; const char *log_mask = NULL; const char *log_file = NULL; - char *trace_file = NULL; ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; @@ -3684,8 +3683,7 @@ void qemu_init(int argc, char **argv, char **envp) xen_domid_restrict = true; break; case QEMU_OPTION_trace: - g_free(trace_file); - trace_file = trace_opt_parse(optarg); + trace_opt_parse(optarg); break; case QEMU_OPTION_plugin: qemu_plugin_opt_parse(optarg, &plugin_list); @@ -3931,7 +3929,7 @@ void qemu_init(int argc, char **argv, char **envp) if (!trace_init_backends()) { exit(1); } - trace_init_file(trace_file); + trace_init_file(); /* Open the logfile at this point and set the log mask if necessary. */ diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c index e419ba9f19..7c914b0dc1 100644 --- a/storage-daemon/qemu-storage-daemon.c +++ b/storage-daemon/qemu-storage-daemon.c @@ -180,12 +180,9 @@ static void process_options(int argc, char *argv[]) help(); exit(EXIT_SUCCESS); case 'T': - { - char *trace_file = trace_opt_parse(optarg); - trace_init_file(trace_file); - g_free(trace_file); - break; - } + trace_opt_parse(optarg); + trace_init_file(); + break; case 'V': printf("qemu-storage-daemon version " QEMU_FULL_VERSION "\n" QEMU_COPYRIGHT "\n"); diff --git a/trace/control.c b/trace/control.c index b35e512dce..7a57fa7dd5 100644 --- a/trace/control.c +++ b/trace/control.c @@ -221,8 +221,10 @@ static void trace_init_events(const char *fname) loc_pop(&loc); } -void trace_init_file(const char *file) +void trace_init_file(void) { + QemuOpts *opts = qemu_find_opts_singleton("trace"); + const char *file = qemu_opt_get(opts, "file"); #ifdef CONFIG_TRACE_SIMPLE st_set_trace_file(file); st_set_trace_file_enabled(true); @@ -286,9 +288,8 @@ bool trace_init_backends(void) return true; } -char *trace_opt_parse(const char *optarg) +void trace_opt_parse(const char *optarg) { - char *trace_file; QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"), optarg, true); if (!opts) { @@ -298,10 +299,7 @@ char *trace_opt_parse(const char *optarg) trace_enable_events(qemu_opt_get(opts, "enable")); } trace_init_events(qemu_opt_get(opts, "events")); - trace_file = g_strdup(qemu_opt_get(opts, "file")); qemu_opts_del(opts); - - return trace_file; } uint32_t trace_get_vcpu_event_count(void) diff --git a/trace/control.h b/trace/control.h index 1f81c491b6..05b95ea453 100644 --- a/trace/control.h +++ b/trace/control.h @@ -167,8 +167,6 @@ void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, /** * trace_init_backends: - * @file: Name of trace output file; may be NULL. - * Corresponds to commandline option "--trace file=...". * * Initialize the tracing backend. * @@ -178,14 +176,12 @@ bool trace_init_backends(void); /** * trace_init_file: - * @file: Name of trace output file; may be NULL. - * Corresponds to commandline option "--trace file=...". * * Record the name of the output file for the tracing backend. * Exits if no selected backend does not support specifying the - * output file, and a non-NULL file was passed. + * output file, and a file was specified with "-trace file=...". */ -void trace_init_file(const char *file); +void trace_init_file(void); /** * trace_init_vcpu: @@ -229,10 +225,8 @@ extern QemuOptsList qemu_trace_opts; * @optarg: A string argument of --trace command line argument * * Initialize tracing subsystem. - * - * Returns the filename to save trace to. It must be freed with g_free(). */ -char *trace_opt_parse(const char *optarg); +void trace_opt_parse(const char *optarg); /** * trace_get_vcpu_event_count: From patchwork Wed Oct 21 20:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849749 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 898BA15E6 for ; Wed, 21 Oct 2020 21:08:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0558924197 for ; Wed, 21 Oct 2020 21:08:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bRBx6uv9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0558924197 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLLH-0001c1-AK for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:08:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB0-0005cY-3a for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006fG-Cp for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JNJ//7TfZxMDLeWnhifDKB4WgSkrgnH3VTrzXvyu7NQ=; b=bRBx6uv9burLf5KG5iexwkxdzFR59FOdLKfavDxFbCeUM0GGlUcaibzfZRNsXEZxiKALBV REPVO0QJM8oyoV8vmD4oT1u8pfE946teyTkAjA+jqu2cKbUOhRv2dMoAGiieZWK0OFmflR clnRTTIpqfwIDGwliOOV/biSbRw7fhk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-1iucuMnFPTmk2eNkPWG2gA-1; Wed, 21 Oct 2020 16:57:23 -0400 X-MC-Unique: 1iucuMnFPTmk2eNkPWG2gA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A60C2186DD39 for ; Wed, 21 Oct 2020 20:57:22 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3809F6EF62; Wed, 21 Oct 2020 20:57:22 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/22] vl: split various early command line options to a separate function Date: Wed, 21 Oct 2020 16:57:02 -0400 Message-Id: <20201021205716.2359430-9-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Various options affect the global state of QEMU including the rest of qemu_init, and they need to be called very early. Group them together in a function that is called at the beginning. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 202 ++++++++++++++++++++++++++++----------------------- 1 file changed, 113 insertions(+), 89 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 05e661abb8..2e1714d7a4 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -117,6 +117,7 @@ #define MAX_VIRTIO_CONSOLES 1 +static const char *cpu_option; static const char *data_dir[16]; static int data_dir_idx; const char *bios_name = NULL; @@ -143,6 +144,9 @@ int vga_interface_type = VGA_NONE; static DisplayOptions dpy; static int num_serial_hds; static Chardev **serial_hds; +static const char *log_mask = NULL; +static const char *log_file = NULL; +static bool list_data_dirs = false; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack = 0; int singlestep = 0; @@ -2859,6 +2863,106 @@ static char *find_datadir(void) return get_relocated_path(CONFIG_QEMU_DATADIR); } +static void qemu_process_early_options(void) +{ + char **dirs; + int i; + +#ifdef CONFIG_SECCOMP + QemuOptsList *olist = qemu_find_opts_err("sandbox", NULL); + if (olist) { + qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal); + } +#endif + + qemu_opts_foreach(qemu_find_opts("name"), + parse_name, NULL, &error_fatal); + +#ifndef _WIN32 + qemu_opts_foreach(qemu_find_opts("add-fd"), + parse_add_fd, NULL, &error_fatal); + + qemu_opts_foreach(qemu_find_opts("add-fd"), + cleanup_add_fd, NULL, &error_fatal); +#endif + + if (!trace_init_backends()) { + exit(1); + } + trace_init_file(); + + /* Open the logfile at this point and set the log mask if necessary. + */ + qemu_set_log_filename(log_file, &error_fatal); + if (log_mask) { + int mask; + mask = qemu_str_to_log_mask(log_mask); + if (!mask) { + qemu_print_log_usage(stdout); + exit(1); + } + qemu_set_log(mask); + } else { + qemu_set_log(0); + } + + /* add configured firmware directories */ + dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0); + for (i = 0; dirs[i] != NULL; i++) { + qemu_add_data_dir(get_relocated_path(dirs[i])); + } + g_strfreev(dirs); + + /* try to find datadir relative to the executable path */ + qemu_add_data_dir(find_datadir()); +} + +static void qemu_process_help_options(void) +{ + int i; + + /* + * Check for -cpu help and -device help before we call select_machine(), + * which will return an error if the architecture has no default machine + * type and the user did not specify one, so that the user doesn't need + * to say '-cpu help -machine something'. + */ + if (cpu_option && is_help_option(cpu_option)) { + list_cpus(cpu_option); + exit(0); + } + + if (qemu_opts_foreach(qemu_find_opts("device"), + device_help_func, NULL, NULL)) { + exit(0); + } + + /* -L help lists the data directories and exits. */ + if (list_data_dirs) { + for (i = 0; i < data_dir_idx; i++) { + printf("%s\n", data_dir[i]); + } + exit(0); + } +} + +static void qemu_maybe_daemonize(const char *pid_file) +{ + Error *err; + + os_daemonize(); + rcu_disable_atfork(); + + if (pid_file && !qemu_write_pidfile(pid_file, &err)) { + error_reportf_err(err, "cannot create PID file: "); + exit(1); + } + + qemu_unlink_pidfile_notifier.notify = qemu_unlink_pidfile; + qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); +} + + void qemu_init(int argc, char **argv, char **envp) { int i; @@ -2875,21 +2979,16 @@ void qemu_init(int argc, char **argv, char **envp) const char *optarg; const char *loadvm = NULL; MachineClass *machine_class; - const char *cpu_option; const char *vga_model = NULL; const char *incoming = NULL; bool userconfig = true; bool nographic = false; int display_remote = 0; - const char *log_mask = NULL; - const char *log_file = NULL; ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; Error *main_loop_err = NULL; Error *err = NULL; - bool list_data_dirs = false; - char **dirs; const char *mem_path = NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); @@ -3833,20 +3932,17 @@ void qemu_init(int argc, char **argv, char **envp) */ loc_set_none(); - /* - * Check for -cpu help and -device help before we call select_machine(), - * which will return an error if the architecture has no default machine - * type and the user did not specify one, so that the user doesn't need - * to say '-cpu help -machine something'. + /* These options affect everything else and should be processed + * before daemonizing. */ - if (cpu_option && is_help_option(cpu_option)) { - list_cpus(cpu_option); - exit(0); - } + qemu_process_early_options(); - if (qemu_opts_foreach(qemu_find_opts("device"), - device_help_func, NULL, NULL)) { - exit(0); + qemu_process_help_options(); + qemu_maybe_daemonize(pid_file); + + if (qemu_init_main_loop(&main_loop_err)) { + error_report_err(main_loop_err); + exit(1); } user_register_global_props(); @@ -3867,40 +3963,6 @@ void qemu_init(int argc, char **argv, char **envp) have_custom_ram_size = set_memory_options(&ram_slots, &maxram_size, machine_class); - os_daemonize(); - rcu_disable_atfork(); - - if (pid_file && !qemu_write_pidfile(pid_file, &err)) { - error_reportf_err(err, "cannot create PID file: "); - exit(1); - } - - qemu_unlink_pidfile_notifier.notify = qemu_unlink_pidfile; - qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); - - if (qemu_init_main_loop(&main_loop_err)) { - error_report_err(main_loop_err); - exit(1); - } - -#ifdef CONFIG_SECCOMP - olist = qemu_find_opts_err("sandbox", NULL); - if (olist) { - qemu_opts_foreach(olist, parse_sandbox, NULL, &error_fatal); - } -#endif - - qemu_opts_foreach(qemu_find_opts("name"), - parse_name, NULL, &error_fatal); - -#ifndef _WIN32 - qemu_opts_foreach(qemu_find_opts("add-fd"), - parse_add_fd, NULL, &error_fatal); - - qemu_opts_foreach(qemu_find_opts("add-fd"), - cleanup_add_fd, NULL, &error_fatal); -#endif - current_machine = MACHINE(object_new_with_class(OBJECT_CLASS(machine_class))); if (machine_help_func(qemu_get_machine_opts(), current_machine)) { exit(0); @@ -3926,44 +3988,6 @@ void qemu_init(int argc, char **argv, char **envp) qemu_set_hw_version(machine_class->hw_version); } - if (!trace_init_backends()) { - exit(1); - } - trace_init_file(); - - /* Open the logfile at this point and set the log mask if necessary. - */ - qemu_set_log_filename(log_file, &error_fatal); - if (log_mask) { - int mask; - mask = qemu_str_to_log_mask(log_mask); - if (!mask) { - qemu_print_log_usage(stdout); - exit(1); - } - qemu_set_log(mask); - } else { - qemu_set_log(0); - } - - /* add configured firmware directories */ - dirs = g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S, 0); - for (i = 0; dirs[i] != NULL; i++) { - qemu_add_data_dir(get_relocated_path(dirs[i])); - } - g_strfreev(dirs); - - /* try to find datadir relative to the executable path */ - qemu_add_data_dir(find_datadir()); - - /* -L help lists the data directories and exits. */ - if (list_data_dirs) { - for (i = 0; i < data_dir_idx; i++) { - printf("%s\n", data_dir[i]); - } - exit(0); - } - machine_smp_parse(current_machine, qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal); From patchwork Wed Oct 21 20:57:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849745 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DF55A61C for ; Wed, 21 Oct 2020 21:06:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81BFF21481 for ; Wed, 21 Oct 2020 21:06:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GrGtn2ye" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81BFF21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLJE-0007rV-CA for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:06:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB3-0005lc-H1 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006fK-CB for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=joMLROSh5hWNvzYW2mRufD5bQKbfXZEfJ+2cbsoVqIk=; b=GrGtn2yeGPQck0cr+D3ojOAWGFPM/DVmzp0nHhdUujp3KYcX6tLaiv76jkr4IULMi0sshb i/buDz9vJyx3CpNxleod6va94tbFI+Q/OvBZEHW8HXuNZeGe+MOMkAIHADeSloVAiNKNmP 1KciPK/Oryx0/ZmcVfV98keA8/vv3Hw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-75-evHRjnNqOKq-TFnj-vvSAQ-1; Wed, 21 Oct 2020 16:57:24 -0400 X-MC-Unique: evHRjnNqOKq-TFnj-vvSAQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 398B35F9C6 for ; Wed, 21 Oct 2020 20:57:23 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C04CA6EF62; Wed, 21 Oct 2020 20:57:22 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/22] vl: move various initialization routines out of qemu_init Date: Wed, 21 Oct 2020 16:57:03 -0400 Message-Id: <20201021205716.2359430-10-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Some very simple initialization routines can be nested in existing subsystem-level functions, do that to simplify qemu_init. Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 3 +++ include/hw/qdev-core.h | 8 -------- migration/migration.c | 4 ++++ softmmu/qdev-monitor.c | 6 ------ softmmu/vl.c | 5 ----- 5 files changed, 7 insertions(+), 19 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 70b1e5e8e8..3c674bb05e 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -873,6 +873,9 @@ static void machine_initfn(Object *obj) MachineState *ms = MACHINE(obj); MachineClass *mc = MACHINE_GET_CLASS(obj); + container_get(obj, "/peripheral"); + container_get(obj, "/peripheral-anon"); + ms->dump_guest_core = true; ms->mem_merge = true; ms->enable_graphics = true; diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 868973319e..56ce7f2d7f 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -769,14 +769,6 @@ BusState *sysbus_get_default(void); char *qdev_get_fw_dev_path(DeviceState *dev); char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev); -/** - * @qdev_machine_init - * - * Initialize platform devices before machine init. This is a hack until full - * support for composition is added. - */ -void qdev_machine_init(void); - /** * device_legacy_reset: * diff --git a/migration/migration.c b/migration/migration.c index deb6005b8d..f48b03cac2 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -169,6 +169,10 @@ void migration_object_init(void) error_report_err(err); exit(1); } + + blk_mig_init(); + ram_mig_init(); + dirty_bitmap_mig_init(); } void migration_shutdown(void) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index bcfb90a08f..bcfcbac181 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -943,12 +943,6 @@ BlockBackend *blk_by_qdev_id(const char *id, Error **errp) return blk; } -void qdev_machine_init(void) -{ - qdev_get_peripheral_anon(); - qdev_get_peripheral(); -} - QemuOptsList qemu_device_opts = { .name = "device", .implied_opt_name = "driver", diff --git a/softmmu/vl.c b/softmmu/vl.c index 2e1714d7a4..a9f69a7d11 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4269,10 +4269,6 @@ void qemu_init(int argc, char **argv, char **envp) exit(1); } - blk_mig_init(); - ram_mig_init(); - dirty_bitmap_mig_init(); - qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); @@ -4305,7 +4301,6 @@ void qemu_init(int argc, char **argv, char **envp) reading from the other reads, because timer polling functions query clock values from the log. */ replay_checkpoint(CHECKPOINT_INIT); - qdev_machine_init(); current_machine->boot_order = boot_order; From patchwork Wed Oct 21 20:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849763 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AED9E16C0 for ; Wed, 21 Oct 2020 21:14:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 544A224197 for ; Wed, 21 Oct 2020 21:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cVQnbSD8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 544A224197 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLRa-0008OX-9J for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:14:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB3-0005kx-B2 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:29695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006fP-CD for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iB6qv4a+aDu0BX/0RS/j/Wdxsua155FSRJWNDGQTqBk=; b=cVQnbSD8uuVyrcBhUMIPCpRrXB6ubmhvkK1dHYpGQZjzQ+CvOWEm9NFbj3xJe9DT/M2I2c 1oxXs8K2DwJem67RmNqnPTEO9B8RRd5lqQjxlFcG4WRcJWOtwrAFE7x1dYrGHD9ZVy1kuc OACUsCZtLhPeKCjRk7789MMyn7FUigE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-238-u815ppS1PtSyQ40Oy-IUsQ-1; Wed, 21 Oct 2020 16:57:25 -0400 X-MC-Unique: u815ppS1PtSyQ40Oy-IUsQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 63AC15F9C1 for ; Wed, 21 Oct 2020 20:57:24 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2B936EF62; Wed, 21 Oct 2020 20:57:23 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/22] vl: extract qemu_init_subsystems Date: Wed, 21 Oct 2020 16:57:04 -0400 Message-Id: <20201021205716.2359430-11-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Group a bunch of subsystem initializations that can be done right after command line parsing. Remove initializations that can be done simply as global variable initializers. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 94 ++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 51 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index a9f69a7d11..e731d754ec 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -129,7 +129,7 @@ bool enable_mlock = false; bool enable_cpu_pm = false; int nb_nics; NICInfo nd_table[MAX_NICS]; -int autostart; +int autostart = 1; static enum { RTC_BASE_UTC, RTC_BASE_LOCALTIME, @@ -1229,7 +1229,8 @@ struct VMChangeStateEntry { int priority; }; -static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head; +static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head = + QTAILQ_HEAD_INITIALIZER(vm_change_state_head); /** * qemu_add_vm_change_state_handler_prio: @@ -2962,11 +2963,45 @@ static void qemu_maybe_daemonize(const char *pid_file) qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); } +static void qemu_init_subsystems(void) +{ + Error *err; + + os_set_line_buffering(); + + module_call_init(MODULE_INIT_TRACE); + + qemu_init_cpu_list(); + qemu_init_cpu_loop(); + qemu_mutex_lock_iothread(); + + atexit(qemu_run_exit_notifiers); + + module_call_init(MODULE_INIT_QOM); + module_call_init(MODULE_INIT_MIGRATION); + + runstate_init(); + precopy_infrastructure_init(); + postcopy_infrastructure_init(); + monitor_init_globals(); + + if (qcrypto_init(&err) < 0) { + error_reportf_err(err, "cannot initialize crypto: "); + exit(1); + } + + os_setup_early_signal_handling(); + + bdrv_init_with_whitelist(); + page_size_init(); + socket_init(); +} void qemu_init(int argc, char **argv, char **envp) { int i; - int snapshot, linux_boot; + int snapshot = 0; + int linux_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; const char *boot_order = NULL; @@ -2987,7 +3022,6 @@ void qemu_init(int argc, char **argv, char **envp) ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; - Error *main_loop_err = NULL; Error *err = NULL; const char *mem_path = NULL; bool have_custom_ram_size; @@ -2995,22 +3029,6 @@ void qemu_init(int argc, char **argv, char **envp) QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); int mem_prealloc = 0; /* force preallocation of physical target memory */ - os_set_line_buffering(); - - error_init(argv[0]); - module_call_init(MODULE_INIT_TRACE); - - qemu_init_cpu_list(); - qemu_init_cpu_loop(); - - qemu_mutex_lock_iothread(); - - atexit(qemu_run_exit_notifiers); - qemu_init_exec_dir(argv[0]); - - module_call_init(MODULE_INIT_QOM); - module_call_init(MODULE_INIT_MIGRATION); - qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); qemu_add_drive_opts(&qemu_common_drive_opts); @@ -3045,27 +3063,10 @@ void qemu_init(int argc, char **argv, char **envp) qemu_add_opts(&qemu_fw_cfg_opts); module_call_init(MODULE_INIT_OPTS); - runstate_init(); - precopy_infrastructure_init(); - postcopy_infrastructure_init(); - monitor_init_globals(); - - if (qcrypto_init(&err) < 0) { - error_reportf_err(err, "cannot initialize crypto: "); - exit(1); - } - - QTAILQ_INIT(&vm_change_state_head); - os_setup_early_signal_handling(); - - cpu_option = NULL; - snapshot = 0; - - nb_nics = 0; - - bdrv_init_with_whitelist(); + error_init(argv[0]); + qemu_init_exec_dir(argv[0]); - autostart = 1; + qemu_init_subsystems(); /* first pass of option parsing */ optind = 1; @@ -3940,13 +3941,10 @@ void qemu_init(int argc, char **argv, char **envp) qemu_process_help_options(); qemu_maybe_daemonize(pid_file); - if (qemu_init_main_loop(&main_loop_err)) { - error_report_err(main_loop_err); - exit(1); - } + qemu_init_main_loop(&error_fatal); + cpu_timers_init(); user_register_global_props(); - replay_configure(icount_opts); if (incoming && !preconfig_exit_requested) { @@ -4125,9 +4123,6 @@ void qemu_init(int argc, char **argv, char **envp) exit(1); } - page_size_init(); - socket_init(); - qemu_opts_foreach(qemu_find_opts("object"), user_creatable_add_opts_foreach, object_create_initial, &error_fatal); @@ -4245,9 +4240,6 @@ void qemu_init(int argc, char **argv, char **envp) semihosting_arg_fallback(kernel_filename, kernel_cmdline); } - /* initialize cpu timers and VCPU throttle modules */ - cpu_timers_init(); - if (default_net) { QemuOptsList *net = qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); From patchwork Wed Oct 21 20:57:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B8BE92C for ; Wed, 21 Oct 2020 21:11:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 906C621481 for ; Wed, 21 Oct 2020 21:11:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WB1vMB+M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 906C621481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLOL-0004z1-Hb for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:11:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAz-0005bv-RW for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006fT-Ba for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C03ZrjuUMwkEt5mkfe2qY3qEEuJCfrYlmiCZCkQ0wzA=; b=WB1vMB+MCtLn4J7JuohkRNAHHTcnQ5t++vZDQ3E4zZL3hKvPJe4nmxeFG6lWkN7wSQn/Mj qskcnLyF9psGcLbpORJiAfvm/DcuBd++0KOu5HDPZQMObczPah5heK0quOV5DC2jYNqTn4 Q52V/ZCBwXyLWuASM7SZGl70KJWjj8w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-wkJ36850OlePL8yuQud95w-1; Wed, 21 Oct 2020 16:57:26 -0400 X-MC-Unique: wkJ36850OlePL8yuQud95w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 146C71005E77 for ; Wed, 21 Oct 2020 20:57:25 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 846416EF62; Wed, 21 Oct 2020 20:57:24 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/22] vl: move prelaunch part of qemu_init to a new function Date: Wed, 21 Oct 2020 16:57:05 -0400 Message-Id: <20201021205716.2359430-12-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" The final part of qemu_init, starting with the completion of board init, is already relatively clean. Split it out of qemu_init so that qemu_init keeps only the messy parts. Signed-off-by: Paolo Bonzini --- include/sysemu/sysemu.h | 1 + softmmu/vl.c | 238 +++++++++++++++++++++------------------- 2 files changed, 124 insertions(+), 115 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 817ff4cf75..9f47b2a354 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -112,6 +112,7 @@ QemuOpts *qemu_get_machine_opts(void); bool defaults_enabled(void); void qemu_init(int argc, char **argv, char **envp); +void qemu_finish_machine_init(void); void qemu_main_loop(void); void qemu_cleanup(void); diff --git a/softmmu/vl.c b/softmmu/vl.c index e731d754ec..52e7d317d7 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -120,6 +120,9 @@ static const char *cpu_option; static const char *data_dir[16]; static int data_dir_idx; +static const char *mem_path; +static const char *boot_order; +static const char *boot_once; const char *bios_name = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int display_opengl; @@ -2997,6 +3000,125 @@ static void qemu_init_subsystems(void) socket_init(); } +/* Called after leaving preconfig state. */ +void qemu_finish_machine_init(void) +{ + MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); + DisplayState *ds; + + if (machine_class->default_ram_id && current_machine->ram_size && + numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { + create_default_memdev(current_machine, mem_path); + } + + /* from here on runstate is RUN_STATE_PRELAUNCH */ + machine_run_board_init(current_machine); + + /* + * TODO To drop support for deprecated bogus if=..., move + * drive_check_orphaned() here, replacing this call. Also drop + * its deprecation warning, along with DriveInfo member + * @claimed_by_board. + */ + drive_mark_claimed_by_board(); + + realtime_init(); + + soundhw_init(); + + if (hax_enabled()) { + hax_sync_vcpus(); + } + + qemu_opts_foreach(qemu_find_opts("fw_cfg"), + parse_fw_cfg, fw_cfg_find(), &error_fatal); + + /* init USB devices */ + if (machine_usb(current_machine)) { + if (foreach_device_config(DEV_USB, usb_parse) < 0) + exit(1); + } + + /* init generic devices */ + rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); + qemu_opts_foreach(qemu_find_opts("device"), + device_init_func, NULL, &error_fatal); + + cpu_synchronize_all_post_init(); + + rom_reset_order_override(); + + /* Did we create any drives that we failed to create a device for? */ + drive_check_orphaned(); + + /* Don't warn about the default network setup that you get if + * no command line -net or -netdev options are specified. There + * are two cases that we would otherwise complain about: + * (1) board doesn't support a NIC but the implicit "-net nic" + * requested one + * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic" + * sets up a nic that isn't connected to anything. + */ + if (!default_net && (!qtest_enabled() || has_defaults)) { + net_check_clients(); + } + + if (boot_once) { + qemu_boot_set(boot_once, &error_fatal); + qemu_register_reset(restore_boot_order, g_strdup(boot_order)); + } + + /* init local displays */ + ds = init_displaystate(); + qemu_display_init(ds, &dpy); + + /* must be after terminal init, SDL library changes signal handlers */ + os_setup_signal_handling(); + + /* init remote displays */ +#ifdef CONFIG_VNC + qemu_opts_foreach(qemu_find_opts("vnc"), + vnc_init_func, NULL, &error_fatal); +#endif + + if (using_spice) { + qemu_spice_display_init(); + } + + if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { + exit(1); + } + + qdev_machine_creation_done(); + + /* TODO: once all bus devices are qdevified, this should be done + * when bus is created by qdev.c */ + /* + * TODO: If we had a main 'reset container' that the whole system + * lived in, we could reset that using the multi-phase reset + * APIs. For the moment, we just reset the sysbus, which will cause + * all devices hanging off it (and all their child buses, recursively) + * to be reset. Note that this will *not* reset any Device objects + * which are not attached to some part of the qbus tree! + */ + qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default()); + qemu_run_machine_init_done_notifiers(); + + if (rom_check_and_register_reset() != 0) { + error_report("rom check and register reset failed"); + exit(1); + } + + replay_start(); + + /* This checkpoint is required by replay to separate prior clock + reading from the other reads, because timer polling functions query + clock values from the log. */ + replay_checkpoint(CHECKPOINT_RESET); + qemu_system_reset(SHUTDOWN_CAUSE_NONE); + register_global_state(); +} + void qemu_init(int argc, char **argv, char **envp) { int i; @@ -3004,9 +3126,6 @@ void qemu_init(int argc, char **argv, char **envp) int linux_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; - const char *boot_order = NULL; - const char *boot_once = NULL; - DisplayState *ds; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts = NULL, *accel_opts = NULL; QemuOptsList *olist; @@ -3023,7 +3142,6 @@ void qemu_init(int argc, char **argv, char **envp) uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; Error *err = NULL; - const char *mem_path = NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); @@ -4340,117 +4458,8 @@ void qemu_init(int argc, char **argv, char **envp) /* do monitor/qmp handling at preconfig state if requested */ qemu_main_loop(); - if (machine_class->default_ram_id && current_machine->ram_size && - numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { - create_default_memdev(current_machine, mem_path); - } - - /* from here on runstate is RUN_STATE_PRELAUNCH */ - machine_run_board_init(current_machine); - - /* - * TODO To drop support for deprecated bogus if=..., move - * drive_check_orphaned() here, replacing this call. Also drop - * its deprecation warning, along with DriveInfo member - * @claimed_by_board. - */ - drive_mark_claimed_by_board(); - - realtime_init(); - - soundhw_init(); - - if (hax_enabled()) { - hax_sync_vcpus(); - } - - qemu_opts_foreach(qemu_find_opts("fw_cfg"), - parse_fw_cfg, fw_cfg_find(), &error_fatal); - - /* init USB devices */ - if (machine_usb(current_machine)) { - if (foreach_device_config(DEV_USB, usb_parse) < 0) - exit(1); - } - - /* init generic devices */ - rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); - qemu_opts_foreach(qemu_find_opts("device"), - device_init_func, NULL, &error_fatal); - - cpu_synchronize_all_post_init(); - - rom_reset_order_override(); - - /* Did we create any drives that we failed to create a device for? */ - drive_check_orphaned(); - - /* Don't warn about the default network setup that you get if - * no command line -net or -netdev options are specified. There - * are two cases that we would otherwise complain about: - * (1) board doesn't support a NIC but the implicit "-net nic" - * requested one - * (2) CONFIG_SLIRP not set, in which case the implicit "-net nic" - * sets up a nic that isn't connected to anything. - */ - if (!default_net && (!qtest_enabled() || has_defaults)) { - net_check_clients(); - } - - if (boot_once) { - qemu_boot_set(boot_once, &error_fatal); - qemu_register_reset(restore_boot_order, g_strdup(boot_order)); - } + qemu_finish_machine_init(); - /* init local displays */ - ds = init_displaystate(); - qemu_display_init(ds, &dpy); - - /* must be after terminal init, SDL library changes signal handlers */ - os_setup_signal_handling(); - - /* init remote displays */ -#ifdef CONFIG_VNC - qemu_opts_foreach(qemu_find_opts("vnc"), - vnc_init_func, NULL, &error_fatal); -#endif - - if (using_spice) { - qemu_spice_display_init(); - } - - if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { - exit(1); - } - - qdev_machine_creation_done(); - - /* TODO: once all bus devices are qdevified, this should be done - * when bus is created by qdev.c */ - /* - * TODO: If we had a main 'reset container' that the whole system - * lived in, we could reset that using the multi-phase reset - * APIs. For the moment, we just reset the sysbus, which will cause - * all devices hanging off it (and all their child buses, recursively) - * to be reset. Note that this will *not* reset any Device objects - * which are not attached to some part of the qbus tree! - */ - qemu_register_reset(resettable_cold_reset_fn, sysbus_get_default()); - qemu_run_machine_init_done_notifiers(); - - if (rom_check_and_register_reset() != 0) { - error_report("rom check and register reset failed"); - exit(1); - } - - replay_start(); - - /* This checkpoint is required by replay to separate prior clock - reading from the other reads, because timer polling functions query - clock values from the log. */ - replay_checkpoint(CHECKPOINT_RESET); - qemu_system_reset(SHUTDOWN_CAUSE_NONE); - register_global_state(); if (loadvm) { Error *local_err = NULL; if (load_snapshot(loadvm, &local_err) < 0) { @@ -4469,7 +4478,6 @@ void qemu_init(int argc, char **argv, char **envp) dump_vmstate_json_to_file(vmstate_dump_file); exit(0); } - if (incoming) { Error *local_err = NULL; qemu_start_incoming_migration(incoming, &local_err); From patchwork Wed Oct 21 20:57:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 75C7115E6 for ; Wed, 21 Oct 2020 21:19:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F2D424198 for ; Wed, 21 Oct 2020 21:19:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K3GajrGL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F2D424198 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLVo-0003WF-Q8 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:19:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB4-0005nc-A5 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006gP-Cw for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=e0egizT1LhBTypV0Z8jUS6/aYGmVEDSIu03qH+texvk=; b=K3GajrGLKgcpe8xr9tiepTUUAUE1Ld6bPleBTtBd3h/cSicHgHwMlJeKZQnbmterQ3Mg/H u5Byf++idpzaZdlesWzUDqtDgQQs23sJeBXpZ2UtNui3sjtOZsOX1a2NtgPT5VmnDqkkYa fXc6fxotmmIHMTN1vZqd9T/PIaShb08= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-494-EsPWbHgVNbKl-iQGy-ONqg-1; Wed, 21 Oct 2020 16:57:30 -0400 X-MC-Unique: EsPWbHgVNbKl-iQGy-ONqg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A4CA4186DD48 for ; Wed, 21 Oct 2020 20:57:28 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 353326EF62; Wed, 21 Oct 2020 20:57:25 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/22] vl: move bios_name out of softmmu/vl.c Date: Wed, 21 Oct 2020 16:57:06 -0400 Message-Id: <20201021205716.2359430-13-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" bios_name is a legacy variable used by machine code. Hide it from softmmu/vl.c. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé --- hw/core/machine.c | 5 +++++ softmmu/vl.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 3c674bb05e..e4dac350d4 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -212,6 +212,8 @@ GlobalProperty hw_compat_2_1[] = { }; const size_t hw_compat_2_1_len = G_N_ELEMENTS(hw_compat_2_1); +const char *bios_name = NULL; + static char *machine_get_kernel(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -396,6 +398,9 @@ static void machine_set_firmware(Object *obj, const char *value, Error **errp) g_free(ms->firmware); ms->firmware = g_strdup(value); + + /* HACK */ + bios_name = ms->firmware; } static void machine_set_suppress_vmdesc(Object *obj, bool value, Error **errp) diff --git a/softmmu/vl.c b/softmmu/vl.c index 52e7d317d7..e32e209a82 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -123,7 +123,6 @@ static int data_dir_idx; static const char *mem_path; static const char *boot_order; static const char *boot_once; -const char *bios_name = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int display_opengl; const char* keyboard_layout = NULL; @@ -4314,7 +4313,6 @@ void qemu_init(int argc, char **argv, char **envp) kernel_filename = qemu_opt_get(machine_opts, "kernel"); initrd_filename = qemu_opt_get(machine_opts, "initrd"); kernel_cmdline = qemu_opt_get(machine_opts, "append"); - bios_name = qemu_opt_get(machine_opts, "firmware"); opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { From patchwork Wed Oct 21 20:57:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849761 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82B0415E6 for ; Wed, 21 Oct 2020 21:14:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 11AC021D24 for ; Wed, 21 Oct 2020 21:14:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="S4cmQ0EV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11AC021D24 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLRZ-0008Ne-VX for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:14:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB1-0005gV-MG for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58124) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006gl-CU for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dRvr5vK9gyZ3cW3q+3aqjtBHNka0CgHWp9sdX69KnyE=; b=S4cmQ0EVlU+dmaWH0sl6P78gopuUTcKWhDgV7aXkFNMJzdRsif6MrKitv2MGeQp74GDzf7 hPZdoTDH6/gVElLfCKIAKwLOumnWfcz9XTm4DhFFGMcsNDGajIswA+ZLvyLb5vb62a2K9T udqXbq7m2DzGsA68h4rcvEFGiJC6jRE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-544-lkO0AsEwM1KG7oGQbjEMUw-1; Wed, 21 Oct 2020 16:57:30 -0400 X-MC-Unique: lkO0AsEwM1KG7oGQbjEMUw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74DF5804B68 for ; Wed, 21 Oct 2020 20:57:29 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C53296EF62; Wed, 21 Oct 2020 20:57:28 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/22] vl: extract various command line validation snippets to a new function Date: Wed, 21 Oct 2020 16:57:07 -0400 Message-Id: <20201021205716.2359430-14-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 78 ++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index e32e209a82..f8b1ffb46e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -123,6 +123,7 @@ static int data_dir_idx; static const char *mem_path; static const char *boot_order; static const char *boot_once; +static const char *incoming; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int display_opengl; const char* keyboard_layout = NULL; @@ -2866,6 +2867,39 @@ static char *find_datadir(void) return get_relocated_path(CONFIG_QEMU_DATADIR); } +static void qemu_validate_options(void) +{ + QemuOpts *machine_opts = qemu_get_machine_opts(); + const char *kernel_filename = qemu_opt_get(machine_opts, "kernel"); + const char *initrd_filename = qemu_opt_get(machine_opts, "initrd"); + const char *kernel_cmdline = qemu_opt_get(machine_opts, "append"); + + if (kernel_filename == NULL) { + if (kernel_cmdline != NULL) { + error_report("-append only allowed with -kernel option"); + exit(1); + } + + if (initrd_filename != NULL) { + error_report("-initrd only allowed with -kernel option"); + exit(1); + } + } + + if (incoming && !preconfig_exit_requested) { + error_report("'preconfig' and 'incoming' options are " + "mutually exclusive"); + exit(EXIT_FAILURE); + } + +#ifdef CONFIG_CURSES + if (is_daemonized() && dpy.type == DISPLAY_TYPE_CURSES) { + error_report("curses display cannot be used with -daemonize"); + exit(1); + } +#endif +} + static void qemu_process_early_options(void) { char **dirs; @@ -3122,9 +3156,6 @@ void qemu_init(int argc, char **argv, char **envp) { int i; int snapshot = 0; - int linux_boot; - const char *initrd_filename; - const char *kernel_filename, *kernel_cmdline; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts = NULL, *accel_opts = NULL; QemuOptsList *olist; @@ -3133,7 +3164,6 @@ void qemu_init(int argc, char **argv, char **envp) const char *loadvm = NULL; MachineClass *machine_class; const char *vga_model = NULL; - const char *incoming = NULL; bool userconfig = true; bool nographic = false; int display_remote = 0; @@ -4050,6 +4080,8 @@ void qemu_init(int argc, char **argv, char **envp) */ loc_set_none(); + qemu_validate_options(); + /* These options affect everything else and should be processed * before daemonizing. */ @@ -4064,12 +4096,6 @@ void qemu_init(int argc, char **argv, char **envp) user_register_global_props(); replay_configure(icount_opts); - if (incoming && !preconfig_exit_requested) { - error_report("'preconfig' and 'incoming' options are " - "mutually exclusive"); - exit(EXIT_FAILURE); - } - configure_rtc(qemu_find_opts_singleton("rtc")); machine_class = select_machine(); @@ -4173,12 +4199,6 @@ void qemu_init(int argc, char **argv, char **envp) error_report("-nographic cannot be used with -daemonize"); exit(1); } -#ifdef CONFIG_CURSES - if (dpy.type == DISPLAY_TYPE_CURSES) { - error_report("curses display cannot be used with -daemonize"); - exit(1); - } -#endif } if (nographic) { @@ -4309,11 +4329,6 @@ void qemu_init(int argc, char **argv, char **envp) qtest_server_init(qtest_chrdev, qtest_log, &error_fatal); } - machine_opts = qemu_get_machine_opts(); - kernel_filename = qemu_opt_get(machine_opts, "kernel"); - initrd_filename = qemu_opt_get(machine_opts, "initrd"); - kernel_cmdline = qemu_opt_get(machine_opts, "append"); - opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { boot_order = qemu_opt_get(opts, "order"); @@ -4334,24 +4349,9 @@ void qemu_init(int argc, char **argv, char **envp) boot_order = machine_class->default_boot_order; } - if (!kernel_cmdline) { - kernel_cmdline = ""; - current_machine->kernel_cmdline = (char *)kernel_cmdline; - } - - linux_boot = (kernel_filename != NULL); - - if (!linux_boot && *kernel_cmdline != '\0') { - error_report("-append only allowed with -kernel option"); - exit(1); - } - - if (!linux_boot && initrd_filename != NULL) { - error_report("-initrd only allowed with -kernel option"); - exit(1); - } - - if (semihosting_enabled() && !semihosting_get_argc() && kernel_filename) { + if (semihosting_enabled() && !semihosting_get_argc()) { + const char *kernel_filename = qemu_opt_get(machine_opts, "kernel"); + const char *kernel_cmdline = qemu_opt_get(machine_opts, "append"); /* fall back to the -kernel/-append */ semihosting_arg_fallback(kernel_filename, kernel_cmdline); } From patchwork Wed Oct 21 20:57:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8266361C for ; Wed, 21 Oct 2020 21:04:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CCB421481 for ; Wed, 21 Oct 2020 21:04:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ElyAGYKS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CCB421481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLHs-0005ye-VF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40406) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAz-0005Zq-2R for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006gs-9e for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313852; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hEmG+5DMurtuugiP1AkAOY/uZr4pKnlUz7Ec9go+dTg=; b=ElyAGYKSzuc5aKlcRRte/BFmfSz2Yei3lvli4xYdcxbK7JJVaO6XGgftoza3hXnmbd5XBs Om5yOsoA02x98tubYmE5vWXI3vCqNJQwb8pgDVuHxw5DpZ4V698AU+eCROd+YIgV2kVbaL 3UqT2IdGGPbm6zqRXy10venU49O4mPc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-OrkrzfU3M9GNMWIMwXdP2w-1; Wed, 21 Oct 2020 16:57:30 -0400 X-MC-Unique: OrkrzfU3M9GNMWIMwXdP2w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 04E31186DD23 for ; Wed, 21 Oct 2020 20:57:30 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7571D6EF6E; Wed, 21 Oct 2020 20:57:29 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/22] vl: preconfig and loadvm are mutually exclusive Date: Wed, 21 Oct 2020 16:57:08 -0400 Message-Id: <20201021205716.2359430-15-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Just like -incoming. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index f8b1ffb46e..3607cd4357 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -124,6 +124,7 @@ static const char *mem_path; static const char *boot_order; static const char *boot_once; static const char *incoming; +static const char *loadvm; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int display_opengl; const char* keyboard_layout = NULL; @@ -2886,6 +2887,11 @@ static void qemu_validate_options(void) } } + if (loadvm && !preconfig_exit_requested) { + error_report("'preconfig' and 'loadvm' options are " + "mutually exclusive"); + exit(EXIT_FAILURE); + } if (incoming && !preconfig_exit_requested) { error_report("'preconfig' and 'incoming' options are " "mutually exclusive"); @@ -3161,7 +3167,6 @@ void qemu_init(int argc, char **argv, char **envp) QemuOptsList *olist; int optind; const char *optarg; - const char *loadvm = NULL; MachineClass *machine_class; const char *vga_model = NULL; bool userconfig = true; From patchwork Wed Oct 21 20:57:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849747 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D23361C for ; Wed, 21 Oct 2020 21:08:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E530C21481 for ; Wed, 21 Oct 2020 21:08:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RWZQMCJs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E530C21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLLH-0001at-H1 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:08:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLAz-0005aE-7o for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:26257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006gz-AU for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sjO3LEWU1B+vyfhOtmKRmrtOL9ZWXQ7OGar1eX5wPng=; b=RWZQMCJsdK9YIWS9Ckqk9PAje6Ha5QmAVTpwd/gqmbEXHk+jX8yJRxpSz8c1DUKX8qgfsm 0Z9dJxB2Nf+3hisXrTl4CfHp46GGCUITaBtKhPxUxPHyigbMfdXpKu0zLYNHKGpUPxICty 0clC+mO2B5BCjd4gk7X0e7e7/kbMJjo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-s-xvwK2dM72ao_u5E8FBYQ-1; Wed, 21 Oct 2020 16:57:31 -0400 X-MC-Unique: s-xvwK2dM72ao_u5E8FBYQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A88E2107AFA5 for ; Wed, 21 Oct 2020 20:57:30 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25C596EF62; Wed, 21 Oct 2020 20:57:30 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/22] vl: extract various command line desugaring snippets to a new function Date: Wed, 21 Oct 2020 16:57:09 -0400 Message-Id: <20201021205716.2359430-16-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 3607cd4357..122bf1821b 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -126,6 +126,7 @@ static const char *boot_once; static const char *incoming; static const char *loadvm; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; +int mem_prealloc; /* force preallocation of physical target memory */ int display_opengl; const char* keyboard_layout = NULL; ram_addr_t ram_size; @@ -159,7 +160,7 @@ int fd_bootchk = 1; static int no_reboot; int no_shutdown = 0; int graphic_rotate = 0; -const char *watchdog; +static const char *watchdog; QEMUOptionRom option_rom[MAX_OPTION_ROMS]; int nb_option_roms; int old_param = 0; @@ -2906,6 +2907,24 @@ static void qemu_validate_options(void) #endif } +static void qemu_process_sugar_options(void) +{ + if (mem_prealloc) { + char *val; + + val = g_strdup_printf("%ld", qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1)); + object_register_sugar_prop("memory-backend", "prealloc-threads", val); + g_free(val); + object_register_sugar_prop("memory-backend", "prealloc", "on"); + } + + if (watchdog) { + int i = select_watchdog(watchdog); + if (i > 0) + exit (i == 1 ? 1 : 0); + } +} + static void qemu_process_early_options(void) { char **dirs; @@ -3160,7 +3179,6 @@ void qemu_finish_machine_init(void) void qemu_init(int argc, char **argv, char **envp) { - int i; int snapshot = 0; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts = NULL, *accel_opts = NULL; @@ -3179,7 +3197,6 @@ void qemu_init(int argc, char **argv, char **envp) bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); - int mem_prealloc = 0; /* force preallocation of physical target memory */ qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4086,6 +4103,7 @@ void qemu_init(int argc, char **argv, char **envp) loc_set_none(); qemu_validate_options(); + qemu_process_sugar_options(); /* These options affect everything else and should be processed * before daemonizing. @@ -4137,15 +4155,6 @@ void qemu_init(int argc, char **argv, char **envp) machine_smp_parse(current_machine, qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal); - if (mem_prealloc) { - char *val; - - val = g_strdup_printf("%d", current_machine->smp.cpus); - object_register_sugar_prop("memory-backend", "prealloc-threads", val); - g_free(val); - object_register_sugar_prop("memory-backend", "prealloc", "on"); - } - /* * Get the default machine options from the machine if it is not already * specified either by the configuration file or by the command line. @@ -4404,12 +4413,6 @@ void qemu_init(int argc, char **argv, char **envp) select_vgahw(machine_class, vga_model); } - if (watchdog) { - i = select_watchdog(watchdog); - if (i > 0) - exit (i == 1 ? 1 : 0); - } - /* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query clock values from the log. */ From patchwork Wed Oct 21 20:57:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8012992C for ; Wed, 21 Oct 2020 21:11:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0989721481 for ; Wed, 21 Oct 2020 21:11:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fI5NPR1i" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0989721481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLON-00050p-SE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:11:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB3-0005ju-0M for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23255) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006hE-Cq for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2KB3v8ZGUPVDT5YIRiKIKLRFaZ18xMqBQEX9ptXmwuA=; b=fI5NPR1iMf2Hiu6jZT6bsPdZ4eh61+vVuZfNf5/J3kUhr71DUxeb8WfisxF8LklHgcYoK3 WJqTlND1Pqo+xcwtXEfGWz7Ncg6H20z4ZLpgr5KNZbt6PUuhD8MyGitm4cX7BiSzkyD78P J+eIjKs4mWyLL/KHEWDlFMKJH2P9A6o= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-460-mPyNkLK0Pt66FxCnPbG-Pw-1; Wed, 21 Oct 2020 16:57:32 -0400 X-MC-Unique: mPyNkLK0Pt66FxCnPbG-Pw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59B06835B8E for ; Wed, 21 Oct 2020 20:57:31 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C98FD6EF66; Wed, 21 Oct 2020 20:57:30 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 16/22] vl: create "-net nic -net user" default earlier Date: Wed, 21 Oct 2020 16:57:10 -0400 Message-Id: <20201021205716.2359430-17-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Create it together with other default backends, even though the processing is done later. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 122bf1821b..8577667b8f 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4235,6 +4235,14 @@ void qemu_init(int argc, char **argv, char **envp) monitor_parse("vc:80Cx24C", "readline", false); } + if (default_net) { + QemuOptsList *net = qemu_find_opts("net"); + qemu_opts_set(net, NULL, "type", "nic", &error_abort); +#ifdef CONFIG_SLIRP + qemu_opts_set(net, NULL, "type", "user", &error_abort); +#endif + } + #if defined(CONFIG_VNC) if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { display_remote++; @@ -4370,14 +4378,6 @@ void qemu_init(int argc, char **argv, char **envp) semihosting_arg_fallback(kernel_filename, kernel_cmdline); } - if (default_net) { - QemuOptsList *net = qemu_find_opts("net"); - qemu_opts_set(net, NULL, "type", "nic", &error_abort); -#ifdef CONFIG_SLIRP - qemu_opts_set(net, NULL, "type", "user", &error_abort); -#endif - } - if (net_init_clients(&err) < 0) { error_report_err(err); exit(1); From patchwork Wed Oct 21 20:57:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE1E361C for ; Wed, 21 Oct 2020 21:04:51 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A5CB21481 for ; Wed, 21 Oct 2020 21:04:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CYB5ofy/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A5CB21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:54326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLHu-000637-EE for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:04:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB1-0005fc-C8 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006hM-J0 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kdzKqU40Mrkt2ehEsXWNYxvEj9MX/Xb2GS8n9gTpND4=; b=CYB5ofy/ioQiDaAvEzwjkCKCaF1Vw1qm6PjZQl2jd+bJ1G9qnM360aN2ucIgkJfZmUSm1K zb2Qh306WdvtUSPSlNS2s4HiJS6mEpvwGOcWtyR1jykmQhhnJJmIFEvJCAvCtQobbdWuMA 5NxbP5qHS12ldAM2t236mbSCG3kLvnA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-580-9VBGNAs1OxmaGqDCZxfwDQ-1; Wed, 21 Oct 2020 16:57:32 -0400 X-MC-Unique: 9VBGNAs1OxmaGqDCZxfwDQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 096641006C94 for ; Wed, 21 Oct 2020 20:57:32 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 796196EF62; Wed, 21 Oct 2020 20:57:31 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 17/22] vl: load plugins as late as possible Date: Wed, 21 Oct 2020 16:57:11 -0400 Message-Id: <20201021205716.2359430-18-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" There is no need to load plugins in the middle of default device processing, move -plugin handling just before preconfig is entered. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé --- softmmu/vl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 8577667b8f..75e57133ad 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -125,6 +125,7 @@ static const char *boot_order; static const char *boot_once; static const char *incoming; static const char *loadvm; +static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int mem_prealloc; /* force preallocation of physical target memory */ int display_opengl; @@ -3064,12 +3065,18 @@ void qemu_finish_machine_init(void) MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); DisplayState *ds; + /* from here on runstate is RUN_STATE_PRELAUNCH */ + if (machine_class->default_ram_id && current_machine->ram_size && numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { create_default_memdev(current_machine, mem_path); } - /* from here on runstate is RUN_STATE_PRELAUNCH */ + /* process plugin before CPUs are created, but once -smp has been parsed */ + if (qemu_plugin_load_list(&plugin_list)) { + exit(1); + } + machine_run_board_init(current_machine); /* @@ -3196,7 +3203,6 @@ void qemu_init(int argc, char **argv, char **envp) Error *err = NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); - QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4164,11 +4170,6 @@ void qemu_init(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } - /* process plugin before CPUs are created, but once -smp has been parsed */ - if (qemu_plugin_load_list(&plugin_list)) { - exit(1); - } - qemu_opts_foreach(qemu_find_opts("device"), default_driver_check, NULL, NULL); qemu_opts_foreach(qemu_find_opts("global"), From patchwork Wed Oct 21 20:57:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849757 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA62915E6 for ; Wed, 21 Oct 2020 21:11:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4442B24197 for ; Wed, 21 Oct 2020 21:11:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bsRqYHsu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4442B24197 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLON-000504-VF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:11:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB1-0005g2-F1 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006iI-AZ for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313855; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yUI3M4ipd89OmxngsbbB8zIQpi1LjWQ0a+wUYL8SpBM=; b=bsRqYHsuuyYsxeIkKrKdJhUDmEpi7kcYcgXsTCfiVxycYkuAxup9UzTdeqaMO8IeK6X/ow eUScOOIwy9xBJJ0H7UsWLur3Gh2sKK/Sn2HaSTTkFVn2Bu0OtGfBdsTJjcBQyN9JkzdX3y qhiEH1+nkiZb99Qdf5jIeiP0H4ydBLA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-8AQQP2oIMbCIkaCTFAHxrQ-1; Wed, 21 Oct 2020 16:57:33 -0400 X-MC-Unique: 8AQQP2oIMbCIkaCTFAHxrQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC8A6186DD23 for ; Wed, 21 Oct 2020 20:57:32 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2996F6EF62; Wed, 21 Oct 2020 20:57:32 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 18/22] vl: move semihosting command line fallback to qemu_finish_machine_init Date: Wed, 21 Oct 2020 16:57:12 -0400 Message-Id: <20201021205716.2359430-19-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Move more sane parts of the huge qemu_init function out of it. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 75e57133ad..e58572dbd8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3067,6 +3067,11 @@ void qemu_finish_machine_init(void) /* from here on runstate is RUN_STATE_PRELAUNCH */ + if (semihosting_enabled() && !semihosting_get_argc() && current_machine->kernel_filename) { + /* fall back to the -kernel/-append */ + semihosting_arg_fallback(current_machine->kernel_filename, current_machine->kernel_cmdline); + } + if (machine_class->default_ram_id && current_machine->ram_size && numa_uses_legacy_mem() && !current_machine->ram_memdev_id) { create_default_memdev(current_machine, mem_path); @@ -4372,13 +4377,6 @@ void qemu_init(int argc, char **argv, char **envp) boot_order = machine_class->default_boot_order; } - if (semihosting_enabled() && !semihosting_get_argc()) { - const char *kernel_filename = qemu_opt_get(machine_opts, "kernel"); - const char *kernel_cmdline = qemu_opt_get(machine_opts, "append"); - /* fall back to the -kernel/-append */ - semihosting_arg_fallback(kernel_filename, kernel_cmdline); - } - if (net_init_clients(&err) < 0) { error_report_err(err); exit(1); From patchwork Wed Oct 21 20:57:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849765 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 160BA92C for ; Wed, 21 Oct 2020 21:14:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 835BA24198 for ; Wed, 21 Oct 2020 21:14:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OING+xcM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 835BA24198 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLRa-0008Pq-FJ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:14:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB1-0005fQ-9E for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAv-0006iO-Cn for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fOwKZw0DWZYQF9wa0fjiKsE3u8waOcPPFhZMYYukGM0=; b=OING+xcMlto/nni5apoGdu7wspEDVBbH3mhCzmtqvslGfM1OjGinLgstO4r/LeI95S+H9r U+5RzZ6zMxCIlzD4lMeKl3iHnZDtlv1pmuHHWs4/ldF9bL1IVdMDrU4goLPY6kTwHe7JWc EczgKV2Kj3pl95DfAQhGZy01MTBImSA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-106-o4hbjHshP26wAcgvcDefnQ-1; Wed, 21 Oct 2020 16:57:34 -0400 X-MC-Unique: o4hbjHshP26wAcgvcDefnQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F46D107AFA5 for ; Wed, 21 Oct 2020 20:57:33 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFDA16EF6B; Wed, 21 Oct 2020 20:57:32 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 19/22] vl: extract default devices to separate functions Date: Wed, 21 Oct 2020 16:57:13 -0400 Message-Id: <20201021205716.2359430-20-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/20 22:12:28 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 216 +++++++++++++++++++++++++++------------------------ 1 file changed, 114 insertions(+), 102 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index e58572dbd8..0a6f47e7d6 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -125,7 +125,9 @@ static const char *boot_order; static const char *boot_once; static const char *incoming; static const char *loadvm; +static int display_remote; static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); +static bool nographic = false; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int mem_prealloc; /* force preallocation of physical target memory */ int display_opengl; @@ -147,6 +149,7 @@ static int rtc_host_datetime_offset = -1; /* valid & used only with RTC_BASE_DATETIME */ QEMUClockType rtc_clock; int vga_interface_type = VGA_NONE; +static const char *vga_model = NULL; static DisplayOptions dpy; static int num_serial_hds; static Chardev **serial_hds; @@ -2224,6 +2227,115 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline)) return 0; } +static void qemu_disable_default_devices(void) +{ + MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); + + qemu_opts_foreach(qemu_find_opts("device"), + default_driver_check, NULL, NULL); + qemu_opts_foreach(qemu_find_opts("global"), + default_driver_check, NULL, NULL); + + if (!vga_model && !default_vga) { + vga_interface_type = VGA_DEVICE; + } + if (!has_defaults || machine_class->no_serial) { + default_serial = 0; + } + if (!has_defaults || machine_class->no_parallel) { + default_parallel = 0; + } + if (!has_defaults || machine_class->no_floppy) { + default_floppy = 0; + } + if (!has_defaults || machine_class->no_cdrom) { + default_cdrom = 0; + } + if (!has_defaults || machine_class->no_sdcard) { + default_sdcard = 0; + } + if (!has_defaults) { + default_monitor = 0; + default_net = 0; + default_vga = 0; + } +} + +static void qemu_create_default_devices(void) +{ + MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); + + if (is_daemonized()) { + /* According to documentation and historically, -nographic redirects + * serial port, parallel port and monitor to stdio, which does not work + * with -daemonize. We can redirect these to null instead, but since + * -nographic is legacy, let's just error out. + * We disallow -nographic only if all other ports are not redirected + * explicitly, to not break existing legacy setups which uses + * -nographic _and_ redirects all ports explicitly - this is valid + * usage, -nographic is just a no-op in this case. + */ + if (nographic + && (default_parallel || default_serial || default_monitor)) { + error_report("-nographic cannot be used with -daemonize"); + exit(1); + } + } + + if (nographic) { + if (default_parallel) + add_device_config(DEV_PARALLEL, "null"); + if (default_serial && default_monitor) { + add_device_config(DEV_SERIAL, "mon:stdio"); + } else { + if (default_serial) + add_device_config(DEV_SERIAL, "stdio"); + if (default_monitor) + monitor_parse("stdio", "readline", false); + } + } else { + if (default_serial) + add_device_config(DEV_SERIAL, "vc:80Cx24C"); + if (default_parallel) + add_device_config(DEV_PARALLEL, "vc:80Cx24C"); + if (default_monitor) + monitor_parse("vc:80Cx24C", "readline", false); + } + + if (default_net) { + QemuOptsList *net = qemu_find_opts("net"); + qemu_opts_set(net, NULL, "type", "nic", &error_abort); +#ifdef CONFIG_SLIRP + qemu_opts_set(net, NULL, "type", "user", &error_abort); +#endif + } + +#if defined(CONFIG_VNC) + if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { + display_remote++; + } +#endif + if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) { + if (!qemu_display_find_default(&dpy)) { + dpy.type = DISPLAY_TYPE_NONE; +#if defined(CONFIG_VNC) + vnc_parse("localhost:0,to=99,id=default", &error_abort); +#endif + } + } + if (dpy.type == DISPLAY_TYPE_DEFAULT) { + dpy.type = DISPLAY_TYPE_NONE; + } + + /* If no default VGA is requested, the default is "none". */ + if (default_vga) { + vga_model = get_default_vga_model(machine_class); + } + if (vga_model) { + select_vgahw(machine_class, vga_model); + } +} + static int serial_parse(const char *devname) { int index = num_serial_hds; @@ -3198,10 +3310,7 @@ void qemu_init(int argc, char **argv, char **envp) int optind; const char *optarg; MachineClass *machine_class; - const char *vga_model = NULL; bool userconfig = true; - bool nographic = false; - int display_remote = 0; ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; @@ -4175,97 +4284,8 @@ void qemu_init(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } - qemu_opts_foreach(qemu_find_opts("device"), - default_driver_check, NULL, NULL); - qemu_opts_foreach(qemu_find_opts("global"), - default_driver_check, NULL, NULL); - - if (!vga_model && !default_vga) { - vga_interface_type = VGA_DEVICE; - } - if (!has_defaults || machine_class->no_serial) { - default_serial = 0; - } - if (!has_defaults || machine_class->no_parallel) { - default_parallel = 0; - } - if (!has_defaults || machine_class->no_floppy) { - default_floppy = 0; - } - if (!has_defaults || machine_class->no_cdrom) { - default_cdrom = 0; - } - if (!has_defaults || machine_class->no_sdcard) { - default_sdcard = 0; - } - if (!has_defaults) { - default_monitor = 0; - default_net = 0; - default_vga = 0; - } - - if (is_daemonized()) { - /* According to documentation and historically, -nographic redirects - * serial port, parallel port and monitor to stdio, which does not work - * with -daemonize. We can redirect these to null instead, but since - * -nographic is legacy, let's just error out. - * We disallow -nographic only if all other ports are not redirected - * explicitly, to not break existing legacy setups which uses - * -nographic _and_ redirects all ports explicitly - this is valid - * usage, -nographic is just a no-op in this case. - */ - if (nographic - && (default_parallel || default_serial || default_monitor)) { - error_report("-nographic cannot be used with -daemonize"); - exit(1); - } - } - - if (nographic) { - if (default_parallel) - add_device_config(DEV_PARALLEL, "null"); - if (default_serial && default_monitor) { - add_device_config(DEV_SERIAL, "mon:stdio"); - } else { - if (default_serial) - add_device_config(DEV_SERIAL, "stdio"); - if (default_monitor) - monitor_parse("stdio", "readline", false); - } - } else { - if (default_serial) - add_device_config(DEV_SERIAL, "vc:80Cx24C"); - if (default_parallel) - add_device_config(DEV_PARALLEL, "vc:80Cx24C"); - if (default_monitor) - monitor_parse("vc:80Cx24C", "readline", false); - } - - if (default_net) { - QemuOptsList *net = qemu_find_opts("net"); - qemu_opts_set(net, NULL, "type", "nic", &error_abort); -#ifdef CONFIG_SLIRP - qemu_opts_set(net, NULL, "type", "user", &error_abort); -#endif - } - -#if defined(CONFIG_VNC) - if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { - display_remote++; - } -#endif - if (dpy.type == DISPLAY_TYPE_DEFAULT && !display_remote) { - if (!qemu_display_find_default(&dpy)) { - dpy.type = DISPLAY_TYPE_NONE; -#if defined(CONFIG_VNC) - vnc_parse("localhost:0,to=99,id=default", &error_abort); -#endif - } - } - if (dpy.type == DISPLAY_TYPE_DEFAULT) { - dpy.type = DISPLAY_TYPE_NONE; - } - + qemu_disable_default_devices(); + qemu_create_default_devices(); if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) { error_report("-alt-grab and -ctrl-grab are only valid " "for SDL, ignoring option"); @@ -4404,14 +4424,6 @@ void qemu_init(int argc, char **argv, char **envp) if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) exit(1); - /* If no default VGA is requested, the default is "none". */ - if (default_vga) { - vga_model = get_default_vga_model(machine_class); - } - if (vga_model) { - select_vgahw(machine_class, vga_model); - } - /* This checkpoint is required by replay to separate prior clock reading from the other reads, because timer polling functions query clock values from the log. */ From patchwork Wed Oct 21 20:57:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849737 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 119D914B4 for ; Wed, 21 Oct 2020 21:03:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AED0C21481 for ; Wed, 21 Oct 2020 21:03:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fSy2OgmH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AED0C21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:49134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLGW-0003u5-CK for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:03:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB2-0005hj-3c for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006iS-BF for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xB+pW8wMlRiDeT88aB17Knd4JTsxOyNUrcHOEWW+0Ws=; b=fSy2OgmHUdJuqIjK47lSZQoHHR1hsrIpIUu1b0Ts13ar8QVI1Z7zgi4+8gWtrcKeMau9xO IR3gbTTXi+teRxOSKCD8Rlr+XQbu0dNbrtZRqObFidrNkzn9kv8wUDMvQNFvjAy1rZYzru h27l2W87ZhCFfzlKJK2iLD4Tmr7Ijh8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-289-y3KvK72wPGu7IwKAyxJ-Nw-1; Wed, 21 Oct 2020 16:57:35 -0400 X-MC-Unique: y3KvK72wPGu7IwKAyxJ-Nw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 401B91005E77 for ; Wed, 21 Oct 2020 20:57:34 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id C326F6EF62; Wed, 21 Oct 2020 20:57:33 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 20/22] vl: move CHECKPOINT_INIT after preconfig Date: Wed, 21 Oct 2020 16:57:14 -0400 Message-Id: <20201021205716.2359430-21-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Move CHECKPOINT_INIT right before the machine initialization is completed. Everything before is essentially an extension of command line parsing. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé --- softmmu/vl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 0a6f47e7d6..e9391929f6 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3194,6 +3194,11 @@ void qemu_finish_machine_init(void) exit(1); } + /* This checkpoint is required by replay to separate prior clock + reading from the other reads, because timer polling functions query + clock values from the log. */ + replay_checkpoint(CHECKPOINT_INIT); + machine_run_board_init(current_machine); /* @@ -4424,11 +4429,6 @@ void qemu_init(int argc, char **argv, char **envp) if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) exit(1); - /* This checkpoint is required by replay to separate prior clock - reading from the other reads, because timer polling functions query - clock values from the log. */ - replay_checkpoint(CHECKPOINT_INIT); - current_machine->boot_order = boot_order; /* parse features once if machine provides default cpu_type */ From patchwork Wed Oct 21 20:57:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AF0D1580 for ; Wed, 21 Oct 2020 21:19:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83C4724198 for ; Wed, 21 Oct 2020 21:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HkOWynpx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83C4724198 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:57656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLVp-0003XL-B7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:19:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB3-0005ml-V3 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006il-D5 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bK4gylZUGKfaKRmWvnQi9V/BTgaNzQabt2jQ7n87MRU=; b=HkOWynpxVXXA41lnxKMyWgKmQbkHhZpNrgQ6Hl+0SVMa3NmusKWYM2qBPb56/fFY3TQ9XT RN1CZY+lT001PsY9ShNANLd+dggcrazvsTOvH3JBMyb35a7cHWVeAQ7ZL+8vvcPB5i8QxK Y+lwvh84mfKrmxu4q5NdiB5XaN7EgFA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-utUJDYgqNMWhhDbTXH9p5A-1; Wed, 21 Oct 2020 16:57:35 -0400 X-MC-Unique: utUJDYgqNMWhhDbTXH9p5A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE10B835B8E for ; Wed, 21 Oct 2020 20:57:34 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C3746EF62; Wed, 21 Oct 2020 20:57:34 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 21/22] vl: separate qemu_create_early_backends Date: Wed, 21 Oct 2020 16:57:15 -0400 Message-Id: <20201021205716.2359430-22-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" "Early" backends are created before the machine and can be used as machine options. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 123 +++++++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 58 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index e9391929f6..866df5bb7c 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -117,6 +117,14 @@ #define MAX_VIRTIO_CONSOLES 1 +typedef struct BlockdevOptionsQueueEntry { + BlockdevOptions *bdo; + Location loc; + QSIMPLEQ_ENTRY(BlockdevOptionsQueueEntry) entry; +} BlockdevOptionsQueueEntry; + +typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue; + static const char *cpu_option; static const char *data_dir[16]; static int data_dir_idx; @@ -126,7 +134,9 @@ static const char *boot_once; static const char *incoming; static const char *loadvm; static int display_remote; +static int snapshot; static QemuPluginList plugin_list = QTAILQ_HEAD_INITIALIZER(plugin_list); +static BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); static bool nographic = false; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; int mem_prealloc; /* force preallocation of physical target memory */ @@ -1043,14 +1053,6 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type, } -typedef struct BlockdevOptionsQueueEntry { - BlockdevOptions *bdo; - Location loc; - QSIMPLEQ_ENTRY(BlockdevOptionsQueueEntry) entry; -} BlockdevOptionsQueueEntry; - -typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue; - static void configure_blockdev(BlockdevOptionsQueue *bdo_queue, MachineClass *machine_class, int snapshot) { @@ -2640,7 +2642,7 @@ static int machine_set_property(void *opaque, * cannot be created here, as it depends on the chardev * already existing. */ -static bool object_create_initial(const char *type, QemuOpts *opts) +static bool object_create_early(const char *type, QemuOpts *opts) { if (user_creatable_print_help(type, opts)) { exit(0); @@ -2692,6 +2694,58 @@ static bool object_create_initial(const char *type, QemuOpts *opts) return true; } +static void qemu_create_early_backends(void) +{ + MachineClass *machine_class = MACHINE_GET_CLASS(current_machine); + + if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) { + error_report("-alt-grab and -ctrl-grab are only valid " + "for SDL, ignoring option"); + } + if (dpy.has_window_close && + (dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) { + error_report("-no-quit is only valid for GTK and SDL, " + "ignoring option"); + } + + qemu_display_early_init(&dpy); + qemu_console_early_init(); + + if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) { +#if defined(CONFIG_OPENGL) + error_report("OpenGL is not supported by the display"); +#else + error_report("OpenGL support is disabled"); +#endif + exit(1); + } + + qemu_opts_foreach(qemu_find_opts("object"), + user_creatable_add_opts_foreach, + object_create_early, &error_fatal); + + /* spice needs the timers to be initialized by this point */ + /* spice must initialize before audio as it changes the default auiodev */ + /* spice must initialize before chardevs (for spicevmc and spiceport) */ + qemu_spice_init(); + + qemu_opts_foreach(qemu_find_opts("chardev"), + chardev_init_func, NULL, &error_fatal); + +#ifdef CONFIG_VIRTFS + qemu_opts_foreach(qemu_find_opts("fsdev"), + fsdev_init_func, NULL, &error_fatal); +#endif + + /* + * Note: we need to create audio and block backends before + * machine_set_property(), so machine properties can refer to + * them. + */ + configure_blockdev(&bdo_queue, machine_class, snapshot); + audio_init_audiodevs(); +} + /* * The remainder of object creation happens after the @@ -2699,7 +2753,7 @@ static bool object_create_initial(const char *type, QemuOpts *opts) */ static bool object_create_delayed(const char *type, QemuOpts *opts) { - return !object_create_initial(type, opts); + return !object_create_early(type, opts); } @@ -3308,7 +3362,6 @@ void qemu_finish_machine_init(void) void qemu_init(int argc, char **argv, char **envp) { - int snapshot = 0; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts = NULL, *accel_opts = NULL; QemuOptsList *olist; @@ -3321,7 +3374,6 @@ void qemu_init(int argc, char **argv, char **envp) FILE *vmstate_dump_file = NULL; Error *err = NULL; bool have_custom_ram_size; - BlockdevOptionsQueue bdo_queue = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue); qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4291,52 +4343,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_disable_default_devices(); qemu_create_default_devices(); - if ((alt_grab || ctrl_grab) && dpy.type != DISPLAY_TYPE_SDL) { - error_report("-alt-grab and -ctrl-grab are only valid " - "for SDL, ignoring option"); - } - if (dpy.has_window_close && - (dpy.type != DISPLAY_TYPE_GTK && dpy.type != DISPLAY_TYPE_SDL)) { - error_report("-no-quit is only valid for GTK and SDL, " - "ignoring option"); - } - - qemu_display_early_init(&dpy); - qemu_console_early_init(); - - if (dpy.has_gl && dpy.gl != DISPLAYGL_MODE_OFF && display_opengl == 0) { -#if defined(CONFIG_OPENGL) - error_report("OpenGL is not supported by the display"); -#else - error_report("OpenGL support is disabled"); -#endif - exit(1); - } - - qemu_opts_foreach(qemu_find_opts("object"), - user_creatable_add_opts_foreach, - object_create_initial, &error_fatal); - - /* spice needs the timers to be initialized by this point */ - /* spice must initialize before audio as it changes the default auiodev */ - /* spice must initialize before chardevs (for spicevmc and spiceport) */ - qemu_spice_init(); - - qemu_opts_foreach(qemu_find_opts("chardev"), - chardev_init_func, NULL, &error_fatal); - -#ifdef CONFIG_VIRTFS - qemu_opts_foreach(qemu_find_opts("fsdev"), - fsdev_init_func, NULL, &error_fatal); -#endif - - /* - * Note: we need to create audio and block backends before - * machine_set_property(), so machine properties can refer to - * them. - */ - configure_blockdev(&bdo_queue, machine_class, snapshot); - audio_init_audiodevs(); + qemu_create_early_backends(); machine_opts = qemu_get_machine_opts(); qemu_opt_foreach(machine_opts, machine_set_property, current_machine, From patchwork Wed Oct 21 20:57:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11849751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B72361C for ; Wed, 21 Oct 2020 21:08:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1937721481 for ; Wed, 21 Oct 2020 21:08:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UNDzNwor" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1937721481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:34522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVLLN-0001gC-3l for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Oct 2020 17:08:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVLB2-0005jA-Oh for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52788) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kVLAx-0006ip-BN for qemu-devel@nongnu.org; Wed, 21 Oct 2020 16:57:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603313858; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1b85d42vwX8iTxar+RM0i1tY3ljNgs7N/FTdg/zYyto=; b=UNDzNwor6BTti/GPPvOkyZTfz9i79i7zuMbTiWlhfKIJ+T/Sets+GVM/ehXVsDArkdsOz2 OCisZ69cgG42xgj1gX01jYqO7L7FhbJqUF1vuOOwuM3vPi2AVeIysTZK7v719scPCgHr0V 90+QldT7q5BCcyQV/hu+ZvEgTrGunh0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-1GrUYk1AP7CT7-rmh-36ww-1; Wed, 21 Oct 2020 16:57:36 -0400 X-MC-Unique: 1GrUYk1AP7CT7-rmh-36ww-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6657C1006718 for ; Wed, 21 Oct 2020 20:57:35 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id E98D96EF62; Wed, 21 Oct 2020 20:57:34 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 22/22] vl: separate qemu_create_late_backends Date: Wed, 21 Oct 2020 16:57:16 -0400 Message-Id: <20201021205716.2359430-23-pbonzini@redhat.com> In-Reply-To: <20201021205716.2359430-1-pbonzini@redhat.com> References: <20201021205716.2359430-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pbonzini@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 02:16:02 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jsnow@redhat.com, berrange@redhat.com, ehabkost@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" "Late" backends are created after the machine. Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 64 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 866df5bb7c..f36ec16cad 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2751,11 +2751,41 @@ static void qemu_create_early_backends(void) * The remainder of object creation happens after the * creation of chardev, fsdev, net clients and device data types. */ -static bool object_create_delayed(const char *type, QemuOpts *opts) +static bool object_create_late(const char *type, QemuOpts *opts) { return !object_create_early(type, opts); } +static void qemu_create_late_backends(void) +{ + if (qtest_chrdev) { + qtest_server_init(qtest_chrdev, qtest_log, &error_fatal); + } + + net_init_clients(&error_fatal); + + qemu_opts_foreach(qemu_find_opts("object"), + user_creatable_add_opts_foreach, + object_create_late, &error_fatal); + + if (tpm_init() < 0) { + exit(1); + } + + qemu_opts_foreach(qemu_find_opts("mon"), + mon_init_func, NULL, &error_fatal); + + /* now chardevs have been created we may have semihosting to connect */ + qemu_semihosting_connect_chardevs(); + qemu_semihosting_console_init(); + + if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) + exit(1); + if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) + exit(1); + if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) + exit(1); +} static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_size, MachineClass *mc) @@ -3372,7 +3402,6 @@ void qemu_init(int argc, char **argv, char **envp) ram_addr_t maxram_size; uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; - Error *err = NULL; bool have_custom_ram_size; qemu_add_opts(&qemu_drive_opts); @@ -4385,10 +4414,6 @@ void qemu_init(int argc, char **argv, char **envp) */ migration_object_init(); - if (qtest_chrdev) { - qtest_server_init(qtest_chrdev, qtest_log, &error_fatal); - } - opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { boot_order = qemu_opt_get(opts, "order"); @@ -4409,32 +4434,7 @@ void qemu_init(int argc, char **argv, char **envp) boot_order = machine_class->default_boot_order; } - if (net_init_clients(&err) < 0) { - error_report_err(err); - exit(1); - } - - qemu_opts_foreach(qemu_find_opts("object"), - user_creatable_add_opts_foreach, - object_create_delayed, &error_fatal); - - if (tpm_init() < 0) { - exit(1); - } - - qemu_opts_foreach(qemu_find_opts("mon"), - mon_init_func, NULL, &error_fatal); - - /* now chardevs have been created we may have semihosting to connect */ - qemu_semihosting_connect_chardevs(); - qemu_semihosting_console_init(); - - if (foreach_device_config(DEV_SERIAL, serial_parse) < 0) - exit(1); - if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0) - exit(1); - if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0) - exit(1); + qemu_create_late_backends(); current_machine->boot_order = boot_order;