Commit 47f4dac3 authored by Anthony Liguori's avatar Anthony Liguori
Browse files

Merge remote-tracking branch 'kraxel/chardev.1' into staging

# By Gerd Hoffmann
# Via Gerd Hoffmann
* kraxel/chardev.1:
  chardev: add pty chardev support to chardev-add (qmp)
  chardev: add socket chardev support to chardev-add (qmp)
  chardev: add parallel chardev support to chardev-add (qmp)
  chardev: add serial chardev support to chardev-add (qmp)
  chardev: add file chardev support to chardev-add (qmp)
  chardev: add hmp hotplug commands
  chardev: add qmp hotplug commands, with null chardev support
  chardev: reduce chardev ifdef mess a bit
  chardev: fix QemuOpts lifecycle
  chardev: add error reporting for qemu_chr_new_from_opts
parents af381ebe 0a1a7fab
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -1482,6 +1482,38 @@ Password is invalidated at the given time. @var{nsec} are the seconds
passed since 1970, i.e. unix epoch.

@end table
ETEXI

    {
        .name       = "chardev-add",
        .args_type  = "args:s",
        .params     = "args",
        .help       = "add chardev",
        .mhandler.cmd = hmp_chardev_add,
    },

STEXI
@item chardev_add args
@findex chardev_add

chardev_add accepts the same parameters as the -chardev command line switch.

ETEXI

    {
        .name       = "chardev-remove",
        .args_type  = "id:s",
        .params     = "id",
        .help       = "remove chardev",
        .mhandler.cmd = hmp_chardev_remove,
    },

STEXI
@item chardev_remove id
@findex chardev_remove

Removes the chardev @var{id}.

ETEXI

    {
+23 −0
Original line number Diff line number Diff line
@@ -1336,3 +1336,26 @@ void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict)
    qmp_nbd_server_stop(&errp);
    hmp_handle_error(mon, &errp);
}

void hmp_chardev_add(Monitor *mon, const QDict *qdict)
{
    const char *args = qdict_get_str(qdict, "args");
    Error *err = NULL;
    QemuOpts *opts;

    opts = qemu_opts_parse(qemu_find_opts("chardev"), args, 1);
    if (opts == NULL) {
        error_setg(&err, "Parsing chardev args failed\n");
    } else {
        qemu_chr_new_from_opts(opts, NULL, &err);
    }
    hmp_handle_error(mon, &err);
}

void hmp_chardev_remove(Monitor *mon, const QDict *qdict)
{
    Error *local_err = NULL;

    qmp_chardev_remove(qdict_get_str(qdict, "id"), &local_err);
    hmp_handle_error(mon, &local_err);
}
+2 −0
Original line number Diff line number Diff line
@@ -80,5 +80,7 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict);
void hmp_nbd_server_start(Monitor *mon, const QDict *qdict);
void hmp_nbd_server_add(Monitor *mon, const QDict *qdict);
void hmp_nbd_server_stop(Monitor *mon, const QDict *qdict);
void hmp_chardev_add(Monitor *mon, const QDict *qdict);
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);

#endif
+3 −1
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ struct CharDriverState {
    char *filename;
    int opened;
    int avail_connections;
    QemuOpts *opts;
    QTAILQ_ENTRY(CharDriverState) next;
};

@@ -89,7 +90,8 @@ struct CharDriverState {
 * Returns: a new character backend
 */
CharDriverState *qemu_chr_new_from_opts(QemuOpts *opts,
                                    void (*init)(struct CharDriverState *s));
                                    void (*init)(struct CharDriverState *s),
                                    Error **errp);

/**
 * @qemu_chr_new:
+104 −0
Original line number Diff line number Diff line
@@ -3017,3 +3017,107 @@
# Since: 1.3.0
##
{ 'command': 'nbd-server-stop' }

##
# @ChardevFile:
#
# Configuration info for file chardevs.
#
# @in:  #optional The name of the input file
# @out: The name of the output file
#
# Since: 1.4
##
{ 'type': 'ChardevFile', 'data': { '*in' : 'str',
                                   'out' : 'str' } }

##
# @ChardevPort:
#
# Configuration info for device chardevs.
#
# @device: The name of the special file for the device,
#          i.e. /dev/ttyS0 on Unix or COM1: on Windows
# @type: What kind of device this is.
#
# Since: 1.4
##
{ 'enum': 'ChardevPortKind', 'data': [ 'serial',
                                       'parallel' ] }

{ 'type': 'ChardevPort', 'data': { 'device' : 'str',
                                   'type'   : 'ChardevPortKind'} }

##
# @ChardevSocket:
#
# Configuration info for socket chardevs.
#
# @addr: socket address to listen on (server=true)
#        or connect to (server=false)
# @server: #optional create server socket (default: true)
# @wait: #optional wait for connect (not used for server
#        sockets, default: false)
# @nodelay: #optional set TCP_NODELAY socket option (default: false)
# @telnet: #optional enable telnet protocol (default: false)
#
# Since: 1.4
##
{ 'type': 'ChardevSocket', 'data': { 'addr'     : 'SocketAddress',
                                     '*server'  : 'bool',
                                     '*wait'    : 'bool',
                                     '*nodelay' : 'bool',
                                     '*telnet'  : 'bool' } }

##
# @ChardevBackend:
#
# Configuration info for the new chardev backend.
#
# Since: 1.4
##
{ 'type': 'ChardevDummy', 'data': { } }

{ 'union': 'ChardevBackend', 'data': { 'file'   : 'ChardevFile',
                                       'port'   : 'ChardevPort',
                                       'socket' : 'ChardevSocket',
                                       'pty'    : 'ChardevDummy',
                                       'null'   : 'ChardevDummy' } }

##
# @ChardevReturn:
#
# Return info about the chardev backend just created.
#
# Since: 1.4
##
{ 'type' : 'ChardevReturn', 'data': { '*pty' : 'str' } }

##
# @chardev-add:
#
# Add a file chardev
#
# @id: the chardev's ID, must be unique
# @backend: backend type and parameters
#
# Returns: chardev info.
#
# Since: 1.4
##
{ 'command': 'chardev-add', 'data': {'id'      : 'str',
                                     'backend' : 'ChardevBackend' },
  'returns': 'ChardevReturn' }

##
# @chardev-remove:
#
# Remove a chardev
#
# @id: the chardev's ID, must exist and not be in use
#
# Returns: Nothing on success
#
# Since: 1.4
##
{ 'command': 'chardev-remove', 'data': {'id': 'str'} }
Loading