From nobody Fri Nov 14 18:23:10 2025 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=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1762251558; cv=none; d=zohomail.com; s=zohoarc; b=FwkABBu3qyLEx6EyY3NIUjLpJYAKJXsuLDyxVVx8e81hWHfUEtGhDGHJLCu18Mt7B0iyX+XKz/rIwEONq/ez2GBinDL8L4Scwaj75yBsRd+TCLXxjh2nfJa8/vOGlNzuWYNg6oCN8BiOOYcSK9kPwxNWBD7lTpv70bqayQpi+yM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762251558; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BmL4bf+MiFO9yHgpIaYFUjP289D4bjT//+SgdM56yk0=; b=dgEr21NnCmaXoyHBcaoarH2yKNv6k8jPKqpVR1lwxDHufVOF2BB1XPgzAyh08uLyvuZubAw700UHAZJvfSb9UuLde3/Ce5r1zBD0yPXglxp3IAEd0CES0SG4HzhOczpBlQJLV8UW4adhLxBGY+0zB4Fo7BsAjM8lXe89FLess4U= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1762251558070104.8119056352391; Tue, 4 Nov 2025 02:19:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vGE6h-0001C2-QK; Tue, 04 Nov 2025 05:17:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vGE6Z-0001A2-0M for qemu-devel@nongnu.org; Tue, 04 Nov 2025 05:17:35 -0500 Received: from forwardcorp1d.mail.yandex.net ([178.154.239.200]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vGE6X-0002mE-0n for qemu-devel@nongnu.org; Tue, 04 Nov 2025 05:17:34 -0500 Received: from mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1a8f:0:640:2fa2:0]) by forwardcorp1d.mail.yandex.net (Yandex) with ESMTPS id AC07080CA1; Tue, 04 Nov 2025 13:17:31 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:95c::1:2]) by mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id NHhfHh1FIW20-u4XDF2Am; Tue, 04 Nov 2025 13:17:31 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1762251451; bh=BmL4bf+MiFO9yHgpIaYFUjP289D4bjT//+SgdM56yk0=; h=Cc:Message-ID:References:Date:In-Reply-To:Subject:To:From; b=I3fwLL5mJ2e8XHYvMUOfUdupi0ekNIV0oj2XxP5i48/W3Huw2uBp0S2YgKubcZQjq cjoRpHraYaKUO4vW0eHl7uegLhPHH1QUdhEpQcEah20JeJADvA58aiAovk/Atq33Tn AnR1vcB8wCvvZpJPWB935PMt9IkrZKHmStE5/FtI= Authentication-Results: mail-nwsmtp-smtp-corp-main-66.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: marcandre.lureau@redhat.com Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, qemu-devel@nongnu.org, vsementsov@yandex-team.ru, raphael@enfabrica.net, armbru@redhat.com, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru Subject: [PATCH v6 7/7] chardev: introduce DEFINE_PROP_CHR_NO_CONNECT Date: Tue, 4 Nov 2025 13:17:15 +0300 Message-ID: <20251104101715.76691-8-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251104101715.76691-1-vsementsov@yandex-team.ru> References: <20251104101715.76691-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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=178.154.239.200; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1d.mail.yandex.net 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yandex-team.ru) X-ZM-MESSAGEID: 1762251562242158500 For further vhost-user-blk backend-transfer migration realization we want to give it (vhost-user-blk) a possibility (and responsibility) to decide when do connect. For incoming migration we'll need to postpone connect at least until early stage of migrate-incoming command, when we already know all migration parameters and can decide, are we going to do incoming backend-transfer (and get chardev fd from incoming stream), or we finally need to connect. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fe.c | 22 +++++++++++++++++++--- hw/core/qdev-properties-system.c | 26 +++++++++++++++++++++++--- include/chardev/char-fe.h | 9 +++++++-- include/hw/qdev-properties-system.h | 3 +++ 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index 504c3653e5..349b462e14 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -189,13 +189,24 @@ bool qemu_chr_fe_backend_open(CharFrontend *c) return c->chr && c->chr->be_open; } =20 -bool qemu_chr_fe_init(CharFrontend *c, Chardev *s, Error **errp) +bool qemu_chr_fe_init_ex(CharFrontend *c, Chardev *s, bool connect, + Error **errp) { unsigned int tag =3D 0; =20 if (s) { - if (!qemu_chr_connect(s, errp)) { - return false; + if (connect) { + if (!qemu_chr_connect(s, errp)) { + return false; + } + } else { + /* DEFINE_PROP_CHR_NO_CONNECT */ + if (!s->connect_postponed) { + error_setg(errp, + "Chardev %s does not support postponed connect", + s->label); + return false; + } } =20 if (CHARDEV_IS_MUX(s)) { @@ -218,6 +229,11 @@ bool qemu_chr_fe_init(CharFrontend *c, Chardev *s, Err= or **errp) return true; } =20 +bool qemu_chr_fe_init(CharFrontend *c, Chardev *s, Error **errp) +{ + return qemu_chr_fe_init_ex(c, s, true, errp); +} + void qemu_chr_fe_deinit(CharFrontend *c, bool del) { assert(c); diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 7aa5cbb510..9803e582e9 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -266,8 +266,8 @@ static void get_chr(Object *obj, Visitor *v, const char= *name, void *opaque, g_free(p); } =20 -static void set_chr(Object *obj, Visitor *v, const char *name, void *opaqu= e, - Error **errp) +static void do_set_chr(Object *obj, Visitor *v, const char *name, void *op= aque, + bool connect, Error **errp) { ERRP_GUARD(); const Property *prop =3D opaque; @@ -297,13 +297,25 @@ static void set_chr(Object *obj, Visitor *v, const ch= ar *name, void *opaque, if (s =3D=3D NULL) { error_setg(errp, "Property '%s.%s' can't find value '%s'", object_get_typename(obj), name, str); - } else if (!qemu_chr_fe_init(fe, s, errp)) { + } else if (!qemu_chr_fe_init_ex(fe, s, connect, errp)) { error_prepend(errp, "Property '%s.%s' can't take value '%s': ", object_get_typename(obj), name, str); } g_free(str); } =20 +static void set_chr(Object *obj, Visitor *v, const char *name, void *opaqu= e, + Error **errp) +{ + do_set_chr(obj, v, name, opaque, true, errp); +} + +static void set_chr_no_connect(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + do_set_chr(obj, v, name, opaque, false, errp); +} + static void release_chr(Object *obj, const char *name, void *opaque) { const Property *prop =3D opaque; @@ -320,6 +332,14 @@ const PropertyInfo qdev_prop_chr =3D { .release =3D release_chr, }; =20 +const PropertyInfo qdev_prop_chr_no_connect =3D { + .type =3D "str", + .description =3D "ID of a chardev to use as a backend", + .get =3D get_chr, + .set =3D set_chr_no_connect, + .release =3D release_chr, +}; + /* --- mac address --- */ =20 /* diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index 5f8a6df17d..c0d991a19f 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -25,14 +25,19 @@ struct CharFrontend { }; =20 /** - * qemu_chr_fe_init: + * qemu_chr_fe_init(_ex): * * Initializes the frontend @c for the given Chardev backend @s. Call * qemu_chr_fe_deinit() to remove the association and release the backend. + * Call qemu_chr_connect(), except for the case when connect=3Dfalse + * parameter set for _ex() version, or when @s =3D=3D NULL. For the latter, + * @connect is ignored. * * Returns: false on error. */ -bool qemu_chr_fe_init(CharFrontend *c, Chardev *be, Error **errp); +bool qemu_chr_fe_init(CharFrontend *c, Chardev *s, Error **errp); +bool qemu_chr_fe_init_ex(CharFrontend *c, Chardev *s, bool connect, + Error **errp); =20 /** * qemu_chr_fe_deinit: diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 45687be005..18ad2e6519 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -7,6 +7,7 @@ bool qdev_prop_sanitize_s390x_loadparm(uint8_t *loadparm, c= onst char *str, Error **errp); =20 extern const PropertyInfo qdev_prop_chr; +extern const PropertyInfo qdev_prop_chr_no_connect; extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_reserved_region; extern const PropertyInfo qdev_prop_multifd_compression; @@ -39,6 +40,8 @@ extern const PropertyInfo qdev_prop_virtio_gpu_output_lis= t; =20 #define DEFINE_PROP_CHR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_chr, CharFrontend) +#define DEFINE_PROP_CHR_NO_CONNECT(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_chr_no_connect, CharFrontend) #define DEFINE_PROP_NETDEV(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_netdev, NICPeers) #define DEFINE_PROP_DRIVE(_n, _s, _f) \ --=20 2.48.1