The virDomainVirtioOptionsCheckABIStability() function is called from various ABI stability check functions. Every caller checks if both old and new definitions have virtio options set and only after that they call the function. This is suboptimal because: a) this check can be done in the function itself (making all callers shorter), b) is inherently wrong, because it doesn't catch case where one definition has virtio options set and the other doesn't. Do proper checks at the beginning of the function and simplify its calls. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/domain_conf.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6e90b8e180..905f8f0691 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21533,6 +21533,15 @@ static bool virDomainVirtioOptionsCheckABIStability(virDomainVirtioOptionsPtr src, virDomainVirtioOptionsPtr dst) { + if (!src && !dst) + return true; + + if (!src || !dst) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Target device virtio options don't match the source")); + return false; + } + if (src->iommu != dst->iommu) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Target device iommu option '%s' does not " @@ -21617,8 +21626,7 @@ virDomainDiskDefCheckABIStability(virDomainDiskDefPtr src, return false; } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21677,8 +21685,7 @@ virDomainControllerDefCheckABIStability(virDomainControllerDefPtr src, } } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21711,8 +21718,7 @@ virDomainFsDefCheckABIStability(virDomainFSDefPtr src, return false; } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21760,8 +21766,7 @@ virDomainNetDefCheckABIStability(virDomainNetDefPtr src, return false; } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21799,8 +21804,7 @@ virDomainInputDefCheckABIStability(virDomainInputDefPtr src, return false; } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -21899,8 +21903,7 @@ virDomainVideoDefCheckABIStability(virDomainVideoDefPtr src, } } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -22113,8 +22116,7 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src, return false; } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) @@ -22136,8 +22138,7 @@ virDomainRNGDefCheckABIStability(virDomainRNGDefPtr src, return false; } - if (src->virtio && dst->virtio && - !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) + if (!virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) return false; if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) -- 2.26.2