On Tue, Jan 4, 2011 at 2:33 PM, Juan Quintela <quint...@redhat.com> wrote: > Linux allows to invalidate block devices. This is needed for the incoming > migration part. > > Signed-off-by: Juan Quintela <quint...@redhat.com> > --- > block.h | 2 ++ > block/raw-posix.c | 24 ++++++++++++++++++++++++ > blockdev.c | 9 +++++---- > 3 files changed, 31 insertions(+), 4 deletions(-) > > diff --git a/block.h b/block.h > index f923add..5ac96a5 100644 > --- a/block.h > +++ b/block.h > @@ -34,6 +34,8 @@ typedef struct QEMUSnapshotInfo { > #define BDRV_O_NATIVE_AIO 0x0080 /* use native AIO instead of the thread > pool */ > #define BDRV_O_NO_BACKING 0x0100 /* don't open the backing file */ > #define BDRV_O_NO_FLUSH 0x0200 /* disable flushing on this disk */ > +#define BDRV_O_INVALIDATE 0x0400 /* invalidate buffer cache for this device. > + re-read things from server */ > > #define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | > BDRV_O_NO_FLUSH) > > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 6b72470..9439cf1 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -51,6 +51,7 @@ > #include <sys/param.h> > #include <linux/cdrom.h> > #include <linux/fd.h> > +#include <linux/fs.h> > #endif > #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) > #include <signal.h> > @@ -168,6 +169,29 @@ static int raw_open_common(BlockDriverState *bs, const > char *filename, > s->fd = fd; > s->aligned_buf = NULL; > > +#ifdef __linux__ > + if ((bdrv_flags & BDRV_O_INVALIDATE)) { > + struct stat buf; > + int res; > + > + res = fstat(fd, &buf); > + > + if (res < 0) { > + return -errno; > + } > + > + if (S_ISBLK(buf.st_mode)) { > + printf("we are in a block device: %s\n", filename);
Leftover debugging?