[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-commits] [COMMIT 1e37d05] raw-posix: Handle errors in raw_create
From: |
Anthony Liguori |
Subject: |
[Qemu-commits] [COMMIT 1e37d05] raw-posix: Handle errors in raw_create |
Date: |
Thu, 16 Jul 2009 23:12:45 -0000 |
From: Stefan Weil <address@hidden>
In qemu-iotests, some large images are created using qemu-img.
Without checks for errors, qemu-img will just create an
empty image, and later read / write tests will fail.
With the patch, failures during image creation are detected
and reported.
Signed-off-by: Stefan Weil <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>
diff --git a/block/raw-posix.c b/block/raw-posix.c
index fa4f83e..389903e 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -852,6 +852,7 @@ again:
static int raw_create(const char *filename, QEMUOptionParameter *options)
{
int fd;
+ int result = 0;
int64_t total_size = 0;
/* Read out options */
@@ -864,11 +865,17 @@ static int raw_create(const char *filename,
QEMUOptionParameter *options)
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
0644);
- if (fd < 0)
- return -EIO;
- ftruncate(fd, total_size * 512);
- close(fd);
- return 0;
+ if (fd < 0) {
+ result = -errno;
+ } else {
+ if (ftruncate(fd, total_size * 512) != 0) {
+ result = -errno;
+ }
+ if (close(fd) != 0) {
+ result = -errno;
+ }
+ }
+ return result;
}
static void raw_flush(BlockDriverState *bs)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-commits] [COMMIT 1e37d05] raw-posix: Handle errors in raw_create,
Anthony Liguori <=