mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 06:35:24 +00:00
qemu: Add virQEMUCapsSupportsGICVersion()
This utility function extracts some of the logic from virQEMUCapsFillDomainFeatureGICCaps() so that it can be used in a different context.
This commit is contained in:
parent
f2b4609723
commit
58f0152f3b
@ -4233,6 +4233,44 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virQEMUCapsSupportsGICVersion:
|
||||||
|
* @qemuCaps: QEMU capabilities
|
||||||
|
* @virtType: domain type
|
||||||
|
* @version: GIC version
|
||||||
|
*
|
||||||
|
* Checks the QEMU binary with capabilities @qemuCaps supports a specific
|
||||||
|
* GIC version for a domain of type @virtType.
|
||||||
|
*
|
||||||
|
* Returns: true if the binary supports the requested GIC version, false
|
||||||
|
* otherwise
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
|
virGICVersion version)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
||||||
|
virGICCapabilityPtr cap = &(qemuCaps->gicCapabilities[i]);
|
||||||
|
|
||||||
|
if (cap->version != version)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (virtType == VIR_DOMAIN_VIRT_KVM &&
|
||||||
|
cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (virtType == VIR_DOMAIN_VIRT_QEMU &&
|
||||||
|
cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virQEMUCapsFillDomainFeatureGICCaps:
|
* virQEMUCapsFillDomainFeatureGICCaps:
|
||||||
* @qemuCaps: QEMU capabilities
|
* @qemuCaps: QEMU capabilities
|
||||||
@ -4257,7 +4295,7 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps,
|
|||||||
virDomainCapsPtr domCaps)
|
virDomainCapsPtr domCaps)
|
||||||
{
|
{
|
||||||
virDomainCapsFeatureGICPtr gic = &domCaps->gic;
|
virDomainCapsFeatureGICPtr gic = &domCaps->gic;
|
||||||
size_t i;
|
virGICVersion version;
|
||||||
|
|
||||||
if (domCaps->arch != VIR_ARCH_ARMV7L &&
|
if (domCaps->arch != VIR_ARCH_ARMV7L &&
|
||||||
domCaps->arch != VIR_ARCH_AARCH64)
|
domCaps->arch != VIR_ARCH_AARCH64)
|
||||||
@ -4267,20 +4305,17 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps,
|
|||||||
!STRPREFIX(domCaps->machine, "virt-"))
|
!STRPREFIX(domCaps->machine, "virt-"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < qemuCaps->ngicCapabilities; i++) {
|
for (version = VIR_GIC_VERSION_LAST - 1;
|
||||||
virGICCapabilityPtr cap = &qemuCaps->gicCapabilities[i];
|
version > VIR_GIC_VERSION_NONE;
|
||||||
|
version--) {
|
||||||
if (domCaps->virttype == VIR_DOMAIN_VIRT_KVM &&
|
if (!virQEMUCapsSupportsGICVersion(qemuCaps,
|
||||||
!(cap->implementation & VIR_GIC_IMPLEMENTATION_KERNEL))
|
domCaps->virttype,
|
||||||
continue;
|
version))
|
||||||
|
|
||||||
if (domCaps->virttype == VIR_DOMAIN_VIRT_QEMU &&
|
|
||||||
!(cap->implementation & VIR_GIC_IMPLEMENTATION_EMULATED))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
gic->supported = true;
|
gic->supported = true;
|
||||||
VIR_DOMAIN_CAPS_ENUM_SET(gic->version,
|
VIR_DOMAIN_CAPS_ENUM_SET(gic->version,
|
||||||
cap->version);
|
version);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -463,6 +463,10 @@ bool virQEMUCapsSupportsChardev(const virDomainDef *def,
|
|||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
virDomainChrDefPtr chr);
|
virDomainChrDefPtr chr);
|
||||||
|
|
||||||
|
bool virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType virtType,
|
||||||
|
virGICVersion version);
|
||||||
|
|
||||||
bool virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
bool virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps,
|
||||||
const char *canonical_machine);
|
const char *canonical_machine);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user