Debian

virsh 錯誤:域已停止

  • June 25, 2018

創建快照時,我的 VM 備份腳本失敗。

virsh snapshot-create-as --domain machine_1 snap --diskspec vda,file=/srv/test/test-snap.qcow2 --disk-only --atomic --no-metadata --quiesce
error: Requested operation is not valid: domain is already quiesced

即使在 VM 重新啟動後,系統仍然處於靜默狀態,並且出現同樣的錯誤。

我認為 quiesce 意味著 FS 凍結,但這沒有任何意義,因為我在登錄有故障的 VM 時仍然可以寫入 FS。這不會在重新啟動後倖存下來,對吧?

會不會是一個通信問題,讓主機認為 GA 說機器處於靜止狀態,而實際上並非如此?

無論如何,是否有查詢靜默狀態的命令(除了嘗試快照並查看是否出現錯誤)?

假設有故障的虛擬機在出現不可重現的錯誤後停止,我可以通過退出停止狀態來解決這個問題,不管這意味著什麼。是否有 virsh 命令來取消 VM 的靜默?

整個備份過程過去可以工作,現在它在 2 個 VM 上失敗,但仍然可以在另外 2 個 VM 上工作,我想不出它們之間有什麼相關的區別。

軟體版本:

  • 主機是 Debian Jessie,帶有來自 backports 的 qemu-kvm 2.8+dfsg-3~bop8+1。
  • 來賓是帶有 qemu-guest-agent 2.8+dfsg-6+deb9u4 的 Debian Stretch。

(作為記錄,備份腳本在 GitHub 上。基本上,它所做的是 1/ 創建快照,2/ 複製,3/ 送出快照。)

如果我quiesce從快照命令行中刪除該選項,事情就會順利進行。但顯然,這並不理想。

根本原因是在 libvirt 1.2.11 中修復的錯誤

通過以下方式修復上游:

commit 6085d917d5c5839b7ed351e99fadbbb56f5178fe
Author: Michal Privoznik <mprivozn@redhat.com>
Date: Thu Nov 27 11:43:56 2014 +0100

qemu: Don't track quiesced state of FSs

https://bugzilla.redhat.com/show_bug.cgi?id=1160084

As of b6d4dad11b (1.2.5) we are trying to keep the status of FSFreeze
in the guest. Even though I've tried to fixed couple of corner cases
(6ea54769ba18), it occurred to me just recently, that the approach is
broken by design. Firstly, there are many other ways to talk to
qemu-ga (even through libvirt) that filesystems can be thawed (e.g.
qemu-agent-command) without libvirt noticing. Moreover, there are
plenty of ways to thaw filesystems without even qemu-ga noticing (yes,
qemu-ga keeps internal track of FSFreeze status). So, instead of
keeping the track ourselves, or asking qemu-ga for stale state, it's
the best to let qemu-ga deal with that (and possibly let guest kernel
propagate an error).

Moreover, there's one bug with the following approach, if fsfreeze
command failed, we've executed fsthaw subsequently. So issuing
domfsfreeze in virsh gave the following result:

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

升級到較新的版本可以解決此問題。

引用自:https://serverfault.com/questions/917247