XAPI updates the pool.conf file before it actually refreshes its database
from the new pool, so we need to wait for that to happen. Hard-coded
delays aren't a good idea, but in the long term XAPI will probably be
adding a hook script for us to use, so this may be an OK stopgap measure.
Bug #2756.
/* The executing instance of refresh-network-uuids, or NULL if none. */
static struct process *refresh_script;
/* The executing instance of refresh-network-uuids, or NULL if none. */
static struct process *refresh_script;
+/* Time at which to start the refresh script. */
+static long long int next_refresh = LLONG_MAX;
+
static void
network_uuid_refresh_run(void)
{
static void
network_uuid_refresh_run(void)
{
- /* Otherwise, check for a change in timestamp.
+ /* Otherwise, schedule a refresh in a few seconds if the timestamp has
+ * changed. Refreshing immediately doesn't work because XAPI takes a while
+ * to switch over to new UUIDs.
*
* (We will always detect a change in timestamp when we start up. That's
* good, since it means that the refresh-network-uuids script gets
*
* (We will always detect a change in timestamp when we start up. That's
* good, since it means that the refresh-network-uuids script gets
get_mtime("/etc/xensource/pool.conf", &new_mtime);
if (new_mtime.tv_sec != pool_conf_mtime.tv_sec
|| new_mtime.tv_nsec != pool_conf_mtime.tv_nsec) {
get_mtime("/etc/xensource/pool.conf", &new_mtime);
if (new_mtime.tv_sec != pool_conf_mtime.tv_sec
|| new_mtime.tv_nsec != pool_conf_mtime.tv_nsec) {
+ next_refresh = time_msec() + 10 * 1000;
+ return;
+ }
+
+ /* Otherwise, if our timer expired then start the refresh. */
+ if (time_msec() >= next_refresh) {
struct stat s;
char *argv[2];
struct stat s;
char *argv[2];
+ next_refresh = LLONG_MAX;
+
argv[0] = xasprintf("%s/scripts/refresh-network-uuids",
ovs_pkgdatadir);
argv[1] = NULL;
argv[0] = xasprintf("%s/scripts/refresh-network-uuids",
ovs_pkgdatadir);
argv[1] = NULL;
{
if (refresh_script) {
process_wait(refresh_script);
{
if (refresh_script) {
process_wait(refresh_script);
- } else if (pool_conf_mtime.tv_sec) {
- poll_timer_wait(1000);
+ } else {
+ if (pool_conf_mtime.tv_sec) {
+ poll_timer_wait(1000);
+ }
+ if (next_refresh != LLONG_MAX) {
+ poll_timer_wait(next_refresh - time_msec());
+ }