On Wed, Jul 06, 2011 at 05:24:00PM -0600, Eric Blake wrote:
* src/vbox/vbox_driver.c (vboxOpenDummy): Reject unknown flags.
* src/vbox/vbox_tmpl.c (vboxOpen, vboxDomainReboot)
(vboxNetworkOpen, vboxNetworkGetXMLDesc, vboxStorageOpen)
(vboxStorageVolCreateXML, vboxStorageVolDelete)
(vboxStorageVolGetXMLDesc, vboxDomainScreenshot): Likewise.
---
src/vbox/vbox_driver.c | 5 ++++-
src/vbox/vbox_tmpl.c | 44 +++++++++++++++++++++++++++++++++++---------
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index b20998a..3b2e95a 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -142,9 +142,12 @@ int vboxRegister(void) {
static virDrvOpenStatus vboxOpenDummy(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
uid_t uid = getuid();
+ virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
if (conn->uri == NULL ||
conn->uri->scheme == NULL ||
STRNEQ (conn->uri->scheme, "vbox") ||
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 4a0858f..d6afa31 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -961,10 +961,13 @@ static void vboxUninitialize(vboxGlobalData *data) {
static virDrvOpenStatus vboxOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
vboxGlobalData *data = NULL;
uid_t uid = getuid();
+ virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
if (conn->uri == NULL) {
conn->uri = xmlParseURI(uid ? "vbox:///session" :
"vbox:///system");
if (conn->uri == NULL) {
@@ -1637,7 +1640,8 @@ cleanup:
return ret;
}
-static int vboxDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) {
+static int vboxDomainReboot(virDomainPtr dom, unsigned int flags)
+{
VBOX_OBJECT_CHECK(dom->conn, int, -1);
IMachine *machine = NULL;
vboxIID iid = VBOX_IID_INITIALIZER;
@@ -1646,6 +1650,8 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags
ATTRIBUTE_UNUSE
PRBool isAccessible = PR_FALSE;
nsresult rc;
+ virCheckFlags(0, -1);
+
vboxIIDFromUUID(&iid, dom->uuid);
rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
@@ -6938,9 +6944,12 @@ static int vboxDomainEventDeregisterAny(virConnectPtr conn,
*/
static virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
vboxGlobalData *data = conn->privateData;
+ virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
if (STRNEQ(conn->driver->name, "VBOX"))
goto cleanup;
@@ -7575,7 +7584,8 @@ static int vboxNetworkDestroy(virNetworkPtr network) {
}
static char *vboxNetworkGetXMLDesc(virNetworkPtr network,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
VBOX_OBJECT_HOST_CHECK(network->conn, char *, NULL);
virNetworkDefPtr def = NULL;
virNetworkIpDefPtr ipdef = NULL;
@@ -7583,6 +7593,8 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network,
PRUnichar *networkInterfaceNameUtf16 = NULL;
IHostNetworkInterface *networkInterface = NULL;
+ virCheckFlags(0, NULL);
+
if (VIR_ALLOC(def) < 0) {
virReportOOMError();
goto cleanup;
@@ -7750,9 +7762,12 @@ cleanup:
static virDrvOpenStatus vboxStorageOpen (virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
vboxGlobalData *data = conn->privateData;
+ virCheckFlags(0, VIR_DRV_OPEN_ERROR);
+
if (STRNEQ(conn->driver->name, "VBOX"))
goto cleanup;
@@ -8098,7 +8113,8 @@ static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr
conn, const cha
static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
const char *xml,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
VBOX_OBJECT_CHECK(pool->conn, virStorageVolPtr, NULL);
virStorageVolDefPtr def = NULL;
PRUnichar *hddFormatUtf16 = NULL;
@@ -8106,6 +8122,8 @@ static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr
pool,
virStoragePoolDef poolDef;
nsresult rc;
+ virCheckFlags(0, NULL);
+
/* since there is currently one default pool now
* and virStorageVolDefFormat() just checks it type
* so just assign it for now, change the behaviour
@@ -8191,7 +8209,8 @@ cleanup:
}
static int vboxStorageVolDelete(virStorageVolPtr vol,
- unsigned int flags ATTRIBUTE_UNUSED) {
+ unsigned int flags)
+{
VBOX_OBJECT_CHECK(vol->conn, int, -1);
vboxIID hddIID = VBOX_IID_INITIALIZER;
unsigned char uuid[VIR_UUID_BUFLEN];
@@ -8201,6 +8220,8 @@ static int vboxStorageVolDelete(virStorageVolPtr vol,
int i = 0;
int j = 0;
+ virCheckFlags(0, -1);
+
if (virUUIDParse(vol->key, uuid) < 0) {
vboxError(VIR_ERR_INVALID_ARG,
_("Could not parse UUID from '%s'"), vol->key);
@@ -8424,7 +8445,8 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol,
virStorageVolInfoPtr info
return ret;
}
-static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags
ATTRIBUTE_UNUSED) {
+static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
+{
VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
IHardDisk *hardDisk = NULL;
unsigned char uuid[VIR_UUID_BUFLEN];
@@ -8434,6 +8456,8 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol,
unsigned int flags A
int defOk = 0;
nsresult rc;
+ virCheckFlags(0, NULL);
+
memset(&pool, 0, sizeof(pool));
memset(&def, 0, sizeof(def));
@@ -8597,7 +8621,7 @@ static char *
vboxDomainScreenshot(virDomainPtr dom,
virStreamPtr st,
unsigned int screen,
- unsigned int flags ATTRIBUTE_UNUSED)
+ unsigned int flags)
{
VBOX_OBJECT_CHECK(dom->conn, char *, NULL);
IConsole *console = NULL;
@@ -8608,6 +8632,8 @@ vboxDomainScreenshot(virDomainPtr dom,
int tmp_fd = -1;
unsigned int max_screen;
+ virCheckFlags(0, NULL);
+
vboxIIDFromUUID(&iid, dom->uuid);
rc = VBOX_OBJECT_GET_MACHINE(iid.value, &machine);
if (NS_FAILED(rc)) {
ACK
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|