提交 3b9f94e1 编写于 作者: B bellard

win32 block device fixes (initial patch by kazu)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2305 c046a42c-6fe2-441c-8c8c-71466251a162
上级 f5e25d70
...@@ -906,13 +906,13 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) ...@@ -906,13 +906,13 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags)
create_flags = OPEN_EXISTING; create_flags = OPEN_EXISTING;
} }
#ifdef QEMU_TOOL #ifdef QEMU_TOOL
overlapped = 0; overlapped = FILE_ATTRIBUTE_NORMAL;
#else #else
overlapped = FILE_FLAG_OVERLAPPED; overlapped = FILE_FLAG_OVERLAPPED;
#endif #endif
s->hfile = CreateFile(filename, access_flags, s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL, FILE_SHARE_READ, NULL,
create_flags, overlapped, 0); create_flags, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE) if (s->hfile == INVALID_HANDLE_VALUE)
return -1; return -1;
return 0; return 0;
...@@ -962,6 +962,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset, ...@@ -962,6 +962,7 @@ static int raw_pwrite(BlockDriverState *bs, int64_t offset,
return ret_count; return ret_count;
} }
#if 0
#ifndef QEMU_TOOL #ifndef QEMU_TOOL
static void raw_aio_cb(void *opaque) static void raw_aio_cb(void *opaque)
{ {
...@@ -1064,10 +1065,12 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb) ...@@ -1064,10 +1065,12 @@ static void raw_aio_cancel(BlockDriverAIOCB *blockacb)
qemu_aio_release(acb); qemu_aio_release(acb);
#endif #endif
} }
#endif /* #if 0 */
static void raw_flush(BlockDriverState *bs) static void raw_flush(BlockDriverState *bs)
{ {
/* XXX: add it */ BDRVRawState *s = bs->opaque;
FlushFileBuffers(s->hfile);
} }
static void raw_close(BlockDriverState *bs) static void raw_close(BlockDriverState *bs)
...@@ -1143,6 +1146,10 @@ void qemu_aio_flush(void) ...@@ -1143,6 +1146,10 @@ void qemu_aio_flush(void)
{ {
} }
void qemu_aio_flush(void)
{
}
void qemu_aio_wait_start(void) void qemu_aio_wait_start(void)
{ {
} }
...@@ -1254,13 +1261,13 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) ...@@ -1254,13 +1261,13 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags)
create_flags = OPEN_EXISTING; create_flags = OPEN_EXISTING;
#ifdef QEMU_TOOL #ifdef QEMU_TOOL
overlapped = 0; overlapped = FILE_ATTRIBUTE_NORMAL;
#else #else
overlapped = FILE_FLAG_OVERLAPPED; overlapped = FILE_FLAG_OVERLAPPED;
#endif #endif
s->hfile = CreateFile(filename, access_flags, s->hfile = CreateFile(filename, access_flags,
FILE_SHARE_READ, NULL, FILE_SHARE_READ, NULL,
create_flags, overlapped, 0); create_flags, overlapped, NULL);
if (s->hfile == INVALID_HANDLE_VALUE) if (s->hfile == INVALID_HANDLE_VALUE)
return -1; return -1;
return 0; return 0;
......
...@@ -56,12 +56,6 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, ...@@ -56,12 +56,6 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num,
static BlockDriverState *bdrv_first; static BlockDriverState *bdrv_first;
static BlockDriver *first_drv; static BlockDriver *first_drv;
#ifdef _WIN32
#define PATH_SEP '\\'
#else
#define PATH_SEP '/'
#endif
int path_is_absolute(const char *path) int path_is_absolute(const char *path)
{ {
const char *p; const char *p;
...@@ -70,7 +64,11 @@ int path_is_absolute(const char *path) ...@@ -70,7 +64,11 @@ int path_is_absolute(const char *path)
p++; p++;
else else
p = path; p = path;
return (*p == PATH_SEP); #ifdef _WIN32
return (*p == '/' || *p == '\\');
#else
return (*p == '/');
#endif
} }
/* if filename is absolute, just copy it to dest. Otherwise, build a /* if filename is absolute, just copy it to dest. Otherwise, build a
...@@ -93,7 +91,15 @@ void path_combine(char *dest, int dest_size, ...@@ -93,7 +91,15 @@ void path_combine(char *dest, int dest_size,
p++; p++;
else else
p = base_path; p = base_path;
p1 = strrchr(base_path, PATH_SEP); p1 = strrchr(base_path, '/');
#ifdef _WIN32
{
const char *p2;
p2 = strrchr(base_path, '\\');
if (!p1 || p2 > p1)
p1 = p2;
}
#endif
if (p1) if (p1)
p1++; p1++;
else else
...@@ -168,7 +174,10 @@ int bdrv_create(BlockDriver *drv, ...@@ -168,7 +174,10 @@ int bdrv_create(BlockDriver *drv,
#ifdef _WIN32 #ifdef _WIN32
void get_tmp_filename(char *filename, int size) void get_tmp_filename(char *filename, int size)
{ {
tmpnam(filename); char temp_dir[MAX_PATH];
GetTempPath(MAX_PATH, temp_dir);
GetTempFileName(temp_dir, "qem", 0, filename);
} }
#else #else
void get_tmp_filename(char *filename, int size) void get_tmp_filename(char *filename, int size)
...@@ -996,7 +1005,11 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size) ...@@ -996,7 +1005,11 @@ char *get_human_readable_size(char *buf, int buf_size, int64_t size)
char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
{ {
char buf1[128], date_buf[128], clock_buf[128]; char buf1[128], date_buf[128], clock_buf[128];
#ifdef _WIN32
struct tm *ptm;
#else
struct tm tm; struct tm tm;
#endif
time_t ti; time_t ti;
int64_t secs; int64_t secs;
...@@ -1006,11 +1019,15 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn) ...@@ -1006,11 +1019,15 @@ char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
"ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
} else { } else {
ti = sn->date_sec; ti = sn->date_sec;
#ifndef _WIN32 #ifdef _WIN32
ptm = localtime(&ti);
strftime(date_buf, sizeof(date_buf),
"%Y-%m-%d %H:%M:%S", ptm);
#else
localtime_r(&ti, &tm); localtime_r(&ti, &tm);
#endif
strftime(date_buf, sizeof(date_buf), strftime(date_buf, sizeof(date_buf),
"%Y-%m-%d %H:%M:%S", &tm); "%Y-%m-%d %H:%M:%S", &tm);
#endif
secs = sn->vm_clock_nsec / 1000000000; secs = sn->vm_clock_nsec / 1000000000;
snprintf(clock_buf, sizeof(clock_buf), snprintf(clock_buf, sizeof(clock_buf),
"%02d:%02d:%02d.%03d", "%02d:%02d:%02d.%03d",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册