qed: replace vm_clock with rt_clock for qemu-tool compatibility
PATCH 1/1 qed: replace vm_clock with rt_clock for qemu-tool compatibility
The QED dirty bit timer marks the file clean after allocating writes have drained. This is cheaper than clearing/setting the dirty bit on each allocating write because the timer introduces a grace period which can be extended if more allocating writes arrive.
The vm_clock was used in an attempt to prevent modifying the image file when live migration has stopped the VM. Unfortunately vm_clock is unavailable in the qemu-tool environment and will abort(3)!
Since QED currently does not support live migration, just replace vm_clock with rt_clock and add comments explaining the migration blocker.
---
Zhi Yong: This patch is needed in addition to the qemu_init_main_loop() patches you sent recently. Without this patch QED may read the vm_clock, which calls abort(3) in qemu-tool.c. Together, our patches make QED work again in qemu-img and qemu-io.
block/qed.c | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-)
block/qed.c +11 -5
@@ -353,10 +353,7 @@ static void qed_start_need_check_timer(BDRVQEDState *s) {trace_qed_start_need_check_timer (s); -/* Use vm_clock so we don't alter the image file while suspended for -* migration. -*/ -qemu_mod_timer (s->need_check_timer,qemu_get_clock_ns (vm_clock) + +qemu_mod_timer (s->need_check_timer,qemu_get_clock_ns (rt_clock) +get_ticks_per_sec () *QED_NEED_CHECK_TIMEOUT ); }
@@ -494,9 +491,18 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags) } } - s->need_check_timer =qemu_new_timer_ns (vm_clock, + s->need_check_timer =qemu_new_timer_ns (rt_clock, qed_need_check_timer_cb, s); +/* There are two issues with live migration: +* +* 1. The destination will open the image file and see the dirty bit is +* set, causing it to "repair" the image while the source still has it +* open for writing. +* +* 2. The timer used for clearing the dirty bit uses rt_clock and can in +* theory fire when the VM is not running during migration. +*/ error_set (&s->migration_blocker,QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED ,"qed" , bs->device_name,"live migration" );
Signature · 1 line
1.7.9
Quoted 13 lines · Stefan Hajnoczi
The QED dirty bit timer marks the file clean after allocating writes have drained. This is cheaper than clearing/setting the dirty bit on each allocating write because the timer introduces a grace period which can be extended if more allocating writes arrive.
The
vm_clockwas used in an attempt to prevent modifying the image file when live migration has stopped the VM. Unfortunatelyvm_clockis unavailable in the qemu-tool environment and will abort(3)!Since QED currently does not support live migration, just replace
vm_clockwithrt_clockand add comments explaining the migration blocker.
Quoted 5 lines
Signed-off-by Stefan Hajnoczi <[email protected]>---
Zhi Yong: This patch is needed in addition to theqemu_init_main_loop()patches you sent recently. Without this patch QED may read thevm_clock, which calls abort(3) inqemu-tool.c. Together, our patches make QED work again in qemu-img
Since vm_clock is created via qemu_init_main_loop(), when QED read vm_clock, why will this call abort()?
Can you elaborate this? what is its call path?
Quoted 45 lines
and qemu-io.
block/qed.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)block/qed.c +11
-6@@ -353,10 +353,7 @@ static void qed_start_need_check_timer(BDRVQEDState *s) { trace_qed_start_need_check_timer(s); - /* Use vm_clock so we don't alter the image file while suspended for - * migration. - */ - qemu_mod_timer(s->need_check_timer, qemu_get_clock_ns(vm_clock) + + qemu_mod_timer(s->need_check_timer, qemu_get_clock_ns(rt_clock) + get_ticks_per_sec() * QED_NEED_CHECK_TIMEOUT); }@@ -494,9 +491,18 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags) } } - s->need_check_timer = qemu_new_timer_ns(vm_clock, + s->need_check_timer = qemu_new_timer_ns(rt_clock, qed_need_check_timer_cb, s); + /* There are two issues with live migration: + * + * 1. The destination will open the image file and see the dirty bit is + * set, causing it to "repair" the image while the source still has it + * open for writing. + * + * 2. The timer used for clearing the dirty bit uses rt_clock and can in + * theory fire when the VM is not running during migration. + */ error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "qed", bs->device_name, "live migration"); --1.7.9
Signature · 3 lines
Regards, Zhi Yong Wu
Quoted 4 lines · Zhi Yong Wu
Since
vm_clockis created viaqemu_init_main_loop(), when QED readvm_clock, why will this callabort()?
Can you elaborate this? what is its call path?
It will crash in cpu_get_clock() (in qemu-tool.c).
Paolo
Quoted 7 lines · Paolo Bonzini
Quoted 4 lines · Zhi Yong Wu
Since
vm_clockis created viaqemu_init_main_loop(), when QED readvm_clock, why will this callabort()?
Can you elaborate this? what is its call path?It will crash in
cpu_get_clock()(inqemu-tool.c).
nice, got it. thanks.
Quoted 2 lines
Paolo
Signature · 3 lines
Regards, Zhi Yong Wu
Am 27.02.2012 09:42, schrieb Paolo Bonzini:
Quoted 7 lines · Zhi Yong Wu
Quoted 4 lines
Since
vm_clockis created viaqemu_init_main_loop(), when QED readvm_clock, why will this callabort()?
Can you elaborate this? what is its call path?It will crash in
cpu_get_clock()(inqemu-tool.c).
The fix isn't very nice if it makes migration impossible. I'd like to introduce a similar timer in qcow2 which does support migration and breaking it is not an option. So what about (completely untested)...
qemu-tool.c +0 -0
@@ -61,7 +61,7 @@ void monitor_protocol_event(MonitorEvent event,
QObject *data)
int64_t cpu_get_clock(void)
{
- abort();
+ return 0;
}
int64_t cpu_get_icount(void)
Kevin
Quoted 18 lines · Kevin Wolf
Am 27.02.2012 09:42, schrieb Paolo Bonzini:
Quoted 7 lines · Zhi Yong Wu
Quoted 4 lines
Since
vm_clockis created viaqemu_init_main_loop(), when QED readvm_clock, why will this callabort()?
Can you elaborate this? what is its call path?It will crash in
cpu_get_clock()(inqemu-tool.c).The fix isn't very nice if it makes migration impossible. I'd like to introduce a similar timer in qcow2 which does support migration and breaking it is not an option. So what about (completely untested)...
qemu-tool.c +0
-0
qemu-tool.c void monitor_protocol_event(MonitorEvent event, · line 66
Quoted 7 lines
qemu-tool.c +1
-1@@ -61,7 +61,7 @@ void monitor_protocol_event(MonitorEvent event, QObject *data) int64_t cpu_get_clock(void) { - abort(); + return 0; }
This is what we used to do, I'm okay with it.
Stefan
Quoted 6 lines · Stefan Hajnoczi
The QED dirty bit timer marks the file clean after allocating writes have drained. This is cheaper than clearing/setting the dirty bit on each allocating write because the timer introduces a grace period which can be extended if more allocating writes arrive.
The
vm_clockwas used in an attempt to prevent modifying the image file
Why can vm_clock do this work but other clock can not? If you're available, can you elaborate what the difference among the three clocks is? such as vm_clock, rt_clock, and host_clock.
Quoted 57 lines
when live migration has stopped the VM. Unfortunately
vm_clockis unavailable in the qemu-tool environment and will abort(3)!Since QED currently does not support live migration, just replace
vm_clockwithrt_clockand add comments explaining the migration blocker.Signed-off-by Stefan Hajnoczi <[email protected]>---
Zhi Yong: This patch is needed in addition to theqemu_init_main_loop()patches you sent recently. Without this patch QED may read thevm_clock, which calls abort(3) inqemu-tool.c. Together, our patches make QED work again in qemu-img and qemu-io.block/qed.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)block/qed.c +11
-6@@ -353,10 +353,7 @@ static void qed_start_need_check_timer(BDRVQEDState *s) { trace_qed_start_need_check_timer(s); - /* Use vm_clock so we don't alter the image file while suspended for - * migration. - */ - qemu_mod_timer(s->need_check_timer, qemu_get_clock_ns(vm_clock) + + qemu_mod_timer(s->need_check_timer, qemu_get_clock_ns(rt_clock) + get_ticks_per_sec() * QED_NEED_CHECK_TIMEOUT); }@@ -494,9 +491,18 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags) } } - s->need_check_timer = qemu_new_timer_ns(vm_clock, + s->need_check_timer = qemu_new_timer_ns(rt_clock, qed_need_check_timer_cb, s); + /* There are two issues with live migration: + * + * 1. The destination will open the image file and see the dirty bit is + * set, causing it to "repair" the image while the source still has it + * open for writing. + * + * 2. The timer used for clearing the dirty bit uses rt_clock and can in + * theory fire when the VM is not running during migration. + */ error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "qed", bs->device_name, "live migration"); --1.7.9
Signature · 3 lines
Regards, Zhi Yong Wu
Quoted 11 lines · Zhi Yong Wu
Quoted 6 lines · Stefan Hajnoczi
The QED dirty bit timer marks the file clean after allocating writes have drained. This is cheaper than clearing/setting the dirty bit on each allocating write because the timer introduces a grace period which can be extended if more allocating writes arrive.
The
vm_clockwas used in an attempt to prevent modifying the image fileWhy can
vm_clockdo this work but other clock can not? If you're available, can you elaborate what the difference among the three clocks is? such asvm_clock,rt_clock, andhost_clock.
See qemu-timer.h.
Stefan
Quoted 8 lines · Stefan Hajnoczi
Quoted 7 lines · Zhi Yong Wu
Quoted 5 lines · Stefan Hajnoczi
The QED dirty bit timer marks the file clean after allocating writes have drained. This is cheaper than clearing/setting the dirty bit on each allocating write because the timer introduces a grace period which can be extended if more allocating writes arrive.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
The
vm_clockwas used in an attempt to prevent modifying the image fileWhy can
vm_clockdo this work but other clock can not? If you're available, can you elaborate what the difference among the three clocks is? such asvm_clock,rt_clock, andhost_clock.See
qemu-timer.h.
thanks
Quoted 2 lines
Stefan
Signature · 3 lines
Regards, Zhi Yong Wu