Skip to content

Commit b236b61

Browse files
committed
qtest/ahci: always specify image format
Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1447439479-16775-2-git-send-email-jsnow@redhat.com
1 parent 6d9e729 commit b236b61

File tree

1 file changed

+29
-22
lines changed

1 file changed

+29
-22
lines changed

tests/ahci-test.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static char tmp_path[] = "/tmp/qtest.XXXXXX";
4949
static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
5050
static char mig_socket[] = "/tmp/qtest-migration.XXXXXX";
5151
static bool ahci_pedantic;
52+
static const char *imgfmt;
5253

5354
/*** Function Declarations ***/
5455
static void ahci_test_port_spec(AHCIQState *ahci, uint8_t port);
@@ -175,11 +176,11 @@ static AHCIQState *ahci_boot(const char *cli, ...)
175176
va_end(ap);
176177
} else {
177178
cli = "-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s"
178-
",format=qcow2"
179+
",format=%s"
179180
" -M q35 "
180181
"-device ide-hd,drive=drive0 "
181182
"-global ide-hd.ver=%s";
182-
s = ahci_boot(cli, tmp_path, "testdisk", "version");
183+
s = ahci_boot(cli, tmp_path, "testdisk", imgfmt, "version");
183184
}
184185

185186
return s;
@@ -1078,12 +1079,12 @@ static void test_flush_retry(void)
10781079

10791080
prepare_blkdebug_script(debug_path, "flush_to_disk");
10801081
ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
1081-
"format=qcow2,cache=writeback,"
1082+
"format=%s,cache=writeback,"
10821083
"rerror=stop,werror=stop "
10831084
"-M q35 "
10841085
"-device ide-hd,drive=drive0 ",
10851086
debug_path,
1086-
tmp_path);
1087+
tmp_path, imgfmt);
10871088

10881089
/* Issue Flush Command and wait for error */
10891090
port = ahci_port_select(ahci);
@@ -1113,10 +1114,10 @@ static void test_migrate_sanity(void)
11131114
char *uri = g_strdup_printf("unix:%s", mig_socket);
11141115

11151116
src = ahci_boot("-m 1024 -M q35 "
1116-
"-hda %s ", tmp_path);
1117+
"-drive if=ide,file=%s,format=%s ", tmp_path, imgfmt);
11171118
dst = ahci_boot("-m 1024 -M q35 "
1118-
"-hda %s "
1119-
"-incoming %s", tmp_path, uri);
1119+
"-drive if=ide,file=%s,format=%s "
1120+
"-incoming %s", tmp_path, imgfmt, uri);
11201121

11211122
ahci_migrate(src, dst, uri);
11221123

@@ -1138,10 +1139,11 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)
11381139
char *uri = g_strdup_printf("unix:%s", mig_socket);
11391140

11401141
src = ahci_boot_and_enable("-m 1024 -M q35 "
1141-
"-hda %s ", tmp_path);
1142+
"-drive if=ide,format=%s,file=%s ",
1143+
imgfmt, tmp_path);
11421144
dst = ahci_boot("-m 1024 -M q35 "
1143-
"-hda %s "
1144-
"-incoming %s", tmp_path, uri);
1145+
"-drive if=ide,format=%s,file=%s "
1146+
"-incoming %s", imgfmt, tmp_path, uri);
11451147

11461148
set_context(src->parent);
11471149

@@ -1197,12 +1199,12 @@ static void ahci_halted_io_test(uint8_t cmd_read, uint8_t cmd_write)
11971199
prepare_blkdebug_script(debug_path, "write_aio");
11981200

11991201
ahci = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
1200-
"format=qcow2,cache=writeback,"
1202+
"format=%s,cache=writeback,"
12011203
"rerror=stop,werror=stop "
12021204
"-M q35 "
12031205
"-device ide-hd,drive=drive0 ",
12041206
debug_path,
1205-
tmp_path);
1207+
tmp_path, imgfmt);
12061208

12071209
/* Initialize and prepare */
12081210
port = ahci_port_select(ahci);
@@ -1263,20 +1265,20 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
12631265
prepare_blkdebug_script(debug_path, "write_aio");
12641266

12651267
src = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
1266-
"format=qcow2,cache=writeback,"
1268+
"format=%s,cache=writeback,"
12671269
"rerror=stop,werror=stop "
12681270
"-M q35 "
12691271
"-device ide-hd,drive=drive0 ",
12701272
debug_path,
1271-
tmp_path);
1273+
tmp_path, imgfmt);
12721274

12731275
dst = ahci_boot("-drive file=%s,if=none,id=drive0,"
1274-
"format=qcow2,cache=writeback,"
1276+
"format=%s,cache=writeback,"
12751277
"rerror=stop,werror=stop "
12761278
"-M q35 "
12771279
"-device ide-hd,drive=drive0 "
12781280
"-incoming %s",
1279-
tmp_path, uri);
1281+
tmp_path, imgfmt, uri);
12801282

12811283
set_context(src->parent);
12821284

@@ -1335,15 +1337,17 @@ static void test_flush_migrate(void)
13351337
prepare_blkdebug_script(debug_path, "flush_to_disk");
13361338

13371339
src = ahci_boot_and_enable("-drive file=blkdebug:%s:%s,if=none,id=drive0,"
1338-
"cache=writeback,rerror=stop,werror=stop "
1340+
"cache=writeback,rerror=stop,werror=stop,"
1341+
"format=%s "
13391342
"-M q35 "
13401343
"-device ide-hd,drive=drive0 ",
1341-
debug_path, tmp_path);
1344+
debug_path, tmp_path, imgfmt);
13421345
dst = ahci_boot("-drive file=%s,if=none,id=drive0,"
1343-
"cache=writeback,rerror=stop,werror=stop "
1346+
"cache=writeback,rerror=stop,werror=stop,"
1347+
"format=%s "
13441348
"-M q35 "
13451349
"-device ide-hd,drive=drive0 "
1346-
"-incoming %s", tmp_path, uri);
1350+
"-incoming %s", tmp_path, imgfmt, uri);
13471351

13481352
set_context(src->parent);
13491353

@@ -1626,9 +1630,12 @@ int main(int argc, char **argv)
16261630
return 0;
16271631
}
16281632

1629-
/* Create a temporary qcow2 image */
1630-
close(mkstemp(tmp_path));
1633+
/* Create a temporary image */
1634+
fd = mkstemp(tmp_path);
1635+
g_assert(fd >= 0);
1636+
imgfmt = "qcow2";
16311637
mkqcow2(tmp_path, TEST_IMAGE_SIZE_MB);
1638+
close(fd);
16321639

16331640
/* Create temporary blkdebug instructions */
16341641
fd = mkstemp(debug_path);

0 commit comments

Comments
 (0)