qmemman: improve check whether VM is still running
In some cases it may happen that qmemman or other application using xenstore will re-create VM directory in xenstore just after VM was destroyed. For example when multiple VMs was destroyed at the same time, but qmemman will kick off just at first @releaseDomain event - other VMs will still be there (at xenstore-list time). This means that qmemman will consider them when redistributing memory (of just destroyed one), so will update memory/target entry of every "running" VM. And at this point it may recreate VM directory of another already destroyed VM. Generally fixing this race condition would require running all the operations (from xenstore-ls, to setting memory/target) in a single xenstore transaction. But this can be lengthly process. And if any other modification happens in the meantime, transaction will rejected and qmemman would need to redo all the changes. Not worth the effort. Fixes QubesOS/qubes-issues#1409
This commit is contained in:
		
							parent
							
								
									f525a58134
								
							
						
					
					
						commit
						fef8761f01
					
				| @ -74,6 +74,16 @@ class XS_Watcher: | |||||||
|         self.log.debug('domain_list_changed(param={!r})'.format(param)) |         self.log.debug('domain_list_changed(param={!r})'.format(param)) | ||||||
| 
 | 
 | ||||||
|         curr = self.handle.ls('', '/local/domain') |         curr = self.handle.ls('', '/local/domain') | ||||||
|  |         # check if domain is really there, it may happen that some empty | ||||||
|  |         # directories are left in xenstore | ||||||
|  |         curr = filter( | ||||||
|  |             lambda x: | ||||||
|  |             self.handle.read('', | ||||||
|  |                              '/local/domain/{}/domid'.format(x) | ||||||
|  |                              ) is not None, | ||||||
|  |             curr | ||||||
|  |         ) | ||||||
|  | 
 | ||||||
|         self.log.debug('curr={!r}'.format(curr)) |         self.log.debug('curr={!r}'.format(curr)) | ||||||
| 
 | 
 | ||||||
|         if curr == None: |         if curr == None: | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marek Marczykowski-Górecki
						Marek Marczykowski-Górecki