From a256b6e5a98ed6368a83a82a79d4f69f8040c68d Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Tue, 6 Mar 2012 11:12:19 -0800 Subject: [PATCH] ovs-xapi-sync: Use unixctl to trigger cache flushes. Typically Open vSwitch communicates with running processes using unixctl. This patch converts ovs-xapi-sync to the strategy for consistency. Signed-off-by: Ethan Jackson --- xenserver/etc_init.d_openvswitch | 7 ++--- ...sr_share_openvswitch_scripts_ovs-xapi-sync | 29 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch index 29f2cf60..aa65657e 100755 --- a/xenserver/etc_init.d_openvswitch +++ b/xenserver/etc_init.d_openvswitch @@ -120,10 +120,9 @@ case $1 in ;; reload|force-reload) # The main OVS daemons keep up-to-date, but ovs-xapi-sync needs help. - pidfile=/var/run/openvswitch/ovs-xapi-sync.pid - if test -e "$pidfile"; then - pid=`cat "$pidfile"` - action "Configuring Open vSwitch external IDs" kill -HUP $pid + if daemon_is_running ovs-xapi-sync; then + action "Configuring Open vSwitch external IDs" \ + ovs-appctl -t ovs-xapi-sync flush-cache fi ;; status) diff --git a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync index 8f5885a9..eea319a8 100755 --- a/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync +++ b/xenserver/usr_share_openvswitch_scripts_ovs-xapi-sync @@ -24,7 +24,6 @@ import argparse import os -import signal import sys import time @@ -39,7 +38,7 @@ import ovs.unixctl vlog = ovs.vlog.Vlog("ovs-xapi-sync") session = None -force_run = False +flush_cache = False exiting = False @@ -49,6 +48,12 @@ def unixctl_exit(conn, unused_argv, unused_aux): conn.reply(None) +def unixctl_flush_cache(conn, unused_argv, unused_aux): + global flush_cache + flush_cache = True + conn.reply(None) + + # Set up a session to interact with XAPI. # # On system start-up, OVS comes up before XAPI, so we can't log into the @@ -226,14 +231,8 @@ def prune_schema(schema): schema.tables = new_tables -def handler(signum, _): - global force_run - if (signum == signal.SIGHUP): - force_run = True - - def main(): - global force_run + global flush_cache parser = argparse.ArgumentParser() parser.add_argument("database", metavar="DATABASE", @@ -257,6 +256,8 @@ def main(): ovs.daemon.daemonize() ovs.unixctl.command_register("exit", "", 0, 0, unixctl_exit, None) + ovs.unixctl.command_register("flush-cache", "", 0, 0, unixctl_flush_cache, + None) error, unixctl_server = ovs.unixctl.UnixctlServer.create(None) if error: ovs.util.ovs_fatal(error, "could not create unixctl server", vlog) @@ -267,8 +268,6 @@ def main(): while not os.path.exists(cookie_file): time.sleep(1) - signal.signal(signal.SIGHUP, handler) - bridges = {} # Map from bridge name to nicira-bridge-id iface_ids = {} # Map from xs-vif-uuid to iface-id vm_ids = {} # Map from xs-vm-uuid to vm-id @@ -279,19 +278,19 @@ def main(): break; idl.run() - if not force_run and seqno == idl.change_seqno: + if not flush_cache and seqno == idl.change_seqno: poller = ovs.poller.Poller() unixctl_server.wait(poller) idl.wait(poller) poller.block() continue - if force_run: - vlog.info("Forced to re-run as the result of a SIGHUP") + if flush_cache: + vlog.info("Flushing cache as the result of unixctl.") bridges = {} iface_ids = {} vm_ids = {} - force_run = False + flush_cache = False seqno = idl.change_seqno txn = ovs.db.idl.Transaction(idl) -- 2.30.2