qemu: Handle hotplug and commandline for secret objects for http cookies

Implement both commandline support and hotplug by adding the http cookie
handling to 'qemuBlockStorageSourceAttachData' handling functions for
it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-03-09 09:14:07 +01:00
parent 877cd35887
commit b512935b17
3 changed files with 21 additions and 0 deletions

View File

@ -1499,11 +1499,13 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr data)
virJSONValueFree(data->formatProps); virJSONValueFree(data->formatProps);
virJSONValueFree(data->prmgrProps); virJSONValueFree(data->prmgrProps);
virJSONValueFree(data->authsecretProps); virJSONValueFree(data->authsecretProps);
virJSONValueFree(data->httpcookiesecretProps);
virJSONValueFree(data->encryptsecretProps); virJSONValueFree(data->encryptsecretProps);
virJSONValueFree(data->tlsProps); virJSONValueFree(data->tlsProps);
VIR_FREE(data->tlsAlias); VIR_FREE(data->tlsAlias);
VIR_FREE(data->authsecretAlias); VIR_FREE(data->authsecretAlias);
VIR_FREE(data->encryptsecretAlias); VIR_FREE(data->encryptsecretAlias);
VIR_FREE(data->httpcookiesecretAlias);
VIR_FREE(data->driveCmd); VIR_FREE(data->driveCmd);
VIR_FREE(data->driveAlias); VIR_FREE(data->driveAlias);
VIR_FREE(data); VIR_FREE(data);
@ -1570,6 +1572,11 @@ qemuBlockStorageSourceAttachApplyStorageDeps(qemuMonitorPtr mon,
&data->authsecretAlias) < 0) &data->authsecretAlias) < 0)
return -1; return -1;
if (data->httpcookiesecretProps &&
qemuMonitorAddObject(mon, &data->httpcookiesecretProps,
&data->httpcookiesecretAlias) < 0)
return -1;
if (data->tlsProps && if (data->tlsProps &&
qemuMonitorAddObject(mon, &data->tlsProps, &data->tlsAlias) < 0) qemuMonitorAddObject(mon, &data->tlsProps, &data->tlsAlias) < 0)
return -1; return -1;
@ -1713,6 +1720,9 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr mon,
if (data->encryptsecretAlias) if (data->encryptsecretAlias)
ignore_value(qemuMonitorDelObject(mon, data->encryptsecretAlias)); ignore_value(qemuMonitorDelObject(mon, data->encryptsecretAlias));
if (data->httpcookiesecretAlias)
ignore_value(qemuMonitorDelObject(mon, data->httpcookiesecretAlias));
if (data->tlsAlias) if (data->tlsAlias)
ignore_value(qemuMonitorDelObject(mon, data->tlsAlias)); ignore_value(qemuMonitorDelObject(mon, data->tlsAlias));
@ -1768,6 +1778,9 @@ qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src,
if (srcpriv->encinfo && srcpriv->encinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) if (srcpriv->encinfo && srcpriv->encinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
data->encryptsecretAlias = g_strdup(srcpriv->encinfo->s.aes.alias); data->encryptsecretAlias = g_strdup(srcpriv->encinfo->s.aes.alias);
if (srcpriv->httpcookie)
data->httpcookiesecretAlias = g_strdup(srcpriv->httpcookie->s.aes.alias);
} }
return g_steal_pointer(&data); return g_steal_pointer(&data);

View File

@ -100,6 +100,9 @@ struct qemuBlockStorageSourceAttachData {
virJSONValuePtr encryptsecretProps; virJSONValuePtr encryptsecretProps;
char *encryptsecretAlias; char *encryptsecretAlias;
virJSONValuePtr httpcookiesecretProps;
char *httpcookiesecretAlias;
virJSONValuePtr tlsProps; virJSONValuePtr tlsProps;
char *tlsAlias; char *tlsAlias;
}; };

View File

@ -2398,6 +2398,7 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
if (qemuBuildObjectCommandline(cmd, data->prmgrProps) < 0 || if (qemuBuildObjectCommandline(cmd, data->prmgrProps) < 0 ||
qemuBuildObjectCommandline(cmd, data->authsecretProps) < 0 || qemuBuildObjectCommandline(cmd, data->authsecretProps) < 0 ||
qemuBuildObjectCommandline(cmd, data->encryptsecretProps) < 0 || qemuBuildObjectCommandline(cmd, data->encryptsecretProps) < 0 ||
qemuBuildObjectCommandline(cmd, data->httpcookiesecretProps) < 0 ||
qemuBuildObjectCommandline(cmd, data->tlsProps) < 0) qemuBuildObjectCommandline(cmd, data->tlsProps) < 0)
return -1; return -1;
@ -10333,6 +10334,10 @@ qemuBuildStorageSourceAttachPrepareCommon(virStorageSourcePtr src,
if (srcpriv->encinfo && if (srcpriv->encinfo &&
qemuBuildSecretInfoProps(srcpriv->encinfo, &data->encryptsecretProps) < 0) qemuBuildSecretInfoProps(srcpriv->encinfo, &data->encryptsecretProps) < 0)
return -1; return -1;
if (srcpriv->httpcookie &&
qemuBuildSecretInfoProps(srcpriv->httpcookie, &data->httpcookiesecretProps) < 0)
return -1;
} }
if (src->haveTLS == VIR_TRISTATE_BOOL_YES && if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&