When I use virt-sysprep, I saw the following errors.
| 
guestfsd: error while loading shared libraries: libcap.so.2: cannot open shared object file: No such file or directory | 
 
In my case, after upgrading an appliance of guestfs with “update-guestfs-appliance” command, I could solve this error.
Here are trial and error logs I did.
KVM host: Ubuntu 13.10 
virtual machine: CentOS 6.5
| 
# guestfish --version 
guestfish 1.22.4 
 
# virt-sysprep --version 
virt-sysprep 1.22.4 
 
# qemu-system-x86_64 --version 
QEMU emulator version 1.5.0 (Debian 1.5.0+dfsg-3ubuntu5.4), Copyright (c) 2003-2008 Fabrice Bellard | 
 
error
| 
# virt-sysprep  --enable ssh-hostkeys,udev-persistent-net -a /var/lib/KVM_images/foobar.qcow2 
Examining the guest ... 
Fatal error: exception Guestfs.Error("guestfs_launch failed. 
This usually means the libguestfs appliance failed to start or crashed. 
See http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs 
or run 'libguestfs-test-tool' and post the *complete* output into a 
bug report | 
 
run as debug mode.
| 
 
# virt-sysprep  --enable ssh-hostkeys,udev-persistent-net -a /var/lib/KVM_images/foobar.qcow2 
guestfsd: error while loading shared libraries: libcap.so.2: cannot open shared object file: No such file or directory 
[    1.395248] Unregister pv shared memory for cpu 0 
[    1.395959] sd 2:0:1:0: [sdb] Synchronizing SCSI cache 
[    1.397359] sd 2:0:0:0: [sda] Synchronizing SCSI cache 
[    1.398840] reboot: Restarting system 
[    1.399376] reboot: machine restart 
libguestfs: child_cleanup: 0x2288f30: child process died 
libguestfs: sending SIGTERM to process 12114 
Fatal error: exception Guestfs.Error("guestfs_launch failed, see earlier error messages") 
libguestfs: closing guestfs handle 0x2288f30 (state 0) 
libguestfs: command: run: rm 
libguestfs: command: run: \ -rf /tmp/libguestfsiwwYZ1 | 
 
run libguestfs-test-tool.
same errors.
| 
# libguestfs-test-tool 
uptime: 1.29 0.74 
guestfsd: error while loading shared libraries: libcap.so.2: cannot open shared object file: No such file or directory 
[    1.304720] Unregister pv shared memory for cpu 0 
[    1.305483] sd 2:0:1:0: [sdb] Synchronizing SCSI cache 
[    1.306562] sd 2:0:0:0: [sda] Synchronizing SCSI cache 
[    1.339817] reboot: Restarting system 
[    1.340285] reboot: machine restart 
libguestfs: error: appliance closed the connection unexpectedly, see earlier error messages 
libguestfs: child_cleanup: 0x24399a0: child process died 
libguestfs: sending SIGTERM to process 14987 
libguestfs: error: guestfs_launch failed, see earlier error messages 
libguestfs-test-tool: failed to launch appliance 
libguestfs: closing guestfs handle 0x24399a0 (state 0) 
libguestfs: command: run: rm 
libguestfs: command: run: \ -rf /tmp/libguestfssEis6M | 
 
update appliance.
| 
# update-guestfs-appliance | 
 
run libuestfs-test-tool again.
Okay.
| 
# libguestfs-test-tool 
umount /sysroot 
fsync /dev/sda 
guestfsd: main_loop: proc 282 (internal_autosync) took 0.03 seconds 
libguestfs: sending SIGTERM to process 17227 
libguestfs: closing guestfs handle 0x25579a0 (state 0) 
libguestfs: command: run: rm 
libguestfs: command: run: \ -rf /tmp/libguestfsuIeeBb 
===== TEST FINISHED OK ===== | 
 
run virt-sysprep. okay.
| 
# virt-sysprep  --enable ssh-hostkeys,udev-persistent-net,random- 
seed -a /var/lib/KVM_images/foobar.qcow2 
Examining the guest ... 
Performing "random-seed" ... 
Performing "ssh-hostkeys" ... 
Performing "udev-persistent-net" ... |