底部的最终更新
我有一个工作的 KVM 域,我已经配置并希望将其用作其他来宾的“模板”。所以,我的流程大致是这样的:
- 关闭“源”域 (
07xQBuild
) - 跑
virt-clone --original 07xQBuild --name 07x2 --file ./07x2.qcow2
- 使用挂载新创建的
07x2.qcow2
映像guestmount
,并编辑网络配置(/etc/netplan/01-config.yaml
、/etc/hostname
等)等内容 - 卸载图像并开始
virsh start 07x2
但这总是以:
error: Failed to start domain 07x2
error: Cannot open log file: '/usr/local/var/log/libvirt/qemu/07x2-fs0-virtiofsd.log': Device or resource busy
没有07x2-fs0-virtiofsd.log
文件,07x2.log
文件只包含:
2020-07-28 13:42:29.400+0000: shutting down, reason=failed
我尝试运行LIBVIRT_DEBUG=1 virsh start 07x2
,但在 400 多行输出中,我只能看到以下错误:
2020-07-28 13:15:00.954+0000: 40737: info : virObjectNew:250 : OBJECT_NEW: obj=0x56440bb29480 classname=virDomain
2020-07-28 13:15:00.954+0000: 40737: info : virObjectRef:385 : OBJECT_REF: obj=0x56440bb25be0
2020-07-28 13:15:00.954+0000: 40737: debug : virDomainGetID:1721 : dom=0x56440bb29480, (VM: name=07x2, uuid=761c9104-b8de-474a-a5d6-31be46b50562)
2020-07-28 13:15:00.955+0000: 40737: debug : virDomainCreate:6544 : dom=0x56440bb29480, (VM: name=07x2, uuid=761c9104-b8de-474a-a5d6-31be46b50562)
2020-07-28 13:15:00.955+0000: 40737: debug : virNetMessageNew:45 : msg=0x56440bb27df0 tracked=0
2020-07-28 13:15:00.955+0000: 40737: debug : virNetMessageEncodePayload:388 : Encode length as 60
2020-07-28 13:15:00.955+0000: 40737: info : virNetClientSendInternal:2108 : RPC_CLIENT_MSG_TX_QUEUE: client=0x56440bb26f60 len=60 prog=536903814 vers=1 proc=9 type=0 status=0 serial=7
2020-07-28 13:15:00.955+0000: 40737: debug : virNetClientCallNew:2061 : New call 0x56440bb39290: msg=0x56440bb27df0, expectReply=1, nonBlock=0
2020-07-28 13:15:00.955+0000: 40737: debug : virNetClientIO:1879 : Outgoing message prog=536903814 version=1 serial=7 proc=9 type=0 length=60 dispatch=(nil)
2020-07-28 13:15:00.955+0000: 40737: debug : virNetClientIO:1931 : We have the buck head=0x56440bb39290 call=0x56440bb39290
2020-07-28 13:15:00.955+0000: 40737: info : virEventGLibHandleUpdate:196 : EVENT_GLIB_UPDATE_HANDLE: watch=1 events=0
2020-07-28 13:15:00.955+0000: 40737: debug : virEventGLibHandleUpdate:206 : Update handle data=0x56440bb27420 watch=1 fd=4 events=0
2020-07-28 13:15:00.955+0000: 40737: debug : virEventGLibHandleUpdate:227 : Removed old handle watch=15
2020-07-28 13:15:00.955+0000: 40738: debug : virEventRunDefaultImpl:340 : running default event implementation
2020-07-28 13:15:00.955+0000: 40737: info : virEventGLibTimeoutUpdate:381 : EVENT_GLIB_UPDATE_TIMEOUT: timer=2 interval=5000
2020-07-28 13:15:00.955+0000: 40737: debug : virEventGLibTimeoutUpdate:390 : Update timeout data=0x56440bb27dc0 timer=2 interval=5000 ms
2020-07-28 13:15:00.955+0000: 40738: debug : virEventRunDefaultImpl:340 : running default event implementation
2020-07-28 13:15:02.363+0000: 40737: info : virEventGLibTimeoutUpdate:381 : EVENT_GLIB_UPDATE_TIMEOUT: timer=2 interval=3000
2020-07-28 13:15:02.363+0000: 40737: debug : virEventGLibTimeoutUpdate:390 : Update timeout data=0x56440bb27dc0 timer=2 interval=3000 ms
2020-07-28 13:15:02.363+0000: 40737: debug : virNetMessageDecodeLength:160 : Got length, now need 304 total (300 more)
2020-07-28 13:15:02.363+0000: 40737: info : virNetClientCallDispatch:1263 : RPC_CLIENT_MSG_RX: client=0x56440bb26f60 len=304 prog=536903814 vers=1 proc=9 type=1 status=1 serial=7
2020-07-28 13:15:02.363+0000: 40737: debug : virKeepAliveCheckMessage:369 : ka=0x56440bb28bb0, client=0x56440bb26f60, msg=0x56440bb26fc8
2020-07-28 13:15:02.363+0000: 40737: info : virEventGLibTimeoutUpdate:381 : EVENT_GLIB_UPDATE_TIMEOUT: timer=2 interval=5000
2020-07-28 13:15:02.363+0000: 40737: debug : virEventGLibTimeoutUpdate:390 : Update timeout data=0x56440bb27dc0 timer=2 interval=5000 ms
2020-07-28 13:15:02.363+0000: 40737: debug : virNetMessageClear:73 : msg=0x56440bb26fc8 nfds=0
2020-07-28 13:15:02.363+0000: 40738: debug : virEventRunDefaultImpl:340 : running default event implementation
2020-07-28 13:15:02.363+0000: 40737: debug : virNetClientIOEventLoopPassTheBuck:1559 : Giving up the buck 0x56440bb39290
2020-07-28 13:15:02.363+0000: 40737: debug : virNetClientIOEventLoopPassTheBuck:1573 : No thread to pass the buck to
2020-07-28 13:15:02.363+0000: 40737: info : virEventGLibHandleUpdate:196 : EVENT_GLIB_UPDATE_HANDLE: watch=1 events=1
2020-07-28 13:15:02.363+0000: 40737: debug : virEventGLibHandleUpdate:206 : Update handle data=0x56440bb27420 watch=1 fd=4 events=1
2020-07-28 13:15:02.363+0000: 40737: debug : virEventGLibHandleUpdate:222 : Added new handle watch=19
2020-07-28 13:15:02.363+0000: 40737: debug : virNetClientIO:1956 : All done with our call head=(nil) call=0x56440bb39290 rv=0
2020-07-28 13:15:02.363+0000: 40737: debug : virNetMessageFree:86 : msg=0x56440bb27df0 nfds=0 cb=(nil)
2020-07-28 13:15:02.363+0000: 40738: debug : virEventRunDefaultImpl:340 : running default event implementation
2020-07-28 13:15:02.363+0000: 40737: debug : virDomainGetName:1642 : domain=0x56440bb29480
error: Failed to start domain 07x2
2020-07-28 13:15:02.363+0000: 40737: debug : virDomainFree:562 : dom=0x56440bb29480, (VM: name=07x2, uuid=761c9104-b8de-474a-a5d6-31be46b50562)
2020-07-28 13:15:02.364+0000: 40737: info : virObjectUnref:347 : OBJECT_UNREF: obj=0x56440bb29480
2020-07-28 13:15:02.364+0000: 40737: info : virObjectUnref:349 : OBJECT_DISPOSE: obj=0x56440bb29480
2020-07-28 13:15:02.364+0000: 40737: debug : virDomainDispose:323 : release domain 0x56440bb29480 07x2 761c9104-b8de-474a-a5d6-31be46b50562
2020-07-28 13:15:02.364+0000: 40737: info : virObjectUnref:347 : OBJECT_UNREF: obj=0x56440bb25be0
error: Cannot open log file: '/usr/local/var/log/libvirt/qemu/07x2-fs0-virtiofsd.log': Device or resource busy
我尝试转储源域的 XML(有效)和克隆的 XML(无效),唯一的 4 个区别是名称、uuid、源文件和 mac 地址:
# diff 07xQBuild.xml 07x2.xml
2,3c2,3
< <name>07xQBuild</name>
< <uuid>24ed7962-518e-4151-8635-84cb72a8a9b4</uuid>
---
> <name>07x2</name>
> <uuid>761c9104-b8de-474a-a5d6-31be46b50562</uuid>
45c45
< <source file='/fast_data/kvm/images/07xQBuild.qcow2'/>
---
> <source file='/fast_data/kvm/images/07x2.qcow2'/>
83c83
< <mac address='52:54:00:01:7c:fc'/>
---
> <mac address='52:54:00:c6:4a:e4'/>
使用 克隆域后是否还需要其他东西virt-clone
?
2020-07-28 17:10 英国夏令时更新
好的,这似乎很简单——我可以创建一个名为 07x3 的新来宾,并且一切正常。由于我一直在重建和测试 07x2 几次,看起来有些东西卡住了。要删除和重新创建域,我一直在这样做:
# virsh destroy 07x2
# virsh undefine 07x2
# rm 07x2.qcow2
这对所有其他域都有效,但 07x2 总是会导致该错误。所以我想新的问题是如何找出我还需要删除/清除/清除什么才能重新创建它?
2020-08-14 11:31 英国夏令时更新
根据@gediz-gÜrsu 的回答,我尝试了这个:
# cp -a /fast_data/kvm/images/07xTemplate.qcow2 /fast_data/kvm/images/07x2.qcow2
# cp -a /usr/local/etc/libvirt/qemu/07xTemplate.xml /usr/local/etc/libvirt/qemu/07x2.xml
- 编辑那个xml,替换名字、uuid、磁盘源和mac地址
# virsh define /usr/local/etc/libvirt/qemu/07x2.xml
- 用于
guestmount
更新磁盘映像设置(IP 地址等) # virsh start 07x2
我得到了完全相同的错误,并且没有名为07x2-fs0-virtiofsd.log
. 07x2.log
看起来与原始问题完全相同。所以我想我们可以排除virt-clone
问题的原因。
然而,运行lsof | grep virtiofsd.log
产生了这个:
virtlogd 3255 root 15w REG 253,1 0 5773534 /usr/local/var/log/libvirt/qemu/07x1-fs0-virtiofsd.log
virtlogd 3255 root 17w REG 253,1 0 5773535 /usr/local/var/log/libvirt/qemu/07x1-fs1-virtiofsd.log
virtlogd 3255 root 19w REG 253,1 0 5773536 /usr/local/var/log/libvirt/qemu/07x1-fs2-virtiofsd.log
virtlogd 3255 root 21w REG 253,1 0 5773537 /usr/local/var/log/libvirt/qemu/07x1-fs3-virtiofsd.log
virtlogd 3255 root 23w REG 253,1 0 5773538 /usr/local/var/log/libvirt/qemu/07x1-fs4-virtiofsd.log
virtlogd 3255 root 27w REG 253,1 0 5767384 /usr/local/var/log/libvirt/qemu/07x2-fs0-virtiofsd.log (deleted)
virtlogd 3255 root 29w REG 253,1 0 5767385 /usr/local/var/log/libvirt/qemu/07x2-fs1-virtiofsd.log (deleted)
virtlogd 3255 root 31w REG 253,1 0 5773542 /usr/local/var/log/libvirt/qemu/07x3-fs0-virtiofsd.log
virtlogd 3255 root 33w REG 253,1 0 5773543 /usr/local/var/log/libvirt/qemu/07x3-fs1-virtiofsd.log
virtlogd 3255 root 35w REG 253,1 0 5773807 /usr/local/var/log/libvirt/qemu/07x3-fs2-virtiofsd.log
virtlogd 3255 root 37w REG 253,1 0 5773808 /usr/local/var/log/libvirt/qemu/07x3-fs3-virtiofsd.log
virtlogd 3255 root 39w REG 253,1 0 5774205 /usr/local/var/log/libvirt/qemu/07x3-fs4-virtiofsd.log
对不起,它很宽 - 滚动查看(deleted)
我猜是问题原因的 2 个条目。因此,解决方案似乎很简单service virtlogd restart
。我现在能够成功启动该域!
如果它不是自动化的并且再次发生,下次不要使用 virt-clone 尝试使用
virsh edit
withcp -ar
。更改 uuid 名称 mac 和复制驱动器的新名称。
您还可以使用它
virt-manager
来添加和删除驱动器以及更改名称,它与ssh -X or -Y
.如果 lsof 没有提供有关此文件的任何信息,则“资源繁忙无法打开文件”可能是权限问题...