Permalink
Browse files

Fixed ebs volumes failing to attach on vmreboot w/kvm. Fixes EUCA-4427.

Fixed failures on vm reboot due to libvirt failing to add ebs vols
back. Added retry around libvirt call in vm reboot just like the
retry around the regular attach operation.
  • Loading branch information...
1 parent 304fd3b commit c653a788877f17184b938f6bdd15f9247a547525 Zach Hill committed Nov 22, 2012
Showing with 15 additions and 9 deletions.
  1. +15 −9 node/handlers_kvm.c
View
@@ -208,15 +208,21 @@ static void * rebooting_thread (void *arg)
free (remoteDevStr);
if (!rc) {
- int err;
- sem_p (hyp_sem);
- err = virDomainAttachDevice (dom, xml);
- sem_v (hyp_sem);
- if (err) {
- logprintfl (EUCAERROR, "[%s] virDomainAttachDevice() failed (err=%d) XML='%s'\n", instance->instanceId, err, xml);
- } else {
- logprintfl (EUCAINFO, "[%s] reattached '%s' to '%s' in domain\n", instance->instanceId, volume->remoteDev, volume->localDevReal);
- }
+ // protect libvirt calls because we've seen problems during concurrent libvirt invocations
+ // zhill - wrap with retry in case libvirt is dumb.
+ int err = 0;
+ for(int i = 1 ; i < 3 ; i++) {
+ sem_p (hyp_sem);
+ err = virDomainAttachDevice (dom, xml);
+ sem_v (hyp_sem);
+ if(err) {
+ logprintfl (EUCAERROR, "[%s] virDomainAttachDevice() failed on attempt %d of 3 (err=%d) XML='%s'\n", instance->instanceId, i, err, xml);
+ sleep(3); //sleep a bit and retry.
+ } else {
+ logprintfl (EUCAINFO, "[%s] reattached '%s' to '%s' in domain\n", instance->instanceId, volume->remoteDev, volume->localDevReal);
+ break;
+ }
+ }
}
if (xml)

0 comments on commit c653a78

Please sign in to comment.