Browse Source
-----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmNZg14ACgkQnKSrs4Gr c8hwwwf/Udbnt6n4SShezEIYRe0udLvuyo1HwcMNLWjllHLfp/yNDcPsGk+r13Ue TxrvbVaucxB5RPdN67KmzPyu+wPM/o0nij7c4CkBvwNPXmfUCF97Lj0prEL+ZeHp HmNg08FRfHM2vKMFyJXqDAidBecUDizLrP9C3nc/LAF6fr9ds+vfFuB/12eSXvZ+ RLnaAj7KLt2MzkgWbDiC6066TPZWCcwFJmc0zkCAthCepokDrKfSHc+0u9U/NXA9 Qv7qKcEBYq3vP3SCvDtbKU3Ig4CoiwO3A3O9wZTypamU2816H9HtEJ5NPtjNUFPF dm3siyKODbDx4mzba/Xv/26lHGSsJA== =bmGV -----END PGP SIGNATURE----- Merge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging Pull request # -----BEGIN PGP SIGNATURE----- # # iQEzBAABCAAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmNZg14ACgkQnKSrs4Gr # c8hwwwf/Udbnt6n4SShezEIYRe0udLvuyo1HwcMNLWjllHLfp/yNDcPsGk+r13Ue # TxrvbVaucxB5RPdN67KmzPyu+wPM/o0nij7c4CkBvwNPXmfUCF97Lj0prEL+ZeHp # HmNg08FRfHM2vKMFyJXqDAidBecUDizLrP9C3nc/LAF6fr9ds+vfFuB/12eSXvZ+ # RLnaAj7KLt2MzkgWbDiC6066TPZWCcwFJmc0zkCAthCepokDrKfSHc+0u9U/NXA9 # Qv7qKcEBYq3vP3SCvDtbKU3Ig4CoiwO3A3O9wZTypamU2816H9HtEJ5NPtjNUFPF # dm3siyKODbDx4mzba/Xv/26lHGSsJA== # =bmGV # -----END PGP SIGNATURE----- # gpg: Signature made Wed 26 Oct 2022 14:58:38 EDT # gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [ultimate] # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [ultimate] # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * tag 'block-pull-request' of https://gitlab.com/stefanha/qemu: virtio-blk: use BDRV_REQ_REGISTERED_BUF optimization hint blkio: implement BDRV_REQ_REGISTERED_BUF optimization stubs: add qemu_ram_block_from_host() and qemu_ram_get_fd() exec/cpu-common: add qemu_ram_get_fd() block: add BlockRAMRegistrar numa: use QLIST_FOREACH_SAFE() for RAM block notifiers block: return errors from bdrv_register_buf() block: add BDRV_REQ_REGISTERED_BUF request flag block: use BdrvRequestFlags type for supported flag fields block: pass size to bdrv_unregister_buf() numa: call ->ram_block_removed() in ram_block_notifer_remove() blkio: add libblkio block driver coroutine: add flag to re-queue at front of CoQueue Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>pull/225/head
42 changed files with 1435 additions and 96 deletions
File diff suppressed because it is too large
@ -0,0 +1,58 @@ |
|||
/*
|
|||
* BlockBackend RAM Registrar |
|||
* |
|||
* SPDX-License-Identifier: GPL-2.0-or-later |
|||
*/ |
|||
|
|||
#include "qemu/osdep.h" |
|||
#include "sysemu/block-backend.h" |
|||
#include "sysemu/block-ram-registrar.h" |
|||
#include "qapi/error.h" |
|||
|
|||
static void ram_block_added(RAMBlockNotifier *n, void *host, size_t size, |
|||
size_t max_size) |
|||
{ |
|||
BlockRAMRegistrar *r = container_of(n, BlockRAMRegistrar, notifier); |
|||
Error *err = NULL; |
|||
|
|||
if (!r->ok) { |
|||
return; /* don't try again if we've already failed */ |
|||
} |
|||
|
|||
if (!blk_register_buf(r->blk, host, max_size, &err)) { |
|||
error_report_err(err); |
|||
ram_block_notifier_remove(&r->notifier); |
|||
r->ok = false; |
|||
} |
|||
} |
|||
|
|||
static void ram_block_removed(RAMBlockNotifier *n, void *host, size_t size, |
|||
size_t max_size) |
|||
{ |
|||
BlockRAMRegistrar *r = container_of(n, BlockRAMRegistrar, notifier); |
|||
blk_unregister_buf(r->blk, host, max_size); |
|||
} |
|||
|
|||
void blk_ram_registrar_init(BlockRAMRegistrar *r, BlockBackend *blk) |
|||
{ |
|||
r->blk = blk; |
|||
r->notifier = (RAMBlockNotifier){ |
|||
.ram_block_added = ram_block_added, |
|||
.ram_block_removed = ram_block_removed, |
|||
|
|||
/*
|
|||
* .ram_block_resized() is not necessary because we use the max_size |
|||
* value that does not change across resize. |
|||
*/ |
|||
}; |
|||
r->ok = true; |
|||
|
|||
ram_block_notifier_add(&r->notifier); |
|||
} |
|||
|
|||
void blk_ram_registrar_destroy(BlockRAMRegistrar *r) |
|||
{ |
|||
if (r->ok) { |
|||
ram_block_notifier_remove(&r->notifier); |
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
/*
|
|||
* 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 |
|||
* BDRV_REQ_REGISTERED_BUF flag set. |
|||
*/ |
|||
typedef struct { |
|||
BlockBackend *blk; |
|||
RAMBlockNotifier notifier; |
|||
bool ok; |
|||
} BlockRAMRegistrar; |
|||
|
|||
void blk_ram_registrar_init(BlockRAMRegistrar *r, BlockBackend *blk); |
|||
void blk_ram_registrar_destroy(BlockRAMRegistrar *r); |
|||
|
|||
/* Have all RAMBlocks been registered successfully? */ |
|||
static inline bool blk_ram_registrar_ok(BlockRAMRegistrar *r) |
|||
{ |
|||
return r->ok; |
|||
} |
|||
|
|||
#endif /* BLOCK_RAM_REGISTRAR_H */ |
|||
@ -0,0 +1,13 @@ |
|||
#include "qemu/osdep.h" |
|||
#include "exec/cpu-common.h" |
|||
|
|||
RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, |
|||
ram_addr_t *offset) |
|||
{ |
|||
return NULL; |
|||
} |
|||
|
|||
int qemu_ram_get_fd(RAMBlock *rb) |
|||
{ |
|||
return -1; |
|||
} |
|||
Loading…
Reference in new issue