]> git.proxmox.com Git - qemu.git/blobdiff - block.c
block: add discard support
[qemu.git] / block.c
diff --git a/block.c b/block.c
index fe07d0bbfbf80a63b04e3085658c892890268f4d..9b5e9e11fee511257edf0c4b18716fe7dbc5e0d1 100644 (file)
--- a/block.c
+++ b/block.c
@@ -1515,6 +1515,17 @@ int bdrv_has_zero_init(BlockDriverState *bs)
     return 1;
 }
 
+int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)
+{
+    if (!bs->drv) {
+        return -ENOMEDIUM;
+    }
+    if (!bs->drv->bdrv_discard) {
+        return 0;
+    }
+    return bs->drv->bdrv_discard(bs, sector_num, nb_sectors);
+}
+
 /*
  * Returns true iff the specified sector is present in the disk image. Drivers
  * not implementing the functionality are assumed to not support backing files,