In a domain created with an interface with a <driver> subelement,
the device contains a non-NULL virDomainVirtioOptions struct, even
for non-virtio NIC models. The subelement need not be present again
after libvirt restarts, or when the interface is passed to clients.
When clients such as virsh domif-setlink put back the modified
interface XML, the new device's virtio attribute is NULL. This may
fail the equality checks for virtio options in qemuDomainChangeNet,
depending on whether libvird was restarted since define or not.
This patch modifies the check for non-virtio models, to ignore olddev
value of virtio (assumed valid), and to allow either NULL or a struct
with all values ABSENT in the new virtio options.
Signed-off-by: Miroslav Los <mirlos(a)cisco.com>
---
src/qemu/qemu_hotplug.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 2756d2aebd..1f4620d833 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3681,6 +3681,7 @@ qemuDomainChangeNet(virQEMUDriver *driver,
bool needVlanUpdate = false;
bool needIsolatedPortChange = false;
bool needQueryRxFilter = false;
+ bool isVirtio = false;
int ret = -1;
int changeidx = -1;
g_autoptr(virConnect) conn = NULL;
@@ -3742,7 +3743,9 @@ qemuDomainChangeNet(virQEMUDriver *driver,
goto cleanup;
}
- if (virDomainNetIsVirtioModel(olddev) &&
+ isVirtio = virDomainNetIsVirtioModel(olddev);
+
+ if (isVirtio &&
(olddev->driver.virtio.name != newdev->driver.virtio.name ||
olddev->driver.virtio.txmode != newdev->driver.virtio.txmode ||
olddev->driver.virtio.ioeventfd != newdev->driver.virtio.ioeventfd ||
@@ -3769,12 +3772,18 @@ qemuDomainChangeNet(virQEMUDriver *driver,
goto cleanup;
}
- if (!!olddev->virtio != !!newdev->virtio ||
- (olddev->virtio && newdev->virtio &&
- (olddev->virtio->iommu != newdev->virtio->iommu ||
- olddev->virtio->ats != newdev->virtio->ats ||
- olddev->virtio->packed != newdev->virtio->packed ||
- olddev->virtio->page_per_vq != newdev->virtio->page_per_vq))) {
+ if ((isVirtio &&
+ (!!olddev->virtio != !!newdev->virtio ||
+ (olddev->virtio && newdev->virtio &&
+ (olddev->virtio->iommu != newdev->virtio->iommu ||
+ olddev->virtio->ats != newdev->virtio->ats ||
+ olddev->virtio->packed != newdev->virtio->packed ||
+ olddev->virtio->page_per_vq != newdev->virtio->page_per_vq))))
||
+ (!isVirtio && newdev->virtio &&
+ (newdev->virtio->iommu != 0 ||
+ newdev->virtio->ats != 0 ||
+ newdev->virtio->packed != 0 ||
+ newdev->virtio->page_per_vq != 0))) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot modify virtio network device driver
options"));
goto cleanup;
--
2.25.1