]> xenbits.xensource.com Git - libvirt.git/commitdiff
Mask out flags used internally for virSecretGetValue
authorMiloslav Trmač <mitr@redhat.com>
Fri, 14 Aug 2009 19:42:19 +0000 (21:42 +0200)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 10 Sep 2009 14:54:54 +0000 (15:54 +0100)
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.

src/driver.h
src/libvirt.c
src/libvirt_internal.h

index 042c4af902e329095e98d4326577e17ff19c15d8..447b7a2ef0c85e64ca2462eda166e5dc9d76edf4 100644 (file)
@@ -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);
index 45619e20e1a24bc70b971a7d0c14d1a66221a81c..96d204c569e74c403aee68cfed8b828cbae68416 100644 (file)
@@ -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;
 
index 6976f34657a304745eb9560ab47268fc2c722ba8..5913798737a2d95f37d92293e7e1ea048c66f78a 100644 (file)
@@ -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);