@@ -177,6 +177,40 @@ def get_watchdog(watchdogs, guest):
177177 except Exception , e :
178178 fail (_ ("Error in watchdog device parameters: %s" ) % str (e ))
179179
180+ def get_security (security , guest ):
181+ seclist = cli .listify (security )
182+ secopts = seclist and seclist [0 ] or None
183+ if not secopts :
184+ return
185+
186+ # Parse security opts
187+ opts = cli .parse_optstr (secopts )
188+ secmodel = virtinst .Seclabel (guest .conn )
189+
190+ def get_and_clear (dictname ):
191+ val = None
192+ if opts .has_key (dictname ):
193+ val = opts [dictname ]
194+ del (opts [dictname ])
195+ return val
196+
197+ mode = get_and_clear ("type" )
198+ label = get_and_clear ("label" )
199+
200+ if label :
201+ secmodel .label = label
202+ if not mode :
203+ mode = secmodel .SECLABEL_TYPE_STATIC
204+ if mode :
205+ secmodel .type = mode
206+
207+ # If extra parameters, then user passed some garbage param
208+ if opts :
209+ raise ValueError (_ ("Unknown option(s) %s" ) % opts .keys ())
210+
211+ secmodel .get_xml_config ()
212+ guest .seclabel = secmodel
213+
180214def parse_disk_option (guest , path , size ):
181215 """helper to properly parse --disk options"""
182216 abspath = None
@@ -554,6 +588,9 @@ def parse_args():
554588 action = "callback" , callback = cli .check_before_store ,
555589 help = _ ("Human readable description of the VM to store in "
556590 "the generated XML." ))
591+ geng .add_option ("" , "--security" , type = "string" , dest = "security" ,
592+ action = "callback" , callback = cli .check_before_store ,
593+ help = _ ("Set domain security driver configuration." ))
557594 parser .add_option_group (geng )
558595
559596 insg = OptionGroup (parser , _ ("Installation Method Options" ))
@@ -790,6 +827,7 @@ def main():
790827 cli .get_uuid (options .uuid , guest )
791828 cli .get_vcpus (options .vcpus , options .check_cpu , guest , conn )
792829 cli .get_cpuset (options .cpuset , guest .memory , guest , conn )
830+ get_security (options .security , guest )
793831
794832 get_watchdog (options .watchdog , guest )
795833 cli .get_sound (options .sound , options .soundhw , guest )
0 commit comments