aboutsummaryrefslogtreecommitdiffstats
path: root/tools/ioemu/block.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-02-27 13:21:36 +0000
committerKeir Fraser <keir.fraser@citrix.com>2008-02-27 13:21:36 +0000
commit8d54d051da3dd1fd9e7666b7b74b074676c8571f (patch)
treec9c30d1caa5c9204967e346a9932815252b65977 /tools/ioemu/block.c
parent28617ff2d019e6ee3bd1e4e487567243297ab36e (diff)
downloadxen-8d54d051da3dd1fd9e7666b7b74b074676c8571f.tar.gz
xen-8d54d051da3dd1fd9e7666b7b74b074676c8571f.tar.bz2
xen-8d54d051da3dd1fd9e7666b7b74b074676c8571f.zip
ioemu: Expandable storage backends should defeat block-device range checks.
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/ioemu/block.c')
-rw-r--r--tools/ioemu/block.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/ioemu/block.c b/tools/ioemu/block.c
index 683dd2e091..c9e27d1191 100644
--- a/tools/ioemu/block.c
+++ b/tools/ioemu/block.c
@@ -123,20 +123,23 @@ void path_combine(char *dest, int dest_size,
static int bdrv_rw_badreq_sectors(BlockDriverState *bs,
int64_t sector_num, int nb_sectors)
{
- return
+ return (
nb_sectors < 0 ||
nb_sectors > bs->total_sectors ||
- sector_num > bs->total_sectors - nb_sectors;
+ sector_num > bs->total_sectors - nb_sectors
+ ) && !bs->extendable;
}
static int bdrv_rw_badreq_bytes(BlockDriverState *bs,
int64_t offset, int count)
{
int64_t size = bs->total_sectors << SECTOR_BITS;
- return
+ return (
count < 0 ||
count > size ||
- offset > size - count;
+ offset > size - count
+ ) && !bs->extendable;
+
}
void bdrv_register(BlockDriver *bdrv)
@@ -347,6 +350,12 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
bs->is_temporary = 0;
bs->encrypted = 0;
+ if (flags & BDRV_O_EXTENDABLE) {
+ if (!(drv->bdrv_flags & BLOCK_DRIVER_FLAG_EXTENDABLE))
+ return -ENOSYS;
+ bs->extendable = 1;
+ }
+
if (flags & BDRV_O_SNAPSHOT) {
BlockDriverState *bs1;
int64_t total_size;