From nobody Sun Feb 8 18:29:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1571225967; cv=none; d=zoho.com; s=zohoarc; b=S79HuKVFrwSj0rgsSS+CSAM8CT+ZCVSxkx1scYmOzNrXpsg/nvFyE1iX7mR5Ok0nJZk5HBNkYgabBtMXrAgS3UV/cBh18GK2Twn61TBNqslhU5GWHm1pStj+c2I0y9kXZBprme1wzCfRyZGMyL1IuC/TCCIVv7axBQ1S2wv3aGg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571225967; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=IeLX1OvBrenBmPp2PbsEh+TVa+eDXY976VojxizdQWk=; b=cL0gCe3+puD8ZwO0E09JTEWyIwUBg1VNOp+fzR6R+8GtWqkIhT1QWHpZgdggijEYnIV8OVEODNU6NW5m2KxNuXaYTlPRfp/S2kBPd+M0n9o7C5gdsDb2mYZLj8sY8vdt6/pXNSDJSB8hQmzcCIHT6m9HkMEAbfJpglU4zN0WeRw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1571225967992183.7121753929606; Wed, 16 Oct 2019 04:39:27 -0700 (PDT) Received: from localhost ([::1]:41334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKheD-0002gy-AH for importer@patchew.org; Wed, 16 Oct 2019 07:39:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42697) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKhUC-00013R-Vf for qemu-devel@nongnu.org; Wed, 16 Oct 2019 07:29:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKhUB-0005Pb-Ig for qemu-devel@nongnu.org; Wed, 16 Oct 2019 07:29:00 -0400 Received: from mga07.intel.com ([134.134.136.100]:55321) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iKhUB-0005OK-9h for qemu-devel@nongnu.org; Wed, 16 Oct 2019 07:28:59 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 04:28:50 -0700 Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by fmsmga001.fm.intel.com with ESMTP; 16 Oct 2019 04:28:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,303,1566889200"; d="scan'208";a="208393367" From: Zhang Chen To: Jason Wang , Paolo Bonzini , qemu-dev Subject: [RFC PATCH 2/4] net/awd.c: Initailize input/output chardev Date: Wed, 16 Oct 2019 19:22:07 +0800 Message-Id: <20191016112209.9024-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191016112209.9024-1-chen.zhang@intel.com> References: <20191016112209.9024-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.100 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: Zhang Chen , Zhang Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Zhang Chen Find and check the chardev awd_node and notification_node, The awd_node used for keep connect with outside(like VM client/other host/Remote server), and the notification_node used for do some operation when disconnect event occur. Signed-off-by: Zhang Chen --- net/awd.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/net/awd.c b/net/awd.c index d42b4a7372..ad3d39c982 100644 --- a/net/awd.c +++ b/net/awd.c @@ -42,6 +42,8 @@ typedef struct AwdState { char *opt_script; uint32_t pulse_interval; uint32_t timeout; + CharBackend chr_awd_node; + CharBackend chr_notification_node; IOThread *iothread; } AwdState; =20 @@ -175,9 +177,30 @@ out: error_propagate(errp, local_err); } =20 +static int find_and_check_chardev(Chardev **chr, + char *chr_name, + Error **errp) +{ + *chr =3D qemu_chr_find(chr_name); + if (*chr =3D=3D NULL) { + error_setg(errp, "Device '%s' not found", + chr_name); + return 1; + } + + if (!qemu_chr_has_feature(*chr, QEMU_CHAR_FEATURE_RECONNECTABLE)) { + error_setg(errp, "chardev \"%s\" is not reconnectable", + chr_name); + return 1; + } + + return 0; +} + static void awd_complete(UserCreatable *uc, Error **errp) { AwdState *s =3D AWD(uc); + Chardev *chr; =20 if (!s->awd_node || !s->iothread || !s->notification_node || !s->opt_script) { @@ -187,6 +210,20 @@ static void awd_complete(UserCreatable *uc, Error **er= rp) return; } =20 + if (find_and_check_chardev(&chr, s->awd_node, errp) || + !qemu_chr_fe_init(&s->chr_awd_node, chr, errp)) { + error_setg(errp, "advanced-watchdog can't find chardev awd_node: %= s", + s->awd_node); + return; + } + + if (find_and_check_chardev(&chr, s->notification_node, errp) || + !qemu_chr_fe_init(&s->chr_notification_node, chr, errp)) { + error_setg(errp, "advanced-watchdog can't find " + "chardev notification_node: %s", s->notification_node); + return; + } + return; } =20 --=20 2.17.1