1

I would like to use backup_drive command to copy disks and their snapshot in one image.

Unfortunately, each time i use the command :

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

But i get this error :

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

I tried devices i found with "domblklist" and "execute query-block"

Someone can give me an example to know whats exactly the "device" i need to put in the backup_drive command ?

i already check this post without success : QEMU cannot find device nor node_name

Thanks !

Best regards, N.B

PoPNicoW
  • 13
  • 3

1 Answers1

0

The info block monitor command will show you the block devices connected to the guest.

[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

Here, the disk device name is drive-scsi0-0-0-0. (The other block devices are virtual CDROM devices.) But what drive_backup expects is the node_name, which appears in parentheses, i.e. #block118.

It also appears you don't have the syntax quite correct. From the help:

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).

So you would do something like:

[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
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Hi Michael, Thanks a lot for the answer, "info block" is more readable than the "query block" command. But i get the same device : root@ubuntukvm05:/# virsh qemu-monitor-command VM_NAME --hmp "info block" drive-ide0-0-0 (#block12515): – PoPNicoW Aug 07 '18 at 16:02
  • @PoPNicoW I played around with it some more. Please see the edited answer. – Michael Hampton Aug 07 '18 at 16:24
  • your explanation is perfectly clear, that help me a lot in my understanding of qmp command. but i'm till getting the error device not found with #block[number]...with two different guest..but works with the device "drive-ide0-0-0" for one...so i guess my first vm is corrupted. Just one more question, does it mean we can't use same argument with JSON and with --hmp like sync (full, top, none...)? – PoPNicoW Aug 07 '18 at 16:56
  • All is good with this command : virsh qemu-monitor-command NAME-VM \ '{"execute":"drive-backup", "arguments": {"device": "drive-virtio-disk0", "sync": "full", "target": "/mnt/backupkvm/testbackupfull.qcow2" }}' {"return":{},"id":"libvirt-99"} – PoPNicoW Aug 13 '18 at 17:26