@@ -482,6 +482,74 @@ def test_207_domain_start_prohibition(self):
482
482
self .loop .run_until_complete (self .vm .start ())
483
483
self .assertFalse (self .vm .is_running ())
484
484
485
+ async def _test_bootmode (self , tpl , vm ):
486
+ await tpl .start ()
487
+ await tpl .run_for_stdio (
488
+ "cat > /etc/qubes/post-install.d/50-test.sh" ,
489
+ input = b"""#!/bin/sh
490
+
491
+ qvm-features-request boot-mode.kernelopts.mode1="opt1=val1 opt2"
492
+ qvm-features-request boot-mode.name.mode1="Fancy name for mode 1"
493
+ qvm-features-request boot-mode.kernelopts.mode2="only-one-option-no-value"
494
+ qvm-features-request boot-mode.active=mode1
495
+ qvm-features-request boot-mode.appvm-default=mode2
496
+ """ ,
497
+ user = "root" ,
498
+ )
499
+ await tpl .run_for_stdio (
500
+ "chmod +x " "/etc/qubes/post-install.d/50-test.sh" , user = "root"
501
+ )
502
+ await tpl .run_service_for_stdio ("qubes.PostInstall" , user = "root" )
503
+ await tpl .shutdown (wait = True )
504
+
505
+ self .assertEqual (tpl .bootmode , "mode1" )
506
+ if tpl != vm :
507
+ self .assertEqual (vm .bootmode , "mode2" )
508
+ await vm .start ()
509
+ cmdline = await vm .run_for_stdio ("cat /proc/cmdline" ).decode ()
510
+ if tpl != vm :
511
+ self .assertIn ("only-one-option-no-value" , cmdline )
512
+ else :
513
+ self .assertIn ("opv1=val1" , cmdline )
514
+
515
+ def test_210_bootmode_template (self ):
516
+ self .test_template = self .app .add_new_vm (
517
+ qubes .vm .templatevm .TemplateVM ,
518
+ name = self .make_vm_name ("tpl" ),
519
+ label = "red" ,
520
+ )
521
+ self .test_template .clone_properties (self .app .default_template )
522
+ self .test_template .features .update (self .app .default_template .features )
523
+ self .test_template .tags .update (self .app .default_template .tags )
524
+ self .loop .run_until_complete (
525
+ self .test_template .clone_disk_files (self .app .default_template )
526
+ )
527
+ self .vm = self .app .add_new_vm (
528
+ qubes .vm .appvm .AppVM ,
529
+ name = self .make_vm_name ("vm" ),
530
+ template = self .test_template ,
531
+ label = "red" ,
532
+ )
533
+ self .loop .run_until_complete (self .vm .create_on_disk ())
534
+ self .app .save ()
535
+ self .loop .run_until_complete (
536
+ self ._test_bootmode (self .test_template , self .vm )
537
+ )
538
+
539
+ def test_211_bootmode_standalone (self ):
540
+ self .vm = self .app .add_new_vm (
541
+ qubes .vm .standalonevm .StandaloneVM ,
542
+ name = self .make_vm_name ("vm" ),
543
+ label = "red" ,
544
+ )
545
+ self .vm .clone_properties (self .app .default_template )
546
+ self .vm .features .update (self .app .default_template .features )
547
+ self .loop .run_until_complete (
548
+ self .vm .clone_disk_files (self .app .default_template )
549
+ )
550
+ self .app .save ()
551
+ self .loop .run_until_complete (self ._test_bootmode (self .vm , self .vm ))
552
+
485
553
486
554
class TC_01_Properties (qubes .tests .SystemTestCase ):
487
555
# pylint: disable=attribute-defined-outside-init
0 commit comments