Yang paling mudah adalah:
# virt-clone --connect=qemu://example.com/system -o this-vm -n that-vm --auto-clone
Yang akan membuat salinan this-vm
, bernama that-vm
, dan menangani duplikasi perangkat penyimpanan. Tidak ada yang baru di sini kecuali detail.
Lebih penting lagi, Apa yang dikatakan FAQ adalah bahwa deskripsi domain XML tidak dapat langsung diedit, Anda harus melalui libvirt. Untuk menyelesaikan langkah-langkah yang diambil oleh virt-clone
perintah, Anda dapat:
source_vm=vm_name
new_vm=new_vm_name
# You cannot "clone" a running vm, stop it. suspend and destroy
# are also valid options for less graceful cloning
virsh shutdown "$source_vm"
# copy the storage.
cp /var/lib/libvirt/images/{"$source_vm","$new_vm"}.img
# dump the xml for the original
virsh dumpxml "$source_vm" > "/tmp/$new_vm.xml"
# hardware addresses need to be removed, libvirt will assign
# new addresses automatically
sed -i /uuid/d "/tmp/$new_vm.xml"
sed -i '/mac address/d' "/tmp/$new_vm.xml"
# and actually rename the vm: (this also updates the storage path)
sed -i "s/$source_vm/$new_vm" "/tmp/$new_vm.xml"
# finally, create the new vm
virsh define "/tmp/$new_vm.xml"
virsh start "$source_vm"
virsh start "$new_vm"