提交 a15de75d 编写于 作者: D Daniel Henrique Barboza 提交者: Cole Robinson

qemu: command: move qemuBuildSmartcardCommandLine validation to qemu_domain.c

Move smartcard validation being done by qemuBuildSmartcardCommandLine()
to the existing qemuDomainSmartcardDefValidate() function. This
function is called by qemuDomainDeviceDefValidate(), allowing smartcard
validation in domain define time.

Tests were adapted to consider the new caps being needed in
this earlier stage.
Reviewed-by: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NDaniel Henrique Barboza <danielhb413@gmail.com>
上级 379e955e
......@@ -8280,24 +8280,10 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
switch (smartcard->type) {
case VIR_DOMAIN_SMARTCARD_TYPE_HOST:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCID_EMULATED)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary lacks smartcard host "
"mode support"));
return -1;
}
virBufferAddLit(&opt, "ccid-card-emulated,backend=nss-emulated");
break;
case VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCID_EMULATED)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary lacks smartcard host "
"mode support"));
return -1;
}
virBufferAddLit(&opt, "ccid-card-emulated,backend=certificates");
for (i = 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) {
virBufferAsprintf(&opt, ",cert%zu=", i + 1);
......@@ -8313,13 +8299,6 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
break;
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCID_PASSTHRU)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary lacks smartcard "
"passthrough mode support"));
return -1;
}
if (!(devstr = qemuBuildChrChardevStr(logManager, secManager,
cmd, cfg, def,
smartcard->data.passthru,
......@@ -8335,9 +8314,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected smartcard type %d"),
smartcard->type);
virReportEnumRangeError(virDomainSmartcardType, smartcard->type);
return -1;
}
......
......@@ -6156,6 +6156,39 @@ static int
qemuDomainSmartcardDefValidate(const virDomainSmartcardDef *def,
virQEMUCapsPtr qemuCaps)
{
switch (def->type) {
case VIR_DOMAIN_SMARTCARD_TYPE_HOST:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCID_EMULATED)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary lacks smartcard host "
"mode support"));
return -1;
}
break;
case VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCID_EMULATED)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary lacks smartcard host "
"mode support"));
return -1;
}
break;
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CCID_PASSTHRU)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this QEMU binary lacks smartcard "
"passthrough mode support"));
return -1;
}
break;
default:
virReportEnumRangeError(virDomainSmartcardType, def->type);
return -1;
}
if (def->type == VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH &&
qemuDomainChrSourceDefValidate(def->data.passthru, qemuCaps) < 0)
return -1;
......
......@@ -1332,12 +1332,13 @@ mymain(void)
DO_TEST("cpu-check-default-partial2", NONE);
DO_TEST("vmcoreinfo", NONE);
DO_TEST("smartcard-host", NONE);
DO_TEST("smartcard-host-certificates", NONE);
DO_TEST("smartcard-host-certificates-database", NONE);
DO_TEST("smartcard-passthrough-tcp", NONE);
DO_TEST("smartcard-passthrough-spicevmc", NONE);
DO_TEST("smartcard-controller", NONE);
DO_TEST("smartcard-host", QEMU_CAPS_CCID_EMULATED);
DO_TEST("smartcard-host-certificates", QEMU_CAPS_CCID_EMULATED);
DO_TEST("smartcard-host-certificates-database",
QEMU_CAPS_CCID_EMULATED);
DO_TEST("smartcard-passthrough-tcp", QEMU_CAPS_CCID_PASSTHRU);
DO_TEST("smartcard-passthrough-spicevmc", QEMU_CAPS_CCID_PASSTHRU);
DO_TEST("smartcard-controller", QEMU_CAPS_CCID_EMULATED);
DO_TEST("pseries-cpu-compat-power9",
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
......@@ -1352,7 +1353,8 @@ mymain(void)
QEMU_CAPS_OBJECT_MEMORY_FILE,
QEMU_CAPS_PIIX_DISABLE_S3,
QEMU_CAPS_PIIX_DISABLE_S4,
QEMU_CAPS_VNC);
QEMU_CAPS_VNC,
QEMU_CAPS_CCID_EMULATED);
DO_TEST("input-virtio-ccw",
QEMU_CAPS_CCW,
QEMU_CAPS_VIRTIO_KEYBOARD,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册