#include "qemu/osdep.h"
#include <getopt.h>
-#include "libqos/libqtest.h"
+#include "libqtest.h"
#include "libqos/libqos-pc.h"
#include "libqos/ahci.h"
#include "libqos/pci-pc.h"
-#include "qemu-common.h"
#include "qapi/qmp/qdict.h"
#include "qemu/host-utils.h"
#define TEST_IMAGE_SIZE_MB_SMALL 64
/*** Globals ***/
-static char tmp_path[] = "/tmp/qtest.XXXXXX";
-static char debug_path[] = "/tmp/qtest-blkdebug.XXXXXX";
-static char mig_socket[] = "/tmp/qtest-migration.XXXXXX";
+static char *tmp_path;
+static char *debug_path;
+static char *mig_socket;
static bool ahci_pedantic;
static const char *imgfmt;
static unsigned test_image_size_mb;
static int prepare_iso(size_t size, unsigned char **buf, char **name)
{
- char cdrom_path[] = "/tmp/qtest.iso.XXXXXX";
+ g_autofree char *cdrom_path = NULL;
unsigned char *patt;
ssize_t ret;
- int fd = mkstemp(cdrom_path);
+ int fd = g_file_open_tmp("qtest.iso.XXXXXX", &cdrom_path, NULL);
g_assert(fd != -1);
g_assert(buf);
char *iso;
int fd;
AHCIOpts opts = {
- .size = (ATAPI_SECTOR_SIZE * nsectors),
+ .size = ((uint64_t)ATAPI_SECTOR_SIZE * nsectors),
.atapi = true,
.atapi_dma = dma,
.post_cb = ahci_cb_cmp_buff,
.set_bcl = override_bcl,
.bcl = bcl,
};
- uint64_t iso_size = ATAPI_SECTOR_SIZE * (nsectors + 1);
+ uint64_t iso_size = (uint64_t)ATAPI_SECTOR_SIZE * (nsectors + 1);
/* Prepare ISO and fill 'tx' buffer */
fd = prepare_iso(iso_size, &tx, &iso);
int main(int argc, char **argv)
{
- const char *arch;
+ const char *arch, *base;
int ret;
int fd;
int c;
return 0;
}
+ /*
+ * "base" stores the starting point where we create temporary files.
+ *
+ * On Windows, this is set to the relative path of current working
+ * directory, because the absolute path causes the blkdebug filename
+ * parser fail to parse "blkdebug:path/to/config:path/to/image".
+ */
+#ifndef _WIN32
+ base = g_get_tmp_dir();
+#else
+ base = ".";
+#endif
+
/* Create a temporary image */
- fd = mkstemp(tmp_path);
+ tmp_path = g_strdup_printf("%s/qtest.XXXXXX", base);
+ fd = g_mkstemp(tmp_path);
g_assert(fd >= 0);
if (have_qemu_img()) {
imgfmt = "qcow2";
close(fd);
/* Create temporary blkdebug instructions */
- fd = mkstemp(debug_path);
+ debug_path = g_strdup_printf("%s/qtest-blkdebug.XXXXXX", base);
+ fd = g_mkstemp(debug_path);
g_assert(fd >= 0);
close(fd);
/* Reserve a hollow file to use as a socket for migration tests */
- fd = mkstemp(mig_socket);
+ fd = g_file_open_tmp("qtest-migration.XXXXXX", &mig_socket, NULL);
g_assert(fd >= 0);
close(fd);
/* Cleanup */
unlink(tmp_path);
+ g_free(tmp_path);
unlink(debug_path);
+ g_free(debug_path);
unlink(mig_socket);
+ g_free(mig_socket);
return ret;
}