plugin: qemu block device: add hints option and EFI disk hint
For '-drive', qemu-server sets special cache options for EFI disk using RBD. In preparation to seamlessly switch to the new '-blockdev' interface, do the same here. Note that the issue from bug #3329, which is solved by these cache options, still affects current versions. With -blockdev, the cache options are split up. While cache.direct and cache.no-flush can be set in the -blockdev options, cache.writeback is a front-end property and was intentionally removed from the -blockdev options by QEMU commit aaa436f998 ("block: Remove cache.writeback from blockdev-add"). It needs to be configured as the 'write-cache' property for the ide-hd/scsi-hd/virtio-blk device. The default is already 'writeback' and no cache mode can be set for an EFI drive configuration in Proxmox VE currently, so there will not be a clash. ┌─────────────┬─────────────────┬──────────────┬────────────────┐ │ │ cache.writeback │ cache.direct │ cache.no-flush │ ├─────────────┼─────────────────┼──────────────┼────────────────┤ │writeback │ on │ off │ off │ ├─────────────┼─────────────────┼──────────────┼────────────────┤ │none │ on │ on │ off │ ├─────────────┼─────────────────┼──────────────┼────────────────┤ │writethrough │ off │ off │ off │ ├─────────────┼─────────────────┼──────────────┼────────────────┤ │directsync │ off │ on │ off │ ├─────────────┼─────────────────┼──────────────┼────────────────┤ │unsafe │ on │ off │ on │ └─────────────┴─────────────────┴──────────────┴────────────────┘ Table from 'man kvm'. Alternatively, the option could only be set once when allocating the RBD volume. However, then we would need to detect all cases were a volume could potentially be used as an EFI disk later. Having a custom disk type would help a lot there. The approach here was chosen as it is catch-all and should not be too costly either. Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
committed by
Fabian Grünbichler
parent
f9c390bdfd
commit
590fb76238
@ -374,6 +374,16 @@ my sub rbd_volume_exists {
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Needs to be public, so qemu-server can mock it for cfg2cmd.
|
||||
sub rbd_volume_config_set {
|
||||
my ($scfg, $storeid, $volname, $key, $value) = @_;
|
||||
|
||||
my $cmd = $rbd_cmd->($scfg, $storeid, 'config', 'image', 'set', $volname, $key, $value);
|
||||
run_rbd_command($cmd, errmsg => "rbd config image set $volname $key $value error");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# Configuration
|
||||
|
||||
sub type {
|
||||
@ -514,7 +524,7 @@ sub path {
|
||||
}
|
||||
|
||||
sub qemu_blockdev_options {
|
||||
my ($class, $scfg, $storeid, $volname) = @_;
|
||||
my ($class, $scfg, $storeid, $volname, $options) = @_;
|
||||
|
||||
my $cmd_option = PVE::CephConfig::ceph_connect_option($scfg, $storeid);
|
||||
my ($name) = ($class->parse_volname($volname))[1];
|
||||
@ -547,6 +557,14 @@ sub qemu_blockdev_options {
|
||||
|
||||
$blockdev->{user} = "$cmd_option->{userid}" if $cmd_option->{keyring};
|
||||
|
||||
# SPI flash does lots of read-modify-write OPs, without writeback this gets really slow #3329
|
||||
if ($options->{hints}->{'efi-disk'}) {
|
||||
# Querying the value would just cost more and the 'rbd image config get' command will just
|
||||
# fail if the config has not been set yet, so it's not even straight-forward to do so.
|
||||
# Simply set the value (possibly again).
|
||||
rbd_volume_config_set($scfg, $storeid, $name, 'rbd_cache_policy', 'writeback');
|
||||
}
|
||||
|
||||
return $blockdev;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user