Bug 1807741 - RFE: Allow monitoring the block threshold for the mirror destination image
Summary: RFE: Allow monitoring the block threshold for the mirror destination image
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.2
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.0
Assignee: Peter Krempa
QA Contact: Han Han
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-27 05:59 UTC by Peter Krempa
Modified: 2020-11-17 17:47 UTC (History)
8 users (show)

Fixed In Version: libvirt-6.6.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-11-17 17:46:46 UTC
Type: Feature Request
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Peter Krempa 2020-02-27 05:59:12 UTC
Description of problem:
oVirt would like to use the virDomainBlockThreshold API or similar to also monitor the filling threshold of the destination of the virDomainBlockCopy job.

It should be possible to achieve this with -blockdev as we have a unique index for the mirror image, so we can use the original event.

Comment 1 Peter Krempa 2020-07-21 09:36:06 UTC
Fixed upstream by:

commit 5c52c186fdaaae3e47a6516daabf66ef31fc1bf9
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 12:51:40 2020 +0200

    qemuDomainGetStorageSourceByDevstr: Look also in 'mirror' chain
    
    A disk can have a mirror, look also in its backing chain.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit 41c6939660d38597bda0475eacccd3980607ac17
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 12:36:50 2020 +0200

    qemuDomainDiskLookupByNodename: Look also for 'mirror' node names
    
    When doing a block copy, there is another chain of images attached to a
    disk. Consider them as well when looking up a disk using nodename.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit fd2369d02654c20c4a262407c563b0f5c7c31d68
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 12:33:34 2020 +0200

    virStorageSourceFindByNodeName: Remove unused 'idx' argument
    
    None of the callers actually use it.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit db712b0673db2afd39ab11d660657b6a1240b2db
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 12:29:34 2020 +0200

    qemuDomainDiskLookupByNodename: Remove unused 'idx'
    
    All callers pass NULL as the value. Remove the argument.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit 877d705ccf9e515a7506a2d326227251c4e272c7
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 13:06:44 2020 +0200

    virDomainSetBlockThreshold: Clarify values of @dev the event is fired for
    
    Top level image may get two events, one with the disk target (vda) and
    one with disk target with index (vda[3]) if the top level image has an
    index.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit c414ab00e288535596010d7cc4174d6e40328408
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 11:51:17 2020 +0200

    qemuProcessHandleBlockThreshold: Report correct indexes
    
    The index returned by qemuDomainDiskLookupByNodename is the position in
    the backing chain rather than the index we report in the XML.
    
    Since with -blockdev they differ now and additionally the disk source
    also has an index we need to fix the 'threshold' events we report:
    
    1) If it's the top level image we must always trigger the event without
       any suffix as we did until now
    
    2) We must report the correct index
    
    3) We must report the correct index also for the top level image, when
       blockdev is used.
    
    This means that we need to potentially emit 2 events, one for the device
    without the index and then when blockdev is used and the top level image
    has an index we must do it also with the index.
    
    This will fix it for blockdev cases, while also not removing previous
    semantics.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1857204
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit 48b7c33cc7fb46af398b7e0aa3d50f05d2f1321b
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 12:01:39 2020 +0200

    qemuDomainDiskBackingStoreGetName: Eliminate temp variable
    
    We can return the formatted string directly.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit 4a19b7b83251f2f6e02561ad58374617ac2e7e3e
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 12:19:35 2020 +0200

    qemuDomainDiskBackingStoreGetName: Remove unused argument
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

commit 794d7d97d8d98179b2e90baca9cf56b232f65e99
Author: Peter Krempa <pkrempa>
Date:   Wed Jul 15 13:02:24 2020 +0200

    virDomainSetBlockThreshold: Document values of '@dev' better
    
    Mention where to obtain the index and how it's treated.
    
    Signed-off-by: Peter Krempa <pkrempa>
    Reviewed-by: Eric Blake <eblake>

Comment 2 Han Han 2020-07-23 10:49:12 UTC
Test on v6.5.0-284-g6c7ba7b496 qemu-kvm-5.0.0-2.module+el8.3.0+7379+0505d6ca.x86_64:

A. Test mirroring of blockcommit:
1. Start a VM and create external snapshot
# virsh snapshot-create-as new --disk-only --no-metadata

2. Do blockcommit
# virsh blockcommit new vda --active

3. Check disk xml and set threshold:
➜  ~ virsh dumpxml 7|xmllint --xpath //disk -
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/new.1595496853" index="29"/>                                                              
      <backingStore type="file" index="1">
        <format type="qcow2"/>
        <source file="/var/lib/libvirt/images/new.qcow2"/>
        <backingStore/>
      </backingStore>
      <mirror type="file" job="active-commit" ready="yes">
        <format type="qcow2"/>
        <source file="/var/lib/libvirt/images/new.qcow2" index="1"/>
      </mirror>
      <target dev="vda" bus="virtio"/>
      <alias name="virtio-disk0"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x09" function="0x0"/>
    </disk>

➜  ~ virsh domblkthreshold new 'vda[1]' 1048576

4. Start a new console to check the events. Do some write in guest
➜  ~ virsh event --loop --all


➜  ~ ssh root.122.186 dd if=/dev/urandom of=file bs=1G count=3

Event:
event 'block-threshold' for domain new: dev: vda[1](/var/lib/libvirt/images/new.qcow2) 1048576 1465384960


B. Test mirroring of blockcopy:
1. Start an VM and do blockcopy:
➜  ~ virsh blockcopy new vda /var/lib/libvirt/images/new-clone1 --transient-job

2. Check the disk xml. Set the threshold for mirroring
➜  ~ virsh dumpxml 7|xmllint --xpath //disk -                                  
<disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/new.qcow2" index="1"/>
      <backingStore/>
      <mirror type="file" file="/var/lib/libvirt/images/new-clone1" format="qcow2" job="copy" ready="yes">
        <format type="qcow2"/>
        <source file="/var/lib/libvirt/images/new-clone1" index="30"/>
        <backingStore/>
      </mirror>
      <target dev="vda" bus="virtio"/>
      <alias name="virtio-disk0"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x09" function="0x0"/>
    </disk>

➜  ~ virsh domblkthreshold new 'vda[30]' 1048576

3. Open another console to check the event and then do some write to VM
➜  ~ virsh event --loop --all
➜  ~ ssh root.122.186 dd if=/dev/urandom of=file bs=1G count=3

Event:
event 'block-threshold' for domain new: dev: vda[30](/var/lib/libvirt/images/new-clone1) 1048576 131969843



All in all, it works.

Comment 10 Han Han 2020-10-09 10:29:19 UTC
It works as comment2 at libvirt-6.6.0-6.module+el8.3.0+8125+aefcf088.x86_64 qemu-kvm-5.1.0-13.module+el8.3.0+8382+afc3bbea.x86_64

Comment 12 errata-xmlrpc 2020-11-17 17:46:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:8.3 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:5137


Note You need to log in before you can comment on or make changes to this bug.