[libvirt] [PATCH v2 3/4] qemu: move qemuBuildSmartcardCommandLine validation to qemu_domain.c
Cole Robinson
crobinso at redhat.com
Wed Dec 18 18:04:48 UTC 2019
On 12/17/19 7:36 PM, Daniel Henrique Barboza wrote:
> 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.
>
> Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> ---
> src/qemu/qemu_command.c | 24 ------------------------
> src/qemu/qemu_domain.c | 33 +++++++++++++++++++++++++++++++++
> tests/qemuxml2xmltest.c | 16 +++++++++-------
> 3 files changed, 42 insertions(+), 31 deletions(-)
>
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index b3f069d5d4..67f7caf9c6 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -8275,24 +8275,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);
> @@ -8308,13 +8294,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,
> @@ -8330,9 +8309,6 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
> break;
>
> default:
> - virReportError(VIR_ERR_INTERNAL_ERROR,
> - _("unexpected smartcard type %d"),
> - smartcard->type);
> return -1;
> }
>
We want a virReportEnumRangeError here too. I fixed that and pushed this
series
Thanks,
Cole
More information about the libvir-list
mailing list