@@ -145,7 +145,6 @@ pub struct TestVm {
145
145
data_dir : Utf8PathBuf ,
146
146
147
147
guest_os : Box < dyn GuestOs > ,
148
- tracing_span : tracing:: Span ,
149
148
150
149
state : VmState ,
151
150
@@ -229,9 +228,6 @@ impl TestVm {
229
228
)
230
229
} ) ?;
231
230
232
- let span =
233
- info_span ! ( parent: None , "VM" , vm = %vm_spec. vm_name, %vm_id) ;
234
-
235
231
let data_dir = params. data_dir . to_path_buf ( ) ;
236
232
let server_addr = params. server_addr ;
237
233
let server = server:: PropolisServer :: new (
@@ -250,7 +246,6 @@ impl TestVm {
250
246
environment_spec,
251
247
data_dir,
252
248
guest_os,
253
- tracing_span : span,
254
249
state : VmState :: New ,
255
250
cleanup_task_tx,
256
251
} )
@@ -274,12 +269,12 @@ impl TestVm {
274
269
275
270
/// Sends an instance ensure request to this VM's server, allowing it to
276
271
/// transition into the running state.
272
+ #[ instrument( skip_all, fields( vm = self . spec. vm_name, vm_id = %self . id) ) ]
277
273
async fn instance_ensure_internal < ' a > (
278
274
& self ,
279
275
migrate : Option < InstanceMigrateInitiateRequest > ,
280
276
console_source : InstanceConsoleSource < ' a > ,
281
277
) -> Result < SerialConsole > {
282
- let _span = self . tracing_span . enter ( ) ;
283
278
let ( vcpus, memory_mib) = match self . state {
284
279
VmState :: New => (
285
280
self . spec . instance_spec . devices . board . cpus ,
@@ -435,18 +430,18 @@ impl TestVm {
435
430
self . put_instance_state ( InstanceStateRequested :: Reboot ) . await
436
431
}
437
432
433
+ #[ instrument( skip_all, fields( vm = self . spec. vm_name, vm_id = %self . id) ) ]
438
434
async fn put_instance_state (
439
435
& self ,
440
436
state : InstanceStateRequested ,
441
437
) -> PropolisClientResult < ( ) > {
442
- let _span = self . tracing_span . enter ( ) ;
443
438
info ! ( ?state, "Requesting instance state change" ) ;
444
439
self . client . instance_state_put ( ) . body ( state) . send ( ) . await
445
440
}
446
441
447
442
/// Issues a Propolis client `instance_get` request.
443
+ #[ instrument( skip_all, fields( vm = self . spec. vm_name, vm_id = %self . id) ) ]
448
444
pub async fn get ( & self ) -> Result < InstanceGetResponse > {
449
- let _span = self . tracing_span . enter ( ) ;
450
445
info ! ( "Sending instance get request to server" ) ;
451
446
self . client
452
447
. instance_get ( )
@@ -456,8 +451,8 @@ impl TestVm {
456
451
. with_context ( || anyhow ! ( "failed to query instance properties" ) )
457
452
}
458
453
454
+ #[ instrument( skip_all, fields( vm = self . spec. vm_name, vm_id = %self . id) ) ]
459
455
pub async fn get_spec ( & self ) -> Result < InstanceSpecGetResponse > {
460
- let _span = self . tracing_span . enter ( ) ;
461
456
info ! ( "Sending instance spec get request to server" ) ;
462
457
self . client
463
458
. instance_spec_get ( )
@@ -469,6 +464,15 @@ impl TestVm {
469
464
470
465
/// Starts this instance by issuing an ensure request that specifies a
471
466
/// migration from `source` and then running the target.
467
+ #[ instrument(
468
+ skip_all,
469
+ fields(
470
+ source = source. spec. vm_name,
471
+ target = self . spec. vm_name,
472
+ source_id = %source. id,
473
+ target_id = %self . id
474
+ )
475
+ ) ]
472
476
pub async fn migrate_from (
473
477
& mut self ,
474
478
source : & Self ,
@@ -485,7 +489,6 @@ impl TestVm {
485
489
}
486
490
} ;
487
491
488
- let _vm_guard = self . tracing_span . enter ( ) ;
489
492
match self . state {
490
493
VmState :: New => {
491
494
let server_addr = source
@@ -582,12 +585,12 @@ impl TestVm {
582
585
. into_inner ( ) )
583
586
}
584
587
588
+ #[ instrument( skip_all, fields( vm = self . spec. vm_name, vm_id = %self . id) ) ]
585
589
pub async fn wait_for_state (
586
590
& self ,
587
591
target : InstanceState ,
588
592
timeout_duration : Duration ,
589
593
) -> Result < ( ) > {
590
- let _span = self . tracing_span . enter ( ) ;
591
594
info ! (
592
595
"Waiting {:?} for server to reach state {:?}" ,
593
596
timeout_duration, target
@@ -633,11 +636,15 @@ impl TestVm {
633
636
/// initial login prompt and the login prompt itself.
634
637
pub async fn wait_to_boot ( & self ) -> Result < ( ) > {
635
638
let timeout_duration = Duration :: from_secs ( 300 ) ;
636
- let _span = self . tracing_span . enter ( ) ;
637
- info ! ( "Waiting {:?} for guest to boot" , timeout_duration) ;
638
-
639
639
let boot_sequence = self . guest_os . get_login_sequence ( ) ;
640
640
let boot = async move {
641
+ info ! (
642
+ vm = self . spec. vm_name,
643
+ vm_id = %self . id,
644
+ ?timeout_duration,
645
+ "waiting for guest to boot"
646
+ ) ;
647
+
641
648
for step in boot_sequence. 0 {
642
649
debug ! ( ?step, "executing command in boot sequence" ) ;
643
650
match step {
@@ -660,6 +667,8 @@ impl TestVm {
660
667
}
661
668
}
662
669
}
670
+
671
+ info ! ( "Guest has booted" ) ;
663
672
Ok :: < ( ) , anyhow:: Error > ( ( ) )
664
673
}
665
674
. instrument ( info_span ! ( "wait_to_boot" ) ) ;
@@ -671,19 +680,18 @@ impl TestVm {
671
680
}
672
681
} ;
673
682
674
- info ! ( "Guest has booted" ) ;
675
683
Ok ( ( ) )
676
684
}
677
685
678
686
/// Waits for up to `timeout_duration` for `line` to appear on the guest
679
687
/// serial console, then returns the unconsumed portion of the serial
680
688
/// console buffer that preceded the requested string.
689
+ #[ instrument( skip_all, fields( vm = self . spec. vm_name, vm_id = %self . id) ) ]
681
690
pub async fn wait_for_serial_output (
682
691
& self ,
683
692
line : & str ,
684
693
timeout_duration : impl Into < SerialOutputTimeout > ,
685
694
) -> Result < String > {
686
- let _span = self . tracing_span . enter ( ) ;
687
695
let timeout_duration: SerialOutputTimeout = timeout_duration. into ( ) ;
688
696
info ! (
689
697
target = line,
@@ -825,7 +833,6 @@ impl Drop for TestVm {
825
833
// for all under-destruction VMs to be reaped before exiting.
826
834
let client = self . client . clone ( ) ;
827
835
let server = self . server . take ( ) ;
828
- let span = self . tracing_span . clone ( ) ;
829
836
let task = tokio:: spawn (
830
837
async move {
831
838
let _server = server;
@@ -890,7 +897,9 @@ impl Drop for TestVm {
890
897
error ! ( %e, "dropped VM not destroyed after 5 seconds" ) ;
891
898
}
892
899
}
893
- . instrument ( span) ,
900
+ . instrument (
901
+ info_span ! ( "VM cleanup" , vm = self . spec. vm_name, vm_id = %self . id) ,
902
+ ) ,
894
903
) ;
895
904
896
905
let _ = self . cleanup_task_tx . send ( task) ;
0 commit comments