The virtio-*-(non-)-transitional device models which replace the use of 'disable-legacy'/'disable-modern' features were introduced in qemu-4.0. This means we can remove the specific parts of the code for formatting the old-style device options and replace all other code to solely depend on the QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL flag. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 6 ++---- src/qemu/qemu_command.c | 23 ++--------------------- src/qemu/qemu_domain_address.c | 3 +-- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index c5338f6830..d7fe1d789d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -6157,8 +6157,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCaps *qemuCaps, /* disk->model values */ VIR_DOMAIN_CAPS_ENUM_SET(disk->model, VIR_DOMAIN_DISK_MODEL_VIRTIO); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY) || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { VIR_DOMAIN_CAPS_ENUM_SET(disk->model, VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL); VIR_DOMAIN_CAPS_ENUM_SET(disk->model, @@ -6275,8 +6274,7 @@ virQEMUCapsFillDomainDeviceRNGCaps(virQEMUCaps *qemuCaps, if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { VIR_DOMAIN_CAPS_ENUM_SET(rng->model, VIR_DOMAIN_RNG_MODEL_VIRTIO); - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { VIR_DOMAIN_CAPS_ENUM_SET(rng->model, VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL, VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index a31b8ee438..089d0493d9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -952,9 +952,7 @@ static int qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device, virQEMUCaps *qemuCaps, char **devtype, - virDomainVirtioOptions **virtioOptions, - virTristateSwitch *disableLegacy, - virTristateSwitch *disableModern) + virDomainVirtioOptions **virtioOptions) { virDomainDeviceInfo *info = virDomainDeviceGetInfo(device); g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; @@ -964,9 +962,6 @@ qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device, bool has_ntmodel = false; bool useBusSuffix = true; - *disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; - *disableModern = VIR_TRISTATE_SWITCH_ABSENT; - qemuBuildVirtioDevGetConfigDev(device, qemuCaps, &baseName, virtioOptions, &has_tmodel, &has_ntmodel, &useBusSuffix); @@ -1026,9 +1021,6 @@ qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device, if (has_tmodel) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { virBufferAddLit(&buf, "-transitional"); - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - *disableLegacy = VIR_TRISTATE_SWITCH_OFF; - *disableModern = VIR_TRISTATE_SWITCH_OFF; } /* No error if -transitional is not supported: our address * allocation will force the device into plain PCI bus, which @@ -1037,12 +1029,6 @@ qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device, } else if (has_ntmodel) { if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { virBufferAddLit(&buf, "-non-transitional"); - } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { - /* Even if the QEMU binary doesn't support the non-transitional - * device, we can still make it work by manually disabling legacy - * VirtIO and enabling modern VirtIO */ - *disableLegacy = VIR_TRISTATE_SWITCH_ON; - *disableModern = VIR_TRISTATE_SWITCH_OFF; } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio non-transitional model not supported for this qemu")); @@ -1073,8 +1059,6 @@ qemuBuildVirtioDevProps(virDomainDeviceType devtype, g_autoptr(virJSONValue) props = NULL; const virDomainDeviceDef device = { .type = devtype }; g_autofree char *model = NULL; - virTristateSwitch disableLegacy = VIR_TRISTATE_SWITCH_ABSENT; - virTristateSwitch disableModern = VIR_TRISTATE_SWITCH_ABSENT; virDomainVirtioOptions *virtioOptions = NULL; /* We temporarily cast the const away here, but that's safe to do @@ -1083,14 +1067,11 @@ qemuBuildVirtioDevProps(virDomainDeviceType devtype, * not touch its contents */ virDomainDeviceSetData((virDomainDeviceDef *) &device, (void *) devdata); - if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions, - &disableLegacy, &disableModern) < 0) + if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions) < 0) return NULL; if (virJSONValueObjectAdd(&props, "s:driver", model, - "S:disable-legacy", qemuOnOffAuto(disableLegacy), - "T:disable-modern", disableModern, NULL) < 0) return NULL; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index bd9a951899..228ac07cd5 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1098,8 +1098,7 @@ qemuDomainFillDevicePCIConnectFlagsIterInit(virDomainDef *def, VIR_PCI_CONNECT_AUTOASSIGN); } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY) || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) { data->virtioFlags = data->pcieFlags; } else { data->virtioFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE | -- 2.37.1