From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 28/29] block: add close notifiers
Date: Fri, 19 Oct 2012 15:32:07 +0200 [thread overview]
Message-ID: <1350653528-5834-29-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1350653528-5834-1-git-send-email-pbonzini@redhat.com>
The first user of close notifiers will be the embedded NBD server.
It would be possible to use them to do some of the ad hoc processing
(e.g. for block jobs and I/O limits) that is currently done by
bdrv_close.
Acked-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
Makefile.objs | 4 ++--
block.c | 9 +++++++++
block.h | 1 +
block_int.h | 2 ++
4 file modificati, 14 inserzioni(+), 2 rimozioni(-)
diff --git a/Makefile.objs b/Makefile.objs
index 3f16d67..ca67885 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -43,7 +43,7 @@ coroutine-obj-$(CONFIG_WIN32) += coroutine-win32.o
block-obj-y = cutils.o iov.o cache-utils.o qemu-option.o module.o async.o
block-obj-y += nbd.o block.o blockjob.o aio.o aes.o qemu-config.o
-block-obj-y += qemu-progress.o qemu-sockets.o uri.o
+block-obj-y += qemu-progress.o qemu-sockets.o uri.o notify.o
block-obj-y += $(coroutine-obj-y) $(qobject-obj-y) $(version-obj-y)
block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
@@ -94,7 +94,7 @@ common-obj-y += bt-host.o bt-vhci.o
common-obj-y += dma-helpers.o
common-obj-y += iov.o acl.o
common-obj-$(CONFIG_POSIX) += compatfd.o
-common-obj-y += notify.o event_notifier.o
+common-obj-y += event_notifier.o
common-obj-y += qemu-timer.o qemu-timer-common.o
common-obj-y += qtest.o
common-obj-y += vl.o
diff --git a/block.c b/block.c
index 2e4ddea..56426a9 100644
--- a/block.c
+++ b/block.c
@@ -30,6 +30,7 @@
#include "module.h"
#include "qjson.h"
#include "sysemu.h"
+#include "notify.h"
#include "qemu-coroutine.h"
#include "qmp-commands.h"
#include "qemu-timer.h"
@@ -312,9 +313,16 @@ BlockDriverState *bdrv_new(const char *device_name)
QTAILQ_INSERT_TAIL(&bdrv_states, bs, list);
}
bdrv_iostatus_disable(bs);
+ notifier_list_init(&bs->close_notifiers);
+
return bs;
}
+void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify)
+{
+ notifier_list_add(&bs->close_notifiers, notify);
+}
+
BlockDriver *bdrv_find_format(const char *format_name)
{
BlockDriver *drv1;
@@ -1102,6 +1110,7 @@ void bdrv_close(BlockDriverState *bs)
block_job_cancel_sync(bs->job);
}
bdrv_drain_all();
+ notifier_list_notify(&bs->close_notifiers, bs);
if (bs->drv) {
if (bs == bs_snapshots) {
diff --git a/block.h b/block.h
index e2d89d7..aa608a8 100644
--- a/block.h
+++ b/block.h
@@ -144,6 +144,7 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
void bdrv_reopen_commit(BDRVReopenState *reopen_state);
void bdrv_reopen_abort(BDRVReopenState *reopen_state);
void bdrv_close(BlockDriverState *bs);
+void bdrv_add_close_notifier(BlockDriverState *bs, Notifier *notify);
int bdrv_attach_dev(BlockDriverState *bs, void *dev);
void bdrv_attach_dev_nofail(BlockDriverState *bs, void *dev);
void bdrv_detach_dev(BlockDriverState *bs, void *dev);
diff --git a/block_int.h b/block_int.h
index f4bae04..cedabbd 100644
--- a/block_int.h
+++ b/block_int.h
@@ -233,6 +233,8 @@ struct BlockDriverState {
BlockDriverState *backing_hd;
BlockDriverState *file;
+ NotifierList close_notifiers;
+
/* number of in-flight copy-on-read requests */
unsigned int copy_on_read_in_flight;
--
1.7.12.1
next prev parent reply other threads:[~2012-10-19 13:34 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-19 13:31 [Qemu-devel] [PULL 00/29] qemu-sockets error propagation + NBD server Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 01/29] error: add error_set_errno and error_setg_errno Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 02/29] qemu-sockets: add Error ** to all functions Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 03/29] qemu-sockets: unix_listen and unix_connect are portable Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 04/29] qemu-sockets: add nonblocking connect for Unix sockets Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 05/29] migration: avoid using error_is_set and thus relying on errp != NULL Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 06/29] migration: centralize call to migrate_fd_error() Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 07/29] migration: use qemu-sockets to establish Unix sockets Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 08/29] migration (outgoing): add error propagation for all protocols Paolo Bonzini
2012-10-22 15:52 ` Markus Armbruster
2012-10-23 11:27 ` Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 09/29] migration (incoming): add error propagation to fd and exec protocols Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 10/29] qemu-char: ask and print error information from qemu-sockets Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 11/29] nbd: " Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 12/29] qemu-ga: " Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 13/29] vnc: avoid Yoda conditionals Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 14/29] vnc: introduce a single label for error returns Paolo Bonzini
2012-10-22 15:49 ` Markus Armbruster
2012-10-23 11:32 ` Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 15/29] vnc: reorganize code for reverse mode Paolo Bonzini
2012-10-22 15:39 ` Markus Armbruster
2012-10-19 13:31 ` [Qemu-devel] [PATCH 16/29] vnc: add error propagation to vnc_display_open Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 17/29] qemu-sockets: include strerror or gai_strerror output in error messages Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 18/29] qemu-sockets: add error propagation to inet_connect_addr Paolo Bonzini
2012-10-22 15:53 ` Markus Armbruster
2012-10-19 13:31 ` [Qemu-devel] [PATCH 19/29] qemu-sockets: add error propagation to inet_dgram_opts Paolo Bonzini
2012-10-19 13:31 ` [Qemu-devel] [PATCH 20/29] qemu-sockets: add error propagation to inet_parse Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 21/29] qemu-sockets: add error propagation to Unix socket functions Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 22/29] vnc: drop QERR_VNC_SERVER_FAILED Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 23/29] build: add QAPI files to the tools Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 24/29] qapi: add socket address types Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 25/29] qemu-sockets: return InetSocketAddress from inet_parse Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 26/29] qemu-sockets: add socket_listen, socket_connect, socket_parse Paolo Bonzini
2012-10-19 13:32 ` [Qemu-devel] [PATCH 27/29] block: prepare code for adding block notifiers Paolo Bonzini
2012-10-19 13:32 ` Paolo Bonzini [this message]
2012-10-19 13:32 ` [Qemu-devel] [PATCH 29/29] qmp: add NBD server commands Paolo Bonzini
2012-10-22 15:59 ` [Qemu-devel] [PULL 00/29] qemu-sockets error propagation + NBD server Markus Armbruster
2012-10-22 19:53 ` Anthony Liguori
2012-10-23 12:34 ` Paolo Bonzini
2012-10-23 15:27 ` Paolo Bonzini
2012-10-23 21:24 ` Paolo Bonzini
2012-10-26 15:33 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350653528-5834-29-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).