mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	kvm: fix of detach volume while OS is in boot state (#4572)
* fix of detach volume while OS is in boot state * check that the VM could be accessed trough ssh
This commit is contained in:
		
							parent
							
								
									2ececbf994
								
							
						
					
					
						commit
						8e33cf7159
					
				| @ -70,6 +70,7 @@ import org.apache.cloudstack.utils.qemu.QemuImgException; | |||||||
| import org.apache.cloudstack.utils.qemu.QemuImgFile; | import org.apache.cloudstack.utils.qemu.QemuImgFile; | ||||||
| import org.apache.commons.collections.MapUtils; | import org.apache.commons.collections.MapUtils; | ||||||
| import org.apache.commons.io.FileUtils; | import org.apache.commons.io.FileUtils; | ||||||
|  | import org.apache.commons.lang.StringUtils; | ||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| import org.libvirt.Connect; | import org.libvirt.Connect; | ||||||
| import org.libvirt.Domain; | import org.libvirt.Domain; | ||||||
| @ -1195,6 +1196,14 @@ public class KVMStorageProcessor implements StorageProcessor { | |||||||
|             } else { |             } else { | ||||||
|                 s_logger.debug("Detaching device: " + xml); |                 s_logger.debug("Detaching device: " + xml); | ||||||
|                 dm.detachDevice(xml); |                 dm.detachDevice(xml); | ||||||
|  |                 LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser(); | ||||||
|  |                 parser.parseDomainXML(dm.getXMLDesc(0)); | ||||||
|  |                 List<DiskDef> disks = parser.getDisks(); | ||||||
|  |                 for (DiskDef diskDef : disks) { | ||||||
|  |                     if (StringUtils.contains(xml, diskDef.getDiskPath())) { | ||||||
|  |                         throw new InternalErrorException("Could not detach volume. Probably the VM is in boot state at the moment"); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } catch (final LibvirtException e) { |         } catch (final LibvirtException e) { | ||||||
|             if (attach) { |             if (attach) { | ||||||
|  | |||||||
| @ -385,11 +385,15 @@ class TestVolumes(cloudstackTestCase): | |||||||
|     def tearDown(self): |     def tearDown(self): | ||||||
|         #Clean up, terminate the created volumes |         #Clean up, terminate the created volumes | ||||||
|         if self.attached: |         if self.attached: | ||||||
|  |             self.virtual_machine.get_ssh_client(reconnect = True) | ||||||
|  | 
 | ||||||
|             self.virtual_machine.detach_volume(self.apiClient, self.volume) |             self.virtual_machine.detach_volume(self.apiClient, self.volume) | ||||||
| 
 | 
 | ||||||
|         if self.virtual_machine.hypervisor == "KVM": |         if self.virtual_machine.hypervisor == "KVM": | ||||||
|             self.virtual_machine.stop(self.apiClient) |             self.virtual_machine.stop(self.apiClient) | ||||||
|             self.virtual_machine.start(self.apiClient) |             self.virtual_machine.start(self.apiClient) | ||||||
|  |             self.virtual_machine.get_ssh_client(reconnect = True) | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|         cleanup_resources(self.apiClient, self.cleanup) |         cleanup_resources(self.apiClient, self.cleanup) | ||||||
|         return |         return | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user