"Daniel P. Berrange" <berrange@xxxxxxxxxx> a écrit :
On Thu, Mar 31, 2016 at 12:05:07PM +0200, villeneu@xxxxxxxxxxxxxxxxxxxx wrote:
Hello
I use lock_manager with libvirt 1.3 and
I would like to know how is exactly calculate the hash SHA256. I would
create a table
to retreive the name with the hash in case of crash to release manualy the
lock.
Do you mean in the case of a host crash, and if so what filesystem ? If
you are using NFS at lesat so you shouldn't need to know the file names,
there is the ability to tell the NFS server to release all locks associated
with a dead host.
I am using NFS. I have many POOL on an NFS server and I use a special share NFS with all my hypervisors
where I put my locks
qemu-lock.conf
...
lock file_lockspace_dir = "/var/lib/libvirt/images/POOL_ADMIN/lock"
...
my POOL are
lock file_lockspace_dir = "/var/lib/libvirt/images/POOL_ADMIN/lock"
....
my POOL are
/var/lib/libvirt/i/var/lib/libvirt/images/POOL_PROD1
/var/lib/libvirt/i/var/lib/libvirt/images/POOL_PROD2
....
In a first time,
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.
from the virsh list ... and I always got
Failed to terminate process xxx with SIGTERM: Device or resource busy and the VM is still in the list
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.
I tried sanlock command to release the resource without success.
ie
sanlock client rem_lockspace -r
__LIBVIRT__DISKS__:b90b9c61e2d6413077205907ffb3281a:/var/lib/libvirt/images/POOL_ADMIN/sanlock/b90b9c61e2d6413077205907ffb3281a:0:4 -p 9383
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.
I do an sha256 hash from /var/lib/libvirt/images/lock/MyVM.img but I
don't get the same hash code form virtlockd ?
It uses the sha256 has of the filename. How did you generate your hash ?
If using shell make sure you don't include a newline
ie you want
echo -n /var/lib/libvirt/images/lock/MyVM.img | sha256sum
not a plain 'echo' as that includes a newline
to test before a script with the python libvirt API
I am using a very simple python script
import hashlib
hash_object = hashlib.sha256(b'/var/lib/libvirt/images/POOL_PROD4/WPAD.img')
hex_dig = hash_object.hexdigest()
print(hex_dig)
>>>f52b8ebb9e2922831cf4ff7520ad51ab48af004dbb732155df5e02809a01654c
and the lock in the directory when I start the VM is
virsh start WPAD
ls -alcrt -rw------- 1 root root 0 31 mars 15:02 f12269eb8c7afd6551f2549d245e52182714ae43fd0212626593195a24349605
so I am little confused ...
Regards,
Daniel
Michel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :||: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
|
_______________________________________________
libvirt-users mailing list
libvirt-users@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvirt-users