From nobody Tue Feb 10 00:39:55 2026 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=1606898715; cv=none; d=zohomail.com; s=zohoarc; b=c03LIFQaCVocVJC153+UUZ8NVfDhnhXRsX7+5XZIxYSDvQrnInR/5Tr1xraF0ELvUGPqqzH317LLdkXdnlfz8rG94lbRVgmTI4WITtZMkasj7YjuHhMFpg5lRp9qV9ks/GUcyu62CHh8qFA7lrf/PSTDrf6NvkURov2KoZB8fuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606898715; 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=rP6OUvjx4v7+K7ARm6JuYlhQiEZ8+rlZHB8RtHnnsmQ=; b=EYI2rx/uxBfa0qGlSVTIj4b9/uq/Uxc9NpSqdkQpJPS3sq+muetK9ySSIb97UkxfLYrWp4WVD19Oxwy1LXUyO7rTJ8WTbZ7I4m0NtQJn4SZ4+wWEhyMwRcNeny/9eV6SeTtn8zeYn27tM+6pc6wz8irnN3vkhjXx2c4LqjitvBQ= 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 1606898715128508.3837337729108; Wed, 2 Dec 2020 00:45:15 -0800 (PST) Received: from localhost ([::1]:58514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kkNl7-0005I2-GU for importer@patchew.org; Wed, 02 Dec 2020 03:45:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kkND7-0003VL-75 for qemu-devel@nongnu.org; Wed, 02 Dec 2020 03:10:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57168) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kkNCR-0003lm-3A for qemu-devel@nongnu.org; Wed, 02 Dec 2020 03:10: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-308-eeaM1bJ8PFiJX-DlmK_kHQ-1; Wed, 02 Dec 2020 03:09:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A4DE80364D for ; Wed, 2 Dec 2020 08:09:14 +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 5D57610013BD for ; Wed, 2 Dec 2020 08:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606896557; 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=rP6OUvjx4v7+K7ARm6JuYlhQiEZ8+rlZHB8RtHnnsmQ=; b=Vsrti59wfFJn6V0xKJgPst6Trw6UOQWZ4YeXo42OA09627S0qoR4hPsPJ4LDRHEJ6sAipw mJafJp3G994vwFoCq2UWRMEJRbofeoFG+Z/73LR40Hb05+xEf4Q3UJdeGLdrvhM/Kfx/QO QH9UjCygeoZ2Fbc9cvFvxoY9rKmGiiM= X-MC-Unique: eeaM1bJ8PFiJX-DlmK_kHQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 066/113] vl: separate qemu_create_early_backends Date: Wed, 2 Dec 2020 03:08:02 -0500 Message-Id: <20201202080849.4125477-67-pbonzini@redhat.com> In-Reply-To: <20201202080849.4125477-1-pbonzini@redhat.com> References: <20201202080849.4125477-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: -35 X-Spam_score: -3.6 X-Spam_bar: --- X-Spam_report: (-3.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.497, 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" "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 91ef21833b..aafcbec356 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) { @@ -2644,7 +2646,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); @@ -2700,6 +2702,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 @@ -2707,7 +2761,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 @@ -3313,7 +3367,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; @@ -3326,7 +3379,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); @@ -4298,52 +4350,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