On 01/07/2013 06:55 AM, Gerd Hoffmann wrote: > qemu_chr_open_socket is splitted into two functions. All initialization
s/splitted/split/ > after creating the socket file handler is splitted away into the new and again > qemu_chr_open_socket_fd function. > > chr->filename doesn't get filled from QemuOpts any more. Qemu gathers > the information using getsockname and getnameinfo instead. This way it > will also work correctly for file handles passed via file descriptor > passing. > > Finally qmp_chardev_open_socket() is the actual qmp hotplug > implementation which basically just calls socket_listen or > socket_connect and the new qemu_chr_open_socket_fd function. > > Signed-off-by: Gerd Hoffmann <kra...@redhat.com> > --- > qapi-schema.json | 13 +++- > qemu-char.c | 168 ++++++++++++++++++++++++++++++++++++----------------- > 2 files changed, 124 insertions(+), 57 deletions(-) > > +++ b/qemu-char.c > @@ -2438,10 +2438,88 @@ static void tcp_chr_close(CharDriverState *chr) > qemu_chr_be_event(chr, CHR_EVENT_CLOSED); > } > > -static CharDriverState *qemu_chr_open_socket(QemuOpts *opts) > +static CharDriverState *qemu_chr_open_socket_fd(int fd, int do_nodelay, > + int is_listen, int is_telnet, > + int is_waitconnect, These three parameters sound like they might be better as 'bool' instead of 'int'. > @@ -2458,10 +2536,7 @@ static CharDriverState *qemu_chr_open_socket(QemuOpts > *opts) > if (!is_listen) > is_waitconnect = 0; > > - chr = g_malloc0(sizeof(CharDriverState)); > - s = g_malloc0(sizeof(TCPCharDriver)); > - > - if (is_unix) { > + if (is_unix) { Spurious re-indentation? > > +static CharDriverState *qmp_chardev_open_socket(ChardevSocket *sock, > + Error **errp) > +{ > + SocketAddress *addr = sock->addr; > + bool do_nodelay = sock->has_delay ? !sock->delay : true; > + bool is_listen = sock->has_server ? sock->server : true; > + bool is_telnet = sock->has_telnet ? sock->telnet : false; > + bool is_waitconnect = sock->has_wait ? sock->wait : false; Especially since you are using bool here. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature