summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-06-18 15:30:13 +0100
committerPeter Maydell <peter.maydell@linaro.org>2020-06-18 15:30:13 +0100
commiteefe34ea4b82c2b47abe28af4cc7247d51553626 (patch)
tree39d206780c8dd62490c6062b2e94776617531eb1 /tests
parent3b268766ecb7b630938e9bfb89b106a9dd8d94ae (diff)
parent7e89a1401a9674c9882948f05f4d17ea7be1c4eb (diff)
downloadqemu-eefe34ea4b82c2b47abe28af4cc7247d51553626.zip
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200617a' into staging
Migration (and HMP and virtiofs) pull 2020-06-17 Migration: HMP/migration and test changes from Mao Zhongyi multifd fix from Laurent Vivier HMP qom-set partial reversion/change from David Hildenbrand now you need -j to pass json format, but it's regained the old 100M type format. Memory leak fix from Pan Nengyuan Virtiofs fchmod seccomp fix from Max Reitz Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> # gpg: Signature made Wed 17 Jun 2020 19:34:58 BST # gpg: using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>" [full] # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * remotes/dgilbert/tags/pull-migration-20200617a: migration: fix multifd_send_pages() next channel docs/xbzrle: update 'cache miss rate' and 'encoding rate' to docs monitor/hmp-cmds: improvements for the 'info migrate' monitor/hmp-cmds: add 'goto end' to reduce duplicate code. monitor/hmp-cmds: delete redundant Error check before invoke hmp_handle_error() monitor/hmp-cmds: don't silently output when running 'migrate_set_downtime' fails monitor/hmp-cmds: add units for migrate_parameters tests/migration: fix unreachable path in stress test tests/migration: mem leak fix hmp: Make json format optional for qom-set qom-hmp-cmds: fix a memleak in hmp_qom_get virtiofsd: Whitelist fchmod Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/migration/stress.c34
1 files changed, 7 insertions, 27 deletions
diff --git a/tests/migration/stress.c b/tests/migration/stress.c
index 0c23964693..a062ef6b55 100644
--- a/tests/migration/stress.c
+++ b/tests/migration/stress.c
@@ -167,29 +167,17 @@ static unsigned long long now(void)
return (tv.tv_sec * 1000ull) + (tv.tv_usec / 1000ull);
}
-static int stressone(unsigned long long ramsizeMB)
+static void stressone(unsigned long long ramsizeMB)
{
size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE;
- char *ram = malloc(ramsizeMB * 1024 * 1024);
+ g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024);
char *ramptr;
size_t i, j, k;
- char *data = malloc(PAGE_SIZE);
+ g_autofree char *data = g_malloc(PAGE_SIZE);
char *dataptr;
size_t nMB = 0;
unsigned long long before, after;
- if (!ram) {
- fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM: %s\n",
- argv0, gettid(), ramsizeMB, strerror(errno));
- return -1;
- }
- if (!data) {
- fprintf(stderr, "%s (%d): ERROR: cannot allocate %d bytes of RAM: %s\n",
- argv0, gettid(), PAGE_SIZE, strerror(errno));
- free(ram);
- return -1;
- }
-
/* We don't care about initial state, but we do want
* to fault it all into RAM, otherwise the first iter
* of the loop below will be quite slow. We can't use
@@ -198,9 +186,7 @@ static int stressone(unsigned long long ramsizeMB)
memset(ram, 0xfe, ramsizeMB * 1024 * 1024);
if (random_bytes(data, PAGE_SIZE) < 0) {
- free(ram);
- free(data);
- return -1;
+ return;
}
before = now();
@@ -227,9 +213,6 @@ static int stressone(unsigned long long ramsizeMB)
}
}
}
-
- free(data);
- free(ram);
}
@@ -242,7 +225,7 @@ static void *stressthread(void *arg)
return NULL;
}
-static int stress(unsigned long long ramsizeGB, int ncpus)
+static void stress(unsigned long long ramsizeGB, int ncpus)
{
size_t i;
unsigned long long ramsizeMB = ramsizeGB * 1024 / ncpus;
@@ -255,8 +238,6 @@ static int stress(unsigned long long ramsizeGB, int ncpus)
}
stressone(ramsizeMB);
-
- return 0;
}
@@ -352,8 +333,7 @@ int main(int argc, char **argv)
fprintf(stdout, "%s (%05d): INFO: RAM %llu GiB across %d CPUs\n",
argv0, gettid(), ramsizeGB, ncpus);
- if (stress(ramsizeGB, ncpus) < 0)
- exit_failure();
+ stress(ramsizeGB, ncpus);
- exit_success();
+ exit_failure();
}