qs->qts = qtest_init(cmdline);
qs->ops = ops;
if (ops) {
- qs->alloc = ops->init_allocator(qs->qts, ALLOC_NO_FLAGS);
- qs->pcibus = ops->qpci_init(qs->qts, qs->alloc);
+ ops->alloc_init(&qs->alloc, qs->qts, ALLOC_NO_FLAGS);
+ qs->pcibus = ops->qpci_new(qs->qts, &qs->alloc);
}
g_free(cmdline);
qs->ops->qpci_free(qs->pcibus);
qs->pcibus = NULL;
}
- if (qs->alloc && qs->ops->uninit_allocator) {
- qs->ops->uninit_allocator(qs->alloc);
- qs->alloc = NULL;
- }
}
+ alloc_destroy(&qs->alloc);
qtest_quit(qs->qts);
g_free(qs);
}
}
}
-void set_context(QOSState *s)
-{
- global_qtest = s->qts;
-}
-
static QDict *qmp_execute(QTestState *qts, const char *command)
{
return qtest_qmp(qts, "{ 'execute': %s }", command);
QDict *rsp, *sub;
bool running;
- set_context(from);
-
/* Is the machine currently running? */
rsp = qmp_execute(from->qts, "query-status");
g_assert(qdict_haskey(rsp, "return"));
sub = qdict_get_qdict(rsp, "return");
g_assert(qdict_haskey(sub, "running"));
running = qdict_get_bool(sub, "running");
- QDECREF(rsp);
+ qobject_unref(rsp);
/* Issue the migrate command. */
rsp = qtest_qmp(from->qts,
"{ 'execute': 'migrate', 'arguments': { 'uri': %s }}",
uri);
g_assert(qdict_haskey(rsp, "return"));
- QDECREF(rsp);
+ qobject_unref(rsp);
/* Wait for STOP event, but only if we were running: */
if (running) {
/* If we were running, we can wait for an event. */
if (running) {
- migrate_allocator(from->alloc, to->alloc);
- set_context(to);
+ migrate_allocator(&from->alloc, &to->alloc);
qtest_qmp_eventwait(to->qts, "RESUME");
return;
}
/* "setup", "active", "completed", "failed", "cancelled" */
if (strcmp(st, "completed") == 0) {
- QDECREF(rsp);
+ qobject_unref(rsp);
break;
}
if ((strcmp(st, "setup") == 0) || (strcmp(st, "active") == 0)) {
- QDECREF(rsp);
+ qobject_unref(rsp);
g_usleep(5000);
continue;
}
g_assert_not_reached();
}
- migrate_allocator(from->alloc, to->alloc);
- set_context(to);
+ migrate_allocator(&from->alloc, &to->alloc);
}
bool have_qemu_img(void)
cli = g_strdup_printf("%s create -f %s %s %uM", qemu_img_abs_path,
fmt, file, size_mb);
ret = g_spawn_command_line_sync(cli, &out, &out2, &rc, &err);
- if (err) {
+ if (err || !g_spawn_check_exit_status(rc, &err)) {
fprintf(stderr, "%s\n", err->message);
g_error_free(err);
}
g_assert(ret && !err);
- /* In glib 2.34, we have g_spawn_check_exit_status. in 2.12, we don't.
- * glib 2.43.91 implementation assumes that any non-zero is an error for
- * windows, but uses extra precautions for Linux. However,
- * 0 is only possible if the program exited normally, so that should be
- * sufficient for our purposes on all platforms, here. */
- if (rc) {
- fprintf(stderr, "qemu-img returned status code %d\n", rc);
- }
- g_assert(!rc);
-
g_free(out);
g_free(out2);
g_free(cli);