#include "libqos/pci-pc.h"
#include "qemu-common.h"
+#include "qapi/qmp/qdict.h"
#include "qemu/host-utils.h"
#include "hw/pci/pci_ids.h"
#include "hw/pci/pci_regs.h"
+/* TODO actually test the results and get rid of this */
+#define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__))
+
/* Test images sizes in MB */
#define TEST_IMAGE_SIZE_MB_LARGE (200 * 1024)
#define TEST_IMAGE_SIZE_MB_SMALL 64
{
AHCIQState *s;
- s = g_malloc0(sizeof(AHCIQState));
+ s = g_new0(AHCIQState, 1);
s->parent = qtest_pc_vboot(cli, ap);
+ global_qtest = s->parent->qts;
alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);
/* Verify that we have an AHCI device present. */
- s->dev = get_ahci_device(&s->fingerprint);
+ s->dev = get_ahci_device(s->parent->qts, &s->fingerprint);
return s;
}
s = ahci_vboot(cli, ap);
va_end(ap);
} else {
- cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
- ",format=%s"
+ cli = "-drive if=none,id=drive0,file=%s,cache=writeback,format=%s"
" -M q35 "
"-device ide-hd,drive=drive0 "
+ "-global ide-hd.serial=%s "
"-global ide-hd.ver=%s";
- s = ahci_boot(cli, tmp_path, "testdisk", imgfmt, "version");
+ s = ahci_boot(cli, tmp_path, imgfmt, "testdisk", "version");
}
return s;
AHCIQState *src, *dst;
AHCICommand *cmd;
uint8_t px;
- const char *s;
char *uri = g_strdup_printf("unix:%s", mig_socket);
prepare_blkdebug_script(debug_path, "flush_to_disk");
ahci_migrate(src, dst, uri);
/* Complete the command */
- s = "{'execute':'cont' }";
- qmp_async(s);
+ qmp_send("{'execute':'cont' }");
qmp_eventwait("RESUME");
ahci_command_wait(dst, cmd);
ahci_command_verify(dst, cmd);
} else {
g_assert(!qdict_get_bool(data, "tray-open"));
}
- QDECREF(rsp);
+ qobject_unref(rsp);
}
static void test_atapi_tray(void)
QDict *rsp;
fd = prepare_iso(iso_size, &tx, &iso);
- ahci = ahci_boot_and_enable("-drive if=none,id=drive0,file=%s,format=raw "
+ ahci = ahci_boot_and_enable("-blockdev node-name=drive0,driver=file,filename=%s "
"-M q35 "
- "-device ide-cd,drive=drive0 ", iso);
+ "-device ide-cd,id=cd0,drive=drive0 ", iso);
port = ahci_port_select(ahci);
ahci_atapi_eject(ahci, port);
atapi_wait_tray(false);
/* Remove media */
- qmp_async("{'execute': 'blockdev-open-tray', "
- "'arguments': {'device': 'drive0'}}");
+ qmp_send("{'execute': 'blockdev-open-tray',"
+ " 'arguments': {'id': 'cd0'}}");
atapi_wait_tray(true);
rsp = qmp_receive();
- QDECREF(rsp);
+ qobject_unref(rsp);
- qmp_discard_response("{'execute': 'x-blockdev-remove-medium', "
- "'arguments': {'device': 'drive0'}}");
+ qmp_discard_response("{'execute': 'blockdev-remove-medium', "
+ "'arguments': {'id': 'cd0'}}");
/* Test the tray without a medium */
ahci_atapi_load(ahci, port);
"'driver': 'raw', "
"'file': { 'driver': 'file', "
"'filename': %s }}}", iso);
- qmp_discard_response("{'execute': 'x-blockdev-insert-medium',"
- "'arguments': { 'device': 'drive0', "
+ qmp_discard_response("{'execute': 'blockdev-insert-medium',"
+ "'arguments': { 'id': 'cd0', "
"'node-name': 'node0' }}");
/* Again, the event shows up first */
- qmp_async("{'execute': 'blockdev-close-tray', "
- "'arguments': {'device': 'drive0'}}");
+ qmp_send("{'execute': 'blockdev-close-tray',"
+ " 'arguments': {'id': 'cd0'}}");
atapi_wait_tray(false);
rsp = qmp_receive();
- QDECREF(rsp);
+ qobject_unref(rsp);
/* Now, to convince ATAPI we understand the media has changed... */
ahci_atapi_test_ready(ahci, port, false, SENSE_NOT_READY);
char *name;
AHCIIOTestOptions *opts;
- opts = g_malloc(sizeof(AHCIIOTestOptions));
+ opts = g_new(AHCIIOTestOptions, 1);
opts->length = len;
opts->address_type = addr;
opts->io_type = type;
if ((addr == ADDR_MODE_LBA48) && (offset == OFFSET_HIGH) &&
(mb_to_sectors(test_image_size_mb) <= 0xFFFFFFF)) {
g_test_message("%s: skipped; test image too small", name);
+ g_free(opts);
g_free(name);
return;
}