[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 19/20] xen: reject unknown flags



* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative)
(xenUnifiedDomainXMLToNative, xenUnifiedDomainBlockPeek): Reject
unknown flags.
* src/xen/xen_hypervisor.c (xenHypervisorOpen)
(xenHypervisorGetDomainState): Likewise.
* src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare): Likewise.
* src/xen/xm_internal.c (xenXMOpen, xenXMDomainGetState):
Likewise.
* src/xen/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
---
 src/xen/xen_driver.c     |   12 +++++++++---
 src/xen/xen_hypervisor.c |    8 ++++++--
 src/xen/xen_inotify.c    |    4 +++-
 src/xen/xend_internal.c  |   20 +++++++++++++++-----
 src/xen/xm_internal.c    |    8 ++++++--
 src/xen/xs_internal.c    |   12 +++++++++---
 6 files changed, 48 insertions(+), 16 deletions(-)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 0f66395..2cdb6c4 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1261,7 +1261,7 @@ static char *
 xenUnifiedDomainXMLFromNative(virConnectPtr conn,
                               const char *format,
                               const char *config,
-                              unsigned int flags ATTRIBUTE_UNUSED)
+                              unsigned int flags)
 {
     virDomainDefPtr def = NULL;
     char *ret = NULL;
@@ -1271,6 +1271,8 @@ xenUnifiedDomainXMLFromNative(virConnectPtr conn,
     int vncport;
     GET_PRIVATE(conn);

+    virCheckFlags(0, NULL);
+
     if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
         STRNEQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
         xenUnifiedError(VIR_ERR_INVALID_ARG,
@@ -1311,13 +1313,15 @@ static char *
 xenUnifiedDomainXMLToNative(virConnectPtr conn,
                             const char *format,
                             const char *xmlData,
-                            unsigned int flags ATTRIBUTE_UNUSED)
+                            unsigned int flags)
 {
     virDomainDefPtr def = NULL;
     char *ret = NULL;
     virConfPtr conf = NULL;
     GET_PRIVATE(conn);

+    virCheckFlags(0, NULL);
+
     if (STRNEQ(format, XEN_CONFIG_FORMAT_XM) &&
         STRNEQ(format, XEN_CONFIG_FORMAT_SEXPR)) {
         xenUnifiedError(VIR_ERR_INVALID_ARG,
@@ -1766,11 +1770,13 @@ xenUnifiedDomainInterfaceStats (virDomainPtr dom, const char *path,
 static int
 xenUnifiedDomainBlockPeek (virDomainPtr dom, const char *path,
                            unsigned long long offset, size_t size,
-                           void *buffer, unsigned int flags ATTRIBUTE_UNUSED)
+                           void *buffer, unsigned int flags)
 {
     int r;
     GET_PRIVATE (dom->conn);

+    virCheckFlags(0, -1);
+
     if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
         r = xenDaemonDomainBlockPeek (dom, path, offset, size, buffer);
         if (r != -2) return r;
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index a92b743..7636bea 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -2201,11 +2201,13 @@ xenHypervisorInit(void)
 virDrvOpenStatus
 xenHypervisorOpen(virConnectPtr conn,
                   virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-                  unsigned int flags ATTRIBUTE_UNUSED)
+                  unsigned int flags)
 {
     int ret;
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;

+    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
     if (initialized == 0)
         if (xenHypervisorInit() == -1)
             return -1;
@@ -3272,11 +3274,13 @@ int
 xenHypervisorGetDomainState(virDomainPtr domain,
                             int *state,
                             int *reason,
-                            unsigned int flags ATTRIBUTE_UNUSED)
+                            unsigned int flags)
 {
     xenUnifiedPrivatePtr priv = domain->conn->privateData;
     virDomainInfo info;

+    virCheckFlags(0, -1);
+
     if (domain->conn == NULL)
         return -1;

diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 2d7207c..0b6883f 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -383,13 +383,15 @@ cleanup:
 virDrvOpenStatus
 xenInotifyOpen(virConnectPtr conn,
                virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-               unsigned int flags ATTRIBUTE_UNUSED)
+               unsigned int flags)
 {
     DIR *dh;
     struct dirent *ent;
     char *path;
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;

+    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
     if (priv->configDir) {
         priv->useXenConfigCache = 1;
     } else {
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 6c2f051..8a4c6a9 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1323,11 +1323,13 @@ error:
 virDrvOpenStatus
 xenDaemonOpen(virConnectPtr conn,
               virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-              unsigned int flags ATTRIBUTE_UNUSED)
+              unsigned int flags)
 {
     char *port = NULL;
     int ret = VIR_DRV_OPEN_ERROR;

+    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
     /* Switch on the scheme, which we expect to be NULL (file),
      * "http" or "xen".
      */
@@ -1488,8 +1490,10 @@ xenDaemonDomainShutdown(virDomainPtr domain)
  * Returns 0 in case of success, -1 (with errno) in case of error.
  */
 int
-xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
+xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags)
 {
+    virCheckFlags(0, -1);
+
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL)) {
         virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
         return(-1);
@@ -1629,8 +1633,10 @@ xenDaemonDomainSave(virDomainPtr domain, const char *filename)
  */
 static int
 xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
-                        unsigned int flags ATTRIBUTE_UNUSED)
+                        unsigned int flags)
 {
+    virCheckFlags(0, -1);
+
     if ((domain == NULL) || (domain->conn == NULL) || (domain->name == NULL) ||
         (filename == NULL)) {
         virXendError(VIR_ERR_INVALID_ARG, __FUNCTION__);
@@ -1921,11 +1927,13 @@ int
 xenDaemonDomainGetState(virDomainPtr domain,
                         int *state,
                         int *reason,
-                        unsigned int flags ATTRIBUTE_UNUSED)
+                        unsigned int flags)
 {
     xenUnifiedPrivatePtr priv = domain->conn->privateData;
     struct sexpr *root;

+    virCheckFlags(0, -1);
+
     if (domain->id < 0 && priv->xendConfigVersion < 3)
         return -1;

@@ -3151,10 +3159,12 @@ xenDaemonDomainMigratePrepare (virConnectPtr dconn,
                                int *cookielen ATTRIBUTE_UNUSED,
                                const char *uri_in,
                                char **uri_out,
-                               unsigned long flags ATTRIBUTE_UNUSED,
+                               unsigned long flags,
                                const char *dname ATTRIBUTE_UNUSED,
                                unsigned long resource ATTRIBUTE_UNUSED)
 {
+    virCheckFlags(0, -1);
+
     /* If uri_in is NULL, get the current hostname as a best guess
      * of how the source host should connect to us.  Note that caller
      * deallocates this string.
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 01b9c4e..c985044 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -442,10 +442,12 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) {
 virDrvOpenStatus
 xenXMOpen (virConnectPtr conn,
            virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-           unsigned int flags ATTRIBUTE_UNUSED)
+           unsigned int flags)
 {
     xenUnifiedPrivatePtr priv = conn->privateData;

+    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
     priv->configDir = XM_CONFIG_DIR;

     priv->configCache = virHashCreate(50, xenXMConfigFree);
@@ -485,8 +487,10 @@ int
 xenXMDomainGetState(virDomainPtr domain,
                     int *state,
                     int *reason,
-                    unsigned int flags ATTRIBUTE_UNUSED)
+                    unsigned int flags)
 {
+    virCheckFlags(0, -1);
+
     if (domain->id != -1)
         return -1;

diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 48e450a..53d1e45 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -267,10 +267,12 @@ virDomainGetVMInfo(virDomainPtr domain, const char *vm, const char *name)
 virDrvOpenStatus
 xenStoreOpen(virConnectPtr conn,
              virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-             unsigned int flags ATTRIBUTE_UNUSED)
+             unsigned int flags)
 {
     xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;

+    virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
     if (flags & VIR_CONNECT_RO)
         priv->xshandle = xs_daemon_open_readonly();
     else
@@ -461,10 +463,12 @@ int
 xenStoreDomainGetState(virDomainPtr domain,
                        int *state,
                        int *reason,
-                       unsigned int flags ATTRIBUTE_UNUSED)
+                       unsigned int flags)
 {
     char *running;

+    virCheckFlags(0, -1);
+
     if (domain->id == -1)
         return -1;

@@ -778,11 +782,13 @@ xenStoreDomainShutdown(virDomainPtr domain)
  * Returns 0 in case of success, -1 in case of error.
  */
 int
-xenStoreDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
+xenStoreDomainReboot(virDomainPtr domain, unsigned int flags)
 {
     int ret;
     xenUnifiedPrivatePtr priv;

+    virCheckFlags(0, -1);
+
     if ((domain == NULL) || (domain->conn == NULL)) {
         virXenStoreError(VIR_ERR_INVALID_ARG, __FUNCTION__);
         return(-1);
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]