Just move the code into qemuBuildObjectSecretCommandLine. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- src/qemu/qemu_command.c | 57 +++++++++++-------------------------------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6920379..3fda234 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -523,52 +523,11 @@ qemuNetworkDriveGetPort(int protocol, /** - * qemuBuildSecretInfoProps: - * @secinfo: pointer to the secret info object - * @type: returns a pointer to a character string for object name - * @props: json properties to return - * - * Build the JSON properties for the secret info type. - * - * Returns 0 on success with the filled in JSON property; otherwise, - * returns -1 on failure error message set. - */ -static int -qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo, - const char **type, - virJSONValuePtr *propsret) -{ - int ret = -1; - char *keyid = NULL; - - *type = "secret"; - - if (!(keyid = qemuDomainGetMasterKeyAlias())) - return -1; - - if (virJSONValueObjectCreate(propsret, - "s:data", secinfo->s.aes.ciphertext, - "s:keyid", keyid, - "s:iv", secinfo->s.aes.iv, - "s:format", "base64", NULL) < 0) - goto cleanup; - - ret = 0; - - cleanup: - VIR_FREE(keyid); - - return ret; -} - - -/** * qemuBuildObjectSecretCommandLine: * @cmd: the command to modify * @secinfo: pointer to the secret info object * - * If the secinfo is available and associated with an AES secret, - * then format the command line for the secret object. This object + * Format the command line for the AES secret object. This object * will be referenced by the device that needs/uses it, so it needs * to be in place first. * @@ -579,14 +538,21 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd, qemuDomainSecretInfoPtr secinfo) { int ret = -1; + char *keyid = NULL; virJSONValuePtr props = NULL; - const char *type; char *tmp = NULL; - if (qemuBuildSecretInfoProps(secinfo, &type, &props) < 0) + if (!(keyid = qemuDomainGetMasterKeyAlias())) return -1; - if (!(tmp = virQEMUBuildObjectCommandlineFromJSON(type, + if (virJSONValueObjectCreate(&props, + "s:data", secinfo->s.aes.ciphertext, + "s:keyid", keyid, + "s:iv", secinfo->s.aes.iv, + "s:format", "base64", NULL) < 0) + goto cleanup; + + if (!(tmp = virQEMUBuildObjectCommandlineFromJSON("secret", secinfo->s.aes.alias, props))) goto cleanup; @@ -597,6 +563,7 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd, cleanup: virJSONValueFree(props); VIR_FREE(tmp); + VIR_FREE(keyid); return ret; } -- 2.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list