On Tue, Aug 20, 2024 at 11:28:05 +0200, Anthony Harivel wrote: > Hi Peter, > > > These test cases parse an XML and format it back. > > > > You've got a bug in the code formatting the socket into the XML: > > > > if (def->kvm_features->socket == NULL) { > > virBufferAsprintf(&childBuf, " socket='%s'/>\n", > > def->kvm_features->socket); > > } else { > > virBufferAddLit(&childBuf, "/>\n"); > > } > > > > > > The above hunk formats the socket only if it's NULL, and skips it if > > it's non-null (inverted condition). > > > > Doh! I think it's time for me to take some PTO... > > Thank you ! > > > However, I tried my best to follow your advice using > virBufferEscapeString() so that i can get rid of the condition on the > socket but it fails for "feature-off". > > But this is passing the test suite: I meant like this: if (def->kvm_features->features[j] != VIR_TRISTATE_SWITCH_ABSENT) { virBufferAsprintf(&childBuf, "<%s state='%s'", virDomainKVMTypeToString(j), virTristateSwitchTypeToString(def->kvm_features->features[j])); virBufferEscapeString(&childBuf, " socket='%s'", def->kvm_features->socket); virBufferAddLit(&childBuf, "/>\n"); } (note also the fixed alinment) Note that the parser should also disallow the socket path if the feature is explicitly off.