#include "qemu/osdep.h"
#include "qemu/cutils.h"
#include "monitor/monitor.h"
+#include "monitor/qmp-helpers.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"
/* Any ChardevCommon member would work */
ChardevCommon *common = backend ? backend->u.null.data : NULL;
- if (common && common->has_logfile) {
+ if (common && common->logfile) {
int flags = O_WRONLY;
if (common->has_logappend &&
common->logappend) {
{
const char *logfile = qemu_opt_get(opts, "logfile");
- backend->has_logfile = logfile != NULL;
backend->logfile = g_strdup(logfile);
-
backend->has_logappend = true;
backend->logappend = qemu_opt_get_bool(opts, "logappend", false);
}
return cc;
}
-static struct ChardevAlias {
- const char *typename;
- const char *alias;
- bool deprecation_warning_printed;
-} chardev_alias_table[] = {
-#ifdef HAVE_CHARDEV_PARPORT
- { "parallel", "parport" },
-#endif
-#ifdef HAVE_CHARDEV_SERIAL
- { "serial", "tty" },
-#endif
-};
-
typedef struct ChadevClassFE {
void (*fn)(const char *name, void *opaque);
void *opaque;
g_string_append_printf(str, "\n %s", name);
}
-static const char *chardev_alias_translate(const char *name)
-{
- int i;
- for (i = 0; i < (int)ARRAY_SIZE(chardev_alias_table); i++) {
- if (g_strcmp0(chardev_alias_table[i].alias, name) == 0) {
- if (!chardev_alias_table[i].deprecation_warning_printed) {
- warn_report("The alias '%s' is deprecated, use '%s' instead",
- name, chardev_alias_table[i].typename);
- chardev_alias_table[i].deprecation_warning_printed = true;
- }
- return chardev_alias_table[i].typename;
- }
- }
- return name;
-}
-
ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Error **errp)
{
Error *local_err = NULL;
const ChardevClass *cc;
ChardevBackend *backend = NULL;
- const char *name = chardev_alias_translate(qemu_opt_get(opts, "backend"));
+ const char *name = qemu_opt_get(opts, "backend");
if (name == NULL) {
error_setg(errp, "chardev: \"%s\" missing backend",
const ChardevClass *cc;
Chardev *chr = NULL;
ChardevBackend *backend = NULL;
- const char *name = chardev_alias_translate(qemu_opt_get(opts, "backend"));
+ const char *name = qemu_opt_get(opts, "backend");
const char *id = qemu_opts_id(opts);
char *bid = NULL;
ret = g_new0(ChardevReturn, 1);
if (CHARDEV_IS_PTY(chr)) {
ret->pty = g_strdup(chr->filename + 4);
- ret->has_pty = true;
}
return ret;
ret = g_new0(ChardevReturn, 1);
if (CHARDEV_IS_PTY(chr_new)) {
ret->pty = g_strdup(chr_new->filename + 4);
- ret->has_pty = true;
}
return ret;
qemu_chr_be_event(chr, CHR_EVENT_BREAK);
}
+bool qmp_add_client_char(int fd, bool has_skipauth, bool skipauth,
+ bool has_tls, bool tls, const char *protocol,
+ Error **errp)
+{
+ Chardev *s = qemu_chr_find(protocol);
+
+ if (!s) {
+ error_setg(errp, "protocol '%s' is invalid", protocol);
+ close(fd);
+ return false;
+ }
+ if (qemu_chr_add_client(s, fd) < 0) {
+ error_setg(errp, "failed to add client");
+ close(fd);
+ return false;
+ }
+ return true;
+}
+
/*
* Add a timeout callback for the chardev (in milliseconds), return
* the GSource object created. Please use this to add timeout hook for