Skip to content

Commit 6d9e729

Browse files
committed
ahci/qtest: don't use tcp sockets for migration tests
Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 1447108074-20609-1-git-send-email-jsnow@redhat.com
1 parent f36aa12 commit 6d9e729

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

tests/ahci-test.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
/*** Globals ***/
4848
static char tmp_path[] = "/tmp/qtest.XXXXXX";
4949
static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
50+
static char mig_socket[] = "/tmp/qtest-migration.XXXXXX";
5051
static bool ahci_pedantic;
5152

5253
/*** Function Declarations ***/
@@ -114,8 +115,11 @@ static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
114115
{
115116
QOSState *tmp = to->parent;
116117
QPCIDevice *dev = to->dev;
118+
char *uri_local = NULL;
119+
117120
if (uri == NULL) {
118-
uri = "tcp:127.0.0.1:1234";
121+
uri_local = g_strdup_printf("%s%s", "unix:", mig_socket);
122+
uri = uri_local;
119123
}
120124

121125
/* context will be 'to' after completion. */
@@ -135,6 +139,7 @@ static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
135139
from->dev = dev;
136140

137141
verify_state(to);
142+
g_free(uri_local);
138143
}
139144

140145
/*** Test Setup & Teardown ***/
@@ -1105,7 +1110,7 @@ static void test_flush_retry(void)
11051110
static void test_migrate_sanity(void)
11061111
{
11071112
AHCIQState *src, *dst;
1108-
const char *uri = "tcp:127.0.0.1:1234";
1113+
char *uri = g_strdup_printf("unix:%s", mig_socket);
11091114

11101115
src = ahci_boot("-m 1024 -M q35 "
11111116
"-hda %s ", tmp_path);
@@ -1117,6 +1122,7 @@ static void test_migrate_sanity(void)
11171122

11181123
ahci_shutdown(src);
11191124
ahci_shutdown(dst);
1125+
g_free(uri);
11201126
}
11211127

11221128
/**
@@ -1129,7 +1135,7 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)
11291135
size_t bufsize = 4096;
11301136
unsigned char *tx = g_malloc(bufsize);
11311137
unsigned char *rx = g_malloc0(bufsize);
1132-
const char *uri = "tcp:127.0.0.1:1234";
1138+
char *uri = g_strdup_printf("unix:%s", mig_socket);
11331139

11341140
src = ahci_boot_and_enable("-m 1024 -M q35 "
11351141
"-hda %s ", tmp_path);
@@ -1158,6 +1164,7 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)
11581164
ahci_shutdown(dst);
11591165
g_free(rx);
11601166
g_free(tx);
1167+
g_free(uri);
11611168
}
11621169

11631170
static void test_migrate_dma(void)
@@ -1251,7 +1258,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
12511258
unsigned char *rx = g_malloc0(bufsize);
12521259
uint64_t ptr;
12531260
AHCICommand *cmd;
1254-
const char *uri = "tcp:127.0.0.1:1234";
1261+
char *uri = g_strdup_printf("unix:%s", mig_socket);
12551262

12561263
prepare_blkdebug_script(debug_path, "write_aio");
12571264

@@ -1301,6 +1308,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
13011308
ahci_shutdown(dst);
13021309
g_free(rx);
13031310
g_free(tx);
1311+
g_free(uri);
13041312
}
13051313

13061314
static void test_migrate_halted_dma(void)
@@ -1322,7 +1330,7 @@ static void test_flush_migrate(void)
13221330
AHCICommand *cmd;
13231331
uint8_t px;
13241332
const char *s;
1325-
const char *uri = "tcp:127.0.0.1:1234";
1333+
char *uri = g_strdup_printf("unix:%s", mig_socket);
13261334

13271335
prepare_blkdebug_script(debug_path, "flush_to_disk");
13281336

@@ -1360,6 +1368,7 @@ static void test_flush_migrate(void)
13601368
ahci_command_free(cmd);
13611369
ahci_shutdown(src);
13621370
ahci_shutdown(dst);
1371+
g_free(uri);
13631372
}
13641373

13651374
static void test_max(void)
@@ -1626,6 +1635,11 @@ int main(int argc, char **argv)
16261635
g_assert(fd >= 0);
16271636
close(fd);
16281637

1638+
/* Reserve a hollow file to use as a socket for migration tests */
1639+
fd = mkstemp(mig_socket);
1640+
g_assert(fd >= 0);
1641+
close(fd);
1642+
16291643
/* Run the tests */
16301644
qtest_add_func("/ahci/sanity", test_sanity);
16311645
qtest_add_func("/ahci/pci_spec", test_pci_spec);
@@ -1668,6 +1682,7 @@ int main(int argc, char **argv)
16681682
/* Cleanup */
16691683
unlink(tmp_path);
16701684
unlink(debug_path);
1685+
unlink(mig_socket);
16711686

16721687
return ret;
16731688
}

0 commit comments

Comments
 (0)