Skip to content

Commit

Permalink
memory: Name all the memory listeners
Browse files Browse the repository at this point in the history
Provide a name field for all the memory listeners.  It can be used to identify
which memory listener is which.

Signed-off-by: Peter Xu <[email protected]>
Reviewed-by: David Hildenbrand <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
xzpeter authored and bonzini committed Sep 30, 2021
1 parent 523a3d9 commit 142518b
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions accel/hvf/hvf-accel-ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ static void hvf_region_del(MemoryListener *listener,
}

static MemoryListener hvf_memory_listener = {
.name = "hvf",
.priority = 10,
.region_add = hvf_region_add,
.region_del = hvf_region_del,
Expand Down
7 changes: 5 additions & 2 deletions accel/kvm/kvm-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ static void kvm_coalesce_pio_del(MemoryListener *listener,
}

static MemoryListener kvm_coalesced_pio_listener = {
.name = "kvm-coalesced-pio",
.coalesced_io_add = kvm_coalesce_pio_add,
.coalesced_io_del = kvm_coalesce_pio_del,
};
Expand Down Expand Up @@ -1633,7 +1634,7 @@ static void kvm_io_ioeventfd_del(MemoryListener *listener,
}

void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
AddressSpace *as, int as_id)
AddressSpace *as, int as_id, const char *name)
{
int i;

Expand All @@ -1649,6 +1650,7 @@ void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
kml->listener.log_start = kvm_log_start;
kml->listener.log_stop = kvm_log_stop;
kml->listener.priority = 10;
kml->listener.name = name;

if (s->kvm_dirty_ring_size) {
kml->listener.log_sync_global = kvm_log_sync_global;
Expand All @@ -1669,6 +1671,7 @@ void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
}

static MemoryListener kvm_io_listener = {
.name = "kvm-io",
.eventfd_add = kvm_io_ioeventfd_add,
.eventfd_del = kvm_io_ioeventfd_del,
.priority = 10,
Expand Down Expand Up @@ -2579,7 +2582,7 @@ static int kvm_init(MachineState *ms)
s->memory_listener.listener.coalesced_io_del = kvm_uncoalesce_mmio_region;

kvm_memory_listener_register(s, &s->memory_listener,
&address_space_memory, 0);
&address_space_memory, 0, "kvm-memory");
if (kvm_eventfds_allowed) {
memory_listener_register(&kvm_io_listener,
&address_space_io);
Expand Down
2 changes: 2 additions & 0 deletions hw/i386/xen/xen-hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ static void xen_log_global_stop(MemoryListener *listener)
}

static MemoryListener xen_memory_listener = {
.name = "xen-memory",
.region_add = xen_region_add,
.region_del = xen_region_del,
.log_start = xen_log_start,
Expand All @@ -732,6 +733,7 @@ static MemoryListener xen_memory_listener = {
};

static MemoryListener xen_io_listener = {
.name = "xen-io",
.region_add = xen_io_add,
.region_del = xen_io_del,
.priority = 10,
Expand Down
1 change: 1 addition & 0 deletions hw/intc/openpic_kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ static void kvm_openpic_realize(DeviceState *dev, Error **errp)

opp->mem_listener.region_add = kvm_openpic_region_add;
opp->mem_listener.region_del = kvm_openpic_region_del;
opp->mem_listener.name = "openpic-kvm";
memory_listener_register(&opp->mem_listener, &address_space_memory);

/* indicate pic capabilities */
Expand Down
1 change: 1 addition & 0 deletions hw/remote/proxy-memory-listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ void proxy_memory_listener_configure(ProxyMemoryListener *proxy_listener,
proxy_listener->listener.region_add = proxy_memory_listener_region_addnop;
proxy_listener->listener.region_nop = proxy_memory_listener_region_addnop;
proxy_listener->listener.priority = 10;
proxy_listener->listener.name = "proxy";

memory_listener_register(&proxy_listener->listener,
&address_space_memory);
Expand Down
1 change: 1 addition & 0 deletions hw/vfio/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ static void vfio_listener_log_sync(MemoryListener *listener,
}

static const MemoryListener vfio_memory_listener = {
.name = "vfio",
.region_add = vfio_listener_region_add,
.region_del = vfio_listener_region_del,
.log_global_start = vfio_listener_log_global_start,
Expand Down
1 change: 1 addition & 0 deletions hw/vfio/spapr.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ static void vfio_prereg_listener_region_del(MemoryListener *listener,
}

const MemoryListener vfio_prereg_listener = {
.name = "vfio-pre-reg",
.region_add = vfio_prereg_listener_region_add,
.region_del = vfio_prereg_listener_region_del,
};
Expand Down
1 change: 1 addition & 0 deletions hw/virtio/vhost-vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
* depends on the addnop().
*/
static const MemoryListener vhost_vdpa_memory_listener = {
.name = "vhost-vdpa",
.commit = vhost_vdpa_listener_commit,
.region_add = vhost_vdpa_listener_region_add,
.region_del = vhost_vdpa_listener_region_del,
Expand Down
2 changes: 2 additions & 0 deletions hw/virtio/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
hdev->features = features;

hdev->memory_listener = (MemoryListener) {
.name = "vhost",
.begin = vhost_begin,
.commit = vhost_commit,
.region_add = vhost_region_addnop,
Expand All @@ -1381,6 +1382,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
};

hdev->iommu_listener = (MemoryListener) {
.name = "vhost-iommu",
.region_add = vhost_iommu_region_add,
.region_del = vhost_iommu_region_del,
};
Expand Down
1 change: 1 addition & 0 deletions hw/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3670,6 +3670,7 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
}

vdev->listener.commit = virtio_memory_listener_commit;
vdev->listener.name = "virtio";
memory_listener_register(&vdev->listener, vdev->dma_as);
}

Expand Down
2 changes: 2 additions & 0 deletions hw/xen/xen_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +689,14 @@ static void xen_pt_io_region_del(MemoryListener *l, MemoryRegionSection *sec)
}

static const MemoryListener xen_pt_memory_listener = {
.name = "xen-pt-mem",
.region_add = xen_pt_region_add,
.region_del = xen_pt_region_del,
.priority = 10,
};

static const MemoryListener xen_pt_io_listener = {
.name = "xen-pt-io",
.region_add = xen_pt_io_region_add,
.region_del = xen_pt_io_region_del,
.priority = 10,
Expand Down
8 changes: 8 additions & 0 deletions include/exec/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,14 @@ struct MemoryListener {
*/
unsigned priority;

/**
* @name:
*
* Name of the listener. It can be used in contexts where we'd like to
* identify one memory listener with the rest.
*/
const char *name;

/* private: */
AddressSpace *address_space;
QTAILQ_ENTRY(MemoryListener) link;
Expand Down
2 changes: 1 addition & 1 deletion include/sysemu/kvm_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ typedef struct KVMMemoryListener {
} KVMMemoryListener;

void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml,
AddressSpace *as, int as_id);
AddressSpace *as, int as_id, const char *name);

void kvm_set_max_memslot_size(hwaddr max_slot_size);

Expand Down
1 change: 1 addition & 0 deletions softmmu/physmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ void cpu_address_space_init(CPUState *cpu, int asidx,
if (tcg_enabled()) {
newas->tcg_as_listener.log_global_after_sync = tcg_log_global_after_sync;
newas->tcg_as_listener.commit = tcg_commit;
newas->tcg_as_listener.name = "tcg";
memory_listener_register(&newas->tcg_as_listener, as);
}
}
Expand Down
1 change: 1 addition & 0 deletions target/arm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ static void kvm_arm_devlistener_del(MemoryListener *listener,
}

static MemoryListener devlistener = {
.name = "kvm-arm",
.region_add = kvm_arm_devlistener_add,
.region_del = kvm_arm_devlistener_del,
};
Expand Down
1 change: 1 addition & 0 deletions target/i386/hax/hax-mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ static void hax_log_sync(MemoryListener *listener,
}

static MemoryListener hax_memory_listener = {
.name = "hax",
.begin = hax_transaction_begin,
.commit = hax_transaction_commit,
.region_add = hax_region_add,
Expand Down
2 changes: 1 addition & 1 deletion target/i386/kvm/kvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ static void register_smram_listener(Notifier *n, void *unused)

address_space_init(&smram_address_space, &smram_as_root, "KVM-SMRAM");
kvm_memory_listener_register(kvm_state, &smram_listener,
&smram_address_space, 1);
&smram_address_space, 1, "kvm-smram");
}

int kvm_arch_init(MachineState *ms, KVMState *s)
Expand Down
1 change: 1 addition & 0 deletions target/i386/nvmm/nvmm-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ nvmm_log_sync(MemoryListener *listener, MemoryRegionSection *section)
}

static MemoryListener nvmm_memory_listener = {
.name = "nvmm",
.begin = nvmm_transaction_begin,
.commit = nvmm_transaction_commit,
.region_add = nvmm_region_add,
Expand Down
1 change: 1 addition & 0 deletions target/i386/whpx/whpx-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,7 @@ static void whpx_log_sync(MemoryListener *listener,
}

static MemoryListener whpx_memory_listener = {
.name = "whpx",
.begin = whpx_transaction_begin,
.commit = whpx_transaction_commit,
.region_add = whpx_region_add,
Expand Down

0 comments on commit 142518b

Please sign in to comment.