From nobody Fri Nov 14 21:05:48 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=1760615246; cv=none; d=zohomail.com; s=zohoarc; b=G5I3VInYO5kN4R+296eyEUF8ltQ4GqbT6ONVCS7+12FDKGsQ8IzGj4BYX+nAVctn22DdS3rD/ZQeLAxoOefpxA7nwpbP0s4c7W+XlecjaGT7pdeVB75IfNmEu0gO/aGZNbdD8usqO0xiV9uembf65MUvxQHKdKxlEe9PNyJ1dxM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760615246; h=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=bpYyRH+FH5+ms+TFU93oV6x9PSDyaNh07aiBxI/3YRc=; b=br8+vKbMNP7TYWj+Vl4VRtZ7YxKYwKSND6N1164VQWHwIzippJcMaqcfidXKsg1j7qV/5sGAZpl2T0YF1vTsUIefEwlq+u1Gjc5I6elV1UsZaFCqEt/KUptkIkH9pivWyNVj7p0MFC5plwm8GnCeKb05Du2NrBECMbOSEOqATbk= 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 1760615246934385.0184686803975; Thu, 16 Oct 2025 04:47:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v9MNb-0007Sk-Is; Thu, 16 Oct 2025 07:42:47 -0400 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 1v9MMx-00079V-5o; Thu, 16 Oct 2025 07:42:07 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v9MMk-0003WL-F9; Thu, 16 Oct 2025 07:42:02 -0400 Received: from mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net [IPv6:2a02:6b8:c1f:3a87:0:640:845c:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 510E7C01DF; Thu, 16 Oct 2025 14:41:37 +0300 (MSK) Received: from vsementsov-lin.. (unknown [2a02:6bf:8080:a8c::1:19]) by mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id LfP2M73FEmI0-jWRYgAwK; Thu, 16 Oct 2025 14:41:36 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1760614896; bh=bpYyRH+FH5+ms+TFU93oV6x9PSDyaNh07aiBxI/3YRc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Sqbpc+alHMEB7F5+LCy/2E+v4XokjaMKFtsNcShpufQqZBFPuScB3DtUzpfIAbaKu Xk/nI7wCrWm6LKqlkxpblLr5DineKaFJBXfIUzNL4ov6c6VD/z9VqRFQGZueuBQ38J /5qMcjOv4mG7lcUsWMv43JGPdnQNZlq4Xb6sX3o4= Authentication-Results: mail-nwsmtp-smtp-corp-main-69.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: raphael@enfabrica.net, pbonzini@redhat.com, farosas@suse.de Cc: mst@redhat.com, sgarzare@redhat.com, marcandre.lureau@redhat.com, kwolf@redhat.com, hreitz@redhat.com, berrange@redhat.com, eblake@redhat.com, armbru@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org, steven.sistare@oracle.com, vsementsov@yandex-team.ru, yc-core@yandex-team.ru, d-tatianin@yandex-team.ru, jasowang@redhat.com Subject: [PATCH v2 18/25] chardev: introduce backend-transfer vmstate for chardev Date: Thu, 16 Oct 2025 14:40:55 +0300 Message-ID: <20251016114104.1384675-19-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251016114104.1384675-1-vsementsov@yandex-team.ru> References: <20251016114104.1384675-1-vsementsov@yandex-team.ru> MIME-Version: 1.0 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.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1760615249755154100 Content-Type: text/plain; charset="utf-8" We'll need to transfer the chardev attached to vhost-user-blk, to support backend-transfer migration for vhost-user-blk. So, prepare chardev vmsd now. Signed-off-by: Vladimir Sementsov-Ogievskiy --- chardev/char-backend-transfer.c | 52 +++++++++++++++++++++++++ chardev/meson.build | 1 + include/chardev/char-backend-transfer.h | 17 ++++++++ 3 files changed, 70 insertions(+) create mode 100644 chardev/char-backend-transfer.c create mode 100644 include/chardev/char-backend-transfer.h diff --git a/chardev/char-backend-transfer.c b/chardev/char-backend-transfe= r.c new file mode 100644 index 0000000000..f1a399c7fa --- /dev/null +++ b/chardev/char-backend-transfer.c @@ -0,0 +1,52 @@ +/* + * Event notifier migration support + * Copyright (c) Yandex Technologies LLC, 2025 + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "chardev/char-fe.h" +#include "migration/vmstate.h" + +typedef struct CharBackendTransferTmp { + CharBackend *parent; + int fd; +} CharBackendTransferTmp; + +static int char_backend_transfer_pre_save(void *opaque) +{ + CharBackendTransferTmp *tmp =3D opaque; + + tmp->fd =3D qemu_chr_get_client(tmp->parent->chr); + if (tmp->fd < 0) { + return -1; + } + + return 0; +} + +static int char_backend_transfer_post_load(void *opaque, int version_id) +{ + CharBackendTransferTmp *tmp =3D opaque; + + return qemu_chr_add_client(tmp->parent->chr, tmp->fd); +} + +const VMStateDescription vmstate_backend_transfer_char_tmp =3D { + .name =3D "backend-transfer-char-tmp", + .pre_save =3D char_backend_transfer_pre_save, + .post_load =3D char_backend_transfer_post_load, + .fields =3D (const VMStateField[]) { + VMSTATE_FD(fd, CharBackendTransferTmp), + VMSTATE_END_OF_LIST() + }, +}; + +const VMStateDescription vmstate_backend_transfer_char =3D { + .name =3D "backend-transfer-char", + .fields =3D (const VMStateField[]) { + VMSTATE_WITH_TMP(CharBackend, CharBackendTransferTmp, + vmstate_backend_transfer_char_tmp), + VMSTATE_END_OF_LIST() + }, +}; diff --git a/chardev/meson.build b/chardev/meson.build index 56ee39ac0b..239c8cd072 100644 --- a/chardev/meson.build +++ b/chardev/meson.build @@ -31,6 +31,7 @@ chardev_ss =3D chardev_ss.apply({}) =20 system_ss.add(files( 'char-hmp-cmds.c', + 'char-backend-transfer.c', 'msmouse.c', 'wctablet.c', 'testdev.c')) diff --git a/include/chardev/char-backend-transfer.h b/include/chardev/char= -backend-transfer.h new file mode 100644 index 0000000000..2c3da5f836 --- /dev/null +++ b/include/chardev/char-backend-transfer.h @@ -0,0 +1,17 @@ +/* + * Event notifier migration support + * Copyright (c) Yandex Technologies LLC, 2025 + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef CHAR_BACKEND_TRANSFER_H +#define CHAR_BACKEND_TRANSFER_H + +#include "qemu/typedefs.h" + +extern const VMStateDescription vmstate_backend_transfer_char; +#define VMSTATE_BACKEND_TRANSFER_CHARDEV(_field, _state) = \ + VMSTATE_STRUCT(_field, _state, 0, vmstate_backend_transfer_char, = \ + CharBackend) + +#endif --=20 2.48.1