From: Zhang Chen <chen.zhang@intel.com >
To: "Jason Wang" <jasowang@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
qemu-dev <qemu-devel@nongnu.org>
Cc: Zhang Chen <chen.zhang@intel.com>, Zhang Chen <zhangckid@gmail.com>
Subject: [PATCH V4 2/5] net/awd.c: Initailize input/output chardev
Date: Tue, 17 Dec 2019 20:45:51 +0800 [thread overview]
Message-ID: <20191217124554.30818-3-chen.zhang@intel.com> (raw)
In-Reply-To: <20191217124554.30818-1-chen.zhang@intel.com>
From: Zhang Chen <chen.zhang@intel.com>
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 <chen.zhang@intel.com>
---
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;
@@ -175,9 +177,30 @@ out:
error_propagate(errp, local_err);
}
+static int find_and_check_chardev(Chardev **chr,
+ char *chr_name,
+ Error **errp)
+{
+ *chr = qemu_chr_find(chr_name);
+ if (*chr == 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 = AWD(uc);
+ Chardev *chr;
if (!s->awd_node || !s->iothread ||
!s->notification_node || !s->opt_script) {
@@ -187,6 +210,20 @@ static void awd_complete(UserCreatable *uc, Error **errp)
return;
}
+ 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;
}
--
2.17.1
next prev parent reply other threads:[~2019-12-17 12:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 12:45 [PATCH V4 0/5] Introduce Advanced Watch Dog module Zhang Chen
2019-12-17 12:45 ` [PATCH V4 1/5] net/awd.c: Introduce Advanced Watch Dog module framework Zhang Chen
2019-12-17 12:45 ` Zhang Chen [this message]
2019-12-17 12:45 ` [PATCH V4 3/5] net/awd.c: Load advanced watch dog worker thread job Zhang Chen
2019-12-17 12:45 ` [PATCH V4 4/5] vl.c: Make Advanced Watch Dog delayed initialization Zhang Chen
2019-12-17 12:45 ` [PATCH V4 5/5] docs/awd.txt: Add doc to introduce Advanced WatchDog(AWD) module Zhang Chen
2020-01-07 4:32 ` [PATCH V4 0/5] Introduce Advanced Watch Dog module Zhang, Chen
2020-01-19 9:10 ` Zhang, Chen
2020-01-20 2:56 ` Jason Wang
2020-02-11 8:58 ` Zhang, Chen
2020-02-12 2:56 ` Jason Wang
2020-02-20 3:36 ` Zhang, Chen
2020-03-04 8:06 ` Zhang, Chen
2020-03-04 13:37 ` Paolo Bonzini
2020-03-09 9:32 ` Zhang, Chen
2020-03-12 15:52 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191217124554.30818-3-chen.zhang@intel.com \
--to=chen.zhang@intel.com \
--cc=jasowang@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhangckid@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).