From 9110941cfd84a076be6c7b7b327463579834f97a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 6 Jul 2011 16:17:10 -0600 Subject: [PATCH] libxl: reject unknown flags * src/libxl/libxl_driver.c (libxlOpen, libxlDomainReboot) (libxlDomainXMLFromNative, libxlDomainXMLToNative) (libxlDomainCreateWithFlags): Reject unknown flags. --- src/libxl/libxl_driver.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 21a343e97f..f938e24545 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -1063,8 +1063,10 @@ libxlActive(void) static virDrvOpenStatus libxlOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { + virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); + if (conn->uri == NULL) { if (libxl_driver == NULL) return VIR_DRV_OPEN_DECLINED; @@ -1482,13 +1484,15 @@ cleanup: } static int -libxlDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) +libxlDomainReboot(virDomainPtr dom, unsigned int flags) { libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm; int ret = -1; libxlDomainObjPrivatePtr priv; + virCheckFlags(0, -1); + libxlDriverLock(driver); vm = virDomainFindByUUID(&driver->domains, dom->uuid); if (!vm) { @@ -2511,7 +2515,7 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) static char * libxlDomainXMLFromNative(virConnectPtr conn, const char * nativeFormat, const char * nativeConfig, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { libxlDriverPrivatePtr driver = conn->privateData; const libxl_version_info *ver_info; @@ -2519,6 +2523,8 @@ libxlDomainXMLFromNative(virConnectPtr conn, const char * nativeFormat, virConfPtr conf = NULL; char *xml = NULL; + virCheckFlags(0, NULL); + if (STRNEQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) { libxlError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); @@ -2551,7 +2557,7 @@ cleanup: static char * libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, const char * domainXml, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { libxlDriverPrivatePtr driver = conn->privateData; const libxl_version_info *ver_info; @@ -2560,6 +2566,8 @@ libxlDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, int len = MAX_CONFIG_SIZE; char *ret = NULL; + virCheckFlags(0, NULL); + if (STRNEQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) { libxlError(VIR_ERR_INVALID_ARG, _("unsupported config type %s"), nativeFormat); @@ -2623,7 +2631,7 @@ libxlNumDefinedDomains(virConnectPtr conn) static int libxlDomainCreateWithFlags(virDomainPtr dom, - unsigned int flags ATTRIBUTE_UNUSED) + unsigned int flags) { libxlDriverPrivatePtr driver = dom->conn->privateData; virDomainObjPtr vm;