47
47
/*** Globals ***/
48
48
static char tmp_path [] = "/tmp/qtest.XXXXXX" ;
49
49
static char debug_path [] = "/tmp/qtest-blkdebug.XXXXXX" ;
50
+ static char mig_socket [] = "/tmp/qtest-migration.XXXXXX" ;
50
51
static bool ahci_pedantic ;
51
52
52
53
/*** Function Declarations ***/
@@ -114,8 +115,11 @@ static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
114
115
{
115
116
QOSState * tmp = to -> parent ;
116
117
QPCIDevice * dev = to -> dev ;
118
+ char * uri_local = NULL ;
119
+
117
120
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 ;
119
123
}
120
124
121
125
/* context will be 'to' after completion. */
@@ -135,6 +139,7 @@ static void ahci_migrate(AHCIQState *from, AHCIQState *to, const char *uri)
135
139
from -> dev = dev ;
136
140
137
141
verify_state (to );
142
+ g_free (uri_local );
138
143
}
139
144
140
145
/*** Test Setup & Teardown ***/
@@ -1105,7 +1110,7 @@ static void test_flush_retry(void)
1105
1110
static void test_migrate_sanity (void )
1106
1111
{
1107
1112
AHCIQState * src , * dst ;
1108
- const char * uri = "tcp:127.0.0.1:1234" ;
1113
+ char * uri = g_strdup_printf ( "unix:%s" , mig_socket ) ;
1109
1114
1110
1115
src = ahci_boot ("-m 1024 -M q35 "
1111
1116
"-hda %s " , tmp_path );
@@ -1117,6 +1122,7 @@ static void test_migrate_sanity(void)
1117
1122
1118
1123
ahci_shutdown (src );
1119
1124
ahci_shutdown (dst );
1125
+ g_free (uri );
1120
1126
}
1121
1127
1122
1128
/**
@@ -1129,7 +1135,7 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)
1129
1135
size_t bufsize = 4096 ;
1130
1136
unsigned char * tx = g_malloc (bufsize );
1131
1137
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 ) ;
1133
1139
1134
1140
src = ahci_boot_and_enable ("-m 1024 -M q35 "
1135
1141
"-hda %s " , tmp_path );
@@ -1158,6 +1164,7 @@ static void ahci_migrate_simple(uint8_t cmd_read, uint8_t cmd_write)
1158
1164
ahci_shutdown (dst );
1159
1165
g_free (rx );
1160
1166
g_free (tx );
1167
+ g_free (uri );
1161
1168
}
1162
1169
1163
1170
static void test_migrate_dma (void )
@@ -1251,7 +1258,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
1251
1258
unsigned char * rx = g_malloc0 (bufsize );
1252
1259
uint64_t ptr ;
1253
1260
AHCICommand * cmd ;
1254
- const char * uri = "tcp:127.0.0.1:1234" ;
1261
+ char * uri = g_strdup_printf ( "unix:%s" , mig_socket ) ;
1255
1262
1256
1263
prepare_blkdebug_script (debug_path , "write_aio" );
1257
1264
@@ -1301,6 +1308,7 @@ static void ahci_migrate_halted_io(uint8_t cmd_read, uint8_t cmd_write)
1301
1308
ahci_shutdown (dst );
1302
1309
g_free (rx );
1303
1310
g_free (tx );
1311
+ g_free (uri );
1304
1312
}
1305
1313
1306
1314
static void test_migrate_halted_dma (void )
@@ -1322,7 +1330,7 @@ static void test_flush_migrate(void)
1322
1330
AHCICommand * cmd ;
1323
1331
uint8_t px ;
1324
1332
const char * s ;
1325
- const char * uri = "tcp:127.0.0.1:1234" ;
1333
+ char * uri = g_strdup_printf ( "unix:%s" , mig_socket ) ;
1326
1334
1327
1335
prepare_blkdebug_script (debug_path , "flush_to_disk" );
1328
1336
@@ -1360,6 +1368,7 @@ static void test_flush_migrate(void)
1360
1368
ahci_command_free (cmd );
1361
1369
ahci_shutdown (src );
1362
1370
ahci_shutdown (dst );
1371
+ g_free (uri );
1363
1372
}
1364
1373
1365
1374
static void test_max (void )
@@ -1626,6 +1635,11 @@ int main(int argc, char **argv)
1626
1635
g_assert (fd >= 0 );
1627
1636
close (fd );
1628
1637
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
+
1629
1643
/* Run the tests */
1630
1644
qtest_add_func ("/ahci/sanity" , test_sanity );
1631
1645
qtest_add_func ("/ahci/pci_spec" , test_pci_spec );
@@ -1668,6 +1682,7 @@ int main(int argc, char **argv)
1668
1682
/* Cleanup */
1669
1683
unlink (tmp_path );
1670
1684
unlink (debug_path );
1685
+ unlink (mig_socket );
1671
1686
1672
1687
return ret ;
1673
1688
}
0 commit comments