aboutsummaryrefslogtreecommitdiff
path: root/qemu-io.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2013-02-08 14:06:11 +0100
committerKevin Wolf <kwolf@redhat.com>2013-02-22 21:29:42 +0100
commit9e8f1835ea3ab3be83634f34c1bb8b69cd871766 (patch)
tree079db917d1d60678dd098fdf53d3b549dc82191d /qemu-io.c
parent9a665b2b8640e464f0a778216fc2dca8d02acf33 (diff)
downloadqemu-9e8f1835ea3ab3be83634f34c1bb8b69cd871766.zip
qemu-9e8f1835ea3ab3be83634f34c1bb8b69cd871766.tar.gz
qemu-9e8f1835ea3ab3be83634f34c1bb8b69cd871766.tar.bz2
block: implement BDRV_O_UNMAP
It is better to present homogeneous hardware independent of the storage technology that is chosen on the host, hence we make discard a host parameter; the user can choose whether to pass it down to the image format and protocol, or to ignore it. Using DISCARD with filesystems can cause very severe fragmentation, so it is left default-off for now. This can change later when we implement the "anchor" operation for efficient management of preallocated files. There is still one choice to make: whether DISCARD has an effect on the dirty bitmap or not. I chose yes, though there is a disadvantage: if the guest is buggy and issues discards for data that is in use, there will be no way to migrate storage for that guest without downgrading the machine type to an older one. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-io.c')
-rw-r--r--qemu-io.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/qemu-io.c b/qemu-io.c
index 6188093..7b3de42 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1899,7 +1899,7 @@ int main(int argc, char **argv)
{
int readonly = 0;
int growable = 0;
- const char *sopt = "hVc:rsnmgkt:T:";
+ const char *sopt = "hVc:d:rsnmgkt:T:";
const struct option lopt[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'V' },
@@ -1911,13 +1911,14 @@ int main(int argc, char **argv)
{ "misalign", 0, NULL, 'm' },
{ "growable", 0, NULL, 'g' },
{ "native-aio", 0, NULL, 'k' },
+ { "discard", 1, NULL, 'd' },
{ "cache", 1, NULL, 't' },
{ "trace", 1, NULL, 'T' },
{ NULL, 0, NULL, 0 }
};
int c;
int opt_index = 0;
- int flags = 0;
+ int flags = BDRV_O_UNMAP;
progname = basename(argv[0]);
@@ -1929,6 +1930,12 @@ int main(int argc, char **argv)
case 'n':
flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB;
break;
+ case 'd':
+ if (bdrv_parse_discard_flags(optarg, &flags) < 0) {
+ error_report("Invalid discard option: %s", optarg);
+ exit(1);
+ }
+ break;
case 'c':
add_user_command(optarg);
break;