無法啟動使用 virt-clone 複製的域
底部的最終更新
我有一個工作的 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 沒有提供有關此文件的任何資訊,則“資源繁忙無法打開文件”可能是權限問題…
lsof |grep virtiofsd.log