<div dir="ltr">Hi,<div><br></div><div><span style="font-size:12.8px">> I don't see your service being called.</span></div><div><span style="font-size:12.8px">It started when system started, see logs:</span></div><div><span style="font-size:12.8px">Jan 12 14:59:42 desktop4 systemd: systemd 219 running in system mode. (+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN)</span></div><div><span style="font-size:12.8px">Jan 12 14:59:42 desktop4 systemd: Detected architecture x86-64.</span></div><div><span style="font-size:12.8px">Jan 12 14:59:42 desktop4 systemd: Set hostname to <desktop4>.</span></div><div><span style="font-size:12.8px">Jan 12 14:59:42 desktop4 systemd: Started Create list of required static device nodes for the current kernel.</span></div><div><span style="font-size:12.8px">Jan 12 14:59:42 desktop4 systemd: Started <b>vPreShutdownHook</b>.</span></div><div><span style="font-size:12.8px">Jan 12 14:59:42 desktop4 systemd: Starting Create Static Device Nodes in /dev...</span></div><div><span style="font-size:12.8px"> </span><br></div><div><span style="font-size:12.8px">> Anyway, look at </span><span style="font-size:12.8px">libvirt-guests.service file. Looks like the following lines cause </span><span style="font-size:12.8px">systemd to wait for a command to finish:</span><span style="font-size:12.8px"><br></span></div><div>The libvirt-guests.service is NOT running in either of my nodes, even though VM is working fine.</div><div><br></div><div>I tried starting <span style="font-size:12.8px"> </span><span style="font-size:12.8px">libvirt-guests.service and added it as Requires target in </span><span style="font-size:12.8px">vPreShutdownHook.service, </span><span style="font-size:12.8px"> but it did not help. On reboot the VM did not migrated.</span></div><div><br></div><div>Thanks</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 11, 2018 at 12:56 PM, Michal Privoznik <span dir="ltr"><<a href="mailto:mprivozn@redhat.com" target="_blank">mprivozn@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">[Please keed the list CCed]<br>
<div><div class="h5"><br>
On 01/10/2018 04:43 PM, Raman Gupta wrote:<br>
>> Does this command alone succeed?<br>
> Yes. I have used this command to migrate VMs successfully, without even<br>
> knowing that spelling has changed.<br>
><br>
><br>
>> I don't know enough about systemd but maybe it's not waiting for virsh to<br>
> finish?<br>
> Yes I also think virsh or libvirtd or related service does not wait<br>
> before /root/vm_migrate.sh<br>
> is called and hence live migration fails.<br>
> If I replace Live Migration with a simple ping to peer node in the<br>
> vPreShutdownHook.service,  then ping goes thru successfully thus indicating<br>
> network service was UP at that time.<br>
><br>
>> Can you try to get any logs to see what is going on actually?<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Session c1 of user gdm.<br>
> Jan  8 15:30:58 desktop4 gdm: Freeing conversation 'gdm-launch-environment'<br>
> with active job<br>
> Jan  8 15:30:58 desktop4 systemd: Stopped target Sound Card.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Sound Card.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping LVM2 PV scan on device 8:3...<br>
> Jan  8 15:30:58 desktop4 systemd: Removed slice system-getty.slice.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping system-getty.slice.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Authorization Manager...<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Virtual Machine and Container<br>
> Registration Service...<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping GlusterFS brick processes<br>
> (stopping only)...<br>
> Jan  8 15:30:58 desktop4 systemd: Removed slice<br>
> system-selinux\x2dpolicy\<wbr>x2dmigrate\x2dlocal\<wbr>x2dchanges.slice.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping<br>
> system-selinux\x2dpolicy\<wbr>x2dmigrate\x2dlocal\<wbr>x2dchanges.slice.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Availability of block devices...<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Virtual Machine<br>
> qemu-1-GsmController.<br>
> Jan  8 15:30:58 desktop4 alsactl[837]: alsactl daemon stopped<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Session 1 of user root.<br>
> Jan  8 15:30:58 desktop4 systemd: Stopping Manage Sound Card State (restore<br>
> and store)...<br>
<br>
</div></div>I don't see your service being called. Anyway, look at<br>
libvirt-guests.service file. Looks like the following lines cause<br>
systemd to wait for a command to finish:<br>
<br>
[Service]<br>
EnvironmentFile=-/etc/<wbr>sysconfig/libvirt-guests<br>
# Hack just call traditional service until we factor<br>
# out the code<br>
ExecStart=@libexecdir@/<wbr>libvirt-guests.sh start<br>
ExecStop=@libexecdir@/libvirt-<wbr>guests.sh stop<br>
Type=oneshot<br>
RemainAfterExit=yes<br>
StandardOutput=journal+console<br>
TimeoutStopSec=0<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
><br>
><br>
> On Wed, Jan 10, 2018 at 8:46 PM, Michal Privoznik <<a href="mailto:mprivozn@redhat.com">mprivozn@redhat.com</a>><br>
> wrote:<br>
><br>
>> On 01/05/2018 12:00 PM, Raman Gupta wrote:<br>
>>> Hi,<br>
>>><br>
>>> I have CentOS 7,  two node system which allows live VM migration between<br>
>>> them. Live migration triggered from virsh is happily happening. I am<br>
>> using<br>
>>> GlusterFS for replicating VM disk files.<br>
>>><br>
>>> Now I want to automatically do the live migration at the time of<br>
>>> reboot/shutdown/halt of the host node and for this I have written a<br>
>> systemd<br>
>>> service unit [vPreShutdownHook.service] and placed the live migration<br>
>>> command in a migrate script which is invoked from this service unit. The<br>
>>> migrate script is invoked but migration does not happen.<br>
>>> If someone has some idea please help me to migrate VM upon shutdown.<br>
>>><br>
>>><br>
>>> ######## vPreShutdownHook.service ###############<br>
>>><br>
>>> [Unit]<br>
>>> Description=vPreShutdownHook<br>
>>> Requires=network.target<br>
>>> Requires=libvirtd.service<br>
>>> Requires=dbus.service<br>
>>> Requires=glusterd.service<br>
>>> Requires=glusterfsd.service<br>
>>> DefaultDependencies=no<br>
>>> Before=shutdown.target reboot.target<br>
>>><br>
>>> [Service]<br>
>>> Type=oneshot<br>
>>> RemainAfterExit=true<br>
>>> ExecStart=/bin/true<br>
>>> ExecStop=/root/vm_migrate.sh<br>
>>><br>
>>> [Install]<br>
>>> WantedBy=multi-user.target<br>
>>><br>
>>><br>
>>> ########## Command to migrate ############<br>
>>> /usr/bin/virsh migrate --verbose --p2p --tunneled --live  --compressed<br>
>>> --comp-methods "mt"  --comp-mt-level 5 --comp-mt-threads 5<br>
>>> --comp-mt-dthreads 5   MY_VM qemu+ssh://root@$node2/system<br>
>><br>
>> Does this command alone succeed?<br>
>> BTW: unless really needed --live will only make the migration take longer.<br>
>><br>
>> I don't know enough about systemd but maybe it's not waiting for virsh<br>
>> to finish? Can you try to get any logs to see what is going on actually?<br>
>><br>
>> Michal<br>
>><br>
><br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">Michal<br>
</font></span></blockquote></div><br></div>