@@ -57,13 +57,17 @@ 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
6263 . get ( "org.lowrisc.hotplug.device" )
6364 . context (
6465 "Cannot find annotation `org.lowrisc.hotplug.device`. Please use normal runc instead." ,
65- ) ?
66- . parse ( ) ?;
66+ ) ?;
67+ for device in device_annotation. split ( ',' ) {
68+ let devref: DeviceRef = device. parse ( ) ?;
69+ devices. push ( devref. device ( ) ?. syspath ( ) . to_owned ( ) ) ;
70+ }
6771
6872 let mut symlinks = Vec :: < Symlink > :: new ( ) ;
6973 if let Some ( symlink_annotation) = config. annotations . get ( "org.lowrisc.hotplug.symlinks" ) {
@@ -72,9 +76,6 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
7276 }
7377 }
7478
75- // Run this before calling into runc to create the container.
76- let hub_path = device. device ( ) ?. syspath ( ) . to_owned ( ) ;
77-
7879 // Switch the logger to syslog. The runc logs are barely forwarded to the user or syslog by
7980 // container managers and orchestrators, while we do want to preserve the hotplug events.
8081 util:: log:: global_replace ( Box :: new ( util:: log:: SyslogLogger :: new ( ) ?) ) ;
@@ -107,7 +108,7 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
107108 rustix:: stdio:: dup2_stdout ( & null) ?;
108109 rustix:: stdio:: dup2_stderr ( null) ?;
109110
110- let mut hotplug = HotPlug :: new ( Arc :: clone ( & container) , hub_path . clone ( ) , symlinks) ?;
111+ let mut hotplug = HotPlug :: new ( Arc :: clone ( & container) , devices . clone ( ) , symlinks) ?;
111112 let hotplug_stream = hotplug. run ( ) ;
112113
113114 let container_stream = {
@@ -133,7 +134,7 @@ async fn create(global: GlobalOptions, create: CreateOptions, notifier: OwnedFd)
133134 let notifier = notifier. take ( ) . context ( "Initialized event seen twice" ) ?;
134135 rustix:: io:: write ( notifier, & [ 0 ] ) ?;
135136 }
136- Event :: Detach ( dev) if dev. syspath ( ) == hub_path => {
137+ Event :: Detach ( dev) if devices . iter ( ) . any ( |hub| dev. syspath ( ) == hub ) => {
137138 info ! ( "Hub device detached. Stopping container." ) ;
138139 let _ = container. kill ( Signal :: KILL ) . await ;
139140 container. wait ( ) . await ?;
0 commit comments