@@ -3063,7 +3063,7 @@ private synchronized Answer execute(PrepareForMigrationCommand cmd) {
30633063
30643064 NicTO [] nics = vm .getNics ();
30653065
3066- boolean success = false ;
3066+ boolean skipDisconnect = false ;
30673067
30683068 try {
30693069 Connect conn = LibvirtConnection .getConnectionByVmName (vm .getName ());
@@ -3079,13 +3079,16 @@ private synchronized Answer execute(PrepareForMigrationCommand cmd) {
30793079 }
30803080 }
30813081
3082- _storagePoolMgr .connectPhysicalDisksViaVmSpec (vm );
3082+ if (!_storagePoolMgr .connectPhysicalDisksViaVmSpec (vm )) {
3083+ skipDisconnect = true ;
3084+ return new PrepareForMigrationAnswer (cmd , "failed to connect physical disks to host" );
3085+ }
30833086
30843087 synchronized (_vms ) {
30853088 _vms .put (vm .getName (), State .Migrating );
30863089 }
30873090
3088- success = true ;
3091+ skipDisconnect = true ;
30893092
30903093 return new PrepareForMigrationAnswer (cmd );
30913094 } catch (LibvirtException e ) {
@@ -3095,7 +3098,7 @@ private synchronized Answer execute(PrepareForMigrationCommand cmd) {
30953098 } catch (URISyntaxException e ) {
30963099 return new PrepareForMigrationAnswer (cmd , e .toString ());
30973100 } finally {
3098- if (!success ) {
3101+ if (!skipDisconnect ) {
30993102 _storagePoolMgr .disconnectPhysicalDisksViaVmSpec (vm );
31003103 }
31013104 }
@@ -3628,7 +3631,9 @@ protected StartAnswer execute(StartCommand cmd) {
36283631
36293632 createVbd (conn , vmSpec , vmName , vm );
36303633
3631- _storagePoolMgr .connectPhysicalDisksViaVmSpec (vmSpec );
3634+ if (!_storagePoolMgr .connectPhysicalDisksViaVmSpec (vmSpec )) {
3635+ return new StartAnswer (cmd , "Failed to connect physical disks to host" );
3636+ }
36323637
36333638 createVifs (vmSpec , vm );
36343639
0 commit comments