From 215e47b9ea2cd7926333b7dc683024aa00e0c386 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 8 Feb 2013 14:06:14 +0100 Subject: blockdev: enable discard by default Because discard is now a host parameter, we can always fake it as enabled in the guest. This is an extension of the current choice to ignore "not supported" errors from the host when discard_granularity is set to nonzero. The default granularity is set to the logical block size or 4k, whichever is largest, because cluster sizes below 4k are rarely used and 4K is a typical block size for files. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- hw/ide/qdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'hw/ide/qdev.c') diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index c436b38bcb..fd06da7003 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -143,7 +143,10 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); IDEState *s = bus->ifs + dev->unit; - if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) { + if (dev->conf.discard_granularity == -1) { + dev->conf.discard_granularity = 512; + } else if (dev->conf.discard_granularity && + dev->conf.discard_granularity != 512) { error_report("discard_granularity must be 512 for ide"); return -1; } -- cgit v1.2.1