On Thu, Oct 16, 2025 at 02:40:53PM +0300, Vladimir Sementsov-Ogievskiy wrote: > A pair for .char_add_client(), to be used to support backend-transfer > migration of chardev attached to vhost-user-blk in following commits. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> > --- > chardev/char-socket.c | 7 +++++++ > chardev/char.c | 6 ++++++ > include/chardev/char.h | 4 ++++ > 3 files changed, 17 insertions(+) > > diff --git a/chardev/char-socket.c b/chardev/char-socket.c > index 0a5738c158..51bb9d0a2d 100644 > --- a/chardev/char-socket.c > +++ b/chardev/char-socket.c > @@ -929,6 +929,12 @@ static int tcp_chr_new_client(Chardev *chr, > QIOChannelSocket *sioc) > return 0; > } > > +static int tcp_chr_get_client(Chardev *chr) > +{ > + SocketChardev *s = SOCKET_CHARDEV(chr); > + > + return s->sioc->fd; > +}
This will crash on a NULL s->sioc pointer when the chardev is not connected. More generally it feels wrong to be exposing internal impl details of the socket chardev in this way. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
