From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606140976; cv=none; d=zohomail.com; s=zohoarc; b=GIoee/cVs5ATmkYqT3WF9+SXwcT+T71BgrQDKaBVZ6HL23Cof+B8Av7JMjHtSNoCMgQOO/a4oN3uPhPS26odIkMip9weJ0EkXJC1vPQ5oweNecHYuOEc5E7IZlN0WdrgrJC3eVEEmXcZJAsjBLm/yk9EFZ2TPOBwmlJ6lyMwQSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606140976; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jmE9sDj26z8c099Zc796rgUYbbHxLvfrprSGh1ULnH8=; b=gId1A/NgqYac6mSH6jQeIyZCdGxPVb4hVOcALOue/1pFe9IiA2MAyLP8uEr0WEy75j3wqWTclDbUIH9WezmjlqM0245fBZwOQOKdR+CV7FornSAP0nfvi22b3XxdY4VpGqBDUGSN5Hz9VvxyN7WpNvJjSD0Rkg9Ydf0BCmh5CwU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606140976114155.9432096320038; Mon, 23 Nov 2020 06:16:16 -0800 (PST) Received: from localhost ([::1]:53742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCdZ-0004Yb-FV for importer@patchew.org; Mon, 23 Nov 2020 09:16:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36400) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCc7-0002oQ-5B for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56063) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc4-0007gz-G8 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:42 -0500 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-157-UUvaQadfOL6iET4v_9eH-w-1; Mon, 23 Nov 2020 09:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6AB27100B713 for ; Mon, 23 Nov 2020 14:14:36 +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 1AC9B5D6D3; Mon, 23 Nov 2020 14:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140879; 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=jmE9sDj26z8c099Zc796rgUYbbHxLvfrprSGh1ULnH8=; b=D0G4hMiTRGzfr8FdG5GVhq+rHeSFEr1N9YVR7sIQAJBFKzIvb3un2Ya+6fO8Hbmy6F6wJJ B0Zj/7Uk9ugh9KKbGJ84HM2s5JrvT+k1jJLt4MEq0K4Qqyup7Vtd0KJTdDwcX3kZYfxco2 EWspOJR2XTs+AXQ/PNERSph408xpDKo= X-MC-Unique: UUvaQadfOL6iET4v_9eH-w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 01/36] vl: extract validation of -smp to machine.c Date: Mon, 23 Nov 2020 09:14:00 -0500 Message-Id: <20201123141435.2726558-2-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Once smp_parse is done, the validation operates on the MachineState. There is no reason for that code to be in vl.c. Reviewed-by: Igor Mammedov Tested-by: Igor Mammedov 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 d0408049b5..cd298fac13 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1074,6 +1074,29 @@ MemoryRegion *machine_consume_memdev(MachineState *m= achine, return ret; } =20 +bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp) +{ + MachineClass *mc =3D 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 =3D 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; =20 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 aaea88f599..fae72a9071 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3972,24 +3972,8 @@ void qemu_init(int argc, char **argv, char **envp) exit(0); } =20 - 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); =20 if (mem_prealloc) { char *val; --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141134; cv=none; d=zohomail.com; s=zohoarc; b=Mefjz6TZ2JadfuaV4WDGrmjIr7Ys5MVpVm6zSzmyaq6z0zuskPyiiJPTIbVQvbr3/ZnYd2GAz8ODfzaSgReVaWjv2A/WqwEObzyONI4bGZE44LYA6Ijb9PB08J4HhMvRh8hfY/9USKZO3EwTjIzZOaB/EXOVy5P7I+6Jl359srs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141134; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A7PITbbM/y0wH2qCdH4g5YJyUpSQrKfKhfPCdLQGsx0=; b=gwGYPz3iycTJi8s8cAxTvQxWa+lzT2LtTzAuQo/EOxMx8hdsjjmUlEO1uhGl9wgc4RE5RD9qYPpawCymW49QRQkmkxCgOdvTyfvwJVaTFiifJdih3ksUWiuMxZdB2yi6rytJqeOjFksq9hHKReIYcYtb+d0O/0U6WzqhhYuWUDQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141134486962.3254809337035; Mon, 23 Nov 2020 06:18:54 -0800 (PST) Received: from localhost ([::1]:33898 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCg9-0007ys-BU for importer@patchew.org; Mon, 23 Nov 2020 09:18:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCc7-0002oU-80 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc4-0007h1-FK for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:43 -0500 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-593-862exOt-NeeetqA6Kzj0Qg-1; Mon, 23 Nov 2020 09:14:37 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8CA418B9ECC for ; Mon, 23 Nov 2020 14:14:36 +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 8B4395D6D3; Mon, 23 Nov 2020 14:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140879; 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=A7PITbbM/y0wH2qCdH4g5YJyUpSQrKfKhfPCdLQGsx0=; b=BEmZBEQ9LGT0Qoq2yohU922UU5Gz/x93aCe2wAymQsn3gp45DBU6yw8/L7TXw+K5/A3e0S 6svnNfgJaloQ08g5PFs7eLzc0RM7I8rC5Rn0QHPg1F73LoH01KAQTwZJ5efYSMYmWcskKx XIAgnPZQ7E1iQQ/vh2bP7Q/CVwCNy+s= X-MC-Unique: 862exOt-NeeetqA6Kzj0Qg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 02/36] vl: remove bogus check Date: Mon, 23 Nov 2020 09:14:01 -0500 Message-Id: <20201123141435.2726558-3-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Igor Mammedov 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 fae72a9071..c45a99a2bf 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4028,12 +4028,6 @@ void qemu_init(int argc, char **argv, char **envp) } =20 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 redirec= ts * serial port, parallel port and monitor to stdio, which does not= work * with -daemonize. We can redirect these to null instead, but si= nce --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141420; cv=none; d=zohomail.com; s=zohoarc; b=gXVTlpNuLUbauDcgMeTw07v8qK77QlkXUZIQRll0/X9QUGKDUYlajhUu5XKDVOUv4g/uVRH8O8tqiNzDrdgOkmYL2ywy9tGkj4wpI0vLIFEJhFgSKcbv/HvvofKaLSH3IcVFFisXV17x3c5qxDxUUGaoxcbl6Bj67xb9z9dB1Lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141420; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kf1g0EXM0XbepA8IpbXTYEtdbqr1gkaRklRa3Cu/jx8=; b=A+Migx6+H4WsgR+wwY8ZSoSrqj1aVLaXVx34etS2emZwDQtHxUL1F75qC4KTYfHXooo7wz+26YU0Y5ofbcipsV7Dwtibk2PVKyTm3gf4zQlIYpNo8q6uth1rIX15COGqXoGX8PBnTqwxX3XNMIr5Pj/fskDZSR6OGyYur391GF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141420831869.6647754672912; Mon, 23 Nov 2020 06:23:40 -0800 (PST) Received: from localhost ([::1]:50934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCkl-0006ZP-3n for importer@patchew.org; Mon, 23 Nov 2020 09:23:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCc9-0002pk-5B for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc6-0007iG-EM for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:44 -0500 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-247-KJB1S7FsNk-VqQRuCpDw5w-1; Mon, 23 Nov 2020 09:14:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 41E7B805BE5 for ; Mon, 23 Nov 2020 14:14:37 +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 05CF25D6D3 for ; Mon, 23 Nov 2020 14:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140881; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kf1g0EXM0XbepA8IpbXTYEtdbqr1gkaRklRa3Cu/jx8=; b=doKJfCLNY5iYjY7UsJsY9jTxg8YUwRkiq02ctNo4wxz5ovSVJdQTKkeWzZWYCzQOfyN2Rv LZP08EHMJejifPbfpGzQMlonLQq6jc/WNSujPkxu6P1vKILpOvC6KRxID/6wj1iy1npQui i+1fS3UrUbq/KiOAzMmyHMsJGv50l4E= X-MC-Unique: KJB1S7FsNk-VqQRuCpDw5w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 03/36] vl: split various early command line options to a separate function Date: Mon, 23 Nov 2020 09:14:02 -0500 Message-Id: <20201123141435.2726558-4-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Igor Mammedov --- softmmu/vl.c | 200 ++++++++++++++++++++++++++++----------------------- 1 file changed, 112 insertions(+), 88 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index c45a99a2bf..07378301d5 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -117,6 +117,7 @@ =20 #define MAX_VIRTIO_CONSOLES 1 =20 +static const char *cpu_option; static const char *data_dir[16]; static int data_dir_idx; enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; @@ -142,6 +143,9 @@ int vga_interface_type =3D VGA_NONE; static DisplayOptions dpy; static int num_serial_hds; static Chardev **serial_hds; +static const char *log_mask; +static const char *log_file; +static bool list_data_dirs; Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack =3D 0; int singlestep =3D 0; @@ -2862,6 +2866,105 @@ static char *find_datadir(void) return get_relocated_path(CONFIG_QEMU_DATADIR); } =20 +static void qemu_process_early_options(void) +{ + char **dirs; + int i; + +#ifdef CONFIG_SECCOMP + QemuOptsList *olist =3D 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 =3D 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 =3D g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S= , 0); + for (i =3D 0; dirs[i] !=3D 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 machi= ne + * 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 =3D 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 =3D qemu_unlink_pidfile; + qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); +} + + void qemu_init(int argc, char **argv, char **envp) { int i; @@ -2878,21 +2981,16 @@ void qemu_init(int argc, char **argv, char **envp) const char *optarg; const char *loadvm =3D NULL; MachineClass *machine_class; - const char *cpu_option; const char *vga_model =3D NULL; const char *incoming =3D NULL; bool userconfig =3D true; bool nographic =3D false; int display_remote =3D 0; - const char *log_mask =3D NULL; - const char *log_file =3D NULL; ram_addr_t maxram_size; uint64_t ram_slots =3D 0; FILE *vmstate_dump_file =3D NULL; Error *main_loop_err =3D NULL; Error *err =3D NULL; - bool list_data_dirs =3D false; - char **dirs; const char *mem_path =3D NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); @@ -3842,19 +3940,17 @@ void qemu_init(int argc, char **argv, char **envp) loc_set_none(); =20 /* - * Check for -cpu help and -device help before we call select_machine(= ), - * which will return an error if the architecture has no default machi= ne - * 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(); =20 - 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); } =20 user_register_global_props(); @@ -3875,40 +3971,6 @@ void qemu_init(int argc, char **argv, char **envp) have_custom_ram_size =3D set_memory_options(&ram_slots, &maxram_size, machine_class); =20 - 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 =3D 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 =3D 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 =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); if (machine_help_func(qemu_get_machine_opts(), current_machine)) { exit(0); @@ -3934,44 +3996,6 @@ void qemu_init(int argc, char **argv, char **envp) qemu_set_hw_version(machine_class->hw_version); } =20 - 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 =3D 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 =3D g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S= , 0); - for (i =3D 0; dirs[i] !=3D 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 =3D 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); =20 --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141135; cv=none; d=zohomail.com; s=zohoarc; b=iPlAV+fj+ZDiNrtKFM1GYZmkzg+SrY7HklBMA47n3F5I/m4ESfx2IG38kNH8JYJ48HQq9l3aUOo2B8kSwhCmnU1dzTj+F0iD4u3PPyv/N1cxaxULX5iCtKQw873dD8oOcPEx6VzS9g4Bvt5GrA86ZPXr8nYc9ew934YEiOQ/AuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141135; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Usp35wofMlITjnrgSzeqe5CcA89RmTwA6lUe1JlMnA=; b=Kf1feO5k98IJQ4jOD+qQaR6/gggpioTEm9/tFFs5SCdWQNnrXjvavwqU7T9m18A3al0VU5SoBp2Kg0KtNR6Tv+qhhho9/1X+8sQ//aV9DiZnWDcRZKAySMyrUFUPmqpNOFFKj8T7bRkaXvZA6i+d2yd5TdjVA8Ye6hOf7w2IcJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141135867992.6465160715262; Mon, 23 Nov 2020 06:18:55 -0800 (PST) Received: from localhost ([::1]:34022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCgB-00082C-6E for importer@patchew.org; Mon, 23 Nov 2020 09:18:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCc7-0002ol-KV for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc5-0007hR-W6 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:43 -0500 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-345-0W7oF2XVOQOlQ0btYxGxIQ-1; Mon, 23 Nov 2020 09:14:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1C51100C606 for ; Mon, 23 Nov 2020 14:14:37 +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 6330C5D6D3; Mon, 23 Nov 2020 14:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140880; 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=5Usp35wofMlITjnrgSzeqe5CcA89RmTwA6lUe1JlMnA=; b=UtSmHfbDoBjuhW1KLx31mg+xD06yKXeq22w5g/D6FRc01uUIMFZNYTifSlUK95Dcm5q2rP JJ6NWMiMm9Q5Us4Bpa644A63Zylb2Ab/o94TLXSeLHKukrCE+I1eL92huhHWYALDrXbNZ5 hcVCl+3/4juhOKvoR6huJkoc7U3y9qE= X-MC-Unique: 0W7oF2XVOQOlQ0btYxGxIQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 04/36] vl: move various initialization routines out of qemu_init Date: Mon, 23 Nov 2020 09:14:03 -0500 Message-Id: <20201123141435.2726558-5-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Some very simple initialization routines can be nested in existing subsystem-level functions, do that to simplify qemu_init. Reviewed-by: Igor Mammedov 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 cd298fac13..5260155962 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -874,6 +874,9 @@ static void machine_initfn(Object *obj) MachineState *ms =3D MACHINE(obj); MachineClass *mc =3D MACHINE_GET_CLASS(obj); =20 + container_get(obj, "/peripheral"); + container_get(obj, "/peripheral-anon"); + ms->dump_guest_core =3D true; ms->mem_merge =3D true; ms->enable_graphics =3D true; diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 5e737195b5..b77a2f1da7 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -785,14 +785,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 *de= v); =20 -/** - * @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 87a9b59f83..d9e94f4080 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -182,6 +182,10 @@ void migration_object_init(void) error_report_err(err); exit(1); } + + blk_mig_init(); + ram_mig_init(); + dirty_bitmap_mig_init(); } =20 void migration_shutdown(void) diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index bf79d0bbcd..d060e765da 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -943,12 +943,6 @@ BlockBackend *blk_by_qdev_id(const char *id, Error **e= rrp) return blk; } =20 -void qdev_machine_init(void) -{ - qdev_get_peripheral_anon(); - qdev_get_peripheral(); -} - QemuOptsList qemu_device_opts =3D { .name =3D "device", .implied_opt_name =3D "driver", diff --git a/softmmu/vl.c b/softmmu/vl.c index 07378301d5..b8d65ac532 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4276,10 +4276,6 @@ void qemu_init(int argc, char **argv, char **envp) exit(1); } =20 - blk_mig_init(); - ram_mig_init(); - dirty_bitmap_mig_init(); - qemu_opts_foreach(qemu_find_opts("mon"), mon_init_func, NULL, &error_fatal); =20 @@ -4312,7 +4308,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(); =20 current_machine->boot_order =3D boot_order; =20 --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606140977; cv=none; d=zohomail.com; s=zohoarc; b=Mg9iMQRmyBhpJ0GTAFQbRBQZq4HVOC12cnc6PhZjjX/klIfEFhUiTXgpzjMztleJwIJRnB3fdPV3Mrkve49MfGSr7HYLLbY9OkoH+b5v5b3RMCB7ahdc35wnkPImh3rk5UAPv+lUCTdL61lfta03EOXcuQqA14S08KVbePTSLSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606140977; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PM2MiVUMIffOMkKcgIxggp1xjchgYUeK05DVXa5V/Pc=; b=ZQqPWhpZRV4rLGEkRB8POhVHykVuHXaddAgr7KJhPhYQeQq6A9+KgTYjdCjPdN1Z9yMmxSzCVuKdQ1hZx2OGtsASyohOOPwcKrk/VzjJzwGEkLEDCw5sg431KhfGpEafXd9yeSipSva28NcnibMROO5OQo+9q7rDRmKNpHFGwHI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606140977045926.4720629850337; Mon, 23 Nov 2020 06:16:17 -0800 (PST) Received: from localhost ([::1]:53962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCdc-0004e7-4y for importer@patchew.org; Mon, 23 Nov 2020 09:16:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCc8-0002or-BD for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc6-0007iA-69 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:44 -0500 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-582--sB8VIq6OP2t0e9-_9Flfg-1; Mon, 23 Nov 2020 09:14:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C43B100B719 for ; Mon, 23 Nov 2020 14:14:38 +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 D23755D6D3; Mon, 23 Nov 2020 14:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140881; 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=PM2MiVUMIffOMkKcgIxggp1xjchgYUeK05DVXa5V/Pc=; b=Q+B1ZwtAdgxsNKT4TTDe+oaHijZfFYKX5v2nf/G4xRM1z6e1RxdG1jc1KGE3uIpBCvte6m e7znX3hr9jG+VrVqZ53a1bfLxHXYG5rpAGmZ/O1hy74TsazbYZkaSZQWRGymseEv4/eS52 sMQqETE4+X/X+QSIlDbPn4zKT70NqDE= X-MC-Unique: -sB8VIq6OP2t0e9-_9Flfg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 05/36] vl: extract qemu_init_subsystems Date: Mon, 23 Nov 2020 09:14:04 -0500 Message-Id: <20201123141435.2726558-6-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Igor Mammedov 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 b8d65ac532..2832ab937e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -128,7 +128,7 @@ bool enable_mlock =3D false; bool enable_cpu_pm =3D false; int nb_nics; NICInfo nd_table[MAX_NICS]; -int autostart; +int autostart =3D 1; static enum { RTC_BASE_UTC, RTC_BASE_LOCALTIME, @@ -1228,7 +1228,8 @@ struct VMChangeStateEntry { int priority; }; =20 -static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head; +static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head =3D + QTAILQ_HEAD_INITIALIZER(vm_change_state_head); =20 /** * qemu_add_vm_change_state_handler_prio: @@ -2964,11 +2965,44 @@ static void qemu_maybe_daemonize(const char *pid_fi= le) qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); } =20 +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(); + socket_init(); +} =20 void qemu_init(int argc, char **argv, char **envp) { int i; - int snapshot, linux_boot; + int snapshot =3D 0; + int linux_boot; const char *initrd_filename; const char *kernel_filename, *kernel_cmdline; const char *boot_order =3D NULL; @@ -2989,7 +3023,6 @@ void qemu_init(int argc, char **argv, char **envp) ram_addr_t maxram_size; uint64_t ram_slots =3D 0; FILE *vmstate_dump_file =3D NULL; - Error *main_loop_err =3D NULL; Error *err =3D NULL; const char *mem_path =3D NULL; bool have_custom_ram_size; @@ -2997,22 +3030,6 @@ void qemu_init(int argc, char **argv, char **envp) QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); int mem_prealloc =3D 0; /* force preallocation of physical target memo= ry */ =20 - 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); @@ -3047,27 +3064,10 @@ void qemu_init(int argc, char **argv, char **envp) qemu_add_opts(&qemu_fw_cfg_opts); module_call_init(MODULE_INIT_OPTS); =20 - 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 =3D NULL; - snapshot =3D 0; - - nb_nics =3D 0; - - bdrv_init_with_whitelist(); + error_init(argv[0]); + qemu_init_exec_dir(argv[0]); =20 - autostart =3D 1; + qemu_init_subsystems(); =20 /* first pass of option parsing */ optind =3D 1; @@ -3948,13 +3948,10 @@ void qemu_init(int argc, char **argv, char **envp) qemu_process_help_options(); qemu_maybe_daemonize(pid_file); =20 - 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(); =20 user_register_global_props(); - replay_configure(icount_opts); =20 if (incoming && !preconfig_exit_requested) { @@ -3991,6 +3988,7 @@ void qemu_init(int argc, char **argv, char **envp) } =20 cpu_exec_init_all(); + page_size_init(); =20 if (machine_class->hw_version) { qemu_set_hw_version(machine_class->hw_version); @@ -4133,9 +4131,6 @@ void qemu_init(int argc, char **argv, char **envp) exit(1); } =20 - page_size_init(); - socket_init(); - qemu_opts_foreach(qemu_find_opts("object"), user_creatable_add_opts_foreach, object_create_initial, &error_fatal); @@ -4252,9 +4247,6 @@ void qemu_init(int argc, char **argv, char **envp) semihosting_arg_fallback(kernel_filename, kernel_cmdline); } =20 - /* initialize cpu timers and VCPU throttle modules */ - cpu_timers_init(); - if (default_net) { QemuOptsList *net =3D qemu_find_opts("net"); qemu_opts_set(net, NULL, "type", "nic", &error_abort); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141240; cv=none; d=zohomail.com; s=zohoarc; b=c8785qkC4qUzGcF0/DiBYO3RkpDPCW2ZOn5CE5LOXUxSv3W/Sf+TrQxYcR1Gy4pJeJqjyseiB/NUo7PP5QPX2I09cB+iPTqVFL1CX17Gi7oNRtLO6XJGhKKMW/76B+dtVjDsoyds5H1shXsFlsRvpI8kUeCTqBS3T3pCI3kzcUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141240; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zDArj2misGRAz5DJ+V7IPPT5E9biWt9FOXzBgTXZJuk=; b=e2cnHUDDZPsmZBzTpMhbq0vSvTBnKL08RGlVSl3JdZ7tIT00BclGyEBP5eUx/57qIgHk0eJd7f3TjOATF03fFCCeWo8GF51AYbi4uBRQ/FIgQ64p6gcxspRwO5ZH3LRJe/SIz84WiysiPfSfSI03sbVVN2VzyB0YNB+jKzh5eL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141240087755.835013816509; Mon, 23 Nov 2020 06:20:40 -0800 (PST) Received: from localhost ([::1]:42286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khChr-0002va-7W for importer@patchew.org; Mon, 23 Nov 2020 09:20:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCc8-0002ov-I2 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc6-0007iC-5A for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:44 -0500 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-63-0GtfyuLFOsy3pwZLaaKZJA-1; Mon, 23 Nov 2020 09:14:39 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B3D518B9ECB for ; Mon, 23 Nov 2020 14:14:38 +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 4D3925D6D3; Mon, 23 Nov 2020 14:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140881; 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=zDArj2misGRAz5DJ+V7IPPT5E9biWt9FOXzBgTXZJuk=; b=LP/CXE+6uTVPzOI5P7ndC+jArt4fycfuQPYSju4xQ6agw1QkCeyasuZUadqTbDVN/vneGI e/+sAkHxCjbKJpj8qffOJtcKWLpofpdvkAMwDWZEa6VYsq6bbARAG1LK+70Hxq/Ev0udVr +mdf+L+7DUELwqvdOKxTwbsEqNnLrkc= X-MC-Unique: 0GtfyuLFOsy3pwZLaaKZJA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 06/36] vl: move prelaunch part of qemu_init to new functions Date: Mon, 23 Nov 2020 09:14:05 -0500 Message-Id: <20201123141435.2726558-7-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 249 +++++++++++++++++++++++++++------------------------ 1 file changed, 134 insertions(+), 115 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 2832ab937e..8ceef00a27 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; enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; int display_opengl; const char* keyboard_layout =3D NULL; @@ -2998,6 +3001,134 @@ static void qemu_init_subsystems(void) socket_init(); } =20 +/* + * Called after leaving preconfig state. From here on runstate is + * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE. + */ +static void qemu_init_board(void) +{ + MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); + + 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); + } + + machine_run_board_init(current_machine); + + /* + * TODO To drop support for deprecated bogus if=3D..., 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(); + + if (hax_enabled()) { + /* FIXME: why isn't cpu_synchronize_all_post_init enough? */ + hax_sync_vcpus(); + } +} + +static void qemu_create_cli_devices(void) +{ + soundhw_init(); + + 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); + rom_reset_order_override(); +} + +static void qemu_machine_creation_done(void) +{ + DisplayState *ds; + + cpu_synchronize_all_post_init(); + + /* 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 =3D 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() !=3D 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; @@ -3005,9 +3136,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 =3D NULL; - const char *boot_once =3D NULL; - DisplayState *ds; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; QemuOptsList *olist; @@ -3024,7 +3152,6 @@ void qemu_init(int argc, char **argv, char **envp) uint64_t ram_slots =3D 0; FILE *vmstate_dump_file =3D NULL; Error *err =3D NULL; - const char *mem_path =3D NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); @@ -4347,117 +4474,10 @@ void qemu_init(int argc, char **argv, char **envp) /* do monitor/qmp handling at preconfig state if requested */ qemu_main_loop(); =20 - 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=3D..., 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 =3D 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(); + qemu_init_board(); + qemu_create_cli_devices(); + qemu_machine_creation_done(); =20 - if (rom_check_and_register_reset() !=3D 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 =3D NULL; if (load_snapshot(loadvm, &local_err) < 0) { @@ -4476,7 +4496,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 =3D NULL; qemu_start_incoming_migration(incoming, &local_err); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141138; cv=none; d=zohomail.com; s=zohoarc; b=em4hBL4G6s4iJUhfBZBbplG43uqWyb1HBHu+kAYFZ6hIBji/4pBpkiIHX5dSEmPW1ALmjJTwplUDpedijapBxdzaGC2KOfkWiGu2jOyTLS44h4u8+EOG94dfFajs0zQeKsgR0EHO3xbHGG/jBB7NMTEDxejPq+CefF2n0EFOy3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141138; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=var/topHFqBKR97UI5yAUI10U08JQBs77LTRyju85Cg=; b=aT6B+ZsOW/RZ81pNLikEtYWSLZIy2Qo2XSr6XJzenA4mTHCpkAAOvhSm/+KNXHf0VgeaNz9laf2W7bu9qu0J6OJx1MAX0EK2FzylM4lNXi2wpYrmCQDEsu0ysGtGl/9pilsjLduo8DMP6NWS7I3cY5KDaVen76wAHROzwY2O1ec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141138106394.09575542065; Mon, 23 Nov 2020 06:18:58 -0800 (PST) Received: from localhost ([::1]:34260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCgD-000885-Au for importer@patchew.org; Mon, 23 Nov 2020 09:18:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcA-0002te-Vt for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc9-0007ir-0g for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:46 -0500 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-331-I0m1A9V2OrOgDh-5n9EmPw-1; Mon, 23 Nov 2020 09:14:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A09318B9ED9 for ; Mon, 23 Nov 2020 14:14:41 +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 BC13A5D6D3; Mon, 23 Nov 2020 14:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140884; 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=var/topHFqBKR97UI5yAUI10U08JQBs77LTRyju85Cg=; b=QkphpZ/MYx1sXc+wKm2A1tAaWE7Pygzf1aoLAcONzDjFqPUcfiMbztDfv/QvKNR1Zoo+3e TopDEWafEderiWv+r3wDE7Jcg6hb46qtSAus9EM2RYOMwtG1VbPif2Jx4ILYyymeNwvTkf VeswCcxR3elM4+oTeI4H0DYaR547g8s= X-MC-Unique: I0m1A9V2OrOgDh-5n9EmPw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 07/36] vl: extract various command line validation snippets to a new function Date: Mon, 23 Nov 2020 09:14:06 -0500 Message-Id: <20201123141435.2726558-8-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 1 + softmmu/vl.c | 78 +++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 5260155962..7ef3de5ce5 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -880,6 +880,7 @@ static void machine_initfn(Object *obj) ms->dump_guest_core =3D true; ms->mem_merge =3D true; ms->enable_graphics =3D true; + ms->kernel_cmdline =3D g_strdup(""); =20 if (mc->nvdimm_supported) { Object *obj =3D OBJECT(ms); diff --git a/softmmu/vl.c b/softmmu/vl.c index 8ceef00a27..6699c23a16 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 =3D VGA_RETRACE_DUMB; int display_opengl; const char* keyboard_layout =3D NULL; @@ -2870,6 +2871,39 @@ static char *find_datadir(void) return get_relocated_path(CONFIG_QEMU_DATADIR); } =20 +static void qemu_validate_options(void) +{ + QemuOpts *machine_opts =3D qemu_get_machine_opts(); + const char *kernel_filename =3D qemu_opt_get(machine_opts, "kernel"); + const char *initrd_filename =3D qemu_opt_get(machine_opts, "initrd"); + const char *kernel_cmdline =3D qemu_opt_get(machine_opts, "append"); + + if (kernel_filename =3D=3D NULL) { + if (kernel_cmdline !=3D NULL) { + error_report("-append only allowed with -kernel option"); + exit(1); + } + + if (initrd_filename !=3D 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 =3D=3D DISPLAY_TYPE_CURSES) { + error_report("curses display cannot be used with -daemonize"); + exit(1); + } +#endif +} + static void qemu_process_early_options(void) { char **dirs; @@ -3133,9 +3167,6 @@ void qemu_init(int argc, char **argv, char **envp) { int i; int snapshot =3D 0; - int linux_boot; - const char *initrd_filename; - const char *kernel_filename, *kernel_cmdline; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; QemuOptsList *olist; @@ -3144,7 +3175,6 @@ void qemu_init(int argc, char **argv, char **envp) const char *loadvm =3D NULL; MachineClass *machine_class; const char *vga_model =3D NULL; - const char *incoming =3D NULL; bool userconfig =3D true; bool nographic =3D false; int display_remote =3D 0; @@ -4066,6 +4096,8 @@ void qemu_init(int argc, char **argv, char **envp) */ loc_set_none(); =20 + qemu_validate_options(); + /* * These options affect everything else and should be processed * before daemonizing. @@ -4081,12 +4113,6 @@ void qemu_init(int argc, char **argv, char **envp) user_register_global_props(); replay_configure(icount_opts); =20 - if (incoming && !preconfig_exit_requested) { - error_report("'preconfig' and 'incoming' options are " - "mutually exclusive"); - exit(EXIT_FAILURE); - } - configure_rtc(qemu_find_opts_singleton("rtc")); =20 machine_class =3D select_machine(); @@ -4191,12 +4217,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 =3D=3D DISPLAY_TYPE_CURSES) { - error_report("curses display cannot be used with -daemonize"); - exit(1); - } -#endif } =20 if (nographic) { @@ -4327,11 +4347,6 @@ void qemu_init(int argc, char **argv, char **envp) qtest_server_init(qtest_chrdev, qtest_log, &error_fatal); } =20 - machine_opts =3D qemu_get_machine_opts(); - kernel_filename =3D qemu_opt_get(machine_opts, "kernel"); - initrd_filename =3D qemu_opt_get(machine_opts, "initrd"); - kernel_cmdline =3D qemu_opt_get(machine_opts, "append"); - opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { boot_order =3D qemu_opt_get(opts, "order"); @@ -4352,24 +4367,9 @@ void qemu_init(int argc, char **argv, char **envp) boot_order =3D machine_class->default_boot_order; } =20 - if (!kernel_cmdline) { - kernel_cmdline =3D ""; - current_machine->kernel_cmdline =3D (char *)kernel_cmdline; - } - - linux_boot =3D (kernel_filename !=3D NULL); - - if (!linux_boot && *kernel_cmdline !=3D '\0') { - error_report("-append only allowed with -kernel option"); - exit(1); - } - - if (!linux_boot && initrd_filename !=3D NULL) { - error_report("-initrd only allowed with -kernel option"); - exit(1); - } - - if (semihosting_enabled() && !semihosting_get_argc() && kernel_filenam= e) { + if (semihosting_enabled() && !semihosting_get_argc()) { + const char *kernel_filename =3D qemu_opt_get(machine_opts, "kernel= "); + const char *kernel_cmdline =3D qemu_opt_get(machine_opts, "append"= ); /* fall back to the -kernel/-append */ semihosting_arg_fallback(kernel_filename, kernel_cmdline); } --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141026; cv=none; d=zohomail.com; s=zohoarc; b=AYJTf2lZPihJAXdhNycOePid7MRaVfgv0HmT6dnNuLwkHS3hEB4w3V+K1qWstXYLA3TZDD8yc95+Kh2JhXvFGaYfz5EWIQZWKqkrdNLVabNHzxw/Q2Us6szONoUAVZ9cGcvhRbSeaZoTFWjKbedjkOpuLEtSc08EoHsokJj7+5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141026; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EId/j+vRbcgqB9EuGzhzDaIodExfiY0lp6Om2qfpMVw=; b=SZ9F20y4SaMkajVie2kH+E4xfh3avfMtiBZiSuTrtq/GjG6BvbQ/NSVmGZvYNQsc4OCgNQt480+myKlHNLrl42QmAG39rlmKJ+36GyT/VdwWqT8w6yyccDfECUfva6eE8duEATz42xtFoNwdtS+tUltHqsVXPYqyI5PJanUFIN4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141026186443.91512314723366; Mon, 23 Nov 2020 06:17:06 -0800 (PST) Received: from localhost ([::1]:57486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCeP-00065y-9M for importer@patchew.org; Mon, 23 Nov 2020 09:17:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcE-00030F-V4 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcC-0007kS-TB for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 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-355-Jhqf9RR7PsCPYI9YkwX5jQ-1; Mon, 23 Nov 2020 09:14:42 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D77E3100B71F for ; Mon, 23 Nov 2020 14:14:41 +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 8ACBE5D6D3; Mon, 23 Nov 2020 14:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140888; 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=EId/j+vRbcgqB9EuGzhzDaIodExfiY0lp6Om2qfpMVw=; b=PAxzuxU2prVuIHW8YuqHpc5EXI8feLuJD9frVkwa6/k27y86vWrpbXOrJXqr/6fgg+oL1Y gKJAswcY17QteG2rIYEP+bgTLbDFmjb/llL+4ccpzRQnoR9Vuv1OOnBcWlm3CHBcVxiSkG kTKvxNx9fSn+CBhPMvHBrLhv3z5Dvoo= X-MC-Unique: Jhqf9RR7PsCPYI9YkwX5jQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 08/36] vl: preconfig and loadvm are mutually exclusive Date: Mon, 23 Nov 2020 09:14:07 -0500 Message-Id: <20201123141435.2726558-9-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Just like -incoming. Later we will add support for "-incoming defer -preconfig", because there are cases (Xen, block layer) that want to look at RUNSTATE_INMIGRATE. -loadvm will remain mutually exclusive with preconfig; the plan is to just do loadvm in the monitor, since the user is already going to interact with it for preconfiguration. Reviewed-by: Igor Mammedov 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 6699c23a16..acea4286e9 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 =3D VGA_RETRACE_DUMB; int display_opengl; const char* keyboard_layout =3D NULL; @@ -2890,6 +2891,11 @@ static void qemu_validate_options(void) } } =20 + 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"); @@ -3172,7 +3178,6 @@ void qemu_init(int argc, char **argv, char **envp) QemuOptsList *olist; int optind; const char *optarg; - const char *loadvm =3D NULL; MachineClass *machine_class; const char *vga_model =3D NULL; bool userconfig =3D true; --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141546; cv=none; d=zohomail.com; s=zohoarc; b=XUCquYltGLKRt7EyWvOcVi1x2JLDlOQfV3aqpmxUtXyzccGvZBHt1mOiFH7iI8Yfmj9tnkroBvIww5+xP2f23f7oCtqwMoFCjWJ52Je1RB5MH9Tt9F83OZfja/iZxKXRW4YKbF5G6a1qT0ksmynp8Dfg4rBM2pzsrGDRhiHaFHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141546; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CG45locCjFwoPcA5B0Ny4DYAZJCuqnv0J1XcSfjFwOM=; b=EAmtYsKcyEsW/KFqSHPGAH67cT6O25y1WMgtkMDCoqOcSSDR9sCsbhLEpximEex2RCD4SB5asKpXy3m+cYu+FuyuW+nT4UqebCBCQjSXpA6+ErYpBMkCV7SnWLuv9vF+OXT9+1p8HqMCspW8A38i6imul62sO67QXawKft0p4Qo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141546635347.1888843473365; Mon, 23 Nov 2020 06:25:46 -0800 (PST) Received: from localhost ([::1]:59364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCmn-0001dl-O7 for importer@patchew.org; Mon, 23 Nov 2020 09:25:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcB-0002v1-GC for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCc9-0007jG-LD for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:47 -0500 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-29-auNpljbEMYOhgLxv68_9JA-1; Mon, 23 Nov 2020 09:14:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 543EA81CBDB for ; Mon, 23 Nov 2020 14:14:42 +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 0483C5D6D3; Mon, 23 Nov 2020 14:14:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140885; 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=CG45locCjFwoPcA5B0Ny4DYAZJCuqnv0J1XcSfjFwOM=; b=O2f6OHpK1fcxi5rvXyCrqvJbFaplfPiqONjM7P75Z5oymoK9h/sqI41+RqIXdOcYVtzdUK 3LsmjglRhULfXDY7Yqw98VQR6K7E0e4D90hdUyvW1LAxA0Ri7OtbkKoJCiFKwolVvE1piC 7yJfn//YeFoekUt84+P75ENC6tiTum4= X-MC-Unique: auNpljbEMYOhgLxv68_9JA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 09/36] vl: extract various command line desugaring snippets to a new function Date: Mon, 23 Nov 2020 09:14:08 -0500 Message-Id: <20201123141435.2726558-10-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Keep the machine initialization sequence free of miscellaneous command line parsing actions. The only difference is that preallocation will always be done with one thread if -smp is not provided; previously it was using mc->default_cpus, which is almost always 1 anyway. Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index acea4286e9..1c08505f3a 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 =3D VGA_RETRACE_DUMB; +static int mem_prealloc; /* force preallocation of physical target memory = */ int display_opengl; const char* keyboard_layout =3D NULL; static ram_addr_t ram_size; @@ -158,7 +159,7 @@ int fd_bootchk =3D 1; static int no_reboot; int no_shutdown =3D 0; int graphic_rotate =3D 0; -const char *watchdog; +static const char *watchdog; QEMUOptionRom option_rom[MAX_OPTION_ROMS]; int nb_option_roms; int old_param =3D 0; @@ -2910,6 +2911,25 @@ static void qemu_validate_options(void) #endif } =20 +static void qemu_process_sugar_options(void) +{ + if (mem_prealloc) { + char *val; + + val =3D g_strdup_printf("%d", + (uint32_t) qemu_opt_get_number(qemu_find_opts_singleton("= smp-opts"), "cpus", 1)); + object_register_sugar_prop("memory-backend", "prealloc-threads", v= al); + g_free(val); + object_register_sugar_prop("memory-backend", "prealloc", "on"); + } + + if (watchdog) { + int i =3D select_watchdog(watchdog); + if (i > 0) + exit (i =3D=3D 1 ? 1 : 0); + } +} + static void qemu_process_early_options(void) { char **dirs; @@ -3171,7 +3191,6 @@ static void qemu_machine_creation_done(void) =20 void qemu_init(int argc, char **argv, char **envp) { - int i; int snapshot =3D 0; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; @@ -3190,7 +3209,6 @@ void qemu_init(int argc, char **argv, char **envp) bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); - int mem_prealloc =3D 0; /* force preallocation of physical target memo= ry */ =20 qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4102,6 +4120,7 @@ void qemu_init(int argc, char **argv, char **envp) loc_set_none(); =20 qemu_validate_options(); + qemu_process_sugar_options(); =20 /* * These options affect everything else and should be processed @@ -4155,15 +4174,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); =20 - if (mem_prealloc) { - char *val; - - val =3D g_strdup_printf("%d", current_machine->smp.cpus); - object_register_sugar_prop("memory-backend", "prealloc-threads", v= al); - g_free(val); - object_register_sugar_prop("memory-backend", "prealloc", "on"); - } - /* * Get the default machine options from the machine if it is not alrea= dy * specified either by the configuration file or by the command line. @@ -4422,12 +4432,6 @@ void qemu_init(int argc, char **argv, char **envp) select_vgahw(machine_class, vga_model); } =20 - if (watchdog) { - i =3D select_watchdog(watchdog); - if (i > 0) - exit (i =3D=3D 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. */ --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141241; cv=none; d=zohomail.com; s=zohoarc; b=O9+LoyhA0wFHBkZevn4pNPfXO6KYln6KtCITwWTcl6i4Gy1aGUZ2RIl7DI/EtkHZvbVj3Na9W0cSQGCAOsx5uh7FrJhx6ldO7slWWkAh+z6OozubpZrIOWaMAEIs5RBVJe6zRnQubOnN57ph3IsmQTb+0lsiICcQEvoeWesofTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141241; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XtsLf+O212+f15Mtk9TRiG0ivfBlg9dYg7XaU5X3V+4=; b=APWgwqshkcxuj9XX1Q7aJBOzt6lgGpboaa6kYvpt88s1AOh1/T8GSS6T2SC8BjeAE3AWzgVEaAWd7bJAQJCoCS0AcoKIGvgAjyRLtN8FRmKXR0qDvcFSmpPPGi8LqPFh8X+I9cnovtSwE5XfsHeYqxOw5rxgYERLSYAKU1ewcoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16061412414901001.7043466946059; Mon, 23 Nov 2020 06:20:41 -0800 (PST) Received: from localhost ([::1]:42464 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khChs-0002zo-Fb for importer@patchew.org; Mon, 23 Nov 2020 09:20:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36508) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcD-0002y8-0d for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcA-0007jr-Al for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:48 -0500 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-477-7ElUTDGWPOqYyhjaZtNE6Q-1; Mon, 23 Nov 2020 09:14:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E4EB3100B714 for ; Mon, 23 Nov 2020 14:14:42 +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 B39395D9E2 for ; Mon, 23 Nov 2020 14:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XtsLf+O212+f15Mtk9TRiG0ivfBlg9dYg7XaU5X3V+4=; b=XAN2DwQNwNziknXCetpgR14F2/0qKoCUrKlzSwZf3eVEbz9sCK6LAj6zr2kRH+vixJ/Nk6 WOyU74EYBGTRUTKcJ3JwzPFf+Olbq+7APHFvHgXyHw60Fh3IyORgvnG71jeEi1+5vVXnXD PKaqtAueiudx4q4GXCUU8QAxRcWpBsI= X-MC-Unique: 7ElUTDGWPOqYyhjaZtNE6Q-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 10/36] qemu-option: restrict qemu_opts_set to merge-lists QemuOpts Date: Mon, 23 Nov 2020 09:14:09 -0500 Message-Id: <20201123141435.2726558-11-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" qemu_opts_set is used to create default network backends and to parse sugar options -kernel, -initrd, -append, -bios and -dtb. These are very different uses: I would *expect* a function named qemu_opts_set to set an option in a merge-lists QemuOptsList, such as -kernel, and possibly to set an option in a non-merge-lists QemuOptsList with non-NULL id, similar to -set. However, it wouldn't *work* to use qemu_opts_set for the latter because qemu_opts_set uses fail_if_exists=3D=3D1. So, for non-merge-lists QemuOptsList and non-NULL id, the semantics of qemu_opts_set (fail if the (QemuOptsList, id) pair already exists) are debatable. On the other hand, I would not expect qemu_opts_set to create a non-merge-lists QemuOpts with a single option; which it does, though. For this case of non-merge-lists QemuOptsList and NULL id, qemu_opts_set hardly adds value over qemu_opts_parse. It does skip some parsing and unescaping, but that's not needed when creating default network backends. So qemu_opts_set has warty behavior for non-merge-lists QemuOptsList if id is non-NULL, and it's mostly pointless if id is NULL. My solution to keeping the API as simple as possible is to limit qemu_opts_set to merge-lists QemuOptsList. For them, it's useful (we don't want comma-unescaping for -kernel) *and* has sane semantics. Network backend creation is switched to qemu_opts_parse. qemu_opts_set is now only used on merge-lists QemuOptsList... except in the testcase, which is changed to use a merge-list QemuOptsList. With this change we can also remove the id parameter. With the parameter always NULL, we know that qemu_opts_create cannot fail and can pass &error_abort to it. Signed-off-by: Paolo Bonzini --- include/qemu/option.h | 3 +-- softmmu/vl.c | 19 +++++++------------ tests/test-qemu-opts.c | 20 +++++++++++++++++--- util/qemu-option.c | 9 +++------ 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/include/qemu/option.h b/include/qemu/option.h index ac69352e0e..f73e0dc7d9 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -119,8 +119,7 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const ch= ar *id, int fail_if_exists, Error **errp); void qemu_opts_reset(QemuOptsList *list); void qemu_opts_loc_restore(QemuOpts *opts); -bool qemu_opts_set(QemuOptsList *list, const char *id, - const char *name, const char *value, Error **errp); +bool qemu_opts_set(QemuOptsList *list, const char *name, const char *value= , Error **errp); const char *qemu_opts_id(QemuOpts *opts); void qemu_opts_set_id(QemuOpts *opts, char *id); void qemu_opts_del(QemuOpts *opts); diff --git a/softmmu/vl.c b/softmmu/vl.c index 1c08505f3a..10b6152e36 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3384,20 +3384,16 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_kernel: - qemu_opts_set(qemu_find_opts("machine"), NULL, "kernel", o= ptarg, - &error_abort); + qemu_opts_set(qemu_find_opts("machine"), "kernel", optarg,= &error_abort); break; case QEMU_OPTION_initrd: - qemu_opts_set(qemu_find_opts("machine"), NULL, "initrd", o= ptarg, - &error_abort); + qemu_opts_set(qemu_find_opts("machine"), "initrd", optarg,= &error_abort); break; case QEMU_OPTION_append: - qemu_opts_set(qemu_find_opts("machine"), NULL, "append", o= ptarg, - &error_abort); + qemu_opts_set(qemu_find_opts("machine"), "append", optarg,= &error_abort); break; case QEMU_OPTION_dtb: - qemu_opts_set(qemu_find_opts("machine"), NULL, "dtb", opta= rg, - &error_abort); + qemu_opts_set(qemu_find_opts("machine"), "dtb", optarg, &e= rror_abort); break; case QEMU_OPTION_cdrom: drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS); @@ -3507,8 +3503,7 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_bios: - qemu_opts_set(qemu_find_opts("machine"), NULL, "firmware",= optarg, - &error_abort); + qemu_opts_set(qemu_find_opts("machine"), "firmware", optar= g, &error_abort); break; case QEMU_OPTION_singlestep: singlestep =3D 1; @@ -4391,9 +4386,9 @@ void qemu_init(int argc, char **argv, char **envp) =20 if (default_net) { QemuOptsList *net =3D qemu_find_opts("net"); - qemu_opts_set(net, NULL, "type", "nic", &error_abort); + qemu_opts_parse(net, "nic", true, &error_abort); #ifdef CONFIG_SLIRP - qemu_opts_set(net, NULL, "type", "user", &error_abort); + qemu_opts_parse(net, "user", true, &error_abort); #endif } =20 diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 297ffe79dd..2aab831d10 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -84,11 +84,25 @@ static QemuOptsList opts_list_03 =3D { }, }; =20 +static QemuOptsList opts_list_04 =3D { + .name =3D "opts_list_04", + .head =3D QTAILQ_HEAD_INITIALIZER(opts_list_04.head), + .merge_lists =3D true, + .desc =3D { + { + .name =3D "str3", + .type =3D QEMU_OPT_STRING, + }, + { /* end of list */ } + }, +}; + static void register_opts(void) { qemu_add_opts(&opts_list_01); qemu_add_opts(&opts_list_02); qemu_add_opts(&opts_list_03); + qemu_add_opts(&opts_list_04); } =20 static void test_find_unknown_opts(void) @@ -402,17 +416,17 @@ static void test_qemu_opts_set(void) QemuOpts *opts; const char *opt; =20 - list =3D qemu_find_opts("opts_list_01"); + list =3D qemu_find_opts("opts_list_04"); g_assert(list !=3D NULL); g_assert(QTAILQ_EMPTY(&list->head)); - g_assert_cmpstr(list->name, =3D=3D, "opts_list_01"); + g_assert_cmpstr(list->name, =3D=3D, "opts_list_04"); =20 /* should not find anything at this point */ opts =3D qemu_opts_find(list, NULL); g_assert(opts =3D=3D NULL); =20 /* implicitly create opts and set str3 value */ - qemu_opts_set(list, NULL, "str3", "value", &error_abort); + qemu_opts_set(list, "str3", "value", &error_abort); g_assert(!QTAILQ_EMPTY(&list->head)); =20 /* get the just created opts */ diff --git a/util/qemu-option.c b/util/qemu-option.c index acefbc23fa..25792159ba 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -670,15 +670,12 @@ void qemu_opts_loc_restore(QemuOpts *opts) loc_restore(&opts->loc); } =20 -bool qemu_opts_set(QemuOptsList *list, const char *id, - const char *name, const char *value, Error **errp) +bool qemu_opts_set(QemuOptsList *list, const char *name, const char *value= , Error **errp) { QemuOpts *opts; =20 - opts =3D qemu_opts_create(list, id, 1, errp); - if (!opts) { - return false; - } + assert(list->merge_lists); + opts =3D qemu_opts_create(list, NULL, 0, &error_abort); return qemu_opt_set(opts, name, value, errp); } =20 --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141425; cv=none; d=zohomail.com; s=zohoarc; b=Q1Y99jI5DjTZtaIYiHfHNEBs6rFuOXgIQzlB0dMJhvfbV3WXwbVZ6XdZaaBeO6xomT/dg4/qn/erwfO8VYC7HWnSGwnOyc+znkkvcbD/BEBIc3btQwSVoq2TkoZoGb/V5rb5OpULUgVhg17Gzatax0HKBMsuAA1woMaXrO4/Cgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141425; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NmX3I71P96GfjBY0QomlHY870xCwJWQCo5SPXB4hhow=; b=ZfcgCBYpCTxhJeadFdieihYOAC4uYZ9AmfwD/SUyoRPVyBu159ZAaV2r9WSDu9IddTzJta51dE2FCQAirRoNSyu6csLwhgbIAsKHCqEnYQ8YbeQE1AbrTLUUxY5SJfgeyscSTsRezQwNDGLIvMes8wq3GLn8jxWhtfGg5lV7iYE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141424912969.9967071244826; Mon, 23 Nov 2020 06:23:44 -0800 (PST) Received: from localhost ([::1]:51094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCkp-0006ds-6C for importer@patchew.org; Mon, 23 Nov 2020 09:23:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcD-0002yz-LP for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20881) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcA-0007jx-TM for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:49 -0500 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-443-0zebXlIKNVGq7nNXV6gSOw-1; Mon, 23 Nov 2020 09:14:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4D5BC18B9ED1 for ; Mon, 23 Nov 2020 14:14:43 +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 0BA355D9E2; Mon, 23 Nov 2020 14:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140886; 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=NmX3I71P96GfjBY0QomlHY870xCwJWQCo5SPXB4hhow=; b=D3y1754tPsdKjJ0Q8Jbbw6d/3n7xP9GMq0WhiwU/5ZLFBKPBo+OciRTECq9uk3/z3mAqG3 +HCUUvGVrwLZpBvjTm7PpuOago5LVugJtTpbfnNWbdBPx2fPXwZDfBNr6sGGiUgH0TTiZ+ j8GVySRWJL0HawyeXpj6+4X5HlzX6Uo= X-MC-Unique: 0zebXlIKNVGq7nNXV6gSOw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 11/36] vl: create "-net nic -net user" default earlier Date: Mon, 23 Nov 2020 09:14:10 -0500 Message-Id: <20201123141435.2726558-12-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Create it together with other default backends, even though the processing = is done later. Reviewed-by: Igor Mammedov 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 10b6152e36..87c10f625c 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4249,6 +4249,14 @@ void qemu_init(int argc, char **argv, char **envp) monitor_parse("vc:80Cx24C", "readline", false); } =20 + if (default_net) { + QemuOptsList *net =3D qemu_find_opts("net"); + qemu_opts_parse(net, "nic", true, &error_abort); +#ifdef CONFIG_SLIRP + qemu_opts_parse(net, "user", true, &error_abort); +#endif + } + #if defined(CONFIG_VNC) if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { display_remote++; @@ -4384,14 +4392,6 @@ void qemu_init(int argc, char **argv, char **envp) semihosting_arg_fallback(kernel_filename, kernel_cmdline); } =20 - if (default_net) { - QemuOptsList *net =3D qemu_find_opts("net"); - qemu_opts_parse(net, "nic", true, &error_abort); -#ifdef CONFIG_SLIRP - qemu_opts_parse(net, "user", true, &error_abort); -#endif - } - if (net_init_clients(&err) < 0) { error_report_err(err); exit(1); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141546; cv=none; d=zohomail.com; s=zohoarc; b=Rp74jOmpZ23ufYVX7KX/DMy4QtKzaa1tyiG3LmibUN3Lmig3bZV01g2YW57Wcl6TGHAbBIQ4l+GghYNv0cD52NPayhZDnUj9zm12RtZUa6rTOUnwK39b1qactcYiNuJAtDWbfyF0VRuOk1vb80d+87D7Sw/m8IVdcHRsvYoiW0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141546; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f+4b/gxmOxkePzojbW9XT0AhSQo5i8jpL0dQ4zDtFFQ=; b=HnKahXGorW2JvIGbnu00Jn06sBC0uZoGL8T77uOXZ3Qfpplq1H/5NqwQfJsgDDOKUVFsZnvAdIAogu7SKeeTHk+lxvf4c4HbjYlyMyiJNuKyQEVjVIUPtK3kQr4k1BLlPXkg0NkSy1JKAWejlHrd0io8Z7g0fV9KphvLzjCynoM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141546280254.35608360448384; Mon, 23 Nov 2020 06:25:46 -0800 (PST) Received: from localhost ([::1]:59358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCmn-0001da-AN for importer@patchew.org; Mon, 23 Nov 2020 09:25:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcE-0002zl-OZ for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21109) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcB-0007jz-3L for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 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-445-ipO9VHy-MCKywd0f1iGvRg-1; Mon, 23 Nov 2020 09:14:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A83B018B9ED7 for ; Mon, 23 Nov 2020 14:14:43 +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 681C15D9E2; Mon, 23 Nov 2020 14:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140886; 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=f+4b/gxmOxkePzojbW9XT0AhSQo5i8jpL0dQ4zDtFFQ=; b=IpNLCn/XBifbJqzj/aQQMRIlHgsiu6wvZ1aqSxOIpaK76uy13wN3nuoR29BCGwe9rqBWST 2SzeyXqb2bh0ZcoE581ceiTQawcDvyRVqa60lifgeEbeGH/XuU+BaY19ehbu/rE0cAm3H+ stTanA4hkI2BTrBHNjz5N+Jh2hVN/fM= X-MC-Unique: ipO9VHy-MCKywd0f1iGvRg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 12/36] vl: load plugins as late as possible Date: Mon, 23 Nov 2020 09:14:11 -0500 Message-Id: <20201123141435.2726558-13-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) There is no need to load plugins in the middle of default device processing, move -plugin handling just before preconfig is entered. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- softmmu/vl.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 87c10f625c..ab08a0290c 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 =3D QTAILQ_HEAD_INITIALIZER(plugin_list); enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; static int mem_prealloc; /* force preallocation of physical target memory = */ int display_opengl; @@ -3074,6 +3075,11 @@ static void qemu_init_board(void) create_default_memdev(current_machine, mem_path); } =20 + /* process plugin before CPUs are created, but once -smp has been pars= ed */ + if (qemu_plugin_load_list(&plugin_list)) { + exit(1); + } + machine_run_board_init(current_machine); =20 /* @@ -3208,7 +3214,6 @@ void qemu_init(int argc, char **argv, char **envp) Error *err =3D NULL; bool have_custom_ram_size; BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); - QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); =20 qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4178,11 +4183,6 @@ void qemu_init(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } =20 - /* process plugin before CPUs are created, but once -smp has been pars= ed */ - 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"), --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141244; cv=none; d=zohomail.com; s=zohoarc; b=VxbhIRKj+w58818/iR7URDm6G05tmJEH0AkYnWXbdqXhJfFpgc98hAqpHOnIu1IsuXtQXqJByGee3ZQhMAF92zsRC2sn0mT2/c9DdrJaW/fap3m6L7GlZ1mZmlsIJR+WLLO8p1FupU5kdYdx9cWPNO1dy2FdwACxhi28VxP4S90= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141244; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1822Dy6qpSjZ0qF5GiK5kkEA0HHfKjbG66Y8OMKKfx8=; b=QV0xuvLA7VDpBqF99ACp5x1it7NwqQ0xNLiQKRrtb39mtLIb/TH+zBvUR64AU5dzt4xhlWkMLsszu9AUOPZd6QJOO4wx6N0yw9qN+GjNY0OyqcSfWhVXLiAgBorkAsmrtzMEXmmpzdbJctKf2O54b/zXC5iiyID5L2ZfiTQn34s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141244357501.1560734720297; Mon, 23 Nov 2020 06:20:44 -0800 (PST) Received: from localhost ([::1]:42676 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khChu-00035n-MU for importer@patchew.org; Mon, 23 Nov 2020 09:20:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcE-0002zG-Ck for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60544) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcB-0007kA-Qr for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 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-480-HW6UmVFcMdKQRVnwEdvuUw-1; Mon, 23 Nov 2020 09:14:44 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F412281CBE9 for ; Mon, 23 Nov 2020 14:14:43 +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 C2B415D9E2 for ; Mon, 23 Nov 2020 14:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1822Dy6qpSjZ0qF5GiK5kkEA0HHfKjbG66Y8OMKKfx8=; b=YGJj+KA1tSMHNvAHUUI9aqmkp77BMvhCL1ZSIvFPTyFQ7vukL+ReSVmzC6H6POKJvFfh1t QslSB2t7Hzeruc07ENuf4JA6dKhXGMeVX07+hLrvGUhH01rcv3LwrS4JvjOWE/gFo4xbQh N5iHTt41f0yDRPPrLu5zwlXLal5GZjE= X-MC-Unique: HW6UmVFcMdKQRVnwEdvuUw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 13/36] vl: move semihosting command line fallback to qemu_init_board Date: Mon, 23 Nov 2020 09:14:12 -0500 Message-Id: <20201123141435.2726558-14-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 ab08a0290c..5d68cf828c 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3070,6 +3070,11 @@ static void qemu_init_board(void) { MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); =20 + if (semihosting_enabled() && !semihosting_get_argc() && current_machin= e->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); @@ -4385,13 +4390,6 @@ void qemu_init(int argc, char **argv, char **envp) boot_order =3D machine_class->default_boot_order; } =20 - if (semihosting_enabled() && !semihosting_get_argc()) { - const char *kernel_filename =3D qemu_opt_get(machine_opts, "kernel= "); - const char *kernel_cmdline =3D 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); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141682; cv=none; d=zohomail.com; s=zohoarc; b=n7XLWzOWLWvsxw4gg0G3uo/tGL5+LgYkQ21adQfgohrJZMJkf2o7Q94VSIBqYqvXYY0bDQrBoW+6UOYp0IFDGMYS2PaF588caRxko+b4z1oq8kN9WRLdEalvTVvcxRdSkcv5YvvXckzAkPpTCLqzU+Q68KH6HZaTAki1/izOA/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141682; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qWMtToJZInFF6ipVkFH5WwwrpOT6b9FW6ITdG46LDts=; b=NOhjXG4e4aG4iwgJWTYheH3Fnt/JcsOFGWj/Hxl/hjwwoblQbH138v5iuoKE9wMhqhHz3WFsxQNpppiKjmw2MGWGGO0vY2t7icZVTvEx2l1YesVhAam0savQ2xZIR1Md6hvvcQPvPSZVLYzPbokkD4G0+//vydaWnzJqeX1kJ/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16061416826251009.3164037462184; Mon, 23 Nov 2020 06:28:02 -0800 (PST) Received: from localhost ([::1]:39640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCoz-0005E9-3X for importer@patchew.org; Mon, 23 Nov 2020 09:28:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36532) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcD-0002z7-Vi for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcB-0007kB-K0 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:49 -0500 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-328-HmPSH24KOYKL8qqrBcwPQw-1; Mon, 23 Nov 2020 09:14:45 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C26D805BE6 for ; Mon, 23 Nov 2020 14:14:44 +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 1A2885D9E8 for ; Mon, 23 Nov 2020 14:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140886; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qWMtToJZInFF6ipVkFH5WwwrpOT6b9FW6ITdG46LDts=; b=bU0A0hncWrNXKrM5ef39qYMyqw8PtqSz1L7+6ti+7BiVwxEd74gzUjr2FZui4zqPjcW6JY 2ZQOwm5irz+rD9DaMCcJTVDeumOLhSAw+bflxg8wtECPzaR5dGgFHTxGw9q5FK9jNkFJNB KBD1jr13iWyMWPc+GBo7iFMN8my6Nog= X-MC-Unique: HmPSH24KOYKL8qqrBcwPQw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 14/36] vl: extract default devices to separate functions Date: Mon, 23 Nov 2020 09:14:13 -0500 Message-Id: <20201123141435.2726558-15-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- softmmu/vl.c | 216 +++++++++++++++++++++++++++------------------------ 1 file changed, 114 insertions(+), 102 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 5d68cf828c..b6c62e1e4f 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 =3D QTAILQ_HEAD_INITIALIZER(plugin_list); +static bool nographic =3D false; enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; static int mem_prealloc; /* force preallocation of physical target memory = */ int display_opengl; @@ -147,6 +149,7 @@ static int rtc_host_datetime_offset =3D -1; /* valid & = used only with RTC_BASE_DATETIME */ QEMUClockType rtc_clock; int vga_interface_type =3D VGA_NONE; +static const char *vga_model =3D 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 (*fu= nc)(const char *cmdline)) return 0; } =20 +static void qemu_disable_default_devices(void) +{ + MachineClass *machine_class =3D 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 =3D VGA_DEVICE; + } + if (!has_defaults || machine_class->no_serial) { + default_serial =3D 0; + } + if (!has_defaults || machine_class->no_parallel) { + default_parallel =3D 0; + } + if (!has_defaults || machine_class->no_floppy) { + default_floppy =3D 0; + } + if (!has_defaults || machine_class->no_cdrom) { + default_cdrom =3D 0; + } + if (!has_defaults || machine_class->no_sdcard) { + default_sdcard =3D 0; + } + if (!has_defaults) { + default_monitor =3D 0; + default_net =3D 0; + default_vga =3D 0; + } +} + +static void qemu_create_default_devices(void) +{ + MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); + + if (is_daemonized()) { + /* According to documentation and historically, -nographic redirec= ts + * serial port, parallel port and monitor to stdio, which does not= work + * with -daemonize. We can redirect these to null instead, but si= nce + * -nographic is legacy, let's just error out. + * We disallow -nographic only if all other ports are not redirect= ed + * 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 =3D qemu_find_opts("net"); + qemu_opts_parse(net, "nic", true, &error_abort); +#ifdef CONFIG_SLIRP + qemu_opts_parse(net, "user", true, &error_abort); +#endif + } + +#if defined(CONFIG_VNC) + if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { + display_remote++; + } +#endif + if (dpy.type =3D=3D DISPLAY_TYPE_DEFAULT && !display_remote) { + if (!qemu_display_find_default(&dpy)) { + dpy.type =3D DISPLAY_TYPE_NONE; +#if defined(CONFIG_VNC) + vnc_parse("localhost:0,to=3D99,id=3Ddefault", &error_abort); +#endif + } + } + if (dpy.type =3D=3D DISPLAY_TYPE_DEFAULT) { + dpy.type =3D DISPLAY_TYPE_NONE; + } + + /* If no default VGA is requested, the default is "none". */ + if (default_vga) { + vga_model =3D get_default_vga_model(machine_class); + } + if (vga_model) { + select_vgahw(machine_class, vga_model); + } +} + static int serial_parse(const char *devname) { int index =3D num_serial_hds; @@ -3209,10 +3321,7 @@ void qemu_init(int argc, char **argv, char **envp) int optind; const char *optarg; MachineClass *machine_class; - const char *vga_model =3D NULL; bool userconfig =3D true; - bool nographic =3D false; - int display_remote =3D 0; ram_addr_t maxram_size; uint64_t ram_slots =3D 0; FILE *vmstate_dump_file =3D NULL; @@ -4188,97 +4297,8 @@ void qemu_init(int argc, char **argv, char **envp) machine_class->default_machine_opts, 0); } =20 - 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 =3D VGA_DEVICE; - } - if (!has_defaults || machine_class->no_serial) { - default_serial =3D 0; - } - if (!has_defaults || machine_class->no_parallel) { - default_parallel =3D 0; - } - if (!has_defaults || machine_class->no_floppy) { - default_floppy =3D 0; - } - if (!has_defaults || machine_class->no_cdrom) { - default_cdrom =3D 0; - } - if (!has_defaults || machine_class->no_sdcard) { - default_sdcard =3D 0; - } - if (!has_defaults) { - default_monitor =3D 0; - default_net =3D 0; - default_vga =3D 0; - } - - if (is_daemonized()) { - /* According to documentation and historically, -nographic redirec= ts - * serial port, parallel port and monitor to stdio, which does not= work - * with -daemonize. We can redirect these to null instead, but si= nce - * -nographic is legacy, let's just error out. - * We disallow -nographic only if all other ports are not redirect= ed - * 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 =3D qemu_find_opts("net"); - qemu_opts_parse(net, "nic", true, &error_abort); -#ifdef CONFIG_SLIRP - qemu_opts_parse(net, "user", true, &error_abort); -#endif - } - -#if defined(CONFIG_VNC) - if (!QTAILQ_EMPTY(&(qemu_find_opts("vnc")->head))) { - display_remote++; - } -#endif - if (dpy.type =3D=3D DISPLAY_TYPE_DEFAULT && !display_remote) { - if (!qemu_display_find_default(&dpy)) { - dpy.type =3D DISPLAY_TYPE_NONE; -#if defined(CONFIG_VNC) - vnc_parse("localhost:0,to=3D99,id=3Ddefault", &error_abort); -#endif - } - } - if (dpy.type =3D=3D DISPLAY_TYPE_DEFAULT) { - dpy.type =3D DISPLAY_TYPE_NONE; - } - + qemu_disable_default_devices(); + qemu_create_default_devices(); if ((alt_grab || ctrl_grab) && dpy.type !=3D DISPLAY_TYPE_SDL) { error_report("-alt-grab and -ctrl-grab are only valid " "for SDL, ignoring option"); @@ -4417,14 +4437,6 @@ void qemu_init(int argc, char **argv, char **envp) qemu_semihosting_connect_chardevs(); qemu_semihosting_console_init(); =20 - /* If no default VGA is requested, the default is "none". */ - if (default_vga) { - vga_model =3D 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. */ --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141838; cv=none; d=zohomail.com; s=zohoarc; b=b+VgHTLJ1hy6vY6jKP5ESGNAWkBDvuNZPXF3TjUhAC9NPSNjqkPRN/s6eJOjrF6MpcqOwPt6s+HWSxizjqRTQcDws3Z9BbRRLs86e0qNluskwYVHoYHuNiYwNOMjXTSInsSfoG/6cZXPH5kNyU7h8F6qAgvChzIY8tMapniDyWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141838; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wgCzhc2Hpg0p6QXTCSufcMxAwLK2IBX/853ecUDZTe4=; b=ZBDZQYJV0tAWtpgqLrSt3TJRsqoFIdgoM3YvxA97SnV/EapwQ/k4qcXHqwS0ROOEl3l3HJm01JX5JeYfmRhVp6mkn3Cis1ZTecAELJSQMZwo6DIdhXFAhRWCT/AYWQxGOuR6lvXXZrPRaD+76b1ki/xUbyJ+ftOImnumGSDxLP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160614183834142.97227374846352; Mon, 23 Nov 2020 06:30:38 -0800 (PST) Received: from localhost ([::1]:47940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCrT-0000Cr-D0 for importer@patchew.org; Mon, 23 Nov 2020 09:30:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcL-00034c-U2 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcG-0007n5-BO for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:57 -0500 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-524-0KAVjmp2PcOoq0A9pkNPnA-1; Mon, 23 Nov 2020 09:14:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B575381CBF5 for ; Mon, 23 Nov 2020 14:14:47 +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 654DD5D9E2; Mon, 23 Nov 2020 14:14:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140891; 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=wgCzhc2Hpg0p6QXTCSufcMxAwLK2IBX/853ecUDZTe4=; b=QDyur1g5l+705DDfToHnT1o3RPtGEUxoKxXRgafpJKU8zus9W3HLp/ASDxj9HEx27e1ArS Yow4WPQbL2mbFnkZDfWA1MLYE5s7lmuFNaRzP8VhufAUCNqDZyJxnBbAwo/GicOet6GGJI qRhueTKnTPKxDEqcw1UE0aebd6qf2LA= X-MC-Unique: 0KAVjmp2PcOoq0A9pkNPnA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 15/36] vl: move CHECKPOINT_INIT after preconfig Date: Mon, 23 Nov 2020 09:14:14 -0500 Message-Id: <20201123141435.2726558-16-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Move CHECKPOINT_INIT right before the machine initialization is completed. Everything before is essentially an extension of command line parsing. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- hw/core/machine.c | 5 +++++ softmmu/vl.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 7ef3de5ce5..a5cfbcc7cb 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1107,6 +1107,11 @@ void machine_run_board_init(MachineState *machine) ObjectClass *oc =3D object_class_by_name(machine->cpu_type); CPUClass *cc; =20 + /* 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); + if (machine->ram_memdev_id) { Object *o; o =3D object_resolve_path_type(machine->ram_memdev_id, diff --git a/softmmu/vl.c b/softmmu/vl.c index b6c62e1e4f..dc0cdc3417 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -4437,11 +4437,6 @@ void qemu_init(int argc, char **argv, char **envp) qemu_semihosting_connect_chardevs(); qemu_semihosting_console_init(); =20 - /* 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 =3D boot_order; =20 /* parse features once if machine provides default cpu_type */ --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141680; cv=none; d=zohomail.com; s=zohoarc; b=hDvS7N0CuNn3OkF017bVcS9f1JtSavrwf3QUglqGNWXcKXejwprjrvwN0xqZYJ7rfmw6nKH6Ez08pxoLjuK7zOezuGWHkLRW6KlE/99hOAEInOMoRPdAaZigrZJKD2JbKNNnicIWcqCP+4h2+z/EwlKTHnZWKaGnZx6c5uHpJb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141680; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eBRPegfxRDUN+YxiiiIzCseZErrn9Vc4ABjB31Iu6Ks=; b=VQGsPgJ3hw+inVWn0FknL3PqX6p32W358z5d/aFJWXP8kYdHLQBMf4aN0fLHd+Vq2dyUDbVL6CB8dNUXQUqk9jhEY7kCZsEcJhzVuHSgG7362tIfTkW+U8SPzvXwxOVQ4qvZL6oZasZeycfnQYynJx+m1ByW1quIVT/CjC5XFHo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141680796751.8841891979251; Mon, 23 Nov 2020 06:28:00 -0800 (PST) Received: from localhost ([::1]:39518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCox-0005Ax-GY for importer@patchew.org; Mon, 23 Nov 2020 09:27:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcN-000350-0q for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:59 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41324) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcI-0007nw-JH for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:58 -0500 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-351-cUzHmYDKNrCX1OS672ODig-1; Mon, 23 Nov 2020 09:14:50 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1B9D0100C60B for ; Mon, 23 Nov 2020 14:14:48 +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 CFBEA5D9E2; Mon, 23 Nov 2020 14:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140893; 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=eBRPegfxRDUN+YxiiiIzCseZErrn9Vc4ABjB31Iu6Ks=; b=aVec8/rAch74t7E7Ya3fo0PSjhWGD/LCCMwjSC9JFY62S3Mn5ZP1tVLYcIDZ+8JMVlxiaI YSnRKhBsWXpsX5v6dOzY1/OYe1TOcQDLf4/7ueRocRA7uUn4kmTff4ZhMyAjMblzkgMvB9 eBEhphEJEItt7BHpxxMRb72AAfKJ8Nw= X-MC-Unique: cUzHmYDKNrCX1OS672ODig-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 16/36] vl: separate qemu_create_early_backends Date: Mon, 23 Nov 2020 09:14:15 -0500 Message-Id: <20201123141435.2726558-17-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" "Early" backends are created before the machine and can be used as machine options. Reviewed-by: Igor Mammedov 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 dc0cdc3417..0a61df55b8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -117,6 +117,14 @@ =20 #define MAX_VIRTIO_CONSOLES 1 =20 +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 =3D QTAILQ_HEAD_INITIALIZER(plugin_list); +static BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_qu= eue); static bool nographic =3D false; enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; static int mem_prealloc; /* force preallocation of physical target memory = */ @@ -1043,14 +1053,6 @@ static void default_drive(int enable, int snapshot, = BlockInterfaceType type, =20 } =20 -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); @@ -2696,6 +2698,58 @@ static bool object_create_initial(const char *type, = QemuOpts *opts) return true; } =20 +static void qemu_create_early_backends(void) +{ + MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); + + if ((alt_grab || ctrl_grab) && dpy.type !=3D DISPLAY_TYPE_SDL) { + error_report("-alt-grab and -ctrl-grab are only valid " + "for SDL, ignoring option"); + } + if (dpy.has_window_close && + (dpy.type !=3D DISPLAY_TYPE_GTK && dpy.type !=3D 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 !=3D DISPLAYGL_MODE_OFF && display_opengl =3D= =3D 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 auiode= v */ + /* 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(); +} + =20 /* * The remainder of object creation happens after the @@ -2703,7 +2757,7 @@ static bool object_create_initial(const char *type, Q= emuOpts *opts) */ static bool object_create_delayed(const char *type, QemuOpts *opts) { - return !object_create_initial(type, opts); + return !object_create_early(type, opts); } =20 =20 @@ -3314,7 +3368,6 @@ static void qemu_machine_creation_done(void) =20 void qemu_init(int argc, char **argv, char **envp) { - int snapshot =3D 0; QemuOpts *opts, *machine_opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; QemuOptsList *olist; @@ -3327,7 +3380,6 @@ void qemu_init(int argc, char **argv, char **envp) FILE *vmstate_dump_file =3D NULL; Error *err =3D NULL; bool have_custom_ram_size; - BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_queue= ); =20 qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4299,52 +4351,7 @@ void qemu_init(int argc, char **argv, char **envp) =20 qemu_disable_default_devices(); qemu_create_default_devices(); - if ((alt_grab || ctrl_grab) && dpy.type !=3D DISPLAY_TYPE_SDL) { - error_report("-alt-grab and -ctrl-grab are only valid " - "for SDL, ignoring option"); - } - if (dpy.has_window_close && - (dpy.type !=3D DISPLAY_TYPE_GTK && dpy.type !=3D 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 !=3D DISPLAYGL_MODE_OFF && display_opengl =3D= =3D 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 auiode= v */ - /* 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(); =20 machine_opts =3D qemu_get_machine_opts(); qemu_opt_foreach(machine_opts, machine_set_property, current_machine, --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141427; cv=none; d=zohomail.com; s=zohoarc; b=AWJE61EP5cv0W6/kjFqSgKFy2EIUElkop+dt8NLVSeBoj8fLv2gkiEgABEt1O83yldwxv094+S0CPczgcGkvxDWrn7EZtuxWUX48HM+5fa3F7fyes81oZUr+J1w4X3NiQJdjPj7qvmwR19f+87TTftSM6RkCGgZhAoNyOLeI3co= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141427; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YkhOTqnc6rSFYqPS+LH9lYeYVI5mFH1qJRbS/5hzVE0=; b=TXtISG55sZ5MLHftT1xzUa5yh6D2oG8Ojq8yVMyFiB2tEUE+gK53Ohudf24no0IfeQMkt3GHihs/DlBv0a4cPFQUqLI35nqVy/1YEGy9p6rHoAI4PBkgKMmPst+nx/RQO/H0zXA98EjJ0sZk/3aoPvTc3heWSGgCjjdKJiMGr+Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141427385650.2114930806159; Mon, 23 Nov 2020 06:23:47 -0800 (PST) Received: from localhost ([::1]:51032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCks-0006c4-Fe for importer@patchew.org; Mon, 23 Nov 2020 09:23:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcK-00034C-6v for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49256) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcH-0007np-Q6 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:55 -0500 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-588-7C7yMod7NxqdXUr6xHhjjg-1; Mon, 23 Nov 2020 09:14:51 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77017804011 for ; Mon, 23 Nov 2020 14:14:48 +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 3659B5D9E2; Mon, 23 Nov 2020 14:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140893; 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=YkhOTqnc6rSFYqPS+LH9lYeYVI5mFH1qJRbS/5hzVE0=; b=hRM8jYqMK8KfWtS2bqeXhubYC1FwudOinXN7ueiEo9k8vbIwA2T2dZx+hq5YMouOvucCBJ vcALee27zPJSLAWOOlYj4OBLOU+fgM7fOrPD8dFTbb61Mc3XI6rj9qHIUPmhg4mQJd52rj yoQnHEsxdgGDKDjYT6Bo7V5UHsLfWtE= X-MC-Unique: 7C7yMod7NxqdXUr6xHhjjg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 17/36] vl: separate qemu_create_late_backends Date: Mon, 23 Nov 2020 09:14:16 -0500 Message-Id: <20201123141435.2726558-18-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" "Late" backends are created after the machine. Reviewed-by: Igor Mammedov 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 0a61df55b8..b2ec2ba8ef 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2755,11 +2755,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); } =20 +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); + + 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); + + /* now chardevs have been created we may have semihosting to connect */ + qemu_semihosting_connect_chardevs(); + qemu_semihosting_console_init(); +} =20 static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_siz= e, MachineClass *mc) @@ -3378,7 +3408,6 @@ void qemu_init(int argc, char **argv, char **envp) ram_addr_t maxram_size; uint64_t ram_slots =3D 0; FILE *vmstate_dump_file =3D NULL; - Error *err =3D NULL; bool have_custom_ram_size; =20 qemu_add_opts(&qemu_drive_opts); @@ -4393,10 +4422,6 @@ void qemu_init(int argc, char **argv, char **envp) */ migration_object_init(); =20 - if (qtest_chrdev) { - qtest_server_init(qtest_chrdev, qtest_log, &error_fatal); - } - opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); if (opts) { boot_order =3D qemu_opt_get(opts, "order"); @@ -4417,32 +4442,7 @@ void qemu_init(int argc, char **argv, char **envp) boot_order =3D machine_class->default_boot_order; } =20 - 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); - - 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); - - /* now chardevs have been created we may have semihosting to connect */ - qemu_semihosting_connect_chardevs(); - qemu_semihosting_console_init(); + qemu_create_late_backends(); =20 current_machine->boot_order =3D boot_order; =20 --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142018; cv=none; d=zohomail.com; s=zohoarc; b=b0mKftbD+Ph7tYAHDUj7BAzFEU0VbCki3SVrlsgkIvvOtUP8FXiDCgitdU7MCdu2zfRzAXY8CCvSyZ2XcrZnK9GLm05OP6M4YqFbDCKD/E/1lD9la+HIf+wjBlkDlYoZOJ+hevzySyK6UVvcjYyc2y09mv9NuW2D82yoQCLzKX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142018; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hr6BmOBAm9O1Te2By5R2isNkfpoVmWjVU8V2jeM9N3c=; b=X2aU7SPYkPFV7RZ7pcYro2MSxP6mvwpQSl7ZBS8KOyYSJFA8hZEaCNdlll6do63B2g4U/HxUPOIFky1AD3c/plxQcpNSOFeLspfpaxj2G5S6AV90yFlZHeCHn9UjdVjTOIbMK6dSJHu32Asg2CkEQGaKl4uXYfmzLtRuFWFINwY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142018848201.70344197902398; Mon, 23 Nov 2020 06:33:38 -0800 (PST) Received: from localhost ([::1]:56322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCuO-0003pl-0O for importer@patchew.org; Mon, 23 Nov 2020 09:33:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcP-000392-3E for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:54741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcJ-0007o7-PG for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:00 -0500 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-98-UPLrS6BTMRWY_6ac3ZcytQ-1; Mon, 23 Nov 2020 09:14:52 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D26DD100C60A for ; Mon, 23 Nov 2020 14:14:48 +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 9175B5D9E2; Mon, 23 Nov 2020 14:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140895; 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=hr6BmOBAm9O1Te2By5R2isNkfpoVmWjVU8V2jeM9N3c=; b=EQTBBVrLxuf9E8oTUx7m9rsMIEyp54kIxk5xNubuQJi57jz+JwsLFMFelFxAG0h7H5x3HP Oz0QShyxU1e/uj4uLvwgtWbfg8KoDgfVs3DbujdBzYuFGndcNsYTFA45FFI7AI61QoSF0m thcQHmUd0rOmCR1tiLVtUtznxT5G0fM= X-MC-Unique: UPLrS6BTMRWY_6ac3ZcytQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 18/36] vl: separate qemu_create_machine Date: Mon, 23 Nov 2020 09:14:17 -0500 Message-Id: <20201123141435.2726558-19-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 113 +++++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 53 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index b2ec2ba8ef..c1eaa1e448 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -133,6 +133,8 @@ static const char *boot_order; static const char *boot_once; static const char *incoming; static const char *loadvm; +static ram_addr_t maxram_size; +static uint64_t ram_slots; static int display_remote; static int snapshot; static QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); @@ -2791,8 +2793,13 @@ static void qemu_create_late_backends(void) qemu_semihosting_console_init(); } =20 -static bool set_memory_options(uint64_t *ram_slots, ram_addr_t *maxram_siz= e, - MachineClass *mc) +static bool have_custom_ram_size(void) +{ + QemuOpts *opts =3D qemu_find_opts_singleton("memory"); + return !!qemu_opt_get_size(opts, "size", 0); +} + +static void set_memory_options(MachineClass *mc) { uint64_t sz; const char *mem_str; @@ -2842,7 +2849,7 @@ static bool set_memory_options(uint64_t *ram_slots, r= am_addr_t *maxram_size, =20 /* store value for the future use */ qemu_opt_set_number(opts, "size", ram_size, &error_abort); - *maxram_size =3D ram_size; + maxram_size =3D ram_size; =20 if (qemu_opt_get(opts, "maxmem")) { uint64_t slots; @@ -2863,15 +2870,59 @@ static bool set_memory_options(uint64_t *ram_slots,= ram_addr_t *maxram_size, exit(EXIT_FAILURE); } =20 - *maxram_size =3D sz; - *ram_slots =3D slots; + maxram_size =3D sz; + ram_slots =3D slots; } else if (qemu_opt_get(opts, "slots")) { error_report("invalid -m option value: missing 'maxmem' option"); exit(EXIT_FAILURE); } =20 loc_pop(&loc); - return !!mem_str; +} + +static void qemu_create_machine(MachineClass *machine_class) +{ + object_set_machine_compat_props(machine_class->compat_props); + + set_memory_options(machine_class); + + current_machine =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); + if (machine_help_func(qemu_get_machine_opts(), current_machine)) { + exit(0); + } + object_property_add_child(object_get_root(), "machine", + OBJECT(current_machine)); + object_property_add_child(container_get(OBJECT(current_machine), + "/unattached"), + "sysbus", OBJECT(sysbus_get_default())); + + if (machine_class->minimum_page_bits) { + if (!set_preferred_target_page_bits(machine_class->minimum_page_bi= ts)) { + /* This would be a board error: specifying a minimum smaller t= han + * a target's compile-time fixed setting. + */ + g_assert_not_reached(); + } + } + + cpu_exec_init_all(); + page_size_init(); + + if (machine_class->hw_version) { + qemu_set_hw_version(machine_class->hw_version); + } + + machine_smp_parse(current_machine, + qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal); + + /* + * Get the default machine options from the machine if it is not alrea= dy + * specified either by the configuration file or by the command line. + */ + if (machine_class->default_machine_opts) { + qemu_opts_set_defaults(qemu_find_opts("machine"), + machine_class->default_machine_opts, 0); + } } =20 static int global_init_func(void *opaque, QemuOpts *opts, Error **errp) @@ -3405,10 +3456,7 @@ void qemu_init(int argc, char **argv, char **envp) const char *optarg; MachineClass *machine_class; bool userconfig =3D true; - ram_addr_t maxram_size; - uint64_t ram_slots =3D 0; FILE *vmstate_dump_file =3D NULL; - bool have_custom_ram_size; =20 qemu_add_opts(&qemu_drive_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); @@ -4334,49 +4382,7 @@ void qemu_init(int argc, char **argv, char **envp) =20 configure_rtc(qemu_find_opts_singleton("rtc")); =20 - machine_class =3D select_machine(); - object_set_machine_compat_props(machine_class->compat_props); - - have_custom_ram_size =3D set_memory_options(&ram_slots, &maxram_size, - machine_class); - - current_machine =3D MACHINE(object_new_with_class(OBJECT_CLASS(machine= _class))); - if (machine_help_func(qemu_get_machine_opts(), current_machine)) { - exit(0); - } - object_property_add_child(object_get_root(), "machine", - OBJECT(current_machine)); - object_property_add_child(container_get(OBJECT(current_machine), - "/unattached"), - "sysbus", OBJECT(sysbus_get_default())); - - if (machine_class->minimum_page_bits) { - if (!set_preferred_target_page_bits(machine_class->minimum_page_bi= ts)) { - /* This would be a board error: specifying a minimum smaller t= han - * a target's compile-time fixed setting. - */ - g_assert_not_reached(); - } - } - - cpu_exec_init_all(); - page_size_init(); - - if (machine_class->hw_version) { - qemu_set_hw_version(machine_class->hw_version); - } - - machine_smp_parse(current_machine, - qemu_opts_find(qemu_find_opts("smp-opts"), NULL), &error_fatal); - - /* - * Get the default machine options from the machine if it is not alrea= dy - * specified either by the configuration file or by the command line. - */ - if (machine_class->default_machine_opts) { - qemu_opts_set_defaults(qemu_find_opts("machine"), - machine_class->default_machine_opts, 0); - } + qemu_create_machine(select_machine()); =20 qemu_disable_default_devices(); qemu_create_default_devices(); @@ -4411,6 +4417,7 @@ void qemu_init(int argc, char **argv, char **envp) * called from configure_accelerator(). */ =20 + machine_class =3D MACHINE_GET_CLASS(current_machine); if (!qtest_enabled() && machine_class->deprecation_reason) { error_report("Machine type '%s' is deprecated: %s", machine_class->name, machine_class->deprecation_reaso= n); @@ -4464,7 +4471,7 @@ void qemu_init(int argc, char **argv, char **envp) exit(EXIT_FAILURE); } backend_size =3D object_property_get_uint(backend, "size", &error= _abort); - if (have_custom_ram_size && backend_size !=3D ram_size) { + if (have_custom_ram_size() && backend_size !=3D ram_size) { error_report("Size specified by -m option must match size = of " "explicitly specified 'memory-backend' proper= ty"); exit(EXIT_FAILURE); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141834; cv=none; d=zohomail.com; s=zohoarc; b=XptQcvsew7pwdhuONrAt4xA7UHKgGcSRjxIbpdsWDPE6qWE1zxjyv0FUkdf+HaWLMXuCrTeZ+H3rQEGUf0DeIx+4aHbE5xth0RHsTK2aUh7fJtswPXGz+s8x36xG1KhKEnKsQ4dL+cXP3GYSepxn0Eqy7VPBWaGg0Kg4Uc8kxt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141834; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ID0gflGBF/uP5jTHeN8FXmAh3AIV6OM/kll/R1mgKBc=; b=MRf/6mzsQQge2oVrdK/6SReF5LTUDt+vp3P6u+yOhsJHCdNV4H5yRQsXWStpPYqMM8D97jTfOvnhEdM4TEP+krrQpHxdpWOucp3kWlrR9dfdeK7nMGKInAvERDP/VJLu/u+0Q28F0yphTGPmfbvif1lvRp8SMe3+NUfmBkmmv0k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141834952973.4601938252134; Mon, 23 Nov 2020 06:30:34 -0800 (PST) Received: from localhost ([::1]:47708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCrQ-00006a-CL for importer@patchew.org; Mon, 23 Nov 2020 09:30:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcO-000379-D4 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:45177) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcK-0007oV-6y for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:00 -0500 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-paF8OiEnNDqXAW32zB9yzQ-1; Mon, 23 Nov 2020 09:14:53 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5067F839A48 for ; Mon, 23 Nov 2020 14:14:52 +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 EC2AA5D9E3; Mon, 23 Nov 2020 14:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140895; 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=ID0gflGBF/uP5jTHeN8FXmAh3AIV6OM/kll/R1mgKBc=; b=eu3SJEzurk6nUjWahb6/uF430+JEFIWmD69DZlV1nCCvVr9jn/FZUNvJNWd0kxw9dIyGmd Eow4YnZzj+uinnTvEDt2C9NgEpjKVfnKHBS/iIDNyK9dv8GrObA8sLX+4h53/3LVz09R0I KX0vdGWsnG2vua5JKCcYOewv3K9lwyY= X-MC-Unique: paF8OiEnNDqXAW32zB9yzQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 19/36] vl: separate qemu_apply_machine_options Date: Mon, 23 Nov 2020 09:14:18 -0500 Message-Id: <20201123141435.2726558-20-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 66 +++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index c1eaa1e448..741a800114 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2700,6 +2700,41 @@ static bool object_create_early(const char *type, Qe= muOpts *opts) return true; } =20 +static void qemu_apply_machine_options(void) +{ + MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); + QemuOpts *machine_opts =3D qemu_get_machine_opts(); + QemuOpts *opts; + + qemu_opt_foreach(machine_opts, machine_set_property, current_machine, + &error_fatal); + current_machine->ram_size =3D ram_size; + current_machine->maxram_size =3D maxram_size; + current_machine->ram_slots =3D ram_slots; + + opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); + if (opts) { + boot_order =3D qemu_opt_get(opts, "order"); + if (boot_order) { + validate_bootdevices(boot_order, &error_fatal); + } + + boot_once =3D qemu_opt_get(opts, "once"); + if (boot_once) { + validate_bootdevices(boot_once, &error_fatal); + } + + boot_menu =3D qemu_opt_get_bool(opts, "menu", boot_menu); + boot_strict =3D qemu_opt_get_bool(opts, "strict", false); + } + + if (!boot_order) { + boot_order =3D machine_class->default_boot_order; + } + + current_machine->boot_order =3D boot_order; +} + static void qemu_create_early_backends(void) { MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); @@ -3449,7 +3484,7 @@ static void qemu_machine_creation_done(void) =20 void qemu_init(int argc, char **argv, char **envp) { - QemuOpts *opts, *machine_opts; + QemuOpts *opts; QemuOpts *icount_opts =3D NULL, *accel_opts =3D NULL; QemuOptsList *olist; int optind; @@ -4388,12 +4423,7 @@ void qemu_init(int argc, char **argv, char **envp) qemu_create_default_devices(); qemu_create_early_backends(); =20 - machine_opts =3D qemu_get_machine_opts(); - qemu_opt_foreach(machine_opts, machine_set_property, current_machine, - &error_fatal); - current_machine->ram_size =3D ram_size; - current_machine->maxram_size =3D maxram_size; - current_machine->ram_slots =3D ram_slots; + qemu_apply_machine_options(); =20 /* * Note: uses machine properties such as kernel-irqchip, must run @@ -4429,30 +4459,8 @@ void qemu_init(int argc, char **argv, char **envp) */ migration_object_init(); =20 - opts =3D qemu_opts_find(qemu_find_opts("boot-opts"), NULL); - if (opts) { - boot_order =3D qemu_opt_get(opts, "order"); - if (boot_order) { - validate_bootdevices(boot_order, &error_fatal); - } - - boot_once =3D qemu_opt_get(opts, "once"); - if (boot_once) { - validate_bootdevices(boot_once, &error_fatal); - } - - boot_menu =3D qemu_opt_get_bool(opts, "menu", boot_menu); - boot_strict =3D qemu_opt_get_bool(opts, "strict", false); - } - - if (!boot_order) { - boot_order =3D machine_class->default_boot_order; - } - qemu_create_late_backends(); =20 - current_machine->boot_order =3D boot_order; - /* parse features once if machine provides default cpu_type */ current_machine->cpu_type =3D machine_class->default_cpu_type; if (cpu_option) { --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142005; cv=none; d=zohomail.com; s=zohoarc; b=KBqGQc6uMlr1pNGRntYhu2r2srNv7dmQMUG+PM9N6dmKCLw4lGHWI9RpKTg+2H/Im75X58/ZiVuTh5zgBWbNkwlaMSQrJVGRkIcm94f1t3ffzthuh9sc6w2P1x4yEPge246sFuWWR1cdbhbkKRC0bErmQ410do6VKt+7Z1Dkfs8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142005; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SWqQa01ursVNrq8bOiF5BaDNpOE9xVyrJ2UEuUCJvmE=; b=RDXsgJw6P1+T+7cOXOOnR5PfRMrWXAOaVrVA+relA7kWCMixAWBI691WRRUFPQPLrGsjIvXHZf6REZj4BUFqN5KNAoNX49gl5NfDCSK/KQWOmDsOzQoGw4dtJRttm3IfcQCpahjVNcqQpqeDta6VeGV6fJjowcN07GBamYPoJRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142005948847.6351746575303; Mon, 23 Nov 2020 06:33:25 -0800 (PST) Received: from localhost ([::1]:56072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCuC-0003jg-Dq for importer@patchew.org; Mon, 23 Nov 2020 09:33:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcQ-0003CG-Dc for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24960) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcL-0007pJ-IX for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:01 -0500 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-199-BwfpjoOANGm_A9QOldlVGg-1; Mon, 23 Nov 2020 09:14:53 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3D2D100C606 for ; Mon, 23 Nov 2020 14:14:52 +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 B2FE45D9E3 for ; Mon, 23 Nov 2020 14:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SWqQa01ursVNrq8bOiF5BaDNpOE9xVyrJ2UEuUCJvmE=; b=JYAImpGbmWxsEGUvtlmWizkZS3ax/DLnnE2BuRnsGkL8gRkPqeOlpBya39VyvLpydDA7pk +PDGqMU7VDohaMb7AUYo3/AaJ/M6FSri3z/ASIBKSTTa9npil4HFzCgNpcPduFytMoIkRE GCQBPPECIjjBzlLgGYRr83+A1z3JLzg= X-MC-Unique: BwfpjoOANGm_A9QOldlVGg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 20/36] vl: separate qemu_resolve_machine_memdev Date: Mon, 23 Nov 2020 09:14:19 -0500 Message-Id: <20201123141435.2726558-21-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This is a bit nasty: the machine is storing a string and later resolving it. We probably want to make the memdev property a normal link, and handle "-M memdev" as a legacy option that is special cased by machine_set_property. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- softmmu/vl.c | 70 +++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 741a800114..6c8a103178 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2834,6 +2834,42 @@ static bool have_custom_ram_size(void) return !!qemu_opt_get_size(opts, "size", 0); } =20 +static void qemu_resolve_machine_memdev(void) +{ + if (current_machine->ram_memdev_id) { + Object *backend; + ram_addr_t backend_size; + + backend =3D object_resolve_path_type(current_machine->ram_memdev_i= d, + TYPE_MEMORY_BACKEND, NULL); + if (!backend) { + error_report("Memory backend '%s' not found", + current_machine->ram_memdev_id); + exit(EXIT_FAILURE); + } + backend_size =3D object_property_get_uint(backend, "size", &error= _abort); + if (have_custom_ram_size() && backend_size !=3D ram_size) { + error_report("Size specified by -m option must match size = of " + "explicitly specified 'memory-backend' proper= ty"); + exit(EXIT_FAILURE); + } + if (mem_path) { + error_report("'-mem-path' can't be used together with" + "'-machine memory-backend'"); + exit(EXIT_FAILURE); + } + ram_size =3D backend_size; + } + + if (!xen_enabled()) { + /* On 32-bit hosts, QEMU is limited by virtual address space */ + if (ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { + error_report("at most 2047 MB RAM can be simulated"); + exit(1); + } + } +} + static void set_memory_options(MachineClass *mc) { uint64_t sz; @@ -4467,39 +4503,7 @@ void qemu_init(int argc, char **argv, char **envp) current_machine->cpu_type =3D parse_cpu_option(cpu_option); } =20 - if (current_machine->ram_memdev_id) { - Object *backend; - ram_addr_t backend_size; - - backend =3D object_resolve_path_type(current_machine->ram_memdev_i= d, - TYPE_MEMORY_BACKEND, NULL); - if (!backend) { - error_report("Memory backend '%s' not found", - current_machine->ram_memdev_id); - exit(EXIT_FAILURE); - } - backend_size =3D object_property_get_uint(backend, "size", &error= _abort); - if (have_custom_ram_size() && backend_size !=3D ram_size) { - error_report("Size specified by -m option must match size = of " - "explicitly specified 'memory-backend' proper= ty"); - exit(EXIT_FAILURE); - } - if (mem_path) { - error_report("'-mem-path' can't be used together with" - "'-machine memory-backend'"); - exit(EXIT_FAILURE); - } - ram_size =3D backend_size; - } - - if (!xen_enabled()) { - /* On 32-bit hosts, QEMU is limited by virtual address space */ - if (ram_size > (2047 << 20) && HOST_LONG_BITS =3D=3D 32) { - error_report("at most 2047 MB RAM can be simulated"); - exit(1); - } - } - + qemu_resolve_machine_memdev(); parse_numa_opts(current_machine); =20 /* do monitor/qmp handling at preconfig state if requested */ --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142017; cv=none; d=zohomail.com; s=zohoarc; b=eJm+TL5jM3TQK+YPDxQy5WXcv8a0wDF3o1ISUMw3OjckvIXTOe85Cz4QI54jZk40rl9E06AxP8/uVW40svI6iohijE8tBSQDiZEUrgVHcjkYWCA5NFwHrk9Low1niisba+NFZdGS/FKcEna3J5+NwOSYdtUWoJSnapkhrt3Jplk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142017; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=trNNlTVD1e/0J8SnkbSIgitAs56/GNLkQlbl890RDh0=; b=gLhaOL5F2V584v0oh8BEVrI0dqcGrT1+OrB5SbiV0gAtg/ZGFTh1t02QSqzJiBBh41M3OOViBy6WJ7++N5KR9V+YZOKG409utkUoRU4yOFhuhTgy3lnceRY9wjWDTEXfD8o6TtXITGUFuoS6hBdRIR8PE0EK0mleYNLoPBj/b4E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142017505744.7615682934778; Mon, 23 Nov 2020 06:33:37 -0800 (PST) Received: from localhost ([::1]:56202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCuN-0003mx-8d for importer@patchew.org; Mon, 23 Nov 2020 09:33:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36762) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcS-0003GR-55 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:51469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcN-0007q1-J7 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:03 -0500 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-218-9e_E1HmhO5Cbp3Z9nWf9dw-1; Mon, 23 Nov 2020 09:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3B295100C60E for ; Mon, 23 Nov 2020 14:14:53 +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 0A71B5D9E3 for ; Mon, 23 Nov 2020 14:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=trNNlTVD1e/0J8SnkbSIgitAs56/GNLkQlbl890RDh0=; b=GgDt17RepB6JZDeAnab+MMNSAyTJW4IjDy7yebjk5M8wF/BaQsxNMuGEOYbyIchdmKNnWj TCahNa5pD/U089egsUIYos7nNdhZfzPO/njbYLAj7b3zVqhS8RDvD0/hsZnUFGpGxEw6SM 83D8GfVl2nM0LK/u7I4NFOL5fHNnNjg= X-MC-Unique: 9e_E1HmhO5Cbp3Z9nWf9dw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 21/36] vl: initialize displays before preconfig loop Date: Mon, 23 Nov 2020 09:14:20 -0500 Message-Id: <20201123141435.2726558-22-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Displays should be available before the monitor starts, so that it is possible to use the graphical console to interact with the monitor itself. This patch is quite ugly, but all this is temporary. The double call to qemu_init_displays will go away as soon we can unify machine initialization between the preconfig and "normal" flows, and so will the preconfig_exit_requested variable (that is only preconfig_requested remains). Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- softmmu/vl.c | 57 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 6c8a103178..073d7412ad 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -137,6 +137,7 @@ static ram_addr_t maxram_size; static uint64_t ram_slots; static int display_remote; static int snapshot; +static bool preconfig_requested; static QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); static BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_qu= eue); static bool nographic =3D false; @@ -3211,12 +3212,12 @@ static void qemu_validate_options(void) } } =20 - if (loadvm && !preconfig_exit_requested) { + if (loadvm && preconfig_requested) { error_report("'preconfig' and 'loadvm' options are " "mutually exclusive"); exit(EXIT_FAILURE); } - if (incoming && !preconfig_exit_requested) { + if (incoming && preconfig_requested) { error_report("'preconfig' and 'incoming' options are " "mutually exclusive"); exit(EXIT_FAILURE); @@ -3380,6 +3381,28 @@ static void qemu_init_subsystems(void) socket_init(); } =20 +static void qemu_init_displays(void) +{ + DisplayState *ds; + + /* init local displays */ + ds =3D 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(); + } +} + /* * Called after leaving preconfig state. From here on runstate is * RUN_STATE_PRELAUNCH or RUN_STATE_INMIGRATE. @@ -3443,8 +3466,6 @@ static void qemu_create_cli_devices(void) =20 static void qemu_machine_creation_done(void) { - DisplayState *ds; - cpu_synchronize_all_post_init(); =20 /* Did we create any drives that we failed to create a device for? */ @@ -3467,23 +3488,6 @@ static void qemu_machine_creation_done(void) qemu_register_reset(restore_boot_order, g_strdup(boot_order)); } =20 - /* init local displays */ - ds =3D 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); } @@ -4083,6 +4087,7 @@ void qemu_init(int argc, char **argv, char **envp) break; case QEMU_OPTION_preconfig: preconfig_exit_requested =3D false; + preconfig_requested =3D true; break; case QEMU_OPTION_enable_kvm: olist =3D qemu_find_opts("machine"); @@ -4506,11 +4511,21 @@ void qemu_init(int argc, char **argv, char **envp) qemu_resolve_machine_memdev(); parse_numa_opts(current_machine); =20 + if (preconfig_requested) { + qemu_init_displays(); + } + /* do monitor/qmp handling at preconfig state if requested */ qemu_main_loop(); =20 qemu_init_board(); + qemu_create_cli_devices(); + + /* initialize displays after all errors have been reported */ + if (!preconfig_requested) { + qemu_init_displays(); + } qemu_machine_creation_done(); =20 if (loadvm) { --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141170; cv=none; d=zohomail.com; s=zohoarc; b=YcWKA+B1DYBkofG66kgG9YQc5wS3NN3yvDnwwcXHYR3gaBKqXcXjS2kbynxfE6N3SGuQTTSUprNrTsg6tcu5OHZdZ2XckkHcbv+75wQbA4HayBLf8rmCKs0B9AG5qGRJXn4YIOnhfJoXUWZnky0UbmGOd4vTEOF2cC0L9snDDyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141170; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Xe4OWKvtZqynRyc78zyoSXZIcM064LRqQVw+ofxUmak=; b=dqpH2rX1k1yz4Nr7/JKDfvnU9YDa60x8qHbwVjimmHDVfbDvj6vUNeMkoJ7A0ezo8/p7n0K10X/giRNR7VaXY0yyhu0/wNTSkxAJPnexeNnrZrlsyWsKnROitLfNJhL8jguXzemNMohQwSwfr5t/EFT7hdfw3lYYHo91P6jxqqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141170045786.0379902046343; Mon, 23 Nov 2020 06:19:30 -0800 (PST) Received: from localhost ([::1]:37648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCgj-00012p-Ai for importer@patchew.org; Mon, 23 Nov 2020 09:19:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcO-00036p-9H for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25003) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcL-0007pG-Ig for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:14:59 -0500 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-395-ifCENtWpMy6SAwamdHUfDA-1; Mon, 23 Nov 2020 09:14:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 87E7D5218 for ; Mon, 23 Nov 2020 14:14:53 +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 559A65D9E3 for ; Mon, 23 Nov 2020 14:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140896; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xe4OWKvtZqynRyc78zyoSXZIcM064LRqQVw+ofxUmak=; b=NI6pZDCQFwbOXepJNLDmlKeoPCyEtaGXVbvSxOps/Xx6of8rIkXV6rMVBr8WXIUYCgb4Q+ EANcO9tCIJYxVG4tFCtwR44NuBnQ4kdDrQebiKqrVW2bW1+KAnGuVciZqkn7mVuSUmDJjT Qi84KaDXsktPMtRTJpalulKANlQKg2E= X-MC-Unique: ifCENtWpMy6SAwamdHUfDA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 22/36] vl: move -global check earlier Date: Mon, 23 Nov 2020 09:14:21 -0500 Message-Id: <20201123141435.2726558-23-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The check has the same effect here, it only matters that it is performed once all devices, both builtin and user-specified, have been created. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index 073d7412ad..ccc3b8e838 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3483,6 +3483,8 @@ static void qemu_machine_creation_done(void) net_check_clients(); } =20 + qdev_prop_check_globals(); + if (boot_once) { qemu_boot_set(boot_once, &error_fatal); qemu_register_reset(restore_boot_order, g_strdup(boot_order)); @@ -4540,7 +4542,6 @@ void qemu_init(int argc, char **argv, char **envp) replay_vmstate_init(); } =20 - qdev_prop_check_globals(); if (vmstate_dump_file) { /* dump and exit */ dump_vmstate_json_to_file(vmstate_dump_file); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141546; cv=none; d=zohomail.com; s=zohoarc; b=GRKG5mdnVkrgsUr0ax4ZdCPcryunE655TBR2jHeODIhx/aj1bWfoA783SvJ8f8YJtiCoMqEuvnUfpuV3SapbSHBr2sthGa1/0AZglxOVTKscDQCtZjTFc46P7f8u3tgeYsLzQwIIaJIN+bd/onkTTjVNKr0ql651axhD+BfrVJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141546; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/BVXCLD6lSYwYsyeslE0Hlb9d9Sq3VdXQGeokQboIk0=; b=ZBMJcVH3rzUQY6qrGv9MZxeoKMpefGhFhu68K5s2LmFGN55P4u7PDT9b7GGpN7Z1y4vIBh9QVUInT7Emme3nqUOrmG4hCzar8tq092L9H6AscudMVN0go5RMgB+PisYcvezVBpLAOlUN6HdpOcZNR3CzRh1oD1NkUzbiX+wE46M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141546985349.6053866050736; Mon, 23 Nov 2020 06:25:46 -0800 (PST) Received: from localhost ([::1]:59556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCmo-0001iQ-6O for importer@patchew.org; Mon, 23 Nov 2020 09:25:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36716) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcP-0003BV-WE for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcL-0007pR-PQ for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:01 -0500 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-427-WjLiQ72AOJmdeZqhdhB-Tg-1; Mon, 23 Nov 2020 09:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3C9918B9ECB for ; Mon, 23 Nov 2020 14:14:53 +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 A23B65D9E3 for ; Mon, 23 Nov 2020 14:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/BVXCLD6lSYwYsyeslE0Hlb9d9Sq3VdXQGeokQboIk0=; b=KjNU0ekIKo/B3M7QQgoeFIM6eaFYuzPrlHHXkflCpfngrZJjpbtrYEDmys9H2XfakkSog/ Vz6VyxoTIvGVOlhqorEcTfQf0uXpsHElBH/kv5HythL8IUNavj+HFv0pFZ2BvrRzUKY55T AFa/nGvDt1Hpgv6us7MKW3HHReWz3FU= X-MC-Unique: WjLiQ72AOJmdeZqhdhB-Tg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 23/36] migration, vl: start migration via qmp_migrate_incoming Date: Mon, 23 Nov 2020 09:14:22 -0500 Message-Id: <20201123141435.2726558-24-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Make qemu_start_incoming_migration local to migration/migration.c. By using the runstate instead of a separate flag, vl need not do anything to setup deferred incoming migration. qmp_migrate_incoming also does not need the deferred_incoming flag anymore, because "-incoming PROTOCOL" will clear the "once" flag before the main loop starts. Therefore, later invocations of the migrate-incoming command will fail with the existing "The incoming migration has already been started" error message. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- include/migration/misc.h | 1 - migration/migration.c | 33 ++++++++------------------------- softmmu/vl.c | 11 +++++++---- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 34e7d75713..bccc1b6b44 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -58,7 +58,6 @@ void dump_vmstate_json_to_file(FILE *out_fp); /* migration/migration.c */ void migration_object_init(void); void migration_shutdown(void); -void qemu_start_incoming_migration(const char *uri, Error **errp); bool migration_is_idle(void); bool migration_is_active(MigrationState *); void add_migration_state_change_notifier(Notifier *notify); diff --git a/migration/migration.c b/migration/migration.c index d9e94f4080..e0dbde4091 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -118,8 +118,6 @@ static NotifierList migration_state_notifiers =3D NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); =20 -static bool deferred_incoming; - /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { MIG_RP_MSG_INVALID =3D 0, /* Must be 0 */ @@ -275,19 +273,6 @@ static bool migrate_late_block_activate(void) MIGRATION_CAPABILITY_LATE_BLOCK_ACTIVATE]; } =20 -/* - * Called on -incoming with a defer: uri. - * The migration can be started later after any parameters have been - * changed. - */ -static void deferred_incoming_migration(Error **errp) -{ - if (deferred_incoming) { - error_setg(errp, "Incoming migration already deferred"); - } - deferred_incoming =3D true; -} - /* * Send a message on the return channel back to the source * of the migration. @@ -429,16 +414,14 @@ void migrate_add_address(SocketAddress *address) addrs->value =3D QAPI_CLONE(SocketAddress, address); } =20 -void qemu_start_incoming_migration(const char *uri, Error **errp) +static void qemu_start_incoming_migration(const char *uri, Error **errp) { const char *p =3D NULL; =20 qapi_event_send_migration(MIGRATION_STATUS_SETUP); - if (!strcmp(uri, "defer")) { - deferred_incoming_migration(errp); - } else if (strstart(uri, "tcp:", &p) || - strstart(uri, "unix:", NULL) || - strstart(uri, "vsock:", NULL)) { + if (strstart(uri, "tcp:", &p) || + strstart(uri, "unix:", NULL) || + strstart(uri, "vsock:", NULL)) { socket_start_incoming_migration(p ? p : uri, errp); #ifdef CONFIG_RDMA } else if (strstart(uri, "rdma:", &p)) { @@ -1988,14 +1971,14 @@ void qmp_migrate_incoming(const char *uri, Error **= errp) Error *local_err =3D NULL; static bool once =3D true; =20 - if (!deferred_incoming) { - error_setg(errp, "For use with '-incoming defer'"); - return; - } if (!once) { error_setg(errp, "The incoming migration has already been started"= ); return; } + if (!runstate_check(RUN_STATE_INMIGRATE)) { + error_setg(errp, "'-incoming' was not specified on the command lin= e"); + return; + } =20 qemu_start_incoming_migration(uri, &local_err); =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index ccc3b8e838..d548c31ba0 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -109,6 +109,7 @@ #include "qapi/qapi-visit-block-core.h" #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" +#include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" @@ -4549,10 +4550,12 @@ void qemu_init(int argc, char **argv, char **envp) } if (incoming) { Error *local_err =3D NULL; - qemu_start_incoming_migration(incoming, &local_err); - if (local_err) { - error_reportf_err(local_err, "-incoming %s: ", incoming); - exit(1); + if (strcmp(incoming, "defer") !=3D 0) { + qmp_migrate_incoming(incoming, &local_err); + if (local_err) { + error_reportf_err(local_err, "-incoming %s: ", incoming); + exit(1); + } } } else if (autostart) { vm_start(); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141681; cv=none; d=zohomail.com; s=zohoarc; b=V+tcu8E6T2fNBEkAC9lvrf9D1UhPLb288xXL+vfuvLw5p8VSeL8j/CxBHwjWVEiVxCLYhUnNpaimsFWfaj2I97IxCjxAI9ZBMF/mXzgRXmshsIrAQwyQvI6ReNKRyQh8MHsgq0OAlWbYossOrGR6zIjXjkbWAq+Pmjfi7jk5cKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141681; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HJ786ZtxQcWYvdNbqpG/nqHQFKY8Ie9Xw7sxd/MhTEc=; b=Tw8sKhdOivHFE/k7g1Yh/Lnk43SgHPHd46tQ9TPD19fYuGBocCTxrUsqJ/TBBPZuI0C/EiB58xc0BC0474flCCTmi+UBccinktBtvTrxChQwjNWptBMALyTx7ETqiGnGtrxv1mWPHeMtLFfdkMRDVsYdQHh8lHvb3AsV3UkpyGA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141681244213.4990219888125; Mon, 23 Nov 2020 06:28:01 -0800 (PST) Received: from localhost ([::1]:39610 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCoy-0005DC-1h for importer@patchew.org; Mon, 23 Nov 2020 09:28:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcR-0003EU-5s for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcM-0007pl-OG for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:02 -0500 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-276-NDMybW-MNBOSvrf3QKE3Tg-1; Mon, 23 Nov 2020 09:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 39B0518B9EDD for ; Mon, 23 Nov 2020 14:14:54 +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 ED98C5D9E3; Mon, 23 Nov 2020 14:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140898; 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=HJ786ZtxQcWYvdNbqpG/nqHQFKY8Ie9Xw7sxd/MhTEc=; b=bVx5gHnEu9wbQUHnz9ba1odqKcPVd6lY+zQqNj1zEQrhumOM+Gyfhki82CFio94yG1KwJE sRBWlPbjKO05HsnDt9M145Odvq3qYarXhQjPI4a0GAPjKVZcMbPNb3ZCtCL2E+sS+KM9X7 1nbjvvvxEMnc97x9v6tG6JH2eAVho5c= X-MC-Unique: NDMybW-MNBOSvrf3QKE3Tg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 24/36] vl: start VM via qmp_cont Date: Mon, 23 Nov 2020 09:14:23 -0500 Message-Id: <20201123141435.2726558-25-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Complement the previous patch by starting the VM with a QMP command. The plan is that the user will be able to do the same, invoking two commands "finish-machine-init" and "cont" instead of "x-exit-preconfig". Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- softmmu/vl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index d548c31ba0..ecfe16c4c4 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -110,6 +110,7 @@ #include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" @@ -4558,7 +4559,7 @@ void qemu_init(int argc, char **argv, char **envp) } } } else if (autostart) { - vm_start(); + qmp_cont(NULL); } =20 accel_setup_post(current_machine); --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141319; cv=none; d=zohomail.com; s=zohoarc; b=Dpx0heYFRqkyC6F6NOyTyk4d+o+OXUyE2UHH3OfbXgTeMgsDFJzqQO7J02hw9ksZyY/aYak+tT74DEz5qhntVRPJ9IJ8mP5d91XnQiCnPwHjAtAaU/SYnXGG7OXb+KLrnoEVk38Vqjxopiy5vAaPu9S0BWUUitNHGR5tovmfNcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141319; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uu4pdBoN9dgyqSaHAUhMadj6P5dazVOovEt0liU4I1Y=; b=JLYjo92qMm4YBxVla6AUbHPQ+beSALt+EOjXq0KQTslRpDBL5ZsfZ4iFRzo04dU0itLmPi93VQ/FJ7R+7oj02KE2YgjFLxQ0iMZXaMHCT/yXAQkGPfp1hd/ev000N3v0ZtOhEGKvyo70bOMbSrKvrVZBr+2QfNGuYVFVVgbESqk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141319337972.2815126677484; Mon, 23 Nov 2020 06:21:59 -0800 (PST) Received: from localhost ([::1]:46034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCj7-0004ZI-W6 for importer@patchew.org; Mon, 23 Nov 2020 09:21:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcQ-0003DD-N8 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:39134) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcM-0007pV-O8 for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:02 -0500 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-231-TRW-lHCRPPO1UxrsTBem9w-1; Mon, 23 Nov 2020 09:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9493218B9EEC for ; Mon, 23 Nov 2020 14:14:54 +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 542645D9E3; Mon, 23 Nov 2020 14:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140897; 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=uu4pdBoN9dgyqSaHAUhMadj6P5dazVOovEt0liU4I1Y=; b=ZDJjbt9Frqstvf2d9X1xa5T2VFGoC2o5xknRgaj9zkElD8Sf5iukLY0S7CQVhfNxgJoSF6 g9UJv4vDkytSiTTkgY/Ii6m5fsjDRI4jkzODCDGxbNIZt0CA/+GOCmsTIG/W4CmwiEZ6fj ZswJMcuWmbn9OSgY6Oz7SFW6SEgbPjs= X-MC-Unique: TRW-lHCRPPO1UxrsTBem9w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 25/36] hmp: introduce cmd_available Date: Mon, 23 Nov 2020 09:14:24 -0500 Message-Id: <20201123141435.2726558-26-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: Igor Mammedov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Combine the RUN_STATE_PRECONFIG and cmd_can_preconfig checks into a single function, to avoid repeating the same expression (or its negation after applying DeMorgan's rule) over and over again. Reviewed-by: Igor Mammedov Signed-off-by: Paolo Bonzini --- monitor/hmp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index 1204233999..d40f4f4391 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -213,6 +213,11 @@ static bool cmd_can_preconfig(const HMPCommand *cmd) return strchr(cmd->flags, 'p'); } =20 +static bool cmd_available(const HMPCommand *cmd) +{ + return !runstate_check(RUN_STATE_PRECONFIG) || cmd_can_preconfig(cmd); +} + static void help_cmd_dump_one(Monitor *mon, const HMPCommand *cmd, char **prefix_args, @@ -220,7 +225,7 @@ static void help_cmd_dump_one(Monitor *mon, { int i; =20 - if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) { + if (!cmd_available(cmd)) { return; } =20 @@ -248,8 +253,7 @@ static void help_cmd_dump(Monitor *mon, const HMPComman= d *cmds, /* Find one entry to dump */ for (cmd =3D cmds; cmd->name !=3D NULL; cmd++) { if (hmp_compare_cmd(args[arg_index], cmd->name) && - ((!runstate_check(RUN_STATE_PRECONFIG) || - cmd_can_preconfig(cmd)))) { + cmd_available(cmd)) { if (cmd->sub_table) { /* continue with next arg */ help_cmd_dump(mon, cmd->sub_table, @@ -653,7 +657,7 @@ static const HMPCommand *monitor_parse_command(MonitorH= MP *hmp_mon, (int)(p - cmdp_start), cmdp_start); return NULL; } - if (runstate_check(RUN_STATE_PRECONFIG) && !cmd_can_preconfig(cmd)) { + if (!cmd_available(cmd)) { monitor_printf(mon, "Command '%.*s' not available with -preconfig " "until after exit_preconfig.\n", (int)(p - cmdp_start), cmdp_start); @@ -1225,8 +1229,7 @@ static void monitor_find_completion_by_table(MonitorH= MP *mon, } readline_set_completion_index(mon->rs, strlen(cmdname)); for (cmd =3D cmd_table; cmd->name !=3D NULL; cmd++) { - if (!runstate_check(RUN_STATE_PRECONFIG) || - cmd_can_preconfig(cmd)) { + if (cmd_available(cmd)) { cmd_completion(mon, cmdname, cmd->name); } } @@ -1234,8 +1237,7 @@ static void monitor_find_completion_by_table(MonitorH= MP *mon, /* find the command */ for (cmd =3D cmd_table; cmd->name !=3D NULL; cmd++) { if (hmp_compare_cmd(args[0], cmd->name) && - (!runstate_check(RUN_STATE_PRECONFIG) || - cmd_can_preconfig(cmd))) { + cmd_available(cmd)) { break; } } --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141835; cv=none; d=zohomail.com; s=zohoarc; b=eMZ8NsrQ+liAEBT+BnfcVVgBT3Tv2EYEvWAK0y5jWhzxbMY4/RxbaAiZsZHLxWNu72a4z1WBHjXwPHFDBnVHtMP9I91xdP9MvBT4r1uin2dtyhsF/dUmjkw5B9iXiP7TnfNkewk0JvX97tesxxc/zFAHavcPmO4bGdEcbLXGq2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141835; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v4PE9CJs88u0SSLJG0v62+R15MCskAS5ymJ2/lnnX5Q=; b=DmkvQERqT4LwDSMnseaMFYu/9z1tiNbuF/wz+9lePi/+ihyVvr3avA1d7VQVLHMX8+z+d1AG1/ZsQvH4pXPZgoWSBBDy6FedWdeYm9xM9vVeWFde2UkPwZ6xEOnlJ3bOyNUoAGAij+5T/nlsGKrPj718GMJ92wgbh3ym10y9Rmw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141835712481.57580729614347; Mon, 23 Nov 2020 06:30:35 -0800 (PST) Received: from localhost ([::1]:47812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCrR-00009A-8f for importer@patchew.org; Mon, 23 Nov 2020 09:30:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcR-0003FH-Gj for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56492) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcM-0007pi-OO for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:03 -0500 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-87-nyFTyeZKPgqASSVXD-1hqg-1; Mon, 23 Nov 2020 09:14:55 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E026A100B71E for ; Mon, 23 Nov 2020 14:14:54 +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 AEAFD5D9E3 for ; Mon, 23 Nov 2020 14:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140897; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v4PE9CJs88u0SSLJG0v62+R15MCskAS5ymJ2/lnnX5Q=; b=Qz9OeJ2uXeAV2jiJQwt8gomSAmZ51qsgHeF5H+lNtFtiKHoZRPtSk6R2/qFmxw7RydBwmL J/Ju6hWe3o9UQeMTntN8NRMXnfM7sxVt551fpMbO9vkm+W8j2g0vsmP+DmcChggbgNWbQt DLIhfyXVo/WrPp5NX0Mwfh76j5B7HiQ= X-MC-Unique: nyFTyeZKPgqASSVXD-1hqg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 26/36] remove preconfig state Date: Mon, 23 Nov 2020 09:14:25 -0500 Message-Id: <20201123141435.2726558-27-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The preconfig state is only used if -incoming is not specified, which makes the RunState state machine more tricky than it need be. However there is already an equivalent condition which works even with -incoming, namely qdev_hotplug. Use it instead of a separate runstate. Signed-off-by: Paolo Bonzini --- hw/core/machine-qmp-cmds.c | 5 ++--- include/qapi/qmp/dispatch.h | 1 + monitor/hmp.c | 7 ++++--- monitor/qmp-cmds.c | 5 ++--- qapi/qmp-dispatch.c | 5 +---- qapi/run-state.json | 5 +---- softmmu/qdev-monitor.c | 12 ++++++++++++ softmmu/vl.c | 13 ++----------- stubs/meson.build | 1 + stubs/qmp-command-available.c | 7 +++++++ tests/qtest/qmp-test.c | 2 +- 11 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 stubs/qmp-command-available.c diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 5362c80a18..cb9387c5f5 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -286,9 +286,8 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error = **errp) =20 void qmp_set_numa_node(NumaOptions *cmd, Error **errp) { - if (!runstate_check(RUN_STATE_PRECONFIG)) { - error_setg(errp, "The command is permitted only in '%s' state", - RunState_str(RUN_STATE_PRECONFIG)); + if (qdev_hotplug) { + error_setg(errp, "The command is permitted only before the machin= e has been created"); return; } =20 diff --git a/include/qapi/qmp/dispatch.h b/include/qapi/qmp/dispatch.h index af8d96c570..1486cac3ef 100644 --- a/include/qapi/qmp/dispatch.h +++ b/include/qapi/qmp/dispatch.h @@ -48,6 +48,7 @@ void qmp_disable_command(QmpCommandList *cmds, const char= *name); void qmp_enable_command(QmpCommandList *cmds, const char *name); =20 bool qmp_command_is_enabled(const QmpCommand *cmd); +bool qmp_command_available(const QmpCommand *cmd, Error **errp); const char *qmp_command_name(const QmpCommand *cmd); bool qmp_has_success_response(const QmpCommand *cmd); QDict *qmp_error_response(Error *err); diff --git a/monitor/hmp.c b/monitor/hmp.c index d40f4f4391..f2fe192d69 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include +#include "hw/qdev-core.h" #include "monitor-internal.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" @@ -215,7 +216,7 @@ static bool cmd_can_preconfig(const HMPCommand *cmd) =20 static bool cmd_available(const HMPCommand *cmd) { - return !runstate_check(RUN_STATE_PRECONFIG) || cmd_can_preconfig(cmd); + return qdev_hotplug || cmd_can_preconfig(cmd); } =20 static void help_cmd_dump_one(Monitor *mon, @@ -658,8 +659,8 @@ static const HMPCommand *monitor_parse_command(MonitorH= MP *hmp_mon, return NULL; } if (!cmd_available(cmd)) { - monitor_printf(mon, "Command '%.*s' not available with -preconfig " - "until after exit_preconfig.\n", + monitor_printf(mon, "Command '%.*s' not available " + "until machine initialization has completed.\n= ", (int)(p - cmdp_start), cmdp_start); return NULL; } diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 6299c0c8c7..501a3024c7 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -104,9 +104,8 @@ void qmp_system_powerdown(Error **errp) =20 void qmp_x_exit_preconfig(Error **errp) { - if (!runstate_check(RUN_STATE_PRECONFIG)) { - error_setg(errp, "The command is permitted only in '%s' state", - RunState_str(RUN_STATE_PRECONFIG)); + if (qdev_hotplug) { + error_setg(errp, "The command is permitted only before machine ini= tialization"); return; } qemu_exit_preconfig_request(); diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 9a2d7dd29a..0a2b20a4e4 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -167,10 +167,7 @@ QDict *qmp_dispatch(const QmpCommandList *cmds, QObjec= t *request, goto out; } =20 - if (runstate_check(RUN_STATE_PRECONFIG) && - !(cmd->options & QCO_ALLOW_PRECONFIG)) { - error_setg(&err, "The command '%s' isn't permitted in '%s' state", - cmd->name, RunState_str(RUN_STATE_PRECONFIG)); + if (!qmp_command_available(cmd, &err)) { goto out; } =20 diff --git a/qapi/run-state.json b/qapi/run-state.json index 964c8ef391..38194b0e44 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -50,15 +50,12 @@ # @colo: guest is paused to save/restore VM state under colo checkpoint, # VM can not get into this state unless colo capability is enabled # for migration. (since 2.8) -# @preconfig: QEMU is paused before board specific init callback is execut= ed. -# The state is reachable only if the --preconfig CLI option is= used. -# (Since 3.0) ## { 'enum': 'RunState', 'data': [ 'debug', 'inmigrate', 'internal-error', 'io-error', 'paused', 'postmigrate', 'prelaunch', 'finish-migrate', 'restore-vm', 'running', 'save-vm', 'shutdown', 'suspended', 'watchdog', - 'guest-panicked', 'colo', 'preconfig' ] } + 'guest-panicked', 'colo' ] } =20 ## # @ShutdownCause: diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index d060e765da..e967d13bd0 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -25,6 +25,7 @@ #include "sysemu/arch_init.h" #include "qapi/error.h" #include "qapi/qapi-commands-qdev.h" +#include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qemu/config-file.h" @@ -997,3 +998,14 @@ int qemu_global_option(const char *str) =20 return 0; } + +bool qmp_command_available(const QmpCommand *cmd, Error **errp) +{ + if (!qdev_hotplug && + !(cmd->options & QCO_ALLOW_PRECONFIG)) { + error_setg(errp, "The command '%s' is permitted only after machine= initialization has completed", + cmd->name); + return false; + } + return true; +} diff --git a/softmmu/vl.c b/softmmu/vl.c index ecfe16c4c4..95c62bdad4 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -573,7 +573,7 @@ static int default_driver_check(void *opaque, QemuOpts = *opts, Error **errp) /***********************************************************/ /* QEMU state */ =20 -static RunState current_run_state =3D RUN_STATE_PRECONFIG; +static RunState current_run_state =3D RUN_STATE_PRELAUNCH; =20 /* We use RUN_STATE__MAX but any invalid value will do */ static RunState vmstop_requested =3D RUN_STATE__MAX; @@ -585,13 +585,7 @@ typedef struct { } RunStateTransition; =20 static const RunStateTransition runstate_transitions_def[] =3D { - /* from -> to */ - { RUN_STATE_PRECONFIG, RUN_STATE_PRELAUNCH }, - /* Early switch to inmigrate state to allow -incoming CLI option wo= rk - * as it used to. TODO: delay actual switching to inmigrate state to - * the point after machine is built and remove this hack. - */ - { RUN_STATE_PRECONFIG, RUN_STATE_INMIGRATE }, + { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, =20 { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, @@ -1633,9 +1627,6 @@ static bool main_loop_should_exit(void) ShutdownCause request; =20 if (preconfig_exit_requested) { - if (runstate_check(RUN_STATE_PRECONFIG)) { - runstate_set(RUN_STATE_PRELAUNCH); - } preconfig_exit_requested =3D false; return true; } diff --git a/stubs/meson.build b/stubs/meson.build index 82b7ba60ab..cc56c83063 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -29,6 +29,7 @@ stub_ss.add(files('pci-bus.c')) stub_ss.add(files('pci-host-piix.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) stub_ss.add(files('qmp_memory_device.c')) +stub_ss.add(files('qmp-command-available.c')) stub_ss.add(files('qtest.c')) stub_ss.add(files('ram-block.c')) stub_ss.add(files('ramfb.c')) diff --git a/stubs/qmp-command-available.c b/stubs/qmp-command-available.c new file mode 100644 index 0000000000..46540af7bf --- /dev/null +++ b/stubs/qmp-command-available.c @@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "qapi/qmp/dispatch.h" + +bool qmp_command_available(const QmpCommand *cmd, Error **errp) +{ + return true; +} diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c index eb1cd8abb8..11614bf63f 100644 --- a/tests/qtest/qmp-test.c +++ b/tests/qtest/qmp-test.c @@ -295,7 +295,7 @@ static void test_qmp_preconfig(void) rsp =3D qtest_qmp(qs, "{ 'execute': 'query-status' }"); ret =3D qdict_get_qdict(rsp, "return"); g_assert(ret); - g_assert_cmpstr(qdict_get_try_str(ret, "status"), =3D=3D, "preconfig"); + g_assert_cmpstr(qdict_get_try_str(ret, "status"), =3D=3D, "prelaunch"); qobject_unref(rsp); =20 /* exit preconfig state */ --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142470; cv=none; d=zohomail.com; s=zohoarc; b=ONIT2892ET998cuB8VFRaKlrTQzvXpNg2k6OsTC3Lhny7PuZV/jUczkanAIaOxqE9Ln0v4H9ZvdV7Ag7rFgQ0IVu6xq3oboRXN6ZNIoq6LmI68ZpbCYoy1/eBDAE4cfozBhfAcpDOtPYht1P/WRALVetFMpRTcL7QbnTSTfYuyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142470; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M9vGObZRIC7nAUEZ3pR+p0NESAsMacm6JfzgB4QhQpU=; b=B8ByesrvIOSTLwZ9PsW5d40OO31bP1SLuSvRhJwfVMC90Ramb17vJUOiJ/oM5aR62t9piidMleGlkCdMsZN1dkBuqhSlpgp4K0YH5DqwrqGpZMWFlyGPI+3thOXoqMQ0cNYKDNwVDctD52i0g+cUS8cTzg1JmXzrYUr7p8vrtzQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142470350639.7924820497302; Mon, 23 Nov 2020 06:41:10 -0800 (PST) Received: from localhost ([::1]:48706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khD1g-0004Ho-Sp for importer@patchew.org; Mon, 23 Nov 2020 09:41:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcU-0003MG-GL for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcN-0007pv-Id for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:06 -0500 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-61-deQF4Bk4MJOnPnkt4D-fXQ-1; Mon, 23 Nov 2020 09:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 37BFF18B9EDC for ; Mon, 23 Nov 2020 14:14:55 +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 066D05D9E3 for ; Mon, 23 Nov 2020 14:14:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M9vGObZRIC7nAUEZ3pR+p0NESAsMacm6JfzgB4QhQpU=; b=IrHDbD6CXKbTHP1IexHTy4Q+T8oqTsTZbGw/9gdFhCkDZnKIHSEp6PTgg2fmSSaQ8/KyJ3 CQ41gsi8ZmZ51R+nfKruIx8ZW5Lqupi3dmNXYcR6ozQY60wsyRQctm0gWE6zcczJdI11vh KJwZ/OfaUn5iuoQ5wNcSKxIbJAC47R0= X-MC-Unique: deQF4Bk4MJOnPnkt4D-fXQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 27/36] vl: remove separate preconfig main_loop Date: Mon, 23 Nov 2020 09:14:26 -0500 Message-Id: <20201123141435.2726558-28-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move post-preconfig initialization to the x-exit-preconfig. If preconfig is not requested, just exit preconfig mode immediately with the QMP command. As a result, the preconfig loop will run with accel_setup_post and os_setup_post restrictions (xen_restrict, chroot, etc.) already done. Signed-off-by: Paolo Bonzini --- include/sysemu/runstate.h | 1 - monitor/qmp-cmds.c | 9 ---- softmmu/vl.c | 95 +++++++++++++++++---------------------- 3 files changed, 41 insertions(+), 64 deletions(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index f760094858..e557f470d4 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -41,7 +41,6 @@ typedef enum WakeupReason { QEMU_WAKEUP_REASON_OTHER, } WakeupReason; =20 -void qemu_exit_preconfig_request(void); void qemu_system_reset_request(ShutdownCause reason); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 501a3024c7..7ced7eb3e8 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -102,15 +102,6 @@ void qmp_system_powerdown(Error **errp) qemu_system_powerdown_request(); } =20 -void qmp_x_exit_preconfig(Error **errp) -{ - if (qdev_hotplug) { - error_setg(errp, "The command is permitted only before machine ini= tialization"); - return; - } - qemu_exit_preconfig_request(); -} - void qmp_cont(Error **errp) { BlockBackend *blk; diff --git a/softmmu/vl.c b/softmmu/vl.c index 95c62bdad4..aa11fc4871 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1313,7 +1313,6 @@ static pid_t shutdown_pid; static int powerdown_requested; static int debug_requested; static int suspend_requested; -static bool preconfig_exit_requested =3D true; static WakeupReason wakeup_reason; static NotifierList powerdown_notifiers =3D NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); @@ -1400,11 +1399,6 @@ static int qemu_debug_requested(void) return r; } =20 -void qemu_exit_preconfig_request(void) -{ - preconfig_exit_requested =3D true; -} - /* * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE. */ @@ -1626,10 +1620,6 @@ static bool main_loop_should_exit(void) RunState r; ShutdownCause request; =20 - if (preconfig_exit_requested) { - preconfig_exit_requested =3D false; - return true; - } if (qemu_debug_requested()) { vm_stop(RUN_STATE_DEBUG); } @@ -3517,6 +3507,43 @@ static void qemu_machine_creation_done(void) register_global_state(); } =20 +void qmp_x_exit_preconfig(Error **errp) +{ + if (qdev_hotplug) { + error_setg(errp, "The command is permitted only before machine ini= tialization"); + return; + } + + qemu_init_board(); + qemu_create_cli_devices(); + qemu_machine_creation_done(); + + if (loadvm) { + Error *local_err =3D NULL; + if (load_snapshot(loadvm, &local_err) < 0) { + error_report_err(local_err); + autostart =3D 0; + exit(1); + } + } + if (replay_mode !=3D REPLAY_MODE_NONE) { + replay_vmstate_init(); + } + + if (incoming) { + Error *local_err =3D NULL; + if (strcmp(incoming, "defer") !=3D 0) { + qmp_migrate_incoming(incoming, &local_err); + if (local_err) { + error_reportf_err(local_err, "-incoming %s: ", incoming); + exit(1); + } + } + } else if (autostart) { + qmp_cont(NULL); + } +} + void qemu_init(int argc, char **argv, char **envp) { QemuOpts *opts; @@ -4081,7 +4108,6 @@ void qemu_init(int argc, char **argv, char **envp) } break; case QEMU_OPTION_preconfig: - preconfig_exit_requested =3D false; preconfig_requested =3D true; break; case QEMU_OPTION_enable_kvm: @@ -4506,57 +4532,18 @@ void qemu_init(int argc, char **argv, char **envp) qemu_resolve_machine_memdev(); parse_numa_opts(current_machine); =20 - if (preconfig_requested) { - qemu_init_displays(); - } - - /* do monitor/qmp handling at preconfig state if requested */ - qemu_main_loop(); - - qemu_init_board(); - - qemu_create_cli_devices(); - - /* initialize displays after all errors have been reported */ - if (!preconfig_requested) { - qemu_init_displays(); - } - qemu_machine_creation_done(); - - if (loadvm) { - Error *local_err =3D NULL; - if (load_snapshot(loadvm, &local_err) < 0) { - error_report_err(local_err); - autostart =3D 0; - exit(1); - } - } - if (replay_mode !=3D REPLAY_MODE_NONE) { - replay_vmstate_init(); - } - if (vmstate_dump_file) { /* dump and exit */ dump_vmstate_json_to_file(vmstate_dump_file); exit(0); } - if (incoming) { - Error *local_err =3D NULL; - if (strcmp(incoming, "defer") !=3D 0) { - qmp_migrate_incoming(incoming, &local_err); - if (local_err) { - error_reportf_err(local_err, "-incoming %s: ", incoming); - exit(1); - } - } - } else if (autostart) { - qmp_cont(NULL); - } =20 + qemu_init_displays(); + if (!preconfig_requested) { + qmp_x_exit_preconfig(&error_fatal); + } accel_setup_post(current_machine); os_setup_post(); - - return; } =20 void qemu_cleanup(void) --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141473; cv=none; d=zohomail.com; s=zohoarc; b=loPVH2doh7Xh32pzmcS84vFd4z6A8bq8b67WbzoZ396g8Wf7BAENR1ibzvkIwJvKB//fogZTtrD0FIUELV8yE7bRQEU6Y6zoXI2YgPJPzluftY4goAoB1AeDnsductVm2edxV436gaMa6pjqfyK+ctCtWX/zdBzgMeaGeo9FBqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141473; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JCAUP+bdY+naX1MLWRT/UStOEqxYOBv8TaUS9sHNWfY=; b=j4lCEUSAqJ2qoJAfaK9wFNuFnhSZYqfkcjv2FdPkadMs/ikW3K3EVRrQUiG5q70gBq6Vo0IcQnRCEDLp+TGf7CR42i88nq/djgSc7QZNCKvytk4urjcUoEqxxQfMxGLZdj0Uqh64G+WqMvHVa1NinzFbNOim5g8XzB4OegJogyI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141473472146.62681819613238; Mon, 23 Nov 2020 06:24:33 -0800 (PST) Received: from localhost ([::1]:54350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khClc-000811-Hb for importer@patchew.org; Mon, 23 Nov 2020 09:24:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcS-0003IR-VF for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37783) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcN-0007qE-Uj for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:04 -0500 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-531-9c5ZEvNPNAOnFZ5P4VSAZw-1; Mon, 23 Nov 2020 09:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 82F825224 for ; Mon, 23 Nov 2020 14:14:55 +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 525FB5D9E3 for ; Mon, 23 Nov 2020 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JCAUP+bdY+naX1MLWRT/UStOEqxYOBv8TaUS9sHNWfY=; b=aY35qkInRRbQAnTKLZmxhz/iTje88Zx9qC2br1DAKEsO3wi0QG7ck0/tjEAi1QcjZe1zSs UvEmV4/ZPg5eBUNvyjmqtmX+MRPQJe3GRXAsvLUw0MzY4m7r39HoXzZht0dWoIzYwwNBQl o+y748yRsq6PLeYrjs7zl7J+6qV1bA0= X-MC-Unique: 9c5ZEvNPNAOnFZ5P4VSAZw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 28/36] vl: allow -incoming defer with -preconfig Date: Mon, 23 Nov 2020 09:14:27 -0500 Message-Id: <20201123141435.2726558-29-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now that there is no RUN_STATE_PRECONFIG anymore that can conflict with RUN_STATE_INMIGRATE, we can allow -incoming defer with -preconfig. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- softmmu/vl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/softmmu/vl.c b/softmmu/vl.c index aa11fc4871..0ba1fcdb3d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -3200,9 +3200,8 @@ static void qemu_validate_options(void) "mutually exclusive"); exit(EXIT_FAILURE); } - if (incoming && preconfig_requested) { - error_report("'preconfig' and 'incoming' options are " - "mutually exclusive"); + if (incoming && preconfig_requested && strcmp(incoming, "defer") !=3D = 0) { + error_report("'preconfig' supports '-incoming defer' only"); exit(EXIT_FAILURE); } =20 --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142391; cv=none; d=zohomail.com; s=zohoarc; b=IKDeHvRD52K9xvyZIG6ReRT4L5JG26HG3wxYvtLYvS5SE0MftLpT5ZrnWg+qBqmGMCdm6kVpofpXM7ClLDOx5Mj7BnYlGiOzqEc7XO7Asp0HgDO1bojeyzFUBm7DOgdiNmfeZCfFzItvy2jV8v0Db+zApZFizfhvcn2aciki7x8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142391; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fMF1vEDUlDf26q6R24QKEw8V9/QUcdVncicb6MHyLI4=; b=LXycFFhQ9WtkNipwJnfhTXaFNGaDd9spXH6feZtw4N/6jWHBIRTbXZBLUhLeeaYVCq5sbAqLyjavGOb/VhNqAtgPyPngKnWKDDT4PA6ILdTcm2E79Mk4GIwOP/2ioN1iMalGE77o4X7rXfI/rb8ClJQr02dbumLXu2ZodJBBnBQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142391504533.2244069590156; Mon, 23 Nov 2020 06:39:51 -0800 (PST) Received: from localhost ([::1]:45262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khD0Q-0002mK-00 for importer@patchew.org; Mon, 23 Nov 2020 09:39:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcU-0003LU-5i for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:06 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44873) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcN-0007q7-JH for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:05 -0500 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-155-ZQkr2ilbMayn6WezFftPqw-1; Mon, 23 Nov 2020 09:14:56 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF690100C607 for ; Mon, 23 Nov 2020 14:14:55 +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 9DFD85D9E3 for ; Mon, 23 Nov 2020 14:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fMF1vEDUlDf26q6R24QKEw8V9/QUcdVncicb6MHyLI4=; b=Ej4wOFDgQ8m6/R55fuZg5YACMzWKuw8YVKNFeSFcANGES2LaDq3h2aLT2HX9Cez2WPxmFO zUwlADY64vvm46O2FqRRsGtXPSjDbNaNJk12ATTpmr+HPIfedAvQQ11HC1RHu/U8g28sGZ bG9tF4A3tuJnEQao0rsxUm7K00uTy3A= X-MC-Unique: ZQkr2ilbMayn6WezFftPqw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 29/36] vl: extract softmmu/datadir.c Date: Mon, 23 Nov 2020 09:14:28 -0500 Message-Id: <20201123141435.2726558-30-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- hw/alpha/dp264.c | 1 + hw/arm/boot.c | 1 + hw/arm/digic_boards.c | 1 + hw/arm/highbank.c | 1 + hw/arm/npcm7xx_boards.c | 1 + hw/arm/sbsa-ref.c | 1 + hw/arm/vexpress.c | 1 + hw/arm/virt.c | 1 + hw/avr/boot.c | 1 + hw/core/loader.c | 1 + hw/display/cg3.c | 1 + hw/display/tcx.c | 1 + hw/hppa/machine.c | 1 + hw/i386/x86.c | 1 + hw/lm32/milkymist.c | 1 + hw/m68k/mcf5208.c | 1 + hw/m68k/q800.c | 1 + hw/microblaze/boot.c | 1 + hw/mips/fuloong2e.c | 1 + hw/mips/jazz.c | 1 + hw/mips/malta.c | 1 + hw/mips/mipssim.c | 1 + hw/nios2/boot.c | 1 + hw/nvram/fw_cfg.c | 1 + hw/pci-host/prep.c | 1 + hw/pci/pci.c | 1 + hw/ppc/e500.c | 1 + hw/ppc/mac_newworld.c | 1 + hw/ppc/mac_oldworld.c | 1 + hw/ppc/pnv.c | 1 + hw/ppc/ppc405_boards.c | 1 + hw/ppc/ppc440_bamboo.c | 1 + hw/ppc/sam460ex.c | 1 + hw/ppc/spapr.c | 1 + hw/ppc/virtex_ml507.c | 1 + hw/riscv/boot.c | 1 + hw/s390x/ipl.c | 1 + hw/sparc/leon3.c | 1 + hw/sparc/sun4m.c | 1 + hw/sparc64/sun4u.c | 1 + include/qemu-common.h | 21 ------- include/qemu/datadir.h | 28 +++++++++ include/sysemu/sysemu.h | 2 - softmmu/datadir.c | 129 ++++++++++++++++++++++++++++++++++++++++ softmmu/meson.build | 1 + softmmu/vl.c | 95 +---------------------------- tests/qtest/fuzz/fuzz.c | 1 + ui/keymaps.c | 1 + 48 files changed, 203 insertions(+), 115 deletions(-) create mode 100644 include/qemu/datadir.h create mode 100644 softmmu/datadir.c diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index c4d407a9f1..c8e300d93f 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -21,6 +21,7 @@ #include "hw/dma/i8257.h" #include "net/net.h" #include "qemu/cutils.h" +#include "qemu/datadir.h" #include "net/net.h" =20 #define MAX_IDE_BUS 2 diff --git a/hw/arm/boot.c b/hw/arm/boot.c index cf97600a91..4d9d47ba1c 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -9,6 +9,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/error-report.h" #include "qapi/error.h" #include diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c index fd228fa96f..be12873673 100644 --- a/hw/arm/digic_boards.c +++ b/hw/arm/digic_boards.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/boards.h" #include "exec/address-spaces.h" diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index fd3429720e..bf7b8f4c64 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "hw/sysbus.h" #include "migration/vmstate.h" diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c index 9821013bc6..306260fa67 100644 --- a/hw/arm/npcm7xx_boards.c +++ b/hw/arm/npcm7xx_boards.c @@ -23,6 +23,7 @@ #include "hw/qdev-properties.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "sysemu/sysemu.h" =20 diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index c3a31f5b8b..b1fa3779d8 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "qemu/units.h" diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 1adb663d77..ac098375c1 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/sysbus.h" #include "hw/arm/boot.h" diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 9c54eea585..82cb9c95cf 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -30,6 +30,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qemu/option.h" #include "monitor/qdev.h" diff --git a/hw/avr/boot.c b/hw/avr/boot.c index d16bb3dbe1..cbede775ce 100644 --- a/hw/avr/boot.c +++ b/hw/avr/boot.c @@ -10,6 +10,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "hw/loader.h" #include "elf.h" #include "boot.h" diff --git a/hw/core/loader.c b/hw/core/loader.c index 8bbb1797a4..fea22d265c 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -44,6 +44,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "trace.h" #include "hw/hw.h" diff --git a/hw/display/cg3.c b/hw/display/cg3.c index 42fcf40010..4b7e78d919 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -25,6 +25,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "ui/console.h" diff --git a/hw/display/tcx.c b/hw/display/tcx.c index 3799d29b75..965f92ff6b 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "ui/console.h" #include "ui/pixel_ops.h" diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 7e41cb2462..f2b71db9bd 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -5,6 +5,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "elf.h" #include "hw/loader.h" diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 836d388248..f3a2425f37 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -26,6 +26,7 @@ #include "qemu/cutils.h" #include "qemu/units.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" #include "qapi/qapi-visit-common.h" diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index 93ca8bc2ac..72d1326531 100644 --- a/hw/lm32/milkymist.c +++ b/hw/lm32/milkymist.c @@ -21,6 +21,7 @@ #include "qemu/units.h" #include "qemu/error-report.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/sysbus.h" #include "hw/irq.h" diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index 2205145ecc..7a03c71059 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -12,6 +12,7 @@ #include "qemu/log.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/irq.h" #include "hw/m68k/mcf.h" diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 6ebcddcfb2..4db2b9bbc7 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -23,6 +23,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "sysemu/sysemu.h" #include "cpu.h" #include "hw/hw.h" diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index e1f56f83f9..6715ba2ff9 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -26,6 +26,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "qemu/option.h" #include "qemu/config-file.h" diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index 84a2132f85..45c596f4fe 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -20,6 +20,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qapi/error.h" #include "cpu.h" diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index aa95c6a3d3..f9442731dd 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "hw/clock.h" #include "hw/mips/mips.h" #include "hw/mips/cpudevs.h" diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 467b21849e..5c11eecec1 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/clock.h" #include "hw/southbridge/piix.h" diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c index cc9b0934b3..f2e6273525 100644 --- a/hw/mips/mipssim.c +++ b/hw/mips/mipssim.c @@ -28,6 +28,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/clock.h" #include "hw/mips/mips.h" diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index 3cb864914b..95a8697906 100644 --- a/hw/nios2/boot.c +++ b/hw/nios2/boot.c @@ -31,6 +31,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "qemu/option.h" #include "qemu/config-file.h" diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 08539a1aab..9e80633d6e 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "sysemu/sysemu.h" #include "sysemu/dma.h" #include "sysemu/reset.h" diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c index d0323fefb1..0469db8c1d 100644 --- a/hw/pci-host/prep.c +++ b/hw/pci-host/prep.c @@ -25,6 +25,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qapi/error.h" #include "hw/pci/pci.h" diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 0131d9d02c..9424231542 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "hw/irq.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 153a74c98c..6a64eb31ab 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -16,6 +16,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qapi/error.h" #include "e500.h" diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 61c63819df..c0accda592 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -48,6 +48,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "hw/ppc/ppc.h" #include "hw/qdev-properties.h" diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 11623e8e67..04f98a4d81 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -26,6 +26,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qapi/error.h" #include "hw/ppc/ppc.h" diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 53a5121cab..14fc9758a9 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qapi/error.h" #include "sysemu/qtest.h" diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index c867e46330..b7249f21cf 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -26,6 +26,7 @@ #include "qemu/units.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/ppc/ppc.h" #include "hw/qdev-properties.h" diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 74028dc986..665bc1784e 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -15,6 +15,7 @@ #include "qemu/units.h" #include "qemu/error-report.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/error-report.h" #include "net/net.h" #include "hw/pci/pci.h" diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 7e59a91981..14e6583eb0 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/error-report.h" #include "qapi/error.h" #include "hw/boards.h" diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index cd8be98caf..049efa0bbf 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -26,6 +26,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "sysemu/sysemu.h" diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index c790c1113f..7f1bca928c 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "cpu.h" #include "hw/sysbus.h" diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 70a9bf8f5d..d62f3dc758 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -19,6 +19,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "qemu/error-report.h" #include "exec/cpu-defs.h" diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index bddbaffac6..ff6b55e816 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -14,6 +14,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qapi/error.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 1c50b02f81..4bc4ebea84 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -27,6 +27,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/irq.h" #include "qemu/timer.h" diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 0f9cd2bf52..8686371318 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" +#include "qemu/datadir.h" #include "qemu-common.h" #include "cpu.h" #include "hw/sysbus.h" diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 8bee7dd2f4..0fa13a7330 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -27,6 +27,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "cpu.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" diff --git a/include/qemu-common.h b/include/qemu-common.h index fda7dc6ca7..654621444e 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -108,27 +108,6 @@ void qemu_progress_end(void); void qemu_progress_print(float delta, int max); const char *qemu_get_vm_name(void); =20 -#define QEMU_FILE_TYPE_BIOS 0 -#define QEMU_FILE_TYPE_KEYMAP 1 -/** - * qemu_find_file: - * @type: QEMU_FILE_TYPE_BIOS (for BIOS, VGA BIOS) - * or QEMU_FILE_TYPE_KEYMAP (for keymaps). - * @name: Relative or absolute file name - * - * If @name exists on disk as an absolute path, or a path relative - * to the current directory, then returns @name unchanged. - * Otherwise searches for @name file in the data directories, either - * configured at build time (DATADIR) or registered with the -L command - * line option. - * - * The caller must use g_free() to free the returned data when it is - * no longer required. - * - * Returns: a path that can access @name, or NULL if no matching file exis= ts. - */ -char *qemu_find_file(int type, const char *name); - /* OS specific functions */ void os_setup_early_signal_handling(void); int os_parse_cmd_args(int index, const char *optarg); diff --git a/include/qemu/datadir.h b/include/qemu/datadir.h new file mode 100644 index 0000000000..21f9097f58 --- /dev/null +++ b/include/qemu/datadir.h @@ -0,0 +1,28 @@ +#ifndef QEMU_DATADIR_H +#define QEMU_DATADIR_H + +#define QEMU_FILE_TYPE_BIOS 0 +#define QEMU_FILE_TYPE_KEYMAP 1 +/** + * qemu_find_file: + * @type: QEMU_FILE_TYPE_BIOS (for BIOS, VGA BIOS) + * or QEMU_FILE_TYPE_KEYMAP (for keymaps). + * @name: Relative or absolute file name + * + * If @name exists on disk as an absolute path, or a path relative + * to the current directory, then returns @name unchanged. + * Otherwise searches for @name file in the data directories, either + * configured at build time (DATADIR) or registered with the -L command + * line option. + * + * The caller must use g_free() to free the returned data when it is + * no longer required. + * + * Returns: a path that can access @name, or NULL if no matching file exis= ts. + */ +char *qemu_find_file(int type, const char *name); +void qemu_add_default_firmwarepath(void); +void qemu_add_data_dir(char *path); +void qemu_list_data_dirs(void); + +#endif diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 1336b4264a..c94b2e7159 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -13,8 +13,6 @@ extern const char *qemu_name; extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; =20 -void qemu_add_data_dir(char *path); - void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); =20 diff --git a/softmmu/datadir.c b/softmmu/datadir.c new file mode 100644 index 0000000000..504c4665be --- /dev/null +++ b/softmmu/datadir.c @@ -0,0 +1,129 @@ +/* + * QEMU firmware and keymap file search + * + * Copyright (c) 2003-2020 QEMU contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/datadir.h" +#include "qemu/cutils.h" +#include "trace.h" + +static const char *data_dir[16]; +static int data_dir_idx; + +char *qemu_find_file(int type, const char *name) +{ + int i; + const char *subdir; + char *buf; + + /* Try the name as a straight path first */ + if (access(name, R_OK) =3D=3D 0) { + trace_load_file(name, name); + return g_strdup(name); + } + + switch (type) { + case QEMU_FILE_TYPE_BIOS: + subdir =3D ""; + break; + case QEMU_FILE_TYPE_KEYMAP: + subdir =3D "keymaps/"; + break; + default: + abort(); + } + + for (i =3D 0; i < data_dir_idx; i++) { + buf =3D g_strdup_printf("%s/%s%s", data_dir[i], subdir, name); + if (access(buf, R_OK) =3D=3D 0) { + trace_load_file(name, buf); + return buf; + } + g_free(buf); + } + return NULL; +} + +void qemu_add_data_dir(char *path) +{ + int i; + + if (path =3D=3D NULL) { + return; + } + if (data_dir_idx =3D=3D ARRAY_SIZE(data_dir)) { + return; + } + for (i =3D 0; i < data_dir_idx; i++) { + if (strcmp(data_dir[i], path) =3D=3D 0) { + g_free(path); /* duplicate */ + return; + } + } + data_dir[data_dir_idx++] =3D path; +} + +/* + * Find a likely location for support files using the location of the bina= ry. + * When running from the build tree this will be "$bindir/pc-bios". + * Otherwise, this is CONFIG_QEMU_DATADIR (possibly relocated). + * + * The caller must use g_free() to free the returned data when it is + * no longer required. + */ +static char *find_datadir(void) +{ + g_autofree char *dir =3D NULL; + + dir =3D g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL); + if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { + return g_steal_pointer(&dir); + } + + return get_relocated_path(CONFIG_QEMU_DATADIR); +} + +void qemu_add_default_firmwarepath(void) +{ + char **dirs; + size_t i; + + /* add configured firmware directories */ + dirs =3D g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S= , 0); + for (i =3D 0; dirs[i] !=3D 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()); +} + +void qemu_list_data_dirs(void) +{ + int i; + for (i =3D 0; i < data_dir_idx; i++) { + printf("%s\n", data_dir[i]); + } +} diff --git a/softmmu/meson.build b/softmmu/meson.build index 8f7210b4f0..7b52339e7a 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -3,6 +3,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'balloon.c', 'cpus.c', 'cpu-throttle.c', + 'datadir.c', 'physmem.c', 'ioport.c', 'memory.c', diff --git a/softmmu/vl.c b/softmmu/vl.c index 0ba1fcdb3d..86ace29f98 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "qemu/units.h" #include "hw/boards.h" #include "hw/qdev-properties.h" @@ -128,8 +129,6 @@ typedef struct BlockdevOptionsQueueEntry { typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) BlockdevOptionsQueue; =20 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; @@ -1975,59 +1974,6 @@ static void parse_display(const char *p) } } =20 -char *qemu_find_file(int type, const char *name) -{ - int i; - const char *subdir; - char *buf; - - /* Try the name as a straight path first */ - if (access(name, R_OK) =3D=3D 0) { - trace_load_file(name, name); - return g_strdup(name); - } - - switch (type) { - case QEMU_FILE_TYPE_BIOS: - subdir =3D ""; - break; - case QEMU_FILE_TYPE_KEYMAP: - subdir =3D "keymaps/"; - break; - default: - abort(); - } - - for (i =3D 0; i < data_dir_idx; i++) { - buf =3D g_strdup_printf("%s/%s%s", data_dir[i], subdir, name); - if (access(buf, R_OK) =3D=3D 0) { - trace_load_file(name, buf); - return buf; - } - g_free(buf); - } - return NULL; -} - -void qemu_add_data_dir(char *path) -{ - int i; - - if (path =3D=3D NULL) { - return; - } - if (data_dir_idx =3D=3D ARRAY_SIZE(data_dir)) { - return; - } - for (i =3D 0; i < data_dir_idx; i++) { - if (strcmp(data_dir[i], path) =3D=3D 0) { - g_free(path); /* duplicate */ - return; - } - } - data_dir[data_dir_idx++] =3D path; -} - static inline bool nonempty_str(const char *str) { return str && *str; @@ -3156,26 +3102,6 @@ static void create_default_memdev(MachineState *ms, = const char *path) &error_fatal); } =20 -/* - * Find a likely location for support files using the location of the bina= ry. - * When running from the build tree this will be "$bindir/pc-bios". - * Otherwise, this is CONFIG_QEMU_DATADIR (possibly relocated). - * - * The caller must use g_free() to free the returned data when it is - * no longer required. - */ -static char *find_datadir(void) -{ - g_autofree char *dir =3D NULL; - - dir =3D g_build_filename(qemu_get_exec_dir(), "pc-bios", NULL); - if (g_file_test(dir, G_FILE_TEST_IS_DIR)) { - return g_steal_pointer(&dir); - } - - return get_relocated_path(CONFIG_QEMU_DATADIR); -} - static void qemu_validate_options(void) { QemuOpts *machine_opts =3D qemu_get_machine_opts(); @@ -3234,9 +3160,6 @@ static void qemu_process_sugar_options(void) =20 static void qemu_process_early_options(void) { - char **dirs; - int i; - #ifdef CONFIG_SECCOMP QemuOptsList *olist =3D qemu_find_opts_err("sandbox", NULL); if (olist) { @@ -3274,21 +3197,11 @@ static void qemu_process_early_options(void) qemu_set_log(0); } =20 - /* add configured firmware directories */ - dirs =3D g_strsplit(CONFIG_QEMU_FIRMWAREPATH, G_SEARCHPATH_SEPARATOR_S= , 0); - for (i =3D 0; dirs[i] !=3D 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()); + qemu_add_default_firmwarepath(); } =20 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 machi= ne @@ -3307,9 +3220,7 @@ static void qemu_process_help_options(void) =20 /* -L help lists the data directories and exits. */ if (list_data_dirs) { - for (i =3D 0; i < data_dir_idx; i++) { - printf("%s\n", data_dir[i]); - } + qemu_list_data_dirs(); exit(0); } } diff --git a/tests/qtest/fuzz/fuzz.c b/tests/qtest/fuzz/fuzz.c index 7be7226bc0..238866a037 100644 --- a/tests/qtest/fuzz/fuzz.c +++ b/tests/qtest/fuzz/fuzz.c @@ -15,6 +15,7 @@ =20 #include =20 +#include "qemu/datadir.h" #include "sysemu/qtest.h" #include "sysemu/runstate.h" #include "sysemu/sysemu.h" diff --git a/ui/keymaps.c b/ui/keymaps.c index 4e5fca57a8..d4a647464b 100644 --- a/ui/keymaps.c +++ b/ui/keymaps.c @@ -24,6 +24,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/datadir.h" #include "keymaps.h" #include "trace.h" #include "qemu/ctype.h" --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142253; cv=none; d=zohomail.com; s=zohoarc; b=hREkmAj+81v/3i76wEaAI3SGkbnNWqDRZDCeeA1rL4aKnMdOsFau8YjUOBeFdrQ6DyBp3+rI1KN+m3JQGO3o5R00ypr4YyvORROIM4291SkqPNojNFyRLRuRqUPuSPCWnkfw/ZzYouhcmQd8yFK43z4YFDpAGEovKbxL5G/+85A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142253; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pq/ZnvvCO6MBzWiF2YzPTUcG77dSzqjhU5UWxsruWtM=; b=IbKSgB/ApwDaXGf6k+ECEDmEnhe4LO9lxmBYt7C/qasI4IkA+Qx5ESh70SGUMFKE8KOBlhNnWcPuJ9rMokTz4ypsEzgQoKrcqJM3t0K4YSEiU8BPHpfmry6WgddlfDZC6iTeuW3xw9aekcL8KirQYzaBJtx4eefIDw7ek36GQak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142253486520.3692745122554; Mon, 23 Nov 2020 06:37:33 -0800 (PST) Received: from localhost ([::1]:40250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCyC-0000eX-4l for importer@patchew.org; Mon, 23 Nov 2020 09:37:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36788) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcT-0003KX-Ql for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44403) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcO-0007qG-2k for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:05 -0500 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-540-4rxqOK9MOXaV--4CK-eTDA-1; Mon, 23 Nov 2020 09:14:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B45DF100B715 for ; Mon, 23 Nov 2020 14:14:56 +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 79AF560C66 for ; Mon, 23 Nov 2020 14:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140899; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pq/ZnvvCO6MBzWiF2YzPTUcG77dSzqjhU5UWxsruWtM=; b=LDHU/klI0zrLMoHdV62Lsf6g/6VNbQYK97XR2JricgogCisBjnrJrfw705aHNRiaAHwpXX XSZX1jrN7Ib3SZCIiragTNehT7+QNHgqSaRsDSfY+V1wqNUcBI8EQGpenxECW7UblXTxZf MOBklF7YXGYP1l3h282jJgYIxmpBUbQ= X-MC-Unique: 4rxqOK9MOXaV--4CK-eTDA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 30/36] vl: extract machine done notifiers Date: Mon, 23 Nov 2020 09:14:29 -0500 Message-Id: <20201123141435.2726558-31-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- hw/core/machine.c | 24 ++++++++++++++++++++++++ include/sysemu/sysemu.h | 1 + softmmu/vl.c | 24 ------------------------ 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index a5cfbcc7cb..745531c9d9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1166,6 +1166,30 @@ void machine_run_board_init(MachineState *machine) machine_class->init(machine); } =20 +static NotifierList machine_init_done_notifiers =3D + NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); + +bool machine_init_done; + +void qemu_add_machine_init_done_notifier(Notifier *notify) +{ + notifier_list_add(&machine_init_done_notifiers, notify); + if (machine_init_done) { + notify->notify(notify, NULL); + } +} + +void qemu_remove_machine_init_done_notifier(Notifier *notify) +{ + notifier_remove(notify); +} + +void qemu_run_machine_init_done_notifiers(void) +{ + machine_init_done =3D true; + notifier_list_notify(&machine_init_done_notifiers, NULL); +} + static const TypeInfo machine_info =3D { .name =3D TYPE_MACHINE, .parent =3D TYPE_OBJECT, diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index c94b2e7159..1b62deaf2b 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -18,6 +18,7 @@ void qemu_remove_exit_notifier(Notifier *notify); =20 extern bool machine_init_done; =20 +void qemu_run_machine_init_done_notifiers(void); void qemu_add_machine_init_done_notifier(Notifier *notify); void qemu_remove_machine_init_done_notifier(Notifier *notify); =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index 86ace29f98..7e13bb4a59 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -204,9 +204,6 @@ bool qemu_uuid_set; static NotifierList exit_notifiers =3D NOTIFIER_LIST_INITIALIZER(exit_notifiers); =20 -static NotifierList machine_init_done_notifiers =3D - NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); - uint32_t xen_domid; enum xen_mode xen_mode =3D XEN_EMULATE; bool xen_domid_restrict; @@ -2432,27 +2429,6 @@ static void qemu_unlink_pidfile(Notifier *n, void *d= ata) } } =20 -bool machine_init_done; - -void qemu_add_machine_init_done_notifier(Notifier *notify) -{ - notifier_list_add(&machine_init_done_notifiers, notify); - if (machine_init_done) { - notify->notify(notify, NULL); - } -} - -void qemu_remove_machine_init_done_notifier(Notifier *notify) -{ - notifier_remove(notify); -} - -static void qemu_run_machine_init_done_notifiers(void) -{ - machine_init_done =3D true; - notifier_list_notify(&machine_init_done_notifiers, NULL); -} - static const QEMUOption *lookup_opt(int argc, char **argv, const char **poptarg, int *poptind) { --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141601; cv=none; d=zohomail.com; s=zohoarc; b=XuxA9MwmZJpNQ13AIdwzeeShGrXKrDVmLf2ah/VDHsw+wdrTGO/BUq0DQT4XoR6k2EM7qDg86W7C4HheKNwiVl3fC8LT5SUAPi3MfyyHfnuS0JVxuDxcnztlKtqd3kSiHM1S8NsB53wMviJF0lDXLxH5OuJKprcWpPhTYfLI+bY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141601; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/LrjPuQtf7rK20LIq8KhnIdXuMU57tW4rSOXbF5Q3Hg=; b=Qv/VILQfZ19U3OtB1DrCAguyPAeiT3iBwT3efELutl4Se04H1HtwYqmU8gAbfX8xMw9VcJjDTtPodMwXNKRMsNwcE1OFULdEZVfQlEqYb96b2MXBQqJVhVNqjHuBnmcf0A+awk/ELCBLeB26Pn+nXNRoCpNByRKJauYB8/4eLvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141601281172.8404672569127; Mon, 23 Nov 2020 06:26:41 -0800 (PST) Received: from localhost ([::1]:34692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCnf-0003AZ-BZ for importer@patchew.org; Mon, 23 Nov 2020 09:26:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcV-0003NZ-7g for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcO-0007qy-Ui for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:06 -0500 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-269-2O8mEB1INKKKMP2Ii0O0ZA-1; Mon, 23 Nov 2020 09:14:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D4745212 for ; Mon, 23 Nov 2020 14:14:57 +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 D60C160C66 for ; Mon, 23 Nov 2020 14:14:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/LrjPuQtf7rK20LIq8KhnIdXuMU57tW4rSOXbF5Q3Hg=; b=AHmxHvqzeLQtXx8fyHa6ncIlR82xGDkLWvm3VFrqmC4/HST91XcW7CchLjIfnVYRiqiqHB JY6od730wzry5vd6Yi9wBVzdjw1DWDm7aXaA9j3HfYB/jxi13+0AXt9rQOmEqhkgsl7Y4N fZ5rc0ty3EQCW8dzUbhs4UN4LwaTtV4= X-MC-Unique: 2O8mEB1INKKKMP2Ii0O0ZA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 31/36] vl: extract softmmu/rtc.c Date: Mon, 23 Nov 2020 09:14:30 -0500 Message-Id: <20201123141435.2726558-32-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- include/sysemu/sysemu.h | 2 + softmmu/meson.build | 1 + softmmu/rtc.c | 190 ++++++++++++++++++++++++++++++++++++++++ softmmu/vl.c | 156 --------------------------------- 4 files changed, 193 insertions(+), 156 deletions(-) create mode 100644 softmmu/rtc.c diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 1b62deaf2b..18cf586cd0 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -22,6 +22,8 @@ void qemu_run_machine_init_done_notifiers(void); void qemu_add_machine_init_done_notifier(Notifier *notify); void qemu_remove_machine_init_done_notifier(Notifier *notify); =20 +void configure_rtc(QemuOpts *opts); + extern int autostart; =20 typedef enum { diff --git a/softmmu/meson.build b/softmmu/meson.build index 7b52339e7a..d098d89653 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -6,6 +6,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'datadir.c', 'physmem.c', 'ioport.c', + 'rtc.c', 'memory.c', 'memory_mapping.c', 'qtest.c', diff --git a/softmmu/rtc.c b/softmmu/rtc.c new file mode 100644 index 0000000000..e1e15ef613 --- /dev/null +++ b/softmmu/rtc.c @@ -0,0 +1,190 @@ +/* + * RTC configuration and clock read + * + * Copyright (c) 2003-2020 QEMU contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/cutils.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" +#include "qemu/error-report.h" +#include "qemu/option.h" +#include "qemu/timer.h" +#include "qom/object.h" +#include "sysemu/replay.h" +#include "sysemu/sysemu.h" + +static enum { + RTC_BASE_UTC, + RTC_BASE_LOCALTIME, + RTC_BASE_DATETIME, +} rtc_base_type =3D RTC_BASE_UTC; +static time_t rtc_ref_start_datetime; +static int rtc_realtime_clock_offset; /* used only with QEMU_CLOCK_REALTIM= E */ +static int rtc_host_datetime_offset =3D -1; /* valid & used only with + RTC_BASE_DATETIME */ +QEMUClockType rtc_clock; +/***********************************************************/ +/* RTC reference time/date access */ +static time_t qemu_ref_timedate(QEMUClockType clock) +{ + time_t value =3D qemu_clock_get_ms(clock) / 1000; + switch (clock) { + case QEMU_CLOCK_REALTIME: + value -=3D rtc_realtime_clock_offset; + /* fall through */ + case QEMU_CLOCK_VIRTUAL: + value +=3D rtc_ref_start_datetime; + break; + case QEMU_CLOCK_HOST: + if (rtc_base_type =3D=3D RTC_BASE_DATETIME) { + value -=3D rtc_host_datetime_offset; + } + break; + default: + assert(0); + } + return value; +} + +void qemu_get_timedate(struct tm *tm, int offset) +{ + time_t ti =3D qemu_ref_timedate(rtc_clock); + + ti +=3D offset; + + switch (rtc_base_type) { + case RTC_BASE_DATETIME: + case RTC_BASE_UTC: + gmtime_r(&ti, tm); + break; + case RTC_BASE_LOCALTIME: + localtime_r(&ti, tm); + break; + } +} + +int qemu_timedate_diff(struct tm *tm) +{ + time_t seconds; + + switch (rtc_base_type) { + case RTC_BASE_DATETIME: + case RTC_BASE_UTC: + seconds =3D mktimegm(tm); + break; + case RTC_BASE_LOCALTIME: + { + struct tm tmp =3D *tm; + tmp.tm_isdst =3D -1; /* use timezone to figure it out */ + seconds =3D mktime(&tmp); + break; + } + default: + abort(); + } + + return seconds - qemu_ref_timedate(QEMU_CLOCK_HOST); +} + +static void configure_rtc_base_datetime(const char *startdate) +{ + time_t rtc_start_datetime; + struct tm tm; + + if (sscanf(startdate, "%d-%d-%dT%d:%d:%d", &tm.tm_year, &tm.tm_mon, + &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) =3D=3D 6)= { + /* OK */ + } else if (sscanf(startdate, "%d-%d-%d", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday) =3D=3D 3) { + tm.tm_hour =3D 0; + tm.tm_min =3D 0; + tm.tm_sec =3D 0; + } else { + goto date_fail; + } + tm.tm_year -=3D 1900; + tm.tm_mon--; + rtc_start_datetime =3D mktimegm(&tm); + if (rtc_start_datetime =3D=3D -1) { + date_fail: + error_report("invalid datetime format"); + error_printf("valid formats: " + "'2006-06-17T16:01:21' or '2006-06-17'\n"); + exit(1); + } + rtc_host_datetime_offset =3D rtc_ref_start_datetime - rtc_start_dateti= me; + rtc_ref_start_datetime =3D rtc_start_datetime; +} + +void configure_rtc(QemuOpts *opts) +{ + const char *value; + + /* Set defaults */ + rtc_clock =3D QEMU_CLOCK_HOST; + rtc_ref_start_datetime =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) / 1000; + rtc_realtime_clock_offset =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) /= 1000; + + value =3D qemu_opt_get(opts, "base"); + if (value) { + if (!strcmp(value, "utc")) { + rtc_base_type =3D RTC_BASE_UTC; + } else if (!strcmp(value, "localtime")) { + Error *blocker =3D NULL; + rtc_base_type =3D RTC_BASE_LOCALTIME; + error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, + "-rtc base=3Dlocaltime"); + replay_add_blocker(blocker); + } else { + rtc_base_type =3D RTC_BASE_DATETIME; + configure_rtc_base_datetime(value); + } + } + value =3D qemu_opt_get(opts, "clock"); + if (value) { + if (!strcmp(value, "host")) { + rtc_clock =3D QEMU_CLOCK_HOST; + } else if (!strcmp(value, "rt")) { + rtc_clock =3D QEMU_CLOCK_REALTIME; + } else if (!strcmp(value, "vm")) { + rtc_clock =3D QEMU_CLOCK_VIRTUAL; + } else { + error_report("invalid option value '%s'", value); + exit(1); + } + } + value =3D qemu_opt_get(opts, "driftfix"); + if (value) { + if (!strcmp(value, "slew")) { + object_register_sugar_prop("mc146818rtc", + "lost_tick_policy", + "slew"); + } else if (!strcmp(value, "none")) { + /* discard is default */ + } else { + error_report("invalid option value '%s'", value); + exit(1); + } + } +} diff --git a/softmmu/vl.c b/softmmu/vl.c index 7e13bb4a59..c9bb205c42 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -152,16 +152,6 @@ bool enable_cpu_pm =3D false; int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart =3D 1; -static enum { - RTC_BASE_UTC, - RTC_BASE_LOCALTIME, - RTC_BASE_DATETIME, -} rtc_base_type =3D RTC_BASE_UTC; -static time_t rtc_ref_start_datetime; -static int rtc_realtime_clock_offset; /* used only with QEMU_CLOCK_REALTIM= E */ -static int rtc_host_datetime_offset =3D -1; /* valid & used only with - RTC_BASE_DATETIME */ -QEMUClockType rtc_clock; int vga_interface_type =3D VGA_NONE; static const char *vga_model =3D NULL; static DisplayOptions dpy; @@ -766,152 +756,6 @@ void qemu_system_vmstop_request(RunState state) qemu_mutex_unlock(&vmstop_lock); qemu_notify_event(); } - -/***********************************************************/ -/* RTC reference time/date access */ -static time_t qemu_ref_timedate(QEMUClockType clock) -{ - time_t value =3D qemu_clock_get_ms(clock) / 1000; - switch (clock) { - case QEMU_CLOCK_REALTIME: - value -=3D rtc_realtime_clock_offset; - /* fall through */ - case QEMU_CLOCK_VIRTUAL: - value +=3D rtc_ref_start_datetime; - break; - case QEMU_CLOCK_HOST: - if (rtc_base_type =3D=3D RTC_BASE_DATETIME) { - value -=3D rtc_host_datetime_offset; - } - break; - default: - assert(0); - } - return value; -} - -void qemu_get_timedate(struct tm *tm, int offset) -{ - time_t ti =3D qemu_ref_timedate(rtc_clock); - - ti +=3D offset; - - switch (rtc_base_type) { - case RTC_BASE_DATETIME: - case RTC_BASE_UTC: - gmtime_r(&ti, tm); - break; - case RTC_BASE_LOCALTIME: - localtime_r(&ti, tm); - break; - } -} - -int qemu_timedate_diff(struct tm *tm) -{ - time_t seconds; - - switch (rtc_base_type) { - case RTC_BASE_DATETIME: - case RTC_BASE_UTC: - seconds =3D mktimegm(tm); - break; - case RTC_BASE_LOCALTIME: - { - struct tm tmp =3D *tm; - tmp.tm_isdst =3D -1; /* use timezone to figure it out */ - seconds =3D mktime(&tmp); - break; - } - default: - abort(); - } - - return seconds - qemu_ref_timedate(QEMU_CLOCK_HOST); -} - -static void configure_rtc_base_datetime(const char *startdate) -{ - time_t rtc_start_datetime; - struct tm tm; - - if (sscanf(startdate, "%d-%d-%dT%d:%d:%d", &tm.tm_year, &tm.tm_mon, - &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec) =3D=3D 6)= { - /* OK */ - } else if (sscanf(startdate, "%d-%d-%d", - &tm.tm_year, &tm.tm_mon, &tm.tm_mday) =3D=3D 3) { - tm.tm_hour =3D 0; - tm.tm_min =3D 0; - tm.tm_sec =3D 0; - } else { - goto date_fail; - } - tm.tm_year -=3D 1900; - tm.tm_mon--; - rtc_start_datetime =3D mktimegm(&tm); - if (rtc_start_datetime =3D=3D -1) { - date_fail: - error_report("invalid datetime format"); - error_printf("valid formats: " - "'2006-06-17T16:01:21' or '2006-06-17'\n"); - exit(1); - } - rtc_host_datetime_offset =3D rtc_ref_start_datetime - rtc_start_dateti= me; - rtc_ref_start_datetime =3D rtc_start_datetime; -} - -static void configure_rtc(QemuOpts *opts) -{ - const char *value; - - /* Set defaults */ - rtc_clock =3D QEMU_CLOCK_HOST; - rtc_ref_start_datetime =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) / 1000; - rtc_realtime_clock_offset =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME) /= 1000; - - value =3D qemu_opt_get(opts, "base"); - if (value) { - if (!strcmp(value, "utc")) { - rtc_base_type =3D RTC_BASE_UTC; - } else if (!strcmp(value, "localtime")) { - Error *blocker =3D NULL; - rtc_base_type =3D RTC_BASE_LOCALTIME; - error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, - "-rtc base=3Dlocaltime"); - replay_add_blocker(blocker); - } else { - rtc_base_type =3D RTC_BASE_DATETIME; - configure_rtc_base_datetime(value); - } - } - value =3D qemu_opt_get(opts, "clock"); - if (value) { - if (!strcmp(value, "host")) { - rtc_clock =3D QEMU_CLOCK_HOST; - } else if (!strcmp(value, "rt")) { - rtc_clock =3D QEMU_CLOCK_REALTIME; - } else if (!strcmp(value, "vm")) { - rtc_clock =3D QEMU_CLOCK_VIRTUAL; - } else { - error_report("invalid option value '%s'", value); - exit(1); - } - } - value =3D qemu_opt_get(opts, "driftfix"); - if (value) { - if (!strcmp(value, "slew")) { - object_register_sugar_prop("mc146818rtc", - "lost_tick_policy", - "slew"); - } else if (!strcmp(value, "none")) { - /* discard is default */ - } else { - error_report("invalid option value '%s'", value); - exit(1); - } - } -} - static int parse_name(void *opaque, QemuOpts *opts, Error **errp) { const char *proc_name; --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141764; cv=none; d=zohomail.com; s=zohoarc; b=fTJJnXAaRkpizXriLrMRLaiWo2+ilal3Scn6dyXy0GdGcOATC3gEcNwvTvT4Hlx3zNxFjU6lcgB+qjcs1B3+aD8JsfzCxOMZ2mhZ73+wKAdJju9n88Xu+GDu5HOX+4z3phUXPsxOa3huwlHKpMk6NkFQtoJYNI+MJUs4yrT71XM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141764; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TPMJfEdLbeWoj6irPtoSvc8pNo5hxSC4s8vDWSBQg4A=; b=h5Ea5rqyoqGQ/ewTztOfGVTNGXSr/j2YYEu4uwiu8yg/FoZifXP3FxNDOsvDzuCM75i5AJ9eSbgHmYpAqmsjcGEL1j+ww4zSt5SQVzp6Mkzvw0yqRhB0fDsLzopoz7mE54pjLfl/HGNgcivqsJeX0pBsPFhP0pRa8Px4I3DNZlM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160614176452361.00903137825878; Mon, 23 Nov 2020 06:29:24 -0800 (PST) Received: from localhost ([::1]:43438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCqJ-0006oh-1j for importer@patchew.org; Mon, 23 Nov 2020 09:29:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcb-0003ca-6w for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55216) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcP-0007rJ-8u for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:12 -0500 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-582-oYc1pB3pMSegwEtKLApk3w-1; Mon, 23 Nov 2020 09:14:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E8C218B9EDC for ; Mon, 23 Nov 2020 14:14:57 +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 3F5FC60C67 for ; Mon, 23 Nov 2020 14:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140900; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TPMJfEdLbeWoj6irPtoSvc8pNo5hxSC4s8vDWSBQg4A=; b=V+o+PrcV1SyV/NEuOF+jLFziXzohWrFDC/AfLHsgdfpExR2KJQcCQIjPH/nKX7basUzAjH MOPjr341gWA/JVhmmicrUyC60sge6ptKuD2Vc2NpTx/HSTPuwFZCqWj017B2WoaLCbbNSr i2l9J4gIx1uFgEZ4HgEEiimgbPRpqjc= X-MC-Unique: oYc1pB3pMSegwEtKLApk3w-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 32/36] vl: extract softmmu/runstate.c Date: Mon, 23 Nov 2020 09:14:31 -0500 Message-Id: <20201123141435.2726558-33-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Acked-by: Igor Mammedov --- include/sysemu/sysemu.h | 3 + softmmu/meson.build | 1 + softmmu/runstate.c | 800 ++++++++++++++++++++++++++++++++++++++++ softmmu/vl.c | 752 +------------------------------------ 4 files changed, 805 insertions(+), 751 deletions(-) create mode 100644 softmmu/runstate.c diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 18cf586cd0..3dac3229ec 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -24,6 +24,8 @@ void qemu_remove_machine_init_done_notifier(Notifier *not= ify); =20 void configure_rtc(QemuOpts *opts); =20 +void qemu_init_subsystems(void); + extern int autostart; =20 typedef enum { @@ -44,6 +46,7 @@ extern int alt_grab; extern int ctrl_grab; extern int graphic_rotate; extern int no_shutdown; +extern int no_reboot; extern int old_param; extern int boot_menu; extern bool boot_strict; diff --git a/softmmu/meson.build b/softmmu/meson.build index d098d89653..2a73ebc223 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -7,6 +7,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'physmem.c', 'ioport.c', 'rtc.c', + 'runstate.c', 'memory.c', 'memory_mapping.c', 'qtest.c', diff --git a/softmmu/runstate.c b/softmmu/runstate.c new file mode 100644 index 0000000000..892f2f679f --- /dev/null +++ b/softmmu/runstate.c @@ -0,0 +1,800 @@ +/* + * QEMU main system emulation loop + * + * Copyright (c) 2003-2020 QEMU contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "audio/audio.h" +#include "block/block.h" +#include "chardev/char.h" +#include "crypto/cipher.h" +#include "crypto/init.h" +#include "exec/cpu-common.h" +#include "exec/exec-all.h" +#include "exec/gdbstub.h" +#include "hw/boards.h" +#include "migration/misc.h" +#include "migration/postcopy-ram.h" +#include "monitor/monitor.h" +#include "net/net.h" +#include "net/vhost_net.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-run-state.h" +#include "qapi/qapi-events-run-state.h" +#include "qemu-common.h" +#include "qemu/error-report.h" +#include "qemu/job.h" +#include "qemu/module.h" +#include "qemu/plugin.h" +#include "qemu/sockets.h" +#include "qemu/thread.h" +#include "qom/object.h" +#include "qom/object_interfaces.h" +#include "sysemu/cpus.h" +#include "sysemu/qtest.h" +#include "sysemu/replay.h" +#include "sysemu/reset.h" +#include "sysemu/runstate.h" +#include "sysemu/sysemu.h" +#include "sysemu/tpm.h" +#include "trace.h" + +static NotifierList exit_notifiers =3D + NOTIFIER_LIST_INITIALIZER(exit_notifiers); + +static RunState current_run_state =3D RUN_STATE_PRELAUNCH; + +/* We use RUN_STATE__MAX but any invalid value will do */ +static RunState vmstop_requested =3D RUN_STATE__MAX; +static QemuMutex vmstop_lock; + +typedef struct { + RunState from; + RunState to; +} RunStateTransition; + +static const RunStateTransition runstate_transitions_def[] =3D { + { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + + { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, + { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_DEBUG, RUN_STATE_PRELAUNCH }, + + { RUN_STATE_INMIGRATE, RUN_STATE_INTERNAL_ERROR }, + { RUN_STATE_INMIGRATE, RUN_STATE_IO_ERROR }, + { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, + { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, + { RUN_STATE_INMIGRATE, RUN_STATE_SHUTDOWN }, + { RUN_STATE_INMIGRATE, RUN_STATE_SUSPENDED }, + { RUN_STATE_INMIGRATE, RUN_STATE_WATCHDOG }, + { RUN_STATE_INMIGRATE, RUN_STATE_GUEST_PANICKED }, + { RUN_STATE_INMIGRATE, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH }, + { RUN_STATE_INMIGRATE, RUN_STATE_POSTMIGRATE }, + { RUN_STATE_INMIGRATE, RUN_STATE_COLO }, + + { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, + { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PRELAUNCH }, + + { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, + { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_IO_ERROR, RUN_STATE_PRELAUNCH }, + + { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, + { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE }, + { RUN_STATE_PAUSED, RUN_STATE_PRELAUNCH }, + { RUN_STATE_PAUSED, RUN_STATE_COLO}, + + { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, + { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_POSTMIGRATE, RUN_STATE_PRELAUNCH }, + + { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, + { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PRELAUNCH }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO}, + + { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, + { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, + + { RUN_STATE_COLO, RUN_STATE_RUNNING }, + + { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, + { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, + { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR }, + { RUN_STATE_RUNNING, RUN_STATE_PAUSED }, + { RUN_STATE_RUNNING, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_RUNNING, RUN_STATE_RESTORE_VM }, + { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, + { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, + { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, + { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, + { RUN_STATE_RUNNING, RUN_STATE_COLO}, + + { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, + + { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, + { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_SHUTDOWN, RUN_STATE_PRELAUNCH }, + { RUN_STATE_SHUTDOWN, RUN_STATE_COLO }, + + { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED }, + { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED }, + { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING }, + { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_SUSPENDED, RUN_STATE_PRELAUNCH }, + { RUN_STATE_SUSPENDED, RUN_STATE_COLO}, + + { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, + { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_WATCHDOG, RUN_STATE_PRELAUNCH }, + { RUN_STATE_WATCHDOG, RUN_STATE_COLO}, + + { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, + { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, + { RUN_STATE_GUEST_PANICKED, RUN_STATE_PRELAUNCH }, + + { RUN_STATE__MAX, RUN_STATE__MAX }, +}; + +static bool runstate_valid_transitions[RUN_STATE__MAX][RUN_STATE__MAX]; + +bool runstate_check(RunState state) +{ + return current_run_state =3D=3D state; +} + +bool runstate_store(char *str, size_t size) +{ + const char *state =3D RunState_str(current_run_state); + size_t len =3D strlen(state) + 1; + + if (len > size) { + return false; + } + memcpy(str, state, len); + return true; +} + +static void runstate_init(void) +{ + const RunStateTransition *p; + + memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitio= ns)); + for (p =3D &runstate_transitions_def[0]; p->from !=3D RUN_STATE__MAX; = p++) { + runstate_valid_transitions[p->from][p->to] =3D true; + } + + qemu_mutex_init(&vmstop_lock); +} + +/* This function will abort() on invalid state transitions */ +void runstate_set(RunState new_state) +{ + assert(new_state < RUN_STATE__MAX); + + trace_runstate_set(current_run_state, RunState_str(current_run_state), + new_state, RunState_str(new_state)); + + if (current_run_state =3D=3D new_state) { + return; + } + + if (!runstate_valid_transitions[current_run_state][new_state]) { + error_report("invalid runstate transition: '%s' -> '%s'", + RunState_str(current_run_state), + RunState_str(new_state)); + abort(); + } + + current_run_state =3D new_state; +} + +int runstate_is_running(void) +{ + return runstate_check(RUN_STATE_RUNNING); +} + +bool runstate_needs_reset(void) +{ + return runstate_check(RUN_STATE_INTERNAL_ERROR) || + runstate_check(RUN_STATE_SHUTDOWN); +} + +StatusInfo *qmp_query_status(Error **errp) +{ + StatusInfo *info =3D g_malloc0(sizeof(*info)); + + info->running =3D runstate_is_running(); + info->singlestep =3D singlestep; + info->status =3D current_run_state; + + return info; +} + +bool qemu_vmstop_requested(RunState *r) +{ + qemu_mutex_lock(&vmstop_lock); + *r =3D vmstop_requested; + vmstop_requested =3D RUN_STATE__MAX; + qemu_mutex_unlock(&vmstop_lock); + return *r < RUN_STATE__MAX; +} + +void qemu_system_vmstop_request_prepare(void) +{ + qemu_mutex_lock(&vmstop_lock); +} + +void qemu_system_vmstop_request(RunState state) +{ + vmstop_requested =3D state; + qemu_mutex_unlock(&vmstop_lock); + qemu_notify_event(); +} +struct VMChangeStateEntry { + VMChangeStateHandler *cb; + void *opaque; + QTAILQ_ENTRY(VMChangeStateEntry) entries; + int priority; +}; + +static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head =3D + QTAILQ_HEAD_INITIALIZER(vm_change_state_head); + +/** + * qemu_add_vm_change_state_handler_prio: + * @cb: the callback to invoke + * @opaque: user data passed to the callback + * @priority: low priorities execute first when the vm runs and the revers= e is + * true when the vm stops + * + * Register a callback function that is invoked when the vm starts or stops + * running. + * + * Returns: an entry to be freed using qemu_del_vm_change_state_handler() + */ +VMChangeStateEntry *qemu_add_vm_change_state_handler_prio( + VMChangeStateHandler *cb, void *opaque, int priority) +{ + VMChangeStateEntry *e; + VMChangeStateEntry *other; + + e =3D g_malloc0(sizeof(*e)); + e->cb =3D cb; + e->opaque =3D opaque; + e->priority =3D priority; + + /* Keep list sorted in ascending priority order */ + QTAILQ_FOREACH(other, &vm_change_state_head, entries) { + if (priority < other->priority) { + QTAILQ_INSERT_BEFORE(other, e, entries); + return e; + } + } + + QTAILQ_INSERT_TAIL(&vm_change_state_head, e, entries); + return e; +} + +VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler = *cb, + void *opaque) +{ + return qemu_add_vm_change_state_handler_prio(cb, opaque, 0); +} + +void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) +{ + QTAILQ_REMOVE(&vm_change_state_head, e, entries); + g_free(e); +} + +void vm_state_notify(int running, RunState state) +{ + VMChangeStateEntry *e, *next; + + trace_vm_state_notify(running, state, RunState_str(state)); + + if (running) { + QTAILQ_FOREACH_SAFE(e, &vm_change_state_head, entries, next) { + e->cb(e->opaque, running, state); + } + } else { + QTAILQ_FOREACH_REVERSE_SAFE(e, &vm_change_state_head, entries, nex= t) { + e->cb(e->opaque, running, state); + } + } +} + +static ShutdownCause reset_requested; +static ShutdownCause shutdown_requested; +static int shutdown_signal; +static pid_t shutdown_pid; +static int powerdown_requested; +static int debug_requested; +static int suspend_requested; +static WakeupReason wakeup_reason; +static NotifierList powerdown_notifiers =3D + NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); +static NotifierList suspend_notifiers =3D + NOTIFIER_LIST_INITIALIZER(suspend_notifiers); +static NotifierList wakeup_notifiers =3D + NOTIFIER_LIST_INITIALIZER(wakeup_notifiers); +static NotifierList shutdown_notifiers =3D + NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); +static uint32_t wakeup_reason_mask =3D ~(1 << QEMU_WAKEUP_REASON_NONE); + +ShutdownCause qemu_shutdown_requested_get(void) +{ + return shutdown_requested; +} + +ShutdownCause qemu_reset_requested_get(void) +{ + return reset_requested; +} + +static int qemu_shutdown_requested(void) +{ + return qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); +} + +static void qemu_kill_report(void) +{ + if (!qtest_driver() && shutdown_signal) { + if (shutdown_pid =3D=3D 0) { + /* This happens for eg ^C at the terminal, so it's worth + * avoiding printing an odd message in that case. + */ + error_report("terminating on signal %d", shutdown_signal); + } else { + char *shutdown_cmd =3D qemu_get_pid_name(shutdown_pid); + + error_report("terminating on signal %d from pid " FMT_pid " (%= s)", + shutdown_signal, shutdown_pid, + shutdown_cmd ? shutdown_cmd : ""= ); + g_free(shutdown_cmd); + } + shutdown_signal =3D 0; + } +} + +static ShutdownCause qemu_reset_requested(void) +{ + ShutdownCause r =3D reset_requested; + + if (r && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) { + reset_requested =3D SHUTDOWN_CAUSE_NONE; + return r; + } + return SHUTDOWN_CAUSE_NONE; +} + +static int qemu_suspend_requested(void) +{ + int r =3D suspend_requested; + if (r && replay_checkpoint(CHECKPOINT_SUSPEND_REQUESTED)) { + suspend_requested =3D 0; + return r; + } + return false; +} + +static WakeupReason qemu_wakeup_requested(void) +{ + return wakeup_reason; +} + +static int qemu_powerdown_requested(void) +{ + int r =3D powerdown_requested; + powerdown_requested =3D 0; + return r; +} + +static int qemu_debug_requested(void) +{ + int r =3D debug_requested; + debug_requested =3D 0; + return r; +} + +/* + * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE. + */ +void qemu_system_reset(ShutdownCause reason) +{ + MachineClass *mc; + + mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; + + cpu_synchronize_all_states(); + + if (mc && mc->reset) { + mc->reset(current_machine); + } else { + qemu_devices_reset(); + } + if (reason && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { + qapi_event_send_reset(shutdown_caused_by_guest(reason), reason); + } + cpu_synchronize_all_post_reset(); +} + +/* + * Wake the VM after suspend. + */ +static void qemu_system_wakeup(void) +{ + MachineClass *mc; + + mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; + + if (mc && mc->wakeup) { + mc->wakeup(current_machine); + } +} + +void qemu_system_guest_panicked(GuestPanicInformation *info) +{ + qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed"); + + if (current_cpu) { + current_cpu->crash_occurred =3D true; + } + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, + !!info, info); + vm_stop(RUN_STATE_GUEST_PANICKED); + if (!no_shutdown) { + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, + !!info, info); + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC); + } + + if (info) { + if (info->type =3D=3D GUEST_PANIC_INFORMATION_TYPE_HYPER_V) { + qemu_log_mask(LOG_GUEST_ERROR, "\nHV crash parameters: (%#"PRI= x64 + " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n= ", + info->u.hyper_v.arg1, + info->u.hyper_v.arg2, + info->u.hyper_v.arg3, + info->u.hyper_v.arg4, + info->u.hyper_v.arg5); + } else if (info->type =3D=3D GUEST_PANIC_INFORMATION_TYPE_S390) { + qemu_log_mask(LOG_GUEST_ERROR, " on cpu %d: %s\n" + "PSW: 0x%016" PRIx64 " 0x%016" PRIx64"\n", + info->u.s390.core, + S390CrashReason_str(info->u.s390.reason), + info->u.s390.psw_mask, + info->u.s390.psw_addr); + } + qapi_free_GuestPanicInformation(info); + } +} + +void qemu_system_guest_crashloaded(GuestPanicInformation *info) +{ + qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded"); + + qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, + !!info, info); + + if (info) { + qapi_free_GuestPanicInformation(info); + } +} + +void qemu_system_reset_request(ShutdownCause reason) +{ + if (no_reboot && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { + shutdown_requested =3D reason; + } else { + reset_requested =3D reason; + } + cpu_stop_current(); + qemu_notify_event(); +} + +static void qemu_system_suspend(void) +{ + pause_all_vcpus(); + notifier_list_notify(&suspend_notifiers, NULL); + runstate_set(RUN_STATE_SUSPENDED); + qapi_event_send_suspend(); +} + +void qemu_system_suspend_request(void) +{ + if (runstate_check(RUN_STATE_SUSPENDED)) { + return; + } + suspend_requested =3D 1; + cpu_stop_current(); + qemu_notify_event(); +} + +void qemu_register_suspend_notifier(Notifier *notifier) +{ + notifier_list_add(&suspend_notifiers, notifier); +} + +void qemu_system_wakeup_request(WakeupReason reason, Error **errp) +{ + trace_system_wakeup_request(reason); + + if (!runstate_check(RUN_STATE_SUSPENDED)) { + error_setg(errp, + "Unable to wake up: guest is not in suspended state"); + return; + } + if (!(wakeup_reason_mask & (1 << reason))) { + return; + } + runstate_set(RUN_STATE_RUNNING); + wakeup_reason =3D reason; + qemu_notify_event(); +} + +void qemu_system_wakeup_enable(WakeupReason reason, bool enabled) +{ + if (enabled) { + wakeup_reason_mask |=3D (1 << reason); + } else { + wakeup_reason_mask &=3D ~(1 << reason); + } +} + +void qemu_register_wakeup_notifier(Notifier *notifier) +{ + notifier_list_add(&wakeup_notifiers, notifier); +} + +static bool wakeup_suspend_enabled; + +void qemu_register_wakeup_support(void) +{ + wakeup_suspend_enabled =3D true; +} + +bool qemu_wakeup_suspend_enabled(void) +{ + return wakeup_suspend_enabled; +} + +void qemu_system_killed(int signal, pid_t pid) +{ + shutdown_signal =3D signal; + shutdown_pid =3D pid; + no_shutdown =3D 0; + + /* Cannot call qemu_system_shutdown_request directly because + * we are in a signal handler. + */ + shutdown_requested =3D SHUTDOWN_CAUSE_HOST_SIGNAL; + qemu_notify_event(); +} + +void qemu_system_shutdown_request(ShutdownCause reason) +{ + trace_qemu_system_shutdown_request(reason); + replay_shutdown_request(reason); + shutdown_requested =3D reason; + qemu_notify_event(); +} + +static void qemu_system_powerdown(void) +{ + qapi_event_send_powerdown(); + notifier_list_notify(&powerdown_notifiers, NULL); +} + +static void qemu_system_shutdown(ShutdownCause cause) +{ + qapi_event_send_shutdown(shutdown_caused_by_guest(cause), cause); + notifier_list_notify(&shutdown_notifiers, &cause); +} + +void qemu_system_powerdown_request(void) +{ + trace_qemu_system_powerdown_request(); + powerdown_requested =3D 1; + qemu_notify_event(); +} + +void qemu_register_powerdown_notifier(Notifier *notifier) +{ + notifier_list_add(&powerdown_notifiers, notifier); +} + +void qemu_register_shutdown_notifier(Notifier *notifier) +{ + notifier_list_add(&shutdown_notifiers, notifier); +} + +void qemu_system_debug_request(void) +{ + debug_requested =3D 1; + qemu_notify_event(); +} + +static bool main_loop_should_exit(void) +{ + RunState r; + ShutdownCause request; + + if (qemu_debug_requested()) { + vm_stop(RUN_STATE_DEBUG); + } + if (qemu_suspend_requested()) { + qemu_system_suspend(); + } + request =3D qemu_shutdown_requested(); + if (request) { + qemu_kill_report(); + qemu_system_shutdown(request); + if (no_shutdown) { + vm_stop(RUN_STATE_SHUTDOWN); + } else { + return true; + } + } + request =3D qemu_reset_requested(); + if (request) { + pause_all_vcpus(); + qemu_system_reset(request); + resume_all_vcpus(); + /* + * runstate can change in pause_all_vcpus() + * as iothread mutex is unlocked + */ + if (!runstate_check(RUN_STATE_RUNNING) && + !runstate_check(RUN_STATE_INMIGRATE) && + !runstate_check(RUN_STATE_FINISH_MIGRATE)) { + runstate_set(RUN_STATE_PRELAUNCH); + } + } + if (qemu_wakeup_requested()) { + pause_all_vcpus(); + qemu_system_wakeup(); + notifier_list_notify(&wakeup_notifiers, &wakeup_reason); + wakeup_reason =3D QEMU_WAKEUP_REASON_NONE; + resume_all_vcpus(); + qapi_event_send_wakeup(); + } + if (qemu_powerdown_requested()) { + qemu_system_powerdown(); + } + if (qemu_vmstop_requested(&r)) { + vm_stop(r); + } + return false; +} + +void qemu_main_loop(void) +{ +#ifdef CONFIG_PROFILER + int64_t ti; +#endif + while (!main_loop_should_exit()) { +#ifdef CONFIG_PROFILER + ti =3D profile_getclock(); +#endif + main_loop_wait(false); +#ifdef CONFIG_PROFILER + dev_time +=3D profile_getclock() - ti; +#endif + } +} + +void qemu_add_exit_notifier(Notifier *notify) +{ + notifier_list_add(&exit_notifiers, notify); +} + +void qemu_remove_exit_notifier(Notifier *notify) +{ + notifier_remove(notify); +} + +static void qemu_run_exit_notifiers(void) +{ + notifier_list_notify(&exit_notifiers, NULL); +} + +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(); + socket_init(); +} + + +void qemu_cleanup(void) +{ + gdbserver_cleanup(); + + /* + * cleaning up the migration object cancels any existing migration + * try to do this early so that it also stops using devices. + */ + migration_shutdown(); + + /* + * We must cancel all block jobs while the block layer is drained, + * or cancelling will be affected by throttling and thus may block + * for an extended period of time. + * vm_shutdown() will bdrv_drain_all(), so we may as well include + * it in the drained section. + * We do not need to end this section, because we do not want any + * requests happening from here on anyway. + */ + bdrv_drain_all_begin(); + + /* No more vcpu or device emulation activity beyond this point */ + vm_shutdown(); + replay_finish(); + + job_cancel_sync_all(); + bdrv_close_all(); + + /* vhost-user must be cleaned up before chardevs. */ + tpm_cleanup(); + net_cleanup(); + audio_cleanup(); + monitor_cleanup(); + qemu_chr_cleanup(); + user_creatable_cleanup(); + /* TODO: unref root container, check all devices are ok */ +} diff --git a/softmmu/vl.c b/softmmu/vl.c index c9bb205c42..914b86ee86 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -112,7 +112,6 @@ #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" -#include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" #include "sysemu/iothread.h" @@ -164,7 +163,7 @@ Chardev *parallel_hds[MAX_PARALLEL_PORTS]; int win2k_install_hack =3D 0; int singlestep =3D 0; int fd_bootchk =3D 1; -static int no_reboot; +int no_reboot; int no_shutdown =3D 0; int graphic_rotate =3D 0; static const char *watchdog; @@ -191,9 +190,6 @@ static const char *qtest_log; QemuUUID qemu_uuid; bool qemu_uuid_set; =20 -static NotifierList exit_notifiers =3D - NOTIFIER_LIST_INITIALIZER(exit_notifiers); - uint32_t xen_domid; enum xen_mode xen_mode =3D XEN_EMULATE; bool xen_domid_restrict; @@ -535,12 +531,6 @@ const char *qemu_get_vm_name(void) return qemu_name; } =20 -static void res_free(void) -{ - g_free(boot_splash_filedata); - boot_splash_filedata =3D NULL; -} - static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp) { const char *driver =3D qemu_opt_get(opts, "driver"); @@ -556,206 +546,6 @@ static int default_driver_check(void *opaque, QemuOpt= s *opts, Error **errp) return 0; } =20 -/***********************************************************/ -/* QEMU state */ - -static RunState current_run_state =3D RUN_STATE_PRELAUNCH; - -/* We use RUN_STATE__MAX but any invalid value will do */ -static RunState vmstop_requested =3D RUN_STATE__MAX; -static QemuMutex vmstop_lock; - -typedef struct { - RunState from; - RunState to; -} RunStateTransition; - -static const RunStateTransition runstate_transitions_def[] =3D { - { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, - - { RUN_STATE_DEBUG, RUN_STATE_RUNNING }, - { RUN_STATE_DEBUG, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_DEBUG, RUN_STATE_PRELAUNCH }, - - { RUN_STATE_INMIGRATE, RUN_STATE_INTERNAL_ERROR }, - { RUN_STATE_INMIGRATE, RUN_STATE_IO_ERROR }, - { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED }, - { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING }, - { RUN_STATE_INMIGRATE, RUN_STATE_SHUTDOWN }, - { RUN_STATE_INMIGRATE, RUN_STATE_SUSPENDED }, - { RUN_STATE_INMIGRATE, RUN_STATE_WATCHDOG }, - { RUN_STATE_INMIGRATE, RUN_STATE_GUEST_PANICKED }, - { RUN_STATE_INMIGRATE, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_INMIGRATE, RUN_STATE_PRELAUNCH }, - { RUN_STATE_INMIGRATE, RUN_STATE_POSTMIGRATE }, - { RUN_STATE_INMIGRATE, RUN_STATE_COLO }, - - { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED }, - { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PRELAUNCH }, - - { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING }, - { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_IO_ERROR, RUN_STATE_PRELAUNCH }, - - { RUN_STATE_PAUSED, RUN_STATE_RUNNING }, - { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_PAUSED, RUN_STATE_POSTMIGRATE }, - { RUN_STATE_PAUSED, RUN_STATE_PRELAUNCH }, - { RUN_STATE_PAUSED, RUN_STATE_COLO}, - - { RUN_STATE_POSTMIGRATE, RUN_STATE_RUNNING }, - { RUN_STATE_POSTMIGRATE, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_POSTMIGRATE, RUN_STATE_PRELAUNCH }, - - { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, - { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, - - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PRELAUNCH }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO}, - - { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, - { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, - - { RUN_STATE_COLO, RUN_STATE_RUNNING }, - - { RUN_STATE_RUNNING, RUN_STATE_DEBUG }, - { RUN_STATE_RUNNING, RUN_STATE_INTERNAL_ERROR }, - { RUN_STATE_RUNNING, RUN_STATE_IO_ERROR }, - { RUN_STATE_RUNNING, RUN_STATE_PAUSED }, - { RUN_STATE_RUNNING, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_RUNNING, RUN_STATE_RESTORE_VM }, - { RUN_STATE_RUNNING, RUN_STATE_SAVE_VM }, - { RUN_STATE_RUNNING, RUN_STATE_SHUTDOWN }, - { RUN_STATE_RUNNING, RUN_STATE_WATCHDOG }, - { RUN_STATE_RUNNING, RUN_STATE_GUEST_PANICKED }, - { RUN_STATE_RUNNING, RUN_STATE_COLO}, - - { RUN_STATE_SAVE_VM, RUN_STATE_RUNNING }, - - { RUN_STATE_SHUTDOWN, RUN_STATE_PAUSED }, - { RUN_STATE_SHUTDOWN, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_SHUTDOWN, RUN_STATE_PRELAUNCH }, - { RUN_STATE_SHUTDOWN, RUN_STATE_COLO }, - - { RUN_STATE_DEBUG, RUN_STATE_SUSPENDED }, - { RUN_STATE_RUNNING, RUN_STATE_SUSPENDED }, - { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING }, - { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_SUSPENDED, RUN_STATE_PRELAUNCH }, - { RUN_STATE_SUSPENDED, RUN_STATE_COLO}, - - { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING }, - { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_WATCHDOG, RUN_STATE_PRELAUNCH }, - { RUN_STATE_WATCHDOG, RUN_STATE_COLO}, - - { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING }, - { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE }, - { RUN_STATE_GUEST_PANICKED, RUN_STATE_PRELAUNCH }, - - { RUN_STATE__MAX, RUN_STATE__MAX }, -}; - -static bool runstate_valid_transitions[RUN_STATE__MAX][RUN_STATE__MAX]; - -bool runstate_check(RunState state) -{ - return current_run_state =3D=3D state; -} - -bool runstate_store(char *str, size_t size) -{ - const char *state =3D RunState_str(current_run_state); - size_t len =3D strlen(state) + 1; - - if (len > size) { - return false; - } - memcpy(str, state, len); - return true; -} - -static void runstate_init(void) -{ - const RunStateTransition *p; - - memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitio= ns)); - for (p =3D &runstate_transitions_def[0]; p->from !=3D RUN_STATE__MAX; = p++) { - runstate_valid_transitions[p->from][p->to] =3D true; - } - - qemu_mutex_init(&vmstop_lock); -} - -/* This function will abort() on invalid state transitions */ -void runstate_set(RunState new_state) -{ - assert(new_state < RUN_STATE__MAX); - - trace_runstate_set(current_run_state, RunState_str(current_run_state), - new_state, RunState_str(new_state)); - - if (current_run_state =3D=3D new_state) { - return; - } - - if (!runstate_valid_transitions[current_run_state][new_state]) { - error_report("invalid runstate transition: '%s' -> '%s'", - RunState_str(current_run_state), - RunState_str(new_state)); - abort(); - } - - current_run_state =3D new_state; -} - -int runstate_is_running(void) -{ - return runstate_check(RUN_STATE_RUNNING); -} - -bool runstate_needs_reset(void) -{ - return runstate_check(RUN_STATE_INTERNAL_ERROR) || - runstate_check(RUN_STATE_SHUTDOWN); -} - -StatusInfo *qmp_query_status(Error **errp) -{ - StatusInfo *info =3D g_malloc0(sizeof(*info)); - - info->running =3D runstate_is_running(); - info->singlestep =3D singlestep; - info->status =3D current_run_state; - - return info; -} - -bool qemu_vmstop_requested(RunState *r) -{ - qemu_mutex_lock(&vmstop_lock); - *r =3D vmstop_requested; - vmstop_requested =3D RUN_STATE__MAX; - qemu_mutex_unlock(&vmstop_lock); - return *r < RUN_STATE__MAX; -} - -void qemu_system_vmstop_request_prepare(void) -{ - qemu_mutex_lock(&vmstop_lock); -} - -void qemu_system_vmstop_request(RunState state) -{ - vmstop_requested =3D state; - qemu_mutex_unlock(&vmstop_lock); - qemu_notify_event(); -} static int parse_name(void *opaque, QemuOpts *opts, Error **errp) { const char *proc_name; @@ -1072,458 +862,6 @@ static int machine_help_func(QemuOpts *opts, Machine= State *machine) return 1; } =20 -struct VMChangeStateEntry { - VMChangeStateHandler *cb; - void *opaque; - QTAILQ_ENTRY(VMChangeStateEntry) entries; - int priority; -}; - -static QTAILQ_HEAD(, VMChangeStateEntry) vm_change_state_head =3D - QTAILQ_HEAD_INITIALIZER(vm_change_state_head); - -/** - * qemu_add_vm_change_state_handler_prio: - * @cb: the callback to invoke - * @opaque: user data passed to the callback - * @priority: low priorities execute first when the vm runs and the revers= e is - * true when the vm stops - * - * Register a callback function that is invoked when the vm starts or stops - * running. - * - * Returns: an entry to be freed using qemu_del_vm_change_state_handler() - */ -VMChangeStateEntry *qemu_add_vm_change_state_handler_prio( - VMChangeStateHandler *cb, void *opaque, int priority) -{ - VMChangeStateEntry *e; - VMChangeStateEntry *other; - - e =3D g_malloc0(sizeof(*e)); - e->cb =3D cb; - e->opaque =3D opaque; - e->priority =3D priority; - - /* Keep list sorted in ascending priority order */ - QTAILQ_FOREACH(other, &vm_change_state_head, entries) { - if (priority < other->priority) { - QTAILQ_INSERT_BEFORE(other, e, entries); - return e; - } - } - - QTAILQ_INSERT_TAIL(&vm_change_state_head, e, entries); - return e; -} - -VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler = *cb, - void *opaque) -{ - return qemu_add_vm_change_state_handler_prio(cb, opaque, 0); -} - -void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) -{ - QTAILQ_REMOVE(&vm_change_state_head, e, entries); - g_free(e); -} - -void vm_state_notify(int running, RunState state) -{ - VMChangeStateEntry *e, *next; - - trace_vm_state_notify(running, state, RunState_str(state)); - - if (running) { - QTAILQ_FOREACH_SAFE(e, &vm_change_state_head, entries, next) { - e->cb(e->opaque, running, state); - } - } else { - QTAILQ_FOREACH_REVERSE_SAFE(e, &vm_change_state_head, entries, nex= t) { - e->cb(e->opaque, running, state); - } - } -} - -static ShutdownCause reset_requested; -static ShutdownCause shutdown_requested; -static int shutdown_signal; -static pid_t shutdown_pid; -static int powerdown_requested; -static int debug_requested; -static int suspend_requested; -static WakeupReason wakeup_reason; -static NotifierList powerdown_notifiers =3D - NOTIFIER_LIST_INITIALIZER(powerdown_notifiers); -static NotifierList suspend_notifiers =3D - NOTIFIER_LIST_INITIALIZER(suspend_notifiers); -static NotifierList wakeup_notifiers =3D - NOTIFIER_LIST_INITIALIZER(wakeup_notifiers); -static NotifierList shutdown_notifiers =3D - NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); -static uint32_t wakeup_reason_mask =3D ~(1 << QEMU_WAKEUP_REASON_NONE); - -ShutdownCause qemu_shutdown_requested_get(void) -{ - return shutdown_requested; -} - -ShutdownCause qemu_reset_requested_get(void) -{ - return reset_requested; -} - -static int qemu_shutdown_requested(void) -{ - return qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); -} - -static void qemu_kill_report(void) -{ - if (!qtest_driver() && shutdown_signal) { - if (shutdown_pid =3D=3D 0) { - /* This happens for eg ^C at the terminal, so it's worth - * avoiding printing an odd message in that case. - */ - error_report("terminating on signal %d", shutdown_signal); - } else { - char *shutdown_cmd =3D qemu_get_pid_name(shutdown_pid); - - error_report("terminating on signal %d from pid " FMT_pid " (%= s)", - shutdown_signal, shutdown_pid, - shutdown_cmd ? shutdown_cmd : ""= ); - g_free(shutdown_cmd); - } - shutdown_signal =3D 0; - } -} - -static ShutdownCause qemu_reset_requested(void) -{ - ShutdownCause r =3D reset_requested; - - if (r && replay_checkpoint(CHECKPOINT_RESET_REQUESTED)) { - reset_requested =3D SHUTDOWN_CAUSE_NONE; - return r; - } - return SHUTDOWN_CAUSE_NONE; -} - -static int qemu_suspend_requested(void) -{ - int r =3D suspend_requested; - if (r && replay_checkpoint(CHECKPOINT_SUSPEND_REQUESTED)) { - suspend_requested =3D 0; - return r; - } - return false; -} - -static WakeupReason qemu_wakeup_requested(void) -{ - return wakeup_reason; -} - -static int qemu_powerdown_requested(void) -{ - int r =3D powerdown_requested; - powerdown_requested =3D 0; - return r; -} - -static int qemu_debug_requested(void) -{ - int r =3D debug_requested; - debug_requested =3D 0; - return r; -} - -/* - * Reset the VM. Issue an event unless @reason is SHUTDOWN_CAUSE_NONE. - */ -void qemu_system_reset(ShutdownCause reason) -{ - MachineClass *mc; - - mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; - - cpu_synchronize_all_states(); - - if (mc && mc->reset) { - mc->reset(current_machine); - } else { - qemu_devices_reset(); - } - if (reason && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { - qapi_event_send_reset(shutdown_caused_by_guest(reason), reason); - } - cpu_synchronize_all_post_reset(); -} - -/* - * Wake the VM after suspend. - */ -static void qemu_system_wakeup(void) -{ - MachineClass *mc; - - mc =3D current_machine ? MACHINE_GET_CLASS(current_machine) : NULL; - - if (mc && mc->wakeup) { - mc->wakeup(current_machine); - } -} - -void qemu_system_guest_panicked(GuestPanicInformation *info) -{ - qemu_log_mask(LOG_GUEST_ERROR, "Guest crashed"); - - if (current_cpu) { - current_cpu->crash_occurred =3D true; - } - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, - !!info, info); - vm_stop(RUN_STATE_GUEST_PANICKED); - if (!no_shutdown) { - qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_POWEROFF, - !!info, info); - qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_PANIC); - } - - if (info) { - if (info->type =3D=3D GUEST_PANIC_INFORMATION_TYPE_HYPER_V) { - qemu_log_mask(LOG_GUEST_ERROR, "\nHV crash parameters: (%#"PRI= x64 - " %#"PRIx64" %#"PRIx64" %#"PRIx64" %#"PRIx64")\n= ", - info->u.hyper_v.arg1, - info->u.hyper_v.arg2, - info->u.hyper_v.arg3, - info->u.hyper_v.arg4, - info->u.hyper_v.arg5); - } else if (info->type =3D=3D GUEST_PANIC_INFORMATION_TYPE_S390) { - qemu_log_mask(LOG_GUEST_ERROR, " on cpu %d: %s\n" - "PSW: 0x%016" PRIx64 " 0x%016" PRIx64"\n", - info->u.s390.core, - S390CrashReason_str(info->u.s390.reason), - info->u.s390.psw_mask, - info->u.s390.psw_addr); - } - qapi_free_GuestPanicInformation(info); - } -} - -void qemu_system_guest_crashloaded(GuestPanicInformation *info) -{ - qemu_log_mask(LOG_GUEST_ERROR, "Guest crash loaded"); - - qapi_event_send_guest_crashloaded(GUEST_PANIC_ACTION_RUN, - !!info, info); - - if (info) { - qapi_free_GuestPanicInformation(info); - } -} - -void qemu_system_reset_request(ShutdownCause reason) -{ - if (no_reboot && reason !=3D SHUTDOWN_CAUSE_SUBSYSTEM_RESET) { - shutdown_requested =3D reason; - } else { - reset_requested =3D reason; - } - cpu_stop_current(); - qemu_notify_event(); -} - -static void qemu_system_suspend(void) -{ - pause_all_vcpus(); - notifier_list_notify(&suspend_notifiers, NULL); - runstate_set(RUN_STATE_SUSPENDED); - qapi_event_send_suspend(); -} - -void qemu_system_suspend_request(void) -{ - if (runstate_check(RUN_STATE_SUSPENDED)) { - return; - } - suspend_requested =3D 1; - cpu_stop_current(); - qemu_notify_event(); -} - -void qemu_register_suspend_notifier(Notifier *notifier) -{ - notifier_list_add(&suspend_notifiers, notifier); -} - -void qemu_system_wakeup_request(WakeupReason reason, Error **errp) -{ - trace_system_wakeup_request(reason); - - if (!runstate_check(RUN_STATE_SUSPENDED)) { - error_setg(errp, - "Unable to wake up: guest is not in suspended state"); - return; - } - if (!(wakeup_reason_mask & (1 << reason))) { - return; - } - runstate_set(RUN_STATE_RUNNING); - wakeup_reason =3D reason; - qemu_notify_event(); -} - -void qemu_system_wakeup_enable(WakeupReason reason, bool enabled) -{ - if (enabled) { - wakeup_reason_mask |=3D (1 << reason); - } else { - wakeup_reason_mask &=3D ~(1 << reason); - } -} - -void qemu_register_wakeup_notifier(Notifier *notifier) -{ - notifier_list_add(&wakeup_notifiers, notifier); -} - -void qemu_register_wakeup_support(void) -{ - wakeup_suspend_enabled =3D true; -} - -bool qemu_wakeup_suspend_enabled(void) -{ - return wakeup_suspend_enabled; -} - -void qemu_system_killed(int signal, pid_t pid) -{ - shutdown_signal =3D signal; - shutdown_pid =3D pid; - no_shutdown =3D 0; - - /* Cannot call qemu_system_shutdown_request directly because - * we are in a signal handler. - */ - shutdown_requested =3D SHUTDOWN_CAUSE_HOST_SIGNAL; - qemu_notify_event(); -} - -void qemu_system_shutdown_request(ShutdownCause reason) -{ - trace_qemu_system_shutdown_request(reason); - replay_shutdown_request(reason); - shutdown_requested =3D reason; - qemu_notify_event(); -} - -static void qemu_system_powerdown(void) -{ - qapi_event_send_powerdown(); - notifier_list_notify(&powerdown_notifiers, NULL); -} - -static void qemu_system_shutdown(ShutdownCause cause) -{ - qapi_event_send_shutdown(shutdown_caused_by_guest(cause), cause); - notifier_list_notify(&shutdown_notifiers, &cause); -} - -void qemu_system_powerdown_request(void) -{ - trace_qemu_system_powerdown_request(); - powerdown_requested =3D 1; - qemu_notify_event(); -} - -void qemu_register_powerdown_notifier(Notifier *notifier) -{ - notifier_list_add(&powerdown_notifiers, notifier); -} - -void qemu_register_shutdown_notifier(Notifier *notifier) -{ - notifier_list_add(&shutdown_notifiers, notifier); -} - -void qemu_system_debug_request(void) -{ - debug_requested =3D 1; - qemu_notify_event(); -} - -static bool main_loop_should_exit(void) -{ - RunState r; - ShutdownCause request; - - if (qemu_debug_requested()) { - vm_stop(RUN_STATE_DEBUG); - } - if (qemu_suspend_requested()) { - qemu_system_suspend(); - } - request =3D qemu_shutdown_requested(); - if (request) { - qemu_kill_report(); - qemu_system_shutdown(request); - if (no_shutdown) { - vm_stop(RUN_STATE_SHUTDOWN); - } else { - return true; - } - } - request =3D qemu_reset_requested(); - if (request) { - pause_all_vcpus(); - qemu_system_reset(request); - resume_all_vcpus(); - /* - * runstate can change in pause_all_vcpus() - * as iothread mutex is unlocked - */ - if (!runstate_check(RUN_STATE_RUNNING) && - !runstate_check(RUN_STATE_INMIGRATE) && - !runstate_check(RUN_STATE_FINISH_MIGRATE)) { - runstate_set(RUN_STATE_PRELAUNCH); - } - } - if (qemu_wakeup_requested()) { - pause_all_vcpus(); - qemu_system_wakeup(); - notifier_list_notify(&wakeup_notifiers, &wakeup_reason); - wakeup_reason =3D QEMU_WAKEUP_REASON_NONE; - resume_all_vcpus(); - qapi_event_send_wakeup(); - } - if (qemu_powerdown_requested()) { - qemu_system_powerdown(); - } - if (qemu_vmstop_requested(&r)) { - vm_stop(r); - } - return false; -} - -void qemu_main_loop(void) -{ -#ifdef CONFIG_PROFILER - int64_t ti; -#endif - while (!main_loop_should_exit()) { -#ifdef CONFIG_PROFILER - ti =3D profile_getclock(); -#endif - main_loop_wait(false); -#ifdef CONFIG_PROFILER - dev_time +=3D profile_getclock() - ti; -#endif - } -} - static void version(void) { printf("QEMU emulator version " QEMU_FULL_VERSION "\n" @@ -2248,21 +1586,6 @@ static MachineClass *machine_parse(const char *name,= GSList *machines) return mc; } =20 -void qemu_add_exit_notifier(Notifier *notify) -{ - notifier_list_add(&exit_notifiers, notify); -} - -void qemu_remove_exit_notifier(Notifier *notify) -{ - notifier_remove(notify); -} - -static void qemu_run_exit_notifiers(void) -{ - notifier_list_notify(&exit_notifiers, NULL); -} - static const char *pid_file; static Notifier qemu_unlink_pidfile_notifier; =20 @@ -3061,39 +2384,6 @@ static void qemu_maybe_daemonize(const char *pid_fil= e) qemu_add_exit_notifier(&qemu_unlink_pidfile_notifier); } =20 -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(); - socket_init(); -} - static void qemu_init_displays(void) { DisplayState *ds; @@ -4275,43 +3565,3 @@ void qemu_init(int argc, char **argv, char **envp) accel_setup_post(current_machine); os_setup_post(); } - -void qemu_cleanup(void) -{ - gdbserver_cleanup(); - - /* - * cleaning up the migration object cancels any existing migration - * try to do this early so that it also stops using devices. - */ - migration_shutdown(); - - /* - * We must cancel all block jobs while the block layer is drained, - * or cancelling will be affected by throttling and thus may block - * for an extended period of time. - * vm_shutdown() will bdrv_drain_all(), so we may as well include - * it in the drained section. - * We do not need to end this section, because we do not want any - * requests happening from here on anyway. - */ - bdrv_drain_all_begin(); - - /* No more vcpu or device emulation activity beyond this point */ - vm_shutdown(); - replay_finish(); - - job_cancel_sync_all(); - bdrv_close_all(); - - res_free(); - - /* vhost-user must be cleaned up before chardevs. */ - tpm_cleanup(); - net_cleanup(); - audio_cleanup(); - monitor_cleanup(); - qemu_chr_cleanup(); - user_creatable_cleanup(); - /* TODO: unref root container, check all devices are ok */ -} --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606141937; cv=none; d=zohomail.com; s=zohoarc; b=aIJHMfrgjz59gRk09aQRLaFCRAzamI75FIH2xfulrWUoSlvRpHVTOcTBO2kWrBO3gNuixwTK8sfAYMm2rLcdqkqfir/4zYleO8gsbscisIj54ozsZo1f1ZPhLtR2HVM7unzsxIYnUrcfBxpTG2V5d3onAGV719kmnJ/VM3DwMzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606141937; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dtXA58RLDs/Dg0pjN/k8j59gaWEIe3paGmrFfjx2SL0=; b=cQ7PpB328FOToP6on6owyobrXUltGLmSpAVqqnLwceHEI9buHGm8y79zWyuQYufUBxl0R6bbeYcdR8yF17sX2K4Uq7CpF5gZgV/kJqr5LbZrY6EjfS2W+shuiKQ10aSNyMMQi8Me6VL4Ab+Phn4EiSxLZS7WIfJDnc6KvOH02Og= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606141937839959.8891430436139; Mon, 23 Nov 2020 06:32:17 -0800 (PST) Received: from localhost ([::1]:52160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCt5-00022x-Nx for importer@patchew.org; Mon, 23 Nov 2020 09:32:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCdI-0005CY-AX for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCdF-0008Kf-Vn for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:56 -0500 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-281-qs8tcxz4NzORPi8Rg2MKLA-1; Mon, 23 Nov 2020 09:14:58 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAF93805BEE for ; Mon, 23 Nov 2020 14:14:57 +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 AFBB560C66 for ; Mon, 23 Nov 2020 14:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140953; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dtXA58RLDs/Dg0pjN/k8j59gaWEIe3paGmrFfjx2SL0=; b=dFjis6mEzAHaObUJ7BY3C2z5BwbP5IxL4NZ3JtUGv7a88b7IFnPaRyMT3G92VVTq5ruhUP nAv61YIy1Go/IKJTMDE3+QjbjYieJdCBQGR2amP3aFNILYqhtlDaRjNt63zXBlKKQSqsU9 RYb3IJMv9YanIVc2GhoPGutE9/Lf64w= X-MC-Unique: qs8tcxz4NzORPi8Rg2MKLA-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 33/36] vl: extract softmmu/globals.c Date: Mon, 23 Nov 2020 09:14:32 -0500 Message-Id: <20201123141435.2726558-34-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- hw/core/machine.c | 2 ++ include/exec/cpu-common.h | 3 ++ include/exec/exec-all.h | 3 -- softmmu/globals.c | 74 +++++++++++++++++++++++++++++++++++++++ softmmu/meson.build | 1 + softmmu/vl.c | 45 ++---------------------- 6 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 softmmu/globals.c diff --git a/hw/core/machine.c b/hw/core/machine.c index 745531c9d9..5659b1f49c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -213,6 +213,8 @@ GlobalProperty hw_compat_2_1[] =3D { }; const size_t hw_compat_2_1_len =3D G_N_ELEMENTS(hw_compat_2_1); =20 +MachineState *current_machine; + static char *machine_get_kernel(Object *obj, Error **errp) { MachineState *ms =3D MACHINE(obj); diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index bd5e15dd7d..5a0a2d93e0 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -105,4 +105,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t star= t, size_t length); =20 #endif =20 +/* vl.c */ +extern int singlestep; + #endif /* CPU_COMMON_H */ diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 94fe05daaa..fab573da06 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -676,7 +676,4 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu, MemoryRegionSection *section); #endif =20 -/* vl.c */ -extern int singlestep; - #endif diff --git a/softmmu/globals.c b/softmmu/globals.c new file mode 100644 index 0000000000..e62d9cd8da --- /dev/null +++ b/softmmu/globals.c @@ -0,0 +1,74 @@ +/* + * Global variables that (mostly) should not exist + * + * Copyright (c) 2003-2020 QEMU contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include "qemu/osdep.h" +#include "exec/cpu-common.h" +#include "hw/display/vga.h" +#include "hw/i386/pc.h" +#include "hw/i386/x86.h" +#include "hw/loader.h" +#include "hw/xen/xen.h" +#include "net/net.h" +#include "sysemu/cpus.h" +#include "sysemu/sysemu.h" + +enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; +int display_opengl; +const char* keyboard_layout; +bool enable_mlock; +bool enable_cpu_pm; +int nb_nics; +NICInfo nd_table[MAX_NICS]; +int autostart =3D 1; +int vga_interface_type =3D VGA_NONE; +Chardev *parallel_hds[MAX_PARALLEL_PORTS]; +int win2k_install_hack; +int singlestep; +int fd_bootchk =3D 1; +int no_reboot; +int no_shutdown; +int graphic_rotate; +QEMUOptionRom option_rom[MAX_OPTION_ROMS]; +int nb_option_roms; +int old_param; +const char *qemu_name; +int alt_grab; +int ctrl_grab; +unsigned int nb_prom_envs; +const char *prom_envs[MAX_PROM_ENVS]; +int boot_menu; +bool boot_strict; +uint8_t *boot_splash_filedata; +int only_migratable; /* turn it off unless user states otherwise */ +int icount_align_option; + +/* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in = the + * little-endian "wire format" described in the SMBIOS 2.6 specification. + */ +QemuUUID qemu_uuid; +bool qemu_uuid_set; + +uint32_t xen_domid; +enum xen_mode xen_mode =3D XEN_EMULATE; +bool xen_domid_restrict; diff --git a/softmmu/meson.build b/softmmu/meson.build index 2a73ebc223..e5865b97cb 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -4,6 +4,7 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'cpus.c', 'cpu-throttle.c', 'datadir.c', + 'globals.c', 'physmem.c', 'ioport.c', 'rtc.c', diff --git a/softmmu/vl.c b/softmmu/vl.c index 914b86ee86..fce15c249a 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -26,6 +26,7 @@ #include "qemu-common.h" #include "qemu/datadir.h" #include "qemu/units.h" +#include "exec/cpu-common.h" #include "hw/boards.h" #include "hw/qdev-properties.h" #include "qapi/error.h" @@ -67,6 +68,8 @@ #include "qemu/log.h" #include "sysemu/blockdev.h" #include "hw/block/block.h" +#include "hw/i386/x86.h" +#include "hw/i386/pc.h" #include "migration/misc.h" #include "migration/snapshot.h" #include "migration/global_state.h" @@ -141,17 +144,8 @@ static bool preconfig_requested; static QemuPluginList plugin_list =3D QTAILQ_HEAD_INITIALIZER(plugin_list); static BlockdevOptionsQueue bdo_queue =3D QSIMPLEQ_HEAD_INITIALIZER(bdo_qu= eue); static bool nographic =3D false; -enum vga_retrace_method vga_retrace_method =3D VGA_RETRACE_DUMB; static int mem_prealloc; /* force preallocation of physical target memory = */ -int display_opengl; -const char* keyboard_layout =3D NULL; static ram_addr_t ram_size; -bool enable_mlock =3D false; -bool enable_cpu_pm =3D false; -int nb_nics; -NICInfo nd_table[MAX_NICS]; -int autostart =3D 1; -int vga_interface_type =3D VGA_NONE; static const char *vga_model =3D NULL; static DisplayOptions dpy; static int num_serial_hds; @@ -159,41 +153,10 @@ static Chardev **serial_hds; static const char *log_mask; static const char *log_file; static bool list_data_dirs; -Chardev *parallel_hds[MAX_PARALLEL_PORTS]; -int win2k_install_hack =3D 0; -int singlestep =3D 0; -int fd_bootchk =3D 1; -int no_reboot; -int no_shutdown =3D 0; -int graphic_rotate =3D 0; static const char *watchdog; -QEMUOptionRom option_rom[MAX_OPTION_ROMS]; -int nb_option_roms; -int old_param =3D 0; -const char *qemu_name; -int alt_grab =3D 0; -int ctrl_grab =3D 0; -unsigned int nb_prom_envs =3D 0; -const char *prom_envs[MAX_PROM_ENVS]; -int boot_menu; -bool boot_strict; -uint8_t *boot_splash_filedata; -int only_migratable; /* turn it off unless user states otherwise */ -bool wakeup_suspend_enabled; -int icount_align_option; static const char *qtest_chrdev; static const char *qtest_log; =20 -/* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in = the - * little-endian "wire format" described in the SMBIOS 2.6 specification. - */ -QemuUUID qemu_uuid; -bool qemu_uuid_set; - -uint32_t xen_domid; -enum xen_mode xen_mode =3D XEN_EMULATE; -bool xen_domid_restrict; - static int has_defaults =3D 1; static int default_serial =3D 1; static int default_parallel =3D 1; @@ -801,8 +764,6 @@ static int usb_parse(const char *cmdline) /***********************************************************/ /* machine registration */ =20 -MachineState *current_machine; - static MachineClass *find_machine(const char *name, GSList *machines) { GSList *el; --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142128; cv=none; d=zohomail.com; s=zohoarc; b=diZ7kL6RI6B+7MMyBjOGyzCudeFhYsi5kx+X2hqoVPuwFH9Vfi/iSE9xGIPpWR8gaMcF7pizCjzji6peQHzYZemW9+VPYERlj6YfAP3vcy6ZRGDnLZkdIkXr2TCA34dPhk1gbo3TTxVLQVtWMYZLJd2x7dQ8R/o678snYq7SHbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142128; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rxAzQW7QJ8ZspnZy7D74NFQ+Bvg+ZhD+1qJeFzLXxlw=; b=T1gLzIDj5Nkk43Tc43h5gbYLBh15QA4hSU2F2JLODJzwOBa0sdYFZZ+a3cNuEBWs4MrV2FvwsAxK9nSZkmZ11QBv8DUanHom2aqP40dksZjLhhjeF+K8NKG3rqw2ms5dY8/k7WmW06IB4BfKOnYvCvbxXeZtItBYoFo/1mX6UJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142128531374.8338578058689; Mon, 23 Nov 2020 06:35:28 -0800 (PST) Received: from localhost ([::1]:60594 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCwA-0005h1-Aq for importer@patchew.org; Mon, 23 Nov 2020 09:35:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCdn-0005nl-2g for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:16:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20351) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCdl-0008Uf-Cx for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:16:26 -0500 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-517-_8uudI7PMwaNdytvPb4kng-1; Mon, 23 Nov 2020 09:14:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55B18805BEA for ; Mon, 23 Nov 2020 14:14:58 +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 1864160C13 for ; Mon, 23 Nov 2020 14:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rxAzQW7QJ8ZspnZy7D74NFQ+Bvg+ZhD+1qJeFzLXxlw=; b=Su+buW03xcz4zNWOwlPA2PX8hMHCJC0pVI9oR4kdTH0EJUTsqxfso8lkWVY16XQ22Qw6Pc 3grpDgApPKqNIK+Zbg3QcqEGbVcM1s0TwBFs850KyOBfS40UnywDQsY15Z+7BzuBFk9ptH JGE0JallEYB45VjDjJR/gq8kzXwYMxo= X-MC-Unique: _8uudI7PMwaNdytvPb4kng-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 34/36] vl: remove serial_max_hds Date: Mon, 23 Nov 2020 09:14:33 -0500 Message-Id: <20201123141435.2726558-35-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" serial_hd(i) is NULL if and only if i >=3D serial_max_hds(). Test serial_hd(i) instead of bounding the loop at serial_max_hds(), thus removing one more function that vl.c is expected to export. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- hw/ppc/spapr.c | 6 ++---- include/sysemu/sysemu.h | 4 ---- softmmu/vl.c | 5 ----- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 049efa0bbf..b7e0894019 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2878,10 +2878,8 @@ static void spapr_machine_init(MachineState *machine) /* Set up VIO bus */ spapr->vio_bus =3D spapr_vio_bus_init(); =20 - for (i =3D 0; i < serial_max_hds(); i++) { - if (serial_hd(i)) { - spapr_vty_create(spapr->vio_bus, serial_hd(i)); - } + for (i =3D 0; serial_hd(i); i++) { + spapr_vty_create(spapr->vio_bus, serial_hd(i)); } =20 /* We always have at least the nvram device on VIO */ diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 3dac3229ec..0e7b405d22 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -74,10 +74,6 @@ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict= *qdict); =20 /* Return the Chardev for serial port i, or NULL if none */ Chardev *serial_hd(int i); -/* return the number of serial ports defined by the user. serial_hd(i) - * will always return NULL for any i which is greater than or equal to thi= s. - */ -int serial_max_hds(void); =20 /* parallel ports */ =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index fce15c249a..d76f87028d 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1439,11 +1439,6 @@ Chardev *serial_hd(int i) return NULL; } =20 -int serial_max_hds(void) -{ - return num_serial_hds; -} - static int parallel_parse(const char *devname) { static int index =3D 0; --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142600; cv=none; d=zohomail.com; s=zohoarc; b=EzcrfUb4HyYLxbQSjQ4/Z7addoHD6Iwilbg8+VPa9GZYtgLmKGuOSz/L6GVrMBqL8K7kEgf66VTPtc2GX9V4yo9fjySyhT35byBATdiET/n8RIezUnSJn5Yz+rqJvIzWRe3KQXmqkz6Aipn+Q5/TbjGG5OdBVjLDL+oltCSVA4U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142600; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+v7k+u/1BuxYQ9O89C5h4ygnZ/IZtmV8MnoYxWKwlU0=; b=gJ2i68Q7m9YFjtaUvpu3DGS4ai8HjSVtZw830xCXJRrqD6mvy3I2Bm/pcnJmi9ECEsLCptCyHQ3+xlQMImSMh3f2zMZ1Wqgg4tNvcRcY0ALSEYJI3hMdNsP0mzZAvFrLsUcVn3rg/cFh/zDnNcu4hzHGvwVzAkWBPmkBVtWsx/4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142600678131.15545019739739; Mon, 23 Nov 2020 06:43:20 -0800 (PST) Received: from localhost ([::1]:52780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khD3n-00068G-Jd for importer@patchew.org; Mon, 23 Nov 2020 09:43:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:37052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCdS-0005Eh-Us for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:16:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCdQ-0008Ny-QA for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:16:06 -0500 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-407-yBxNn2NEOaSNA9s-4CiZhg-1; Mon, 23 Nov 2020 09:14:59 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B07825221 for ; Mon, 23 Nov 2020 14:14:58 +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 7406D60C13 for ; Mon, 23 Nov 2020 14:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140964; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+v7k+u/1BuxYQ9O89C5h4ygnZ/IZtmV8MnoYxWKwlU0=; b=TaNDxB2BOrSL8DebpERGlFXOJCp3a/tEyNpzOhAILaihs/UZFy/S/UONhHmqzykKjRlhfI Lvs/y7T0dC4XeF6EaCRZWMxL6PAgbuw5AYTxKd0Wj3ZTWbUTS/sevWtEoGwMRjQQrSxRVY sc0oekHQPo27kLvE0HEfeWY5s1FIJ7E= X-MC-Unique: yBxNn2NEOaSNA9s-4CiZhg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 35/36] vl: clean up -boot variables Date: Mon, 23 Nov 2020 09:14:34 -0500 Message-Id: <20201123141435.2726558-36-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move more of them into MachineState, in preparation for moving initializati= on of the machine out of vl.c. Signed-off-by: Paolo Bonzini Reviewed-by: Igor Mammedov --- include/hw/boards.h | 1 + softmmu/vl.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 4537cfb5c6..b9233af54a 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -283,6 +283,7 @@ struct MachineState { ram_addr_t maxram_size; uint64_t ram_slots; const char *boot_order; + const char *boot_once; char *kernel_filename; char *kernel_cmdline; char *initrd_filename; diff --git a/softmmu/vl.c b/softmmu/vl.c index d76f87028d..aeb988bcad 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -132,8 +132,6 @@ typedef QSIMPLEQ_HEAD(, BlockdevOptionsQueueEntry) Bloc= kdevOptionsQueue; =20 static const char *cpu_option; static const char *mem_path; -static const char *boot_order; -static const char *boot_once; static const char *incoming; static const char *loadvm; static ram_addr_t maxram_size; @@ -1733,6 +1731,8 @@ static void qemu_apply_machine_options(void) { MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); QemuOpts *machine_opts =3D qemu_get_machine_opts(); + const char *boot_order =3D NULL; + const char *boot_once =3D NULL; QemuOpts *opts; =20 qemu_opt_foreach(machine_opts, machine_set_property, current_machine, @@ -1762,6 +1762,7 @@ static void qemu_apply_machine_options(void) } =20 current_machine->boot_order =3D boot_order; + current_machine->boot_once =3D boot_once; } =20 static void qemu_create_early_backends(void) @@ -2444,9 +2445,9 @@ static void qemu_machine_creation_done(void) =20 qdev_prop_check_globals(); =20 - if (boot_once) { - qemu_boot_set(boot_once, &error_fatal); - qemu_register_reset(restore_boot_order, g_strdup(boot_order)); + if (current_machine->boot_once) { + qemu_boot_set(current_machine->boot_once, &error_fatal); + qemu_register_reset(restore_boot_order, g_strdup(current_machine->= boot_order)); } =20 if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606142195; cv=none; d=zohomail.com; s=zohoarc; b=kOAtzY6wSPXEsEBv/kvqG0LiMCGGOuQg+R9ySZwA9rGLvXw/pJ5TpKNTC1/Uy3S2U+TStbRE7fwzsdogAJVWeQ1YiGYc0nIXEltYNKUChNO0o7/0d2AsriU2bxGx0eGUy/poMzh/0NQ18IcdWMvvM6aTjyD5s+IdKivC72L5/iA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606142195; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SLZ0uXFwEcjnpLdepRZFkosGAqAjWhR6PGdsLsTLWv4=; b=h+8ARUjZdKNTJaf06DxrzFu5rrR/V/WN6HEeT3IPSLQvn75ndK3d8OD5HNpAkc4bLKGSmbxnJ5riaDB1cjq1ONDWFTiphIfhPpD5r+gTjWsDKbCHmvfOC452j8cgiRv+pzwRhFql5pb3ZcS22k+NwXfB5U9a/jDsjj+FXsYcgO4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606142195258184.7903432925591; Mon, 23 Nov 2020 06:36:35 -0800 (PST) Received: from localhost ([::1]:36388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCxE-0007Se-T8 for importer@patchew.org; Mon, 23 Nov 2020 09:36:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcW-0003Pr-4m for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1khCcQ-0007rl-Lm for qemu-devel@nongnu.org; Mon, 23 Nov 2020 09:15:07 -0500 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-33-U1-S9HfVNt6qnpkh61kwrQ-1; Mon, 23 Nov 2020 09:15:00 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 173B95214 for ; Mon, 23 Nov 2020 14:14:59 +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 D0CFC60C13 for ; Mon, 23 Nov 2020 14:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606140901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SLZ0uXFwEcjnpLdepRZFkosGAqAjWhR6PGdsLsTLWv4=; b=MLjgnufgBTGMGKCYvVijS1pbEMeHMzAKd7qR7M9fwJIUkL58dpu6Bq/FhUptVsUuea6OpJ oIEPp3OrHTchwJPTSAYBydpy5IufN2AE5SOaJTiEHDeeQ7R4+UENY11Y7ai2isk8ABUIPY WTLYjg/15GhH9H+VqmJl+C3MbOIzshQ= X-MC-Unique: U1-S9HfVNt6qnpkh61kwrQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 36/36] vl: move all generic initialization out of vl.c Date: Mon, 23 Nov 2020 09:14:35 -0500 Message-Id: <20201123141435.2726558-37-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" qdev_machine_creation_done is only setting a flag now. Extend it to move more code out of vl.c. Leave only consistency checks and gdbserver processing in qemu_machine_creation_done. gdbserver_start can be moved after qdev_machine_creation_done because it only does listen on the socket and creates some internal data structures; it does not send any data (e.g. guest state) over the socket. Signed-off-by: Paolo Bonzini Reviewed-by:=20 --- hw/core/machine.c | 47 +++++++++++++++++++++++++++++++++++++++++- hw/core/qdev.c | 12 +++-------- include/hw/qdev-core.h | 1 + softmmu/vl.c | 37 +-------------------------------- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 5659b1f49c..025c4f9749 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -16,16 +16,21 @@ #include "sysemu/replay.h" #include "qemu/units.h" #include "hw/boards.h" +#include "hw/loader.h" #include "qapi/error.h" #include "qapi/qapi-visit-common.h" #include "qapi/visitor.h" #include "hw/sysbus.h" +#include "sysemu/cpus.h" #include "sysemu/sysemu.h" +#include "sysemu/reset.h" +#include "sysemu/runstate.h" #include "sysemu/numa.h" #include "qemu/error-report.h" #include "sysemu/qtest.h" #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +#include "migration/global_state.h" #include "migration/vmstate.h" =20 GlobalProperty hw_compat_5_1[] =3D { @@ -1186,10 +1191,50 @@ void qemu_remove_machine_init_done_notifier(Notifie= r *notify) notifier_remove(notify); } =20 -void qemu_run_machine_init_done_notifiers(void) +void qdev_machine_creation_done(void) { + cpu_synchronize_all_post_init(); + + if (current_machine->boot_once) { + qemu_boot_set(current_machine->boot_once, &error_fatal); + qemu_register_reset(restore_boot_order, g_strdup(current_machine->= boot_order)); + } + + /* + * ok, initial machine setup is done, starting from now we can + * only create hotpluggable devices + */ + qdev_hotplug =3D true; + qdev_assert_realized_properly(); + + /* 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()); + machine_init_done =3D true; notifier_list_notify(&machine_init_done_notifiers, NULL); + + if (rom_check_and_register_reset() !=3D 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(); } =20 static const TypeInfo machine_info =3D { diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 262bca716f..bc5df8ce69 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -413,7 +413,7 @@ void qdev_unrealize(DeviceState *dev) object_property_set_bool(OBJECT(dev), "realized", false, &error_abort); } =20 -static int qdev_assert_realized_properly(Object *obj, void *opaque) +static int qdev_assert_realized_properly_cb(Object *obj, void *opaque) { DeviceState *dev =3D DEVICE(object_dynamic_cast(obj, TYPE_DEVICE)); DeviceClass *dc; @@ -426,16 +426,10 @@ static int qdev_assert_realized_properly(Object *obj,= void *opaque) return 0; } =20 -void qdev_machine_creation_done(void) +void qdev_assert_realized_properly(void) { - /* - * ok, initial machine setup is done, starting from now we can - * only create hotpluggable devices - */ - qdev_hotplug =3D true; - object_child_foreach_recursive(object_get_root(), - qdev_assert_realized_properly, NULL); + qdev_assert_realized_properly_cb, NULL); } =20 bool qdev_machine_modified(void) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index b77a2f1da7..6446846752 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -815,6 +815,7 @@ const VMStateDescription *qdev_get_vmsd(DeviceState *de= v); =20 const char *qdev_fw_name(DeviceState *dev); =20 +void qdev_assert_realized_properly(void); Object *qdev_get_machine(void); =20 /* FIXME: make this a link<> */ diff --git a/softmmu/vl.c b/softmmu/vl.c index aeb988bcad..1fde4a17a9 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -72,7 +72,6 @@ #include "hw/i386/pc.h" #include "migration/misc.h" #include "migration/snapshot.h" -#include "migration/global_state.h" #include "sysemu/tpm.h" #include "sysemu/dma.h" #include "hw/audio/soundhw.h" @@ -2426,8 +2425,6 @@ static void qemu_create_cli_devices(void) =20 static void qemu_machine_creation_done(void) { - cpu_synchronize_all_post_init(); - /* Did we create any drives that we failed to create a device for? */ drive_check_orphaned(); =20 @@ -2445,43 +2442,11 @@ static void qemu_machine_creation_done(void) =20 qdev_prop_check_globals(); =20 - if (current_machine->boot_once) { - qemu_boot_set(current_machine->boot_once, &error_fatal); - qemu_register_reset(restore_boot_order, g_strdup(current_machine->= boot_order)); - } - - if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { - exit(1); - } - qdev_machine_creation_done(); =20 - /* 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() !=3D 0) { - error_report("rom check and register reset failed"); + if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) { 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(); } =20 void qmp_x_exit_preconfig(Error **errp) --=20 2.26.2 From nobody Sun May 5 09:50:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606479744; cv=none; d=zohomail.com; s=zohoarc; b=O47UJ1IrBtKRBCLLA/TivzrERQ4xtBxW0T4oW8mBoFRmRDr79YWvia3Z7qkdYeYaTnwqbDfsUWz/ECW3MV3mwy1Pt+aBGq4n2TDRSMnXxfxfNP83+ARjOSWCMnYLL1yOAyE6j6Nkf2otrt5qHSZLxenZ3q4tOYQ+wt46mUFzX7k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606479744; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WftYRWHj8Rb/gn0/VZRcWgh+dko2d0dsJLIa/BQZ+os=; b=Y3C6b5VVnTX4BMsi4I3Y7iQRmGbA/SUGieizY9SpE24Lp0w7E0Wb2FhPNJH24qtpn+BMkQFFxrWhX14XXcdcamjQqzMtJ0nvAVNVVaI0XLJ58xm/LaKyl00Zyj1lU/6wg57tEHWx5pb89h2JCcIZ4V6MCmZmJxs2h2oxldIGb0g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1606479744822246.81126084947346; Fri, 27 Nov 2020 04:22:24 -0800 (PST) Received: from localhost ([::1]:58248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kicS0-0003pJ-Ol for importer@patchew.org; Fri, 27 Nov 2020 07:02:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kicQd-0003I3-48 for qemu-devel@nongnu.org; Fri, 27 Nov 2020 07:00:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47017) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kicQO-0001yQ-Lw for qemu-devel@nongnu.org; Fri, 27 Nov 2020 07:00:42 -0500 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-271-kTFuWI72MzSNul4_h8cdWg-1; Fri, 27 Nov 2020 07:00:23 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 25963185E49B for ; Fri, 27 Nov 2020 12:00: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 D92C95D9CC; Fri, 27 Nov 2020 12:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606478425; 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=WftYRWHj8Rb/gn0/VZRcWgh+dko2d0dsJLIa/BQZ+os=; b=PfpzZ7J1aB0YQ5Gsey12gf/mWWcmBEu7m94zksQWQJ9FsSBGKPOrB2bFDiReN+AW94vVCU ZsrluVTPBRMzcWrwNu0F75jRFlp6zjtKfwhHu929kndld2TtozWHPVr0Ivbc+C9zzzuEFP wDUMBxFbl2Kkznz157RxvUbS+bwa1Ks= X-MC-Unique: kTFuWI72MzSNul4_h8cdWg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PATCH 37/36] machine: introduce MachineInitPhase Date: Fri, 27 Nov 2020 07:00:21 -0500 Message-Id: <20201127120021.3221679-1-pbonzini@redhat.com> In-Reply-To: <20201123141435.2726558-1-pbonzini@redhat.com> References: <20201123141435.2726558-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H3=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: imammedo@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Generalize the qdev_hotplug variable to the different phases of machine initialization. We would like to allow different monitor commands depending on the phase. Signed-off-by: Paolo Bonzini --- This has to be the last patch because patch 36 is where hw/core/machine.c takes care of setting qdev_hotplug to true. And this explains the weird [PATCH 00/37] in the previous version of the RFC. :) hw/core/machine-qmp-cmds.c | 6 +++--- hw/core/machine.c | 3 ++- hw/core/qdev.c | 16 ++++++++++++++-- hw/pci/pci.c | 2 +- hw/usb/core.c | 2 +- hw/virtio/virtio-iommu.c | 2 +- include/hw/qdev-core.h | 12 +++++++++++- monitor/hmp.c | 2 +- softmmu/qdev-monitor.c | 24 +++++++++++++----------- softmmu/vl.c | 4 +++- ui/console.c | 2 +- 11 files changed, 51 insertions(+), 24 deletions(-) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index cb9387c5f5..6cbeb688c4 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -286,9 +286,9 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error = **errp) =20 void qmp_set_numa_node(NumaOptions *cmd, Error **errp) { - if (qdev_hotplug) { - error_setg(errp, "The command is permitted only before the machin= e has been created"); - return; + if (phase_check(PHASE_MACHINE_READY)) { + error_setg(errp, "The command is permitted only before the machine= has been created"); + return; } =20 set_numa_options(MACHINE(qdev_get_machine()), cmd, errp); diff --git a/hw/core/machine.c b/hw/core/machine.c index 025c4f9749..a71cb23ecf 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1171,6 +1171,7 @@ void machine_run_board_init(MachineState *machine) } =20 machine_class->init(machine); + phase_advance(PHASE_MACHINE_INITIALIZED); } =20 static NotifierList machine_init_done_notifiers =3D @@ -1204,7 +1205,7 @@ void qdev_machine_creation_done(void) * ok, initial machine setup is done, starting from now we can * only create hotpluggable devices */ - qdev_hotplug =3D true; + phase_advance(PHASE_MACHINE_READY); qdev_assert_realized_properly(); =20 /* TODO: once all bus devices are qdevified, this should be done diff --git a/hw/core/qdev.c b/hw/core/qdev.c index bc5df8ce69..beb35879c6 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -41,7 +41,6 @@ #include "migration/vmstate.h" #include "trace.h" =20 -bool qdev_hotplug =3D false; static bool qdev_hot_added =3D false; bool qdev_hot_removed =3D false; =20 @@ -1023,7 +1022,7 @@ static void device_initfn(Object *obj) { DeviceState *dev =3D DEVICE(obj); =20 - if (qdev_hotplug) { + if (phase_check(PHASE_MACHINE_READY)) { dev->hotplugged =3D 1; qdev_hot_added =3D true; } @@ -1267,6 +1266,19 @@ Object *qdev_get_machine(void) return dev; } =20 +static MachineInitPhase machine_phase; + +bool phase_check(MachineInitPhase phase) +{ + return machine_phase >=3D phase; +} + +void phase_advance(MachineInitPhase phase) +{ + assert(machine_phase =3D=3D phase - 1); + machine_phase =3D phase; +} + static const TypeInfo device_type_info =3D { .name =3D TYPE_DEVICE, .parent =3D TYPE_OBJECT, diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 9424231542..d4349ea577 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1062,7 +1062,7 @@ static PCIDevice *do_pci_register_device(PCIDevice *p= ci_dev, address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_container_region, pci_dev->nam= e); =20 - if (qdev_hotplug) { + if (phase_check(PHASE_MACHINE_READY)) { pci_init_bus_master(pci_dev); } pci_dev->irq_state =3D 0; diff --git a/hw/usb/core.c b/hw/usb/core.c index 5234dcc73f..e960036f4d 100644 --- a/hw/usb/core.c +++ b/hw/usb/core.c @@ -97,7 +97,7 @@ void usb_wakeup(USBEndpoint *ep, unsigned int stream) USBDevice *dev =3D ep->dev; USBBus *bus =3D usb_bus_from_device(dev); =20 - if (!qdev_hotplug) { + if (!phase_check(PHASE_MACHINE_READY)) { /* * This is machine init cold plug. No need to wakeup anyone, * all devices will be reset anyway. And trying to wakeup can diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index fc5c75d693..8370fd80d7 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -928,7 +928,7 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryR= egion *mr, * accept it. Having a different masks is possible but the guest will = use * sub-optimal block sizes, so warn about it. */ - if (qdev_hotplug) { + if (phase_check(PHASE_MACHINE_READY)) { int new_granule =3D ctz64(new_mask); int cur_granule =3D ctz64(cur_mask); =20 diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 6446846752..05e7e7bc45 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -821,7 +821,6 @@ Object *qdev_get_machine(void); /* FIXME: make this a link<> */ bool qdev_set_parent_bus(DeviceState *dev, BusState *bus, Error **errp); =20 -extern bool qdev_hotplug; extern bool qdev_hot_removed; =20 char *qdev_get_dev_path(DeviceState *dev); @@ -847,4 +846,15 @@ void device_listener_unregister(DeviceListener *listen= er); */ bool qdev_should_hide_device(QemuOpts *opts); =20 +typedef enum MachineInitPhase { + PHASE_NO_MACHINE, + PHASE_MACHINE_CREATED, + PHASE_ACCEL_CREATED, + PHASE_MACHINE_INITIALIZED, + PHASE_MACHINE_READY, +} MachineInitPhase; + +extern bool phase_check(MachineInitPhase phase); +extern void phase_advance(MachineInitPhase phase); + #endif diff --git a/monitor/hmp.c b/monitor/hmp.c index f2fe192d69..6c0b33a0b1 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -216,7 +216,7 @@ static bool cmd_can_preconfig(const HMPCommand *cmd) =20 static bool cmd_available(const HMPCommand *cmd) { - return qdev_hotplug || cmd_can_preconfig(cmd); + return phase_check(PHASE_MACHINE_READY) || cmd_can_preconfig(cmd); } =20 static void help_cmd_dump_one(Monitor *mon, diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c index e967d13bd0..184fe317af 100644 --- a/softmmu/qdev-monitor.c +++ b/softmmu/qdev-monitor.c @@ -244,7 +244,7 @@ static DeviceClass *qdev_get_device_class(const char **= driver, Error **errp) =20 dc =3D DEVICE_CLASS(oc); if (!dc->user_creatable || - (qdev_hotplug && !dc->hotpluggable)) { + (phase_check(PHASE_MACHINE_READY) && !dc->hotpluggable)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "driver", "pluggable device type"); return NULL; @@ -637,7 +637,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **er= rp) } hide =3D should_hide_device(opts); =20 - if ((hide || qdev_hotplug) && bus && !qbus_is_hotpluggable(bus)) { + if ((hide || phase_check(PHASE_MACHINE_READY)) && bus && !qbus_is_hotp= luggable(bus)) { error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name); return NULL; } @@ -655,15 +655,17 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **= errp) dev =3D qdev_new(driver); =20 /* Check whether the hotplug is allowed by the machine */ - if (qdev_hotplug && !qdev_hotplug_allowed(dev, errp)) { - goto err_del_dev; - } + if (phase_check(PHASE_MACHINE_READY)) { + if (!qdev_hotplug_allowed(dev, errp)) { + goto err_del_dev; + } =20 - if (!bus && qdev_hotplug && !qdev_get_machine_hotplug_handler(dev)) { - /* No bus, no machine hotplug handler --> device is not hotpluggab= le */ - error_setg(errp, "Device '%s' can not be hotplugged on this machin= e", - driver); - goto err_del_dev; + if (!bus && !qdev_get_machine_hotplug_handler(dev)) { + /* No bus, no machine hotplug handler --> device is not hotplu= ggable */ + error_setg(errp, "Device '%s' can not be hotplugged on this ma= chine", + driver); + goto err_del_dev; + } } =20 qdev_set_id(dev, qemu_opts_id(opts)); @@ -1001,7 +1003,7 @@ int qemu_global_option(const char *str) =20 bool qmp_command_available(const QmpCommand *cmd, Error **errp) { - if (!qdev_hotplug && + if (!phase_check(PHASE_MACHINE_READY) && !(cmd->options & QCO_ALLOW_PRECONFIG)) { error_setg(errp, "The command '%s' is permitted only after machine= initialization has completed", cmd->name); diff --git a/softmmu/vl.c b/softmmu/vl.c index 1fde4a17a9..2dd5c2c775 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2451,7 +2451,7 @@ static void qemu_machine_creation_done(void) =20 void qmp_x_exit_preconfig(Error **errp) { - if (qdev_hotplug) { + if (phase_check(PHASE_MACHINE_READY)) { error_setg(errp, "The command is permitted only before machine ini= tialization"); return; } @@ -3428,12 +3428,14 @@ void qemu_init(int argc, char **argv, char **envp) qemu_create_early_backends(); =20 qemu_apply_machine_options(); + phase_advance(PHASE_MACHINE_CREATED); =20 /* * Note: uses machine properties such as kernel-irqchip, must run * after machine_set_property(). */ configure_accelerators(argv[0]); + phase_advance(PHASE_ACCEL_CREATED); =20 /* * Beware, QOM objects created before this point miss global and diff --git a/ui/console.c b/ui/console.c index e07d2c380d..3a98135daa 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1343,7 +1343,7 @@ static QemuConsole *new_console(DisplayState *ds, con= sole_type_t console_type, if (QTAILQ_EMPTY(&consoles)) { s->index =3D 0; QTAILQ_INSERT_TAIL(&consoles, s, next); - } else if (console_type !=3D GRAPHIC_CONSOLE || qdev_hotplug) { + } else if (console_type !=3D GRAPHIC_CONSOLE || phase_check(PHASE_MACH= INE_READY)) { QemuConsole *last =3D QTAILQ_LAST(&consoles); s->index =3D last->index + 1; QTAILQ_INSERT_TAIL(&consoles, s, next); --=20 2.26.2