From 91b7eb29b68708802ed260592c1aa8205b6d7cc1 Mon Sep 17 00:00:00 2001 From: Uri Lublin <uril@redhat.com> Date: Tue, 7 Apr 2009 16:26:01 +0300 Subject: [PATCH 02/11] block_set_watermark: use term_printf_async for notifications. Those notifications are asynchronous. The user needs to enable watermark-notifications using "notify" monitor command. https://bugzilla.redhat.com/show_bug.cgi?id=494170 Also fixed a typo: Noticed-by: john cooper <john.cooper@redhat.com> Signed-off-by: Uri Lublin <uril@redhat.com> Message-Id: <1239110761-15858-3-git-send-email-uril@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com RH-Upstream-status: pending Acked-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: john cooper <john.cooper@redhat.com> Acked-by: Zachary Amsden <zamsden@redhat.com> Bugzilla: 497886 --- qemu/block-qcow2.c | 8 +++++--- qemu/console.h | 3 ++- qemu/monitor.c | 9 ++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 41750ed..35d17e3 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -26,6 +26,7 @@ #include <zlib.h> #include "aes.h" #include <assert.h> +#include "console.h" /* Differences with QCOW: @@ -2381,9 +2382,10 @@ retry: if (bs->high_watermark) { uint64_t ha = (s->highest_alloc << s->cluster_bits); if (ha >= bs->high_watermark) { - term_printf("high watermark reached for %s alloc=%" PRIu64 - " mark=%" PRIu64 "\n", - bs->device_name, ha, bs->high_watermark); + term_printf_async(WATERMARK_ASYNC_EVENT, + "high watermark reached for %s alloc=%" + PRIu64 " mark=%" PRIu64 "\n", + bs->device_name, ha, bs->high_watermark); bs->high_watermark = 0; } } diff --git a/qemu/console.h b/qemu/console.h index 034e459..b802779 100644 --- a/qemu/console.h +++ b/qemu/console.h @@ -194,7 +194,8 @@ extern uint8_t _translate_keycode(const int key); #define MIGRATION_ASYNC_EVENT 4 #define REBOOT_ASYNC_EVENT 5 #define VMSTOP_ASYNC_EVENT 6 -#define MAX_ASYNC_EVENT VMSTOP_ASYNC_EVENT +#define WATERMARK_ASYNC_EVENT 7 +#define MAX_ASYNC_EVENT WATERMARK_ASYNC_EVENT /* FIXME: term_printf et al should probably go elsewhere so everything does not need to include console.h */ diff --git a/qemu/monitor.c b/qemu/monitor.c index d8296ab..35e8cda 100644 --- a/qemu/monitor.c +++ b/qemu/monitor.c @@ -259,6 +259,8 @@ static void do_notify_async_events(char *event_str, char *enable) event = REBOOT_ASYNC_EVENT; else if (!strcmp(event_str, "vmstop")) event = VMSTOP_ASYNC_EVENT; + else if (!strcmp(event_str, "watermark")) + event = WATERMARK_ASYNC_EVENT; else return; @@ -607,7 +609,7 @@ void do_block_set_watermark(char *device, int megs) } if (megs < 0) - term_printf("ileggal offset\n"); + term_printf("illegal offset\n"); else bdrv_set_high_watermark(bs, offset); } @@ -1640,10 +1642,11 @@ static term_cmd_t term_cmds[] = { { "set_qxl_log_level", "i", qxl_do_set_log_level, "", "set qxl log level" }, #endif { "notify", "ss", do_notify_async_events, - "vnc|rtc|migration|reboot|shutdown|vmstop on|off", "enable / disable printing of notifications for the specified event" }, + "vnc|rtc|migration|reboot|shutdown|vmstop|watermark on|off", + "enable / disable printing of notifications for the specified event" }, { "block_set_watermark", "Bi", do_block_set_watermark, "block-device offset(in MB)", - "set watermark, get notification when reached"}, + "set watermark, get notification when reached (set 0 to disable)"}, { NULL, NULL, }, }; -- 1.6.1