Thanks for volunteering to fix this after me, I did not expect that, here is my attempt: https://www.redhat.com/archives/libvir-list/2017-August/msg00134.html On Thu, Aug 03, 2017 at 07:30:43AM -0400, John Ferlan wrote:
Merge into previous... With the explanation to add smartcard xml2xml
A v2 would have been easier to read
tests. As shown below other tests already exists. This includes the aha moment where an extra > was being printed for smartcards using type= as a result of virDomainChrTypeFormat doing the printing. Needed to print the > for the other two types explicitly. Existing tests (far more exist for channel, console, serial, and parallel): tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-guestfwd.xml: ... <channel type='pipe'> <source path='/tmp/guestfwd'/> ... tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml: ... <console type='pty'> <target type='virtio' port='0'/> </console> ... tests/qemuxml2xmloutdata/qemuxml2xmlout-serial-pty.xml: ... <serial type='pty'> <target port='0'/> </serial> ... tests/qemuxml2xmloutdata/qemuxml2xmlout-parallel-tcp.xml: ... <parallel type='tcp'> <source mode='bind' host='127.0.0.1' service='9999'/> <protocol type='raw'/> ... qemuxml2xmlout-virtio-rng-egd.xml: ... <rng model='virtio'> <backend model='egd' type='tcp'> <source mode='connect' host='1.2.3.4' service='1234'/> <protocol type='raw'/> </backend> ... qemuxml2xmlout-usb-redir-filter-version.xml: ... <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='0' port='1'/> </redirdev> ... Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/conf/domain_conf.c | 3 +- .../qemuxml2xmlout-smartcard-controller.xml | 31 ++++++++++++++++++++ .../qemuxml2xmlout-smartcard-host-certificates.xml | 34 ++++++++++++++++++++++ .../qemuxml2xmlout-smartcard-host.xml | 31 ++++++++++++++++++++ ...muxml2xmlout-smartcard-passthrough-spicevmc.xml | 31 ++++++++++++++++++++ .../qemuxml2xmlout-smartcard-passthrough-tcp.xml | 33 +++++++++++++++++++++ tests/qemuxml2xmltest.c | 6 ++++ 7 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-controller.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host-certificates.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-host.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-spicevmc.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-smartcard-passthrough-tcp.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 878c15d..f758210 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23064,9 +23064,11 @@ virDomainSmartcardDefFormat(virBufferPtr buf, switch (def->type) { case VIR_DOMAIN_SMARTCARD_TYPE_HOST: + virBufferAddLit(buf, ">\n"); break; case VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES: + virBufferAddLit(buf, ">\n"); for (i = 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) { virBufferEscapeString(&childBuf, "<certificate>%s</certificate>\n", def->data.cert.file[i]); @@ -23092,7 +23094,6 @@ virDomainSmartcardDefFormat(virBufferPtr buf, return -1; if (virBufferUse(&childBuf)) { - virBufferAddLit(buf, ">\n");
This change makes the else branch pointless, since it assumes the element will be a pair one. I split the '>' addition out of the Chr.*Format functions completely, to let the callers decide.
virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "</smartcard>\n"); } else {
[...]
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index bf4d507..0d549ad 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1199,6 +1199,12 @@ mymain(void) DO_TEST("cpu-check-default-partial", NONE); DO_TEST("cpu-check-default-partial2", NONE); + DO_TEST("smartcard-host", NONE); + DO_TEST("smartcard-host-certificates", NONE); + DO_TEST("smartcard-passthrough-tcp", NONE); + DO_TEST("smartcard-passthrough-spicevmc", NONE); + DO_TEST("smartcard-controller", NONE); +
But your test cases match mine exactly :D Jan
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL) virFileDeleteTree(fakerootdir); -- 2.9.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list