@@ -57,13 +57,18 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
5757 let mut notifier = Some ( notifier) ;
5858
5959 let config = runc:: config:: Config :: from_bundle ( & create. bundle ) ?;
60- let device: DeviceRef = config
60+ let mut devices = Vec :: new ( ) ;
61+ let device_annotation = config
6162 . annotations
62- . get ( "org.lowrisc.hotplug.device" )
63+ . get ( "org.lowrisc.hotplug.devices" )
64+ . or_else ( || config. annotations . get ( "org.lowrisc.hotplug.device" ) )
6365 . context (
64- "Cannot find annotation `org.lowrisc.hotplug.device`. Please use normal runc instead." ,
65- ) ?
66- . parse ( ) ?;
66+ "Cannot find annotation `org.lowrisc.hotplug.devices`. Please use normal runc instead." ,
67+ ) ?;
68+ for device in device_annotation. split ( ',' ) {
69+ let devref: DeviceRef = device. parse ( ) ?;
70+ devices. push ( devref. device ( ) ?. syspath ( ) . to_owned ( ) ) ;
71+ }
6772
6873 let mut symlinks = Vec :: < Symlink > :: new ( ) ;
6974 if let Some ( symlink_annotation) = config. annotations . get ( "org.lowrisc.hotplug.symlinks" ) {
@@ -72,9 +77,6 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
7277 }
7378 }
7479
75- // Run this before calling into runc to create the container.
76- let hub_path = device. device ( ) ?. syspath ( ) . to_owned ( ) ;
77-
7880 // Switch the logger to syslog. The runc logs are barely forwarded to the user or syslog by
7981 // container managers and orchestrators, while we do want to preserve the hotplug events.
8082 util:: log:: global_replace ( Box :: new ( util:: log:: SyslogLogger :: new ( ) ?) ) ;
@@ -107,7 +109,7 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
107109 rustix:: stdio:: dup2_stdout ( & null) ?;
108110 rustix:: stdio:: dup2_stderr ( null) ?;
109111
110- let mut hotplug = HotPlug :: new ( Arc :: clone ( & container) , hub_path . clone ( ) , symlinks) ?;
112+ let mut hotplug = HotPlug :: new ( Arc :: clone ( & container) , devices . clone ( ) , symlinks) ?;
111113 let hotplug_stream = hotplug. run ( ) ;
112114
113115 let container_stream = {
@@ -133,7 +135,7 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
133135 let notifier = notifier. take ( ) . context ( "Initialized event seen twice" ) ?;
134136 rustix:: io:: write ( notifier, & [ 0 ] ) ?;
135137 }
136- Event :: Detach ( dev) if dev. syspath ( ) == hub_path => {
138+ Event :: Detach ( dev) if devices . iter ( ) . any ( |hub| dev. syspath ( ) == hub ) => {
137139 info ! ( "Hub device detached. Stopping container." ) ;
138140 let _ = container. kill ( Signal :: KILL ) . await ;
139141 container. wait ( ) . await ?;
0 commit comments