mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
qemu: domcaps: Simplify adding new domaincaps based on qemu caps
Add a helper which converts qemu emulator capabilities to the domain capability XML. This will simplify future additions of new features. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
caa6dc3b31
commit
ffd151d17b
@ -5281,12 +5281,32 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct virQEMUCapsDomainFeatureCapabilityTuple {
|
||||||
|
virDomainCapsFeature domcap;
|
||||||
|
virQEMUCapsFlags qemucap;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This maps the qemu features to the entries in <features> of the domain
|
||||||
|
* capability XML.
|
||||||
|
* */
|
||||||
|
static const struct virQEMUCapsDomainFeatureCapabilityTuple domCapsTuples[] = {
|
||||||
|
{ VIR_DOMAIN_CAPS_FEATURE_IOTHREADS, QEMU_CAPS_OBJECT_IOTHREAD },
|
||||||
|
{ VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO, QEMU_CAPS_DEVICE_VMCOREINFO },
|
||||||
|
{ VIR_DOMAIN_CAPS_FEATURE_GENID, QEMU_CAPS_DEVICE_VMGENID },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps,
|
virQEMUCapsFillDomainFeaturesFromQEMUCaps(virQEMUCapsPtr qemuCaps,
|
||||||
virDomainCapsPtr domCaps)
|
virDomainCapsPtr domCaps)
|
||||||
{
|
{
|
||||||
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_IOTHREADS] = virTristateBoolFromBool(
|
size_t i;
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD));
|
|
||||||
|
for (i = 0; i < G_N_ELEMENTS(domCapsTuples); i++) {
|
||||||
|
if (virQEMUCapsGet(qemuCaps, domCapsTuples[i].qemucap))
|
||||||
|
domCaps->features[domCapsTuples[i].domcap] = VIR_TRISTATE_BOOL_YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -5572,6 +5592,7 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
|
|||||||
virDomainCapsDeviceRNGPtr rng = &domCaps->rng;
|
virDomainCapsDeviceRNGPtr rng = &domCaps->rng;
|
||||||
|
|
||||||
virDomainCapsFeaturesInitUnsupported(domCaps);
|
virDomainCapsFeaturesInitUnsupported(domCaps);
|
||||||
|
virQEMUCapsFillDomainFeaturesFromQEMUCaps(qemuCaps, domCaps);
|
||||||
|
|
||||||
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
|
||||||
domCaps->machine);
|
domCaps->machine);
|
||||||
@ -5584,12 +5605,6 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
|
|||||||
domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus);
|
domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus);
|
||||||
}
|
}
|
||||||
|
|
||||||
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_VMCOREINFO] = virTristateBoolFromBool(
|
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO));
|
|
||||||
|
|
||||||
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_GENID] = virTristateBoolFromBool(
|
|
||||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID));
|
|
||||||
|
|
||||||
if (virQEMUCapsFillDomainOSCaps(os,
|
if (virQEMUCapsFillDomainOSCaps(os,
|
||||||
domCaps->machine,
|
domCaps->machine,
|
||||||
domCaps->arch,
|
domCaps->arch,
|
||||||
@ -5598,7 +5613,6 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps);
|
virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps);
|
||||||
virQEMUCapsFillDomainIOThreadCaps(qemuCaps, domCaps);
|
|
||||||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk);
|
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk);
|
||||||
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics);
|
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics);
|
||||||
virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video);
|
virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user