A bit of refactoring so that the public APIs are easier to match
to at least one driver callback, by making the internal flags
go through a new driver callback.
* docs/hvsupport.pl: Allow for internal-only callbacks.
* src/driver.h (virDrvSecretGetValue): Revert previous change.
(virDrvSecretGetValueInternal): New driver callback.
(struct _virSecretDriver): Add new callback.
* src/secret/secret_driver.c (secretGetValue): Split...
(secretGetValueInternal): ...into new function.
(secretDriver): Register internal getValue handler.
* src/libvirt.c (virSecretGetValue): Update clients.
* src/remote/remote_driver.c (remoteSecretGetValue): Likewise.
* src/qemu/qemu_process.c (qemuProcessGetVolumeQcowPassphrase):
Likewise.
---
I'm not convinced this makes life any better, but I finally got
things into shape to work if we want to go this route.
Meanwhile, I'm pushing the v4 patch as-is, so this becomes an
independent separate patch.
docs/hvsupport.pl | 4 +++-
src/driver.h | 5 +++++
src/libvirt.c | 2 +-
src/qemu/qemu_process.c | 6 +++---
src/remote/remote_driver.c | 8 +-------
src/secret/secret_driver.c | 12 ++++++++++--
6 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
index b0d1f0f..e1049e6 100755
--- a/docs/hvsupport.pl
+++ b/docs/hvsupport.pl
@@ -161,6 +161,8 @@ while (defined($line = <FILE>)) {
$api = "virConnect$name";
} elsif (exists $apis{"virNode$name"}) {
$api = "virNode$name";
+ } elsif ($name =~ /Internal$/) {
+ next;
} else {
die "driver $name does not have a public API";
}
@@ -211,7 +213,7 @@ foreach my $src (@srcs) {
my $meth = $2;
my $vers = $3;
- next if $api eq "no" || $api eq "name";
+ next if $api eq "no" || $api eq "name" || $api =~ /Internal$/;
die "Method $meth in $src is missing version" unless defined $vers;
diff --git a/src/driver.h b/src/driver.h
index 9d0d3de..759150d 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1258,6 +1258,10 @@ typedef int
typedef unsigned char *
(*virDrvSecretGetValue) (virSecretPtr secret,
size_t *value_size,
+ unsigned int flags);
+typedef unsigned char *
+ (*virDrvSecretGetValueInternal) (virSecretPtr secret,
+ size_t *value_size,
unsigned int flags,
unsigned int internalFlags);
typedef int
@@ -1295,6 +1299,7 @@ struct _virSecretDriver {
virDrvSecretGetXMLDesc getXMLDesc;
virDrvSecretSetValue setValue;
virDrvSecretGetValue getValue;
+ virDrvSecretGetValueInternal getValueInternal;
virDrvSecretUndefine undefine;
};
diff --git a/src/libvirt.c b/src/libvirt.c
index 39e2041..34acede 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -12680,7 +12680,7 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size,
unsigned int flags)
if (conn->secretDriver != NULL && conn->secretDriver->getValue !=
NULL) {
unsigned char *ret;
- ret = conn->secretDriver->getValue(secret, value_size, flags, 0);
+ ret = conn->secretDriver->getValue(secret, value_size, flags);
if (ret == NULL)
goto error;
return ret;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 448b06e..cb7575f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -257,7 +257,7 @@ qemuProcessGetVolumeQcowPassphrase(virConnectPtr conn,
if (conn->secretDriver == NULL ||
conn->secretDriver->lookupByUUID == NULL ||
- conn->secretDriver->getValue == NULL) {
+ conn->secretDriver->getValueInternal == NULL) {
qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
_("secret storage not supported"));
goto cleanup;
@@ -276,8 +276,8 @@ qemuProcessGetVolumeQcowPassphrase(virConnectPtr conn,
enc->secrets[0]->uuid);
if (secret == NULL)
goto cleanup;
- data = conn->secretDriver->getValue(secret, &size, 0,
- VIR_SECRET_GET_VALUE_INTERNAL_CALL);
+ data = conn->secretDriver->getValueInternal(secret, &size, 0,
+ VIR_SECRET_GET_VALUE_INTERNAL_CALL);
virUnrefSecret(secret);
if (data == NULL)
goto cleanup;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index c2f8bbd..d3b5df9 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3174,7 +3174,7 @@ remoteSecretClose (virConnectPtr conn)
static unsigned char *
remoteSecretGetValue (virSecretPtr secret, size_t *value_size,
- unsigned int flags, unsigned int internalFlags)
+ unsigned int flags)
{
unsigned char *rv = NULL;
remote_secret_get_value_args args;
@@ -3183,12 +3183,6 @@ remoteSecretGetValue (virSecretPtr secret, size_t *value_size,
remoteDriverLock (priv);
- /* internalFlags intentionally do not go over the wire */
- if (internalFlags) {
- remoteError(VIR_ERR_NO_SUPPORT, "%s", _("no internalFlags
support"));
- goto done;
- }
-
make_nonnull_secret (&args.secret, secret);
args.flags = flags;
diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c
index 02cdbb9..87e2b83 100644
--- a/src/secret/secret_driver.c
+++ b/src/secret/secret_driver.c
@@ -873,8 +873,9 @@ cleanup:
}
static unsigned char *
-secretGetValue(virSecretPtr obj, size_t *value_size, unsigned int flags,
- unsigned int internalFlags)
+secretGetValueInternal(virSecretPtr obj, size_t *value_size,
+ unsigned int flags,
+ unsigned int internalFlags)
{
virSecretDriverStatePtr driver = obj->conn->secretPrivateData;
unsigned char *ret = NULL;
@@ -921,6 +922,12 @@ cleanup:
return ret;
}
+static unsigned char *
+secretGetValue(virSecretPtr obj, size_t *value_size, unsigned int flags)
+{
+ return secretGetValueInternal(obj, value_size, flags, 0);
+}
+
static int
secretUndefine(virSecretPtr obj)
{
@@ -1078,6 +1085,7 @@ static virSecretDriver secretDriver = {
.getXMLDesc = secretGetXMLDesc, /* 0.7.1 */
.setValue = secretSetValue, /* 0.7.1 */
.getValue = secretGetValue, /* 0.7.1 */
+ .getValueInternal = secretGetValueInternal, /* 0.9.4 */
.undefine = secretUndefine, /* 0.7.1 */
};
--
1.7.4.4