mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemu: Remove extra logic around QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
ec91195ead
commit
89c40977f2
@ -6157,8 +6157,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCaps *qemuCaps,
|
|||||||
|
|
||||||
/* disk->model values */
|
/* disk->model values */
|
||||||
VIR_DOMAIN_CAPS_ENUM_SET(disk->model, VIR_DOMAIN_DISK_MODEL_VIRTIO);
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->model, VIR_DOMAIN_DISK_MODEL_VIRTIO);
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY) ||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
|
||||||
VIR_DOMAIN_CAPS_ENUM_SET(disk->model,
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->model,
|
||||||
VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL);
|
VIR_DOMAIN_DISK_MODEL_VIRTIO_TRANSITIONAL);
|
||||||
VIR_DOMAIN_CAPS_ENUM_SET(disk->model,
|
VIR_DOMAIN_CAPS_ENUM_SET(disk->model,
|
||||||
@ -6275,8 +6274,7 @@ virQEMUCapsFillDomainDeviceRNGCaps(virQEMUCaps *qemuCaps,
|
|||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) {
|
||||||
VIR_DOMAIN_CAPS_ENUM_SET(rng->model, VIR_DOMAIN_RNG_MODEL_VIRTIO);
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->model, VIR_DOMAIN_RNG_MODEL_VIRTIO);
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) ||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) {
|
|
||||||
VIR_DOMAIN_CAPS_ENUM_SET(rng->model,
|
VIR_DOMAIN_CAPS_ENUM_SET(rng->model,
|
||||||
VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
|
VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL,
|
||||||
VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL);
|
VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL);
|
||||||
|
@ -952,9 +952,7 @@ static int
|
|||||||
qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device,
|
qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device,
|
||||||
virQEMUCaps *qemuCaps,
|
virQEMUCaps *qemuCaps,
|
||||||
char **devtype,
|
char **devtype,
|
||||||
virDomainVirtioOptions **virtioOptions,
|
virDomainVirtioOptions **virtioOptions)
|
||||||
virTristateSwitch *disableLegacy,
|
|
||||||
virTristateSwitch *disableModern)
|
|
||||||
{
|
{
|
||||||
virDomainDeviceInfo *info = virDomainDeviceGetInfo(device);
|
virDomainDeviceInfo *info = virDomainDeviceGetInfo(device);
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
@ -964,9 +962,6 @@ qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device,
|
|||||||
bool has_ntmodel = false;
|
bool has_ntmodel = false;
|
||||||
bool useBusSuffix = true;
|
bool useBusSuffix = true;
|
||||||
|
|
||||||
*disableLegacy = VIR_TRISTATE_SWITCH_ABSENT;
|
|
||||||
*disableModern = VIR_TRISTATE_SWITCH_ABSENT;
|
|
||||||
|
|
||||||
qemuBuildVirtioDevGetConfigDev(device, qemuCaps, &baseName,
|
qemuBuildVirtioDevGetConfigDev(device, qemuCaps, &baseName,
|
||||||
virtioOptions, &has_tmodel,
|
virtioOptions, &has_tmodel,
|
||||||
&has_ntmodel, &useBusSuffix);
|
&has_ntmodel, &useBusSuffix);
|
||||||
@ -1026,9 +1021,6 @@ qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device,
|
|||||||
if (has_tmodel) {
|
if (has_tmodel) {
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
||||||
virBufferAddLit(&buf, "-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
|
/* No error if -transitional is not supported: our address
|
||||||
* allocation will force the device into plain PCI bus, which
|
* allocation will force the device into plain PCI bus, which
|
||||||
@ -1037,12 +1029,6 @@ qemuBuildVirtioDevGetConfig(const virDomainDeviceDef *device,
|
|||||||
} else if (has_ntmodel) {
|
} else if (has_ntmodel) {
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
||||||
virBufferAddLit(&buf, "-non-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 {
|
} else {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("virtio non-transitional model not supported for this qemu"));
|
_("virtio non-transitional model not supported for this qemu"));
|
||||||
@ -1073,8 +1059,6 @@ qemuBuildVirtioDevProps(virDomainDeviceType devtype,
|
|||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
const virDomainDeviceDef device = { .type = devtype };
|
const virDomainDeviceDef device = { .type = devtype };
|
||||||
g_autofree char *model = NULL;
|
g_autofree char *model = NULL;
|
||||||
virTristateSwitch disableLegacy = VIR_TRISTATE_SWITCH_ABSENT;
|
|
||||||
virTristateSwitch disableModern = VIR_TRISTATE_SWITCH_ABSENT;
|
|
||||||
virDomainVirtioOptions *virtioOptions = NULL;
|
virDomainVirtioOptions *virtioOptions = NULL;
|
||||||
|
|
||||||
/* We temporarily cast the const away here, but that's safe to do
|
/* We temporarily cast the const away here, but that's safe to do
|
||||||
@ -1083,14 +1067,11 @@ qemuBuildVirtioDevProps(virDomainDeviceType devtype,
|
|||||||
* not touch its contents */
|
* not touch its contents */
|
||||||
virDomainDeviceSetData((virDomainDeviceDef *) &device, (void *) devdata);
|
virDomainDeviceSetData((virDomainDeviceDef *) &device, (void *) devdata);
|
||||||
|
|
||||||
if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions,
|
if (qemuBuildVirtioDevGetConfig(&device, qemuCaps, &model, &virtioOptions) < 0)
|
||||||
&disableLegacy, &disableModern) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (virJSONValueObjectAdd(&props,
|
if (virJSONValueObjectAdd(&props,
|
||||||
"s:driver", model,
|
"s:driver", model,
|
||||||
"S:disable-legacy", qemuOnOffAuto(disableLegacy),
|
|
||||||
"T:disable-modern", disableModern,
|
|
||||||
NULL) < 0)
|
NULL) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1098,8 +1098,7 @@ qemuDomainFillDevicePCIConnectFlagsIterInit(virDomainDef *def,
|
|||||||
VIR_PCI_CONNECT_AUTOASSIGN);
|
VIR_PCI_CONNECT_AUTOASSIGN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY) ||
|
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL)) {
|
|
||||||
data->virtioFlags = data->pcieFlags;
|
data->virtioFlags = data->pcieFlags;
|
||||||
} else {
|
} else {
|
||||||
data->virtioFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
|
data->virtioFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
|
||||||
|
Loading…
Reference in New Issue
Block a user