@@ -78,14 +78,16 @@ type AttachDeviceParams struct {
7878
7979 configPath string // config.v1.json
8080 resultFile string // init-debug.log
81+ withDevID bool
8182}
8283
83- func NewAttachDeviceParams (id string , tenant int , configPath string , resultFile string ) * AttachDeviceParams {
84+ func NewAttachDeviceParams (id string , tenant int , configPath string , resultFile string , withDevID bool ) * AttachDeviceParams {
8485 return & AttachDeviceParams {
8586 id : id ,
8687 tenant : tenant ,
8788 configPath : configPath ,
8889 resultFile : resultFile ,
90+ withDevID : withDevID ,
8991 }
9092}
9193
@@ -299,8 +301,14 @@ func AttachDevice(ctx context.Context, params *AttachDeviceParams) (devName stri
299301 }
300302 }()
301303
302- if err = os .WriteFile (path .Join (targetPath , "control" ), ([]byte )(fmt .Sprintf ("dev_config=overlaybd/%s" , configPath )), 0666 ); err != nil {
303- return devName , fmt .Errorf ("failed to write target dev_config for %s: dev_config=overlaybd/%s: %w" , targetPath , configPath , err )
304+ if params .withDevID {
305+ if err = os .WriteFile (path .Join (targetPath , "control" ), ([]byte )(fmt .Sprintf ("dev_config=overlaybd/%s;%s" , configPath , snID )), 0666 ); err != nil {
306+ return devName , fmt .Errorf ("failed to write target dev_config for %s: dev_config=overlaybd/%s;%s: %w" , targetPath , configPath , snID , err )
307+ }
308+ } else {
309+ if err = os .WriteFile (path .Join (targetPath , "control" ), ([]byte )(fmt .Sprintf ("dev_config=overlaybd/%s" , configPath )), 0666 ); err != nil {
310+ return devName , fmt .Errorf ("failed to write target dev_config for %s: dev_config=overlaybd/%s: %w" , targetPath , configPath , err )
311+ }
304312 }
305313
306314 err = os .WriteFile (path .Join (targetPath , "control" ), ([]byte )(fmt .Sprintf ("max_data_area_mb=%d" , obdMaxDataAreaMB )), 0666 )
@@ -455,6 +463,7 @@ func (o *snapshotter) attachAndMountBlockDevice(ctx context.Context, snID string
455463 o .tenant ,
456464 configPath ,
457465 o .overlaybdInitDebuglogPath (snID ),
466+ false ,
458467 ),
459468 )
460469 if err != nil {
0 commit comments