* 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/xs_internal.c (xenStoreOpen, xenStoreDomainGetState)
(xenStoreDomainReboot): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen, xenDaemonDomainReboot)
(xenDaemonDomainCoreDump, xenDaemonDomainGetState)
(xenDaemonDomainMigratePrepare): Likewise.
(xenDaemonDomainGetXMLDesc): Prefer unsigned flags.
* src/xen/xend_internal.h (xenDaemonDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.h (xenXMDomainGetXMLDesc): Likewise.
* src/xen/xm_internal.c (xenXMDomainGetXMLDesc): Likewise.
(xenXMOpen, xenXMDomainGetState): Reject unknown flags.
---
src/xen/xen_driver.c | 12 +++++++++---
src/xen/xen_hypervisor.c | 8 ++++++--
src/xen/xen_inotify.c | 4 +++-
src/xen/xend_internal.c | 23 +++++++++++++++++------
src/xen/xend_internal.h | 3 ++-
src/xen/xm_internal.c | 11 ++++++++---
src/xen/xm_internal.h | 2 +-
src/xen/xs_internal.c | 12 +++++++++---
8 files changed, 55 insertions(+), 20 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..543dfb1 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(VIR_CONNECT_RO, 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..241dbc7 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(VIR_CONNECT_RO, 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..17be97e 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(VIR_CONNECT_RO, 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__);
@@ -1837,7 +1843,8 @@ cleanup:
* the caller must free() the returned value.
*/
char *
-xenDaemonDomainGetXMLDesc(virDomainPtr domain, int flags, const char *cpus)
+xenDaemonDomainGetXMLDesc(virDomainPtr domain, unsigned int flags,
+ const char *cpus)
{
xenUnifiedPrivatePtr priv;
virDomainDefPtr def;
@@ -1921,11 +1928,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 +3160,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/xend_internal.h b/src/xen/xend_internal.h
index 5d324da..c4ed9ba 100644
--- a/src/xen/xend_internal.h
+++ b/src/xen/xend_internal.h
@@ -115,7 +115,8 @@ int xenDaemonDomainGetState(virDomainPtr domain,
int *state,
int *reason,
unsigned int flags);
-char *xenDaemonDomainGetXMLDesc(virDomainPtr domain, int flags, const char *cpus);
+char *xenDaemonDomainGetXMLDesc(virDomainPtr domain, unsigned int flags,
+ const char *cpus);
unsigned long xenDaemonDomainGetMaxMemory(virDomainPtr domain);
char **xenDaemonListDomainsOld(virConnectPtr xend);
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 01b9c4e..9347e39 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(VIR_CONNECT_RO, 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;
@@ -543,7 +547,8 @@ error:
* Turn a config record into a lump of XML describing the
* domain, suitable for later feeding for virDomainCreateXML
*/
-char *xenXMDomainGetXMLDesc(virDomainPtr domain, int flags) {
+char *xenXMDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
+{
xenUnifiedPrivatePtr priv;
const char *filename;
xenXMConfCachePtr entry;
diff --git a/src/xen/xm_internal.h b/src/xen/xm_internal.h
index cf315cd..89af23e 100644
--- a/src/xen/xm_internal.h
+++ b/src/xen/xm_internal.h
@@ -45,7 +45,7 @@ int xenXMDomainGetState(virDomainPtr domain,
int *state,
int *reason,
unsigned int flags);
-char *xenXMDomainGetXMLDesc(virDomainPtr domain, int flags);
+char *xenXMDomainGetXMLDesc(virDomainPtr domain, unsigned int flags);
int xenXMDomainSetMemory(virDomainPtr domain, unsigned long memory);
int xenXMDomainSetMaxMemory(virDomainPtr domain, unsigned long memory);
unsigned long xenXMDomainGetMaxMemory(virDomainPtr domain);
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 48e450a..f62d716 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(VIR_CONNECT_RO, 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