[kvm-unit-tests GIT PULL 04/13] lib: s390x: snippet: Add function to create a guest of specific length

Janosch Frank <[email protected]>
Newsgroups org.kernel.vger.kvm,org.kernel.vger.linux-s390
Message-ID <[email protected]>
While 1MB is certainly enough to store the guest code, it's often not
enough for memory tests. Let's add a separate function to allow
arbitrary guest sizes.

Signed-off-by: Janosch Frank <[email protected]>
Reviewed-by: Nico Boehr <[email protected]>
Reviewed-by: Christoph Schlameuss <[email protected]>
---
 lib/s390x/snippet.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/s390x/snippet.h b/lib/s390x/snippet.h
index 94688f49..05c9a2d4 100644
--- a/lib/s390x/snippet.h
+++ b/lib/s390x/snippet.h
@@ -123,10 +123,14 @@ static inline void snippet_pv_init(struct vm *vm, const char *gbin,
 }
 
 /* Allocates and sets up a snippet based guest */
-static inline void snippet_setup_guest(struct vm *vm, bool is_pv)
+static inline void snippet_setup_guest_len(struct vm *vm, bool is_pv,
+					   unsigned long len)
 {
+	/* Guest sizes are specified in megabyte chunks */
+	assert(!(len & ~HPAGE_MASK));
+
 	/* Initialize the vm struct and allocate control blocks */
-	sie_guest_create(vm, SZ_1M);
+	sie_guest_create(vm, len);
 
 	if (is_pv) {
 		/* FMT4 needs a ESCA */
@@ -141,6 +145,12 @@ static inline void snippet_setup_guest(struct vm *vm, bool is_pv)
 	}
 }
 
+/* Allocates and sets up a snippet based guest */
+static inline void snippet_setup_guest(struct vm *vm, bool is_pv)
+{
+	snippet_setup_guest_len(vm, is_pv, SZ_1M);
+}
+
 static inline void snippet_destroy_guest(struct vm *vm)
 {
 	sie_guest_destroy(vm);
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.