summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-07-13 16:24:38 -0600
committerEric Blake <eblake@redhat.com>2011-07-15 12:22:20 -0600
commit461e0f1a2df4fd0cd2e16d38bb2847cf7be9a365 (patch)
tree90f20a0058a57b308c8eeaaa34e430900a1d36cd /src
parentmaint: fix typos (diff)
downloadlibvirt-461e0f1a2df4fd0cd2e16d38bb2847cf7be9a365.tar.gz
libvirt-461e0f1a2df4fd0cd2e16d38bb2847cf7be9a365.tar.bz2
libvirt-461e0f1a2df4fd0cd2e16d38bb2847cf7be9a365.zip
flags: use common dumpxml flags check
The previous patches only cleaned up ATTRIBUTE_UNUSED flags cases; auditing the drivers found other places where flags was being used but not validated. In particular, domainGetXMLDesc had issues with clients accepting a different set of flags than the common virDomainDefFormat helper function. * src/conf/domain_conf.c (virDomainDefFormat): Add common flag check. * src/uml/uml_driver.c (umlDomainAttachDeviceFlags) (umlDomainDetachDeviceFlags): Reject unknown flags. * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc) (vboxDomainAttachDeviceFlags) (vboxDomainDetachDeviceFlags): Likewise. * src/qemu/qemu_driver.c (qemudDomainMemoryPeek): Likewise. (qemuDomainGetXMLDesc): Document common flag handling. * src/libxl/libxl_driver.c (libxlDomainGetXMLDesc): Likewise. * src/lxc/lxc_driver.c (lxcDomainGetXMLDesc): Likewise. * src/openvz/openvz_driver.c (openvzDomainGetXMLDesc): Likewise. * src/phyp/phyp_driver.c (phypDomainGetXMLDesc): Likewise. * src/test/test_driver.c (testDomainGetXMLDesc): Likewise. * src/vmware/vmware_driver.c (vmwareDomainGetXMLDesc): Likewise. * src/xenapi/xenapi_driver.c (xenapiDomainGetXMLDesc): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/conf/domain_conf.c4
-rw-r--r--src/libxl/libxl_driver.c2
-rw-r--r--src/lxc/lxc_driver.c2
-rw-r--r--src/openvz/openvz_driver.c2
-rw-r--r--src/phyp/phyp_driver.c2
-rw-r--r--src/qemu/qemu_driver.c6
-rw-r--r--src/test/test_driver.c2
-rw-r--r--src/uml/uml_driver.c24
-rw-r--r--src/vbox/vbox_tmpl.c18
-rw-r--r--src/vmware/vmware_driver.c2
-rw-r--r--src/xenapi/xenapi_driver.c4
11 files changed, 49 insertions, 19 deletions
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a78996fbb..788981f93 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9624,6 +9624,10 @@ char *virDomainDefFormat(virDomainDefPtr def,
const char *type = NULL;
int n, allones = 1;
+ virCheckFlags(VIR_DOMAIN_XML_SECURE |
+ VIR_DOMAIN_XML_INACTIVE |
+ VIR_DOMAIN_XML_UPDATE_CPU, NULL);
+
if (!(type = virDomainVirtTypeToString(def->virtType))) {
virDomainReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected domain type %d"), def->virtType);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index f938e2454..cc37d05af 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -2494,6 +2494,8 @@ libxlDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
virDomainObjPtr vm;
char *ret = NULL;
+ /* Flags checked by virDomainDefFormat */
+
libxlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
libxlDriverUnlock(driver);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index b6da757b7..78f0f9dca 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -967,6 +967,8 @@ static char *lxcDomainGetXMLDesc(virDomainPtr dom,
virDomainObjPtr vm;
char *ret = NULL;
+ /* Flags checked by virDomainDefFormat */
+
lxcDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
lxcDriverUnlock(driver);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index d50ecf16f..cc0c59053 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -461,6 +461,8 @@ static char *openvzDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
virDomainObjPtr vm;
char *ret = NULL;
+ /* Flags checked by virDomainDefFormat */
+
openvzDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
openvzDriverUnlock(driver);
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 62ba192e2..2489063a3 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -3317,6 +3317,8 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
virDomainDef def;
char *managed_system = phyp_driver->managed_system;
+ /* Flags checked by virDomainDefFormat */
+
memset(&def, 0, sizeof(virDomainDef));
def.virtType = VIR_DOMAIN_VIRT_PHYP;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f3a495f36..0a73a5970 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3850,9 +3850,7 @@ static char *qemuDomainGetXMLDesc(virDomainPtr dom,
unsigned long balloon;
int err;
- virCheckFlags(VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_UPDATE_CPU, NULL);
+ /* Flags checked by virDomainDefFormat */
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -6283,6 +6281,8 @@ qemudDomainMemoryPeek (virDomainPtr dom,
int fd = -1, ret = -1;
qemuDomainObjPrivatePtr priv;
+ virCheckFlags(VIR_MEMORY_VIRTUAL | VIR_MEMORY_PHYSICAL, -1);
+
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver);
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index f3fb320f2..064a1cdee 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2366,6 +2366,8 @@ static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
virDomainObjPtr privdom;
char *ret = NULL;
+ /* Flags checked by virDomainDefFormat */
+
testDriverLock(privconn);
privdom = virDomainFindByName(&privconn->domains,
domain->name);
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index d0374ea4a..557c948db 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1653,9 +1653,7 @@ static char *umlDomainGetXMLDesc(virDomainPtr dom,
virDomainObjPtr vm;
char *ret = NULL;
- virCheckFlags(VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_UPDATE_CPU, NULL);
+ /* Flags checked by virDomainDefFormat */
umlDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -1929,9 +1927,13 @@ cleanup:
}
-static int umlDomainAttachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags) {
+static int
+umlDomainAttachDeviceFlags(virDomainPtr dom,
+ const char *xml,
+ unsigned int flags)
+{
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
+
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
umlReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify the persistent configuration of a domain"));
@@ -2037,9 +2039,13 @@ cleanup:
}
-static int umlDomainDetachDeviceFlags(virDomainPtr dom,
- const char *xml,
- unsigned int flags) {
+static int
+umlDomainDetachDeviceFlags(virDomainPtr dom,
+ const char *xml,
+ unsigned int flags)
+{
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
+
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
umlReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("cannot modify the persistent configuration of a domain"));
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 6cb9bb4ce..53bac798b 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2145,6 +2145,8 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) {
nsresult rc;
char *tmp;
+ /* Flags checked by virDomainDefFormat */
+
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
goto cleanup;
@@ -5296,8 +5298,12 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) {
return vboxDomainAttachDeviceImpl(dom, xml, 0);
}
-static int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
- unsigned int flags) {
+static int
+vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
+ unsigned int flags)
+{
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
+
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
@@ -5446,8 +5452,12 @@ cleanup:
return ret;
}
-static int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
- unsigned int flags) {
+static int
+vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
+ unsigned int flags)
+{
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);
+
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
vboxError(VIR_ERR_OPERATION_INVALID, "%s",
_("cannot modify the persistent configuration of a domain"));
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index c0430fee4..36b48e0fb 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -807,6 +807,8 @@ vmwareDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
virDomainObjPtr vm;
char *ret = NULL;
+ /* Flags checked by virDomainDefFormat */
+
vmwareDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
vmwareDriverUnlock(driver);
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 98838e69e..97da1d1e2 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1318,9 +1318,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
struct xen_vif_set *vif_set = NULL;
char *xml;
- virCheckFlags(VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_UPDATE_CPU, NULL);
+ /* Flags checked by virDomainDefFormat */
if (!xen_vm_get_by_name_label(session, &vms, dom->name)) return NULL;
if (vms->size != 1) {