大网数据广告活动
服务器运维问答

Q: Unable to create 'live' snapshot of running KVM using virsh

· 52CE 我爱测

I was kindly directed to here, Serverfault from Stackoverflow to pose my question. I'm running the following command on a RHEL7 hypervisor to create a live backup (disc image) of a running kvm, which is running a production docke…

问题原文

原帖链接 · Rick Epoch · CC BY-SA 4.0

I was kindly directed to here, Serverfault from Stackoverflow to pose my question.

I'm running the following command on a RHEL7 hypervisor to create a live backup (disc image) of a running kvm, which is running a production docker service in the kvm I want a live snapshot.

Many docs I have read lead me to this command to get a live snapshot of a running KVM:

# virsh snapshot-create-as \
    --domain undercloud-vm undercloud-vm-snapshot \
    --diskspec vda,file=/backup/images/undercloud-vm.qcow2 \
    --quiesce \
    --disk-only \
    --atomic    

error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': failed to open /var/lib/docker/overlay2: Permission denied

Not wanting to mess with the KVM's /var/lib/docker/overlay2 directory permissions, I have resorted to asking this question here. And if anyone has come across this issue of trying to make a live snapshot of a KVM that happens to be running docker inside. The main thing here is that the KVM is production, and it can not simply be paused or frozen to create the snapshot, it must continue to run and process data.

Any pointers to get me a live backup would be greatly appreciated.

INFO............

In the KVM: (running: /usr/libexec/qemu-kvm ...)

  • OS: Red Hat Enterprise Linux Server release 7.5 (Maipo)
  • Channel: org.qemu.guest_agent.0 has been added as virtual H/W
  • YUM: yum install qemu-guest-agent
  • S/W: Docker version 1.13.1, build 6e3bb8e/1.13.1

Hypervisor:

  • HW: PowerEdge FC630, Dell FX2s 36 CPUs, 128GB RAM
  • OS: Red Hat Enterprise Linux Server release 7.6 (Maipo)
  • SW: qemu-img-rhev = 10:2.10.0-21.el7_5.4
  • qemu-kvm-(common-)rhev = 10:2.10.0-21.el7_5.4

社区高分解答

原帖链接 · larsks · CC BY-SA 4.0

I just ran into the same problem. It's an selinux issue: selinux (on the guest) is preventing the QEMU guest agent from quiescing the target filesystem. You can see a summary of the issue like this:

# ausearch -c qemu-ga --raw | audit2allow


#============= virt_qemu_ga_t ==============

allow virt_qemu_ga_t container_var_lib_t:dir { ioctl open read search };

allow virt_qemu_ga_t proc_net_t:file read;

You can generate an appropriate local security module that permits qemu-ga to operate correctly like this:

# ausearch -c qemu-ga --raw | audit2allow -M local
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i local.pp
# semodule -i local.pp

With this change in place, we are able to use the --quiesce option when generating snapshots.


Update: upon inspection, this solution actually shows up in the error message included in the bug report:

Jan 16 10:59:49 localhost python: SELinux is preventing /usr/bin/qemu-ga from search access on the directory /var/lib/docker.#012#012***** Plugin catchall (100. confidence) suggests **************************#012#012If you believe that qemu-ga should be allowed search access on the docker directory by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c 'qemu-ga' --raw | audit2allow -M my-qemuga#012# semodule -i my-qemuga.pp#012

If you look at the end of the error there, it says:

You can generate a local policy module to allow this access.
allow this access for now by executing:
# ausearch -c 'qemu-ga' --raw | audit2allow -M my-qemuga
# semodule -i my-qemuga.pp

...which is exactly what I wrote here.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-11-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。