<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body style="font-family:Arial;font-size:14px"><p>
"Daniel P. Berrange" <<a href="mailto:berrange@redhat.com">berrange@redhat.com</a>> a écrit :</p>
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
On Thu, Mar 31, 2016 at 12:05:07PM +0200, <a href="mailto:villeneu@kassis.univ-brest.fr">villeneu@kassis.univ-brest.fr</a> wrote:
<blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
Hello<br><br>
I use lock_manager with libvirt 1.3 and<br>
I would like to know how is exactly calculate the hash SHA256. I would<br>
create a table<br>
to retreive the name with the hash in case of crash to release manualy the<br>
lock.</blockquote>
Do you mean in the case of a host crash, and if so what filesystem ? If<br>
you are using NFS at lesat so you shouldn't need to know the file names,<br>
there is the ability to tell the NFS server to release all locks associated<br>
with a dead host.<br><br>
I am using NFS. I have many POOL on an NFS server and I use a special share NFS with all my hypervisors<br>
where I put my locks<br><br>
qemu-lock.conf<br>
...<br>
lock file_lockspace_dir = "/var/lib/libvirt/images/POOL_ADMIN/lock"<br><br>
...<br>
my POOL are<br>
lock file_lockspace_dir = "/var/lib/libvirt/images/POOL_ADMIN/lock"<br>
....<br>
my POOL are<br>
/var/lib/libvirt/i/var/lib/libvirt/images/POOL_PROD1<br>
/var/lib/libvirt/i/var/lib/libvirt/images/POOL_PROD2<br>
....<br><br>
In a first time,<br>
I tried sanlock with the same configuration but some old VMs often have crashed and the qemu process were in an anormal state ( defunc ), and I wasn't be able to kill correctly the process. The virsh destroy command couldn't remove the VM.<br>
from the virsh list ... and I always got<br>
Failed to terminate process xxx with SIGTERM: Device or resource busy and the VM is still in the list<br><br>
I wasn't be able to freeing the resource with sanlock and the result was that I couldn't start a VM which crashed before because the lock was still present.<br>
I tried sanlock command to release the resource without success.<br><br>
ie<br>
sanlock client rem_lockspace -r<br>
__LIBVIRT__DISKS__:b90b9c61e2d6413077205907ffb3281a:/var/lib/libvirt/images/POOL_ADMIN/sanlock/b90b9c61e2d6413077205907ffb3281a:0:4 -p 9383<br><br><br>
So I decided to try lock_manager , but there is no tools as sanlock to coupled vm name and lock. In a case of crash and if the lock isn't removed I will be with the same problem, it 's one of the reason I want to create a datatable with sha256 checksum and the vm name.<br><br><blockquote style="border-left:2px solid blue;margin-left:2px;padding-left:12px;" type="cite">
I do an sha256 hash from /var/lib/libvirt/images/lock/MyVM.img but I<br>
don't get the same hash code form virtlockd ?</blockquote>
It uses the sha256 has of the filename. How did you generate your hash ?<br>
If using shell make sure you don't include a newline<br><br>
ie you want<br><br>
echo -n /var/lib/libvirt/images/lock/MyVM.img | sha256sum<br><br>
not a plain 'echo' as that includes a newline<br><br>
to test before a script with the python libvirt API<br>
I am using a very simple python script<br><br>
import hashlib<br>
hash_object = hashlib.sha256(b'/var/lib/libvirt/images/POOL_PROD4/WPAD.img')<br>
hex_dig = hash_object.hexdigest()<br>
print(hex_dig)<br>
>>>f52b8ebb9e2922831cf4ff7520ad51ab48af004dbb732155df5e02809a01654c<br>
and the lock in the directory when I start the VM is<br>
virsh start WPAD<br>
ls -alcrt -rw------- 1 root root 0 31 mars 15:02 f12269eb8c7afd6551f2549d245e52182714ae43fd0212626593195a24349605<br><br>
so I am little confused ...<br><br>
Regards,<br>
Daniel<br><br><br>
Michel<br>
--<br>
|: <a href="http://berrange.com" target="_blank">http://berrange.com</a> -o- <a href="http://www.flickr.com/photos/dberrange/" target="_blank">http://www.flickr.com/photos/dberrange/</a> :|<br>
|: <a href="http://libvirt.org" target="_blank">http://libvirt.org</a> -o- <a href="http://virt-manager.org" target="_blank">http://virt-manager.org</a> :|<br>
|: <a href="http://autobuild.org" target="_blank">http://autobuild.org</a> -o- <a href="http://search.cpan.org/~danberr/" target="_blank">http://search.cpan.org/~danberr/</a> :||: <a href="http://entangle-photo.org" target="_blank">http://entangle-photo.org</a> -o- <a href="http://live.gnome.org/gtk-vnc" target="_blank">http://live.gnome.org/gtk-vnc</a> :|</blockquote>
<br><br></body></html>