3030#include "container.h"
3131#include "syscall.h"
3232
33- struct hyper_pod global_pod = {
33+ static struct hyper_pod global_pod = {
3434 .containers = LIST_HEAD_INIT (global_pod .containers ),
3535 .exec_head = LIST_HEAD_INIT (global_pod .exec_head ),
3636};
@@ -555,10 +555,8 @@ static int hyper_destroy_pod(struct hyper_pod *pod, int error)
555555 return 0 ;
556556}
557557
558- static int hyper_start_pod (char * json , int length )
558+ static int hyper_start_pod (struct hyper_pod * pod , char * json , int length )
559559{
560- struct hyper_pod * pod = & global_pod ;
561-
562560 fprintf (stdout , "call hyper_start_pod, json %s, len %d\n" , json , length );
563561
564562 if (pod -> init_pid )
@@ -584,11 +582,10 @@ static int hyper_start_pod(char *json, int length)
584582 return 0 ;
585583}
586584
587- static int hyper_new_container (char * json , int length )
585+ static int hyper_new_container (struct hyper_pod * pod , char * json , int length )
588586{
589587 int ret ;
590588 struct hyper_container * c ;
591- struct hyper_pod * pod = & global_pod ;
592589
593590 fprintf (stdout , "call hyper_new_container, json %s, len %d\n" , json , length );
594591
@@ -624,10 +621,9 @@ static int hyper_new_container(char *json, int length)
624621 return ret ;
625622}
626623
627- static int hyper_kill_container (char * json , int length )
624+ static int hyper_kill_container (struct hyper_pod * pod , char * json , int length )
628625{
629626 struct hyper_container * c ;
630- struct hyper_pod * pod = & global_pod ;
631627 int ret = -1 ;
632628
633629 JSON_Value * value = hyper_json_parse (json , length );
@@ -649,10 +645,9 @@ static int hyper_kill_container(char *json, int length)
649645 return ret ;
650646}
651647
652- static int hyper_remove_container (char * json , int length )
648+ static int hyper_remove_container (struct hyper_pod * pod , char * json , int length )
653649{
654650 struct hyper_container * c ;
655- struct hyper_pod * pod = & global_pod ;
656651 int ret = -1 ;
657652
658653 JSON_Value * value = hyper_json_parse (json , length );
@@ -716,7 +711,7 @@ static int hyper_open_container_file(void *data)
716711 exit (ret );
717712}
718713
719- static int hyper_cmd_rw_file (char * json , int length , uint32_t * rdatalen , uint8_t * * rdata , int rw )
714+ static int hyper_cmd_rw_file (struct hyper_pod * pod , char * json , int length , uint32_t * rdatalen , uint8_t * * rdata , int rw )
720715{
721716 struct file_command cmd = {
722717 .id = NULL ,
@@ -727,7 +722,6 @@ static int hyper_cmd_rw_file(char *json, int length, uint32_t *rdatalen, uint8_t
727722 .rw = rw ,
728723 };
729724 struct hyper_container * c ;
730- struct hyper_pod * pod = & global_pod ;
731725 char * data = NULL ;
732726 void * stack = NULL ;
733727 int stacksize = getpagesize () * 4 ;
@@ -1102,7 +1096,7 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11021096 hyper_set_be32 (data , APIVERSION );
11031097 break ;
11041098 case STARTPOD :
1105- ret = hyper_start_pod ((char * )buf -> data + 8 , len - 8 );
1099+ ret = hyper_start_pod (pod , (char * )buf -> data + 8 , len - 8 );
11061100 hyper_print_uptime ();
11071101 break ;
11081102 case DESTROYPOD :
@@ -1111,13 +1105,13 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11111105 hyper_destroy_pod (pod , 0 );
11121106 return 0 ;
11131107 case EXECCMD :
1114- ret = hyper_exec_cmd ((char * )buf -> data + 8 , len - 8 );
1108+ ret = hyper_exec_cmd (pod , (char * )buf -> data + 8 , len - 8 );
11151109 break ;
11161110 case WRITEFILE :
1117- ret = hyper_cmd_rw_file ((char * )buf -> data + 8 , len - 8 , NULL , NULL , WRITEFILE );
1111+ ret = hyper_cmd_rw_file (pod , (char * )buf -> data + 8 , len - 8 , NULL , NULL , WRITEFILE );
11181112 break ;
11191113 case READFILE :
1120- ret = hyper_cmd_rw_file ((char * )buf -> data + 8 , len - 8 , & datalen , & data , READFILE );
1114+ ret = hyper_cmd_rw_file (pod , (char * )buf -> data + 8 , len - 8 , & datalen , & data , READFILE );
11211115 break ;
11221116 case PING :
11231117 break ;
@@ -1128,13 +1122,13 @@ static int hyper_ctlmsg_handle(struct hyper_event *he, uint32_t len)
11281122 ret = hyper_set_win_size (pod , (char * )buf -> data + 8 , len - 8 );
11291123 break ;
11301124 case NEWCONTAINER :
1131- ret = hyper_new_container ((char * )buf -> data + 8 , len - 8 );
1125+ ret = hyper_new_container (pod , (char * )buf -> data + 8 , len - 8 );
11321126 break ;
11331127 case KILLCONTAINER :
1134- ret = hyper_kill_container ((char * )buf -> data + 8 , len - 8 );
1128+ ret = hyper_kill_container (pod , (char * )buf -> data + 8 , len - 8 );
11351129 break ;
11361130 case REMOVECONTAINER :
1137- ret = hyper_remove_container ((char * )buf -> data + 8 , len - 8 );
1131+ ret = hyper_remove_container (pod , (char * )buf -> data + 8 , len - 8 );
11381132 break ;
11391133 case ONLINECPUMEM :
11401134 hyper_cmd_online_cpu_mem ();
0 commit comments