vhost-user: don't poke at chardev internal QemuOpts
PATCH 1/1 vhost-user: don't poke at chardev internal QemuOpts
The vhost-user code is poking at the QemuOpts instance in the CharDriverState struct, not realizing that it is valid for this to be NULL. e.g. the following crash shows a codepath where it will be NULL:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617
617 QTAILQ_FOREACH(opt, &opts->head, next) {
[Current thread is 1 (Thread 0x7f1d4970bb40 (LWP 6603))]
(gdb) bt
#0 0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617 #1 0x000055baf696b7da in net_vhost_parse_chardev (opts=0x55baf8ff9260, errp=0x7ffc51368e48) at net/vhost-user.c:314 #2 0x000055baf696b985 in net_init_vhost_user (netdev=0x55baf8ff9250, name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) at net/vhost-user.c:360 #3 0x000055baf6960216 in net_client_init1 (object=0x55baf8ff9250, is_netdev=true, errp=0x7ffc51368e48) at net/net.c:1051 #4 0x000055baf6960518 in net_client_init (opts=0x55baf776e7e0, is_netdev=true, errp=0x7ffc51368f00) at net/net.c:1108 #5 0x000055baf696083f in netdev_add (opts=0x55baf776e7e0, errp=0x7ffc51368f00) at net/net.c:1186 #6 0x000055baf69608c7 in qmp_netdev_add (qdict=0x55baf7afaf60, ret=0x7ffc51368f50, errp=0x7ffc51368f48) at net/net.c:1205 #7 0x000055baf6622135 in handle_qmp_command (parser=0x55baf77fb590, tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978 #8 0x000055baf6a9d099 in json_message_process_token (lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113, y=19) at qobject/json-streamer.c:105 #9 0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598, ch=125 '}', flush=false) at qobject/json-lexer.c:319
#10 0x000055baf6abf8f2 in json_lexer_feed (lexer=0x55baf77fb598, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-lexer.c:369 #11 0x000055baf6a9d13c in json_message_parser_feed (parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-streamer.c:124 #12 0x000055baf66221f7 in monitor_qmp_read (opaque=0x55baf77fb530, buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994 #13 0x000055baf6757014 in qemu_chr_be_write_impl (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
#14 0x000055baf6757076 in qemu_chr_be_write (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
#15 0x000055baf675b3b0 in tcp_chr_read (chan=0x55baf90244b0, cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
#16 0x000055baf6a5d655 in qio_channel_fd_source_dispatch (source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) at io/channel-watch.c:84 #17 0x00007f1d3e80cbbd in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#18 0x000055baf69d3720 in glib_pollfds_poll () at main-loop.c:213
#19 0x000055baf69d37fd in os_host_main_loop_wait (timeout=126000000) at main-loop.c:258
#20 0x000055baf69d38ad in main_loop_wait (nonblocking=0) at main-loop.c:506
#21 0x000055baf676587b in main_loop () at vl.c:1908
#22 0x000055baf676d3bf in main (argc=101, argv=0x7ffc5136a6c8, envp=0x7ffc5136a9f8) at vl.c:4604
(gdb) p opts
$1 = (QemuOpts *) 0x0
The crash occurred when attaching vhost-user net via QMP:
{
"execute": "chardev-add",
"arguments": {
"id": "charnet2",
"backend": {
"type": "socket",
"data": {
"addr": {
"type": "unix",
"data": {
"path": "/var/run/openvswitch/vhost-user1"
}
},
"wait": false,
"server": false
}
}
},
"id": "libvirt-19"
}
{
"return": {
},
"id": "libvirt-19"
}
{
"execute": "netdev_add",
"arguments": {
"type": "vhost-user",
"chardev": "charnet2",
"id": "hostnet2"
},
"id": "libvirt-20"
}The vhost-user code should not be poking at the internals of the CharDriverState struct. What it wants is a chardev that is operating as a network server, so add an explicit API to allow it to validate this feature condition without looking at chardev internals.
---
NB, I've not functionally tested this - just compiled and unit tested.
include/sysemu/char.h | 1 + net/vhost-user.c | 40 ++++------------------------------------ qemu-char.c | 7 +++++++ 3 files changed, 12 insertions(+), 36 deletions(-)
include/sysemu/char.h +1 -0
@@ -437,6 +437,7 @@ int qemu_chr_add_client(CharDriverState *s, int fd);CharDriverState *qemu_chr_find (const char *name);bool chr_is_ringbuf (const CharDriverState *chr); +bool qemu_chr_is_network_server (CharDriverState *chr);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename); void register_char_driver(const char *name, ChardevBackendKind kind,
net/vhost-user.c +4 -36
@@ -27,11 +27,6 @@ typedef struct VhostUserState {bool started; } VhostUserState; -typedef struct VhostUserChardevProps { -bool is_socket; -bool is_unix; -}VhostUserChardevProps ; -VHostNetState *vhost_user_get_vhost_net (NetClientState *nc) {VhostUserState *s =DO_UPCAST (VhostUserState, nc, nc);
@@ -278,45 +273,18 @@ static int net_vhost_user_init(NetClientState *peer, const char *device,return 0 ; } -static int net_vhost_chardev_opts (void *opaque, -const char *name,const char *value, -Error **errp) -{ -VhostUserChardevProps *props = opaque; - -if (strcmp (name,"backend" ) ==0 &&strcmp (value,"socket" ) ==0 ) { - props->is_socket = true; - }else if (strcmp (name,"path" ) ==0 ) { - props->is_unix = true; - }else if (strcmp (name,"server" ) ==0 ) { - }else { -error_setg (errp, -"vhost-user does not support a chardev with option %s=%s" , - name, value); -return -1 ; - } -return 0 ; -} - -static CharDriverState *net_vhost_parse_chardev ( +static CharDriverState *net_vhost_claim_chardev (const NetdevVhostUserOptions *opts,Error **errp) {CharDriverState *chr =qemu_chr_find (opts->chardev); -VhostUserChardevProps props;if (chr ==NULL ) {error_setg (errp,"chardev \"%s\" not found" , opts->chardev);return NULL ; } -/* inspect chardev opts */ -memset (&props,0 ,sizeof (props)); -if (qemu_opt_foreach (chr->opts, net_vhost_chardev_opts, &props, errp)) { -return NULL ; - } - -if (!props.is_socket || !props.is_unix) { -error_setg (errp,"chardev \"%s\" is not a unix socket" , +if (!qemu_chr_is_network_server (chr)) { +error_setg (errp,"chardev \"%s\" does not provide a network server" , opts->chardev);return NULL ; }
@@ -357,7 +325,7 @@ int net_init_vhost_user(const Netdev *netdev, const char *name,assert (netdev->type ==NET_CLIENT_DRIVER_VHOST_USER ); vhost_user_opts = &netdev->u.vhost_user; - chr =net_vhost_parse_chardev (vhost_user_opts, errp); + chr =net_vhost_claim_chardev (vhost_user_opts, errp);if (!chr) {return -1 ; }
qemu-char.c +7 -0
@@ -4596,6 +4596,13 @@ static CharDriverState *qmp_chardev_open_udp(const char *id,return qemu_chr_open_udp (sioc, common, errp); } + +bool qemu_chr_is_network_server (CharDriverState *chr) +{ +return chr->chr_wait_connected !=NULL ; +} + +ChardevReturn *qmp_chardev_add (const char *id,ChardevBackend *backend,Error **errp) {
Signature · 1 line
2.7.4
Hi
Quoted 103 lines · Daniel P. Berrange
The vhost-user code is poking at the QemuOpts instance in the CharDriverState struct, not realizing that it is valid for this to be NULL. e.g. the following crash shows a codepath where it will be NULL:
Program terminated with signal SIGSEGV, Segmentation fault.
#00x000055baf6ab4adcinqemu_opt_foreach(opts=0x0, func=0x55baf696b650
<net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) atutil/qemu-option.c:617
617QTAILQ_FOREACH(opt, &opts->head, next){
[Current thread is 1 (Thread0x7f1d4970bb40(LWP 6603))]
(gdb) bt
#00x000055baf6ab4adcinqemu_opt_foreach(opts=0x0, func=0x55baf696b650
<net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) atutil/qemu-option.c:617
#10x000055baf696b7dainnet_vhost_parse_chardev(opts=0x55baf8ff9260,
errp=0x7ffc51368e48) atnet/vhost-user.c:314
#20x000055baf696b985innet_init_vhost_user(netdev=0x55baf8ff9250,
name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) atnet/vhost-user.c:360
#30x000055baf6960216innet_client_init1(object=0x55baf8ff9250,
is_netdev=true, errp=0x7ffc51368e48) atnet/net.c:1051
#40x000055baf6960518innet_client_init(opts=0x55baf776e7e0,
is_netdev=true, errp=0x7ffc51368f00) atnet/net.c:1108
#50x000055baf696083finnetdev_add(opts=0x55baf776e7e0,
errp=0x7ffc51368f00) atnet/net.c:1186
#60x000055baf69608c7inqmp_netdev_add(qdict=0x55baf7afaf60,
ret=0x7ffc51368f50, errp=0x7ffc51368f48) atnet/net.c:1205
#70x000055baf6622135inhandle_qmp_command(parser=0x55baf77fb590,
tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978
#80x000055baf6a9d099injson_message_process_token
(lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113, y=19)at qobject/json-streamer.c:105 #9 0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598,ch=125 '}', flush=false) at
qobject/json-lexer.c:319
#100x000055baf6abf8f2injson_lexer_feed(lexer=0x55baf77fb598,
buffer=0x7ffc51369170 "}R\204\367\272U", size=1) atqobject/json-lexer.c:369
#110x000055baf6a9d13cinjson_message_parser_feed
(parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) atqobject/json-streamer.c:124
#120x000055baf66221f7inmonitor_qmp_read(opaque=0x55baf77fb530,
buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994
#130x000055baf6757014inqemu_chr_be_write_impl(s=0x55baf7610a40,
buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
#140x000055baf6757076inqemu_chr_be_write(s=0x55baf7610a40,
buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
#150x000055baf675b3b0intcp_chr_read(chan=0x55baf90244b0,
cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
#160x000055baf6a5d655inqio_channel_fd_source_dispatch
(source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) atio/channel-watch.c:84
#170x00007f1d3e80cbbding_main_context_dispatch() from/usr/lib64/libglib-2.0.so.0
#180x000055baf69d3720inglib_pollfds_poll() at main-loop.c:213 #190x000055baf69d37fdinos_host_main_loop_wait(timeout=126000000) at
main-loop.c:258
#200x000055baf69d38adinmain_loop_wait(nonblocking=0) at
main-loop.c:506
#210x000055baf676587binmain_loop() at vl.c:1908
#220x000055baf676d3bfin main (argc=101, argv=0x7ffc5136a6c8,
envp=0x7ffc5136a9f8) at vl.c:4604
(gdb) p opts
$1 = (QemuOpts *)0x0The crash occurred when attaching vhost-user net via QMP:
{ "execute": "chardev-add", "arguments": { "id": "charnet2", "backend": { "type": "socket", "data": { "addr": { "type": "unix", "data": { "path": "/var/run/openvswitch/vhost-user1" } }, "wait": false, "server": false } } }, "id": "libvirt-19" } { "return": { }, "id": "libvirt-19" } { "execute": "netdev_add", "arguments": { "type": "vhost-user", "chardev": "charnet2", "id": "hostnet2" }, "id": "libvirt-20" }
Quoted 5 lines
The vhost-user code should not be poking at the internals of the CharDriverState struct. What it wants is a chardev that is operating as a network server, so add an explicit API to allow it to validate this feature condition without looking at chardev internals.
It has to be a unix socket too, why did you drop that check?
Quoted 125 lines
Signed-off-by Daniel P. Berrange <[email protected]>---
NB, I've not functionally tested this - just compiled and unit tested.
include/sysemu/char.h | 1 + net/vhost-user.c | 40 ++++------------------------------------ qemu-char.c | 7 +++++++ 3 files changed, 12 insertions(+), 36 deletions(-)include/sysemu/char.h +1
-0@@ -437,6 +437,7 @@ int qemu_chr_add_client(CharDriverState *s, int fd);CharDriverState *qemu_chr_find (const char *name);bool chr_is_ringbuf (const CharDriverState *chr); +bool qemu_chr_is_network_server (CharDriverState *chr);QemuOpts *qemu_chr_parse_compat (const char *label,const char *filename); void register_char_driver(const char *name, ChardevBackendKind kind,net/vhost-user.c +3
-35@@ -27,11 +27,6 @@ typedef struct VhostUserState {bool started; } VhostUserState; -typedef struct VhostUserChardevProps { -bool is_socket; -bool is_unix; -}VhostUserChardevProps ; -VHostNetState *vhost_user_get_vhost_net (NetClientState *nc) {VhostUserState *s =DO_UPCAST (VhostUserState, nc, nc);@@ -278,45 +273,18 @@ static int net_vhost_user_init(NetClientState *peer,const char *device, return 0; } -static int net_vhost_chardev_opts (void *opaque, -const char *name,const char *value, -Error **errp) -{ -VhostUserChardevProps *props = opaque; - -if (strcmp (name,"backend" ) ==0 &&strcmp (value,"socket" ) ==0 ) { - props->is_socket = true; - }else if (strcmp (name,"path" ) ==0 ) { - props->is_unix = true; - }else if (strcmp (name,"server" ) ==0 ) { - }else { -error_setg (errp, - "vhost-user does not support a chardev with option %s=%s", - name, value); -return -1 ; - } -return 0 ; -} - -static CharDriverState *net_vhost_parse_chardev ( +static CharDriverState *net_vhost_claim_chardev ( const NetdevVhostUserOptions *opts, Error **errp) {CharDriverState *chr =qemu_chr_find (opts->chardev); -VhostUserChardevProps props;if (chr ==NULL ) {error_setg (errp,"chardev \"%s\" not found" , opts->chardev);return NULL ; } -/* inspect chardev opts */ -memset (&props,0 ,sizeof (props)); -if (qemu_opt_foreach (chr->opts, net_vhost_chardev_opts, &props, errp)) { -return NULL ; - } - -if (!props.is_socket || !props.is_unix) { - error_setg(errp, "chardev \"%s\" is not a unix socket", +if (!qemu_chr_is_network_server (chr)) { + error_setg(errp, "chardev \"%s\" does not provide a networkserver",
opts->chardev); return NULL; }net/vhost-user.c +1
-1@@ -357,7 +325,7 @@ int net_init_vhost_user(const Netdev *netdev, constchar *name, assert(netdev->type == NET_CLIENT_DRIVER_VHOST_USER); vhost_user_opts = &netdev->u.vhost_user; - chr =net_vhost_parse_chardev (vhost_user_opts, errp); + chr =net_vhost_claim_chardev (vhost_user_opts, errp);if (!chr) {return -1 ;}qemu-char.c +7
-0@@ -4596,6 +4596,13 @@ static CharDriverState *qmp_chardev_open_udp(constchar *id, return qemu_chr_open_udp(sioc, common, errp); } + +bool qemu_chr_is_network_server (CharDriverState *chr) +{ +return chr->chr_wait_connected !=NULL ; +} + +ChardevReturn *qmp_chardev_add (const char *id,ChardevBackend *backend,Error **errp){
--
2.7.4
Quoted 1 line
--
Marc-André Lureau
Quoted 108 lines · Marc-André Lureau
Hi
Quoted 103 lines · Daniel P. Berrange
The vhost-user code is poking at the QemuOpts instance in the CharDriverState struct, not realizing that it is valid for this to be NULL. e.g. the following crash shows a codepath where it will be NULL:
Program terminated with signal SIGSEGV, Segmentation fault.
#00x000055baf6ab4adcinqemu_opt_foreach(opts=0x0, func=0x55baf696b650
<net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) atutil/qemu-option.c:617
617QTAILQ_FOREACH(opt, &opts->head, next){
[Current thread is 1 (Thread0x7f1d4970bb40(LWP 6603))]
(gdb) bt
#00x000055baf6ab4adcinqemu_opt_foreach(opts=0x0, func=0x55baf696b650
<net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) atutil/qemu-option.c:617
#10x000055baf696b7dainnet_vhost_parse_chardev(opts=0x55baf8ff9260,
errp=0x7ffc51368e48) atnet/vhost-user.c:314
#20x000055baf696b985innet_init_vhost_user(netdev=0x55baf8ff9250,
name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) atnet/vhost-user.c:360
#30x000055baf6960216innet_client_init1(object=0x55baf8ff9250,
is_netdev=true, errp=0x7ffc51368e48) atnet/net.c:1051
#40x000055baf6960518innet_client_init(opts=0x55baf776e7e0,
is_netdev=true, errp=0x7ffc51368f00) atnet/net.c:1108
#50x000055baf696083finnetdev_add(opts=0x55baf776e7e0,
errp=0x7ffc51368f00) atnet/net.c:1186
#60x000055baf69608c7inqmp_netdev_add(qdict=0x55baf7afaf60,
ret=0x7ffc51368f50, errp=0x7ffc51368f48) atnet/net.c:1205
#70x000055baf6622135inhandle_qmp_command(parser=0x55baf77fb590,
tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978
#80x000055baf6a9d099injson_message_process_token
(lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113, y=19)at qobject/json-streamer.c:105 #9 0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598,ch=125 '}', flush=false) at
qobject/json-lexer.c:319
#100x000055baf6abf8f2injson_lexer_feed(lexer=0x55baf77fb598,
buffer=0x7ffc51369170 "}R\204\367\272U", size=1) atqobject/json-lexer.c:369
#110x000055baf6a9d13cinjson_message_parser_feed
(parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) atqobject/json-streamer.c:124
#120x000055baf66221f7inmonitor_qmp_read(opaque=0x55baf77fb530,
buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994
#130x000055baf6757014inqemu_chr_be_write_impl(s=0x55baf7610a40,
buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
#140x000055baf6757076inqemu_chr_be_write(s=0x55baf7610a40,
buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
#150x000055baf675b3b0intcp_chr_read(chan=0x55baf90244b0,
cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
#160x000055baf6a5d655inqio_channel_fd_source_dispatch
(source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) atio/channel-watch.c:84
#170x00007f1d3e80cbbding_main_context_dispatch() from/usr/lib64/libglib-2.0.so.0
#180x000055baf69d3720inglib_pollfds_poll() at main-loop.c:213 #190x000055baf69d37fdinos_host_main_loop_wait(timeout=126000000) at
main-loop.c:258
#200x000055baf69d38adinmain_loop_wait(nonblocking=0) at
main-loop.c:506
#210x000055baf676587binmain_loop() at vl.c:1908
#220x000055baf676d3bfin main (argc=101, argv=0x7ffc5136a6c8,
envp=0x7ffc5136a9f8) at vl.c:4604
(gdb) p opts
$1 = (QemuOpts *)0x0The crash occurred when attaching vhost-user net via QMP:
{ "execute": "chardev-add", "arguments": { "id": "charnet2", "backend": { "type": "socket", "data": { "addr": { "type": "unix", "data": { "path": "/var/run/openvswitch/vhost-user1" } }, "wait": false, "server": false } } }, "id": "libvirt-19" } { "return": { }, "id": "libvirt-19" } { "execute": "netdev_add", "arguments": { "type": "vhost-user", "chardev": "charnet2", "id": "hostnet2" }, "id": "libvirt-20" }
Quoted 7 lines
Quoted 5 lines
The vhost-user code should not be poking at the internals of the CharDriverState struct. What it wants is a chardev that is operating as a network server, so add an explicit API to allow it to validate this feature condition without looking at chardev internals.
It has to be a unix socket too, why did you drop that check?
Oh does it ? I was reading the code as allowing a TCP or UNIX server. What aspect of it requires UNIX sockets ?
Regards,
Daniel
Signature · 3 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Quoted 124 lines · Daniel P. Berrange
Quoted 12 lines · Marc-André Lureau
Hi
Quoted 7 lines · Daniel P. Berrange
The vhost-user code is poking at the QemuOpts instance in the CharDriverState struct, not realizing that it is valid for this to be NULL. e.g. the following crash shows a codepath where it will be NULL:
Program terminated with signal SIGSEGV, Segmentation fault. #0
0x000055baf6ab4adcinqemu_opt_foreach(opts=0x0,func=0x55baf696b650
Quoted 1 line
Quoted 1 line
<
net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48)at
Quoted 5 lines
Quoted 5 lines
util/qemu-option.c:617
617QTAILQ_FOREACH(opt, &opts->head, next){
[Current thread is 1 (Thread0x7f1d4970bb40(LWP 6603))] (gdb) bt
#00x000055baf6ab4adcinqemu_opt_foreach(opts=0x0,func=0x55baf696b650
Quoted 1 line
Quoted 1 line
<
net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48)at
Quoted 2 lines
Quoted 2 lines
util/qemu-option.c:617
#10x000055baf696b7dainnet_vhost_parse_chardev(opts=0x55baf8ff9260,
Quoted 8 lines
Quoted 8 lines
errp=0x7ffc51368e48) at
net/vhost-user.c:314
#20x000055baf696b985innet_init_vhost_user(netdev=0x55baf8ff9250,
name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) atnet/vhost-user.c:360
#30x000055baf6960216innet_client_init1(object=0x55baf8ff9250,
is_netdev=true, errp=0x7ffc51368e48) atnet/net.c:1051
#40x000055baf6960518innet_client_init(opts=0x55baf776e7e0,
is_netdev=true, errp=0x7ffc51368f00) atnet/net.c:1108Quoted 8 lines
Quoted 8 lines
#5
0x000055baf696083finnetdev_add(opts=0x55baf776e7e0,
errp=0x7ffc51368f00) atnet/net.c:1186
#60x000055baf69608c7inqmp_netdev_add(qdict=0x55baf7afaf60,
ret=0x7ffc51368f50, errp=0x7ffc51368f48) atnet/net.c:1205
#70x000055baf6622135inhandle_qmp_command(parser=0x55baf77fb590,
tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978
#80x000055baf6a9d099injson_message_process_token
(lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113,y=19)
Quoted 5 lines
Quoted 5 lines
at qobject/json-streamer.c:105 #9 0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598,ch=125 '}', flush=false) at
qobject/json-lexer.c:319
#100x000055baf6abf8f2injson_lexer_feed(lexer=0x55baf77fb598,
buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at
qobject/json-lexer.c:369Quoted 2 lines
Quoted 2 lines
#11
0x000055baf6a9d13cinjson_message_parser_feed
(parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U",size=1) at
Quoted 9 lines
Quoted 9 lines
qobject/json-streamer.c:124
#120x000055baf66221f7inmonitor_qmp_read(opaque=0x55baf77fb530,
buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994
#130x000055baf6757014inqemu_chr_be_write_impl(s=0x55baf7610a40,
buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
#140x000055baf6757076inqemu_chr_be_write(s=0x55baf7610a40,
buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
#150x000055baf675b3b0intcp_chr_read(chan=0x55baf90244b0,Quoted 8 lines
Quoted 8 lines
cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
#160x000055baf6a5d655inqio_channel_fd_source_dispatch
(source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) atio/channel-watch.c:84
#170x00007f1d3e80cbbding_main_context_dispatch() from/usr/lib64/libglib-2.0.so.0
#180x000055baf69d3720inglib_pollfds_poll() at main-loop.c:213 #190x000055baf69d37fdinos_host_main_loop_wait(timeout=126000000)at
Quoted 53 lines
Quoted 52 lines
main-loop.c:258
#200x000055baf69d38adinmain_loop_wait(nonblocking=0) at
main-loop.c:506
#210x000055baf676587binmain_loop() at vl.c:1908 #220x000055baf676d3bfin main (argc=101, argv=0x7ffc5136a6c8,
envp=0x7ffc5136a9f8) at vl.c:4604
(gdb) p opts
$1 = (QemuOpts *)0x0The crash occurred when attaching vhost-user net via QMP:
{ "execute": "chardev-add", "arguments": { "id": "charnet2", "backend": { "type": "socket", "data": { "addr": { "type": "unix", "data": { "path": "/var/run/openvswitch/vhost-user1" } }, "wait": false, "server": false } } }, "id": "libvirt-19" } { "return": { }, "id": "libvirt-19" } { "execute": "netdev_add", "arguments": { "type": "vhost-user", "chardev": "charnet2", "id": "hostnet2" }, "id": "libvirt-20" }The vhost-user code should not be poking at the internals of the CharDriverState struct. What it wants is a chardev that is operating as a network server, so add an explicit API to allow it to validate this feature condition without looking at chardev internals.
Quoted 6 lines
Quoted 1 line
It has to be a unix socket too, why did you drop that check?
Oh does it ? I was reading the code as allowing a TCP or UNIX server. What aspect of it requires UNIX sockets ?
docs/specs/vhost-user.txt
"It implements the control plane needed
to establish virtqueue sharing with a user space process on the same host. It
uses communication over a Unix domain socket to share file descriptors in the
ancillary data of the message."
Quoted 10 lines
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/
:|
|: http://libvirt.org -o- http://virt-manager.org
:|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/
:|
Signature · 1 line
Marc-André Lureau