Port forward port 80 to XOS

Change-Id: I843c80064acf4e07fca0c2b96a105e33a3b40f00
diff --git a/roles/config-virt/files/qemu b/roles/config-virt/files/qemu
new file mode 100644
index 0000000..451cdda
--- /dev/null
+++ b/roles/config-virt/files/qemu
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+SHELL="/bin/bash"
+
+NIC=$( route|grep default|awk '{print $NF}' )
+
+NAME="${1}"
+OP="${2}"
+SUBOP="${3}"
+ARGS="${4}"
+
+add_rule() {
+    TABLE=$1
+    CHAIN=$2
+    ARGS=$3
+    iptables -t $TABLE -C $CHAIN $ARGS
+    if [ "$?" -ne 0 ]
+    then
+        iptables -t $TABLE -I $CHAIN 1 $ARGS
+    fi
+}
+
+add_port_fwd_rule() {
+    DPORT=$1
+    VMIP=$2
+    TOPORT=$3
+
+    add_rule "nat" "PREROUTING" "-p tcp -i $NIC --dport $DPORT -j DNAT --to-destination $VMIP:$TOPORT"
+}
+
+if [ "$OP" = "start" ]
+then
+    XOS=$( getent hosts xos | awk '{print $1}' )
+    if [ -n "$XOS" ]
+    then
+	add_port_fwd_rule 80 $XOS 80
+    fi
+    add_rule "filter" "FORWARD" "-p tcp --dport 80 -j ACCEPT"
+fi
+
diff --git a/roles/config-virt/tasks/main.yml b/roles/config-virt/tasks/main.yml
index 67a14a1..0f0ed05 100644
--- a/roles/config-virt/tasks/main.yml
+++ b/roles/config-virt/tasks/main.yml
@@ -51,17 +51,14 @@
 
 - name: Have libvirt enable port forwarding to VM's
   become: yes
-  template:
-    src={{ item }}.j2
+  copy:
+    src={{ item }}
     dest=/etc/libvirt/hooks/{{ item }}
     mode=0755 owner=root
   with_items:
-    - daemon
     - qemu
   notify:
-    - reload libvirt-bin
     - run qemu hook
-  when: not on_maas
 
 - name: Wait for uvt-kvm image to be available
   async_status: jid={{ uvt_sync.ansible_job_id }}