0

I have an upstart job that is configured to run a one-off script with a few virsh commands to import and start VMs. This job is configured to start on started libvirt-bin.

However, I'm encountering an issue where the libvirt-bin service starts, and forks, but isn't actually usable until it begins listening on it's socket. However, once the process forks, Upstart considers the process started, and my virsh commands fail because of the race condition with the libvirt-bin socket.

Is there a way to solve this with only Upstart, or do I need to add a function for checking the socket to my script to keep it from failing out? I've tried using the upstart-socket-bridge and upstart-file-bridge, to no avail.

This is running on Ubuntu 14.04 with Upstart 1.12.

4
  • Update to a systemd-based distribution and use systemd? This is not an issue under systemd because libvirt notifies systemd when it is actually ready to go. Mar 16, 2016 at 20:39
  • @MichaelHampton Yeah that would be nice. But this a professional forum, so certainly you understand that I can't just change my distribution willy-nilly. Maybe if I was asking on superuser that would be a reasonable suggestion.
    – zymhan
    Mar 18, 2016 at 14:33
  • @WildVelociraptor: This is not a forum at all, it's a Q&A site. And it's not unprofessional to suggest using another environment where a specific problem is not a problem. Yes, that often can't be done for a multitude of reasons, but that doesn't mean you can't consider it.
    – Sven
    Mar 18, 2016 at 14:39
  • Sorry, it's not a forum, slip of the tongue (er, fingers). I still think the advice is unnecessary, as I don't know many sysadmins who haven't considered throwing out the entire stack to use something less crappy. But like many others, I'm stuck with a rigid list of usable software. And CentOS 7 is not on that list unfortunately.
    – zymhan
    Mar 18, 2016 at 14:45

1 Answer 1

0

The easiest would be to add a static sleep of a few seconds to your script startup. This may not be ideal for many reasons, especially if you use this script more generally, since the sleep is not directly linked to libvirt being up.

It might be better to have the script check if libvirt is indeed started. You may be able to do this using the exit status of virsh connect or checking if libvirtd has bound to the socket (lsof).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .