@@ -67,7 +67,7 @@ public Answer execute(RestoreBackupCommand command, LibvirtComputingResource ser
6767 int lastIndex = volumePath .lastIndexOf ("/" );
6868 newVolumeId = volumePath .substring (lastIndex + 1 );
6969 restoreVolume (backupPath , backupRepoType , backupRepoAddress , volumePath , diskType , restoreVolumeUuid ,
70- new Pair <>(vmName , command .getVmState ()));
70+ new Pair <>(vmName , command .getVmState ()), mountOptions );
7171 } else if (Boolean .TRUE .equals (vmExists )) {
7272 restoreVolumesOfExistingVM (volumePaths , backupPath , backupRepoType , backupRepoAddress , mountOptions );
7373 } else {
@@ -80,7 +80,7 @@ public Answer execute(RestoreBackupCommand command, LibvirtComputingResource ser
8080 private void restoreVolumesOfExistingVM (List <String > volumePaths , String backupPath ,
8181 String backupRepoType , String backupRepoAddress , String mountOptions ) {
8282 String diskType = "root" ;
83- String mountDirectory = mountBackupDirectory (backupRepoAddress , backupRepoType );
83+ String mountDirectory = mountBackupDirectory (backupRepoAddress , backupRepoType , mountOptions );
8484 try {
8585 for (int idx = 0 ; idx < volumePaths .size (); idx ++) {
8686 String volumePath = volumePaths .get (idx );
@@ -101,7 +101,7 @@ private void restoreVolumesOfExistingVM(List<String> volumePaths, String backupP
101101
102102 private void restoreVolumesOfDestroyedVMs (List <String > volumePaths , String vmName , String backupPath ,
103103 String backupRepoType , String backupRepoAddress , String mountOptions ) {
104- String mountDirectory = mountBackupDirectory (backupRepoAddress , backupRepoType );
104+ String mountDirectory = mountBackupDirectory (backupRepoAddress , backupRepoType , mountOptions );
105105 String diskType = "root" ;
106106 try {
107107 for (int i = 0 ; i < volumePaths .size (); i ++) {
@@ -121,8 +121,8 @@ private void restoreVolumesOfDestroyedVMs(List<String> volumePaths, String vmNam
121121 }
122122
123123 private void restoreVolume (String backupPath , String backupRepoType , String backupRepoAddress , String volumePath ,
124- String diskType , String volumeUUID , Pair <String , VirtualMachine .State > vmNameAndState ) {
125- String mountDirectory = mountBackupDirectory (backupRepoAddress , backupRepoType );
124+ String diskType , String volumeUUID , Pair <String , VirtualMachine .State > vmNameAndState , String mountOptions ) {
125+ String mountDirectory = mountBackupDirectory (backupRepoAddress , backupRepoType , mountOptions );
126126 Pair <String , String > bkpPathAndVolUuid ;
127127 try {
128128 bkpPathAndVolUuid = getBackupPath (mountDirectory , volumePath , backupPath , diskType , volumeUUID );
@@ -145,12 +145,22 @@ private void restoreVolume(String backupPath, String backupRepoType, String back
145145 }
146146
147147
148- private String mountBackupDirectory (String backupRepoAddress , String backupRepoType ) {
148+ private String mountBackupDirectory (String backupRepoAddress , String backupRepoType , String mountOptions ) {
149149 String randomChars = RandomStringUtils .random (5 , true , false );
150150 String mountDirectory = String .format ("%s.%s" ,BACKUP_TEMP_FILE_PREFIX , randomChars );
151151 try {
152152 mountDirectory = Files .createTempDirectory (mountDirectory ).toString ();
153+ String mountOpts = null ;
154+ if (Objects .nonNull (mountOptions )) {
155+ mountOpts = mountOptions ;
156+ if ("cifs" .equals (backupRepoType )) {
157+ mountOpts += ",nobrl" ;
158+ }
159+ }
153160 String mount = String .format (MOUNT_COMMAND , backupRepoType , backupRepoAddress , mountDirectory );
161+ if (Objects .nonNull (mountOpts )) {
162+ mount += " -o " + mountOpts ;
163+ }
154164 Script .runSimpleBashScript (mount );
155165 } catch (Exception e ) {
156166 throw new CloudRuntimeException (String .format ("Failed to mount %s to %s" , backupRepoType , backupRepoAddress ), e );
0 commit comments