Run libguestfs API calls in a thread pool

The libguestfs API is a binding to a native C library, and thus
it will block greenthreads. To avoid this all libguestfs API
calls need to be run in a threadpool. This can be done by just
wrapping the GuestFS object in an eventlet.tpool.Proxy object

Fixes bug #1132742
Change-Id: I877ad9e88442e41c9ad234503d9b1ddf1fb27408
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2013-02-25 12:00:05 +00:00
parent 42d058b2a1
commit ea07be64a4

View File

@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from eventlet import tpool
import guestfs
from nova import exception
@@ -93,7 +94,7 @@ class VFSGuestFS(vfs.VFS):
def setup(self):
LOG.debug(_("Setting up appliance for %(imgfile)s %(imgfmt)s") %
{'imgfile': self.imgfile, 'imgfmt': self.imgfmt})
self.handle = guestfs.GuestFS()
self.handle = tpool.Proxy(guestfs.GuestFS())
try:
self.handle.add_drive_opts(self.imgfile, format=self.imgfmt)