Re: After blockcopy with pivot, a dirty-bitmap is added, but not been removed automatically.

2021-05-13 Thread Peter Krempa
On Thu, May 13, 2021 at 13:55:22 +0800, ChangLimin wrote:
> >On Mon, May 10, 2021 at 13:34:41 +0800, ChangLimin wrote:
> >> Hi Peter,
> >>
> >> Since 
> >> https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=7bfff40fdfe5410c446c1cd8ec413e00530faf7d,
> >> after blockcopy with pivot, a dirty-bitmap is added, but not been removed 
> >> automatically.
> >> Is that something wrong?
> >
> >Yeah, it's a bug and it should be removed. I'll have a look.
> > 
> 
> Can this patch fix the bug? 
> 
> diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
> index faf9a9fb7d..15dabe2c23 100644
> --- a/src/qemu/qemu_blockjob.c
> +++ b/src/qemu/qemu_blockjob.c
> @@ -1338,7 +1338,8 @@ 
> qemuBlockJobProcessEventCompletedCopyBitmaps(virDomainObj *vm,
>      g_autoptr(virJSONValue) actions = NULL;
>      bool shallow = job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW;
> 
> -    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
> +    if (job->disk->src->readonly &&

No. The problem is that the bitmap shouldn't be added in the first
place if we are not invoking code to delete it.

> +        !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
>          return 0;
> 



Re: After blockcopy with pivot, a dirty-bitmap is added, but not been removed automatically.

2021-05-12 Thread ChangLimin
>On Mon, May 10, 2021 at 13:34:41 +0800, ChangLimin wrote:
>> Hi Peter,
>>
>> Since 
>> https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=7bfff40fdfe5410c446c1cd8ec413e00530faf7d,
>> after blockcopy with pivot, a dirty-bitmap is added, but not been removed 
>> automatically.
>> Is that something wrong?
>
>Yeah, it's a bug and it should be removed. I'll have a look.
> 

Can this patch fix the bug? 

diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c
index faf9a9fb7d..15dabe2c23 100644
--- a/src/qemu/qemu_blockjob.c
+++ b/src/qemu/qemu_blockjob.c
@@ -1338,7 +1338,8 @@ qemuBlockJobProcessEventCompletedCopyBitmaps(virDomainObj 
*vm,
     g_autoptr(virJSONValue) actions = NULL;
     bool shallow = job->jobflags & VIR_DOMAIN_BLOCK_COPY_SHALLOW;

-    if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
+    if (job->disk->src->readonly &&
+        !virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN))
         return 0;




After blockcopy with pivot, a dirty-bitmap is added, but not been removed automatically.

2021-05-10 Thread ChangLimin
Hi Peter,

Since 
https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=7bfff40fdfe5410c446c1cd8ec413e00530faf7d,
 
after blockcopy with pivot, a dirty-bitmap is added, but not been removed 
automatically.
Is that something wrong?

0. start a vm, and switch on some traces
# virsh start cirros
# virsh qemu-monitor-command cirros --hmp "trace-event handle_qmp* on"
# virsh qemu-monitor-command cirros --hmp "trace-event hbitmap* on"

1. cirros0.img is opened.
# virsh domblklist cirros
 Target   Source

 vda  /vms/images1/cirros0.img

2. blockcopy and pivot to cirros1.img
# virsh blockcopy cirros vda --dest /vms/images1/cirros1.img --pivot 
--transient-job
Successfully pivoted

3. cirros1.img is opened
# virsh domblklist cirros
 Target   Source

 vda  /vms/images1/cirros1.img

4. From qemu log, a dirty-bitmap is added @1620475221.389151

77998@1620475125.281656:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"human-monitor-command", "arguments": {"command-line": "trace-event qmp_job* 
on"}, "id": "libvirt-380"}
77998@1620475125.299950:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"human-monitor-command", "arguments": {"command-line": "trace-event mirror* 
on"}, "id": "libvirt-381"}
77998@1620475125.317931:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"human-monitor-command", "arguments": {"command-line": "trace-event hbitmap* 
on"}, "id": "libvirt-382"}
77998@1620475217.640133:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"query-named-block-nodes", "arguments": {"flat": true}, "id": "libvirt-383"}
77998@1620475217.642025:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"blockdev-add", "arguments": {"node-name": "libvirt-2-storage", "driver": 
"file", "filename": "/vms/images1/cirros1.img", "auto-read-only": true, "aio": 
"native", "cache": {"no-flush": false, "direct": true}, "discard": "unmap"}, 
"id": "libvirt-384"}
77998@1620475217.643434:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"blockdev-create", "arguments": {"job-id": "create-libvirt-2-format", 
"options": {"driver": "qcow2", "cluster-size": 65536, "size": 46137344, "file": 
"libvirt-2-storage"}}, "id": "libvirt-385"}
77998@1620475217.827378:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"query-jobs", "id": "libvirt-386"}
77998@1620475217.827980:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"job-dismiss", "arguments": {"id": "create-libvirt-2-format"}, "id": 
"libvirt-387"}
77998@1620475217.850802:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"blockdev-add", "arguments": {"backing": null, "node-name": "libvirt-2-format", 
"driver": "qcow2", "read-only": false, "cache": {"no-flush": false, "direct": 
true}, "file": "libvirt-2-storage"}, "id": "libvirt-388"}
77998@1620475217.853157:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"blockdev-mirror", "arguments": {"auto-finalize": true, "device": 
"libvirt-1-format", "auto-dismiss": false, "sync": "full", "job-id": 
"copy-vda-libvirt-1-format", "target": "libvirt-2-format"}, "id": "libvirt-389"}
77998@1620475217.871674:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"query-block-jobs", "id": "libvirt-390"}
77998@1620475221.387625:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"query-block-jobs", "id": "libvirt-396"}
77998@1620475221.389151:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"transaction", "arguments": {"actions": [{"type": "block-dirty-bitmap-add", 
"data": {"name": "libvirt-tmp-activewrite", "persistent": false, "node": 
"libvirt-2-format", "disabled": false}}]}, "id": "libvirt-397"}
77998@1620475221.389755:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"job-complete", "arguments": {"id": "copy-vda-libvirt-1-format"}, "id": 
"libvirt-398"}
77998@1620475221.391321:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"query-jobs", "id": "libvirt-399"}
77998@1620475221.391926:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"job-dismiss", "arguments": {"id": "copy-vda-libvirt-1-format"}, "id": 
"libvirt-400"}
77998@1620475221.393052:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"blockdev-del", "arguments": {"node-name": "libvirt-1-format"}, "id": 
"libvirt-401"}
77998@1620475221.393702:handle_qmp_command mon 0x55ebd4b176b0 req: {"execute": 
"blockdev-del", "arguments": {"node-name": "libvirt-1-storage"}, "id": 
"libvirt-402"}
Also there are many hbitmap_xx events.

5. I have debuged the source, in qemuBlockJobProcessEventCompletedCopyBitmaps , 
QEMU_CAPS_BLOCKDEV_REOPEN cap is not supported unti the latest qemu. 
So the bitmap is not removed. Is the QEMU_CAPS_BLOCKDEV_REOPEN cap be must?

Regards,
Chang Limin


Re: After blockcopy with pivot, a dirty-bitmap is added, but not been removed automatically.

2021-05-10 Thread Peter Krempa
On Mon, May 10, 2021 at 13:34:41 +0800, ChangLimin wrote:
> Hi Peter,
> 
> Since 
> https://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=7bfff40fdfe5410c446c1cd8ec413e00530faf7d,
>  
> after blockcopy with pivot, a dirty-bitmap is added, but not been removed 
> automatically.
> Is that something wrong?

Yeah, it's a bug and it should be removed. I'll have a look.