[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v3 5/8] block: add BlockRAMRegistrar
From: |
Hanna Reitz |
Subject: |
Re: [RFC v3 5/8] block: add BlockRAMRegistrar |
Date: |
Thu, 14 Jul 2022 11:30:11 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 |
On 08.07.22 06:17, Stefan Hajnoczi wrote:
Emulated devices and other BlockBackend users wishing to take advantage
of blk_register_buf() all have the same repetitive job: register
RAMBlocks with the BlockBackend using RAMBlockNotifier.
Add a BlockRAMRegistrar API to do this. A later commit will use this
from hw/block/virtio-blk.c.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
MAINTAINERS | 1 +
include/sysemu/block-ram-registrar.h | 30 +++++++++++++++++++++
block/block-ram-registrar.c | 39 ++++++++++++++++++++++++++++
block/meson.build | 1 +
4 files changed, 71 insertions(+)
create mode 100644 include/sysemu/block-ram-registrar.h
create mode 100644 block/block-ram-registrar.c
What memory is handled in ram_list? Is it everything? If so, won’t
devices have trouble registering all those buffer, especially if they
happen to be fragmented in physical memory? (nvme_register_buf() seems
to say it can run out of slots quite easily.)
diff --git a/MAINTAINERS b/MAINTAINERS
index 50f340d9ee..d16189449f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2490,6 +2490,7 @@ F: block*
F: block/
F: hw/block/
F: include/block/
+F: include/sysemu/block-*.h
F: qemu-img*
F: docs/tools/qemu-img.rst
F: qemu-io*
Sneaky. ;)
diff --git a/include/sysemu/block-ram-registrar.h
b/include/sysemu/block-ram-registrar.h
new file mode 100644
index 0000000000..09d63f64b2
--- /dev/null
+++ b/include/sysemu/block-ram-registrar.h
@@ -0,0 +1,30 @@
+/*
+ * BlockBackend RAM Registrar
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef BLOCK_RAM_REGISTRAR_H
+#define BLOCK_RAM_REGISTRAR_H
+
+#include "exec/ramlist.h"
+
+/**
+ * struct BlockRAMRegistrar:
+ *
+ * Keeps RAMBlock memory registered with a BlockBackend using
+ * blk_register_buf() including hotplugged memory.
+ *
+ * Emulated devices or other BlockBackend users initialize a BlockRAMRegistrar
+ * with blk_ram_registrar_init() before submitting I/O requests with the
+ * BLK_REQ_REGISTERED_BUF flag set.
s/BLK/BDRV/, right?
+ */
+typedef struct {
+ BlockBackend *blk;
+ RAMBlockNotifier notifier;
+} BlockRAMRegistrar;
+
+void blk_ram_registrar_init(BlockRAMRegistrar *r, BlockBackend *blk);
+void blk_ram_registrar_destroy(BlockRAMRegistrar *r);
+
+#endif /* BLOCK_RAM_REGISTRAR_H */
- [RFC v3 0/8] blkio: add libblkio BlockDriver, Stefan Hajnoczi, 2022/07/08
- [RFC v3 2/8] numa: call ->ram_block_removed() in ram_block_notifer_remove(), Stefan Hajnoczi, 2022/07/08
- [RFC v3 1/8] blkio: add io_uring block driver using libblkio, Stefan Hajnoczi, 2022/07/08
- [RFC v3 3/8] block: pass size to bdrv_unregister_buf(), Stefan Hajnoczi, 2022/07/08
- [RFC v3 5/8] block: add BlockRAMRegistrar, Stefan Hajnoczi, 2022/07/08
- Re: [RFC v3 5/8] block: add BlockRAMRegistrar,
Hanna Reitz <=
- [RFC v3 4/8] block: add BDRV_REQ_REGISTERED_BUF request flag, Stefan Hajnoczi, 2022/07/08
- [RFC v3 8/8] virtio-blk: use BDRV_REQ_REGISTERED_BUF optimization hint, Stefan Hajnoczi, 2022/07/08
- [RFC v3 6/8] stubs: add memory_region_from_host() and memory_region_get_fd(), Stefan Hajnoczi, 2022/07/08
- [RFC v3 7/8] blkio: implement BDRV_REQ_REGISTERED_BUF optimization, Stefan Hajnoczi, 2022/07/08