QEMU QMP 如何找到设备来使用 drive_backup?

QEMU QMP 如何找到设备来使用 drive_backup?

我想使用 backup_drive 命令在一个映像中复制磁盘及其快照。

不幸的是,每次我使用该命令时:

virsh qemu-monitor-command VM_NAME --hmp drive_backup device=drive-ide0-0-0 sync=full target=/mnt/mig-kvm/test_sync_snap.qcow2

但我收到此错误:

Device 'device=ide0-0-0' not found

我尝试使用“domblklist”和“execute query-block”找到的设备

有人可以给我举个例子让我知道我需要在 backup_drive 命令中输入什么“设备”吗?

我已经检查过这篇文章但没有成功: QEMU 找不到设备或节点名称

谢谢 !

谨致问候,NB

答案1

监视info block命令将显示连接到客户的块设备。

[root@makrura ~]# virsh qemu-monitor-command hyperv-server-2016 --hmp "info block"
drive-scsi0-0-0-0 (#block118): /var/lib/libvirt/images/hyperv-server-2016.qcow2 (qcow2)
    Attached to:      scsi0-0-0-0
    Cache mode:       writeback

drive-sata0-0-1 (#block396): /var/lib/libvirt/isos/14393.0.160916-1106.RS1_REFRESH_SERVERHYPERCORE_OEM_X64FRE_EN-US.ISO (raw, read-only)
    Attached to:      sata0-0-1
    Removable device: not locked, tray closed
    Cache mode:       writeback

drive-sata0-0-2 (#block542): /usr/share/virtio-win/virtio-win-0.1.141.iso (raw, read-only)
    Attached to:      sata0-0-2
    Removable device: not locked, tray closed
    Cache mode:       writeback

这里的磁盘设备名是drive-scsi0-0-0-0。(其他块设备都是虚拟 CDROM 设备。)但drive_backup期望的是出现在括号中的 node_name,即#block118

看来你的语法也不太正确。来自帮助:

drive_backup [-n] [-f] [-c] device target [format] -- initiates a point-in-time
            copy for a device. The device's contents are
            copied to the new image file, excluding data that
            is written after the command is started.
            The -n flag requests QEMU to reuse the image found
            in new-image-file, instead of recreating it from scratch.
            The -f flag requests QEMU to copy the whole disk,
            so that the result does not need a backing file.
            The -c flag requests QEMU to compress backup data
            (if the target format supports it).

因此你可以这样做:

[root@makrura ~]# virsh qemu-monitor-command hyperv-server-2016 --hmp "drive_backup -f #block118 /tmp/test.qcow2 qcow2"


[root@makrura ~]# ls -l /tmp/test.qcow2 
-rw-r--r--. 1 qemu qemu 982712320 Aug  7 11:19 /tmp/test.qcow2

相关内容