@@ -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;
}