From nobody Wed Feb 11 04:02:47 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 ARC-Seal: i=1; a=rsa-sha256; t=1594628907; cv=none; d=zohomail.com; s=zohoarc; b=Q/8t443GhxCza0H4trERe+iuaiNRJs524A381GcV8RCUxVv7iDPzwUpp34EDSP9SK0tUCUWTL1ZSBrUIcTbuFuO5LAdqBTOlfweECyZMYreckJoGjYd0oTqpn3CS2wtVotfvxY8r/IjtahSMfO+0iPEn0u2bpMZ6SdVpChs6ZYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594628907; 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=tBsau8jOfwRZQzzDPU2wnY6HOyNPZwnSDlheVxVne2k=; b=RLglByl/A3BvpPrgA1XT/kfDsSxpbhrOWTLbah6O8+QYIiKua4j4Dok6mCioKii1B4YvN4LHKys9OqKZnWgxCOFxhlqhIkeCnWy+TX/9wt8fQak6yXimi7XtVgqWbXVxfeSyn8UIbzoSSzqMLa9MeeL3NZBDQFKwQeb1EFx+Tv0= ARC-Authentication-Results: i=1; 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 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 1594628907801232.41623755796218; Mon, 13 Jul 2020 01:28:27 -0700 (PDT) Received: from localhost ([::1]:42868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jutp4-0000LG-Ii for importer@patchew.org; Mon, 13 Jul 2020 04:28:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jutmf-0004c5-8B for qemu-devel@nongnu.org; Mon, 13 Jul 2020 04:25:57 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:22793 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jutmd-0006sX-BQ for qemu-devel@nongnu.org; Mon, 13 Jul 2020 04:25:56 -0400 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-424-_LB_Mp3aO-2fmQU-_5DLYg-1; Mon, 13 Jul 2020 04:25:37 -0400 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 853A5E91A for ; Mon, 13 Jul 2020 08:25:36 +0000 (UTC) Received: from localhost (unknown [10.36.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8125E60BF3; Mon, 13 Jul 2020 08:25:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594628754; 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=tBsau8jOfwRZQzzDPU2wnY6HOyNPZwnSDlheVxVne2k=; b=OHy1lIcnKmBWlCl5ikbeQu/PPpvD22kzE2IolNebm3fq9b/nc9K2zJmjU+VzZUblPXpzr1 60BgVvknWL7aW+2JwfuzrJPzJ+Ko0qAdonO5MxXqfHSCicscH4r5DXKvLeOBeyldjg7KJh T7Q44QwDVC8wfIvFOomxgV8FssAaHAg= X-MC-Unique: _LB_Mp3aO-2fmQU-_5DLYg-1 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Subject: [PULL 8/8] chardev: Extract system emulation specific code Date: Mon, 13 Jul 2020 12:24:24 +0400 Message-Id: <20200713082424.2947383-9-marcandre.lureau@redhat.com> In-Reply-To: <20200713082424.2947383-1-marcandre.lureau@redhat.com> References: <20200713082424.2947383-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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=205.139.110.120; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/13 03:20:22 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H2=-1, 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?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Dr. David Alan Gilbert" , Markus Armbruster , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Split out code only used during system emulation, to reduce code pulled in user emulation and tools. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20200423202112.644-6-philmd@redhat.com> Reviewed-by: Richard Henderson Signed-off-by: Marc-Andr=C3=A9 Lureau --- chardev/chardev-internal.h | 3 ++ chardev/char.c | 35 +------------------ chardev/chardev-sysemu.c | 69 ++++++++++++++++++++++++++++++++++++++ chardev/Makefile.objs | 1 + 4 files changed, 74 insertions(+), 34 deletions(-) create mode 100644 chardev/chardev-sysemu.c diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h index e0264ac3498..f4d0429763b 100644 --- a/chardev/chardev-internal.h +++ b/chardev/chardev-internal.h @@ -26,6 +26,7 @@ =20 #include "chardev/char.h" #include "chardev/char-fe.h" +#include "qom/object.h" =20 #define MAX_MUX 4 #define MUX_BUFFER_SIZE 32 /* Must be a power of 2. */ @@ -59,4 +60,6 @@ typedef struct MuxChardev { void mux_set_focus(Chardev *chr, int focus); void mux_chr_send_all_event(Chardev *chr, QEMUChrEvent event); =20 +Object *get_chardevs_root(void); + #endif /* CHAR_MUX_H */ diff --git a/chardev/char.c b/chardev/char.c index 807be52300e..77e7ec814f2 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -45,7 +45,7 @@ /***********************************************************/ /* character device */ =20 -static Object *get_chardevs_root(void) +Object *get_chardevs_root(void) { return container_get(object_get_root(), "/chardevs"); } @@ -305,33 +305,6 @@ static const TypeInfo char_type_info =3D { .class_init =3D char_class_init, }; =20 -static int chardev_machine_done_notify_one(Object *child, void *opaque) -{ - Chardev *chr =3D (Chardev *)child; - ChardevClass *class =3D CHARDEV_GET_CLASS(chr); - - if (class->chr_machine_done) { - return class->chr_machine_done(chr); - } - - return 0; -} - -static void chardev_machine_done_hook(Notifier *notifier, void *unused) -{ - int ret =3D object_child_foreach(get_chardevs_root(), - chardev_machine_done_notify_one, NULL); - - if (ret) { - error_report("Failed to call chardev machine_done hooks"); - exit(1); - } -} - -static Notifier chardev_machine_done_notify =3D { - .notify =3D chardev_machine_done_hook, -}; - static bool qemu_chr_is_busy(Chardev *s) { if (CHARDEV_IS_MUX(s)) { @@ -1198,12 +1171,6 @@ void qemu_chr_cleanup(void) static void register_types(void) { type_register_static(&char_type_info); - - /* this must be done after machine init, since we register FEs with mu= xes - * as part of realize functions like serial_isa_realizefn when -nograp= hic - * is specified - */ - qemu_add_machine_init_done_notifier(&chardev_machine_done_notify); } =20 type_init(register_types); diff --git a/chardev/chardev-sysemu.c b/chardev/chardev-sysemu.c new file mode 100644 index 00000000000..eecdc615ee1 --- /dev/null +++ b/chardev/chardev-sysemu.c @@ -0,0 +1,69 @@ +/* + * QEMU System Emulator + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * 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 "sysemu/sysemu.h" +#include "chardev/char.h" +#include "qemu/error-report.h" +#include "chardev-internal.h" + +static int chardev_machine_done_notify_one(Object *child, void *opaque) +{ + Chardev *chr =3D (Chardev *)child; + ChardevClass *class =3D CHARDEV_GET_CLASS(chr); + + if (class->chr_machine_done) { + return class->chr_machine_done(chr); + } + + return 0; +} + +static void chardev_machine_done_hook(Notifier *notifier, void *unused) +{ + int ret =3D object_child_foreach(get_chardevs_root(), + chardev_machine_done_notify_one, NULL); + + if (ret) { + error_report("Failed to call chardev machine_done hooks"); + exit(1); + } +} + + +static Notifier chardev_machine_done_notify =3D { + .notify =3D chardev_machine_done_hook, +}; + +static void register_types(void) +{ + /* + * This must be done after machine init, since we register FEs with mu= xes + * as part of realize functions like serial_isa_realizefn when -nograp= hic + * is specified. + */ + qemu_add_machine_init_done_notifier(&chardev_machine_done_notify); +} + +type_init(register_types); diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs index 62ec0a33235..3783dadc4c7 100644 --- a/chardev/Makefile.objs +++ b/chardev/Makefile.objs @@ -1,4 +1,5 @@ chardev-obj-y +=3D char.o +chardev-obj-$(CONFIG_SOFTMMU) +=3D chardev-sysemu.o chardev-obj-$(CONFIG_WIN32) +=3D char-console.o chardev-obj-$(CONFIG_POSIX) +=3D char-fd.o chardev-obj-y +=3D char-fe.o --=20 2.27.0.221.ga08a83db2b