File tree Expand file tree Collapse file tree 5 files changed +31
-20
lines changed Expand file tree Collapse file tree 5 files changed +31
-20
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ struct mngr_msg {
27
27
int err ;
28
28
29
29
/* ack of WAKEUP_REASON */
30
- int reason ;
30
+ unsigned reason ;
31
31
32
32
/* ack of DM_QUERY */
33
33
int state ;
Original file line number Diff line number Diff line change @@ -392,7 +392,7 @@ int suspend_vm(char *vmname)
392
392
return ack .data .err ;
393
393
}
394
394
395
- int resume_vm (char * vmname )
395
+ int resume_vm (char * vmname , unsigned reason )
396
396
{
397
397
struct mngr_msg req ;
398
398
struct mngr_msg ack ;
@@ -401,6 +401,8 @@ int resume_vm(char *vmname)
401
401
req .msgid = DM_RESUME ;
402
402
req .timestamp = time (NULL );
403
403
404
+ req .data .reason = reason ;
405
+
404
406
send_msg (vmname , & req , & ack );
405
407
406
408
if (ack .data .err ) {
Original file line number Diff line number Diff line change @@ -466,23 +466,27 @@ static int acrnctl_do_suspend(int argc, char *argv[])
466
466
static int acrnctl_do_resume (int argc , char * argv [])
467
467
{
468
468
struct vmmngr_struct * s ;
469
- int i ;
469
+ unsigned reason = 0 ;
470
470
471
- for (i = 1 ; i < argc ; i ++ ) {
472
- s = vmmngr_find (argv [i ]);
473
- if (!s ) {
474
- printf ("Can't find vm %s\n" , argv [i ]);
475
- continue ;
476
- }
471
+ s = vmmngr_find (argv [1 ]);
472
+ if (!s ) {
473
+ printf ("Can't find vm %s\n" , argv [1 ]);
474
+ return -1 ;
475
+ }
477
476
478
- switch (s -> state ) {
479
- case VM_PAUSED :
480
- resume_vm (argv [i ]);
481
- break ;
482
- default :
483
- printf ("%s current state %s, can't resume\n" ,
484
- argv [i ], state_str [s -> state ]);
485
- }
477
+ if (argc == 3 ) {
478
+ sscanf (argv [2 ], "%x" , & reason );
479
+ reason = (reason & (0xff << 24 )) ? 0 : reason ;
480
+ }
481
+
482
+ switch (s -> state ) {
483
+ case VM_PAUSED :
484
+ resume_vm (argv [1 ], reason );
485
+ printf ("resume %s reason(0x%x\n" , argv [1 ], reason );
486
+ break ;
487
+ default :
488
+ printf ("%s current state %s, can't resume\n" ,
489
+ argv [1 ], state_str [s -> state ]);
486
490
}
487
491
488
492
return 0 ;
Original file line number Diff line number Diff line change @@ -56,6 +56,6 @@ int start_vm(char *vmname);
56
56
int pause_vm (char * vmname );
57
57
int continue_vm (char * vmname );
58
58
int suspend_vm (char * vmname );
59
- int resume_vm (char * vmname );
59
+ int resume_vm (char * vmname , unsigned reason );
60
60
61
61
#endif /* _ACRNCTL_H_ */
Original file line number Diff line number Diff line change @@ -105,11 +105,13 @@ static void try_do_works(void)
105
105
}
106
106
107
107
static void acrnd_run_vm (char * name );
108
+ unsigned get_sos_wakeup_reason (void );
108
109
109
110
/* Time to run/resume VM */
110
111
void acrnd_vm_timer_func (struct work_arg * arg )
111
112
{
112
113
struct vmmngr_struct * vm ;
114
+ unsigned reason ;
113
115
114
116
if (!arg ) {
115
117
pdebug ();
@@ -128,7 +130,8 @@ void acrnd_vm_timer_func(struct work_arg *arg)
128
130
acrnd_run_vm (arg -> name );
129
131
break ;
130
132
case VM_PAUSED :
131
- resume_vm (arg -> name );
133
+ reason = get_sos_wakeup_reason ();
134
+ resume_vm (arg -> name , reason );
132
135
break ;
133
136
default :
134
137
pdebug ();
@@ -235,6 +238,7 @@ static int active_all_vms(void)
235
238
struct vmmngr_struct * vm ;
236
239
int ret = 0 ;
237
240
pid_t pid ;
241
+ unsigned reason ;
238
242
239
243
vmmngr_update ();
240
244
@@ -246,7 +250,8 @@ static int active_all_vms(void)
246
250
acrnd_run_vm (vm -> name );
247
251
break ;
248
252
case VM_PAUSED :
249
- ret += resume_vm (vm -> name );
253
+ reason = get_sos_wakeup_reason ();
254
+ ret += resume_vm (vm -> name , reason );
250
255
break ;
251
256
default :
252
257
pdebug ();
You can’t perform that action at this time.
0 commit comments