[libvirt] [PATCH 02/10] Add VIR_SECRET_GET_VALUE_INTERNAL_CALL.
Daniel P. Berrange
berrange at redhat.com
Thu Sep 10 14:52:47 UTC 2009
On Mon, Sep 07, 2009 at 04:12:37PM +0200, Miloslav Trma?? wrote:
> Add a VIR_SECRET_GET_VALUE_INTERNAL_CALL flag value, replacing the
> originally separate libvirt_internal_call parameter. The flag is used
> to differentiate external virSecretGetValue() calls from internal calls
> by libvirt drivers that need to use the secret even if it is private.
>
> * src/libvirt_internal.h (VIR_SECRET_GET_VALUE_FLAGS_MASK): New
> definition.
> * src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): New definition.
> * src/libvirt.c (virSecretGetValue): Don't allow the user to specify
> internal flags.
> * src/remote_internal.c (remoteSecretGetValue): Don't allow send
> internal flags over RPC.
> ---
> src/driver.h | 12 ++++++++++++
> src/libvirt.c | 2 ++
> src/libvirt_internal.h | 3 +++
> src/remote_internal.c | 3 ++-
> 4 files changed, 19 insertions(+), 1 deletions(-)
>
> diff --git a/src/driver.h b/src/driver.h
> index 042c4af..28d7848 100644
> --- a/src/driver.h
> +++ b/src/driver.h
> @@ -12,6 +12,8 @@
> #include <libxml/uri.h>
>
> #include "internal.h"
> +#include "libvirt_internal.h"
> +
> /*
> * List of registered drivers numbers
> */
> @@ -802,6 +804,16 @@ struct _virDeviceMonitor {
> virDrvNodeDeviceDestroy deviceDestroy;
> };
>
> +enum {
> + /* This getValue call is inside libvirt, override the "private" flag.
> + This flag can not be set by outside callers. */
> + VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 16
> +};
> +
> +/* Make sure ... INTERNAL_CALL can not be set by the caller */
> +verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL &
> + VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
> +
> typedef virSecretPtr
> (*virDrvSecretLookupByUUIDString) (virConnectPtr conn,
> const char *uuid);
> diff --git a/src/libvirt.c b/src/libvirt.c
> index 45619e2..96d204c 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -9066,6 +9066,8 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags)
> goto error;
> }
>
> + flags &= VIR_SECRET_GET_VALUE_FLAGS_MASK;
> +
> if (conn->secretDriver != NULL && conn->secretDriver->getValue != NULL) {
> unsigned char *ret;
>
> diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
> index 6976f34..60564d2 100644
> --- a/src/libvirt_internal.h
> +++ b/src/libvirt_internal.h
> @@ -27,6 +27,9 @@
> /* bits 16 and above of virDomainXMLFlags are for internal use */
> #define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
>
> +/* Bits 16 and above of virSecretGetValue flags are for internal use */
> +#define VIR_SECRET_GET_VALUE_FLAGS_MASK 0xffff
> +
> #ifdef WITH_LIBVIRTD
> int virStateInitialize(int privileged);
> int virStateCleanup(void);
> diff --git a/src/remote_internal.c b/src/remote_internal.c
> index 3dd4609..745b128 100644
> --- a/src/remote_internal.c
> +++ b/src/remote_internal.c
> @@ -76,6 +76,7 @@
> # define AI_ADDRCONFIG 0
> #endif
>
> +#include "libvirt_internal.h"
> #include "virterror_internal.h"
> #include "logging.h"
> #include "datatypes.h"
> @@ -6595,7 +6596,7 @@ remoteSecretGetValue (virSecretPtr secret, size_t *value_size,
> remoteDriverLock (priv);
>
> make_nonnull_secret (&args.secret, secret);
> - args.flags = flags;
> + args.flags = flags & VIR_SECRET_GET_VALUE_FLAGS_MASK;
>
> memset (&ret, 0, sizeof (ret));
> if (call (secret->conn, priv, 0, REMOTE_PROC_SECRET_GET_VALUE,
This is redundant, since libvirt.c has already masked the flags out by the
time we get here
I think the mask lives better in driver.h, so going to push the following
slight re-arrangement instead (also moving the existing flag)
Regards,
Daniel
commit 94a7da7de17a6355bcfc4ffce4b0c1053a5eb081
Author: Miloslav TrmaÄ <mitr at redhat.com>
Date: Fri Aug 14 21:42:19 2009 +0200
Mask out flags used internally for virSecretGetValue
Add a VIR_SECRET_GET_VALUE_INTERNAL_CALL flag value, replacing the
originally separate libvirt_internal_call parameter. The flag is used
to differentiate external virSecretGetValue() calls from internal calls
by libvirt drivers that need to use the secret even if it is private.
* src/libvirt_internal.h Remove VIR_DOMAIN_XML_FLAGS_MASK
* src/driver.h Add VIR_SECRET_GET_VALUE_FLAGS_MASK constant and
VIR_SECRET_GET_VALUE_INTERNAL_CALL. Re-add the
VIR_DOMAIN_XML_FLAGS_MASK constant
* src/libvirt.c (virSecretGetValue): Don't allow the user to specify
internal flags.
diff --git a/src/driver.h b/src/driver.h
index 042c4af..447b7a2 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -802,6 +802,22 @@ struct _virDeviceMonitor {
virDrvNodeDeviceDestroy deviceDestroy;
};
+/* bits 16 and above of virDomainXMLFlags are for internal use */
+#define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
+
+/* Bits 16 and above of virSecretGetValue flags are for internal use */
+#define VIR_SECRET_GET_VALUE_FLAGS_MASK 0xffff
+
+enum {
+ /* This getValue call is inside libvirt, override the "private" flag.
+ This flag can not be set by outside callers. */
+ VIR_SECRET_GET_VALUE_INTERNAL_CALL = 1 << 16
+};
+
+/* Make sure ... INTERNAL_CALL can not be set by the caller */
+verify((VIR_SECRET_GET_VALUE_INTERNAL_CALL &
+ VIR_SECRET_GET_VALUE_FLAGS_MASK) == 0);
+
typedef virSecretPtr
(*virDrvSecretLookupByUUIDString) (virConnectPtr conn,
const char *uuid);
diff --git a/src/libvirt.c b/src/libvirt.c
index 45619e2..96d204c 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -9066,6 +9066,8 @@ virSecretGetValue(virSecretPtr secret, size_t *value_size, unsigned int flags)
goto error;
}
+ flags &= VIR_SECRET_GET_VALUE_FLAGS_MASK;
+
if (conn->secretDriver != NULL && conn->secretDriver->getValue != NULL) {
unsigned char *ret;
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 6976f34..5913798 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -24,9 +24,6 @@
#include "internal.h"
-/* bits 16 and above of virDomainXMLFlags are for internal use */
-#define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
-
#ifdef WITH_LIBVIRTD
int virStateInitialize(int privileged);
int virStateCleanup(void);
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list