From nobody Mon Feb 9 08:33:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644334972275430.255399095582; Tue, 8 Feb 2022 07:42:52 -0800 (PST) Received: from localhost ([::1]:33076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHSdm-0005Rt-Q0 for importer@patchew.org; Tue, 08 Feb 2022 10:42:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHRjy-00048d-3q for qemu-devel@nongnu.org; Tue, 08 Feb 2022 09:45:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:40829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHRju-0001e2-1f for qemu-devel@nongnu.org; Tue, 08 Feb 2022 09:45:07 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-13-bQzuuVkONeuoAWrQeK1uDg-1; Tue, 08 Feb 2022 09:45:02 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D437F1091DAE; Tue, 8 Feb 2022 14:45:00 +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 46D2E7DE42; Tue, 8 Feb 2022 14:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644331505; 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=H7JuujSZ9WJvt/byWe9v0f0tYgfBEKts1xVNKYazMLY=; b=Jsx4q0/EbTq6NoFRUcAw46vrpmSSWU1ThdjCZSkyhbS6iXZsMcU217opGnIXCmaDravaI7 H9ECVX+m/w+qX+naozIqxAAxRmy2wC1M35kUQjic5YENFtHKyFmIYnrRY8+Bn2Ot7ofBD1 wIWyDnt0HxLRJJ5u6ilSU+q/LOs1UwM= X-MC-Unique: bQzuuVkONeuoAWrQeK1uDg-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 1/3] migration: allow calling migration_shutdown without a prior initialization Date: Tue, 8 Feb 2022 09:44:56 -0500 Message-Id: <20220208144458.1079634-2-pbonzini@redhat.com> In-Reply-To: <20220208144458.1079634-1-pbonzini@redhat.com> References: <20220208144458.1079634-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, berrange@redhat.com, mark.burton@greensocs.com, armbru@redhat.com, f4bug@amsat.org, mirela.grujic@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644334974353100001 Content-Type: text/plain; charset="utf-8" This can happen with the qemu-qmp binaries. Signed-off-by: Paolo Bonzini --- migration/migration.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index bcc385b94b..075b21d9b5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -226,6 +226,10 @@ void migration_cancel(const Error *error) =20 void migration_shutdown(void) { + if (!current_migration) { + return; + } + /* * When the QEMU main thread exit, the COLO thread * may wait a semaphore. So, we should wakeup the --=20 2.31.1 From nobody Mon Feb 9 08:33:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644335671838107.24111613299203; Tue, 8 Feb 2022 07:54:31 -0800 (PST) Received: from localhost ([::1]:50624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHSp4-0001lQ-Dx for importer@patchew.org; Tue, 08 Feb 2022 10:54:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHRjy-00048u-N4 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 09:45:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHRjv-0001ht-EK for qemu-devel@nongnu.org; Tue, 08 Feb 2022 09:45:09 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-504-khO2MFcTNXuBxLaMHnHFWQ-1; Tue, 08 Feb 2022 09:45:02 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86F7794DD4; Tue, 8 Feb 2022 14:45:01 +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 EEFDB7D3CE; Tue, 8 Feb 2022 14:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644331505; 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=MBLSF4wMVv/UfkJb2xcYNzkciWKslCxtAdXAzNNthZ4=; b=a0U/+b/JKXLcoqFGM6CemBFblRRGYL36w6VLwNrqMtrp4YkhVjf87dnc99fBUTLzeb3Ynk HqtjEofTqCH8oIbLqRREodJX0HiR2NbT+xW+7h/sAc4ndngzR5nZw7/4mYz6AtPnk01dHr dAPr2SGpheR8kDLrv0ZI/e/oorLMec4= X-MC-Unique: khO2MFcTNXuBxLaMHnHFWQ-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 2/3] net: initialize global variables early Date: Tue, 8 Feb 2022 09:44:57 -0500 Message-Id: <20220208144458.1079634-3-pbonzini@redhat.com> In-Reply-To: <20220208144458.1079634-1-pbonzini@redhat.com> References: <20220208144458.1079634-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, berrange@redhat.com, mark.burton@greensocs.com, armbru@redhat.com, f4bug@amsat.org, mirela.grujic@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644335672383100005 Content-Type: text/plain; charset="utf-8" Initialize global variables separately from net_init_clients, so that calling net_cleanup does not crash miserably. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/xen_nic.c | 20 ++++++++++---------- include/net/net.h | 1 + net/net.c | 5 ++++- softmmu/runstate.c | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 5c815b4f0c..cd8f1edb29 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -275,7 +275,7 @@ static NetClientInfo net_xen_info =3D { .receive =3D net_rx_packet, }; =20 -static int net_init(struct XenLegacyDevice *xendev) +static int xen_net_init(struct XenLegacyDevice *xendev) { struct XenNetDev *netdev =3D container_of(xendev, struct XenNetDev, xe= ndev); =20 @@ -307,7 +307,7 @@ static int net_init(struct XenLegacyDevice *xendev) return 0; } =20 -static int net_connect(struct XenLegacyDevice *xendev) +static int xen_net_connect(struct XenLegacyDevice *xendev) { struct XenNetDev *netdev =3D container_of(xendev, struct XenNetDev, xe= ndev); int rx_copy; @@ -362,7 +362,7 @@ static int net_connect(struct XenLegacyDevice *xendev) return 0; } =20 -static void net_disconnect(struct XenLegacyDevice *xendev) +static void xen_net_disconnect(struct XenLegacyDevice *xendev) { struct XenNetDev *netdev =3D container_of(xendev, struct XenNetDev, xe= ndev); =20 @@ -378,14 +378,14 @@ static void net_disconnect(struct XenLegacyDevice *xe= ndev) } } =20 -static void net_event(struct XenLegacyDevice *xendev) +static void xen_net_event(struct XenLegacyDevice *xendev) { struct XenNetDev *netdev =3D container_of(xendev, struct XenNetDev, xe= ndev); net_tx_packets(netdev); qemu_flush_queued_packets(qemu_get_queue(netdev->nic)); } =20 -static int net_free(struct XenLegacyDevice *xendev) +static int xen_net_free(struct XenLegacyDevice *xendev) { struct XenNetDev *netdev =3D container_of(xendev, struct XenNetDev, xe= ndev); =20 @@ -403,9 +403,9 @@ static int net_free(struct XenLegacyDevice *xendev) struct XenDevOps xen_netdev_ops =3D { .size =3D sizeof(struct XenNetDev), .flags =3D DEVOPS_FLAG_NEED_GNTDEV, - .init =3D net_init, - .initialise =3D net_connect, - .event =3D net_event, - .disconnect =3D net_disconnect, - .free =3D net_free, + .init =3D xen_net_init, + .initialise =3D xen_net_connect, + .event =3D xen_net_event, + .disconnect =3D xen_net_disconnect, + .free =3D xen_net_free, }; diff --git a/include/net/net.h b/include/net/net.h index 523136c7ac..463a2c6de5 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -216,6 +216,7 @@ extern const char *host_net_devices[]; /* from net.c */ int net_client_parse(QemuOptsList *opts_list, const char *str); void show_netdevs(void); +void net_init(void); int net_init_clients(Error **errp); void net_check_clients(void); void net_cleanup(void); diff --git a/net/net.c b/net/net.c index f0d14dbfc1..82406a1851 100644 --- a/net/net.c +++ b/net/net.c @@ -1551,13 +1551,16 @@ out: return ret; } =20 -int net_init_clients(Error **errp) +void net_init(void) { net_change_state_entry =3D qemu_add_vm_change_state_handler(net_vm_change_state_handler, NULL= ); =20 QTAILQ_INIT(&net_clients); +} =20 +int net_init_clients(Error **errp) +{ if (qemu_opts_foreach(qemu_find_opts("netdev"), net_init_netdev, NULL, errp)) { return -1; diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 10d9b7365a..0ba7828155 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -776,6 +776,7 @@ void qemu_init_subsystems(void) =20 bdrv_init_with_whitelist(); socket_init(); + net_init(); } =20 =20 --=20 2.31.1 From nobody Mon Feb 9 08:33:50 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644341211014492.9483367009684; Tue, 8 Feb 2022 09:26:51 -0800 (PST) Received: from localhost ([::1]:59268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHUGO-000103-VK for importer@patchew.org; Tue, 08 Feb 2022 12:26:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHRka-0004cm-PL for qemu-devel@nongnu.org; Tue, 08 Feb 2022 09:45:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHRkY-0001sV-He for qemu-devel@nongnu.org; Tue, 08 Feb 2022 09:45:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-547-rpGCOerCMZyGBnodhBouXw-1; Tue, 08 Feb 2022 09:45:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 811FE1091DA0; Tue, 8 Feb 2022 14:45: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 A1AD77D3CE; Tue, 8 Feb 2022 14:45:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644331545; 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=AkU+3bMXQ5Q1RXFuQl/YoAUzbZXdN9D5MiHPMBhEA5M=; b=bwEyMi/xxakF9uA+NLJJ96f+gcRLR6CO05IKxkEDk2X3JmaACFozFI1lS0NZrdonnhitzd kn8qIYT34BLr79X7+yjBS3hKAMZGvFwG8HRnTQv9C/1MroxJ9RGsvprPb228tRCRo+wM2C qDZi3zTR8mxnMXDrU8J399TL5jYy5Ro= X-MC-Unique: rpGCOerCMZyGBnodhBouXw-1 From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [RFC PATCH 3/3] introduce qemu-qmp-* Date: Tue, 8 Feb 2022 09:44:58 -0500 Message-Id: <20220208144458.1079634-4-pbonzini@redhat.com> In-Reply-To: <20220208144458.1079634-1-pbonzini@redhat.com> References: <20220208144458.1079634-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=170.10.129.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: damien.hedde@greensocs.com, berrange@redhat.com, mark.burton@greensocs.com, armbru@redhat.com, f4bug@amsat.org, mirela.grujic@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1644341213193100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- meson.build | 16 +++-- softmmu/{vl.c =3D> climain.c} | 2 +- softmmu/meson.build | 1 - softmmu/qmpmain.c | 120 ++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 6 deletions(-) rename softmmu/{vl.c =3D> climain.c} (99%) create mode 100644 softmmu/qmpmain.c diff --git a/meson.build b/meson.build index 5f43355071..eed85d3d1a 100644 --- a/meson.build +++ b/meson.build @@ -3003,14 +3003,21 @@ foreach target : target_dirs execs =3D [{ 'name': 'qemu-system-' + target_name, 'win_subsystem': 'console', - 'sources': files('softmmu/main.c'), + 'sources': [files('softmmu/climain.c', 'softmmu/main.c')], 'dependencies': [] }] - if targetos =3D=3D 'windows' and (sdl.found() or gtk.found()) + if targetos !=3D 'windows' + execs +=3D [{ + 'name': 'qemu-qmp-' + target_name, + 'win_subsystem': 'console', + 'sources': [files('softmmu/qmpmain.c', 'softmmu/main.c')], + 'dependencies': [] + }] + elif sdl.found() or gtk.found() execs +=3D [{ 'name': 'qemu-system-' + target_name + 'w', 'win_subsystem': 'windows', - 'sources': files('softmmu/main.c'), + 'sources': [files('softmmu/climain.c', 'softmmu/main.c')], 'dependencies': [] }] endif @@ -3019,7 +3026,7 @@ foreach target : target_dirs execs +=3D [{ 'name': 'qemu-fuzz-' + target_name, 'win_subsystem': 'console', - 'sources': specific_fuzz.sources(), + 'sources': [files('softmmu/climain.c'), specific_fuzz.sources()], 'dependencies': specific_fuzz.dependencies(), }] endif @@ -3040,6 +3047,7 @@ foreach target : target_dirs emulator =3D executable(exe_name, exe['sources'], install: true, c_args: c_args, + include_directories: target_inc, dependencies: arch_deps + deps + exe['dependencies'], objects: lib.extract_all_objects(recursive: true), link_language: link_language, diff --git a/softmmu/vl.c b/softmmu/climain.c similarity index 99% rename from softmmu/vl.c rename to softmmu/climain.c index 5e1b35ba48..0489850415 100644 --- a/softmmu/vl.c +++ b/softmmu/climain.c @@ -1,5 +1,5 @@ /* - * QEMU System Emulator + * QEMU System Emulator command-line interface * * Copyright (c) 2003-2008 Fabrice Bellard * diff --git a/softmmu/meson.build b/softmmu/meson.build index d8e03018ab..d53673f8d2 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -12,7 +12,6 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'memory.c', 'memory_mapping.c', 'qtest.c', - 'vl.c', 'cpu-timers.c', 'runstate-action.c', )]) diff --git a/softmmu/qmpmain.c b/softmmu/qmpmain.c new file mode 100644 index 0000000000..d976736ed9 --- /dev/null +++ b/softmmu/qmpmain.c @@ -0,0 +1,120 @@ +/* + * QEMU System Emulator machine interface + * + * Copyright (c) 2020 Red Hat, Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/rcu.h" +#include "qemu-common.h" +#include "chardev/char.h" +#include "monitor/monitor.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-types-sockets.h" +#include "qemu/systemd.h" +#include "sysemu/cpu-timers.h" +#include "sysemu/sysemu.h" +#include "ui/console.h" +#include "hw/qdev-core.h" + +static void open_socket_and_monitor(void) +{ + int nfds =3D check_socket_activation(); + Chardev *chardev; + if (nfds > 1) { + error_report("QEMU only supports listening on one socket"); + exit(1); + } + if (!nfds) { + ChardevBackend backend =3D { + .type =3D CHARDEV_BACKEND_KIND_STDIO, + .u.stdio.data =3D &(ChardevStdio) { + .has_signal =3D true, + .signal =3D false + } + }; + chardev =3D qemu_chardev_new("#qmp0", TYPE_CHARDEV_STDIO, &backend= , NULL, &error_fatal); + } else { + ChardevBackend backend =3D { + .type =3D CHARDEV_BACKEND_KIND_SOCKET, + .u.socket.data =3D &(ChardevSocket) { + .addr =3D &(SocketAddressLegacy) { + .type =3D SOCKET_ADDRESS_TYPE_FD, + .u.fd.data =3D &(String){ + .str =3D (char *) stringify(FIRST_SOCKET_ACTIVATION= _FD) + } + } + } + }; + chardev =3D qemu_chardev_new("#qmp0", TYPE_CHARDEV_SOCKET, &backen= d, NULL, &error_fatal); + } + monitor_init_qmp(chardev, true, &error_fatal); +} + +bool defaults_enabled(void) +{ + return false; +} + +DisplayOptions *qmp_query_display_options(Error **errp) +{ + error_setg(errp, "You're running too fast!"); + return NULL; +} + +Chardev *serial_hd(int i) +{ + return NULL; +} + +void qmp_x_exit_preconfig(Error **errp) +{ + error_setg(errp, "You're running too fast!"); +} + +void qemu_init(int argc, char **argv, char **envp) +{ + error_init(argv[0]); + qemu_init_exec_dir(argv[0]); + + qemu_init_subsystems(); + + /* Missing: parse -name, -sandbox, -trace, -L */ + + /* + * Clear error location left behind by the loop. + * Best done right after the loop. Do not insert code here! + */ + loc_set_none(); + + /* Missing: process -name, -sandbox, -trace, -L */ + + rcu_disable_atfork(); + qemu_init_main_loop(&error_fatal); + cpu_timers_init(); + open_socket_and_monitor(); + + /* Missing: replay_configure, configure_rtc */ + + /* machine-set: + * qemu_create_machine(); + * qemu_apply_machine_options(); + * phase_advance(PHASE_MACHINE_CREATED); + * + * accel-set: + * configure_accelerators(argv[0]); + * phase_advance(PHASE_ACCEL_CREATED); + * machine type deprecation + * migration_object_init(); + * cpu_type... + * accel_setup_post(current_machine); + * machine_run_board_init(current_machine, errp); + */ + + init_displaystate(); + os_setup_signal_handling(); +} --=20 2.31.1