diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-02-28 18:15:42 +0000 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-02-28 18:15:42 +0000 |
commit | 6065dcf33180741bec0292f603bfdde864eb347b (patch) | |
tree | 3a24ff1025208ad26c8965dfae4a6823155b4889 | |
parent | 4092caa643fa1103fbbdc96948f500c4a5c1f4cd (diff) | |
download | xen-6065dcf33180741bec0292f603bfdde864eb347b.tar.gz xen-6065dcf33180741bec0292f603bfdde864eb347b.tar.bz2 xen-6065dcf33180741bec0292f603bfdde864eb347b.zip |
libxc: Quieten the discard_file_cache() function. Preserve errno
across it. No longer make calls to the function dependent on 'non-live
save/restore': it's not a good test of whether the fd is a socket.
Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r-- | tools/libxc/xc_linux.c | 14 | ||||
-rw-r--r-- | tools/libxc/xc_linux_save.c | 29 | ||||
-rw-r--r-- | tools/libxc/xc_private.h | 2 | ||||
-rw-r--r-- | tools/libxc/xc_solaris.c | 3 |
4 files changed, 21 insertions, 27 deletions
diff --git a/tools/libxc/xc_linux.c b/tools/libxc/xc_linux.c index 4874c042dd..eac5acc793 100644 --- a/tools/libxc/xc_linux.c +++ b/tools/libxc/xc_linux.c @@ -329,14 +329,15 @@ int xc_evtchn_unmask(int xce_handle, evtchn_port_t port) } /* Optionally flush file to disk and discard page cache */ -int discard_file_cache(int fd, int flush) +void discard_file_cache(int fd, int flush) { off_t cur = 0; + int saved_errno = errno; if ( flush && (fsync(fd) < 0) ) { - PERROR("Failed to flush file: %s", strerror(errno)); - return -errno; + /*PERROR("Failed to flush file: %s", strerror(errno));*/ + goto out; } /* @@ -354,11 +355,12 @@ int discard_file_cache(int fd, int flush) /* Discard from the buffer cache. */ if ( posix_fadvise64(fd, 0, cur, POSIX_FADV_DONTNEED) < 0 ) { - PERROR("Failed to discard cache: %s", strerror(errno)); - return -errno; + /*PERROR("Failed to discard cache: %s", strerror(errno));*/ + goto out; } - return 0; + out: + errno = saved_errno; } /* diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c index d8c87e3d95..77541030b5 100644 --- a/tools/libxc/xc_linux_save.c +++ b/tools/libxc/xc_linux_save.c @@ -178,20 +178,14 @@ static int noncached_write(int fd, int live, void *buffer, int len) int rc = write(fd,buffer,len); - if (!live) { - write_count += len; + write_count += len; - if (write_count >= MAX_PAGECACHE_USAGE*PAGE_SIZE) { - int serrno = errno; - - /* Time to discard cache - dont care if this fails */ - discard_file_cache(fd, 0 /* no flush */); - - write_count = 0; - - errno = serrno; - } + if (write_count >= MAX_PAGECACHE_USAGE*PAGE_SIZE) { + /* Time to discard cache - dont care if this fails */ + discard_file_cache(fd, 0 /* no flush */); + write_count = 0; } + return rc; } @@ -1286,10 +1280,9 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, DPRINTF("Warning - couldn't disable shadow mode"); } } - else { - // flush last write and discard cache for file - discard_file_cache(io_fd, 1 /* flush */); - } + + // flush last write and discard cache for file + discard_file_cache(io_fd, 1 /* flush */); if (live_shinfo) munmap(live_shinfo, PAGE_SIZE); @@ -1300,10 +1293,10 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, if (live_p2m_frame_list) munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE); - if(live_p2m) + if (live_p2m) munmap(live_p2m, P2M_SIZE); - if(live_m2p) + if (live_m2p) munmap(live_m2p, M2P_SIZE(max_mfn)); free(pfn_type); diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h index 13935d361b..7fa3258db1 100644 --- a/tools/libxc/xc_private.h +++ b/tools/libxc/xc_private.h @@ -166,6 +166,6 @@ void bitmap_64_to_byte(uint8_t *bp, const uint64_t *lp, int nbits); void bitmap_byte_to_64(uint64_t *lp, const uint8_t *bp, int nbits); /* Optionally flush file to disk and discard page cache */ -int discard_file_cache(int fd, int flush); +void discard_file_cache(int fd, int flush); #endif /* __XC_PRIVATE_H__ */ diff --git a/tools/libxc/xc_solaris.c b/tools/libxc/xc_solaris.c index 4c537291e8..65008115ea 100644 --- a/tools/libxc/xc_solaris.c +++ b/tools/libxc/xc_solaris.c @@ -244,8 +244,7 @@ int xc_evtchn_unmask(int xce_handle, evtchn_port_t port) } /* Optionally flush file to disk and discard page cache */ -int discard_file_cache(int fd, int flush) +void discard_file_cache(int fd, int flush) { // TODO: Implement for Solaris! - return 0; } |