[kvm-unit-tests PATCH v2 1/3] s390x: spec_ex-sie: refactor to use snippet API

Nico Boehr
2023-11-06T17:08:57Z

spec_ex-sie uses a snippet, but allocated the memory on its own without
obvious reason to do so.

Refactor the test to use snippet_init().

Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
Reviewed-by: Janosch Frank <frankja@linux.ibm.com>
---
s390x/spec_ex-sie.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/s390x/spec_ex-sie.c b/s390x/spec_ex-sie.c
index 5fa135b81c86..fe2f23ee3d84 100644
--- a/s390x/spec_ex-sie.c
+++ b/s390x/spec_ex-sie.c
@@ -17,19 +17,18 @@
#include <hardware.h>

static struct vm vm;
-extern const char SNIPPET_NAME_START(c, spec_ex)[];
-extern const char SNIPPET_NAME_END(c, spec_ex)[];
static bool strict;

static void setup_guest(void)
{
- char *guest;
- int binary_size = SNIPPET_LEN(c, spec_ex);
+ extern const char SNIPPET_NAME_START(c, spec_ex)[];
+ extern const char SNIPPET_NAME_END(c, spec_ex)[];

setup_vm();
- guest = alloc_pages(8);
- memcpy(guest, SNIPPET_NAME_START(c, spec_ex), binary_size);
- sie_guest_create(&vm, (uint64_t) guest, HPAGE_SIZE);
+
+ snippet_setup_guest(&vm, false);
+ snippet_init(&vm, SNIPPET_NAME_START(c, spec_ex),
+ SNIPPET_LEN(c, spec_ex), SNIPPET_UNPACK_OFF);
}

static void reset_guest(void)
--
2.41.0