@@ -80,9 +80,9 @@ func (m *mounter) GetBlockSizeBytes(devicePath string) (int64, error) {
8080
8181func (m * mounter ) GetDevicePath (ctx context.Context , volumeID string ) (string , error ) {
8282 backoff := wait.Backoff {
83- Duration : 1 * time .Second ,
84- Factor : 1.1 ,
85- Steps : 15 ,
83+ Duration : 2 * time .Second ,
84+ Factor : 1.5 ,
85+ Steps : 20 ,
8686 }
8787
8888 var devicePath string
@@ -111,6 +111,15 @@ func (m *mounter) GetDevicePath(ctx context.Context, volumeID string) (string, e
111111}
112112
113113func (m * mounter ) getDevicePathBySerialID (volumeID string ) (string , error ) {
114+ // First try XenServer device paths
115+ xenDevicePath , err := m .getDevicePathForXenServer (volumeID )
116+ if err != nil {
117+ fmt .Printf ("Failed to get VMware device path: %v\n " , err )
118+ }
119+ if xenDevicePath != "" {
120+ return xenDevicePath , nil
121+ }
122+
114123 // Try VMware device paths
115124 vmwareDevicePath , err := m .getDevicePathForVMware (volumeID )
116125 if err != nil {
@@ -129,13 +138,60 @@ func (m *mounter) getDevicePathBySerialID(volumeID string) (string, error) {
129138 return source , nil
130139 }
131140 if ! os .IsNotExist (err ) {
141+ fmt .Printf ("Not found: %s\n " , err .Error ())
132142 return "" , err
133143 }
134144 }
135145
136146 return "" , nil
137147}
138148
149+ func (m * mounter ) getDevicePathForXenServer (volumeID string ) (string , error ) {
150+ for i := 'b' ; i <= 'z' ; i ++ {
151+ devicePath := fmt .Sprintf ("/dev/xvd%c" , i )
152+ fmt .Printf ("Checking XenServer device path: %s\n " , devicePath )
153+
154+ if _ , err := os .Stat (devicePath ); err == nil {
155+ isBlock , err := m .IsBlockDevice (devicePath )
156+ if err == nil && isBlock {
157+ if m .verifyXenServerDevice (devicePath , volumeID ) {
158+ fmt .Printf ("Found and verified XenServer device: %s\n " , devicePath )
159+ return devicePath , nil
160+ }
161+ }
162+ }
163+ }
164+ return "" , fmt .Errorf ("device not found for volume %s" , volumeID )
165+ }
166+
167+ func (m * mounter ) verifyXenServerDevice (devicePath string , volumeID string ) bool {
168+ size , err := m .GetBlockSizeBytes (devicePath )
169+ if err != nil {
170+ fmt .Printf ("Failed to get device size: %v\n " , err )
171+ return false
172+ }
173+ fmt .Printf ("Device size: %d bytes\n " , size )
174+
175+ mounted , err := m .isDeviceMounted (devicePath )
176+ if err != nil {
177+ fmt .Printf ("Failed to check if device is mounted: %v\n " , err )
178+ return false
179+ }
180+ if mounted {
181+ fmt .Printf ("Device is already mounted: %s\n " , devicePath )
182+ return false
183+ }
184+
185+ props , err := m .getDeviceProperties (devicePath )
186+ if err != nil {
187+ fmt .Printf ("Failed to get device properties: %v\n " , err )
188+ return false
189+ }
190+ fmt .Printf ("Device properties: %v\n " , props )
191+
192+ return true
193+ }
194+
139195func (m * mounter ) getDevicePathForVMware (volumeID string ) (string , error ) {
140196 // Loop through /dev/sdb to /dev/sdz (/dev/sda -> the root disk)
141197 for i := 'b' ; i <= 'z' ; i ++ {
0 commit comments