Answer the question
In order to leave comments, you need to log in
Hook script not working (libvirt+qemu+virt-manager)?
The main OS Centos 6.8 (111.11.11.1), inside the Windows Server virtual machine (192.168.122.40)
I did it according to this principle: I
created a file in /etc/libvirt/hooks/qemu
#!/bin/bash
# used some from advanced script to have multiple ports: use an equal number of guest and host ports
# Update the following variables to fit your setup
Guest_name=vm5
Guest_ipaddr=192.168.122.40
Host_ipaddr=111.11.11.1
Host_port=( '8041' '8042' )
Guest_port=( '80' '443' )
length=$(( ${#Host_port[@]} - 1 ))
if [ "${1}" = "${Guest_name}" ]; then
if [ "${2}" = "stopped" ] || [ "${2}" = "reconnect" ]; then
for i in `seq 0 $length`; do
iptables -t nat -D PREROUTING -d ${Host_ipaddr} -p tcp --dport ${Host_port[$i]} -j DNAT --to ${Guest_ipaddr}:${Guest_port[$i]}
iptables -D FORWARD -d ${Guest_ipaddr}/32 -p tcp -m state --state NEW -m tcp --dport ${Guest_port[$i]} -j ACCEPT
done
fi
if [ "${2}" = "start" ] || [ "${2}" = "reconnect" ]; then
for i in `seq 0 $length`; do
iptables -t nat -A PREROUTING -d ${Host_ipaddr} -p tcp --dport ${Host_port[$i]} -j DNAT --to ${Guest_ipaddr}:${Guest_port[$i]}
iptables -I FORWARD -d ${Guest_ipaddr}/32 -p tcp -m state --state NEW -m tcp --dport ${Guest_port[$i]} -j ACCEPT
done
fi
fi
Error starting domain: Hook script execution failed: internal error Child process (LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /etc/libvirt/hooks/qemu wsvm prepare begin -) unexpected exit status 1: libvirt: error : cannot execute binary /etc/libvirt/hooks/qemu: No such file or directory
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 44, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 65, in tmpcb
callback(*args, **kwargs)
File "/usr/share/virt-manager/virtManager/domain.py", line 1125, in startup
self._backend.create()
File "/usr/lib64/python2.6/site-packages/libvirt.py", line 686, in create
if ret == -1: raise libvirtError ('virDomainCreate() failed', dom=self)
libvirtError: Hook script execution failed: internal error Child process (LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /etc/libvirt/hooks/qemu wsvm prepare begin -) unexpected exit status 1: libvirt: error : cannot execute binary /etc/libvirt/hooks/qemu: No such file or directory
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question