Commit 5f258577 authored by Evgeny Yakovlev's avatar Evgeny Yakovlev Committed by Stefan Hajnoczi
Browse files

virtio-blk: advertise F_WCE (F_FLUSH) if F_CONFIG_WCE is advertised



Virtio spec 1.1 (and earlier), 5.2.5.2 Driver Requirements: Device
Initialization:

"Devices SHOULD always offer VIRTIO_BLK_F_FLUSH, and MUST offer it if
they offer VIRTIO_BLK_F_CONFIG_WCE"

Currently F_CONFIG_WCE and F_WCE are not connected to each other.
Qemu will advertise F_CONFIG_WCE if config-wce argument is
set for virtio-blk device. And F_WCE is advertised only if
underlying block backend actually has it's caching enabled.

Fix this by advertising F_WCE if F_CONFIG_WCE is also advertised.

To preserve backwards compatibility with newer machine types make this
behaviour governed by "x-enable-wce-if-config-wce" virtio-blk-device
property and introduce hw_compat_4_2 with new property being off by
default for all machine types <= 4.2 (but don't introduce 4.3
machine type itself yet).

Signed-off-by: default avatarEvgeny Yakovlev <wrfsh@yandex-team.ru>
Message-Id: <1572978137-189218-1-git-send-email-wrfsh@yandex-team.ru>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent b0ca999a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2149,6 +2149,7 @@ type_init(machvirt_machine_init);

static void virt_machine_4_2_options(MachineClass *mc)
{
    compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
}
DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)

+5 −1
Original line number Diff line number Diff line
@@ -991,7 +991,9 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
        virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
    }

    if (blk_enable_write_cache(s->blk)) {
    if (blk_enable_write_cache(s->blk) ||
        (s->conf.x_enable_wce_if_config_wce &&
         virtio_has_feature(features, VIRTIO_BLK_F_CONFIG_WCE))) {
        virtio_add_feature(&features, VIRTIO_BLK_F_WCE);
    }
    if (blk_is_read_only(s->blk)) {
@@ -1270,6 +1272,8 @@ static Property virtio_blk_properties[] = {
                       conf.max_discard_sectors, BDRV_REQUEST_MAX_SECTORS),
    DEFINE_PROP_UINT32("max-write-zeroes-sectors", VirtIOBlock,
                       conf.max_write_zeroes_sectors, BDRV_REQUEST_MAX_SECTORS),
    DEFINE_PROP_BOOL("x-enable-wce-if-config-wce", VirtIOBlock,
                     conf.x_enable_wce_if_config_wce, true),
    DEFINE_PROP_END_OF_LIST(),
};

+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@
#include "hw/pci/pci.h"
#include "hw/mem/nvdimm.h"

GlobalProperty hw_compat_4_2[] = {
    { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" },
};
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);

GlobalProperty hw_compat_4_1[] = {
    { "virtio-pci", "x-pcie-flr-init", "off" },
};
+1 −0
Original line number Diff line number Diff line
@@ -431,6 +431,7 @@ static void pc_i440fx_4_2_machine_options(MachineClass *m)
    m->alias = "pc";
    m->is_default = 1;
    pcmc->default_cpu_version = 1;
    compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
}

DEFINE_I440FX_MACHINE(v4_2, "pc-i440fx-4.2", NULL,
+1 −0
Original line number Diff line number Diff line
@@ -354,6 +354,7 @@ static void pc_q35_4_2_machine_options(MachineClass *m)
    pc_q35_machine_options(m);
    m->alias = "q35";
    pcmc->default_cpu_version = 1;
    compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len);
}

DEFINE_Q35_MACHINE(v4_2, "pc-q35-4.2", NULL,
Loading