hw/virtio/vhost-user: make compilation unit common
PPC architectures use a custom value for VHOST_USER_MAX_RAM_SLOTS (32 instead of 512). vhost_user struct and several functions use VHOST_USER_MAX_RAM_SLOTS to define stack allocated buffers. To avoid changing all functions to use heap allocated buffers, we keep this max, and simply add a target_base_ppc() conditional for the single place where size really matters. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Link: https://lore.kernel.org/qemu-devel/20260225041948.52929-5-philmd@linaro.org Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Pierrick Bouvier committed
Feb 25, 2026 at 05:19 UTC
c7c15bc178dd87d24cd9f30621167c68626c2e2a
2 files changed
+5
-9
hw/virtio/meson.build
+1
-2
@@ -17,8 +17,7 @@ if have_vhost
17
system_virtio_ss.add(files('vhost.c'))
18
system_virtio_ss.add(files('vhost-backend.c', 'vhost-iova-tree.c'))
19
if have_vhost_user
20
- # fixme - this really should be generic
21
- specific_virtio_ss.add(files('vhost-user.c'))
20
+ system_virtio_ss.add(files('vhost-user.c'))
21
system_virtio_ss.add(files('vhost-user-base.c'))
22
23
# MMIO Stubs
hw/virtio/vhost-user.c
+4
-7
@@ -44,13 +44,8 @@
44
#define VHOST_USER_F_PROTOCOL_FEATURES 30
45
#define VHOST_USER_BACKEND_MAX_FDS 8
46
47
-#if defined(TARGET_PPC) || defined(TARGET_PPC64)
48
-#include "hw/ppc/spapr.h"
49
-#define VHOST_USER_MAX_RAM_SLOTS SPAPR_MAX_RAM_SLOTS
50
-
51
-#else
47
+#include "hw/ppc/spapr_common.h"
48
#define VHOST_USER_MAX_RAM_SLOTS 512
53
-#endif
49
50
/*
51
* Maximum size of virtio device config space
@@ -2287,7 +2282,9 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
2282
return -EINVAL;
2283
}
2284
2290
- u->user->memory_slots = MIN(ram_slots, VHOST_USER_MAX_RAM_SLOTS);
2285
+ const uint64_t vhost_user_max_ram_slots = target_base_ppc() ?
2286
+ SPAPR_MAX_RAM_SLOTS : VHOST_USER_MAX_RAM_SLOTS;
2287
+ u->user->memory_slots = MIN(ram_slots, vhost_user_max_ram_slots);
2288
}
2289
}
2290