29 nov. 2012

Virtualbox and Centos: Frozen network, Detected Tx Unit Hang

Since few days I had a really annoying issue with one of my virtual machine:

I run a python script using urllib2 to collect some data from various online APIs. Everything seems to run smoothly when sudenly the script starts to hang and becomes unresponsive (CTRL+C does not have any effect). I open a new shell to see what's going on and I notice that any application that triggers a network activity starts to hang (yum, pip...). I open my TTY console and I notice that some error messages are popping : "eth0: Detected Tx Unit Hang", "eth0 Reset Adapter" and something about kernel hang timeout... A lot of signs that something really bad is happening on this machine. The only way to recover from it consists in performing a hardware reset of the Guest machine, but the problem arises again shortly after.


Screenshot of the situation

The issue had nothing to do with my script or my VM setup, but was in the configuration of the VirtualBox instance. I have a Intel i7-2600 CPU with 4 cores on my Host, so I though it was a good idea to assign multiple cores to my VM to improve performances and to have something closer to my production server. Turns out that by doing this I caused the problem: assigning more than 1 cpu to my VM results in the network interface to hang and freeze the kernel after a certain amount of data is transmited. I'm using the last version of Virtualbox to date (4.2.4) with Centos (6.3). Hopefully this will be fix in the next release.

TL;DR: If your VM is hanging and shows some network errors, check how many CPU you assigned to it, and if this is more than one, reduce it.

I posted this fix in English because I ran into this annoying situation and I wanted it to be available to more than my usual French audience, considering I didn't find that much info about it except this old entry in Virtualbox bugtracker.

4 commentaires:

  1. This is happening to me too. I was running CentOS 6.3 w/ VB 4.2.6 and 7 CPUs. I have upgraded to CentOS 6.4 in hopes that this will help. I'll let you know what I find.

    RépondreSupprimer
    Réponses
    1. CentOS 6.4 has been 100% up. No problems with the eth device hanging. You should give it a shot.

      Supprimer
    2. Thanks for your input joel. Indeed I wrote that article back in november 2012, maybe some updates from Virtualbox and Centos side have helped getting rid of it. I'll try on my VM later on and update the article.

      Supprimer
  2. This happened to me. I upgraded VirtualBox (5.2.4) and my box was giving this error. I had two virtual network adapters, one was enabled but not attached. So I disabled the 2nd one, reset, and the problem went away.

    RépondreSupprimer

Merci pour votre participation constructive