How to reset a KVM clone virtual Machines with virt-sysprep on Linux

Originally published at: https://www.cyberciti.biz/faq/how-to-reset-a-kvm-clone-virtual-machines-with-virt-sysprep-on-linux/

I know how to clone a KVM VM. Once cloned I would like to reset cloned VM. How do I reset, unconfigure or customize a virtual machine so clones can be made? How can I reset a KVM clone virtual Machines with virt-sysprep command on a Linux server based hypervisor?

On my RHEL 7.5 server I ran:

virt-sysprep -n -d test10 --hostname test10 --keep-user-accounts username

I got:

virt-sysprep: error: user-accounts: --keep-user-accounts parameter was
used, but the "user-account" operation is not enabled
If reporting bugs, run virt-sysprep with debugging enabled and include the 
complete output:
  virt-sysprep -v -x [...]

How do I fix this?

You need to pass the –enable user-account option as follows:

virt-sysprep -n -d test10 --hostname test10  --enable user-account --keep-user-accounts username