error: Operation not supported: internal snapshots of a VM with pflash based firmware are not supported error:
不支持操作:不支持基于pflash固件的虚拟机的内部快照
[root@localhost kvms]# virsh snapshot-create rabbitmq2
error: Operation not supported: \
internal snapshots of a VM with pflash based firmware are not supported
#物理机型号: 长城飞腾服务器擎天EF860 /物理CPU型号: S2500
#KVM宿主机系统版本
[root@localhost kvms]# cat /etc/.productinfo
Kylin Linux Advanced Server
release V10 (SP2) /(Sword)-aarch64-Build09/20210524
[root@localhost kvms]# cat /etc/system-release
Kylin Linux Advanced Server release V10 (Sword)
---
搜索关键字loader
,type
类型为pflash
#KVM虚拟机xml文件
[root@localhost kvms]# virsh edit rabbitmq2
<domain type='kvm'>
<name>rabbitmq</name>
<uuid>b3e8cfbf-f37d-464d-871f-d4f2c7107b10</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://kylin.cn/kylin/10.0"/>
</libosinfo:libosinfo>
</metadata>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>
<os>
<type arch='aarch64' machine='virt-4.1'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
<nvram>/var/lib/libvirt/qemu/nvram/rabbitmq_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<gic version='3'/>
</features>
<cpu mode='host-passthrough' check='none'/>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data/kvms/rabbitmq.qcow2'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'/>
<controller type='pci' index='1' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='1' port='0x8'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
</controller>
<controller type='pci' index='2' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='2' port='0x9'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='3' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='3' port='0xa'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='4' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='4' port='0xb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
</controller>
<controller type='pci' index='5' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='5' port='0xc'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
</controller>
<controller type='pci' index='6' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='6' port='0xd'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
</controller>
<controller type='pci' index='7' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='7' port='0xe'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
</controller>
<controller type='pci' index='8' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='8' port='0xf'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:cd:d2:44'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<target type='system-serial' port='0'>
<model name='pl011'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'>
<address type='usb' bus='0' port='1'/>
</input>
<input type='keyboard' bus='usb'>
<address type='usb' bus='0' port='2'/>
</input>
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='virtio' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</memballoon>
</devices>
</domain>
不支持内部快照,还可以创建外部快照
如果您的客户域是一个简单的虚拟机,其中所有disk的类型都是
file
,那么创建一个上电虚拟机状态(不包括RAM)的外部快照如下所示。对于这个例子,假设有一个硬盘驱动器在’ hda’和CD-ROM在’hdb '。硬盘叫vda也可以
# name of domain, snapshot, and target disk device
# 虚拟机、快照、目标磁盘设备的名字
thedomain="rabbitmq2"
snapshotname="snapshot1"
targetdisk="vda"
# 查看''类型,应该只是'file'类型
virsh dumpxml $thedomain | grep ' -A5
# show block level devices and qcow2 paths (hda,hdb,..etc)
# 显示块级设备和qcow2路径(hda,hdb,..等)
virsh domblklist $thedomain
# create snapshot in default pool location
# file name is $thedomain.$snapshotname
virsh snapshot-create-as $thedomain --name $snapshotname --disk-only
# 列出虚拟机快照
virsh snapshot-list $thedomain
#查看默认pool
virsh pool-list
[root@localhost kvms]# thedomain="rabbitmq2"
[root@localhost kvms]# snapshotname="snapshot1"
[root@localhost kvms]# targetdisk="vda"
[root@localhost kvms]# virsh dumpxml $thedomain | grep '
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data/kvms/rabbitmq2.qcow2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
--
<disk type='file' device='cdrom'>
<driver name='qemu'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
[root@localhost kvms]# virsh domblklist $thedomain
Target Source
--------------------------------------
vda /data/kvms/rabbitmq2.qcow2
sda -
[root@localhost kvms]# virsh snapshot-create-as $thedomain --name $snapshotname --disk-only
Domain snapshot snapshot1 created
[root@localhost kvms]# virsh snapshot-list $thedomain
Name Creation Time State
--------------------------------------------------------
snapshot1 2023-03-28 09:37:03 +0800 disk-snapshot
查看下面的机制并为恢复快照准备变量,请执行下面的命令。
# 请注意,vda的路径现在已更改为快照文件
virsh domblklist $thedomain
#
virsh dumpxml $thedomain | grep ' -A5
# pull default pool path from xml
pooldir=$(virsh pool-dumpxml default | grep -Po "(?<=path\>)[^<]+")
echo "default pool dir: $pooldir"
# should see two files starting with $thedomain
# the one named $thedomain.$snapshotname is the snapshot
cd $pooldir
ls -latr $thedomain*
# snapshot points to backing file, which is original disk
sudo qemu-img info $thedomain.$snapshotname -U --backing-chain
# capture original backing file name so we can revert
backingfile=$(qemu-img info $thedomain.$snapshotname -U | grep -Po 'backing file:\s\K(.*)')
echo "backing file: $backingfile"
为了进行还原,我们需要将域 xml 修改回原始 qCow2文件,删除快照元数据,最后删除快照文件。(如果不再需要恢复快照,可以删除快照元数据文件和快照文件。)
# stop VM
virsh destroy $thedomain
# edit hda path back to original qcow2 disk
virt-xml $thedomain --edit target=$targetdisk --disk path=$backingfile --update
# validate that we are now pointing back at original qcow2 disk
virsh domblklist $thedomain
# delete snapshot metadata
virsh snapshot-delete --metadata $thedomain $snapshotname
# delete snapshot qcow2 file
sudo rm $pooldir/$thedomain.$snapshotname
# start guest domain
virsh start $thedomain
# 请注意,vda的路径现在已更改为快照文件
[root@localhost kvms]# virsh domblklist $thedomain
Target Source
------------------------------------------
vda /data/kvms/rabbitmq2.snapshot1
sda -
#< source > 已更改为快照文件
[root@localhost kvms]# virsh dumpxml $thedomain | grep '
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data/kvms/rabbitmq2.snapshot1'/>
<backingStore type='file' index='1'>
<format type='qcow2'/>
<source file='/data/kvms/rabbitmq2.qcow2'/>
--
<disk type='file' device='cdrom'>
<driver name='qemu'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
#从 xml 中提取默认池路径
[root@localhost kvms]# pooldir=$(virsh pool-dumpxml default | grep -Po "(?<=path\>)[^<]+")
error: failed to get pool 'default'
error: Storage pool not found: no storage pool with matching name 'default'
# 列出pool池
[root@localhost kvms]# virsh pool-list
Name State Autostart
----------------------------
kvms active yes
#修改pool池后,重新提取
[root@localhost kvms]# pooldir=$(virsh pool-dumpxml kvms | grep -Po "(?<=path\>)[^<]+")
[root@localhost kvms]# echo "default pool dir: $pooldir"
default pool dir: /data/kvms
#应该看到两个以$thedomain开头的文件
#一个名为$thedomain的。$snapshotname是快照
[root@localhost kvms]# cd $pooldir
[root@localhost kvms]# pwd
/data/kvms
[root@localhost kvms]# ls -latr $thedomain*
-rw------- 1 qemu qemu 85912715264 Mar 28 09:36 rabbitmq2.qcow2
-rw------- 1 qemu qemu 951058432 Mar 28 09:42 rabbitmq2.snapshot1
#快照指向备份文件,即原磁盘以上翻译结果来自有道神经网络翻译(YNMT)· 通用场景
[root@localhost kvms]# sudo qemu-img info $thedomain.$snapshotname -U --backing-chain
image: rabbitmq2.snapshot1
file format: qcow2
virtual size: 80 GiB (85899345920 bytes)
disk size: 1.22 GiB
cluster_size: 65536
backing file: /data/kvms/rabbitmq2.qcow2
backing file format: qcow2
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false
image: /data/kvms/rabbitmq2.qcow2
file format: qcow2
virtual size: 80 GiB (85899345920 bytes)
disk size: 3.72 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
refcount bits: 16
corrupt: false
#捕获原始备份文件名,以便恢复
[root@localhost kvms]# backingfile=$(qemu-img info $thedomain.$snapshotname -U | grep -Po 'backing file:\s\K(.*)')
[root@localhost kvms]# echo "backing file: $backingfile"
backing file: /data/kvms/rabbitmq2.qcow2
-------------------------------------------------------------
#为了进行还原,我们需要将域 xml 修改回原始 qCow2文件,删除快照元数据,最后删除快照文件
-------------------------------------------------------------
[root@localhost kvms]# virsh destroy $thedomain
Domain rabbitmq2 destroyed
#编辑 hda 路径返回原始 qCow2磁盘
[root@localhost kvms]# virt-xml $thedomain --edit target=$targetdisk --disk path=$backingfile --update
WARNING The VM is not running, --update is inapplicable.
Domain 'rabbitmq2' defined successfully.
WARNING XML did not change after domain define. You may have changed a value that libvirt is setting by default.
#验证我们现在指向的是原始的 qCow2磁盘
[root@localhost kvms]# virsh domblklist $thedomain
Target Source
--------------------------------------
vda /data/kvms/rabbitmq2.qcow2
sda -
#如果不需要快照元数据文件则可以删除,否则直接启动
[root@localhost kvms]# virsh snapshot-delete --metadata $thedomain $snapshotname
Domain snapshot snapshot1 deleted
#如果不需要快照文件则删除
[root@localhost kvms]# sudo rm $pooldir/$thedomain.$snapshotname
#启动恢复好快照的虚拟机
[root@localhost kvms]# virsh start $thedomain
Domain rabbitmq2 started
[root@localhost kvms]# virsh domblklist $thedomain
Target Source
--------------------------------------
vda /data/kvms/rabbitmq2.qcow2
sda
#恢复快照结束 -
---
[root@localhost kvms]# ls -latr $thedomain*
-rw------- 1 qemu qemu 85912715264 Mar 28 09:44 rabbitmq2.qcow2
[root@localhost kvms]# ls
Kylin-Server-10-SP2-Release-Build09-20210524-arm64.iso rabbitmq2.qcow2 rabbitmq.qcow2 rdjc-db.qcow2
[root@localhost kvms]# virsh snapshot-list $thedomain
Name Creation Time State
-------------------------------
[root@localhost kvms]# virsh dumpxml $thedomain | grep '
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data/kvms/rabbitmq2.qcow2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
--
<disk type='file' device='cdrom'>
<driver name='qemu'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
[root@localhost kvms]# virsh edit rabbitmq2
<domain type='kvm'>
<name>rabbitmq2</name>
<uuid>19bf5e14-01d2-4600-b338-8e656c6ca09e</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://kylin.cn/kylin/10.0"/>
</libosinfo:libosinfo>
</metadata>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>4</vcpu>
<os>
<type arch='aarch64' machine='virt-4.1'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/edk2/aarch64/QEMU_EFI-pflash.raw</loader>
<nvram>/var/lib/libvirt/qemu/nvram/rabbitmq2_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<gic version='3'/>
</features>
<cpu mode='host-passthrough' check='none'/>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/data/kvms/rabbitmq2.snapshot1'/>
</features>
<cpu mode='host-passthrough' check='none'/>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
---
<source file='/data/kvms/rabbitmq2.snapshot1'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/data/kvms/rabbitmq2.qcow2'/>
<backingStore type='file'>
<format type='qcow2'/>
<source file='/data/kvms/rabbitmq2.qcow2'/>
</backingStore>
</backingStore>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='sda' bus='scsi'/>
<readonly/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0' model='qemu-xhci' ports='15'>
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
</controller>
<controller type='scsi' index='0' model='virtio-scsi'>
<address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</controller>
<controller type='pci' index='0' model='pcie-root'/>
<controller type='pci' index='1' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='1' port='0x8'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
</controller>
<controller type='pci' index='2' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='2' port='0x9'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<controller type='pci' index='3' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='3' port='0xa'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='4' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='4' port='0xb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x3'/>
</controller>
<controller type='pci' index='5' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='5' port='0xc'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x4'/>
</controller>
<controller type='pci' index='6' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='6' port='0xd'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x5'/>
</controller>
<controller type='pci' index='7' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='7' port='0xe'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x6'/>
</controller>
<controller type='pci' index='8' model='pcie-root-port'>
<model name='pcie-root-port'/>
<target chassis='8' port='0xf'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x7'/>
</controller>
<controller type='virtio-serial' index='0'>
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:f9:6a:e7'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
</interface>
<serial type='pty'>
<target type='system-serial' port='0'>
<model name='pl011'/>
</target>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
<input type='tablet' bus='usb'>
<address type='usb' bus='0' port='1'/>
</input>
<input type='keyboard' bus='usb'>
<address type='usb' bus='0' port='2'/>
</input>
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='virtio' heads='1' primary='yes'/>
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
</memballoon>
</devices>
</domain>