Fix weird bugs
This commit is contained in:
parent
97f8030700
commit
ef6b984296
|
@ -144,27 +144,23 @@ class VMInstance:
|
||||||
self.inmigrate = False
|
self.inmigrate = False
|
||||||
|
|
||||||
# Receive the migration from another host (wait until VM is running)
|
# Receive the migration from another host (wait until VM is running)
|
||||||
def receive_migrate(self):
|
def receive_migrate(self, conn):
|
||||||
print('>>> Receiving migration of %s' % self.domuuid)
|
print('>>> Receiving migration of %s' % self.domuuid)
|
||||||
self.inreceive = True
|
self.inreceive = True
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if self.dom == None:
|
self.dom = conn.lookupByUUID(uuid.UUID(self.domuuid).bytes)
|
||||||
self.dom = conn.lookupByUUID(uuid.UUID(self.domuuid).bytes)
|
|
||||||
elif self.dom.state()[0] != libvirt.VIR_DOMAIN_RUNNING:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
except:
|
except:
|
||||||
pass
|
time.sleep(0.2)
|
||||||
|
continue
|
||||||
|
|
||||||
time.sleep(0.2)
|
if self.dom.state()[0] == libvirt.VIR_DOMAIN_RUNNING:
|
||||||
|
break
|
||||||
|
|
||||||
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
||||||
if not self.domuuid in self.thishypervisor.domain_list:
|
if not self.domuuid in self.thishypervisor.domain_list:
|
||||||
self.thishypervisor.domain_list.append(self.domuuid)
|
self.thishypervisor.domain_list.append(self.domuuid)
|
||||||
|
print('>>> Migrated successfully')
|
||||||
print('>>> Migrated successfully' % self.domuuid)
|
|
||||||
self.inreceive = False
|
self.inreceive = False
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -197,7 +193,7 @@ class VMInstance:
|
||||||
|
|
||||||
# VM should be migrated to this hypervisor
|
# VM should be migrated to this hypervisor
|
||||||
elif running != libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor == self.thishypervisor.name and self.inreceive == False:
|
elif running != libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor == self.thishypervisor.name and self.inreceive == False:
|
||||||
self.receive_migrate()
|
self.receive_migrate(conn)
|
||||||
|
|
||||||
# VM should be migrated away from this hypervisor
|
# VM should be migrated away from this hypervisor
|
||||||
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name and self.inmigrate == False:
|
elif running == libvirt.VIR_DOMAIN_RUNNING and self.state == "migrate" and self.hypervisor != self.thishypervisor.name and self.inmigrate == False:
|
||||||
|
|
Loading…
Reference in New Issue