@@ -889,25 +889,33 @@ static void hyper_cmd_online_cpu_mem()
889889 }
890890}
891891
892- static int hyper_setup_ctl_channel ( char * name )
892+ static int hyper_ctl_send_ready ( int fd )
893893{
894894 uint8_t buf [8 ];
895- int ret = hyper_open_channel (name , 0 );
896- if (ret < 0 )
897- return ret ;
898895
899896 fprintf (stdout , "send ready message\n" );
900897 hyper_set_be32 (buf , READY );
901898 hyper_set_be32 (buf + 4 , 8 );
902- if (hyper_send_data_block (ret , buf , 8 ) < 0 ) {
899+ if (hyper_send_data_block (fd , buf , 8 ) < 0 ) {
903900 perror ("send READY MESSAGE failed\n" );
904- goto out ;
901+ return -1 ;
905902 }
903+ return 0 ;
904+ }
906905
907- return ret ;
908- out :
909- close (ret );
910- return -1 ;
906+ static int hyper_setup_ctl_channel (char * name )
907+ {
908+ int fd ;
909+
910+ fd = hyper_open_channel (name , 0 );
911+ if (fd < 0 )
912+ return fd ;
913+ if (hyper_ctl_send_ready (fd ) < 0 ) {
914+ close (fd );
915+ return -1 ;
916+ }
917+
918+ return fd ;
911919}
912920
913921static int hyper_setup_tty_channel (char * name )
@@ -1264,7 +1272,15 @@ static struct hyper_event_ops hyper_ttyfd_ops = {
12641272
12651273static int hyper_vsock_ctl_accept (struct hyper_event * he , int efd , int events )
12661274{
1267- return hyper_vsock_accept (he , efd , & hyper_epoll .ctl , & hyper_ctlfd_ops );
1275+ if (hyper_vsock_accept (he , efd , & hyper_epoll .ctl , & hyper_ctlfd_ops ) < 0 )
1276+ return -1 ;
1277+
1278+ if (hyper_ctl_send_ready (hyper_epoll .ctl .fd )) {
1279+ hyper_event_hup (& hyper_epoll .ctl , efd );
1280+ return -1 ;
1281+ }
1282+
1283+ return 0 ;
12681284}
12691285
12701286static int hyper_vsock_msg_accept (struct hyper_event * he , int efd , int events )
0 commit comments