提交 ffd151d1 编写于 作者: P Peter Krempa

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 caa6dc3b
......@@ -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
virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
virQEMUCapsFillDomainFeaturesFromQEMUCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
{
domCaps->features[VIR_DOMAIN_CAPS_FEATURE_IOTHREADS] = virTristateBoolFromBool(
virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD));
size_t i;
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;
virDomainCapsFeaturesInitUnsupported(domCaps);
virQEMUCapsFillDomainFeaturesFromQEMUCaps(qemuCaps, domCaps);
domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
domCaps->machine);
......@@ -5584,12 +5605,6 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
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,
domCaps->machine,
domCaps->arch,
......@@ -5598,7 +5613,6 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps,
return -1;
virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps);
virQEMUCapsFillDomainIOThreadCaps(qemuCaps, domCaps);
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, domCaps->machine, disk);
virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics);
virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册