Devel
Threads by month
- ----- 2026 -----
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 27 participants
- 40017 discussions
16 Mar '10
---
docs/drvesx.html.in | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index 9b413ab..6855298 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -32,6 +32,14 @@ gsx://example.com (GSX over HTTPS)
esx://example.com/?transport=http (ESX over HTTP)
esx://example.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the server's SSL certificate)
</pre>
+ <p>
+ <strong>Note</strong>: In contrast to other drivers, the ESX driver is
+ a client-side-only driver. That means you cannot use the
+ <a href="remote.html">remote transport mechanism</a> provided by the
+ remote driver and libvirtd. Instead the ESX driver communicates to the
+ ESX server using HTTP(S). Therefore, you cannot use URIs like
+ <code>esx+ssh://example.com</code>.
+ </p>
<h3><a name="uriformat">URI Format</a></h3>
--
1.6.3.3
3
3
16 Mar '10
---
src/phyp/phyp_driver.c | 73 ++++++++++++++++++++---------------------------
src/phyp/phyp_driver.h | 1 -
2 files changed, 31 insertions(+), 43 deletions(-)
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 32c0a7a..9598162 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -102,12 +102,6 @@ phypOpen(virConnectPtr conn,
return VIR_DRV_OPEN_ERROR;
}
- if (conn->uri->user == NULL) {
- PHYP_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("Missing username in phyp:// URI"));
- return VIR_DRV_OPEN_ERROR;
- }
-
if (VIR_ALLOC(phyp_driver) < 0) {
virReportOOMError();
goto failure;
@@ -160,9 +154,8 @@ phypOpen(virConnectPtr conn,
"%s", _("Error while opening SSH session."));
goto failure;
}
- //conn->uri->path = string;
+
connection_data->session = session;
- connection_data->auth = auth;
uuid_table->nlpars = 0;
uuid_table->lpars = NULL;
@@ -245,8 +238,8 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
{
LIBSSH2_SESSION *session;
const char *hostname = conn->uri->server;
- const char *username = conn->uri->user;
- const char *password = NULL;
+ char *username = NULL;
+ char *password = NULL;
int sock;
int rc;
struct addrinfo *ai = NULL, *cur;
@@ -270,6 +263,28 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
goto err;
}
+ if (conn->uri->user != NULL) {
+ username = strdup(conn->uri->user);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto err;
+ }
+ } else {
+ if (auth == NULL || auth->cb == NULL) {
+ PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
+ "%s", _("No authentication callback provided."));
+ goto err;
+ }
+
+ username = virRequestUsername(auth, NULL, conn->uri->server);
+
+ if (username == NULL) {
+ PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED, "Username request failed");
+ goto err;
+ }
+ }
+
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_ADDRCONFIG | AI_NUMERICSERV;
hints.ai_socktype = SOCK_STREAM;
@@ -336,44 +351,16 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
if (rc == LIBSSH2_ERROR_SOCKET_NONE
|| rc == LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED
|| rc == LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED) {
- int i;
- int hasPassphrase = 0;
-
- virConnectCredential creds[] = {
- {VIR_CRED_PASSPHRASE, "password", "Password", NULL, NULL, 0},
- };
-
- if (!auth || !auth->cb) {
+ if (auth == NULL || auth->cb == NULL) {
PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
"%s", _("No authentication callback provided."));
goto disconnect;
}
- for (i = 0; i < auth->ncredtype; i++) {
- if (auth->credtype[i] == VIR_CRED_PASSPHRASE)
- hasPassphrase = 1;
- }
+ password = virRequestPassword(auth, username, conn->uri->server);
- if (!hasPassphrase) {
- PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- "%s", _("Required credentials are not supported."));
- goto disconnect;
- }
-
- int res =
- (auth->cb) (creds, ARRAY_CARDINALITY(creds), auth->cbdata);
-
- if (res < 0) {
- PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- "%s", _("Unable to fetch credentials."));
- goto disconnect;
- }
-
- if (creds[0].result) {
- password = creds[0].result;
- } else {
- PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED,
- "%s", _("Unable to get password certificates"));
+ if (password == NULL) {
+ PHYP_ERROR(conn, VIR_ERR_AUTH_FAILED, "Password request failed");
goto disconnect;
}
@@ -404,6 +391,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
VIR_FREE(userhome);
VIR_FREE(pubkey);
VIR_FREE(pvtkey);
+ VIR_FREE(username);
VIR_FREE(password);
return NULL;
@@ -411,6 +399,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
VIR_FREE(userhome);
VIR_FREE(pubkey);
VIR_FREE(pvtkey);
+ VIR_FREE(username);
VIR_FREE(password);
return session;
}
diff --git a/src/phyp/phyp_driver.h b/src/phyp/phyp_driver.h
index d05f184..f680994 100644
--- a/src/phyp/phyp_driver.h
+++ b/src/phyp/phyp_driver.h
@@ -35,7 +35,6 @@ typedef struct _ConnectionData ConnectionData;
typedef ConnectionData *ConnectionDataPtr;
struct _ConnectionData {
LIBSSH2_SESSION *session;
- virConnectAuthPtr auth;
int sock;
};
--
1.6.3.3
2
1
16 Mar '10
---
src/xenapi/xenapi_driver.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 9a38e3f..7d0b748 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -172,9 +172,12 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
VIR_FREE(password);
if (privP != NULL) {
+ virCapabilitiesFree(privP->caps);
+
if (privP->session != NULL)
xenSessionFree(privP->session);
+ VIR_FREE(privP->url);
VIR_FREE(privP);
}
--
1.6.3.3
2
1
16 Mar '10
---
src/xenapi/xenapi_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 00b62b3..9a38e3f 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -87,7 +87,8 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
char *password = NULL;
struct _xenapiPrivate *privP = NULL;
- if (STRCASENEQ(conn->uri->scheme, "XenAPI")) {
+ if (conn->uri == NULL || conn->uri->scheme == NULL ||
+ STRCASENEQ(conn->uri->scheme, "XenAPI")) {
return VIR_DRV_OPEN_DECLINED;
}
--
1.6.3.3
2
1
[libvirt] [PATCH] xenapi: Request a username if there is non in the URI
by Matthias Bolte 16 Mar '10
by Matthias Bolte 16 Mar '10
16 Mar '10
Use virRequestUsername and virRequestPassword.
---
src/xenapi/xenapi_driver.c | 119 +++++++++++++++++++++++++++++++-------------
1 files changed, 84 insertions(+), 35 deletions(-)
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 8d5c8bb..00b62b3 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -83,62 +83,101 @@ getCapsObject (void)
static virDrvOpenStatus
xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
{
- char *passwd = NULL;
- xen_session *session;
- struct _xenapiPrivate *privP;
+ char *username = NULL;
+ char *password = NULL;
+ struct _xenapiPrivate *privP = NULL;
if (STRCASENEQ(conn->uri->scheme, "XenAPI")) {
return VIR_DRV_OPEN_DECLINED;
}
+
if (conn->uri->server == NULL) {
- xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "Server name not in URI");
- return VIR_DRV_OPEN_ERROR;
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Server name not in URI");
+ goto error;
+ }
+
+ if (auth == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Authentication Credentials not found");
+ goto error;
}
- if (auth) {
- passwd = xenapiUtil_RequestPassword(auth, conn->uri->user, conn->uri->server);
+
+ if (conn->uri->user != NULL) {
+ username = strdup(conn->uri->user);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto error;
+ }
} else {
- xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "Authentication Credentials not found");
- return VIR_DRV_OPEN_ERROR;
+ username = virRequestUsername(auth, NULL, conn->uri->server);
+
+ if (username == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Username request failed");
+ goto error;
+ }
}
- if (!passwd || !conn->uri->user) {
- xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "Username/Password not valid");
- if (passwd) VIR_FREE(passwd);
- return VIR_DRV_OPEN_ERROR;
+
+ password = virRequestPassword(auth, username, conn->uri->server);
+
+ if (password == NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED,
+ "Password request failed");
+ goto error;
}
+
if (VIR_ALLOC(privP) < 0) {
virReportOOMError();
- return VIR_DRV_OPEN_ERROR;
+ goto error;
}
+
if (virAsprintf(&privP->url, "https://%s", conn->uri->server) < 0) {
virReportOOMError();
- VIR_FREE(passwd);
- return VIR_DRV_OPEN_ERROR;
+ goto error;
}
- xenapiUtil_ParseQuery(conn, conn->uri, &privP->noVerify);
+
+ if (xenapiUtil_ParseQuery(conn, conn->uri, &privP->noVerify) < 0)
+ goto error;
+
+ if (!(privP->caps = getCapsObject())) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
+ "Capabilities not found");
+ goto error;
+ }
+
xmlInitParser();
xmlKeepBlanksDefault(0);
xen_init();
curl_global_init(CURL_GLOBAL_ALL);
- session = xen_session_login_with_password(call_func, privP, conn->uri->user, passwd, xen_api_latest_version);
+ privP->session = xen_session_login_with_password(call_func, privP, username,
+ password, xen_api_latest_version);
- if (session && session->ok) {
- privP->session = session;
- if (!(privP->caps = getCapsObject())) {
- xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Capabilities not found");
- VIR_FREE(passwd);
- return VIR_DRV_OPEN_ERROR;
- }
+ if (privP->session != NULL && privP->session->ok) {
conn->privateData = privP;
- VIR_FREE(passwd);
+
+ VIR_FREE(username);
+ VIR_FREE(password);
+
return VIR_DRV_OPEN_SUCCESS;
- } else {
- xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "");
- if (session) xenSessionFree(session);
+ }
+
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED, "");
+
+ error:
+ VIR_FREE(username);
+ VIR_FREE(password);
+
+ if (privP != NULL) {
+ if (privP->session != NULL)
+ xenSessionFree(privP->session);
+
VIR_FREE(privP);
- VIR_FREE(passwd);
- return VIR_DRV_OPEN_ERROR;
}
+
+ return VIR_DRV_OPEN_ERROR;
}
/*
@@ -150,10 +189,20 @@ xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUS
static int
xenapiClose (virConnectPtr conn)
{
- xen_session_logout(((struct _xenapiPrivate *)(conn->privateData))->session);
- virCapabilitiesFree(((struct _xenapiPrivate *)(conn->privateData))->caps);
- VIR_FREE(((struct _xenapiPrivate *)(conn->privateData))->url);
- VIR_FREE(conn->privateData);
+ struct _xenapiPrivate *priv = conn->privateData;
+
+ virCapabilitiesFree(priv->caps);
+
+ if (priv->session != NULL) {
+ xen_session_logout(priv->session);
+ xenSessionFree(priv->session);
+ }
+
+ VIR_FREE(priv->url);
+ VIR_FREE(priv);
+
+ conn->privateData = NULL;
+
return 0;
}
--
1.6.3.3
2
1
[libvirt] [PATCH] xenapi: Check for valid private data in xenapiSessionErrorHandle
by Matthias Bolte 16 Mar '10
by Matthias Bolte 16 Mar '10
16 Mar '10
---
src/xenapi/xenapi_utils.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 4b9a6d8..bfd53ed 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -374,12 +374,12 @@ xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
const char *buf, const char *filename, const char *func,
size_t lineno)
{
- xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ struct _xenapiPrivate *priv = conn->privateData;
- if (buf == NULL) {
- char *ret = returnErrorFromSession(session);
+ if (buf == NULL && priv != NULL && priv->session != NULL) {
+ char *ret = returnErrorFromSession(priv->session);
virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), ret);
- xen_session_clear_error(session);
+ xen_session_clear_error(priv->session);
VIR_FREE(ret);
} else {
virReportErrorHelper(conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s"), buf);
--
1.6.3.3
2
1
[libvirt] [PATCH] esx: Move username and password helper functions to util.c
by Matthias Bolte 16 Mar '10
by Matthias Bolte 16 Mar '10
16 Mar '10
---
src/esx/esx_driver.c | 8 ++--
src/esx/esx_util.c | 83 ----------------------------------------------
src/esx/esx_util.h | 7 ----
src/util/util.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/util/util.h | 5 +++
5 files changed, 98 insertions(+), 94 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c47af1c..3f8b900 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -354,7 +354,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto failure;
}
} else {
- username = esxUtil_RequestUsername(auth, "root", conn->uri->server);
+ username = virRequestUsername(auth, "root", conn->uri->server);
if (username == NULL) {
ESX_ERROR(VIR_ERR_AUTH_FAILED, "Username request failed");
@@ -366,7 +366,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto failure;
}
- password = esxUtil_RequestPassword(auth, username, conn->uri->server);
+ password = virRequestPassword(auth, username, conn->uri->server);
if (password == NULL) {
ESX_ERROR(VIR_ERR_AUTH_FAILED, "Password request failed");
@@ -491,14 +491,14 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
goto failure;
}
- username = esxUtil_RequestUsername(auth, "administrator", vCenter);
+ username = virRequestUsername(auth, "administrator", vCenter);
if (username == NULL) {
ESX_ERROR(VIR_ERR_AUTH_FAILED, "Username request failed");
goto failure;
}
- password = esxUtil_RequestPassword(auth, username, vCenter);
+ password = virRequestPassword(auth, username, vCenter);
if (password == NULL) {
ESX_ERROR(VIR_ERR_AUTH_FAILED, "Password request failed");
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index dcbd86c..3cbd2b1 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -49,89 +49,6 @@
-char *
-esxUtil_RequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
- const char *hostname)
-{
- unsigned int ncred;
- virConnectCredential cred;
- char *prompt = NULL;
-
- memset(&cred, 0, sizeof(virConnectCredential));
-
- if (virAsprintf(&prompt, "Enter username for %s [%s]", hostname,
- defaultUsername) < 0) {
- return NULL;
- }
-
- for (ncred = 0; ncred < auth->ncredtype; ncred++) {
- if (auth->credtype[ncred] != VIR_CRED_AUTHNAME) {
- continue;
- }
-
- cred.type = VIR_CRED_AUTHNAME;
- cred.prompt = prompt;
- cred.challenge = hostname;
- cred.defresult = defaultUsername;
- cred.result = NULL;
- cred.resultlen = 0;
-
- if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
- VIR_FREE(cred.result);
- }
-
- break;
- }
-
- VIR_FREE(prompt);
-
- return cred.result;
-}
-
-
-
-char *
-esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
- const char *hostname)
-{
- unsigned int ncred;
- virConnectCredential cred;
- char *prompt;
-
- memset(&cred, 0, sizeof(virConnectCredential));
-
- if (virAsprintf(&prompt, "Enter %s password for %s", username,
- hostname) < 0) {
- return NULL;
- }
-
- for (ncred = 0; ncred < auth->ncredtype; ncred++) {
- if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE &&
- auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) {
- continue;
- }
-
- cred.type = auth->credtype[ncred];
- cred.prompt = prompt;
- cred.challenge = hostname;
- cred.defresult = NULL;
- cred.result = NULL;
- cred.resultlen = 0;
-
- if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
- VIR_FREE(cred.result);
- }
-
- break;
- }
-
- VIR_FREE(prompt);
-
- return cred.result;
-}
-
-
-
int
esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
int *noVerify, int *autoAnswer)
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index b5cb419..f4f971c 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -28,13 +28,6 @@
# include "internal.h"
# include "conf.h"
-char *esxUtil_RequestUsername(virConnectAuthPtr auth,
- const char *defaultUsername,
- const char *hostname);
-
-char *esxUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
- const char *hostname);
-
int esxUtil_ParseQuery(xmlURIPtr uri, char **transport, char **vCenter,
int *noVerify, int *autoAnswer);
diff --git a/src/util/util.c b/src/util/util.c
index 87b0714..4292f01 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2676,3 +2676,92 @@ int virBuildPathInternal(char **path, ...)
return ret;
}
+
+
+
+char *
+virRequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
+ const char *hostname)
+{
+ unsigned int ncred;
+ virConnectCredential cred;
+ char *prompt;
+
+ memset(&cred, 0, sizeof (virConnectCredential));
+
+ if (defaultUsername != NULL) {
+ if (virAsprintf(&prompt, _("Enter username for %s [%s]"), hostname,
+ defaultUsername) < 0) {
+ return NULL;
+ }
+ } else {
+ if (virAsprintf(&prompt, _("Enter username for %s"), hostname) < 0) {
+ return NULL;
+ }
+ }
+
+ for (ncred = 0; ncred < auth->ncredtype; ncred++) {
+ if (auth->credtype[ncred] != VIR_CRED_AUTHNAME) {
+ continue;
+ }
+
+ cred.type = VIR_CRED_AUTHNAME;
+ cred.prompt = prompt;
+ cred.challenge = hostname;
+ cred.defresult = defaultUsername;
+ cred.result = NULL;
+ cred.resultlen = 0;
+
+ if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+ VIR_FREE(cred.result);
+ }
+
+ break;
+ }
+
+ VIR_FREE(prompt);
+
+ return cred.result;
+}
+
+
+
+char *
+virRequestPassword(virConnectAuthPtr auth, const char *username,
+ const char *hostname)
+{
+ unsigned int ncred;
+ virConnectCredential cred;
+ char *prompt;
+
+ memset(&cred, 0, sizeof (virConnectCredential));
+
+ if (virAsprintf(&prompt, _("Enter %s password for %s"), username,
+ hostname) < 0) {
+ return NULL;
+ }
+
+ for (ncred = 0; ncred < auth->ncredtype; ncred++) {
+ if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE &&
+ auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) {
+ continue;
+ }
+
+ cred.type = auth->credtype[ncred];
+ cred.prompt = prompt;
+ cred.challenge = hostname;
+ cred.defresult = NULL;
+ cred.result = NULL;
+ cred.resultlen = 0;
+
+ if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+ VIR_FREE(cred.result);
+ }
+
+ break;
+ }
+
+ VIR_FREE(prompt);
+
+ return cred.result;
+}
diff --git a/src/util/util.h b/src/util/util.h
index e8fc565..9796e0a 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -268,4 +268,9 @@ void virFileWaitForDevices(void);
# define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
+char *virRequestUsername(virConnectAuthPtr auth, const char *defaultUsername,
+ const char *hostname);
+char *virRequestPassword(virConnectAuthPtr auth, const char *username,
+ const char *hostname);
+
#endif /* __VIR_UTIL_H__ */
--
1.6.3.3
2
4
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/nodeinfo.c | 4 ++--
src/xenapi/xenapi_driver.c | 27 ++++++++++++++---------------
src/xenapi/xenapi_utils.c | 4 ++--
3 files changed, 17 insertions(+), 18 deletions(-)
Actually, one more error is reported by syntax-check, but it's already fixed
in "xenapi: Request a username if there is non in the URI" patch sent by
Matthias yesterday:
src/xenapi/xenapi_driver.c: if (passwd) VIR_FREE(passwd)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index bf57517..4858e71 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -162,10 +162,10 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
nodeinfo->cores = 1;
nodeinfo->nodes = 1;
-#if HAVE_NUMACTL
+# if HAVE_NUMACTL
if (numa_available() >= 0)
nodeinfo->nodes = numa_max_node() + 1;
-#endif
+# endif
/* NB: It is impossible to fill our nodes, since cpuinfo
* has no knowledge of NUMA nodes */
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 8d5c8bb..ad77068 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -1716,11 +1716,11 @@ write_func(void *ptr, size_t size, size_t nmemb, void *comms_)
{
xen_comms *comms = comms_;
size_t n = size * nmemb;
- #ifdef PRINT_XML
- printf("\n\n---Result from server -----------------------\n");
- printf("%s\n",((char*) ptr));
- fflush(stdout);
- #endif
+#ifdef PRINT_XML
+ printf("\n\n---Result from server -----------------------\n");
+ printf("%s\n",((char*) ptr));
+ fflush(stdout);
+#endif
return (size_t) (comms->func(ptr, n, comms->handle) ? n : 0);
}
@@ -1734,12 +1734,11 @@ call_func(const void *data, size_t len, void *user_handle,
{
//(void)user_handle;
struct _xenapiPrivate *priv = (struct _xenapiPrivate *)user_handle;
- #ifdef PRINT_XML
-
- printf("\n\n---Data to server: -----------------------\n");
- printf("%s\n",((char*) data));
- fflush(stdout);
- #endif
+#ifdef PRINT_XML
+ printf("\n\n---Data to server: -----------------------\n");
+ printf("%s\n",((char*) data));
+ fflush(stdout);
+#endif
CURL *curl = curl_easy_init();
if (!curl) {
return -1;
@@ -1750,9 +1749,9 @@ call_func(const void *data, size_t len, void *user_handle,
};
curl_easy_setopt(curl, CURLOPT_URL, priv->url);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
- #ifdef CURLOPT_MUTE
- curl_easy_setopt(curl, CURLOPT_MUTE, 1);
- #endif
+#ifdef CURLOPT_MUTE
+ curl_easy_setopt(curl, CURLOPT_MUTE, 1);
+#endif
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_func);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &comms);
curl_easy_setopt(curl, CURLOPT_POST, 1);
diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c
index 4b9a6d8..59edbf3 100644
--- a/src/xenapi/xenapi_utils.c
+++ b/src/xenapi/xenapi_utils.c
@@ -548,7 +548,7 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
char macStr[VIR_MAC_STRING_BUFLEN];
virFormatMacAddr(def->nets[i]->mac, macStr);
if (!(mac = strdup(macStr))) {
- if (bridge) VIR_FREE(bridge);
+ VIR_FREE(bridge);
goto error_cleanup;
}
}
@@ -559,7 +559,7 @@ createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
VIR_FREE(bridge);
device_number++;
}
- if (bridge) VIR_FREE(bridge);
+ VIR_FREE(bridge);
}
}
return 0;
--
1.7.0.2
2
2
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_monitor_text.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index e629c6b..b7c41a1 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -939,7 +939,7 @@ static int qemuMonitorTextSaveMemory(qemuMonitorPtr mon,
if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
- _("could save memory region to '%s'"), path);
+ _("could not save memory region to '%s'"), path);
goto cleanup;
}
@@ -986,7 +986,7 @@ int qemuMonitorTextSetMigrationSpeed(qemuMonitorPtr mon,
if (qemuMonitorCommand(mon, cmd, &info) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("could restrict migration speed"));
+ "%s", _("could not restrict migration speed"));
goto cleanup;
}
--
1.7.0.2
2
1
Re: [libvirt] [PATCH 1/2] Addition of XenAPI support to libvirt
by Sharadha Prabhakar (3P) 15 Mar '10
by Sharadha Prabhakar (3P) 15 Mar '10
15 Mar '10
Patch includes
1) Modification of xenapiDomainGetOSType
1) global url and SSL flags removed and placed in private driver struct.
2) SSL verify on url parsed using function similar to the one in ESX.
3) mapDomainPinVcpu updated in xenapi_utils.c
diff -Nur ./libvirt_org/src/xenapi/xenapi_driver.c ./libvirt/src/xenapi/xenapi_driver.c
--- ./libvirt_org/src/xenapi/xenapi_driver.c 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_driver.c 2010-03-04 16:59:01.000000000 +0000
@@ -0,0 +1,1738 @@
+
+/*
+ * xenapi_driver.c: Xen API driver.
+ * Copyright (C) 2009 Citrix Ltd.
+ * Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+*/
+
+#include <config.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <libxml/uri.h>
+#include <xen_internal.h>
+#include <libxml/parser.h>
+#include <curl/curl.h>
+#include <xen/api/xen_common.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_all.h>
+#include <xen/api/xen_vm_metrics.h>
+
+#include "libvirt_internal.h"
+#include "libvirt/libvirt.h"
+#include "domain_conf.h"
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "xenapi_driver.h"
+#include "xenapi_driver_private.h"
+#include "util.h"
+#include "uuid.h"
+#include "memory.h"
+#include "driver.h"
+#include "buf.h"
+#include "xenapi_utils.h"
+
+
+/*
+*getCapsObject
+*
+*Build the capabilities of the hypervisor
+*Return virCapsPtr on success or NULL on failure
+*/
+static virCapsPtr
+getCapsObject (void)
+{
+ virCapsPtr caps = virCapabilitiesNew("x86_64", 0, 0);
+ if (!caps) {
+ virReportOOMError();
+ return NULL;
+ }
+ virCapsGuestPtr guest1 = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 0, "", "", 0, NULL);
+ if (!guest1)
+ goto error_cleanup;
+ virCapsGuestDomainPtr domain1 = virCapabilitiesAddGuestDomain(guest1, "xen", "", "", 0, NULL);
+ if (!domain1)
+ goto error_cleanup;
+ virCapsGuestPtr guest2 = virCapabilitiesAddGuest(caps, "xen", "x86_64", 0, "", "", 0, NULL);
+ if (!guest2)
+ goto error_cleanup;
+ virCapsGuestDomainPtr domain2 = virCapabilitiesAddGuestDomain(guest2, "xen", "", "", 0, NULL);
+ if (!domain2)
+ goto error_cleanup;
+
+ return caps;
+
+ error_cleanup:
+ virCapabilitiesFree(caps);
+ return NULL;
+}
+
+/*
+*XenapiOpen
+*
+*Authenticates and creates a session with the server
+*Return VIR_DRV_OPEN_SUCCESS on success, else VIR_DRV_OPEN_ERROR
+*/
+static virDrvOpenStatus
+xenapiOpen (virConnectPtr conn, virConnectAuthPtr auth , int flags ATTRIBUTE_UNUSED)
+{
+ char *passwd;
+ xen_session *session;
+ struct _xenapiPrivate *privP;
+ int noVerify=0;
+
+ if (!STRCASEEQ(conn->uri->scheme,"XenAPI")) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED ,"Check URI format: 'XenAPI://user@server'");
+ return VIR_DRV_OPEN_DECLINED;
+ }
+ if (conn->uri->server==NULL) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED ,"Server name not in URI");
+ return VIR_DRV_OPEN_ERROR;
+ }
+ if (auth) {
+ passwd = xenapiUtil_RequestPassword(auth,conn->uri->user,conn->uri->server);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED ,"Authentication Credentials not found");
+ return VIR_DRV_OPEN_ERROR;
+ }
+ if (!passwd && !conn->uri->user) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED ,"Username/Password not valid");
+ return VIR_DRV_OPEN_ERROR;
+ }
+ if (VIR_ALLOC(privP) < 0) {
+ virReportOOMError();
+ return VIR_DRV_OPEN_ERROR;
+ }
+ if (virAsprintf(&(privP->url),"https://%s",conn->uri->server) < 0) {
+ virReportOOMError();
+ return VIR_DRV_OPEN_ERROR;
+ }
+ privP->SSLflag=2;
+ xenapiUtil_ParseQuery(conn, conn->uri,&noVerify);
+ if (noVerify==1) privP->SSLflag=0;
+ xmlInitParser();
+ xmlKeepBlanksDefault(0);
+ xen_init();
+ curl_global_init(CURL_GLOBAL_ALL);
+
+ session = xen_session_login_with_password (call_func, (void *)privP, conn->uri->user, "xenroot", xen_api_latest_version);
+
+ if ( session && session->ok ) {
+ privP->session = session;
+ virCapsPtr caps = getCapsObject();
+ if (caps)
+ privP->caps = caps;
+ conn->privateData = privP;
+ return VIR_DRV_OPEN_SUCCESS;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_AUTH_FAILED ,"");
+ VIR_FREE(privP);
+ return VIR_DRV_OPEN_ERROR;
+ }
+}
+
+/*
+* xenapiClose:
+*
+* Returns 0 on successful session logout
+*
+*/
+static int
+xenapiClose (virConnectPtr conn)
+{
+ xen_session_logout(((struct _xenapiPrivate *)(conn->privateData))->session);
+ virCapabilitiesFree(((struct _xenapiPrivate *)(conn->privateData))->caps);
+ VIR_FREE(((struct _xenapiPrivate *)(conn->privateData))->url);
+ VIR_FREE(conn->privateData);
+ return 0;
+}
+
+/*
+*
+* xenapiSupportsFeature
+*
+* Returns 0
+*/
+static int
+xenapiSupportsFeature (virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
+{
+ switch (feature) {
+ case VIR_DRV_FEATURE_MIGRATION_V2:
+ case VIR_DRV_FEATURE_MIGRATION_P2P:
+ default:
+ return 0;
+ }
+}
+
+/*
+* xenapiType:
+*
+*
+*Returns name of the driver
+*/
+static const char *
+xenapiType (virConnectPtr conn ATTRIBUTE_UNUSED)
+{
+ return "XenAPI";
+}
+
+
+/*
+* xenapiGetVersion:
+*
+* Gets the version of XenAPI
+*
+*/
+static int
+xenapiGetVersion (virConnectPtr conn, unsigned long *hvVer)
+{
+ xen_host host;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ xen_string_string_map *result=NULL;
+ if (!(xen_session_get_this_host(session, &host,session))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+ return -1;
+ }
+ if (!(xen_host_get_software_version(session, &result, host))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+ xen_host_free(host);
+ return -1;
+ }
+ xen_host_free(host);
+ if (result && result->size>0) {
+ int i;
+ char *version=NULL;
+ for (i=0; i<result->size; i++) {
+ if (STREQ(result->contents[i].key,"xen")) {
+ if (!(version = strdup(result->contents[i].val))) {
+ xen_string_string_map_free(result);
+ virReportOOMError();
+ return -1;
+ }
+ break;
+ }
+ }
+ if (version) {
+ unsigned long major=0,minor=0,release=0;
+ if (sscanf(version,"%ld.%ld.%ld",&major,&minor,&release)!=3) {
+ virReportOOMError();
+ xen_string_string_map_free(result);
+ VIR_FREE(version);
+ return -1;
+ }
+ *hvVer = major * 1000000 + minor * 1000 + release;
+ VIR_FREE(version);
+ xen_string_string_map_free(result);
+ return 0;
+ }
+ }
+ return -1;
+}
+
+
+/*
+* xenapiGetHostname:
+*
+*
+* Returns the hostname on success, or NULL on failure
+*/
+static char *
+xenapiGetHostname (virConnectPtr conn)
+{
+ char *result=NULL;
+ xen_host host;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ if (!(xen_session_get_this_host(session, &host, session))) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+ return NULL;
+ }
+ if (!(xen_host_get_hostname(session, &result, host)))
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+ xen_host_free(host);
+ return result;
+}
+
+
+/*
+* xenapiGetMaxVcpus:
+*
+*
+* Returns a hardcoded value for Maximum VCPUS
+*/
+static int
+xenapiGetMaxVcpus (virConnectPtr conn ATTRIBUTE_UNUSED, const char *type ATTRIBUTE_UNUSED)
+{
+ /* this is hardcoded for simplicity and set to a resonable value compared
+ to the actual value */
+ return 16;
+}
+
+
+/*
+* xenapiNodeGetInfo:
+*
+*
+* Returns Node details on success or else -1
+*/
+static int
+xenapiNodeGetInfo (virConnectPtr conn, virNodeInfoPtr info)
+{
+ int64_t memory,mhz;
+ xen_host_cpu_set *host_cpu_set;
+ xen_host_cpu host_cpu;
+ xen_host_metrics_set *xen_met_set;
+ char *modelname;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ info->nodes = 1;
+ info->threads = 1;
+ info->sockets = 1;
+
+ if (xen_host_metrics_get_all(session, &xen_met_set)) {
+ xen_host_metrics_get_memory_total(session, &memory, xen_met_set->contents[0]);
+ info->memory = (unsigned long)(memory/1024);
+ xen_host_metrics_set_free(xen_met_set);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,"Unable to get host metric Information");
+ return -1;
+ }
+ if (xen_host_cpu_get_all(session, &host_cpu_set)) {
+ host_cpu = host_cpu_set->contents[0];
+ xen_host_cpu_get_modelname(session, &modelname, host_cpu);
+ if (!virStrncpy(info->model,modelname,LIBVIRT_MODELNAME_LEN-1,LIBVIRT_MODELNAME_LEN)){
+ virReportOOMError();
+ xen_host_cpu_set_free(host_cpu_set);
+ VIR_FREE(modelname);
+ return -1;
+ }
+ xen_host_cpu_get_speed(session, &mhz, host_cpu);
+ info->mhz = (unsigned long)mhz;
+ info->cpus = host_cpu_set->size;
+ info->cores = host_cpu_set->size;
+
+ xen_host_cpu_set_free(host_cpu_set);
+ VIR_FREE(modelname);
+ return 0;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,"Unable to get Host CPU set");
+ return -1;
+}
+
+/*
+* xenapiGetCapabilities:
+*
+*
+* Returns capabilities as an XML string
+*/
+static char *
+xenapiGetCapabilities (virConnectPtr conn)
+{
+ virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
+ if (caps) {
+ char *xml = virCapabilitiesFormatXML(caps);
+ return xml;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,"Capabilities not available");
+ return NULL;
+}
+
+
+/*
+* xenapiListDomains
+*
+* Collects the list of active domains, and store their ID in @maxids
+* Returns the number of domain found or -1 in case of error
+*/
+static int
+xenapiListDomains (virConnectPtr conn, int *ids, int maxids)
+{
+ /* vm.list */
+ xen_host host;
+ xen_vm_set *result=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ if (xen_session_get_this_host(session, &host, session)) {
+ xen_host_get_resident_vms(session, &result, host);
+ xen_host_free(host);
+ } else
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+
+ if (result != NULL) {
+ int i;
+ for ( i=0; (i < (result->size)) && (i<maxids) ; i++ ) {
+ int64_t t0;
+ xen_vm_get_domid(session, &t0, result->contents[i]);
+ ids[i] = (int)(t0 & 0xffffffff);
+ }
+ xen_vm_set_free(result);
+ return i;
+ }
+ return -1;
+}
+
+/*
+* xenapiNumOfDomains
+*
+*
+* Returns the number of domains found or -1 in case of error
+*/
+static int
+xenapiNumOfDomains (virConnectPtr conn)
+{
+ /* #(vm.list) */
+ xen_vm_set *result=NULL;
+ xen_host host=NULL;
+ int numDomains=-1;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+
+ xen_session_get_this_host(session, &host, session);
+ if ( host!=NULL ) {
+ xen_host_get_resident_vms(session, &result, host);
+ if ( result != NULL) {
+ numDomains = result->size;
+ xen_vm_set_free(result);
+ }
+ xen_host_free(host);
+ }
+ if (!(session->ok))
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+ return numDomains;
+}
+
+/*
+* xenapiDomainCreateXML
+*
+* Launches a new domain based on the XML description
+* Returns the domain pointer or NULL in case of error
+*/
+static virDomainPtr
+xenapiDomainCreateXML (virConnectPtr conn,
+ const char *xmlDesc, ATTRIBUTE_UNUSED unsigned int flags)
+{
+ xen_vm_record *record=NULL;
+ xen_vm vm=NULL;
+ virDomainPtr domP=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
+ if (!caps)
+ return NULL;
+
+ virDomainDefPtr defPtr = virDomainDefParseString(caps, xmlDesc, flags);
+ createVMRecordFromXml(conn, defPtr, &record, &vm);
+ virDomainDefFree(defPtr);
+ if (record) {
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ virUUIDParse(record->uuid,raw_uuid);
+ if (vm) {
+ if (xen_vm_start(session, vm, false, false)) {
+ domP = virGetDomain(conn, record->name_label, raw_uuid);
+ if (!domP) {
+ xen_vm_record_free(record);
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Domain Pointer is invalid");
+ return domP;
+ }
+ domP->id = record->domid;
+ xen_vm_free(vm);
+ }
+ else
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
+ xen_vm_record_free(record);
+ }
+ else
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return domP;
+}
+
+/*
+* xenapiDomainLookupByID
+*
+*
+* Returns a valid domain pointer of the domain with ID same as the one passed
+* or NULL in case of error
+*/
+static virDomainPtr
+xenapiDomainLookupByID (virConnectPtr conn, int id)
+{
+ int i;
+ int64_t domID;
+ char *uuid;
+ xen_host host;
+ xen_vm_set *result;
+ xen_vm_record *record;
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ virDomainPtr domP=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+
+ xen_session_get_this_host(session, &host, session);
+ if (host!=NULL && session->ok) {
+ xen_host_get_resident_vms(session, &result, host);
+ if ( result !=NULL ) {
+ for( i=0; i < (result->size); i++) {
+ xen_vm_get_domid(session, &domID, result->contents[i]);
+ if ( domID == id ) {
+ xen_vm_get_record(session, &record, result->contents[i]);
+ xen_vm_get_uuid(session, &uuid, result->contents[i]);
+ virUUIDParse(uuid,raw_uuid);
+ domP = virGetDomain(conn, record->name_label, raw_uuid);
+ if (domP) {
+ int64_t domid=-1;
+ xen_vm_get_domid(session, &domid, result->contents[i]);
+ domP->id = domid;
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR , "Domain Pointer not valid");
+ domP = NULL;
+ }
+ xen_uuid_free(uuid);
+ xen_vm_record_free(record);
+ break;
+ }
+ }
+ xen_vm_set_free(result);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN ,NULL);
+ }
+ xen_host_free(host);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR ,NULL);
+ }
+ return domP;
+}
+
+/*
+* xenapiDomainLookupByUUID
+*
+* Returns the domain pointer of domain with matching UUID
+* or -1 in case of error
+*/
+static virDomainPtr
+xenapiDomainLookupByUUID (virConnectPtr conn,
+ const unsigned char *uuid)
+{
+ /* vm.get_by_uuid */
+ xen_vm vm;
+ xen_vm_record *record;
+ char uuidStr[VIR_UUID_STRING_BUFLEN];
+ virDomainPtr domP=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ virUUIDFormat(uuid,uuidStr);
+ if (xen_vm_get_by_uuid(session, &vm, uuidStr)) {
+ xen_vm_get_record(session, &record, vm);
+ if (record != NULL) {
+ domP = virGetDomain(conn, record->name_label, uuid);
+ if (!domP) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR , "Domain Pointer not valid");
+ domP=NULL;
+ } else {
+ domP->id = record->domid;
+ }
+ xen_vm_record_free(record);
+ }
+ else
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN ,NULL);
+ xen_vm_free(vm);
+ } else
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN ,NULL);
+ return domP;
+}
+
+/*
+* xenapiDomainLookupByName
+*
+* Returns the domain pointer of domain with matching name
+* or -1 in case of error
+*/
+static virDomainPtr
+xenapiDomainLookupByName (virConnectPtr conn,
+ const char *name)
+{
+ /* vm.get_by_name_label */
+ xen_vm_set *vms=NULL;
+ xen_vm vm;
+ char *uuid=NULL;
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ virDomainPtr domP=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, (char *)name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return NULL;
+ }
+ vm = vms->contents[0];
+ xen_vm_get_uuid(session, &uuid, vm);
+ if (uuid!=NULL) {
+ virUUIDParse(uuid,raw_uuid);
+ domP = virGetDomain(conn, name, raw_uuid);
+ if (domP != NULL) {
+ int64_t domid=-1;
+ xen_vm_get_domid(session, &domid, vm);
+ domP->id = domid;
+ xen_uuid_free(uuid);
+ xen_vm_set_free(vms);
+ return domP;
+ } else {
+ xen_uuid_free(uuid);
+ xen_vm_set_free(vms);
+ if (!(session->ok))
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
+ return NULL;
+ }
+ }
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
+ return NULL;
+}
+
+/*
+* xenapiDomainSuspend
+*
+* a VM is paused
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainSuspend (virDomainPtr dom)
+{
+ /* vm.pause() */
+ xen_vm vm;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn,VIR_ERR_NO_DOMAIN,NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ } else {
+ vm = vms->contents[0];
+ if (!xen_vm_pause(session, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ }
+ return 0;
+}
+
+/*
+* xenapiDomainResume
+*
+* Resumes a VM
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainResume (virDomainPtr dom)
+{
+ /* vm.unpause() */
+ xen_vm vm;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ } else {
+ vm = vms->contents[0];
+ if (!xen_vm_unpause(session, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ }
+ return 0;
+}
+
+/*
+* xenapiDomainShutdown
+*
+* shutsdown a VM
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainShutdown (virDomainPtr dom)
+{
+ /* vm.clean_shutdown */
+ xen_vm vm;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if(!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ } else {
+ vm = vms->contents[0];
+ if (!xen_vm_clean_shutdown(session, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ }
+ return 0;
+}
+
+/*
+* xenapiDomainReboot
+*
+* Reboots a VM
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainReboot (virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED)
+{
+ /* vm.clean_reboot */
+ xen_vm vm;
+ struct xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!xen_vm_clean_reboot(session, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ return 0;
+}
+
+/*
+* xenapiDomaindestroy
+*
+* A VM is hard shutdown
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainDestroy (virDomainPtr dom)
+{
+ /* vm.hard_shutdown */
+ xen_vm vm;
+ struct xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!xen_vm_hard_shutdown(session, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ return 0;
+}
+
+/*
+* xenapiDomainGetOSType
+*
+*
+* Returns OS version on success or NULL in case of error
+*/
+static char *
+xenapiDomainGetOSType (virDomainPtr dom)
+{
+ xen_vm vm=NULL;
+ xen_vm_set *vms;
+ char *ostype = NULL;
+ char *boot_policy=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)){
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return NULL;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return NULL;
+ }
+ vm = vms->contents[0];
+ if(!xen_vm_get_hvm_boot_policy(session, &boot_policy, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ goto cleanup;
+ }
+ if (!(ostype=(STREQ(boot_policy,"BIOS order")?strdup("hvm"):strdup("xen"))))
+ virReportOOMError();
+ VIR_FREE(boot_policy);
+ cleanup:
+ xen_vm_set_free(vms);
+ return ostype;
+}
+/*
+* xenapiDomainGetMaxMemory
+*
+* Returns maximum static memory for VM on success
+* or 0 in case of error
+*/
+static unsigned long
+xenapiDomainGetMaxMemory (virDomainPtr dom)
+{
+ int64_t mem_static_max=0;
+ xen_vm vm;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return 0;
+ }
+ vm = vms->contents[0];
+ xen_vm_get_memory_static_max(session, &mem_static_max, vm);
+ xen_vm_set_free(vms);
+ return (unsigned long)(mem_static_max/1024);
+ } else {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return 0;
+ }
+}
+
+/*
+* xenapiDomainSetMaxMemory
+*
+* Sets maximum static memory for VM on success
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainSetMaxMemory (virDomainPtr dom, unsigned long memory)
+{
+ /* vm.set_memory_static_max */
+ xen_vm vm;
+ struct xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!(xen_vm_set_memory_static_max(session, vm, memory))) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ } else {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ return 0;
+}
+
+/*
+* xenapiDomainGetInfo:
+*
+* Fills a structure with domain information
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainGetInfo (virDomainPtr dom, virDomainInfoPtr info)
+{
+ int64_t maxmem=0,memory=0,vcpu=0;
+ xen_vm vm;
+ xen_vm_record *record;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ info->cpuTime = 0; /* CPU time is not advertised */
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ xen_vm_get_memory_static_max(session, &maxmem, vm);
+ info->maxMem = (maxmem/1024);
+ enum xen_vm_power_state state = XEN_VM_POWER_STATE_UNKNOWN;
+ xen_vm_get_power_state(session, &state, vm);
+ info->state = mapPowerState(state);
+ xen_vm_get_record(session, &record, vm);
+ if (record!=NULL) {
+ xen_vm_metrics_get_memory_actual(session, &memory, record->metrics->u.handle);
+ info->memory = (memory/1024);
+ xen_vm_record_free(record);
+ }
+ xen_vm_get_vcpus_max(session, &vcpu, vm);
+ info->nrVirtCpu = vcpu;
+ xen_vm_set_free(vms);
+ return 0;
+ }
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+}
+
+
+/*
+* xenapiDomainSetVcpus
+*
+* Sets the VCPUs on the domain
+* Return 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainSetVcpus (virDomainPtr dom, unsigned int nvcpus)
+{
+
+ /* vm.set_vcpus_max */
+ xen_vm vm;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (xen_vm_set_vcpus_number_live(session, vm, (int64_t)nvcpus)) {
+ xen_vm_set_free(vms);
+ return 0;
+ }
+ }
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+}
+
+/*
+* xenapiDomainPinVcpu
+*
+* Dynamically change the real CPUs which can be allocated to a virtual CPU
+* Returns 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainPinVcpu (virDomainPtr dom, unsigned int vcpu ATTRIBUTE_UNUSED,
+ unsigned char *cpumap, int maplen)
+{
+ char *value=NULL;
+ xen_vm vm;
+ xen_vm_set *vms;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if ((value = mapDomainPinVcpu(cpumap, maplen))) {
+ xen_vm_remove_from_vcpus_params(session, vm, (char *)"mask");
+ if (xen_vm_add_to_vcpus_params(session, vm, (char *)"mask", value)) {
+ xen_vm_set_free(vms);
+ VIR_FREE(value);
+ return 0;
+ }
+ VIR_FREE(value);
+ } else {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ }
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+}
+
+/*
+* xenapiDomainGetVcpus
+*
+* Gets Vcpu information
+* Return number of structures filled on success or -1 in case of error
+*/
+static int
+xenapiDomainGetVcpus (virDomainPtr dom,
+ virVcpuInfoPtr info, int maxinfo,
+ unsigned char *cpumaps, int maplen)
+{
+
+ xen_vm_set *vms=NULL;
+ xen_vm vm=NULL;
+ xen_string_string_map *vcpu_params=NULL;
+ int nvcpus=0,cpus=0,i;
+ virDomainInfoPtr domInfo;
+ virNodeInfo nodeInfo;
+ virVcpuInfoPtr ifptr;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ char *mask=NULL;
+ if((cpumaps!=NULL) && (maplen < 1))
+ return -1;
+ if (VIR_ALLOC(domInfo)<0) {
+ virReportOOMError();
+ return -1;
+ }
+ if (virDomainGetInfo(dom,domInfo)==0) {
+ nvcpus = domInfo->nrVirtCpu;
+ VIR_FREE(domInfo);
+ } else {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Couldn't fetch Domain Information");
+ return -1;
+ }
+ if ( virNodeGetInfo(dom->conn,&nodeInfo)==0)
+ cpus = nodeInfo.cpus;
+ else {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Couldn't fetch Node Information");
+ return -1;
+ }
+ if(nvcpus > maxinfo) nvcpus = maxinfo;
+
+ if (cpumaps != NULL)
+ memset(cpumaps, 0, maxinfo * maplen);
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) return -1;
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!xen_vm_get_vcpus_params(session, &vcpu_params, vm)) {
+ xen_vm_set_free(vms);
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+ }
+ for (i=0; i<vcpu_params->size; i++) {
+ if (STREQ(vcpu_params->contents[i].key,"mask")) {
+ if (!(mask = strdup(vcpu_params->contents[i].val))){
+ xen_vm_set_free(vms);
+ xen_string_string_map_free(vcpu_params);
+ virReportOOMError();
+ return -1;
+ }
+ break;
+ }
+ }
+ xen_string_string_map_free(vcpu_params);
+ for (i=0,ifptr=info ;i<nvcpus; i++,ifptr++) {
+ ifptr->number = i;
+ ifptr->state = VIR_VCPU_RUNNING;
+ ifptr->cpuTime = 0;
+ ifptr->cpu = 0;
+ if (mask !=NULL)
+ getCpuBitMapfromString(mask,VIR_GET_CPUMAP(cpumaps,maplen,i),maplen);
+ }
+ VIR_FREE(mask);
+ xen_vm_set_free(vms);
+ return i;
+}
+
+/*
+* xenapiDomainGetMaxVcpus
+*
+*
+* Returns maximum number of Vcpus on success or -1 in case of error
+*/
+static int
+xenapiDomainGetMaxVcpus (virDomainPtr dom)
+{
+ xen_vm vm;
+ xen_vm_set *vms;
+ int64_t maxvcpu=0;
+ enum xen_vm_power_state state;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ xen_vm_get_power_state(session, &state, vm);
+ if(state == XEN_VM_POWER_STATE_RUNNING) {
+ xen_vm_get_vcpus_max(session, &maxvcpu, vm);
+ } else {
+ maxvcpu = xenapiGetMaxVcpus(dom->conn, NULL);
+ }
+ xen_vm_set_free(vms);
+ return (int)maxvcpu;
+ }
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+}
+
+/*
+* xenapiDomainDumpXML
+*
+*
+* Returns XML string of the domain configuration on success or -1 in case of error
+*/
+static char *
+xenapiDomainDumpXML (virDomainPtr dom, ATTRIBUTE_UNUSED int flags)
+{
+ xen_vm vm=NULL;
+ xen_vm_set *vms;
+ xen_string_string_map *result=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ virDomainDefPtr defPtr = NULL;
+
+ if(!xen_vm_get_by_name_label(session, &vms, dom->name)) return NULL;
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return NULL;
+ }
+ if (VIR_ALLOC(defPtr)<0) {
+ virReportOOMError();
+ xen_vm_set_free(vms);
+ return NULL;
+ }
+ vm = vms->contents[0];
+ defPtr->virtType = VIR_DOMAIN_VIRT_XEN;
+ defPtr->id = dom->id;
+ memcpy((char *)defPtr->uuid,(char *)dom->uuid,VIR_UUID_BUFLEN);
+ if (!(defPtr->name = strdup(dom->name)))
+ goto error_cleanup;
+ char *boot_policy=NULL;
+ xen_vm_get_hvm_boot_policy(session, &boot_policy, vm);
+ if (STREQ(boot_policy,"BIOS order")) {
+ if (!(defPtr->os.type = strdup("hvm"))) {
+ VIR_FREE(boot_policy);
+ goto error_cleanup;
+ }
+ xen_vm_get_hvm_boot_params(session, &result, vm);
+ if (result!=NULL) {
+ int i;
+ for (i=0; i<(result->size); i++) {
+ if (STREQ(result->contents[i].key,"order")) {
+ int cnt=0;
+ while(result->contents[i].val[cnt]!='\0') {
+ defPtr->os.bootDevs[cnt] = map2LibvirtBootOrder(result->contents[i].val[cnt]);
+ cnt++;
+ }
+ defPtr->os.nBootDevs = cnt;
+ }
+ }
+ xen_string_string_map_free(result);
+ }
+ VIR_FREE(boot_policy);
+ } else {
+ if(!(defPtr->os.type = strdup("xen"))) {
+ VIR_FREE(boot_policy);
+ goto error_cleanup;
+ }
+ if(!(defPtr->os.loader = strdup("pygrub"))) {
+ VIR_FREE(boot_policy);
+ goto error_cleanup;
+ }
+ char *value=NULL;
+ xen_vm_get_pv_kernel(session, &value, vm);
+ if (STRNEQ(value,"")) {
+ if(!(defPtr->os.kernel = strdup(value))) {
+ VIR_FREE(boot_policy);
+ VIR_FREE(value);
+ goto error_cleanup;
+ }
+ VIR_FREE(value);
+ }
+ xen_vm_get_pv_ramdisk(session, &value, vm);
+ if (STRNEQ(value,"")) {
+ if(!(defPtr->os.initrd = strdup(value))) {
+ VIR_FREE(boot_policy);
+ VIR_FREE(value);
+ goto error_cleanup;
+ }
+ VIR_FREE(value);
+ }
+ xen_vm_get_pv_args(session, &value, vm);
+ if (STRNEQ(value,"")) {
+ if(!(defPtr->os.cmdline = strdup(value))) {
+ VIR_FREE(boot_policy);
+ VIR_FREE(value);
+ goto error_cleanup;
+ }
+ VIR_FREE(value);
+ }
+ VIR_FREE(boot_policy);
+ if(!(defPtr->os.bootloader = strdup("pygrub")))
+ goto error_cleanup;
+ }
+ char *val=NULL;
+ xen_vm_get_pv_bootloader_args(session, &val, vm);
+ if (STRNEQ(val,"")) {
+ if(!(defPtr->os.bootloaderArgs = strdup(val))) {
+ VIR_FREE(val);
+ goto error_cleanup;
+ }
+ VIR_FREE(val);
+ }
+ unsigned long memory=0;
+ memory = xenapiDomainGetMaxMemory(dom);
+ defPtr->maxmem = memory;
+ int64_t dynamic_mem=0;
+ if (xen_vm_get_memory_dynamic_max(session, &dynamic_mem, vm)) {
+ defPtr->memory = (unsigned long) (dynamic_mem/1024);
+ } else {
+ defPtr->memory = memory;
+ }
+ defPtr->vcpus = xenapiDomainGetMaxVcpus(dom);
+ enum xen_on_normal_exit action;
+ if (xen_vm_get_actions_after_shutdown(session, &action, vm)) {
+ defPtr->onPoweroff = xenapiNormalExitEnum2virDomainLifecycle(action);
+ }
+ if (xen_vm_get_actions_after_reboot(session, &action, vm)) {
+ defPtr->onReboot = xenapiNormalExitEnum2virDomainLifecycle(action);
+ }
+ enum xen_on_crash_behaviour crash;
+ if (xen_vm_get_actions_after_crash(session, &crash, vm)) {
+ defPtr->onCrash = xenapiCrashExitEnum2virDomainLifecycle(action);
+ }
+ xen_vm_get_platform(session, &result, vm);
+ if (result!=NULL) {
+ int i;
+ for(i=0; i< (result->size); i++) {
+ if (STREQ(result->contents[i].val,"true")) {
+ if (STREQ(result->contents[i].key,"acpi"))
+ defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_ACPI);
+ else if (STREQ(result->contents[i].key,"apic"))
+ defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_APIC);
+ else if (STREQ(result->contents[i].key,"pae"))
+ defPtr->features = defPtr->features | (1<<VIR_DOMAIN_FEATURE_PAE);
+ }
+ }
+ xen_string_string_map_free(result);
+ }
+ struct xen_vif_set *vif_set=NULL;
+ xen_vm_get_vifs(session, &vif_set, vm);
+ if (vif_set) {
+ int i;
+ xen_vif vif;
+ xen_vif_record *vif_rec=NULL;
+ xen_network network;
+ char *bridge=NULL;
+ defPtr->nnets = vif_set->size;
+ if (VIR_ALLOC_N(defPtr->nets, vif_set->size)<0) {
+ xen_vif_set_free(vif_set);
+ goto error_cleanup;
+ }
+ for (i=0; i<vif_set->size; i++) {
+ if (VIR_ALLOC(defPtr->nets[i])<0) {
+ xen_vif_set_free(vif_set);
+ goto error_cleanup;
+ }
+ defPtr->nets[i]->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+ vif = vif_set->contents[i];
+ xen_vif_get_network(session, &network, vif);
+ if (network!=NULL) {
+ xen_network_get_bridge(session, &bridge, network);
+ if (bridge!=NULL)
+ defPtr->nets[i]->data.bridge.brname = bridge;
+ xen_network_free(network);
+ }
+ xen_vif_get_record(session, &vif_rec, vif);
+ if (vif_rec!=NULL) {
+ if(virParseMacAddr((const char *)vif_rec->mac,defPtr->nets[i]->mac) < 0)
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, "Unable to parse given mac address");
+ xen_vif_record_free(vif_rec);
+ }
+ }
+ xen_vif_set_free(vif_set);
+ }
+ if (vms) xen_vm_set_free(vms);
+ char *xml = virDomainDefFormat(defPtr,0);
+ virDomainDefFree(defPtr);
+ return xml;
+
+ error_cleanup:
+ virReportOOMError();
+ xen_vm_set_free(vms);
+ virDomainDefFree(defPtr);
+ return NULL;
+
+}
+
+/*
+* xenapiListDefinedDomains
+*
+* list the defined but inactive domains, stores the pointers to the names in @names
+* Returns number of names provided in the array or -1 in case of error
+*/
+static int
+xenapiListDefinedDomains (virConnectPtr conn, char **const names,
+ int maxnames)
+{
+ int i,j=0,doms;
+ xen_vm_set *result;
+ xen_vm_record *record;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ xen_vm_get_all(session, &result);
+ if (result != NULL) {
+ for (i=0; i< (result->size) && j< maxnames; i++) {
+ xen_vm_get_record(session, &record, result->contents[i]);
+ if ( record!=NULL ) {
+ if ( record->is_a_template == 0 ) {
+ char *usenames;
+ if (!(usenames = strdup(record->name_label))) {
+ virReportOOMError();
+ xen_vm_record_free(record);
+ xen_vm_set_free(result);
+ return -1;
+ }
+ names[j++]=usenames;
+ }
+ xen_vm_record_free(record);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get VM record");
+ xen_vm_set_free(result);
+ return -1;
+ }
+ }
+ doms=j;
+ xen_vm_set_free(result);
+ return doms;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+}
+
+/*
+* xenapiNumOfDefinedDomains
+*
+* Provides the number of defined but inactive domains
+* Returns number of domains found on success or -1 in case of error
+*/
+static int
+xenapiNumOfDefinedDomains (virConnectPtr conn)
+{
+ xen_vm_set *result;
+ xen_vm_record *record;
+ int DomNum=0,i;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ xen_vm_get_all(session, &result);
+ if ( result != NULL) {
+ for ( i=0; i< (result->size); i++ ) {
+ xen_vm_get_record(session, &record, result->contents[i]);
+ if (record==NULL && !session->ok) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(result);
+ return -1;
+ }
+ if (record->is_a_template == 0)
+ DomNum++;
+ xen_vm_record_free(record);
+ }
+ xen_vm_set_free(result);
+ return DomNum;
+ }
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ return -1;
+}
+
+/*
+* xenapiDomainCreate
+*
+* starts a VM
+* Return 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainCreate (virDomainPtr dom)
+{
+ xen_vm_set *vms;
+ xen_vm vm;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!xen_vm_start(session, vm, false, false)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ } else {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ return 0;
+}
+
+/*
+* xenapiDomainDefineXML
+*
+* Defines a domain from the given XML but does not start it
+* Returns 0 on success or -1 in case of error
+*/
+static virDomainPtr
+xenapiDomainDefineXML (virConnectPtr conn, const char *xml)
+{
+ xen_vm_record *record=NULL;
+ xen_vm vm=NULL;
+ virDomainPtr domP=NULL;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ virCapsPtr caps = ((struct _xenapiPrivate *)(conn->privateData))->caps;
+ if (!caps)
+ return NULL;
+ virDomainDefPtr defPtr = virDomainDefParseString(caps, xml, 0);
+ if (!defPtr)
+ return NULL;
+ if (createVMRecordFromXml( conn, defPtr, &record, &vm)!=0) {
+ if (!(session->ok))
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ else
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get VM information from XML");
+ virDomainDefFree(defPtr);
+ return NULL;
+ }
+ if (record!=NULL) {
+ unsigned char raw_uuid[VIR_UUID_BUFLEN];
+ virUUIDParse(record->uuid,raw_uuid);
+ domP = virGetDomain(conn, record->name_label, raw_uuid);
+ if (!domP && !(session->ok))
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
+ xen_vm_record_free(record);
+ }
+ else if (vm!=NULL)
+ xen_vm_free(vm);
+ virDomainDefFree(defPtr);
+ return domP;
+}
+
+/*
+* xenapiDomainUndefine
+*
+* destroys a domain
+* Return 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainUndefine (virDomainPtr dom)
+{
+ struct xen_vm_set *vms;
+ xen_vm vm;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!xen_vm_destroy(session, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ return 0;
+}
+
+/*
+* xenapiDomainGetAutostart
+*
+* Provides a boolean value indicating whether the domain configured
+* to be automatically started when the host machine boots
+* Return 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainGetAutostart (virDomainPtr dom, int *autostart)
+{
+ int i,flag=0;
+ xen_vm_set *vms;
+ xen_vm vm;
+ xen_string_string_map *result;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if(!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ if (!xen_vm_get_other_config(session, &result, vm)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ for (i=0; i < result->size; i++) {
+ if (STREQ(result->contents[i].key, "auto_poweron")) {
+ flag=1;
+ if (STREQ(result->contents[i].val, "true"))
+ *autostart = 1;
+ else
+ *autostart = 0;
+ }
+ }
+ xen_vm_set_free(vms);
+ xen_string_string_map_free(result);
+ if (flag==0) return -1;
+ return 0;
+}
+
+/*
+* xenapiDomainSetAutostart
+*
+* Configure the domain to be automatically started when the host machine boots
+* Return 0 on success or -1 in case of error
+*/
+static int
+xenapiDomainSetAutostart (virDomainPtr dom, int autostart)
+{
+ xen_vm_set *vms;
+ xen_vm vm;
+ char *value;
+ xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+ if (!xen_vm_get_by_name_label(session, &vms, dom->name)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ return -1;
+ }
+ if (vms->size!=1) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,"Domain name is not unique");
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ vm = vms->contents[0];
+ xen_vm_remove_from_other_config(session, vm, (char *)"auto_poweron");
+ if (autostart==1)
+ value = (char *)"true";
+ else
+ value = (char *)"false";
+ if (!xen_vm_add_to_other_config(session, vm, (char *)"auto_poweron", value)) {
+ xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ xen_vm_set_free(vms);
+ return -1;
+ }
+ xen_vm_set_free(vms);
+ return 0;
+}
+
+static char *
+xenapiDomainGetSchedulerType (virDomainPtr dom ATTRIBUTE_UNUSED, int *nparams)
+{
+ *nparams = 0;
+ char *result=NULL;
+ if (!(result = strdup("credit")))
+ virReportOOMError();
+ return result;
+}
+
+/*
+* xenapiNodeGetFreeMemory
+*
+* provides the free memory available on the Node
+* Returns memory size on success or 0 in case of error
+*/
+static unsigned long long
+xenapiNodeGetFreeMemory (virConnectPtr conn)
+{
+ xen_host_metrics_set *xen_met_set;
+ unsigned long long freeMem=0;
+ xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
+ xen_host_metrics_get_all(session, &xen_met_set);
+ if (xen_met_set != NULL) {
+ if (!xen_host_metrics_get_memory_free(session, (int64_t *)&freeMem, xen_met_set->contents[0])) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get host metrics - memory information");
+ freeMem=0;
+ }
+ xen_host_metrics_set_free(xen_met_set);
+ } else {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, "Couldn't get host metrics");
+ }
+ return freeMem;
+}
+
+/*
+* xenapiNodeGetCellsFreeMemory
+*
+*
+* Returns the number of entries filled in freeMems, or -1 in case of error.
+*/
+static int
+xenapiNodeGetCellsFreeMemory (virConnectPtr conn, unsigned long long *freeMems,
+ int startCell, int maxCells)
+{
+ if (maxCells >1 && startCell >0) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_NO_SUPPORT, "");
+ return -1;
+ } else {
+ freeMems[0] = xenapiNodeGetFreeMemory(conn);
+ return 1;
+ }
+}
+
+/* The interface which we export upwards to libvirt.c. */
+static virDriver xenapiDriver = {
+ VIR_DRV_XENAPI,
+ "XenAPI",
+ xenapiOpen, /* open */
+ xenapiClose, /* close */
+ xenapiSupportsFeature, /* supports_feature */
+ xenapiType, /* type */
+ xenapiGetVersion, /* version */
+ NULL, /*getlibvirtVersion */
+ xenapiGetHostname, /* getHostname */
+ xenapiGetMaxVcpus, /* getMaxVcpus */
+ xenapiNodeGetInfo, /* nodeGetInfo */
+ xenapiGetCapabilities, /* getCapabilities */
+ xenapiListDomains, /* listDomains */
+ xenapiNumOfDomains, /* numOfDomains */
+ xenapiDomainCreateXML, /* domainCreateXML */
+ xenapiDomainLookupByID, /* domainLookupByID */
+ xenapiDomainLookupByUUID, /* domainLookupByUUID */
+ xenapiDomainLookupByName, /* domainLookupByName */
+ xenapiDomainSuspend, /* domainSuspend */
+ xenapiDomainResume, /* domainResume */
+ xenapiDomainShutdown, /* domainShutdown */
+ xenapiDomainReboot, /* domainReboot */
+ xenapiDomainDestroy, /* domainDestroy */
+ xenapiDomainGetOSType, /* domainGetOSType */
+ xenapiDomainGetMaxMemory, /* domainGetMaxMemory */
+ xenapiDomainSetMaxMemory, /* domainSetMaxMemory */
+ NULL, /* domainSetMemory */
+ xenapiDomainGetInfo, /* domainGetInfo */
+ NULL, /* domainSave */
+ NULL, /* domainRestore */
+ NULL, /* domainCoreDump */
+ xenapiDomainSetVcpus, /* domainSetVcpus */
+ xenapiDomainPinVcpu, /* domainPinVcpu */
+ xenapiDomainGetVcpus, /* domainGetVcpus */
+ xenapiDomainGetMaxVcpus, /* domainGetMaxVcpus */
+ NULL, /* domainGetSecurityLabel */
+ NULL, /* nodeGetSecurityModel */
+ xenapiDomainDumpXML, /* domainDumpXML */
+ NULL, /* domainXmlFromNative */
+ NULL, /* domainXmlToNative */
+ xenapiListDefinedDomains, /* listDefinedDomains */
+ xenapiNumOfDefinedDomains, /* numOfDefinedDomains */
+ xenapiDomainCreate, /* domainCreate */
+ xenapiDomainDefineXML, /* domainDefineXML */
+ xenapiDomainUndefine, /* domainUndefine */
+ NULL, /* domainAttachDevice */
+ NULL,
+ NULL, /* domainDetachDevice */
+ NULL,
+ xenapiDomainGetAutostart, /* domainGetAutostart */
+ xenapiDomainSetAutostart, /* domainSetAutostart */
+ xenapiDomainGetSchedulerType, /* domainGetSchedulerType */
+ NULL, /* domainGetSchedulerParameters */
+ NULL, /* domainSetSchedulerParameters */
+ NULL, /* domainMigratePrepare */
+ NULL, /* domainMigratePerform */
+ NULL, /* domainMigrateFinish */
+ NULL, /* domainBlockStats */
+ NULL, /* domainInterfaceStats */
+ NULL,
+ NULL, /* domainBlockPeek */
+ NULL, /* domainMemoryPeek */
+ xenapiNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
+ xenapiNodeGetFreeMemory, /* getFreeMemory */
+ NULL, /* domainEventRegister */
+ NULL, /* domainEventDeregister */
+ NULL, /* domainMigratePrepare2 */
+ NULL, /* domainMigrateFinish2 */
+ NULL, /* nodeDeviceDettach */
+ NULL, /* nodeDeviceReAttach */
+ NULL, /* nodeDeviceReset */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+/**
+ * xenapiRegister:
+ *
+ *
+ * Returns the driver priority or -1 in case of error.
+ */
+int
+xenapiRegister (void)
+{
+ return virRegisterDriver (&xenapiDriver);
+}
+
+/*
+* write_func
+* used by curl to read data from the server
+*/
+size_t
+write_func(void *ptr, size_t size, size_t nmemb, void *comms_)
+{
+ xen_comms *comms = comms_;
+ size_t n = size * nmemb;
+ #ifdef PRINT_XML
+ printf("\n\n---Result from server -----------------------\n");
+ printf("%s\n",((char*) ptr));
+ fflush(stdout);
+ #endif
+ return (size_t) (comms->func(ptr, n, comms->handle) ? n : 0);
+}
+
+/*
+* call_func
+* sets curl options, used with xen_session_login_with_password
+*/
+int
+call_func(const void *data, size_t len, void *user_handle,
+ void *result_handle, xen_result_func result_func)
+{
+ //(void)user_handle;
+ struct _xenapiPrivate *priv = (struct _xenapiPrivate *)user_handle;
+ #ifdef PRINT_XML
+
+ printf("\n\n---Data to server: -----------------------\n");
+ printf("%s\n",((char*) data));
+ fflush(stdout);
+ #endif
+ CURL *curl = curl_easy_init();
+ if (!curl) {
+ return -1;
+ }
+ xen_comms comms = {
+ .func = result_func,
+ .handle = result_handle
+ };
+ curl_easy_setopt(curl, CURLOPT_URL, priv->url);
+ curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
+ #ifdef CURLOPT_MUTE
+ curl_easy_setopt(curl, CURLOPT_MUTE, 1);
+ #endif
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_func);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &comms);
+ curl_easy_setopt(curl, CURLOPT_POST, 1);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, priv->SSLflag);
+ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, priv->SSLflag);
+ CURLcode result = curl_easy_perform(curl);
+ curl_easy_cleanup(curl);
+ return result;
+
+}
+
+
+
diff -Nur ./libvirt_org/src/xenapi/xenapi_driver.h ./libvirt/src/xenapi/xenapi_driver.h
--- ./libvirt_org/src/xenapi/xenapi_driver.h 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_driver.h 2010-02-26 13:21:50.000000000 +0000
@@ -0,0 +1,15 @@
+/*
+ * xenapi_driver.h.c: Xen API driver header file to be included in libvirt.c.
+ * Copyright (C) 2009 Citrix Ltd.
+ * Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+ */
+
+
+#ifndef __VIR_XENAPI_PRIV_H__
+#define __VIR_XENAPI_PRIV_H__
+
+
+extern int xenapiRegister (void);
+
+
+#endif /* __VIR_XENAPI_PRIV_H__ */
diff -Nur ./libvirt_org/src/xenapi/xenapi_driver_private.h ./libvirt/src/xenapi/xenapi_driver_private.h
--- ./libvirt_org/src/xenapi/xenapi_driver_private.h 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_driver_private.h 2010-03-03 16:09:47.000000000 +0000
@@ -0,0 +1,49 @@
+/*
+ * xenapi_driver_private.h: Xen API driver's private header file.
+ * Copyright (C) 2009 Citrix Ltd.
+ * Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+ */
+
+
+#ifndef __VIR_XENAPI_H__
+#define __VIR_XENAPI_H__
+
+#include <xen/api/xen_common.h>
+#include <libxml/tree.h>
+#include "virterror_internal.h"
+
+//#define PRINT_XML
+#define VIR_FROM_THIS VIR_FROM_XENAPI
+#define LIBVIRT_MODELNAME_LEN (32)
+#define xenapiSessionErrorHandler(conn,errNum,buf) xenapiSessionErrorHandle(conn, errNum, \
+ buf,__FILE__,__FUNCTION__,__LINE__)
+
+void
+xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
+ const char *buf, const char *filename, const char *func, size_t lineno);
+
+typedef struct
+{
+ xen_result_func func;
+ void *handle;
+} xen_comms;
+
+
+int
+call_func(const void *data, size_t len, void *user_handle,
+ void *result_handle, xen_result_func result_func);
+size_t
+write_func(void *ptr, size_t size, size_t nmemb, void *comms);
+
+/* xenAPI driver's private data structure */
+struct _xenapiPrivate {
+ xen_session *session;
+ void *handle;
+ char *uname;
+ char *pwd;
+ char *url;
+ int SSLflag;
+ virCapsPtr caps;
+};
+
+#endif /* __VIR_XENAPI_H__ */
diff -Nur ./libvirt_org/src/xenapi/xenapi_utils.c ./libvirt/src/xenapi/xenapi_utils.c
--- ./libvirt_org/src/xenapi/xenapi_utils.c 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_utils.c 2010-03-03 18:01:06.000000000 +0000
@@ -0,0 +1,578 @@
+/*
+ * xenapi_utils.c: Xen API driver -- utils parts.
+ * Copyright (C) 2009 Citrix Ltd.
+ * Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <config.h>
+
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <libxml/uri.h>
+#include <xen_internal.h>
+#include <libxml/parser.h>
+#include <curl/curl.h>
+#include <xen/api/xen_common.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_all.h>
+#include <xen/api/xen_vm_metrics.h>
+
+#include "domain_conf.h"
+#include "libvirt_internal.h"
+#include "libvirt/libvirt.h"
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "xenapi_driver_private.h"
+#include "util.h"
+#include "uuid.h"
+#include "memory.h"
+#include "driver.h"
+#include "buf.h"
+#include "xenapi_utils.h"
+#include "util/logging.h"
+#include "qparams.h"
+
+
+char *
+xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
+ const char *hostname)
+{
+ unsigned int ncred;
+ virConnectCredential cred;
+ char *prompt;
+
+ memset(&cred, 0, sizeof(virConnectCredential));
+
+ if (virAsprintf(&prompt, "Enter %s password for %s", username,
+ hostname) < 0) {
+ return NULL;
+ }
+
+ for (ncred = 0; ncred < auth->ncredtype; ncred++) {
+ if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE &&
+ auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) {
+ continue;
+ }
+
+ cred.type = auth->credtype[ncred];
+ cred.prompt = prompt;
+ cred.challenge = hostname;
+ cred.defresult = NULL;
+ cred.result = NULL;
+ cred.resultlen = 0;
+
+ if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+ VIR_FREE(cred.result);
+ }
+
+ break;
+ }
+
+ VIR_FREE(prompt);
+
+ return cred.result;
+}
+
+int
+xenapiUtil_ParseQuery(virConnectPtr conn, xmlURIPtr uri, int *noVerify)
+{
+ int result = 0;
+ int i;
+ struct qparam_set *queryParamSet = NULL;
+ struct qparam *queryParam = NULL;
+
+#ifdef HAVE_XMLURI_QUERY_RAW
+ queryParamSet = qparam_query_parse(uri->query_raw);
+#else
+ queryParamSet = qparam_query_parse(uri->query);
+#endif
+
+ if (queryParamSet == NULL) {
+ goto failure;
+ }
+
+ for (i = 0; i < queryParamSet->n; i++) {
+ queryParam = &queryParamSet->p[i];
+ if (STRCASEEQ(queryParam->name, "no_verify")) {
+ if (noVerify == NULL) {
+ continue;
+ }
+ if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 ||
+ (*noVerify != 0 && *noVerify != 1)) {
+ xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG,
+ "Query parameter 'no_verify' has unexpected value (should be 0 or 1)");
+ goto failure;
+ }
+ }
+ }
+
+ cleanup:
+ if (queryParamSet != NULL) {
+ free_qparam_set(queryParamSet);
+ }
+
+ return result;
+
+ failure:
+ result = -1;
+
+ goto cleanup;
+}
+
+
+
+enum xen_on_normal_exit
+actionShutdownLibvirt2XenapiEnum(enum virDomainLifecycleAction action)
+{
+ enum xen_on_normal_exit num = XEN_ON_NORMAL_EXIT_RESTART;
+ if (action == VIR_DOMAIN_LIFECYCLE_DESTROY)
+ num = XEN_ON_NORMAL_EXIT_DESTROY;
+ else if (action == VIR_DOMAIN_LIFECYCLE_RESTART)
+ num = XEN_ON_NORMAL_EXIT_RESTART;
+ return num;
+}
+
+
+enum xen_on_crash_behaviour
+actionCrashLibvirt2XenapiEnum(enum virDomainLifecycleAction action)
+{
+ enum xen_on_crash_behaviour num = XEN_ON_CRASH_BEHAVIOUR_RESTART;
+ if (action == VIR_DOMAIN_LIFECYCLE_DESTROY)
+ num = XEN_ON_CRASH_BEHAVIOUR_DESTROY;
+ else if (action == VIR_DOMAIN_LIFECYCLE_RESTART)
+ num = XEN_ON_CRASH_BEHAVIOUR_RESTART;
+ else if (action == VIR_DOMAIN_LIFECYCLE_PRESERVE)
+ num = XEN_ON_CRASH_BEHAVIOUR_PRESERVE;
+ else if (action == VIR_DOMAIN_LIFECYCLE_RESTART_RENAME)
+ num = XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART;
+ return num;
+}
+
+/* generate XenAPI boot order format from libvirt format */
+char *
+createXenAPIBootOrderString(int nboot, int *bootDevs)
+{
+ virBuffer ret = VIR_BUFFER_INITIALIZER;
+ char *val = NULL;
+ int i;
+ for (i=0;i<nboot;i++) {
+ if (bootDevs[i] == VIR_DOMAIN_BOOT_FLOPPY)
+ val = (char *)"a";
+ else if (bootDevs[i] == VIR_DOMAIN_BOOT_DISK)
+ val = (char *)"c";
+ else if (bootDevs[i] == VIR_DOMAIN_BOOT_CDROM)
+ val = (char *)"d";
+ else if (bootDevs[i] == VIR_DOMAIN_BOOT_NET)
+ val = (char *)"n";
+ if (val)
+ virBufferEscapeString(&ret,"%s",val);
+ }
+ return virBufferContentAndReset(&ret);
+}
+
+/* convert boot order string to libvirt boot order enum */
+enum virDomainBootOrder
+map2LibvirtBootOrder(char c) {
+ switch(c) {
+ case 'a':
+ return VIR_DOMAIN_BOOT_FLOPPY;
+ case 'c':
+ return VIR_DOMAIN_BOOT_DISK;
+ case 'd':
+ return VIR_DOMAIN_BOOT_CDROM;
+ case 'n':
+ return VIR_DOMAIN_BOOT_NET;
+ default:
+ return -1;
+ }
+}
+
+enum virDomainLifecycleAction
+xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action)
+{
+ enum virDomainLifecycleAction num = VIR_DOMAIN_LIFECYCLE_RESTART;
+ if (action == XEN_ON_NORMAL_EXIT_DESTROY)
+ num = VIR_DOMAIN_LIFECYCLE_DESTROY;
+ else if (action == XEN_ON_NORMAL_EXIT_RESTART)
+ num = VIR_DOMAIN_LIFECYCLE_RESTART;
+ return num;
+}
+
+
+enum virDomainLifecycleAction
+xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action)
+{
+ enum virDomainLifecycleAction num = VIR_DOMAIN_LIFECYCLE_RESTART;
+ if (action == XEN_ON_CRASH_BEHAVIOUR_DESTROY)
+ num = VIR_DOMAIN_LIFECYCLE_DESTROY;
+ else if (action == XEN_ON_CRASH_BEHAVIOUR_RESTART)
+ num = VIR_DOMAIN_LIFECYCLE_RESTART;
+ else if (action == XEN_ON_CRASH_BEHAVIOUR_PRESERVE)
+ num = VIR_DOMAIN_LIFECYCLE_PRESERVE;
+ else if (action == XEN_ON_CRASH_BEHAVIOUR_RENAME_RESTART)
+ num = VIR_DOMAIN_LIFECYCLE_RESTART_RENAME;
+ return num;
+}
+
+
+
+/* returns 'file' or 'block' for the storage type */
+int
+getStorageVolumeType(char *type)
+{
+ if((STREQ(type,"lvmoiscsi")) ||
+ (STREQ(type,"lvmohba")) ||
+ (STREQ(type,"lvm")) ||
+ (STREQ(type,"file")) ||
+ (STREQ(type,"iso")) ||
+ (STREQ(type,"ext")) ||
+ (STREQ(type,"nfs")))
+ return (int)VIR_STORAGE_VOL_FILE;
+ else if((STREQ(type,"iscsi")) ||
+ (STREQ(type,"equal")) ||
+ (STREQ(type,"hba")) ||
+ (STREQ(type,"cslg")) ||
+ (STREQ(type,"udev")) ||
+ (STREQ(type,"netapp")))
+ return (int)VIR_STORAGE_VOL_BLOCK;
+ return -1;
+}
+
+/* returns error description if any received from the server */
+char *
+returnErrorFromSession(xen_session *session)
+{
+ int i;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ for (i=0; i<session->error_description_count-1; i++) {
+ if (!i)
+ virBufferEscapeString(&buf,"%s",session->error_description[i]);
+ else
+ virBufferEscapeString(&buf," : %s",session->error_description[i]);
+ }
+ return virBufferContentAndReset(&buf);
+}
+
+/* converts bitmap to string of the form '1,2...' */
+char *
+mapDomainPinVcpu(unsigned char *cpumap, int maplen)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ size_t len;
+ char *ret=NULL;
+ int i, j;
+ for (i = 0; i < maplen; i++) {
+ for (j = 0; j < 8; j++) {
+ if (cpumap[i] & (1 << j)) {
+ virBufferVSprintf(&buf,"%d,", (8*i)+j);
+ }
+ }
+ }
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
+ ret = virBufferContentAndReset(&buf);
+ len = strlen(ret);
+ if (len > 0 && ret[len - 1] == ',')
+ ret[len - 1] = 0;
+ return ret;
+}
+
+/* obtains the CPU bitmap from the string passed */
+void
+getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen)
+{
+ int pos;
+ int max_bits = maplen * 8;
+ char *num = NULL,*bp=NULL;
+ bzero(cpumap, maplen);
+ num = strtok_r (mask, ",", &bp);
+ while (num != NULL) {
+ if (sscanf (num, "%d", &pos)!=1)
+ virReportOOMError();
+ if (pos<0 || pos>max_bits-1)
+ VIR_WARN ("number in str %d exceeds cpumap's max bits %d\n", pos, max_bits);
+ else
+ (cpumap)[pos/8] |= (1<<(pos%8));
+ num = strtok_r (NULL, ",", &bp);
+ }
+}
+
+
+/* mapping XenServer power state to Libvirt power state */
+virDomainState
+mapPowerState(enum xen_vm_power_state state)
+{
+ virDomainState virState;
+ switch (state) {
+ case (XEN_VM_POWER_STATE_HALTED):
+ case (XEN_VM_POWER_STATE_SUSPENDED):
+ virState = VIR_DOMAIN_SHUTOFF;
+ break;
+ case (XEN_VM_POWER_STATE_PAUSED):
+ virState = VIR_DOMAIN_PAUSED;
+ break;
+ case (XEN_VM_POWER_STATE_RUNNING):
+ virState = VIR_DOMAIN_RUNNING;
+ break;
+ case (XEN_VM_POWER_STATE_UNKNOWN):
+ case (XEN_VM_POWER_STATE_UNDEFINED):
+ virState = VIR_DOMAIN_NOSTATE;
+ break;
+ default:
+ virState = VIR_DOMAIN_NOSTATE;
+ break;
+ }
+ return virState;
+}
+
+/* allocate a flexible array and fill values(key,val) */
+int
+allocStringMap (xen_string_string_map **strings, char *key, char *val)
+{
+ int sz = ((*strings) == NULL)?0:(*strings)->size;
+ sz++;
+ if(VIR_REALLOC_N(*strings, sizeof(xen_string_string_map)+
+ sizeof(xen_string_string_map_contents)*sz)<0) {
+ virReportOOMError();
+ return -1;
+ }
+ (*strings)->size = sz;
+ (*strings)->contents[sz-1].key = strdup(key);
+ (*strings)->contents[sz-1].val = strdup(val);
+ return 0;
+}
+
+/* Error handling function returns error messages from the server if any */
+void
+xenapiSessionErrorHandle(virConnectPtr conn, virErrorNumber errNum,
+ const char *buf, const char *filename, const char *func, size_t lineno)
+{
+ if (buf==NULL) {
+ char *ret=NULL;
+ ret = returnErrorFromSession(((struct _xenapiPrivate *)(conn->privateData))->session);
+ virReportErrorHelper (conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s\n"), ret);
+ xen_session_clear_error(((struct _xenapiPrivate *)(conn->privateData))->session);
+ VIR_FREE(ret);
+ } else {
+ virReportErrorHelper (conn, VIR_FROM_XENAPI, errNum, filename, func, lineno, _("%s\n"), buf);
+ }
+}
+
+/* creates network intereface for VM */
+int
+createVifNetwork (virConnectPtr conn, xen_vm vm, char *device,
+ char *bridge, char *mac)
+{
+ xen_vm xvm = NULL;
+ char *uuid = NULL;
+ xen_vm_get_uuid(((struct _xenapiPrivate *)(conn->privateData))->session, &uuid, vm);
+ if (uuid) {
+ if(!xen_vm_get_by_uuid(((struct _xenapiPrivate *)(conn->privateData))->session,
+ &xvm, uuid))
+ return -1;
+ VIR_FREE(uuid);
+ }
+ xen_vm_record_opt *vm_opt = xen_vm_record_opt_alloc();
+ vm_opt->is_record = 0;
+ vm_opt->u.handle = xvm;
+ xen_network_set *net_set = NULL;
+ xen_network_record *net_rec = NULL;
+ int cnt=0;
+ if (xen_network_get_all(((struct _xenapiPrivate *)(conn->privateData))->session, &net_set)) {
+ for(cnt=0;cnt<(net_set->size);cnt++) {
+ if (xen_network_get_record(((struct _xenapiPrivate *)(conn->privateData))->session,
+ &net_rec, net_set->contents[cnt])) {
+ if (STREQ(net_rec->bridge,bridge)) {
+ break;
+ } else {
+ xen_network_record_free(net_rec);
+ }
+ }
+ }
+ }
+ if ( (cnt<net_set->size) && net_rec) {
+ xen_network network = NULL;
+ xen_network_get_by_uuid(((struct _xenapiPrivate *)(conn->privateData))->session,
+ &network, net_rec->uuid);
+ xen_network_record_opt *network_opt = xen_network_record_opt_alloc();
+ network_opt->is_record = 0;
+ network_opt->u.handle = network;
+ xen_vif_record *vif_record = xen_vif_record_alloc();
+ vif_record->mac = mac;
+ vif_record->vm = vm_opt;
+ vif_record->network = network_opt;
+ xen_vif vif=NULL;
+
+ vif_record->other_config = xen_string_string_map_alloc(0);
+ vif_record->runtime_properties = xen_string_string_map_alloc(0);
+ vif_record->qos_algorithm_params = xen_string_string_map_alloc(0);
+ vif_record->device = strdup(device);
+ xen_vif_create(((struct _xenapiPrivate *)(conn->privateData))->session,
+ &vif, vif_record);
+ if (!vif) {
+ xen_vif_free(vif);
+ xen_vif_record_free(vif_record);
+ xen_network_record_free(net_rec);
+ xen_network_set_free(net_set);
+ return 0;
+ }
+ xen_vif_record_free(vif_record);
+ xen_network_record_free(net_rec);
+ }
+ if (net_set!=NULL) xen_network_set_free(net_set);
+ return -1;
+}
+
+/* Create a VM record from the XML description */
+int
+createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr def,
+ xen_vm_record **record, xen_vm *vm)
+{
+ char uuidStr[VIR_UUID_STRING_BUFLEN];
+ *record = xen_vm_record_alloc();
+ if (!((*record)->name_label = strdup(def->name)))
+ goto error_cleanup;
+ if (def->uuid) {
+ virUUIDFormat(def->uuid,uuidStr);
+ if (!((*record)->uuid = strdup(uuidStr)))
+ goto error_cleanup;
+ }
+ if (STREQ(def->os.type,"hvm")) {
+ if(!((*record)->hvm_boot_policy = strdup("BIOS order")))
+ goto error_cleanup;
+ char *boot_order = NULL;
+ if (def->os.nBootDevs!=0)
+ boot_order = createXenAPIBootOrderString(def->os.nBootDevs, &def->os.bootDevs[0]);
+ if (boot_order!=NULL) {
+ xen_string_string_map *hvm_boot_params=NULL;
+ allocStringMap(&hvm_boot_params, (char *)"order",boot_order);
+ (*record)->hvm_boot_params = hvm_boot_params;
+ VIR_FREE(boot_order);
+ }
+ } else if (STREQ(def->os.type,"xen")) {
+ if (!((*record)->pv_bootloader = strdup("pygrub")))
+ goto error_cleanup;
+ if (def->os.kernel){
+ if (!((*record)->pv_kernel = strdup(def->os.kernel)))
+ goto error_cleanup;
+ }
+ if (def->os.initrd) {
+ if (!((*record)->pv_ramdisk = strdup(def->os.initrd)))
+ goto error_cleanup;
+ }
+ if(def->os.cmdline) {
+ if (!((*record)->pv_args = strdup(def->os.cmdline)))
+ goto error_cleanup;
+ }
+ (*record)->hvm_boot_params = xen_string_string_map_alloc(0);
+ }
+ if (def->os.bootloaderArgs)
+ if(!((*record)->pv_bootloader_args = strdup(def->os.bootloaderArgs)))
+ goto error_cleanup;
+
+ if (def->memory)
+ (*record)->memory_static_max = (int64_t) (def->memory * 1024);
+ if (def->maxmem)
+ (*record)->memory_dynamic_max = (int64_t) (def->maxmem * 1024);
+ else
+ (*record)->memory_dynamic_max = (*record)->memory_static_max;
+
+ if (def->vcpus) {
+ (*record)->vcpus_max = (int64_t) def->vcpus;
+ (*record)->vcpus_at_startup = (int64_t) def->vcpus;
+ }
+ if (def->onPoweroff)
+ (*record)->actions_after_shutdown = actionShutdownLibvirt2XenapiEnum(def->onPoweroff);
+ if (def->onReboot)
+ (*record)->actions_after_reboot = actionShutdownLibvirt2XenapiEnum(def->onReboot);
+ if (def->onCrash)
+ (*record)->actions_after_crash = actionCrashLibvirt2XenapiEnum(def->onCrash);
+
+ xen_string_string_map *strings=NULL;
+ if (def->features) {
+ if (def->features & (1<<VIR_DOMAIN_FEATURE_ACPI))
+ allocStringMap(&strings,(char *)"acpi",(char *)"true");
+ if (def->features & (1<<VIR_DOMAIN_FEATURE_APIC))
+ allocStringMap(&strings,(char *)"apic",(char *)"true");
+ if (def->features & (1<<VIR_DOMAIN_FEATURE_PAE))
+ allocStringMap(&strings,(char *)"pae",(char *)"true");
+ }
+ if (strings!=NULL)
+ (*record)->platform = strings;
+
+ (*record)->vcpus_params = xen_string_string_map_alloc(0);
+ (*record)->other_config = xen_string_string_map_alloc(0);
+ (*record)->last_boot_cpu_flags = xen_string_string_map_alloc(0);
+ (*record)->xenstore_data = xen_string_string_map_alloc(0);
+ (*record)->hvm_shadow_multiplier = 1.000;
+ if (!xen_vm_create(((struct _xenapiPrivate *)(conn->privateData))->session,
+ vm, *record)) {
+ xenapiSessionErrorHandler(conn,VIR_ERR_INTERNAL_ERROR,NULL);
+ return -1;
+ }
+
+ int device_number=0;
+ char *bridge=NULL,*mac=NULL;
+ int i;
+ for (i=0;i<def->nnets;i++) {
+ if (def->nets[i]->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+ if (def->nets[i]->data.bridge.brname)
+ if(!(bridge = strdup(def->nets[i]->data.bridge.brname)))
+ goto error_cleanup;
+ if (def->nets[i]->mac) {
+ char macStr[VIR_MAC_STRING_BUFLEN];
+ virFormatMacAddr(def->nets[i]->mac, macStr);
+ if(!(mac = strdup(macStr))) {
+ if (bridge) VIR_FREE(bridge);
+ goto error_cleanup;
+ }
+ }
+ if (mac!=NULL && bridge!=NULL) {
+ char device[NETWORK_DEVID_SIZE]="\0";
+ sprintf(device,"%d",device_number);
+ createVifNetwork(conn, *vm, device, bridge, mac);
+ VIR_FREE(bridge);
+ device_number++;
+ }
+ if (bridge) VIR_FREE(bridge);
+ /*if (mac!=NULL && bridge!=NULL) {
+ char device[NETWORK_DEVID_SIZE]="\0";
+ sprintf(device,"%d",device_number);
+ if (createVifNetwork(conn, *vm, device, bridge, mac)<0) {
+ VIR_FREE(mac);
+ VIR_FREE(bridge);
+ xen_vm_record_free(*record);
+ xenapiSessionErrorHandler(conn,VIR_ERR_INTERNAL_ERROR,NULL);
+ return -1;
+ }
+ VIR_FREE(bridge);
+ device_number++;
+ } else {
+ if (bridge)
+ VIR_FREE(bridge);
+ if (mac)
+ VIR_FREE(mac);
+ xen_vm_record_free(*record);
+ xenapiSessionErrorHandler(conn,VIR_ERR_INTERNAL_ERROR,NULL);
+ return -1;
+ }*/
+ }
+ }
+ return 0;
+
+ error_cleanup:
+ virReportOOMError();
+ xen_vm_record_free(*record);
+ return -1;
+}
+
diff -Nur ./libvirt_org/src/xenapi/xenapi_utils.h ./libvirt/src/xenapi/xenapi_utils.h
--- ./libvirt_org/src/xenapi/xenapi_utils.h 1970-01-01 01:00:00.000000000 +0100
+++ ./libvirt/src/xenapi/xenapi_utils.h 2010-03-03 18:01:19.000000000 +0000
@@ -0,0 +1,93 @@
+/*
+ * xenapi_utils.h: Xen API driver -- utils header
+ * Copyright (C) 2009 Citrix Ltd.
+ * Sharadha Prabhakar <sharadha.prabhakar(a)citrix.com>
+ */
+
+#ifndef _VIR_XENAPI_UTILS_
+#define _VIR_XENAPI_UTILS_
+
+#include <stdio.h>
+#include <string.h>
+#include <config.h>
+
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <libxml/uri.h>
+#include <xen_internal.h>
+#include <libxml/parser.h>
+#include <curl/curl.h>
+#include <xen/api/xen_common.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_vm.h>
+#include <xen/api/xen_all.h>
+#include <xen/api/xen_vm_metrics.h>
+
+#include "libvirt_internal.h"
+#include "libvirt/libvirt.h"
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "conf/domain_conf.h"
+#include "xenapi_driver_private.h"
+#include "util.h"
+#include "uuid.h"
+#include "memory.h"
+#include "driver.h"
+#include "buf.h"
+
+#define NETWORK_DEVID_SIZE (10)
+
+typedef uint64_t cpumap_t;
+
+char *
+xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username,
+ const char *hostname);
+
+int
+xenapiUtil_ParseQuery(virConnectPtr conn, xmlURIPtr uri, int *noVerify);
+
+enum xen_on_normal_exit
+actionShutdownLibvirt2XenapiEnum(enum virDomainLifecycleAction action);
+
+enum xen_on_crash_behaviour
+actionCrashLibvirt2XenapiEnum(enum virDomainLifecycleAction action);
+
+char *
+createXenAPIBootOrderString(int nboot, int *bootDevs);
+
+enum virDomainBootOrder map2LibvirtBootOrder(char c);
+
+enum virDomainLifecycleAction
+xenapiNormalExitEnum2virDomainLifecycle(enum xen_on_normal_exit action);
+
+enum virDomainLifecycleAction
+xenapiCrashExitEnum2virDomainLifecycle(enum xen_on_crash_behaviour action);
+
+void getCpuBitMapfromString(char *mask, unsigned char *cpumap, int maplen);
+
+int getStorageVolumeType(char *type);
+
+char *returnErrorFromSession(xen_session *session);
+
+virDomainState
+mapPowerState(enum xen_vm_power_state state);
+
+char *
+mapDomainPinVcpu(unsigned char *cpumap, int maplen);
+
+int
+createVMRecordFromXml (virConnectPtr conn, virDomainDefPtr defPtr,
+ xen_vm_record **record, xen_vm *vm);
+
+int
+allocStringMap (xen_string_string_map **strings, char *key, char *val);
+
+int
+createVifNetwork(virConnectPtr conn, xen_vm vm, char *device,
+ char *bridge, char *mac);
+
+#endif //_VIR_XENAPI_UTILS_
2
3
Hi,
I have set up KVM on FC12.
I was wondering if its possible to Display the VM using spice + libvirt?
As in, if I can define my domain with graphics like:
<graphics type='spice' port='-1' autoport='yes' listen='0.0.0.0'/>
or
<graphics type='spice' port='5903' ' listen='0.0.0.0'/>
Thanks & Regards
Anuj
3
3
Hi all,
Qemu has the command line parameter aio=(native|threads).
I don't see a way to pass this option from libvirt. Would it be
possible to add support for this option?
Ruben
1
0
Hi,
I'm having an issue when trying to start a (previously created) vbox
item : virsh gets stucked in virDomainCreate and I see no error
message (LIBVIRT_DEBUG=1).
Is there any mean to get more information on what is happening ?
Moreover, now that virsh has stalled, running "connect
vbox:///session" on another virsh instance gets an error from "secret
driver". Is this normal, as if I'm only supposed to have 1 connection
at a time ?
Thanks
Regards
Anthony
2
1
13 Mar '10
---
src/Makefile.am | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 67f8b6d..4c12586 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -786,7 +786,9 @@ if WITH_LINUX
USED_SYM_FILES += libvirt_linux.syms
endif
+if WITH_MACVTAP
USED_SYM_FILES += libvirt_macvtap.syms
+endif
EXTRA_DIST += \
libvirt_public.syms \
--
1.6.3.3
2
2
Hi,
I currently testing a two-nodes HA-cluster with DRBD (Pacemaker, Heartbeat,
DRBD). When the virtual machines (with KVM) are running on one node and I
halt or reboot this node, heartbeat cannot migrate the resources to the
other node. Then the virtual machines are unmanaged in both nodes. I think
it's related to heartbeat and libvirt init order (libvirtd shouldn't stop
before heartbeat) or some configuration is missing ?
Thank you in advance.
Best regards.
Chaibi.
1
0
Hi *,
Apologies for cross posting.
I have installed the the libvirt and virt-toolss in an ubuntu karmic
9.10. I am trying to access-manage an ESX 3.5i via ssh protocol.
Although I have configured and verified that ssh access operates
correctly with keys, when I try to access the ESX via virt-manager,
it doesn't work.
Cheers,
Dimitris
--------------
Dimitrios K. Kalogeras
Electrical Engineer Ph.D.
Network Engineer
NTUA/GR-Net Network Management Center
_____________________________________
skype: aweboy
voice: +30-210-772 1863
fax: +30-210-772 1866
3
3
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_driver.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f8ab545..26b5600 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2695,12 +2695,15 @@ static int qemudStartVMDaemon(virConnectPtr conn,
FD_ZERO(&keepfd);
+ DEBUG0("Beginning VM startup process");
+
if (virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("VM is already active"));
return -1;
}
+ DEBUG0("Generating domain security label (if required)");
/* If you are using a SecurityDriver with dynamic labelling,
then generate a security label for isolation */
if (driver->securityDriver &&
@@ -2708,17 +2711,21 @@ static int qemudStartVMDaemon(virConnectPtr conn,
driver->securityDriver->domainGenSecurityLabel(vm) < 0)
return -1;
+ DEBUG0("Generating setting domain security labels (if required)");
if (driver->securityDriver &&
driver->securityDriver->domainSetSecurityAllLabel &&
driver->securityDriver->domainSetSecurityAllLabel(vm) < 0)
goto cleanup;
- /* Ensure no historical cgroup for this VM is lieing around bogus settings */
+ /* Ensure no historical cgroup for this VM is lieing around bogus
+ * settings */
+ DEBUG0("Removing old cgroup (if required)");
qemuRemoveCgroup(driver, vm, 1);
if ((vm->def->ngraphics == 1) &&
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
vm->def->graphics[0]->data.vnc.autoport) {
+ DEBUG0("Determining VNC port");
int port = qemudNextFreeVNCPort(driver);
if (port < 0) {
qemuReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2735,6 +2742,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
goto cleanup;
}
+ DEBUG0("Creating domain log file");
if ((logfile = qemudLogFD(driver, vm->def->name)) < 0)
goto cleanup;
@@ -2751,14 +2759,17 @@ static int qemudStartVMDaemon(virConnectPtr conn,
goto cleanup;
}
+ DEBUG0("Determing emulator version");
if (qemudExtractVersionInfo(emulator,
NULL,
&qemuCmdFlags) < 0)
goto cleanup;
+ DEBUG0("Setting up domain cgroup (if required)");
if (qemuSetupCgroup(driver, vm) < 0)
goto cleanup;
+ DEBUG0("Preparing host devices");
if (qemuPrepareHostDevices(driver, vm->def) < 0)
goto cleanup;
@@ -2767,6 +2778,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
goto cleanup;
}
+ DEBUG0("Preparing monitor state");
if (qemuPrepareMonitorChr(driver, priv->monConfig, vm->def->name) < 0)
goto cleanup;
@@ -2798,6 +2810,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
* use in hotplug
*/
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
+ DEBUG0("Assigning domain PCI addresses");
/* Populate cache with current addresses */
if (priv->pciaddrs) {
qemuDomainPCIAddressSetFree(priv->pciaddrs);
@@ -2816,6 +2829,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
priv->persistentAddrs = 0;
}
+ DEBUG0("Building emulator command line");
vm->def->id = driver->nextvmid++;
if (qemudBuildCommandLine(conn, driver, vm->def, priv->monConfig,
priv->monJSON, qemuCmdFlags, &argv, &progenv,
@@ -2899,25 +2913,31 @@ static int qemudStartVMDaemon(virConnectPtr conn,
if (ret == -1) /* The VM failed to start */
goto cleanup;
+ DEBUG0("Waiting for monitor to show up");
if (qemudWaitForMonitor(driver, vm, pos) < 0)
goto abort;
+ DEBUG0("Detecting VCPU PIDs");
if (qemuDetectVcpuPIDs(driver, vm) < 0)
goto abort;
+ DEBUG0("Setting CPU affinity");
if (qemudInitCpuAffinity(vm) < 0)
goto abort;
+ DEBUG0("Setting any required VM passwords");
if (qemuInitPasswords(conn, driver, vm, qemuCmdFlags) < 0)
goto abort;
/* If we have -device, then addresses are assigned explicitly.
* If not, then we have to detect dynamic ones here */
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ DEBUG0("Determining domain device PCI addresses");
if (qemuInitPCIAddresses(driver, vm) < 0)
goto abort;
}
+ DEBUG0("Setting initial memory amount");
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuMonitorSetBalloon(priv->mon, vm->def->memory) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -2925,6 +2945,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
}
if (migrateFrom == NULL) {
+ DEBUG0("Starting domain CPUs");
/* Allow the CPUS to start executing */
if (qemuMonitorStartCPUs(priv->mon, conn) < 0) {
if (virGetLastError() == NULL)
@@ -2937,6 +2958,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
qemuDomainObjExitMonitorWithDriver(driver, vm);
+ DEBUG0("Writing domain status to disk");
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
goto abort;
--
1.6.6
2
1
[in general, technical lists tend to frown on the practice of top-posting]
On 03/10/2010 02:49 PM, Dev.Atom wrote:
> Sorry, I'm not used to use mailing list
>
> I think the relevants part are these functions :
>
> int virFileOperation(const char *path, int openflags, mode_t mode,
> uid_t uid, gid_t gid,
> virFileOperationHook hook, void *hookdata,
> unsigned int flags)
> __attribute__((__warn_unused_result__));
>
> int virDirCreate(const char *path, mode_t mode, uid_t uid, gid_t gid,
> unsigned int flags)
> __attribute__((__warn_unused_result__));
Yes, my request was not to dump the entire (750k) preprocessor output to
the list, but to just the relevant portion of the output to make sure
there weren't any macros interfering with the parse.
>
> Matthias say that he has patches which will be ready in the week, and I
> can wait for these patches
Matthias probably already hit it on the head - gnulib can guarantee that
uid_t is defined in spite of mingw not providing it, but I haven't
personally checked whether we are using this aspect of gnulib yet, and I
will defer to see Matthias' patches.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
2
2
[libvirt] [PATCH] Only use the numa functions when they are available.
by Chris Lalancette 13 Mar '10
by Chris Lalancette 13 Mar '10
13 Mar '10
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/nodeinfo.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 8d7e055..bf57517 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -160,10 +160,12 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
nodeinfo->cpus = 0;
nodeinfo->mhz = 0;
nodeinfo->cores = 1;
- if (numa_available() < 0)
- nodeinfo->nodes = 1;
- else
+
+ nodeinfo->nodes = 1;
+#if HAVE_NUMACTL
+ if (numa_available() >= 0)
nodeinfo->nodes = numa_max_node() + 1;
+#endif
/* NB: It is impossible to fill our nodes, since cpuinfo
* has no knowledge of NUMA nodes */
--
1.6.6.1
2
1
[libvirt] [PATCH] Make nodeGetInfo report the correct number of NUMA nodes.
by Chris Lalancette 13 Mar '10
by Chris Lalancette 13 Mar '10
13 Mar '10
The nodeGetInfo code was always assuming that machine had a
single NUMA node, which is not correct. The good news is that
libnuma gives us this information pretty easily, so let's
properly report it.
NOTE: With recent hardware starting to support CPU hot-add
and hot-remove, both this code and the nodeCapsInitNUMA()
code are quickly going to become obsolete. We'll have to
think of a more dynamic solution for dealing with NUMA
nodes and CPUs that can come and go at will.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/nodeinfo.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 0748602..8d7e055 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -159,7 +159,11 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
nodeinfo->cpus = 0;
nodeinfo->mhz = 0;
- nodeinfo->nodes = nodeinfo->cores = 1;
+ nodeinfo->cores = 1;
+ if (numa_available() < 0)
+ nodeinfo->nodes = 1;
+ else
+ nodeinfo->nodes = numa_max_node() + 1;
/* NB: It is impossible to fill our nodes, since cpuinfo
* has no knowledge of NUMA nodes */
--
1.6.6.1
3
5
13 Mar '10
Currently we have a hard-coded maximum of 100 VNC autoports
that the qemu driver can use. This may not be enough for
running large numbers of guests on larger machines.
However, we don't necessarily necessarily want to make
it an open-ended number; that could lead to Denial of
Service. Allow a user-settable option to control the
number of autoports we will assign. The default is still
100, but now users can increase that if they wish.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/libvirtd_qemu.aug | 3 +++
src/qemu/qemu.conf | 4 ++++
src/qemu/qemu_conf.c | 6 ++++++
src/qemu/qemu_conf.h | 2 ++
src/qemu/qemu_driver.c | 5 +++--
src/qemu/test_libvirtd_qemu.aug | 14 ++++++++++++++
6 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 5bd60b3..0dd89ae 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -13,11 +13,13 @@ module Libvirtd_qemu =
let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
let bool_val = store /0|1/
+ let int_val = store /[0-9]+/
let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
let str_array_val = counter "el" . array_start . ( str_array_element . ( array_sep . str_array_element ) * ) ? . array_end
let str_entry (kw:string) = [ key kw . value_sep . str_val ]
let bool_entry (kw:string) = [ key kw . value_sep . bool_val ]
+ let int_entry (kw:string) = [ key kw . value_sep . int_val ]
let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
@@ -29,6 +31,7 @@ module Libvirtd_qemu =
| str_entry "vnc_password"
| bool_entry "vnc_sasl"
| str_entry "vnc_sasl_dir"
+ | int_entry "vnc_max_connections"
| str_entry "security_driver"
| str_entry "user"
| str_entry "group"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 3da332f..edcf083 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -79,6 +79,10 @@
# vnc_sasl_dir = "/some/directory/sasl2"
+# The maximum number of VNC connections we will allow. Once
+# libvirtd has created this many qemu guests with VNC ports,
+# no more guests can be started. The default is 100 guests.
+# vnc_max_connections = 100
# The default security driver is SELinux. If SELinux is disabled
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 40ca221..02186fd 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -113,6 +113,8 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
return -1;
}
+ driver->vncMaxConnections = 100;
+
#ifdef HAVE_MNTENT_H
/* For privileged driver, try and find hugepage mount automatically.
* Non-privileged driver requires admin to create a dir for the
@@ -211,6 +213,10 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
}
}
+ p = virConfGetValue (conf, "vnc_max_connections");
+ CHECK_TYPE ("vnc_max_connections", VIR_CONF_LONG);
+ if (p) driver->vncMaxConnections = p->l;
+
p = virConfGetValue (conf, "user");
CHECK_TYPE ("user", VIR_CONF_STRING);
if (!(user = strdup(p && p->str ? p->str : QEMU_USER))) {
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 6a9de5e..e0c4a9b 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -122,6 +122,8 @@ struct qemud_driver {
char *vncListen;
char *vncPassword;
char *vncSASLdir;
+ unsigned int vncMaxConnections;
+
char *hugetlbfs_mount;
char *hugepage_path;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 49983dd..8324075 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2147,10 +2147,11 @@ qemuInitPCIAddresses(struct qemud_driver *driver,
return ret;
}
-static int qemudNextFreeVNCPort(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
+static int qemudNextFreeVNCPort(struct qemud_driver *driver)
+{
int i;
- for (i = 5900 ; i < 6000 ; i++) {
+ for (i = 5900 ; i < (5900 + driver->vncMaxConnections) ; i++) {
int fd;
int reuse = 1;
struct sockaddr_in addr;
diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug
index 2feedc0..3c2190a 100644
--- a/src/qemu/test_libvirtd_qemu.aug
+++ b/src/qemu/test_libvirtd_qemu.aug
@@ -80,6 +80,13 @@ vnc_sasl = 1
#
vnc_sasl_dir = \"/some/directory/sasl2\"
+
+# The maximum number of VNC connections we will allow. Once
+# libvirtd has created this many qemu guests with VNC ports,
+# no more guests can be started. The default is 100 guests.
+#
+vnc_max_connections = 100
+
security_driver = \"selinux\"
user = \"root\"
@@ -180,6 +187,13 @@ relaxed_acs_check = 1
{ "#comment" = "" }
{ "vnc_sasl_dir" = "/some/directory/sasl2" }
{ "#empty" }
+{ "#empty" }
+{ "#comment" = "The maximum number of VNC connections we will allow. Once" }
+{ "#comment" = "libvirtd has created this many qemu guests with VNC ports," }
+{ "#comment" = "no more guests can be started. The default is 100 guests." }
+{ "#comment" = "" }
+{ "vnc_max_connections" = "100" }
+{ "#empty" }
{ "security_driver" = "selinux" }
{ "#empty" }
{ "user" = "root" }
--
1.6.6.1
2
1
Hi,
I'm having an issue when trying to start a (previously created) vbox
item : virsh gets stucked in virDomainCreate and I see no error
message (LIBVIRT_DEBUG=1).
Is there any mean to get more information on what is happening ?
Moreover, now that virsh has stalled, running "connect
vbox:///session" on another virsh instance gets an error from "secret
driver". Is this normal, as if I'm only supposed to have 1 connection
at a time ?
Thanks
Regards
Anthony
1
0
I am trying to compare the results that I am getting on a RHEL 5.3 server using xm list (using libvirt.so.0.3.3) against both my Dom0 and my Linux DomU on the same server to see if the cpu values match to what the kernel is reporting in /proc/stat. Here is an example of what I am seeing on both:
>From Dom0:
$ sudo /usr/sbin/xm list;cat /proc/stat | grep cpu
Name ID Mem(MiB) VCPUs State Time(s)
Domain-0 0 746 1 r----- 73722.3
rhel5_01 1 255 1 -b---- 18558.4
cpu 412542 1477862 522101 1111350509 347838 0 262 487234
cpu0 412542 1477862 522101 1111350509 347838 0 262 487234
>From DomU (rhelt_01):
$ cat /proc/stat | grep cpu
cpu 138184 148634 246128 924538039 467802 133 178 339822
cpu0 138184 148634 246128 924538039 467802 133 178 339822
The results of the two do not appear close. Should the cpu times match, is this a bug, or does Time mean something different than I think it does??
Thanks.
John
2
3
cmdCd was returning a 0 on success and -1 on error, when
the rest of the code expected a TRUE on success and a
FALSE on error. Fix the discrepancy.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
tools/virsh.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index a47edd5..c6e3f2a 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -7469,7 +7469,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (!ctl->imode) {
vshError(ctl, "%s", _("cd: command valid only in interactive mode"));
- return -1;
+ return FALSE;
}
dir = vshCommandOptString(cmd, "dir", &found);
@@ -7482,10 +7482,10 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (chdir (dir) == -1) {
vshError(ctl, _("cd: %s: %s"), strerror(errno), dir);
- return -1;
+ return FALSE;
}
- return 0;
+ return TRUE;
}
#endif
--
1.6.6.1
3
2
If you ran virsh in interactive mode and ran a command
that virsh could not parse, it would then SEGV
on subsequent commands. The problem is that we are
freeing the vshCmd structure in the syntaxError label
at the end of vshCommandParse, but forgetting to
set ctl->cmd to NULL. This means that on the next command,
we would try to free the same structure again, leading
to badness. Make sure to set ctl->cmd to NULL after
freeing it.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
tools/virsh.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index c6e3f2a..eeaddbc 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8643,8 +8643,10 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
return TRUE;
syntaxError:
- if (ctl->cmd)
+ if (ctl->cmd) {
vshCommandFree(ctl->cmd);
+ ctl->cmd = NULL;
+ }
if (first)
vshCommandOptFree(first);
VIR_FREE(tkdata);
--
1.6.6.1
3
2
No functional change. These all generated compiler warnings which, for
some reason weren't converted to errors by
--enable-compiler-warnings=error.
* tools/virsh.c:
* change return type frmo int to void on two functions that don't
return a value.
* remove unused variables/labels from two functions
* eliminate non-literal format strings
* typecast char* into xmlChar* when calling xmlParseBalancedChunkMemory
---
tools/virsh.c | 24 ++++++++++--------------
1 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index a47edd5..33f3647 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -421,7 +421,7 @@ static void vshCatchDisconnect(int sig, siginfo_t * siginfo,
* Catch SIGPIPE signals which may arise when disconnection
* from libvirtd occurs
*/
-static int
+static void
vshSetupSignals(void) {
struct sigaction sig_action;
@@ -435,10 +435,10 @@ vshSetupSignals(void) {
/*
* vshReconnect:
*
- * Reconnect after an
+ * Reconnect after a disconnect from libvirtd
*
*/
-static int
+static void
vshReconnect(vshControl *ctl) {
if (ctl->conn != NULL)
virConnectClose(ctl->conn);
@@ -1896,9 +1896,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
{
virDomainJobInfo info;
virDomainPtr dom;
- int ret = TRUE, autostart;
- unsigned int id;
- char *str, uuid[VIR_UUID_STRING_BUFLEN];
+ int ret = TRUE;
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -1980,8 +1978,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom;
int ret = TRUE;
- unsigned int id;
- char *str, uuid[VIR_UUID_STRING_BUFLEN];
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
return FALSE;
@@ -1992,7 +1988,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd)
if (virDomainAbortJob(dom) < 0)
ret = FALSE;
-cleanup:
virDomainFree(dom);
return ret;
}
@@ -6705,7 +6700,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to attach interface"));
+ vshError(ctl, "%s", _("Failed to attach interface"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Interface attached successfully\n"));
@@ -6834,7 +6829,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to detach interface"));
+ vshError(ctl, "%s", _("Failed to detach interface"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Interface detached successfully\n"));
@@ -7007,7 +7002,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to attach disk"));
+ vshError(ctl, "%s", _("Failed to attach disk"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Disk attached successfully\n"));
@@ -7128,7 +7123,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
}
if (ret != 0) {
- vshError(ctl, _("Failed to detach disk"));
+ vshError(ctl, "%s", _("Failed to detach disk"));
ret = FALSE;
} else {
vshPrint(ctl, "%s", _("Disk detached successfully\n"));
@@ -7257,7 +7252,8 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
if (doc == NULL)
goto no_memory;
- res = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0, buffer, &node_list);
+ res = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
+ (const xmlChar *)buffer, &node_list);
if (res != 0) {
vshError(ctl, _("Failed to parse XML fragment %s"), from);
ret = FALSE;
--
1.7.0.1
2
1
[libvirt] [PATCH] Silence compiler complaints about non-literal format strings
by Laine Stump 12 Mar '10
by Laine Stump 12 Mar '10
12 Mar '10
* src/util/macvtap.c: replace _("....") with "%s", _("...") in two places
---
src/util/macvtap.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 736cbaf..999e670 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -435,13 +435,13 @@ link_add(virConnectPtr conn,
malformed_resp:
ReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("malformed netlink response message"));
+ "%s", _("malformed netlink response message"));
VIR_FREE(recvbuf);
return -1;
buffer_too_small:
ReportError(conn, VIR_ERR_INTERNAL_ERROR,
- _("internal buffer is too small"));
+ "%s", _("internal buffer is too small"));
return -1;
}
--
1.7.0.1
3
2
Hi,
I have a Admin machine on which libvirt client is installed. I want to
manage Virtual Machines[which have a separate rootfs per VM] with the
help of libvirt remote access.
While creating a VM, in the libvirt virsh console, is there any
capability to transfer the rootfs directory on the fly[[like TFTP]],
from the admin machine to host machine which have several other VM's?
Please let me know.
Regards,
Srikanth.
1
0
[libvirt] [PATCH] Fix generation of floppy disk arg for QEMU's -global arg
by Daniel P. Berrange 12 Mar '10
by Daniel P. Berrange 12 Mar '10
12 Mar '10
* src/qemu/qemu_conf.c: Fix ',' vs '.' typo in floppy disk arg
---
src/qemu/qemu_conf.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fb06cd0..beb4386 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3521,7 +3521,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
char *fdc;
ADD_ARG_LIT("-global");
- if (virAsprintf(&fdc, "isa-fdc,drive%c=drive-%s",
+ if (virAsprintf(&fdc, "isa-fdc.drive%c=drive-%s",
disk->info.addr.drive.unit ? 'B' : 'A',
disk->info.alias) < 0)
goto no_memory;
--
1.6.6
3
2
12 Mar '10
The code to add job support into libvirtd caused a problem
in qemudDomainSetVcpus. In particular, a qemuDomainObjEndJob()
call was added at the end of the function, but a
corresponding qemuDomainObjBeginJob() was not. Additionally,
a call to qemuDomainObj{Enter,Exit}Monitor() was also missed
in qemudDomainHotplugVcpus(). These missing calls conspired to
cause a hang in the libvirtd process after the command was
finished. Fix this by adding the missing calls.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6bfae93..ee3dbd3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4515,7 +4515,9 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
if (nvcpus > vm->def->vcpus) {
for (i = vm->def->vcpus ; i < nvcpus ; i++) {
/* Online new CPU */
+ qemuDomainObjEnterMonitor(vm);
rc = qemuMonitorSetCPU(priv->mon, i, 1);
+ qemuDomainObjExitMonitor(vm);
if (rc == 0)
goto unsupported;
if (rc < 0)
@@ -4526,7 +4528,9 @@ static int qemudDomainHotplugVcpus(virDomainObjPtr vm, unsigned int nvcpus)
} else {
for (i = vm->def->vcpus - 1 ; i >= nvcpus ; i--) {
/* Offline old CPU */
+ qemuDomainObjEnterMonitor(vm);
rc = qemuMonitorSetCPU(priv->mon, i, 0);
+ qemuDomainObjExitMonitor(vm);
if (rc == 0)
goto unsupported;
if (rc < 0)
@@ -4559,18 +4563,21 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver);
+ if (qemuDomainObjBeginJob(vm) < 0)
+ goto cleanup;
+
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
virUUIDFormat(dom->uuid, uuidstr);
qemuReportError(VIR_ERR_NO_DOMAIN,
_("no domain with matching uuid '%s'"), uuidstr);
- goto cleanup;
+ goto endjob;
}
if (!virDomainObjIsActive(vm)) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domain is not running"));
- goto cleanup;
+ goto endjob;
}
if (!(type = virDomainVirtTypeToString(vm->def->virtType))) {
--
1.6.6.1
2
2
Currently if you dump the core of a qemu guest with
qemudDomainCoreDump, subsequent commands will hang
up libvirtd. This is because qemudDomainCoreDump
uses qemuDomainWaitForMigrationComplete, which expects
the qemuDriverLock to be held when it's called. This
patch does the simple thing and moves the qemuDriveUnlock
to the end of the qemudDomainCoreDump so that the driver
lock is held for the entirety of the call (as it is done
in qemudDomainSave). We will probably want to make the
lock more fine-grained than that in the future, but
we can fix both qemudDomainCoreDump and qemudDomainSave
at the same time.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ee3dbd3..49983dd 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4390,7 +4390,6 @@ static int qemudDomainCoreDump(virDomainPtr dom,
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
if (!vm) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -4401,7 +4400,7 @@ static int qemudDomainCoreDump(virDomainPtr dom,
}
priv = vm->privateData;
- if (qemuDomainObjBeginJob(vm) < 0)
+ if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
goto cleanup;
if (!virDomainObjIsActive(vm)) {
@@ -4499,6 +4498,7 @@ cleanup:
virDomainObjUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
+ qemuDriverUnlock(driver);
return ret;
}
--
1.6.6.1
2
2
12 Mar '10
2
1
As previously discussed[1], this patch removes the
qemudDomainSetMaxMemory() function, since it doesn't
work. This means that instead of getting somewhat
cryptic errors, you will now get:
error: Unable to change MaxMemorySize
error: this function is not supported by the hypervisor: virDomainSetMaxMemory
Which describes the situation perfectly.
[1] https://www.redhat.com/archives/libvir-list/2010-February/msg00928.html
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 42 +-----------------------------------------
1 files changed, 1 insertions(+), 41 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c5490b2..6bfae93 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3816,46 +3816,6 @@ cleanup:
return ret;
}
-static int qemudDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
- struct qemud_driver *driver = dom->conn->privateData;
- virDomainObjPtr vm;
- int ret = -1;
-
- qemuDriverLock(driver);
- vm = virDomainFindByUUID(&driver->domains, dom->uuid);
- qemuDriverUnlock(driver);
-
- if (!vm) {
- char uuidstr[VIR_UUID_STRING_BUFLEN];
- virUUIDFormat(dom->uuid, uuidstr);
- qemuReportError(VIR_ERR_NO_DOMAIN,
- _("no domain with matching uuid '%s'"), uuidstr);
- goto cleanup;
- }
-
- if (!virDomainObjIsActive(vm)) {
- qemuReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("domain is not running"));
- goto cleanup;
- }
-
- if (newmax < vm->def->memory) {
- qemuReportError(VIR_ERR_INVALID_ARG, "%s",
- _("cannot set max memory lower than current memory"));
- goto cleanup;
- }
-
- /* There isn't any way to change this value for a running qemu guest */
- qemuReportError(VIR_ERR_NO_SUPPORT,
- "%s", _("cannot set max memory of an active domain"));
-
-cleanup:
- if (vm)
- virDomainObjUnlock(vm);
- return ret;
-}
-
-
static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
struct qemud_driver *driver = dom->conn->privateData;
qemuDomainObjPrivatePtr priv;
@@ -9506,7 +9466,7 @@ static virDriver qemuDriver = {
qemudDomainDestroy, /* domainDestroy */
qemudDomainGetOSType, /* domainGetOSType */
qemudDomainGetMaxMemory, /* domainGetMaxMemory */
- qemudDomainSetMaxMemory, /* domainSetMaxMemory */
+ NULL, /* domainSetMaxMemory */
qemudDomainSetMemory, /* domainSetMemory */
qemudDomainGetInfo, /* domainGetInfo */
qemudDomainSave, /* domainSave */
--
1.6.6.1
2
2
When using the JSON monitor, qemuMonitorJSONExtractCPUInfo
was returning 0 on success. Unfortunately, higher levels of
the cpuinfo code expect that it returns the number of CPUs
it found on success. This one-line patch fixes it so that
it returns the correct number. This makes "virsh vcpuinfo <domain>"
work when using the JSON monitor.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_monitor_json.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index f04fd2e..7a263cb 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -648,7 +648,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
*pids = threads;
threads = NULL;
- ret = 0;
+ ret = ncpus;
cleanup:
VIR_FREE(threads);
--
1.6.6.1
2
2
[libvirt] [PATCH 12/13] Core driver implementation with ebtables support
by Stefan Berger 11 Mar '10
by Stefan Berger 11 Mar '10
11 Mar '10
Attachment may have been too big for mailserver -- sending patch inline.
This patch implements the core driver and provides
- management functionality for managing the filter XMLs
- compiling the internal filter representation into ebtables rules
- applying ebtables rules on a network (tap,macvtap) interface
- tearing down ebtables rules that were applied on behalf of an
interface
- updating of filters while VMs are running and causing the firewalls to
be rebuilt
- other bits and pieces
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
---
configure.ac | 3
daemon/libvirtd.c | 7
include/libvirt/virterror.h | 5
python/generator.py | 2
src/conf/nwfilter_conf.c | 2503
++++++++++++++++++++++++++++++
src/conf/nwfilter_conf.h | 472 +++++
src/datatypes.c | 142 +
src/datatypes.h | 32
src/nwfilter/nwfilter_driver.c | 429 +++++
src/nwfilter/nwfilter_driver.h | 35
src/nwfilter/nwfilter_ebiptables_driver.c | 1313 +++++++++++++++
src/nwfilter/nwfilter_ebiptables_driver.h | 41
src/nwfilter/nwfilter_gentech_driver.c | 656 +++++++
src/nwfilter/nwfilter_gentech_driver.h | 52
src/util/virterror.c | 27
15 files changed, 5719 insertions(+)
Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- /dev/null
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -0,0 +1,2503 @@
+/*
+ * nwfilter_conf.c: network filter XML processing
+ * (derived from storage_conf.c)
+ *
+ * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Daniel P. Berrange
+ *
+ * Copyright (C) 2010 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Stefan Berger <stefanb(a)us.ibm.com>
+ */
+#include <stdio.h>
+#include <config.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <regex.h>
+#include <dirent.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <net/ethernet.h>
+
+#include "config.h"
+
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "nwfilter_conf.h"
+#include "domain_conf.h"
+
+#include "xml.h"
+#include "uuid.h"
+#include "buf.h"
+#include "util.h"
+#include "memory.h"
+
+#include "nwfilter/nwfilter_gentech_driver.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_NWFILTER
+
+#define virNWFilterError(conn, code, fmt...)
\
+ virReportErrorHelper(conn, VIR_FROM_NWFILTER, code,
__FILE__,\
+ __FUNCTION__, __LINE__, fmt)
+
+VIR_ENUM_IMPL(virNWFilterRuleAction, VIR_NWFILTER_RULE_ACTION_LAST,
+ "drop",
+ "accept");
+
+VIR_ENUM_IMPL(virNWFilterJumpTarget, VIR_NWFILTER_RULE_ACTION_LAST,
+ "DROP",
+ "ACCEPT");
+
+VIR_ENUM_IMPL(virNWFilterRuleDirection,
VIR_NWFILTER_RULE_DIRECTION_LAST,
+ "in",
+ "out",
+ "inout");
+
+VIR_ENUM_IMPL(virNWFilterChainPolicy, VIR_NWFILTER_CHAIN_POLICY_LAST,
+ "ACCEPT",
+ "DROP");
+
+VIR_ENUM_IMPL(virNWFilterEbtablesTable,
VIR_NWFILTER_EBTABLES_TABLE_LAST,
+ "filter",
+ "nat",
+ "broute");
+
+VIR_ENUM_IMPL(virNWFilterChainSuffix, VIR_NWFILTER_CHAINSUFFIX_LAST,
+ "root",
+ "arp",
+ "ipv4");
+
+
+/*
+ * a map entry for a simple static int-to-string map
+ */
+struct int_map {
+ int32_t attr;
+ const char *val;
+};
+
+
+/*
+ * only one filter update allowed
+ */
+static virMutex updateMutex;
+
+static void
+virNWFilterLockFilterUpdates(void) {
+ virMutexLock(&updateMutex);
+}
+
+static void
+virNWFilterUnlockFilterUpdates(void) {
+ virMutexUnlock(&updateMutex);
+}
+
+
+/*
+ * regular expressions for parameter names and values
+ */
+static regex_t regex_nam;
+static regex_t regex_val;
+
+
+/*
+ * attribute names for the rules XML
+ */
+static const char srcmacaddr_str[] = "srcmacaddr";
+static const char srcmacmask_str[] = "srcmacmask";
+static const char dstmacaddr_str[] = "dstmacaddr";
+static const char dstmacmask_str[] = "dstmacmask";
+static const char srcipaddr_str[] = "srcipaddr";
+static const char srcipmask_str[] = "srcipmask";
+static const char dstipaddr_str[] = "dstipaddr";
+static const char dstipmask_str[] = "dstipmask";
+static const char srcportstart_str[] = "srcportstart";
+static const char srcportend_str[] = "srcportend";
+static const char dstportstart_str[] = "dstportstart";
+static const char dstportend_str[] = "dstportend";
+
+#define SRCMACADDR srcmacaddr_str
+#define SRCMACMASK srcmacmask_str
+#define DSTMACADDR dstmacaddr_str
+#define DSTMACMASK dstmacmask_str
+#define SRCIPADDR srcipaddr_str
+#define SRCIPMASK srcipmask_str
+#define DSTIPADDR dstipaddr_str
+#define DSTIPMASK dstipmask_str
+#define SRCPORTSTART srcportstart_str
+#define SRCPORTEND srcportend_str
+#define DSTPORTSTART dstportstart_str
+#define DSTPORTEND dstportend_str
+
+
+/**
+ * intMapGetByInt:
+ * @intmap: Pointer to int-to-string map
+ * @attr: The attribute to look up
+ * @res: Pointer to string pointer for result
+ *
+ * Returns 1 if value was found with result returned, 0 otherwise.
+ *
+ * lookup a map entry given the integer.
+ */
+static bool
+intMapGetByInt(const struct int_map *intmap, int32_t attr, const char
**res)
+{
+ int i = 0;
+ bool found = 0;
+ while (intmap[i].val && !found) {
+ if (intmap[i].attr == attr) {
+ *res = intmap[i].val;
+ found = 1;
+ }
+ i++;
+ }
+ return found;
+}
+
+
+/**
+ * intMapGetByString:
+ * @intmap: Pointer to int-to-string map
+ * @str: Pointer to string for which to find the entry
+ * @casecmp : Whether to ignore case when doing string matching
+ * @result: Pointer to int for result
+ *
+ * Returns 0 if no entry was found, 1 otherwise.
+ *
+ * Do a lookup in the map trying to find an integer key using the
string
+ * value. Returns 1 if entry was found with result returned, 0
otherwise.
+ */
+static bool
+intMapGetByString(const struct int_map *intmap, const char *str, int
casecmp,
+ int32_t *result)
+{
+ int i = 0;
+ bool found = 0;
+ while (intmap[i].val && !found) {
+ if ( (casecmp && STRCASEEQ(intmap[i].val, str)) ||
+ STREQ (intmap[i].val, str) ) {
+ *result = intmap[i].attr;
+ found = 1;
+ }
+ i++;
+ }
+ return found;
+}
+
+
+void
+virNWFilterRuleDefFree(virNWFilterRuleDefPtr def) {
+ int i;
+ if (!def)
+ return;
+
+ for (i = 0; i < def->nvars; i++)
+ VIR_FREE(def->vars[i]);
+
+ VIR_FREE(def->vars);
+
+ VIR_FREE(def);
+}
+
+
+static void
+hashDealloc(void *payload, const char *name ATTRIBUTE_UNUSED)
+{
+ VIR_FREE(payload);
+}
+
+
+static void
+virNWFilterIncludeDefFree(virNWFilterIncludeDefPtr inc) {
+ if (!inc)
+ return;
+ virNWFilterHashTableFree(inc->params);
+ VIR_FREE(inc->filterref);
+ VIR_FREE(inc);
+}
+
+
+static void
+virNWFilterEntryFree(virNWFilterEntryPtr entry) {
+ if (!entry)
+ return;
+
+ virNWFilterRuleDefFree(entry->rule);
+ virNWFilterIncludeDefFree(entry->include);
+ VIR_FREE(entry);
+}
+
+
+void
+virNWFilterDefFree(virNWFilterDefPtr def) {
+ int i;
+ if (!def)
+ return;
+
+ VIR_FREE(def->name);
+
+ for (i = 0; i < def->nentries; i++)
+ virNWFilterEntryFree(def->filterEntries[i]);
+
+ VIR_FREE(def->filterEntries);
+
+ VIR_FREE(def);
+}
+
+
+void
+virNWFilterPoolObjFree(virNWFilterPoolObjPtr obj) {
+ if (!obj)
+ return;
+
+ virNWFilterDefFree(obj->def);
+ virNWFilterDefFree(obj->newDef);
+
+ VIR_FREE(obj->configFile);
+
+ virMutexDestroy(&obj->lock);
+
+ VIR_FREE(obj);
+}
+
+
+void
+virNWFilterPoolObjListFree(virNWFilterPoolObjListPtr pools)
+{
+ unsigned int i;
+ for (i = 0 ; i < pools->count ; i++)
+ virNWFilterPoolObjFree(pools->objs[i]);
+ VIR_FREE(pools->objs);
+ pools->count = 0;
+}
+
+
+static int
+virNWFilterRuleDefAddVar(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virNWFilterRuleDefPtr nwf,
+ nwItemDesc *item,
+ const char *var)
+{
+ int i = 0;
+
+ if (nwf->vars) {
+ for (i = 0; i < nwf->nvars; i++)
+ if (STREQ(nwf->vars[i], var)) {
+ item->var = nwf->vars[i];
+ return 0;
+ }
+ }
+
+ if (VIR_REALLOC_N(nwf->vars, nwf->nvars+1) < 0) {
+ virReportOOMError();
+ return 1;
+ }
+
+ nwf->vars[nwf->nvars] = strdup(var);
+
+ if (!nwf->vars[nwf->nvars]) {
+ virReportOOMError();
+ return 1;
+ }
+
+ item->var = nwf->vars[nwf->nvars++];
+
+ return 0;
+}
+
+
+void
+virNWFilterPoolObjRemove(virNWFilterPoolObjListPtr pools,
+ virNWFilterPoolObjPtr pool)
+{
+ unsigned int i;
+
+ virNWFilterPoolObjUnlock(pool);
+
+ for (i = 0 ; i < pools->count ; i++) {
+ virNWFilterPoolObjLock(pools->objs[i]);
+ if (pools->objs[i] == pool) {
+ virNWFilterPoolObjUnlock(pools->objs[i]);
+ virNWFilterPoolObjFree(pools->objs[i]);
+
+ if (i < (pools->count - 1))
+ memmove(pools->objs + i, pools->objs + i + 1,
+ sizeof(*(pools->objs)) * (pools->count - (i +
1)));
+
+ if (VIR_REALLOC_N(pools->objs, pools->count - 1) < 0) {
+ ; /* Failure to reduce memory allocation isn't fatal */
+ }
+ pools->count--;
+
+ break;
+ }
+ virNWFilterPoolObjUnlock(pools->objs[i]);
+ }
+}
+
+
+
+typedef bool (*valueValidator)(enum attrDatatype datatype, void
*valptr,
+ virNWFilterRuleDefPtr nwf);
+typedef bool (*valueFormatter)(virBufferPtr buf,
+ virNWFilterRuleDefPtr nwf);
+
+typedef struct _virXMLAttr2Struct virXMLAttr2Struct;
+struct _virXMLAttr2Struct
+{
+ const char *name; // attribute name
+ enum attrDatatype datatype;
+ int dataIdx; // offset of the hasXYZ boolean
+ valueValidator validator; // beyond-standard checkers
+ valueFormatter formatter; // beyond-standard formatter
+};
+
+
+
+static bool
+checkPriority(enum attrDatatype datatype ATTRIBUTE_UNUSED, void *val,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
+{
+ unsigned char prio = *(unsigned char *)val;
+ if (prio > 7)
+ return 0;
+ return 1;
+}
+
+
+static bool
+checkVLAN(enum attrDatatype datatype ATTRIBUTE_UNUSED, void *val,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
+{
+ uint16_t vid = *(uint16_t *)val;
+ if (vid >= 0x1000)
+ return 0;
+ return 1;
+}
+
+
+
+
+static const struct int_map macProtoMap[] = {
+ {
+ .attr = ETHERTYPE_ARP,
+ .val = "arp",
+ }, {
+ .attr = ETHERTYPE_IP,
+ .val = "ipv4",
+ }, {
+ .val = NULL,
+ }
+};
+
+
+static bool
+checkMacProtocolID(enum attrDatatype datatype, void *value,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
+{
+ int32_t res = -1;
+ const char *str;
+
+ if (datatype == DATATYPE_STRING) {
+ if (intMapGetByString(macProtoMap, (char *)value, 1, &res) ==
0)
+ res = -1;
+ } else if (datatype == DATATYPE_UINT16) {
+ if (intMapGetByInt(macProtoMap,
+ (int32_t)*(uint16_t *)value, &str) == 0)
+ res = -1;
+ }
+
+ if (res != -1) {
+ nwf->p.ethHdrFilter.dataProtocolID.u.u16 = res;
+ return 1;
+ }
+
+ return 0;
+}
+
+
+static bool
+macProtocolIDFormatter(virBufferPtr buf,
+ virNWFilterRuleDefPtr nwf)
+{
+ const char *str = NULL;
+
+ if (intMapGetByInt(macProtoMap,
+ nwf->p.ethHdrFilter.dataProtocolID.u.u16,
+ &str)) {
+ virBufferVSprintf(buf, "%s", str);
+ return 1;
+ }
+ return 0;
+}
+
+
+/* generic function to check for a valid (ipv4,ipv6, mac) mask
+ * A mask is valid of there is a sequence of 1's followed by a sequence
+ * of 0s or only 1s or only 0s
+ */
+static bool
+checkValidMask(unsigned char *data, int len)
+{
+ uint32_t idx = 0;
+ uint8_t mask = 0x80;
+ int checkones = 1;
+
+ while ((idx >> 3) < len) {
+ if (checkones) {
+ if (!(data[idx>>3] & mask))
+ checkones = 0;
+ } else {
+ if ((data[idx>>3] & mask))
+ return 0;
+ }
+
+ idx++;
+ mask >>= 1;
+ if (!mask)
+ mask = 0x80;
+ }
+ return 1;
+}
+
+
+/* check for a valid IPv4 mask */
+static bool
+checkIPv4Mask(enum attrDatatype datatype ATTRIBUTE_UNUSED, void
*maskptr,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
+{
+ return checkValidMask(maskptr, 4);
+}
+
+
+static bool
+checkMACMask(enum attrDatatype datatype ATTRIBUTE_UNUSED,
+ void *macMask,
+ virNWFilterRuleDefPtr nwf ATTRIBUTE_UNUSED)
+{
+ return checkValidMask((unsigned char *)macMask, 6);
+}
+
+
+static int getMaskNumBits(const unsigned char *mask, int len) {
+ int i = 0;
+ while (i < (len << 3)) {
+ if (!(mask[i>>3] & (0x80 >> (i & 3))))
+ break;
+ i++;
+ }
+ return i;
+}
+
+/*
+ * supported arp opcode -- see 'ebtables -h arp' for the naming
+ */
+static const struct int_map arpOpcodeMap[] = {
+ {
+ .attr = 1,
+ .val = "Request",
+ } , {
+ .attr = 2,
+ .val = "Reply",
+ } , {
+ .attr = 3,
+ .val = "Request_Reverse",
+ } , {
+ .attr = 4,
+ .val = "Reply_Reverse",
+ } , {
+ .attr = 5,
+ .val = "DRARP_Request",
+ } , {
+ .attr = 6,
+ .val = "DRARP_Reply",
+ } , {
+ .attr = 7,
+ .val = "DRARP_Error",
+ } , {
+ .attr = 8,
+ .val = "InARP_Request",
+ } , {
+ .attr = 9,
+ .val = "ARP_NAK",
+ } , {
+ .val = NULL,
+ }
+};
+
+
+static bool
+arpOpcodeValidator(enum attrDatatype datatype,
+ void *value,
+ virNWFilterRuleDefPtr nwf)
+{
+ int32_t res = -1;
+ const char *str;
+
+ if (datatype == DATATYPE_STRING) {
+ if (intMapGetByString(arpOpcodeMap, (char *)value, 1, &res) ==
0)
+ res = -1;
+ } else if (datatype == DATATYPE_UINT8) {
+ if (intMapGetByInt(arpOpcodeMap,
+ (uint32_t)*(uint16_t *)value, &str) == 0)
+ res = -1;
+ }
+
+ if (res != -1) {
+ nwf->p.arpHdrFilter.dataOpcode.u.u16 = res;
+ return 1;
+ }
+ return 0;
+}
+
+
+static bool
+arpOpcodeFormatter(virBufferPtr buf,
+ virNWFilterRuleDefPtr nwf)
+{
+ const char *str = NULL;
+
+ if (intMapGetByInt(arpOpcodeMap,
+ nwf->p.arpHdrFilter.dataOpcode.u.u16,
+ &str)) {
+ virBufferVSprintf(buf, "%s", str);
+ return 1;
+ }
+ return 0;
+}
+
+
+static const struct int_map ipProtoMap[] = {
+ {
+ .attr = IPPROTO_TCP,
+ .val = "tcp",
+ } , {
+ .attr = IPPROTO_UDP,
+ .val = "udp",
+ } , {
+ .attr = IPPROTO_ICMP,
+ .val = "icmp",
+ } , {
+ .attr = IPPROTO_IGMP,
+ .val = "igmp",
+#ifdef IPPROTO_SCTP
+ } , {
+ .attr = IPPROTO_SCTP,
+ .val = "sctp",
+#endif
+ } , {
+ .val = NULL,
+ }
+};
+
+
+static bool checkIPProtocolID(enum attrDatatype datatype,
+ void *value,
+ virNWFilterRuleDefPtr nwf)
+{
+ int32_t res = -1;
+ const char *str;
+
+ if (datatype == DATATYPE_STRING) {
+ if (intMapGetByString(ipProtoMap, (char *)value, 1, &res) == 0)
+ res = -1;
+ } else if (datatype == DATATYPE_UINT8) {
+ // may just accept what user provides and not test...
+ if (intMapGetByInt(ipProtoMap,
+ (uint32_t)*(uint16_t *)value, &str) == 0)
+ res = -1;
+ }
+
+ if (res != -1) {
+ nwf->p.ipHdrFilter.ipHdr.dataProtocolID.u.u16 = res;
+ return 1;
+ }
+ return 0;
+}
+
+
+static bool
+formatIPProtocolID(virBufferPtr buf,
+ virNWFilterRuleDefPtr nwf)
+{
+ const char *str = NULL;
+
+ if (intMapGetByInt(ipProtoMap,
+ nwf->p.ipHdrFilter.ipHdr.dataProtocolID.u.u16,
+ &str)) {
+ virBufferVSprintf(buf, "%s", str);
+ return 1;
+ }
+ return 0;
+}
+
+
+static const virXMLAttr2Struct macAttributes[] = {
+ {
+ .name = SRCMACADDR,
+ .datatype = DATATYPE_MACADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataSrcMACAddr),
+ },
+ {
+ .name = SRCMACMASK,
+ .datatype = DATATYPE_MACMASK,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataSrcMACMask),
+ },
+ {
+ .name = DSTMACADDR,
+ .datatype = DATATYPE_MACADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataDstMACAddr),
+ },
+ {
+ .name = DSTMACMASK,
+ .datatype = DATATYPE_MACMASK,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataDstMACMask),
+ },
+ {
+ .name = "protocolid",
+ .datatype = DATATYPE_UINT16 | DATATYPE_STRING,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataProtocolID),
+ .validator= checkMacProtocolID,
+ .formatter= macProtocolIDFormatter,
+ },
+ {
+ .name = "priority",
+ .datatype = DATATYPE_UINT8,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataPriority),
+ .validator= checkPriority, // enforce only 3 valid bits
+ },
+ {
+ .name = "vlanid",
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ethHdrFilter.dataVLANID),
+ .validator= checkVLAN, // enforce only 12 valid bits
+ },
+ {
+ .name = NULL,
+ }
+};
+
+static const virXMLAttr2Struct arpAttributes[] = {
+ {
+ .name = "hwtype",
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataHWType),
+ }, {
+ .name = "protocoltype",
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataProtocolType),
+ }, {
+ .name = "opcode",
+ .datatype = DATATYPE_UINT8 | DATATYPE_STRING,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataOpcode),
+ .validator= arpOpcodeValidator,
+ .formatter= arpOpcodeFormatter,
+ }, {
+ .name = SRCMACADDR,
+ .datatype = DATATYPE_MACADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataSrcMACAddr),
+ }, {
+ .name = DSTMACADDR,
+ .datatype = DATATYPE_MACADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataDstMACAddr),
+ }, {
+ .name = SRCIPADDR,
+ .datatype = DATATYPE_IPADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataSrcIPAddr),
+ }, {
+ .name = DSTIPADDR,
+ .datatype = DATATYPE_IPADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.arpHdrFilter.dataDstIPAddr),
+ },
+ {
+ .name = NULL,
+ }
+};
+
+static const virXMLAttr2Struct ipAttributes[] = {
+ {
+ .name = "version",
+ .datatype = DATATYPE_UINT8,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.ipHdr.dataIPVersion),
+ },
+ {
+ .name = SRCIPADDR,
+ .datatype = DATATYPE_IPADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.ipHdr.dataSrcAddr),
+ },
+ {
+ .name = DSTIPADDR,
+ .datatype = DATATYPE_IPADDR,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.ipHdr.dataDstAddr),
+ },
+ {
+ .name = SRCIPMASK,
+ .datatype = DATATYPE_IPMASK,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.ipHdr.dataSrcMask),
+ },
+ {
+ .name = DSTIPMASK,
+ .datatype = DATATYPE_IPMASK,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.ipHdr.dataDstMask),
+ },
+ {
+ .name = "protocol",
+ .datatype = DATATYPE_STRING,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.ipHdr.dataProtocolID),
+ .validator= checkIPProtocolID,
+ .formatter= formatIPProtocolID,
+ },
+ {
+ .name = SRCPORTSTART,
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.portData.dataSrcPortStart),
+ },
+ {
+ .name = SRCPORTEND,
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.portData.dataSrcPortEnd),
+ },
+ {
+ .name = DSTPORTSTART,
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.portData.dataDstPortStart),
+ },
+ {
+ .name = DSTPORTEND,
+ .datatype = DATATYPE_UINT16,
+ .dataIdx = offsetof(virNWFilterRuleDef,
p.ipHdrFilter.portData.dataDstPortEnd),
+ },
+ {
+ .name = NULL,
+ }
+};
+
+
+typedef struct _virAttributes virAttributes;
+struct _virAttributes {
+ const char *id;
+ const virXMLAttr2Struct *att;
+ enum virNWFilterRuleProtocolType prtclType;
+};
+
+
+static const virAttributes virAttr[] = {
+ {
+ .id = "arp",
+ .att = arpAttributes,
+ .prtclType = VIR_NWFILTER_RULE_PROTOCOL_ARP,
+ }, {
+ .id = "mac",
+ .att = macAttributes,
+ .prtclType = VIR_NWFILTER_RULE_PROTOCOL_MAC,
+ }, {
+ .id = "ip",
+ .att = ipAttributes,
+ .prtclType = VIR_NWFILTER_RULE_PROTOCOL_IP,
+ }, {
+ .id = NULL,
+ }
+};
+
+
+static bool
+virNWMACAddressParser(const char *input,
+ nwMACAddressPtr output)
+{
+ if (virParseMacAddr(input, &output->addr[0]) == 0)
+ return 1;
+ return 0;
+}
+
+
+static bool
+virNWIPv4AddressParser(const char *input,
+ nwIPAddressPtr output)
+{
+ int i;
+ char *endptr;
+ const char *n = input;
+ long int d;
+
+ for (i = 0; i < 4; i++) {
+ d = strtol(n, &endptr, 10);
+ if (d < 0 || d > 255 ||
+ (endptr - n > 3 ) ||
+ (i <= 2 && *endptr != '.' ) ||
+ (i == 3 && *endptr != '\0'))
+ return 0;
+ output->addr.ipv4Addr[i] = (unsigned char)d;
+ n = endptr + 1;
+ }
+ return 1;
+}
+
+
+static int
+virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
+ xmlNodePtr node,
+ virNWFilterRuleDefPtr nwf,
+ const virXMLAttr2Struct *att)
+{
+ int rc = 0;
+ int idx = 0;
+ char *prop;
+ int found = 0;
+ enum attrDatatype datatype, att_datatypes;
+ enum virNWFilterEntryItemFlags *flags ,match_flag = 0, flags_set =
0;
+ nwItemDesc *item;
+ int int_val;
+ void *data_ptr, *storage_ptr;
+ valueValidator validator;
+ char *match = virXMLPropString(node, "match");
+ nwIPAddress ipaddr;
+
+ if (match && STREQ(match, "no"))
+ match_flag = NWFILTER_ENTRY_ITEM_FLAG_IS_NEG;
+ VIR_FREE(match);
+ match = NULL;
+
+ while (att[idx].name != NULL && rc == 0) {
+ prop = virXMLPropString(node, att[idx].name);
+
+ item = (nwItemDesc *)((char *)nwf + att[idx].dataIdx);
+ flags = &item->flags;
+ flags_set = match_flag;
+
+ if (prop) {
+ found = 0;
+
+ validator = NULL;
+
+ if (STRPREFIX(prop, "$")) {
+ flags_set |= NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR;
+ storage_ptr = NULL;
+
+ if (virNWFilterRuleDefAddVar(conn,
+ nwf,
+ item,
+ &prop[1]))
+ rc = -1;
+ found = 1;
+ }
+
+ datatype = 1;
+
+ att_datatypes = att[idx].datatype;
+
+ while (datatype <= DATATYPE_LAST && found == 0 && rc == 0)
{
+ if ((att_datatypes & datatype)) {
+
+ att_datatypes ^= datatype;
+
+ validator = att[idx].validator;
+
+ switch (datatype) {
+
+ case DATATYPE_UINT8:
+ storage_ptr = &item->u.u8;
+ if (sscanf(prop, "%d", &int_val) == 1) {
+ if (int_val >= 0 && int_val <= 0xff) {
+ if (!validator)
+ *(uint8_t *)storage_ptr =
int_val;
+ found = 1;
+ data_ptr = &int_val;
+ } else
+ rc = -1;
+ } else
+ rc = -1;
+ break;
+
+ case DATATYPE_UINT16:
+ storage_ptr = &item->u.u16;
+ if (sscanf(prop, "%d", &int_val) == 1) {
+ if (int_val >= 0 && int_val <= 0xffff)
{
+ if (!validator)
+ *(uint16_t *)storage_ptr =
int_val;
+ found = 1;
+ data_ptr = &int_val;
+ } else
+ rc = -1;
+ } else
+ rc = -1;
+ break;
+
+ case DATATYPE_IPADDR:
+ // parse as dotted IPv4
+ // search for existing parser in libvirt
+ // later: also parse as IPv6
+ storage_ptr = &item->u.ipaddr;
+ if (!virNWIPv4AddressParser(prop,
+ (nwIPAddressPtr)storage_ptr)) {
+ rc = -1;
+ }
+ found = 1;
+ break;
+
+ case DATATYPE_IPMASK:
+ // parse as dotted IPv4
+ // parse as CIDR mask
+ // later: also parse as IPv6
+ storage_ptr = &item->u.u8;
+ if (!virNWIPv4AddressParser(prop, &ipaddr))
{
+ if (sscanf(prop, "%d", &int_val) == 1)
{
+ if (int_val >= 0 && int_val <= 32)
{
+ if (!validator)
+ *(uint8_t *)storage_ptr =
+ (uint8_t)int_val;
+ found = 1;
+ data_ptr = &int_val;
+ } else
+ rc = -1;
+ } else
+ rc = -1;
+ } else {
+ if (checkIPv4Mask(datatype,
+ ipaddr.addr.ipv4Addr,
nwf))
+ *(uint8_t *)storage_ptr =
+
getMaskNumBits(ipaddr.addr.ipv4Addr,
+
sizeof(ipaddr.addr.ipv4Addr));
+ else
+ rc = -1;
+ found = 1;
+ }
+ break;
+
+ case DATATYPE_MACADDR:
+ storage_ptr = &item->u.macaddr;
+ if (!virNWMACAddressParser(prop,
+ (nwMACAddressPtr)storage_ptr))
{
+ rc = -1;
+ }
+ found = 1;
+ break;
+
+ case DATATYPE_MACMASK:
+ validator = checkMACMask;
+ storage_ptr = &item->u.macaddr;
+ if (!virNWMACAddressParser(prop,
+ (nwMACAddressPtr)storage_ptr))
{
+ rc = -1;
+ }
+ data_ptr = storage_ptr;
+ found = 1;
+ break;
+
+ case DATATYPE_STRING:
+ if (!validator) {
+ // not supported
+ rc = -1;
+ break;
+ }
+ data_ptr = prop;
+ found = 1;
+ break;
+
+ case DATATYPE_LAST:
+ default:
+ break;
+ }
+ }
+
+ if (rc != 0 && att_datatypes != 0) {
+ rc = 0;
+ found = 0;
+ }
+
+ datatype <<= 1;
+ } /* while */
+
+ if (found == 1 && rc == 0) {
+ *flags = NWFILTER_ENTRY_ITEM_FLAG_EXISTS | flags_set;
+ item->datatype = datatype >> 1;
+ if (validator) {
+ if (!validator(datatype >> 1, data_ptr, nwf)) {
+ rc = -1;
+ *flags = 0;
+ }
+ }
+ }
+
+ if (!found || rc) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("%s has illegal value %s"),
+ att[idx].name, prop);
+ rc = -1;
+ }
+ VIR_FREE(prop);
+ }
+ idx++;
+ }
+
+ return rc;
+}
+
+
+/**
+ * virNWFilterHashTablePut:
+ * @table: Pointer to a virNWFilterHashTable
+ * @name: name of the key to enter
+ * @val: The value associated with the key
+ * @freeName: Whether the name must be freed on table destruction
+ *
+ * Returns 0 on success, 1 on failure.
+ *
+ * Put an entry into the hashmap replacing and freeing an existing
entry
+ * if one existed.
+ */
+int
+virNWFilterHashTablePut(virNWFilterHashTablePtr table,
+ const char *name,
+ char *val,
+ int copyName)
+{
+ if (!virHashLookup(table->hashTable, name)) {
+ if (copyName) {
+ name = strdup(name);
+ if (!name)
+ return 1;
+
+ if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
+ VIR_FREE(name);
+ return 1;
+ }
+ table->names[table->nNames++] = (char *)name;
+ }
+
+ if (virHashAddEntry(table->hashTable, name, val) != 0) {
+ if (copyName) {
+ VIR_FREE(name);
+ table->nNames--;
+ }
+ return 1;
+ }
+ } else {
+ if (virHashUpdateEntry(table->hashTable, name, val,
hashDealloc) != 0) {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+
+/**
+ * virNWFilterHashTableFree:
+ * @table: Pointer to virNWFilterHashTable
+ *
+ * Free a hashtable de-allocating memory for all its entries.
+ *
+ * All hash tables within the NWFilter driver must use this
+ * function to deallocate and free their content.
+ */
+void
+virNWFilterHashTableFree(virNWFilterHashTablePtr table)
+{
+ int i;
+ if (!table)
+ return;
+ virHashFree(table->hashTable, hashDealloc);
+
+ for (i = 0; i < table->nNames; i++)
+ VIR_FREE(table->names[i]);
+ VIR_FREE(table->names);
+ VIR_FREE(table);
+}
+
+
+virNWFilterHashTablePtr
+virNWFilterHashTableCreate(int n) {
+ virNWFilterHashTablePtr ret;
+
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+ ret->hashTable = virHashCreate(n);
+ if (!ret->hashTable) {
+ virReportOOMError();
+ VIR_FREE(ret);
+ return NULL;
+ }
+ return ret;
+}
+
+
+int
+virNWFilterHashTableRemoveEntry(virNWFilterHashTablePtr ht,
+ const char *entry)
+{
+ int i;
+ int rc = virHashRemoveEntry(ht->hashTable, entry, hashDealloc);
+
+ if (rc == 0) {
+ for (i = 0; i < ht->nNames; i++) {
+ if (STREQ(ht->names[i], entry)) {
+ VIR_FREE(ht->names[i]);
+ ht->names[i] = ht->names[--ht->nNames];
+ ht->names[ht->nNames] = NULL;
+ break;
+ }
+ }
+ }
+ return rc;
+}
+
+
+struct addToTableStruct {
+ virNWFilterHashTablePtr target;
+ int errOccurred;
+ virConnectPtr conn;
+};
+
+
+static void
+addToTable(void *payload, const char *name, void *data)
+{
+ struct addToTableStruct *atts = (struct addToTableStruct *)data;
+ char *val;
+
+ if (atts->errOccurred)
+ return;
+
+ val = strdup((char *)payload);
+ if (!val) {
+ virReportOOMError();
+ atts->errOccurred = 1;
+ return;
+ }
+
+ if (virNWFilterHashTablePut(atts->target, name, val, 1) != 0) {
+ virNWFilterReportError(atts->conn, VIR_ERR_INTERNAL_ERROR,
+ _("Could not put variable '%s' into
hashmap"),
+ name);
+ atts->errOccurred = 1;
+ VIR_FREE(val);
+ }
+}
+
+
+int
+virNWFilterHashTablePutAll(virConnectPtr conn,
+ virNWFilterHashTablePtr src,
+ virNWFilterHashTablePtr dest)
+{
+ struct addToTableStruct atts = {
+ .target = dest,
+ .errOccurred = 0,
+ .conn = conn,
+ };
+
+ virHashForEach(src->hashTable, addToTable, &atts);
+ if (atts.errOccurred)
+ goto err_exit;
+
+ return 0;
+
+err_exit:
+ return 1;
+}
+
+
+virNWFilterHashTablePtr
+virNWFilterParseParamAttributes(xmlNodePtr cur)
+{
+ char *nam, *val;
+
+ virNWFilterHashTablePtr table = virNWFilterHashTableCreate(0);
+ if (!table) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ cur = cur->children;
+
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (xmlStrEqual(cur->name, BAD_CAST "parameter")) {
+ nam = virXMLPropString(cur, "name");
+ val = virXMLPropString(cur, "value");
+ if (nam != NULL && val != NULL) {
+ if (regexec(®ex_nam, nam, 0, NULL, 0) != 0)
+ goto skip_entry;
+ if (regexec(®ex_val, val, 0, NULL, 0) != 0)
+ goto skip_entry;
+ if (virNWFilterHashTablePut(table, nam, val, 1)) {
+ VIR_FREE(nam);
+ VIR_FREE(val);
+ virNWFilterHashTableFree(table);
+ return NULL;
+ }
+ val = NULL;
+ }
+skip_entry:
+ VIR_FREE(nam);
+ VIR_FREE(val);
+ }
+ }
+ cur = cur->next;
+ }
+ return table;
+}
+
+
+struct formatterParam {
+ virBufferPtr buf;
+ const char *indent;
+};
+
+
+static void
+_formatParameterAttrs(void *payload, const char *name, void *data)
+{
+ struct formatterParam *fp = (struct formatterParam *)data;
+
+ virBufferVSprintf(fp->buf, "%s<parameter name='%s' value='%s'/>\n",
+ fp->indent,
+ name,
+ (char *)payload);
+}
+
+
+char *
+virNWFilterFormatParamAttributes(virNWFilterHashTablePtr table,
+ const char *indent)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ struct formatterParam fp = {
+ .buf = &buf,
+ .indent = indent,
+ };
+
+ virHashForEach(table->hashTable, _formatParameterAttrs, &fp);
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+}
+
+
+static virNWFilterIncludeDefPtr
+virNWFilterIncludeParse(virConnectPtr conn,
+ xmlNodePtr cur)
+{
+ virNWFilterIncludeDefPtr ret;
+
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ ret->filterref = virXMLPropString(cur, "filter");
+ if (!ret->filterref) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("rule node requires action
attribute"));
+ goto err_exit;
+ }
+
+ ret->params = virNWFilterParseParamAttributes(cur);
+ if (!ret->params)
+ goto err_exit;
+
+cleanup:
+ return ret;
+
+err_exit:
+ virNWFilterIncludeDefFree(ret);
+ ret = NULL;
+ goto cleanup;
+}
+
+
+static void
+virNWFilterRuleDefFixup(virNWFilterRuleDefPtr rule)
+{
+#define COPY_NEG_SIGN(A, B) \
+ (A).flags = ((A).flags & ~NWFILTER_ENTRY_ITEM_FLAG_IS_NEG) | \
+ ((B).flags & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG);
+
+ switch (rule->prtclType) {
+ case VIR_NWFILTER_RULE_PROTOCOL_MAC:
+ COPY_NEG_SIGN(rule->p.ethHdrFilter.dataSrcMACMask,
+ rule->p.ethHdrFilter.dataSrcMACAddr);
+ COPY_NEG_SIGN(rule->p.ethHdrFilter.dataDstMACMask,
+ rule->p.ethHdrFilter.dataDstMACAddr);
+ break;
+
+ case VIR_NWFILTER_RULE_PROTOCOL_IP:
+ COPY_NEG_SIGN(rule->p.ipHdrFilter.ipHdr.dataSrcMask,
+ rule->p.ipHdrFilter.ipHdr.dataSrcAddr);
+ COPY_NEG_SIGN(rule->p.ipHdrFilter.ipHdr.dataDstMask,
+ rule->p.ipHdrFilter.ipHdr.dataDstAddr);
+ break;
+
+ case VIR_NWFILTER_RULE_PROTOCOL_ARP:
+ case VIR_NWFILTER_RULE_PROTOCOL_NONE:
+ break;
+ }
+
+#undef COPY_NEG_SIGN
+}
+
+
+static virNWFilterRuleDefPtr
+virNWFilterRuleParse(virConnectPtr conn,
+ xmlNodePtr node)
+{
+ char *action;
+ char *direction;
+ char *prio;
+ int found;
+ int found_i;
+ unsigned int priority;
+
+ xmlNodePtr cur;
+ virNWFilterRuleDefPtr ret;
+
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ action = virXMLPropString(node, "action");
+ direction = virXMLPropString(node, "direction");
+ prio = virXMLPropString(node, "priority");
+
+ if (!action) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("rule node requires action
attribute"));
+ goto err_exit;
+ }
+
+ if ((ret->action = virNWFilterRuleActionTypeFromString(action)) <
0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("unknown rule action attribute
value"));
+ goto err_exit;
+ }
+
+ if (!direction) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("rule node requires direction
attribute"));
+ goto err_exit;
+ }
+
+ if ((ret->tt = virNWFilterRuleDirectionTypeFromString(direction)) <
0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("unknown rule direction attribute
value"));
+ goto err_exit;
+ }
+
+ ret->priority = MAX_RULE_PRIORITY / 2;
+
+ if (prio) {
+ if (sscanf(prio, "%d", (int *)&priority) == 1) {
+ if ((int)priority >= 0 && priority <= MAX_RULE_PRIORITY)
+ ret->priority = priority;
+ }
+ }
+
+ cur = node->children;
+
+ found = 0;
+
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ int i = 0;
+ while (1) {
+ if (found)
+ i = found_i;
+
+ if (xmlStrEqual(cur->name, BAD_CAST virAttr[i].id)) {
+
+ found_i = i;
+ found = 1;
+ ret->prtclType = virAttr[i].prtclType;
+
+ if (virNWFilterRuleDetailsParse(conn,
+ cur,
+ ret,
+ virAttr[i].att) <
0) {
+ /* we ignore malformed rules
+ goto err_exit;
+ */
+ }
+ break;
+ }
+ if (!found) {
+ i++;
+ if (!virAttr[i].id)
+ break;
+ } else
+ break;
+ }
+ }
+
+ cur = cur->next;
+ }
+
+ virNWFilterRuleDefFixup(ret);
+
+cleanup:
+ VIR_FREE(prio);
+ VIR_FREE(action);
+ VIR_FREE(direction);
+
+ return ret;
+
+err_exit:
+ virNWFilterRuleDefFree(ret);
+ ret = NULL;
+ goto cleanup;
+}
+
+
+static virNWFilterDefPtr
+virNWFilterDefParseXML(virConnectPtr conn,
+ xmlXPathContextPtr ctxt) {
+ virNWFilterDefPtr ret;
+ xmlNodePtr curr = ctxt->node;
+ char *uuid = NULL;
+ char *chain = NULL;
+ virNWFilterEntryPtr entry;
+
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ ret->name = virXPathString("string(./@name)", ctxt);
+ if (!ret->name) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("filter has no name"));
+ goto cleanup;
+ }
+
+ ret->chainsuffix = VIR_NWFILTER_CHAINSUFFIX_ROOT;
+ chain = virXPathString("string(./@chain)", ctxt);
+ if (chain) {
+ if ((ret->chainsuffix =
+ virNWFilterChainSuffixTypeFromString(chain)) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unknown chain suffix '%s'"),
chain);
+ goto cleanup;
+ }
+ }
+
+ uuid = virXPathString("string(./uuid)", ctxt);
+ if (uuid == NULL) {
+ if (virUUIDGenerate(ret->uuid) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("unable to generate uuid"));
+ goto cleanup;
+ }
+ } else {
+ if (virUUIDParse(uuid, ret->uuid) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("malformed uuid element"));
+ goto cleanup;
+ }
+ VIR_FREE(uuid);
+ }
+
+ curr = curr->children;
+
+ while (curr != NULL) {
+ if (curr->type == XML_ELEMENT_NODE) {
+ if (VIR_ALLOC(entry) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ /* ignore malformed rule and include elements */
+ if (xmlStrEqual(curr->name, BAD_CAST "rule"))
+ entry->rule = virNWFilterRuleParse(conn, curr);
+ else if (xmlStrEqual(curr->name, BAD_CAST "filterref"))
+ entry->include = virNWFilterIncludeParse(conn, curr);
+
+ if (entry->rule || entry->include) {
+ if (VIR_REALLOC_N(ret->filterEntries, ret->nentries+1)
< 0) {
+ VIR_FREE(entry);
+ virReportOOMError();
+ goto cleanup;
+ }
+ ret->filterEntries[ret->nentries++] = entry;
+ } else
+ VIR_FREE(entry);
+ }
+ curr = curr->next;
+ }
+
+ VIR_FREE(chain);
+
+ return ret;
+
+ cleanup:
+ VIR_FREE(chain);
+ VIR_FREE(uuid);
+ return NULL;
+}
+
+
+/* Called from SAX on parsing errors in the XML. */
+static void
+catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
+{
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
+
+ if (ctxt) {
+ virConnectPtr conn = ctxt->_private;
+
+ if (conn &&
+ conn->err.code == VIR_ERR_NONE &&
+ ctxt->lastError.level == XML_ERR_FATAL &&
+ ctxt->lastError.message != NULL) {
+ virNWFilterReportError(conn, VIR_ERR_XML_DETAIL,
+ _("at line %d: %s"),
+ ctxt->lastError.line,
+ ctxt->lastError.message);
+ }
+ }
+}
+
+
+virNWFilterDefPtr
+virNWFilterDefParseNode(virConnectPtr conn,
+ xmlDocPtr xml,
+ xmlNodePtr root) {
+ xmlXPathContextPtr ctxt = NULL;
+ virNWFilterDefPtr def = NULL;
+
+ if (STRNEQ((const char *)root->name, "filter")) {
+ virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
+ "%s",
+ _("unknown root element for nw filter
pool"));
+ goto cleanup;
+ }
+
+ ctxt = xmlXPathNewContext(xml);
+ if (ctxt == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ctxt->node = root;
+ def = virNWFilterDefParseXML(conn, ctxt);
+
+cleanup:
+ xmlXPathFreeContext(ctxt);
+ return def;
+}
+
+
+static virNWFilterDefPtr
+virNWFilterDefParse(virConnectPtr conn,
+ const char *xmlStr,
+ const char *filename) {
+ virNWFilterDefPtr ret = NULL;
+ xmlParserCtxtPtr pctxt;
+ xmlDocPtr xml = NULL;
+ xmlNodePtr node = NULL;
+
+ /* Set up a parser context so we can catch the details of XML
errors. */
+ pctxt = xmlNewParserCtxt ();
+ if (!pctxt || !pctxt->sax)
+ goto cleanup;
+ pctxt->sax->error = catchXMLError;
+ pctxt->_private = conn;
+
+ if (conn) virResetError (&conn->err);
+ if (filename) {
+ xml = xmlCtxtReadFile (pctxt, filename, NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ } else {
+ xml = xmlCtxtReadDoc (pctxt, BAD_CAST xmlStr,
+ "nwfilter.xml", NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ }
+
+ if (!xml) {
+ if (conn && conn->err.code == VIR_ERR_NONE)
+ virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
+ "%s",_("failed to parse xml
document"));
+ goto cleanup;
+ }
+
+ node = xmlDocGetRootElement(xml);
+ if (node == NULL) {
+ virNWFilterReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("missing root element"));
+ goto cleanup;
+ }
+
+ ret = virNWFilterDefParseNode(conn, xml, node);
+
+ xmlFreeParserCtxt (pctxt);
+ xmlFreeDoc(xml);
+
+ return ret;
+
+ cleanup:
+ xmlFreeParserCtxt (pctxt);
+ xmlFreeDoc(xml);
+ return NULL;
+}
+
+
+virNWFilterDefPtr
+virNWFilterDefParseString(virConnectPtr conn,
+ const char *xmlStr)
+{
+ return virNWFilterDefParse(conn, xmlStr, NULL);
+}
+
+
+virNWFilterDefPtr
+virNWFilterDefParseFile(virConnectPtr conn,
+ const char *filename)
+{
+ return virNWFilterDefParse(conn, NULL, filename);
+}
+
+
+virNWFilterPoolObjPtr
+virNWFilterPoolObjFindByUUID(virNWFilterPoolObjListPtr pools,
+ const unsigned char *uuid)
+{
+ unsigned int i;
+
+ for (i = 0 ; i < pools->count ; i++) {
+ virNWFilterPoolObjLock(pools->objs[i]);
+ if (!memcmp(pools->objs[i]->def->uuid, uuid, VIR_UUID_BUFLEN))
+ return pools->objs[i];
+ virNWFilterPoolObjUnlock(pools->objs[i]);
+ }
+
+ return NULL;
+}
+
+
+virNWFilterPoolObjPtr
+virNWFilterPoolObjFindByName(virNWFilterPoolObjListPtr pools,
+ const char *name)
+{
+ unsigned int i;
+
+ for (i = 0 ; i < pools->count ; i++) {
+ virNWFilterPoolObjLock(pools->objs[i]);
+ if (STREQ(pools->objs[i]->def->name, name))
+ return pools->objs[i];
+ virNWFilterPoolObjUnlock(pools->objs[i]);
+ }
+
+ return NULL;
+}
+
+
+int virNWFilterSaveXML(virConnectPtr conn,
+ const char *configDir,
+ virNWFilterDefPtr def,
+ const char *xml)
+{
+ char *configFile = NULL;
+ int fd = -1, ret = -1;
+ size_t towrite;
+ int err;
+
+ if ((configFile = virNWFilterConfigFile(conn, configDir,
def->name)) == NULL)
+ goto cleanup;
+
+ if ((err = virFileMakePath(configDir))) {
+ virReportSystemError(err,
+ _("cannot create config directory '%s'"),
+ configDir);
+ goto cleanup;
+ }
+
+ if ((fd = open(configFile,
+ O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR )) < 0) {
+ virReportSystemError(errno,
+ _("cannot create config file '%s'"),
+ configFile);
+ goto cleanup;
+ }
+
+ towrite = strlen(xml);
+ if (safewrite(fd, xml, towrite) < 0) {
+ virReportSystemError(errno,
+ _("cannot write config file '%s'"),
+ configFile);
+ goto cleanup;
+ }
+
+ if (close(fd) < 0) {
+ virReportSystemError(errno,
+ _("cannot save config file '%s'"),
+ configFile);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ if (fd != -1)
+ close(fd);
+
+ VIR_FREE(configFile);
+
+ return ret;
+}
+
+
+int virNWFilterSaveConfig(virConnectPtr conn,
+ const char *configDir,
+ virNWFilterDefPtr def)
+{
+ int ret = -1;
+ char *xml;
+
+ if (!(xml = virNWFilterDefFormat(conn, def)))
+ goto cleanup;
+
+ if (virNWFilterSaveXML(conn, configDir, def, xml))
+ goto cleanup;
+
+ ret = 0;
+cleanup:
+ VIR_FREE(xml);
+ return ret;
+}
+
+
+static int
+_virNWFilterDefLoopDetect(virConnectPtr conn,
+ virNWFilterPoolObjListPtr pools,
+ virNWFilterDefPtr def,
+ const char *filtername)
+{
+ int rc = 0;
+ int i;
+ virNWFilterEntryPtr entry;
+ virNWFilterPoolObjPtr obj;
+
+ if (!def)
+ return 0;
+
+ for (i = 0; i < def->nentries; i++) {
+ entry = def->filterEntries[i];
+ if (entry->include) {
+
+ if (STREQ(filtername, entry->include->filterref)) {
+ rc = 1;
+ break;
+ }
+
+ obj = virNWFilterPoolObjFindByName(pools,
+
entry->include->filterref);
+ if (obj) {
+ rc = _virNWFilterDefLoopDetect(conn,
+ pools,
+ obj->def, filtername);
+
+ virNWFilterPoolObjUnlock(obj);
+ if (rc)
+ break;
+ }
+ }
+ }
+
+ return rc;
+}
+
+
+/*
+ * virNWFilterDefLoopDetect:
+ * @conn: pointer to virConnect object
+ * @pools : the pools to search
+ * @def : the filter definiton that may add a loop and is to be tested
+ *
+ * Detect a loop introduced through the filters being able to
+ * reference each other.
+ *
+ * Returns 0 in case no loop was detected, 1 otherwise.
+ */
+static int
+virNWFilterDefLoopDetect(virConnectPtr conn,
+ virNWFilterPoolObjListPtr pools,
+ virNWFilterDefPtr def)
+{
+ return _virNWFilterDefLoopDetect(conn, pools, def, def->name);
+}
+
+int nCallbackDriver;
+#define MAX_CALLBACK_DRIVER 10
+static virNWFilterCallbackDriverPtr
callbackDrvArray[MAX_CALLBACK_DRIVER];
+
+void
+virNWFilterRegisterCallbackDriver(virNWFilterCallbackDriverPtr cbd)
+{
+ if (nCallbackDriver < MAX_CALLBACK_DRIVER) {
+ callbackDrvArray[nCallbackDriver++] = cbd;
+ }
+}
+
+
+struct cbStruct {
+ virConnectPtr conn;
+ int doUpdate;
+ int err;
+};
+
+static void
+virNWFilterDomainFWUpdateCB(void *payload,
+ const char *name ATTRIBUTE_UNUSED,
+ void *data)
+{
+ virDomainObjPtr obj = payload;
+ virDomainDefPtr vm = obj->def;
+ struct cbStruct *cb = data;
+ int i;
+
+ virDomainObjLock(obj);
+
+ if (virDomainObjIsActive(obj)) {
+ for (i = 0; i < vm->nnets; i++) {
+ virDomainNetDefPtr net = vm->nets[i];
+ if ((net->filter) && (net->ifname)) {
+ if (cb->doUpdate)
+ cb->err =
virNWFilterUpdateInstantiateFilter(cb->conn,
+ net);
+ else
+ cb->err = virNWFilterRollbackUpdateFilter(cb->conn,
net);
+ if (cb->err)
+ break;
+ }
+ }
+ }
+
+ virDomainObjUnlock(obj);
+}
+
+
+static int
+virNWFilterTriggerVMFilterRebuild(virConnectPtr conn)
+{
+ int i;
+ int err;
+ struct cbStruct cb = {
+ .conn = conn,
+ .err = 0,
+ .doUpdate = 1,
+ };
+
+ for (i = 0; i < nCallbackDriver; i++) {
+ callbackDrvArray[i]->vmFilterRebuild(conn,
+
virNWFilterDomainFWUpdateCB,
+ &cb);
+ }
+
+ err = cb.err;
+
+ if (err) {
+ cb.doUpdate = 0; // rollback
+ cb.err = 0;
+
+ for (i = 0; i < nCallbackDriver; i++)
+ callbackDrvArray[i]->vmFilterRebuild(conn,
+
virNWFilterDomainFWUpdateCB,
+ &cb);
+ }
+
+ return err;
+}
+
+
+int
+virNWFilterTestUnassignDef(virConnectPtr conn,
+ virNWFilterPoolObjPtr pool)
+{
+ int rc = 0;
+
+ virNWFilterLockFilterUpdates();
+
+ pool->wantRemoved = 1;
+ // trigger the update on VMs referencing the filter
+ if (virNWFilterTriggerVMFilterRebuild(conn))
+ rc = 1;
+
+ pool->wantRemoved = 0;
+ virNWFilterUnlockFilterUpdates();
+ return rc;
+}
+
+
+virNWFilterPoolObjPtr
+virNWFilterPoolObjAssignDef(virConnectPtr conn,
+ virNWFilterPoolObjListPtr pools,
+ virNWFilterDefPtr def)
+{
+ virNWFilterPoolObjPtr pool;
+
+ if (virNWFilterDefLoopDetect(conn, pools, def)) {
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ "%s", _("filter would introduce loop"));
+ return NULL;
+ }
+
+ if ((pool = virNWFilterPoolObjFindByName(pools, def->name))) {
+ virNWFilterLockFilterUpdates();
+ pool->newDef = def;
+ // trigger the update on VMs referencing the filter
+ if (virNWFilterTriggerVMFilterRebuild(conn)) {
+ pool->newDef = NULL;
+ virNWFilterUnlockFilterUpdates();
+ virNWFilterPoolObjUnlock(pool);
+ return NULL;
+ }
+
+ virNWFilterDefFree(pool->def);
+ pool->def = def;
+ pool->newDef = NULL;
+ virNWFilterUnlockFilterUpdates();
+ return pool;
+ }
+
+ if (VIR_ALLOC(pool) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ if (virRecursiveMutexInit(&pool->lock) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("cannot initialize mutex"));
+ VIR_FREE(pool);
+ return NULL;
+ }
+ virNWFilterPoolObjLock(pool);
+ pool->active = 0;
+ pool->def = def;
+
+ if (VIR_REALLOC_N(pools->objs, pools->count+1) < 0) {
+ pool->def = NULL;
+ virNWFilterPoolObjUnlock(pool);
+ virNWFilterPoolObjFree(pool);
+ virReportOOMError();
+ return NULL;
+ }
+ pools->objs[pools->count++] = pool;
+
+ return pool;
+}
+
+
+static virNWFilterPoolObjPtr
+virNWFilterPoolObjLoad(virConnectPtr conn,
+ virNWFilterPoolObjListPtr pools,
+ const char *file,
+ const char *path)
+{
+ virNWFilterDefPtr def;
+ virNWFilterPoolObjPtr pool;
+
+ if (!(def = virNWFilterDefParseFile(conn, path))) {
+ return NULL;
+ }
+
+ if (!virFileMatchesNameSuffix(file, def->name, ".xml")) {
+ virNWFilterError(conn, VIR_ERR_INVALID_NWFILTER,
+ "NWFilter pool config filename '%s' does not match pool
name '%s'",
+ path, def->name);
+ virNWFilterDefFree(def);
+ return NULL;
+ }
+
+ if (!(pool = virNWFilterPoolObjAssignDef(conn, pools, def))) {
+ virNWFilterDefFree(def);
+ return NULL;
+ }
+
+ pool->configFile = strdup(path);
+ if (pool->configFile == NULL) {
+ virReportOOMError();
+ virNWFilterDefFree(def);
+ return NULL;
+ }
+
+ return pool;
+}
+
+
+int
+virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
+ virNWFilterPoolObjListPtr pools,
+ const char *configDir)
+{
+ DIR *dir;
+ struct dirent *entry;
+
+ if (!(dir = opendir(configDir))) {
+ if (errno == ENOENT) {
+ return 0;
+ }
+ virReportSystemError(errno, _("Failed to open dir '%s'"),
+ configDir);
+ return -1;
+ }
+
+ while ((entry = readdir(dir))) {
+ char path[PATH_MAX];
+ virNWFilterPoolObjPtr pool;
+
+ if (entry->d_name[0] == '.')
+ continue;
+
+ if (!virFileHasSuffix(entry->d_name, ".xml"))
+ continue;
+
+ if (virFileBuildPath(configDir, entry->d_name,
+ NULL, path, PATH_MAX) < 0) {
+ virNWFilterError(conn, VIR_ERR_INTERNAL_ERROR,
+ "Config filename '%s/%s' is too long",
+ configDir, entry->d_name);
+ continue;
+ }
+
+ pool = virNWFilterPoolObjLoad(conn, pools, entry->d_name,
path);
+ if (pool)
+ virNWFilterPoolObjUnlock(pool);
+ }
+
+ closedir(dir);
+
+ return 0;
+}
+
+
+int
+virNWFilterPoolObjSaveDef(virConnectPtr conn,
+ virNWFilterDriverStatePtr driver,
+ virNWFilterPoolObjPtr pool,
+ virNWFilterDefPtr def)
+{
+ char *xml;
+ int fd = -1, ret = -1;
+ ssize_t towrite;
+
+ if (!pool->configFile) {
+ int err;
+ char path[PATH_MAX];
+
+ if ((err = virFileMakePath(driver->configDir))) {
+ virReportSystemError(err,
+ _("cannot create config directory %
s"),
+ driver->configDir);
+ return -1;
+ }
+
+ if (virFileBuildPath(driver->configDir, def->name, ".xml",
+ path, sizeof(path)) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("cannot construct config file
path"));
+ return -1;
+ }
+ if (!(pool->configFile = strdup(path))) {
+ virReportOOMError();
+ return -1;
+ }
+ }
+
+ if (!(xml = virNWFilterDefFormat(conn, def))) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("failed to generate XML"));
+ return -1;
+ }
+
+ if ((fd = open(pool->configFile,
+ O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR )) < 0) {
+ virReportSystemError(errno,
+ _("cannot create config file %s"),
+ pool->configFile);
+ goto cleanup;
+ }
+
+ towrite = strlen(xml);
+ if (safewrite(fd, xml, towrite) != towrite) {
+ virReportSystemError(errno,
+ _("cannot write config file %s"),
+ pool->configFile);
+ goto cleanup;
+ }
+
+ if (close(fd) < 0) {
+ virReportSystemError(errno,
+ _("cannot save config file %s"),
+ pool->configFile);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+ cleanup:
+ if (fd != -1)
+ close(fd);
+
+ VIR_FREE(xml);
+
+ return ret;
+}
+
+
+int
+virNWFilterPoolObjDeleteDef(virConnectPtr conn,
+ virNWFilterPoolObjPtr pool)
+{
+ if (!pool->configFile) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("no config file for %s"),
pool->def->name);
+ return -1;
+ }
+
+ if (unlink(pool->configFile) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("cannot remove config for %s"),
+ pool->def->name);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static void
+virNWIPAddressFormat(virBufferPtr buf, nwIPAddressPtr ipaddr)
+{
+ if (!ipaddr->isIPv6) {
+ virBufferVSprintf(buf, "%d.%d.%d.%d",
+ ipaddr->addr.ipv4Addr[0],
+ ipaddr->addr.ipv4Addr[1],
+ ipaddr->addr.ipv4Addr[2],
+ ipaddr->addr.ipv4Addr[3]);
+ } else {
+ virBufferAddLit(buf, "MISSING IPv6 ADDRESS FORMATTER");
+ }
+}
+
+
+static void
+virNWFilterRuleDefDetailsFormat(virConnectPtr conn,
+ virBufferPtr buf,
+ const char *type,
+ const virXMLAttr2Struct *att,
+ virNWFilterRuleDefPtr def)
+{
+ int i, j;
+ bool typeShown = 0;
+ bool neverShown = 1;
+ enum match {
+ MATCH_NONE = 0,
+ MATCH_YES,
+ MATCH_NO
+ } matchShown = MATCH_NONE;
+ nwItemDesc *item;
+
+ while (att[i].name) {
+ item = (nwItemDesc *)((char *)def + att[i].dataIdx);
+ enum virNWFilterEntryItemFlags flags = item->flags;
+ void *storage_ptr;
+ if ((flags & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)) {
+ if (!typeShown) {
+ virBufferVSprintf(buf, " <%s", type);
+ typeShown = 1;
+ neverShown = 0;
+ }
+
+ if ((flags & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG)) {
+ if (matchShown == MATCH_NONE) {
+ virBufferAddLit(buf, " match='no'");
+ matchShown = MATCH_NO;
+ } else if (matchShown == MATCH_YES) {
+ virBufferAddLit(buf, "/>\n");
+ typeShown = 0;
+ matchShown = MATCH_NONE;
+ continue;
+ }
+ } else {
+ if (matchShown == MATCH_NO) {
+ virBufferAddLit(buf, "/>\n");
+ typeShown = 0;
+ matchShown = MATCH_NONE;
+ continue;
+ }
+ matchShown = MATCH_YES;
+ }
+
+ virBufferVSprintf(buf, " %s='",
+ att[i].name);
+ if (att[i].formatter) {
+ if (!att[i].formatter(buf, def)) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("formatter for %s %s
reported error"),
+ type,
+ att[i].name);
+ goto err_exit;
+ }
+ } else if ((flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
+ virBufferVSprintf(buf, "$%s", item->var);
+ } else {
+ switch (att[i].datatype) {
+
+ case DATATYPE_IPMASK:
+ // display all masks in CIDR format
+ case DATATYPE_UINT8:
+ storage_ptr = &item->u.u8;
+ virBufferVSprintf(buf, "%d", *(uint8_t
*)storage_ptr);
+ break;
+
+ case DATATYPE_UINT16:
+ storage_ptr = &item->u.u16;
+ virBufferVSprintf(buf, "%d", *(uint16_t
*)storage_ptr);
+ break;
+
+ case DATATYPE_IPADDR:
+ storage_ptr = &item->u.ipaddr;
+ virNWIPAddressFormat(buf,
+ (nwIPAddressPtr)storage_ptr);
+ break;
+
+ case DATATYPE_MACMASK:
+ case DATATYPE_MACADDR:
+ storage_ptr = &item->u.macaddr;
+ for (j = 0; j < 6; j++)
+ virBufferVSprintf(buf, "%02x%s",
+
((nwMACAddressPtr)storage_ptr)->addr[j],
+ (j < 5) ? ":" : "");
+ break;
+
+ case DATATYPE_STRING:
+ default:
+ virBufferVSprintf(buf,
+ "UNSUPPORTED DATATYPE 0x%02x\n",
+ att[i].datatype);
+ }
+ }
+ virBufferAddLit(buf, "'");
+ }
+ i++;
+ }
+ if (typeShown)
+ virBufferAddLit(buf, "/>\n");
+
+ if (neverShown)
+ virBufferVSprintf(buf,
+ " <%s/>\n", type);
+
+err_exit:
+ return;
+}
+
+
+static char *
+virNWFilterRuleDefFormat(virConnectPtr conn,
+ virNWFilterRuleDefPtr def)
+{
+ int i;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ virBuffer buf2 = VIR_BUFFER_INITIALIZER;
+ char *data;
+
+ virBufferVSprintf(&buf, " <rule action='%s' direction='%s'
priority='%d'",
+ virNWFilterRuleActionTypeToString(def->action),
+ virNWFilterRuleDirectionTypeToString(def->tt),
+ def->priority);
+
+ i = 0;
+ while (virAttr[i].id) {
+ if (virAttr[i].prtclType == def->prtclType) {
+ virNWFilterRuleDefDetailsFormat(conn,
+ &buf2,
+ virAttr[i].id,
+ virAttr[i].att,
+ def);
+ break;
+ }
+ i++;
+ }
+
+ if (virBufferError(&buf2))
+ goto no_memory;
+
+ data = virBufferContentAndReset(&buf2);
+
+ if (data) {
+ virBufferAddLit(&buf, ">\n");
+ virBufferVSprintf(&buf, "%s </rule>\n", data);
+ VIR_FREE(data);
+ } else
+ virBufferAddLit(&buf, "/>\n");
+
+ if (virBufferError(&buf))
+ goto no_memory;
+
+ return virBufferContentAndReset(&buf);
+
+no_memory:
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ virBufferFreeAndReset(&buf2);
+
+ return NULL;
+}
+
+
+static char *
+virNWFilterIncludeDefFormat(virNWFilterIncludeDefPtr inc)
+{
+ char *attrs;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virBufferVSprintf(&buf," <filterref filter='%s'",
+ inc->filterref);
+
+ attrs = virNWFilterFormatParamAttributes(inc->params, " ");
+
+ if (!attrs || strlen(attrs) <= 1)
+ virBufferAddLit(&buf, "/>\n");
+ else
+ virBufferVSprintf(&buf, ">\n%s </filterref>\n", attrs);
+
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+}
+
+
+static char *
+virNWFilterEntryFormat(virConnectPtr conn,
+ virNWFilterEntryPtr entry)
+{
+ if (entry->rule)
+ return virNWFilterRuleDefFormat(conn, entry->rule);
+ return virNWFilterIncludeDefFormat(entry->include);
+}
+
+
+char *
+virNWFilterDefFormat(virConnectPtr conn,
+ virNWFilterDefPtr def)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ char uuid[VIR_UUID_STRING_BUFLEN];
+ int i;
+ char *xml;
+
+ virBufferVSprintf(&buf, "<filter name='%s' chain='%s'",
+ def->name,
+
virNWFilterChainSuffixTypeToString(def->chainsuffix));
+ virBufferAddLit(&buf, ">\n");
+
+ virUUIDFormat(def->uuid, uuid);
+ virBufferVSprintf(&buf," <uuid>%s</uuid>\n", uuid);
+
+ for (i = 0; i < def->nentries; i++) {
+ xml = virNWFilterEntryFormat(conn, def->filterEntries[i]);
+ if (!xml)
+ goto err_exit;
+ virBufferVSprintf(&buf, "%s", xml);
+ VIR_FREE(xml);
+ }
+
+ virBufferAddLit(&buf, "</filter>\n");
+
+ if (virBufferError(&buf))
+ goto no_memory;
+
+ return virBufferContentAndReset(&buf);
+
+ no_memory:
+ virReportOOMError();
+
+ err_exit:
+ virBufferFreeAndReset(&buf);
+ return NULL;
+}
+
+
+char *virNWFilterConfigFile(virConnectPtr conn ATTRIBUTE_UNUSED,
+ const char *dir,
+ const char *name)
+{
+ char *ret = NULL;
+
+ if (virAsprintf(&ret, "%s/%s.xml", dir, name) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ return ret;
+}
+
+
+int virNWFilterConfLayerInit(void) {
+ if (virMutexInit(&updateMutex))
+ return 1;
+
+ if (regcomp(®ex_nam, "^[a-zA-Z0-9_]+$" , REG_NOSUB|
REG_EXTENDED) != 0)
+ return -1;
+
+ if (regcomp(®ex_val, "^[a-zA-Z0-9_.:]+$", REG_NOSUB|
REG_EXTENDED) != 0) {
+ regfree(®ex_nam);
+ return -1;
+ }
+
+ return 0;
+}
+
+
+void virNWFilterConfLayerShutdown(void) {
+ regfree(®ex_nam);
+ regfree(®ex_val);
+}
+
+
+void virNWFilterPoolObjLock(virNWFilterPoolObjPtr obj)
+{
+ virMutexLock(&obj->lock);
+}
+
+void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj)
+{
+ virMutexUnlock(&obj->lock);
+}
Index: libvirt-acl/src/conf/nwfilter_conf.h
===================================================================
--- /dev/null
+++ libvirt-acl/src/conf/nwfilter_conf.h
@@ -0,0 +1,472 @@
+/*
+ * nwfilter_conf.h: network filter XML processing
+ * (derived from storage_conf.h)
+ *
+ * Copyright (C) 2006-2010 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Daniel P. Berrange
+ *
+ * Copyright (C) 2010 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Stefan Berger <stefanb(a)us.ibm.com>
+ */
+#ifndef NWFILTER_CONF_H
+#define NWFILTER_CONF_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include "internal.h"
+#include "util.h"
+#include "hash.h"
+#include "xml.h"
+
+/**
+ * Chain suffix size is:
+ * max. user define table name length -
+ * sizeof("FO-") -
+ * max. interface name size -
+ * sizeof("-") -
+ * terminating '0' =
+ * 32-3-15-1-1 = 12
+ */
+#define MAX_CHAIN_SUFFIX_SIZE 12
+
+
+enum virNWFilterEntryItemFlags {
+ NWFILTER_ENTRY_ITEM_FLAG_EXISTS = 1 << 0,
+ NWFILTER_ENTRY_ITEM_FLAG_IS_NEG = 1 << 1,
+ NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR = 1 << 2,
+};
+
+
+#define HAS_ENTRY_ITEM(data) \
+ (((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_EXISTS)
+
+#define ENTRY_GET_NEG_SIGN(data) \
+ ((((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG) ? "!" : "")
+
+// datatypes appearing in rule attributes
+enum attrDatatype {
+ DATATYPE_UINT16 = (1 << 0),
+ DATATYPE_UINT8 = (1 << 1),
+ DATATYPE_MACADDR = (1 << 2),
+ DATATYPE_MACMASK = (1 << 3),
+ DATATYPE_IPADDR = (1 << 4),
+ DATATYPE_IPMASK = (1 << 5),
+ DATATYPE_STRING = (1 << 6),
+
+ DATATYPE_LAST = (1 << 7),
+};
+
+
+typedef struct _nwMACAddress nwMACAddress;
+typedef nwMACAddress *nwMACAddressPtr;
+struct _nwMACAddress {
+ unsigned char addr[6];
+};
+
+
+typedef struct _nwIPAddress nwIPAddress;
+typedef nwIPAddress *nwIPAddressPtr;
+struct _nwIPAddress {
+ int isIPv6;
+ union {
+ unsigned char ipv4Addr[4];
+ /* unsigned char ipv6Addr[16]; future :-) */
+ } addr;
+};
+
+
+typedef struct _nwItemDesc nwItemDesc;
+typedef nwItemDesc *nwItemDescPtr;
+struct _nwItemDesc {
+ enum virNWFilterEntryItemFlags flags;
+ char *var;
+ enum attrDatatype datatype;
+ union {
+ nwMACAddress macaddr;
+ nwIPAddress ipaddr;
+ uint8_t u8;
+ uint16_t u16;
+ char protocolID[10];
+ } u;
+};
+
+
+typedef struct _ethHdrFilterDef ethHdrFilterDef;
+typedef ethHdrFilterDef *ethHdrFilterDefPtr;
+struct _ethHdrFilterDef {
+ nwItemDesc dataSrcMACAddr;
+ nwItemDesc dataSrcMACMask;
+ nwItemDesc dataDstMACAddr;
+ nwItemDesc dataDstMACMask;
+ nwItemDesc dataProtocolID;
+ nwItemDesc dataPriority;
+ nwItemDesc dataVLANID;
+};
+
+
+typedef struct _arpHdrFilterDef arpHdrFilterDef;
+typedef arpHdrFilterDef *arpHdrFilterDefPtr;
+struct _arpHdrFilterDef {
+ nwItemDesc dataHWType;
+ nwItemDesc dataProtocolType;
+ nwItemDesc dataOpcode;
+ nwItemDesc dataSrcMACAddr;
+ nwItemDesc dataSrcIPAddr;
+ nwItemDesc dataDstMACAddr;
+ nwItemDesc dataDstIPAddr;
+};
+
+
+typedef struct _ipHdrDataDef ipHdrDataDef;
+typedef ipHdrDataDef *ipHdrDataDefPtr;
+struct _ipHdrDataDef {
+ nwItemDesc dataIPVersion;
+ nwItemDesc dataSrcAddr;
+ nwItemDesc dataSrcMask;
+ nwItemDesc dataDstAddr;
+ nwItemDesc dataDstMask;
+ nwItemDesc dataProtocolID;
+};
+
+
+typedef struct _portDataDef portDataDef;
+typedef portDataDef *portDataDefPtr;
+struct _portDataDef {
+ nwItemDesc dataSrcPortStart;
+ nwItemDesc dataSrcPortEnd;
+ nwItemDesc dataDstPortStart;
+ nwItemDesc dataDstPortEnd;
+};
+
+
+typedef struct _ipHdrFilterDef ipHdrFilterDef;
+typedef ipHdrFilterDef *ipHdrFilterDefPtr;
+struct _ipHdrFilterDef {
+ ipHdrDataDef ipHdr;
+ portDataDef portData;
+ nwItemDesc dataDSCP;
+};
+
+
+enum virNWFilterRuleActionType {
+ VIR_NWFILTER_RULE_ACTION_DROP = 0,
+ VIR_NWFILTER_RULE_ACTION_ACCEPT,
+
+ VIR_NWFILTER_RULE_ACTION_LAST,
+};
+
+enum virNWFilterRuleDirectionType {
+ VIR_NWFILTER_RULE_DIRECTION_IN = 0,
+ VIR_NWFILTER_RULE_DIRECTION_OUT,
+ VIR_NWFILTER_RULE_DIRECTION_INOUT,
+
+ VIR_NWFILTER_RULE_DIRECTION_LAST,
+};
+
+enum virNWFilterChainPolicyType {
+ VIR_NWFILTER_CHAIN_POLICY_ACCEPT = 0,
+ VIR_NWFILTER_CHAIN_POLICY_DROP,
+
+ VIR_NWFILTER_CHAIN_POLICY_LAST,
+};
+
+enum virNWFilterRuleProtocolType {
+ VIR_NWFILTER_RULE_PROTOCOL_NONE = 0,
+ VIR_NWFILTER_RULE_PROTOCOL_MAC,
+ VIR_NWFILTER_RULE_PROTOCOL_ARP,
+ VIR_NWFILTER_RULE_PROTOCOL_IP,
+};
+
+enum virNWFilterEbtablesTableType {
+ VIR_NWFILTER_EBTABLES_TABLE_FILTER = 0,
+ VIR_NWFILTER_EBTABLES_TABLE_NAT,
+ VIR_NWFILTER_EBTABLES_TABLE_BROUTE,
+
+ VIR_NWFILTER_EBTABLES_TABLE_LAST,
+};
+
+
+#define MAX_RULE_PRIORITY 1000
+
+
+typedef struct _virNWFilterRuleDef virNWFilterRuleDef;
+typedef virNWFilterRuleDef *virNWFilterRuleDefPtr;
+struct _virNWFilterRuleDef {
+ unsigned int priority;
+ int action; /*enum virNWFilterRuleActionType*/
+ int tt; /*enum virNWFilterRuleDirectionType*/
+ enum virNWFilterRuleProtocolType prtclType;
+ union {
+ ethHdrFilterDef ethHdrFilter;
+ arpHdrFilterDef arpHdrFilter;
+ ipHdrFilterDef ipHdrFilter;
+ } p;
+
+ int nvars;
+ char **vars;
+};
+
+
+typedef struct _virNWFilterHashTable virNWFilterHashTable;
+typedef virNWFilterHashTable *virNWFilterHashTablePtr;
+struct _virNWFilterHashTable {
+ virHashTablePtr hashTable;
+
+ int nNames;
+ char **names;
+};
+
+
+typedef struct _virNWFilterIncludeDef virNWFilterIncludeDef;
+typedef virNWFilterIncludeDef *virNWFilterIncludeDefPtr;
+struct _virNWFilterIncludeDef {
+ char *filterref;
+ virNWFilterHashTablePtr params;
+};
+
+
+typedef struct _virNWFilterEntry virNWFilterEntry;
+typedef virNWFilterEntry *virNWFilterEntryPtr;
+struct _virNWFilterEntry {
+ virNWFilterRuleDef *rule;
+ virNWFilterIncludeDef *include;
+};
+
+enum virNWFilterChainSuffixType {
+ VIR_NWFILTER_CHAINSUFFIX_ROOT = 0,
+ VIR_NWFILTER_CHAINSUFFIX_ARP,
+ VIR_NWFILTER_CHAINSUFFIX_IPv4,
+
+ VIR_NWFILTER_CHAINSUFFIX_LAST,
+};
+
+
+typedef struct _virNWFilterDef virNWFilterDef;
+typedef virNWFilterDef *virNWFilterDefPtr;
+
+struct _virNWFilterDef {
+ char *name;
+ unsigned char uuid[VIR_UUID_BUFLEN];
+
+ int chainsuffix; /*enum virNWFilterChainSuffixType */
+
+ int nentries;
+ virNWFilterEntryPtr *filterEntries;
+};
+
+
+typedef struct _virNWFilterPoolObj virNWFilterPoolObj;
+typedef virNWFilterPoolObj *virNWFilterPoolObjPtr;
+
+struct _virNWFilterPoolObj {
+ virMutex lock;
+
+ char *configFile;
+ int active;
+ int wantRemoved;
+
+ virNWFilterDefPtr def;
+ virNWFilterDefPtr newDef;
+};
+
+
+typedef struct _virNWFilterPoolObjList virNWFilterPoolObjList;
+typedef virNWFilterPoolObjList *virNWFilterPoolObjListPtr;
+struct _virNWFilterPoolObjList {
+ unsigned int count;
+ virNWFilterPoolObjPtr *objs;
+};
+
+
+typedef struct _virNWFilterDriverState virNWFilterDriverState;
+typedef virNWFilterDriverState *virNWFilterDriverStatePtr;
+struct _virNWFilterDriverState {
+ virMutex lock;
+
+ virNWFilterPoolObjList pools;
+
+ char *configDir;
+};
+
+
+typedef struct _virNWFilterTechDriver virNWFilterTechDriver;
+typedef virNWFilterTechDriver *virNWFilterTechDriverPtr;
+
+
+typedef struct _virNWFilterRuleInst virNWFilterRuleInst;
+typedef virNWFilterRuleInst *virNWFilterRuleInstPtr;
+struct _virNWFilterRuleInst {
+ int ndata;
+ void **data;
+ virNWFilterTechDriverPtr techdriver;
+};
+
+
+enum virDomainNetType;
+
+typedef int (*virNWFilterRuleCreateInstance)(virConnectPtr conn,
+ enum virDomainNetType
nettype,
+ virNWFilterDefPtr filter,
+ virNWFilterRuleDefPtr
rule,
+ const char *ifname,
+ virNWFilterHashTablePtr
vars,
+ virNWFilterRuleInstPtr
res);
+
+typedef int (*virNWFilterRuleApplyRules)(virConnectPtr conn,
+ const char *ifname,
+ int nruleInstances,
+ void **_inst);
+
+typedef int (*virNWFilterRuleRemoveRules)(virConnectPtr conn,
+ const char *ifname,
+ int nruleInstances,
+ void **_inst);
+
+typedef int (*virNWFilterRuleAllTeardown)(const char *ifname);
+
+typedef int (*virNWFilterRuleFreeInstanceData)(void * _inst);
+
+typedef int (*virNWFilterRuleDisplayInstanceData)(virConnectPtr conn,
+ void *_inst);
+
+
+struct _virNWFilterTechDriver {
+ const char *name;
+
+ virNWFilterRuleCreateInstance createRuleInstance;
+ virNWFilterRuleApplyRules applyRules;
+ virNWFilterRuleRemoveRules removeRules;
+ virNWFilterRuleAllTeardown allTeardown;
+ virNWFilterRuleFreeInstanceData freeRuleInstance;
+ virNWFilterRuleDisplayInstanceData displayRuleInstance;
+};
+
+
+virNWFilterHashTablePtr virNWFilterParseParamAttributes(xmlNodePtr
cur);
+char * virNWFilterFormatParamAttributes(virNWFilterHashTablePtr table,
+ const char *indent);
+
+virNWFilterHashTablePtr virNWFilterHashTableCreate(int n);
+void virNWFilterHashTableFree(virNWFilterHashTablePtr table);
+int virNWFilterHashTablePut(virNWFilterHashTablePtr table,
+ const char *name,
+ char *val,
+ int freeName);
+int virNWFilterHashTableRemoveEntry(virNWFilterHashTablePtr table,
+ const char *name);
+int virNWFilterHashTablePutAll(virConnectPtr conn,
+ virNWFilterHashTablePtr src,
+ virNWFilterHashTablePtr dest);
+
+void virNWFilterRuleDefFree(virNWFilterRuleDefPtr def);
+
+void virNWFilterDefFree(virNWFilterDefPtr def);
+void virNWFilterPoolObjListFree(virNWFilterPoolObjListPtr pools);
+void virNWFilterPoolObjRemove(virNWFilterPoolObjListPtr pools,
+ virNWFilterPoolObjPtr pool);
+
+void virNWFilterPoolObjFree(virNWFilterPoolObjPtr obj);
+
+virNWFilterPoolObjPtr
+ virNWFilterPoolObjFindByUUID(virNWFilterPoolObjListPtr pools,
+ const unsigned char *uuid);
+
+virNWFilterPoolObjPtr
+ virNWFilterPoolObjFindByName(virNWFilterPoolObjListPtr pools,
+ const char *name);
+
+
+int virNWFilterPoolObjSaveDef(virConnectPtr conn,
+ virNWFilterDriverStatePtr driver,
+ virNWFilterPoolObjPtr pool,
+ virNWFilterDefPtr def);
+
+int virNWFilterPoolObjDeleteDef(virConnectPtr conn,
+ virNWFilterPoolObjPtr pool);
+
+virNWFilterPoolObjPtr virNWFilterPoolObjAssignDef(virConnectPtr conn,
+
virNWFilterPoolObjListPtr pools,
+ virNWFilterDefPtr
def);
+
+int virNWFilterTestUnassignDef(virConnectPtr conn,
+ virNWFilterPoolObjPtr pool);
+
+virNWFilterDefPtr virNWFilterDefParseNode(virConnectPtr conn,
+ xmlDocPtr xml,
+ xmlNodePtr root);
+
+char *virNWFilterDefFormat(virConnectPtr conn,
+ virNWFilterDefPtr def);
+
+int virNWFilterSaveXML(virConnectPtr conn,
+ const char *configDir,
+ virNWFilterDefPtr def,
+ const char *xml);
+
+int virNWFilterSaveConfig(virConnectPtr conn,
+ const char *configDir,
+ virNWFilterDefPtr def);
+
+int virNWFilterPoolLoadAllConfigs(virConnectPtr conn,
+ virNWFilterPoolObjListPtr pools,
+ const char *configDir);
+
+char *virNWFilterConfigFile(virConnectPtr conn,
+ const char *dir,
+ const char *name);
+
+virNWFilterDefPtr virNWFilterDefParseString(virConnectPtr conn,
+ const char *xml);
+virNWFilterDefPtr virNWFilterDefParseFile(virConnectPtr conn,
+ const char *filename);
+
+void virNWFilterPoolObjLock(virNWFilterPoolObjPtr obj);
+void virNWFilterPoolObjUnlock(virNWFilterPoolObjPtr obj);
+
+int virNWFilterConfLayerInit(void);
+void virNWFilterConfLayerShutdown(void);
+
+#define virNWFilterReportError(conn, code, fmt...)
\
+ virReportErrorHelper(conn, VIR_FROM_NWFILTER, code, __FILE__,
\
+ __FUNCTION__, __LINE__, fmt)
+
+
+typedef int (*virNWFilterRebuild)(virConnectPtr conn,
+ virHashIterator, void *data);
+
+typedef struct _virNWFilterCallbackDriver virNWFilterCallbackDriver;
+typedef virNWFilterCallbackDriver *virNWFilterCallbackDriverPtr;
+struct _virNWFilterCallbackDriver {
+ const char *name;
+
+ virNWFilterRebuild vmFilterRebuild;
+};
+
+void virNWFilterRegisterCallbackDriver(virNWFilterCallbackDriverPtr);
+
+
+VIR_ENUM_DECL(virNWFilterRuleAction);
+VIR_ENUM_DECL(virNWFilterRuleDirection);
+VIR_ENUM_DECL(virNWFilterRuleProtocol);
+VIR_ENUM_DECL(virNWFilterJumpTarget);
+VIR_ENUM_DECL(virNWFilterChainPolicy);
+VIR_ENUM_DECL(virNWFilterEbtablesTable);
+VIR_ENUM_DECL(virNWFilterChainSuffix);
+
+#endif
Index: libvirt-acl/include/libvirt/virterror.h
===================================================================
--- libvirt-acl.orig/include/libvirt/virterror.h
+++ libvirt-acl/include/libvirt/virterror.h
@@ -69,6 +69,7 @@ typedef enum {
VIR_FROM_PHYP, /* Error from IBM power hypervisor */
VIR_FROM_SECRET, /* Error from secret storage */
VIR_FROM_CPU, /* Error from CPU driver */
+ VIR_FROM_NWFILTER, /* Error from network filter driver */
} virErrorDomain;
@@ -168,6 +169,10 @@ typedef enum {
VIR_ERR_NO_INTERFACE, /* interface driver not running */
VIR_ERR_INVALID_INTERFACE, /* invalid interface object */
VIR_ERR_MULTIPLE_INTERFACES, /* more than one matching interface
found */
+ VIR_WAR_NO_NWFILTER, /* failed to start nwfilter driver */
+ VIR_ERR_INVALID_NWFILTER, /* invalid nwfilter object */
+ VIR_ERR_NO_NWFILTER, /* nw filter pool not found */
+ VIR_ERR_BUILD_FIREWALL, /* nw filter pool not found */
VIR_WAR_NO_SECRET, /* failed to start secret storage */
VIR_ERR_INVALID_SECRET, /* invalid secret */
VIR_ERR_NO_SECRET, /* secret not found */
Index: libvirt-acl/src/util/virterror.c
===================================================================
--- libvirt-acl.orig/src/util/virterror.c
+++ libvirt-acl/src/util/virterror.c
@@ -175,6 +175,9 @@ static const char *virErrorDomainName(vi
case VIR_FROM_CPU:
dom = "CPU ";
break;
+ case VIR_FROM_NWFILTER:
+ dom = "Network Filter";
+ break;
}
return(dom);
}
@@ -1097,6 +1100,30 @@ virErrorMsg(virErrorNumber error, const
else
errmsg = _("Secret not found: %s");
break;
+ case VIR_WAR_NO_NWFILTER:
+ if (info == NULL)
+ errmsg = _("Failed to start the nwfilter driver");
+ else
+ errmsg = _("Failed to start the nwfilter driver: %s");
+ break;
+ case VIR_ERR_INVALID_NWFILTER:
+ if (info == NULL)
+ errmsg = _("Invalid network filter");
+ else
+ errmsg = _("Invalid network filter: %s");
+ break;
+ case VIR_ERR_NO_NWFILTER:
+ if (info == NULL)
+ errmsg = _("Network filter not found");
+ else
+ errmsg = _("Network filter not found: %s");
+ break;
+ case VIR_ERR_BUILD_FIREWALL:
+ if (info == NULL)
+ errmsg = _("Error while building firewall");
+ else
+ errmsg = _("Error while building firewall: %s");
+ break;
case VIR_ERR_CONFIG_UNSUPPORTED:
if (info == NULL)
errmsg = _("unsupported configuration");
Index: libvirt-acl/src/nwfilter/nwfilter_driver.c
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_driver.c
@@ -0,0 +1,429 @@
+/*
+ * nwfilter_driver.c: core driver for network filter APIs
+ * (based on storage_driver.c)
+ *
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Daniel P. Berrange
+ * Copyright (C) 2010 IBM Corporation
+ * Copyright (C) 2010 Stefan Berger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Daniel P. Berrange <berrange(a)redhat.com>
+ * Stefan Berger <stefanb(a)us.ibm.com>
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#if HAVE_PWD_H
+#include <pwd.h>
+#endif
+#include <errno.h>
+#include <string.h>
+
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "driver.h"
+#include "util.h"
+#include "nwfilter_driver.h"
+#include "nwfilter_conf.h"
+#include "memory.h"
+
+#include "domain_conf.h"
+#include "nwfilter_conf.h"
+#include "nwfilter_gentech_driver.h"
+#include "nwfilter_ebiptables_driver.h"
+
+#define VIR_FROM_THIS VIR_FROM_NWFILTER
+
+#define nwfilterLog(msg...) fprintf(stderr, msg)
+
+
+static virNWFilterDriverStatePtr driverState;
+
+static int nwfilterDriverShutdown(void);
+
+static void nwfilterDriverLock(virNWFilterDriverStatePtr driver)
+{
+ virMutexLock(&driver->lock);
+}
+static void nwfilterDriverUnlock(virNWFilterDriverStatePtr driver)
+{
+ virMutexUnlock(&driver->lock);
+}
+
+
+/**
+ * virNWFilterStartup:
+ *
+ * Initialization function for the QEmu daemon
+ */
+static int
+nwfilterDriverStartup(int privileged) {
+ char *base = NULL;
+
+ if (virNWFilterConfLayerInit() < 0)
+ return -1;
+
+ if (VIR_ALLOC(driverState) < 0)
+ goto alloc_err_exit;
+
+ if (virMutexInit(&driverState->lock) < 0)
+ goto alloc_err_exit;
+
+ nwfilterDriverLock(driverState);
+
+ if (privileged) {
+ if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
+ goto out_of_memory;
+ } else {
+ uid_t uid = geteuid();
+ char *userdir = virGetUserDirectory(uid);
+
+ if (!userdir)
+ goto error;
+
+ if (virAsprintf(&base, "%s/.libvirt", userdir) == -1) {
+ nwfilterLog("out of memory in virAsprintf");
+ VIR_FREE(userdir);
+ goto out_of_memory;
+ }
+ VIR_FREE(userdir);
+ }
+
+ if (virAsprintf(&driverState->configDir,
+ "%s/nwfilter", base) == -1)
+ goto out_of_memory;
+
+ VIR_FREE(base);
+
+ if (virNWFilterPoolLoadAllConfigs(NULL,
+ &driverState->pools,
+ driverState->configDir) < 0)
+ goto error;
+
+ nwfilterDriverUnlock(driverState);
+
+ return 0;
+
+out_of_memory:
+ nwfilterLog("virNWFilterStartup: out of memory");
+
+error:
+ VIR_FREE(base);
+ nwfilterDriverUnlock(driverState);
+ nwfilterDriverShutdown();
+
+alloc_err_exit:
+ virNWFilterConfLayerShutdown();
+
+ return -1;
+}
+
+/**
+ * virNWFilterReload:
+ *
+ * Function to restart the nwfilter driver, it will recheck the
configuration
+ * files and update its state
+ */
+static int
+nwfilterDriverReload(void) {
+ if (!driverState) {
+ return -1;
+ }
+
+ nwfilterDriverLock(driverState);
+ virNWFilterPoolLoadAllConfigs(NULL,
+ &driverState->pools,
+ driverState->configDir);
+ nwfilterDriverUnlock(driverState);
+
+ return 0;
+}
+
+/**
+ * virNWFilterActive:
+ *
+ * Checks if the nwfilter driver is active, i.e. has an active pool
+ *
+ * Returns 1 if active, 0 otherwise
+ */
+static int
+nwfilterDriverActive(void) {
+ if (!driverState->pools.count)
+ return 0;
+ return 1;
+}
+
+/**
+ * virNWFilterShutdown:
+ *
+ * Shutdown the nwfilter driver, it will stop all active nwfilter pools
+ */
+static int
+nwfilterDriverShutdown(void) {
+ if (!driverState)
+ return -1;
+
+ nwfilterDriverLock(driverState);
+
+ /* free inactive pools */
+ virNWFilterPoolObjListFree(&driverState->pools);
+
+ VIR_FREE(driverState->configDir);
+ nwfilterDriverUnlock(driverState);
+ virMutexDestroy(&driverState->lock);
+ VIR_FREE(driverState);
+
+ return 0;
+}
+
+
+static virNWFilterPtr
+nwfilterLookupByUUID(virConnectPtr conn,
+ const unsigned char *uuid) {
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ virNWFilterPoolObjPtr pool;
+ virNWFilterPtr ret = NULL;
+
+ nwfilterDriverLock(driver);
+ pool = virNWFilterPoolObjFindByUUID(&driver->pools, uuid);
+ nwfilterDriverUnlock(driver);
+
+ if (!pool) {
+ virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ "%s", _("no pool with matching uuid"));
+ goto cleanup;
+ }
+
+ ret = virGetNWFilter(conn, pool->def->name, pool->def->uuid);
+
+cleanup:
+ if (pool)
+ virNWFilterPoolObjUnlock(pool);
+ return ret;
+}
+
+
+static virNWFilterPtr
+nwfilterLookupByName(virConnectPtr conn,
+ const char *name) {
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ virNWFilterPoolObjPtr pool;
+ virNWFilterPtr ret = NULL;
+
+ nwfilterDriverLock(driver);
+ pool = virNWFilterPoolObjFindByName(&driver->pools, name);
+ nwfilterDriverUnlock(driver);
+
+ if (!pool) {
+ virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ _("no pool with matching name '%s'"),
name);
+ goto cleanup;
+ }
+
+ ret = virGetNWFilter(conn, pool->def->name, pool->def->uuid);
+
+cleanup:
+ if (pool)
+ virNWFilterPoolObjUnlock(pool);
+ return ret;
+}
+
+
+static virDrvOpenStatus
+nwfilterOpen(virConnectPtr conn,
+ virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED) {
+ if (!driverState)
+ return VIR_DRV_OPEN_DECLINED;
+
+ conn->nwfilterPrivateData = driverState;
+ return VIR_DRV_OPEN_SUCCESS;
+}
+
+
+static int
+nwfilterClose(virConnectPtr conn) {
+ conn->nwfilterPrivateData = NULL;
+ return 0;
+}
+
+
+static int
+nwfilterNumNWFilters(virConnectPtr conn) {
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ return driver->pools.count;
+}
+
+
+static int
+nwfilterListNWFilters(virConnectPtr conn,
+ char **const names,
+ int nnames) {
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ int got = 0, i;
+
+ nwfilterDriverLock(driver);
+ for (i = 0 ; i < driver->pools.count && got < nnames ; i++) {
+ virNWFilterPoolObjLock(driver->pools.objs[i]);
+ if (!(names[got] = strdup(driver->pools.objs[i]->def->name))) {
+ virNWFilterPoolObjUnlock(driver->pools.objs[i]);
+ virReportOOMError();
+ goto cleanup;
+ }
+ got++;
+ virNWFilterPoolObjUnlock(driver->pools.objs[i]);
+ }
+ nwfilterDriverUnlock(driver);
+ return got;
+
+ cleanup:
+ nwfilterDriverUnlock(driver);
+ for (i = 0 ; i < got ; i++)
+ VIR_FREE(names[i]);
+ memset(names, 0, nnames * sizeof(*names));
+ return -1;
+}
+
+
+static virNWFilterPtr
+nwfilterDefine(virConnectPtr conn,
+ const char *xml,
+ unsigned int flags ATTRIBUTE_UNUSED) {
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ virNWFilterDefPtr def;
+ virNWFilterPoolObjPtr pool = NULL;
+ virNWFilterPtr ret = NULL;
+
+ nwfilterDriverLock(driver);
+ if (!(def = virNWFilterDefParseString(conn, xml)))
+ goto cleanup;
+
+ if (!(pool = virNWFilterPoolObjAssignDef(conn, &driver->pools,
def)))
+ goto cleanup;
+
+ if (virNWFilterPoolObjSaveDef(conn, driver, pool, def) < 0) {
+ virNWFilterPoolObjRemove(&driver->pools, pool);
+ def = NULL;
+ goto cleanup;
+ }
+ def = NULL;
+
+ ret = virGetNWFilter(conn, pool->def->name, pool->def->uuid);
+
+cleanup:
+ virNWFilterDefFree(def);
+ if (pool)
+ virNWFilterPoolObjUnlock(pool);
+ nwfilterDriverUnlock(driver);
+ return ret;
+}
+
+
+static int
+nwfilterUndefine(virNWFilterPtr obj) {
+ virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
+ virNWFilterPoolObjPtr pool;
+ int ret = -1;
+
+ nwfilterDriverLock(driver);
+ pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
+ if (!pool) {
+ virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
+ "%s", _("no nwfilter pool with matching
uuid"));
+ goto cleanup;
+ }
+
+ if (virNWFilterTestUnassignDef(obj->conn, pool)) {
+ virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
+ "%s",
+ _("nwfilter is in use"));
+ goto cleanup;
+ }
+
+ if (virNWFilterPoolObjDeleteDef(obj->conn, pool) < 0)
+ goto cleanup;
+
+ VIR_FREE(pool->configFile);
+
+ virNWFilterPoolObjRemove(&driver->pools, pool);
+ pool = NULL;
+ ret = 0;
+
+cleanup:
+ if (pool)
+ virNWFilterPoolObjUnlock(pool);
+ nwfilterDriverUnlock(driver);
+ return ret;
+}
+
+
+static char *
+nwfilterDumpXML(virNWFilterPtr obj,
+ unsigned int flags ATTRIBUTE_UNUSED) {
+ virNWFilterDriverStatePtr driver = obj->conn->nwfilterPrivateData;
+ virNWFilterPoolObjPtr pool;
+ char *ret = NULL;
+
+ nwfilterDriverLock(driver);
+ pool = virNWFilterPoolObjFindByUUID(&driver->pools, obj->uuid);
+ nwfilterDriverUnlock(driver);
+
+ if (!pool) {
+ virNWFilterReportError(obj->conn, VIR_ERR_INVALID_NWFILTER,
+ "%s", _("no nwfilter pool with matching
uuid"));
+ goto cleanup;
+ }
+
+ ret = virNWFilterDefFormat(obj->conn, pool->def);
+
+cleanup:
+ if (pool)
+ virNWFilterPoolObjUnlock(pool);
+ return ret;
+}
+
+
+static virNWFilterDriver nwfilterDriver = {
+ .name = "nwfilter",
+ .open = nwfilterOpen,
+ .close = nwfilterClose,
+ .numOfNWFilters = nwfilterNumNWFilters,
+ .listNWFilters = nwfilterListNWFilters,
+ .nwfilterLookupByName = nwfilterLookupByName,
+ .nwfilterLookupByUUID = nwfilterLookupByUUID,
+ .defineXML = nwfilterDefine,
+ .undefine = nwfilterUndefine,
+ .getXMLDesc = nwfilterDumpXML,
+};
+
+
+static virStateDriver stateDriver = {
+ .name = "NWFilter",
+ .initialize = nwfilterDriverStartup,
+ .cleanup = nwfilterDriverShutdown,
+ .reload = nwfilterDriverReload,
+ .active = nwfilterDriverActive,
+};
+
+int nwfilterRegister(void) {
+ virRegisterNWFilterDriver(&nwfilterDriver);
+ virRegisterStateDriver(&stateDriver);
+ return 0;
+}
Index: libvirt-acl/src/nwfilter/nwfilter_driver.h
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_driver.h
@@ -0,0 +1,35 @@
+/*
+ * nwfilter_driver.h: core driver for nwfilter APIs
+ * (based on storage driver)
+ *
+ * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2008 Daniel P. Berrange
+ * Copyright (C) 2010 IBM Corporation
+ * Copyright (C) 2010 Stefan Berger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Daniel P. Berrange <berrange(a)redhat.com>
+ * Stefan Berger <stefanb(a)us.ibm.com>
+ */
+
+#ifndef __VIR_NWFILTER_DRIVER_H__
+#define __VIR_NWFILTER_DRIVER_H__
+
+#include "nwfilter_conf.h"
+
+int nwfilterRegister(void);
+
+#endif /* __VIR_NWFILTER_DRIVER_H__ */
Index: libvirt-acl/src/datatypes.h
===================================================================
--- libvirt-acl.orig/src/datatypes.h
+++ libvirt-acl/src/datatypes.h
@@ -121,6 +121,17 @@
/**
+ * VIR_NWFILTER_MAGIC:
+ *
+ * magic value used to protect the API when pointers to network filter
+ * pool structures are passed down by the users.
+ */
+#define VIR_NWFILTER_MAGIC 0xDEAD7777
+#define VIR_IS_NWFILTER(obj) ((obj) &&
(obj)->magic==VIR_NWFILTER_MAGIC)
+#define VIR_IS_CONNECTED_NWFILTER(obj) (VIR_IS_NWFILTER(obj) &&
VIR_IS_CONNECT((obj)->conn))
+
+
+/**
* _virConnect:
*
* Internal structure associated to a connection
@@ -141,6 +152,7 @@ struct _virConnect {
virStorageDriverPtr storageDriver;
virDeviceMonitorPtr deviceMonitor;
virSecretDriverPtr secretDriver;
+ virNWFilterDriverPtr nwfilterDriver;
/* Private data pointer which can be used by driver and
* network driver as they wish.
@@ -152,6 +164,7 @@ struct _virConnect {
void * storagePrivateData;
void * devMonPrivateData;
void * secretPrivateData;
+ void * nwfilterPrivateData;
/*
* The lock mutex must be acquired before accessing/changing
@@ -173,6 +186,7 @@ struct _virConnect {
virHashTablePtr storageVols;/* hash table for known storage vols */
virHashTablePtr nodeDevices; /* hash table for known node devices
*/
virHashTablePtr secrets; /* hash taboe for known secrets */
+ virHashTablePtr nwfilterPools; /* hash tables ofr known nw filter
pools */
int refs; /* reference count */
};
@@ -336,4 +350,22 @@ int virUnrefSecret(virSecretPtr secret);
virStreamPtr virGetStream(virConnectPtr conn);
int virUnrefStream(virStreamPtr st);
+/**
+* _virNWFilter:
+*
+* Internal structure associated to a network filter
+*/
+struct _virNWFilter {
+ unsigned int magic; /* specific value to check */
+ int refs; /* reference count */
+ virConnectPtr conn; /* pointer back to the
connection */
+ char *name; /* the network filter external
name */
+ unsigned char uuid[VIR_UUID_BUFLEN]; /* the network filter unique
identifier */
+};
+
+virNWFilterPtr virGetNWFilter(virConnectPtr conn,
+ const char *name,
+ const unsigned char *uuid);
+int virUnrefNWFilter(virNWFilterPtr pool);
+
#endif
Index: libvirt-acl/src/datatypes.c
===================================================================
--- libvirt-acl.orig/src/datatypes.c
+++ libvirt-acl/src/datatypes.c
@@ -175,6 +175,9 @@ virGetConnect(void) {
ret->secrets = virHashCreate(20);
if (ret->secrets == NULL)
goto failed;
+ ret->nwfilterPools = virHashCreate(20);
+ if (ret->nwfilterPools == NULL)
+ goto failed;
ret->refs = 1;
return(ret);
@@ -1362,3 +1365,142 @@ int virUnrefStream(virStreamPtr st) {
virMutexUnlock(&st->conn->lock);
return (refs);
}
+
+
+/**
+ * virGetNWFilter:
+ * @conn: the hypervisor connection
+ * @name: pointer to the network filter pool name
+ * @uuid: pointer to the uuid
+ *
+ * Lookup if the network filter is already registered for that
connection,
+ * if yes return a new pointer to it, if no allocate a new structure,
+ * and register it in the table. In any case a corresponding call to
+ * virFreeNWFilterPool() is needed to not leak data.
+ *
+ * Returns a pointer to the network, or NULL in case of failure
+ */
+virNWFilterPtr
+virGetNWFilter(virConnectPtr conn, const char *name, const unsigned
char *uuid) {
+ virNWFilterPtr ret = NULL;
+
+ if ((!VIR_IS_CONNECT(conn)) || (name == NULL) || (uuid == NULL)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ return(NULL);
+ }
+ virMutexLock(&conn->lock);
+
+ /* TODO search by UUID first as they are better differenciators */
+
+ ret = (virNWFilterPtr) virHashLookup(conn->nwfilterPools, name);
+ /* TODO check the UUID */
+ if (ret == NULL) {
+ if (VIR_ALLOC(ret) < 0) {
+ virMutexUnlock(&conn->lock);
+ virReportOOMError();
+ goto error;
+ }
+ ret->name = strdup(name);
+ if (ret->name == NULL) {
+ virMutexUnlock(&conn->lock);
+ virReportOOMError();
+ goto error;
+ }
+ ret->magic = VIR_NWFILTER_MAGIC;
+ ret->conn = conn;
+ if (uuid != NULL)
+ memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
+
+ if (virHashAddEntry(conn->nwfilterPools, name, ret) < 0) {
+ virMutexUnlock(&conn->lock);
+ virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("failed to add network filter pool
to connection hash table"));
+ goto error;
+ }
+ conn->refs++;
+ }
+ ret->refs++;
+ virMutexUnlock(&conn->lock);
+ return(ret);
+
+error:
+ if (ret != NULL) {
+ VIR_FREE(ret->name);
+ VIR_FREE(ret);
+ }
+ return(NULL);
+}
+
+
+/**
+ * virReleaseNWFilterPool:
+ * @pool: the pool to release
+ *
+ * Unconditionally release all memory associated with a pool.
+ * The conn.lock mutex must be held prior to calling this, and will
+ * be released prior to this returning. The pool obj must not
+ * be used once this method returns.
+ *
+ * It will also unreference the associated connection object,
+ * which may also be released if its ref count hits zero.
+ */
+static void
+virReleaseNWFilterPool(virNWFilterPtr pool) {
+ virConnectPtr conn = pool->conn;
+ DEBUG("release pool %p %s", pool, pool->name);
+
+ /* TODO search by UUID first as they are better differenciators */
+ if (virHashRemoveEntry(conn->nwfilterPools, pool->name, NULL) < 0)
{
+ virMutexUnlock(&conn->lock);
+ virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("pool missing from connection hash
table"));
+ conn = NULL;
+ }
+
+ pool->magic = -1;
+ VIR_FREE(pool->name);
+ VIR_FREE(pool);
+
+ if (conn) {
+ DEBUG("unref connection %p %d", conn, conn->refs);
+ conn->refs--;
+ if (conn->refs == 0) {
+ virReleaseConnect(conn);
+ /* Already unlocked mutex */
+ return;
+ }
+ virMutexUnlock(&conn->lock);
+ }
+}
+
+
+/**
+ * virUnrefNWFilter:
+ * @pool: the nwfilter to unreference
+ *
+ * Unreference the networkf itler. If the use count drops to zero, the
+ * structure is actually freed.
+ *
+ * Returns the reference count or -1 in case of failure.
+ */
+int
+virUnrefNWFilter(virNWFilterPtr pool) {
+ int refs;
+
+ if (!VIR_IS_CONNECTED_NWFILTER(pool)) {
+ virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ return(-1);
+ }
+ virMutexLock(&pool->conn->lock);
+ DEBUG("unref pool %p %s %d", pool, pool->name, pool->refs);
+ pool->refs--;
+ refs = pool->refs;
+ if (refs == 0) {
+ virReleaseNWFilterPool(pool);
+ /* Already unlocked mutex */
+ return (0);
+ }
+
+ virMutexUnlock(&pool->conn->lock);
+ return (refs);
+}
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -0,0 +1,1313 @@
+/*
+ * nwfilter_ebiptables_driver.c: driver for ebtables/iptables on tap
devices
+ *
+ * Copyright (C) 2010 IBM Corp.
+ * Copyright (C) 2010 Stefan Berger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Stefan Berger <stefanb(a)us.ibm.com>
+ */
+
+#include <config.h>
+
+#include <stdint.h>
+#include <sys/stat.h>
+
+#include "internal.h"
+
+#include "buf.h"
+#include "memory.h"
+#include "logging.h"
+#include "datatypes.h"
+#include "virterror_internal.h"
+#include "domain_conf.h"
+#include "nwfilter_conf.h"
+#include "nwfilter_driver.h"
+#include "nwfilter_gentech_driver.h"
+#include "nwfilter_ebiptables_driver.h"
+
+#define VIR_FROM_THIS VIR_FROM_NWFILTER
+
+
+
+#define EBTABLES_DEFAULT_TABLE "nat"
+#define EBTABLES_CHAIN_INCOMING "PREROUTING"
+#define EBTABLES_CHAIN_OUTGOING "POSTROUTING"
+
+#define CHAINPREFIX_HOST_IN 'I'
+#define CHAINPREFIX_HOST_OUT 'O'
+#define CHAINPREFIX_HOST_IN_TEMP 'J'
+#define CHAINPREFIX_HOST_OUT_TEMP 'P'
+
+
+#define CMD_SEPARATOR "\n"
+#define CMD_DEF_PRE "cmd=\""
+#define CMD_DEF_POST "\""
+#define CMD_DEF(X) CMD_DEF_PRE X CMD_DEF_POST
+#define CMD_EXEC "res=`${cmd}`" CMD_SEPARATOR
+#define CMD_STOPONERR(X) \
+ X ? "if [ $? -ne 0 ]; then" \
+ " echo \"Failure to execute command '${cmd}'.\";" \
+ " exit 1;" \
+ "fi" CMD_SEPARATOR \
+ : ""
+
+
+#define EBTABLES_CMD EBTABLES_PATH
+#define BASH_CMD BASH_PATH
+
+#define PRINT_ROOT_CHAIN(buf, prefix, ifname) \
+ snprintf(buf, sizeof(buf), "%c-%s", prefix, ifname)
+#define PRINT_CHAIN(buf, prefix, ifname, suffix) \
+ snprintf(buf, sizeof(buf), "%c-%s-%s", prefix, ifname, suffix)
+
+
+static const char *supported_protocols[] = {
+ "ipv4",
+ "arp",
+ NULL,
+};
+
+
+static int
+printVar(virConnectPtr conn,
+ virNWFilterHashTablePtr vars,
+ char *buf, int bufsize,
+ nwItemDescPtr item,
+ int *done)
+{
+ *done = 0;
+
+ if ((item->flags & NWFILTER_ENTRY_ITEM_FLAG_HAS_VAR)) {
+ char *val = (char *)virHashLookup(vars->hashTable, item->var);
+ if (!val) {
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("cannot find value for '%s'"),
+ item->var);
+ return 1;
+ }
+
+ if (!virStrcpy(buf, val, bufsize)) {
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("Buffer to small to print MAC
address "
+ "'%s' into"),
+ item->var);
+ return 1;
+ }
+
+ *done = 1;
+ }
+ return 0;
+}
+
+
+static int
+printDataType(virConnectPtr conn,
+ virNWFilterHashTablePtr vars,
+ char *buf, int bufsize,
+ nwItemDescPtr item)
+{
+ int done;
+ if (printVar(conn, vars, buf, bufsize, item, &done))
+ return 1;
+
+ if (done)
+ return 0;
+
+ switch (item->datatype) {
+ case DATATYPE_IPADDR:
+ if (snprintf(buf, bufsize, "%d.%d.%d.%d",
+ item->u.ipaddr.addr.ipv4Addr[0],
+ item->u.ipaddr.addr.ipv4Addr[1],
+ item->u.ipaddr.addr.ipv4Addr[2],
+ item->u.ipaddr.addr.ipv4Addr[3]) >= bufsize) {
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("Buffer too small for IP
address"));
+ return 1;
+ }
+ break;
+
+ case DATATYPE_MACADDR:
+ if (bufsize < VIR_MAC_STRING_BUFLEN) {
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("Buffer too small for MAC
address"));
+ return 1;
+ }
+
+ virFormatMacAddr(item->u.macaddr.addr, buf);
+ break;
+
+ case DATATYPE_UINT16:
+ if (snprintf(buf, bufsize, "%d",
+ item->u.u16) >= bufsize) {
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("Buffer too small for port
number"));
+ return 1;
+ }
+ break;
+ default:
+ virNWFilterReportError(conn, VIR_ERR_INVALID_NWFILTER,
+ _("Unhandled datatype"));
+ return 1;
+ break;
+ }
+
+ return 0;
+}
+
+
+static void
+ebiptablesRuleInstFree(ebiptablesRuleInstPtr inst)
+{
+ if (!inst)
+ return;
+
+ VIR_FREE(inst->commandTemplate);
+ VIR_FREE(inst);
+}
+
+
+static int
+ebiptablesAddRuleInst(virConnectPtr conn,
+ virNWFilterRuleInstPtr res,
+ char *commandTemplate,
+ enum virNWFilterChainSuffixType neededChain,
+ char chainprefix,
+ unsigned int priority)
+{
+ ebiptablesRuleInstPtr inst;
+
+ if (VIR_ALLOC(inst) < 0) {
+ virReportOOMError();
+ return 1;
+ }
+
+ inst->commandTemplate = commandTemplate;
+ inst->neededProtocolChain = neededChain;
+ inst->chainprefix = chainprefix;
+ inst->priority = priority;
+
+ return virNWFilterRuleInstAddData(conn, res, inst);
+}
+
+/*
+ * ebtablesCreateRuleInstance:
+ * @conn : Pointer to a virConnect object
+ * @chainPrefix : The prefix to put in front of the name of the chain
+ * @nwfilter : The filter
+ * @rule: The rule of the filter to convert
+ * @ifname : The name of the interface to apply the rule to
+ * @vars : A map containing the variables to resolve
+ * @res : The data structure to store the result(s) into
+ *
+ * Convert a single rule into its representation for later
instantiation
+ *
+ * Returns 0 in case of success with the result stored in the data
structure
+ * pointed to by res, != 0 otherwise with the error message stored in
the
+ * virConnect object.
+ */
+static int
+ebtablesCreateRuleInstance(virConnectPtr conn,
+ char chainPrefix,
+ virNWFilterDefPtr nwfilter,
+ virNWFilterRuleDefPtr rule,
+ const char *ifname,
+ virNWFilterHashTablePtr vars,
+ virNWFilterRuleInstPtr res)
+{
+ char macaddr[VIR_MAC_STRING_BUFLEN],
+ ipaddr[INET_ADDRSTRLEN],
+ portstr[20];
+ char chain[MAX_CHAINNAME_LENGTH];
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (nwfilter->chainsuffix == VIR_NWFILTER_CHAINSUFFIX_ROOT)
+ PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
+ else
+ PRINT_CHAIN(chain, chainPrefix, ifname,
+
virNWFilterChainSuffixTypeToString(nwfilter->chainsuffix));
+
+
+ switch (rule->prtclType) {
+ case VIR_NWFILTER_RULE_PROTOCOL_MAC:
+
+ virBufferVSprintf(&buf,
+ CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%
s",
+ EBTABLES_DEFAULT_TABLE, chain);
+
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataProtocolID)) {
+ virBufferVSprintf(&buf,
+ " -p %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.ethHdrFilter.dataProtocolID),
+ rule->p.ethHdrFilter.dataProtocolID.u.u16);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataSrcMACAddr)) {
+ if (printDataType(conn,
+ vars,
+ macaddr, sizeof(macaddr),
+ &rule->p.ethHdrFilter.dataSrcMACAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " -s %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.ethHdrFilter.dataSrcMACAddr),
+ macaddr);
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataSrcMACMask)) {
+ if (printDataType(conn,
+ vars,
+ macaddr, sizeof(macaddr),
+
&rule->p.ethHdrFilter.dataSrcMACMask))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ "/%s",
+ macaddr);
+ }
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataDstMACAddr)) {
+ if (printDataType(conn,
+ vars,
+ macaddr, sizeof(macaddr),
+ &rule->p.ethHdrFilter.dataDstMACAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " -d %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.ethHdrFilter.dataDstMACAddr),
+ macaddr);
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataDstMACMask)) {
+ if (printDataType(conn,
+ vars,
+ macaddr, sizeof(macaddr),
+
&rule->p.ethHdrFilter.dataDstMACMask))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ "/%s",
+ macaddr);
+ }
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataPriority)) {
+ virBufferVSprintf(&buf,
+ " --vlan-prio %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.ethHdrFilter.dataPriority),
+ rule->p.ethHdrFilter.dataPriority.u.u8);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ethHdrFilter.dataVLANID)) {
+ virBufferVSprintf(&buf,
+ " --vlan-id %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.ethHdrFilter.dataVLANID),
+ rule->p.ethHdrFilter.dataVLANID.u.u16);
+ }
+ break;
+
+ case VIR_NWFILTER_RULE_PROTOCOL_ARP:
+
+ virBufferVSprintf(&buf,
+ CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%
s",
+ EBTABLES_DEFAULT_TABLE, chain);
+
+ virBufferAddLit(&buf, " -p arp");
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataHWType)) {
+ virBufferVSprintf(&buf,
+ " --arp-htype %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataHWType),
+ rule->p.arpHdrFilter.dataHWType.u.u16);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataOpcode)) {
+ virBufferVSprintf(&buf,
+ " --arp-opcode %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataOpcode),
+ rule->p.arpHdrFilter.dataOpcode.u.u16);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataProtocolType)) {
+ virBufferVSprintf(&buf,
+ " --arp-ptype %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataProtocolType),
+ rule->p.arpHdrFilter.dataProtocolType.u.u16);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataSrcIPAddr)) {
+ if (printDataType(conn,
+ vars,
+ ipaddr, sizeof(ipaddr),
+ &rule->p.arpHdrFilter.dataSrcIPAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --arp-ip-src %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataSrcIPAddr),
+ ipaddr);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataDstIPAddr)) {
+ if (printDataType(conn,
+ vars,
+ ipaddr, sizeof(ipaddr),
+ &rule->p.arpHdrFilter.dataDstIPAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --arp-ip-dst %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataDstIPAddr),
+ ipaddr);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataSrcMACAddr)) {
+ if (printDataType(conn,
+ vars,
+ macaddr, sizeof(macaddr),
+ &rule->p.arpHdrFilter.dataSrcMACAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --arp-mac-src %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataSrcMACAddr),
+ macaddr);
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.arpHdrFilter.dataDstMACAddr)) {
+ if (printDataType(conn,
+ vars,
+ macaddr, sizeof(macaddr),
+ &rule->p.arpHdrFilter.dataDstMACAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --arp-mac-dst %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.arpHdrFilter.dataDstMACAddr),
+ macaddr);
+ }
+ break;
+
+ case VIR_NWFILTER_RULE_PROTOCOL_IP:
+ virBufferVSprintf(&buf,
+ CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%
s",
+ EBTABLES_DEFAULT_TABLE, chain);
+
+ // FIXME -- may not be necessary if rule is in IPv4 user
defined
+ // table...
+ virBufferAddLit(&buf,
+ " -p ipv4");
+
+ if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataSrcAddr)) {
+ if (printDataType(conn,
+ vars,
+ ipaddr, sizeof(ipaddr),
+ &rule->p.ipHdrFilter.ipHdr.dataSrcAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --ip-source %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.ipHdrFilter.ipHdr.dataSrcAddr),
+ ipaddr);
+
+ if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataSrcMask))
{
+ virBufferVSprintf(&buf,
+ "/%d",
+
rule->p.ipHdrFilter.ipHdr.dataSrcMask.u.u8);
+ }
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataDstAddr)) {
+
+ if (printDataType(conn,
+ vars,
+ ipaddr, sizeof(ipaddr),
+ &rule->p.ipHdrFilter.ipHdr.dataDstAddr))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --ip-destination %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.ipHdrFilter.ipHdr.dataDstAddr),
+ ipaddr);
+
+ if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataDstMask))
{
+ virBufferVSprintf(&buf,
+ "/%d",
+
rule->p.ipHdrFilter.ipHdr.dataDstMask.u.u8);
+ }
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.ipHdr.dataProtocolID))
{
+ virBufferVSprintf(&buf,
+ " --ip-protocol %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.ipHdrFilter.ipHdr.dataProtocolID),
+
rule->p.ipHdrFilter.ipHdr.dataProtocolID.u.u16);
+ }
+
+ if
(HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataSrcPortStart)) {
+
+ if (printDataType(conn,
+ vars,
+ portstr, sizeof(portstr),
+
&rule->p.ipHdrFilter.portData.dataSrcPortStart))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --ip-source-port %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.ipHdrFilter.portData.dataSrcPortStart),
+ portstr);
+
+ if
(HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataSrcPortEnd)) {
+ if (printDataType(conn,
+ vars,
+ portstr, sizeof(portstr),
+
&rule->p.ipHdrFilter.portData.dataSrcPortEnd))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ ":%s",
+ portstr);
+ }
+ }
+
+ if
(HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataDstPortStart)) {
+
+ if (printDataType(conn,
+ vars,
+ portstr, sizeof(portstr),
+
&rule->p.ipHdrFilter.portData.dataDstPortStart))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ " --ip-destination-port %s %s",
+
ENTRY_GET_NEG_SIGN(&rule->p.ipHdrFilter.portData.dataDstPortStart),
+ portstr);
+
+ if
(HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.portData.dataDstPortEnd)) {
+ if (printDataType(conn,
+ vars,
+ portstr, sizeof(portstr),
+
&rule->p.ipHdrFilter.portData.dataDstPortEnd))
+ goto err_exit;
+
+ virBufferVSprintf(&buf,
+ ":%s",
+ portstr);
+ }
+ }
+
+ if (HAS_ENTRY_ITEM(&rule->p.ipHdrFilter.dataDSCP)) {
+ virBufferVSprintf(&buf,
+ " --ip-tos %s %d",
+
ENTRY_GET_NEG_SIGN(&rule->p.ipHdrFilter.dataDSCP),
+ rule->p.ipHdrFilter.dataDSCP.u.u8);
+ }
+ break;
+
+ case VIR_NWFILTER_RULE_PROTOCOL_NONE:
+ virBufferVSprintf(&buf,
+ CMD_DEF_PRE EBTABLES_CMD " -t %s -%%c %s %%
s",
+ EBTABLES_DEFAULT_TABLE, chain);
+ break;
+ }
+
+ virBufferVSprintf(&buf,
+ " -j %s" CMD_DEF_POST CMD_SEPARATOR
+ CMD_EXEC,
+ virNWFilterJumpTargetTypeToString(rule->action));
+
+ if (virBufferError(&buf)) {
+ virBufferFreeAndReset(&buf);
+ virReportOOMError();
+ return -1;
+ }
+
+ return ebiptablesAddRuleInst(conn,
+ res,
+ virBufferContentAndReset(&buf),
+ nwfilter->chainsuffix,
+ chainPrefix,
+ rule->priority);
+
+err_exit:
+ virBufferFreeAndReset(&buf);
+
+ return -1;
+}
+
+
+/*
+ * ebiptablesCreateRuleInstance:
+ * @conn : Pointer to a virConnect object
+ * @nwfilter : The filter
+ * @rule: The rule of the filter to convert
+ * @ifname : The name of the interface to apply the rule to
+ * @vars : A map containing the variables to resolve
+ * @res : The data structure to store the result(s) into
+ *
+ * Convert a single rule into its representation for later
instantiation
+ *
+ * Returns 0 in case of success with the result stored in the data
structure
+ * pointed to by res, != 0 otherwise with the error message stored in
the
+ * virConnect object.
+ */
+static int
+ebiptablesCreateRuleInstance(virConnectPtr conn,
+ enum virDomainNetType nettype
ATTRIBUTE_UNUSED,
+ virNWFilterDefPtr nwfilter,
+ virNWFilterRuleDefPtr rule,
+ const char *ifname,
+ virNWFilterHashTablePtr vars,
+ virNWFilterRuleInstPtr res)
+{
+ int rc = 0;
+
+ switch (rule->prtclType) {
+ case VIR_NWFILTER_RULE_PROTOCOL_IP:
+ case VIR_NWFILTER_RULE_PROTOCOL_MAC:
+ case VIR_NWFILTER_RULE_PROTOCOL_ARP:
+ case VIR_NWFILTER_RULE_PROTOCOL_NONE:
+
+ if (rule->tt == VIR_NWFILTER_RULE_DIRECTION_OUT ||
+ rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT) {
+ rc = ebtablesCreateRuleInstance(conn,
+ CHAINPREFIX_HOST_IN_TEMP,
+ nwfilter,
+ rule,
+ ifname,
+ vars,
+ res);
+ if (rc)
+ return rc;
+ }
+
+ if (rule->tt == VIR_NWFILTER_RULE_DIRECTION_IN ||
+ rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT) {
+ rc = ebtablesCreateRuleInstance(conn,
+ CHAINPREFIX_HOST_OUT_TEMP,
+ nwfilter,
+ rule,
+ ifname,
+ vars,
+ res);
+ }
+ break;
+ }
+
+ return rc;
+}
+
+
+static int
+ebiptablesFreeRuleInstance(void *_inst)
+{
+ ebiptablesRuleInstFree((ebiptablesRuleInstPtr)_inst);
+ return 0;
+}
+
+
+static int
+ebiptablesDisplayRuleInstance(virConnectPtr conn ATTRIBUTE_UNUSED,
+ void *_inst)
+{
+ ebiptablesRuleInstPtr inst = (ebiptablesRuleInstPtr)_inst;
+ printf("Command Template: %s\nNeeded protocol: %s\n\n",
+ inst->commandTemplate,
+
virNWFilterChainSuffixTypeToString(inst->neededProtocolChain));
+ return 0;
+}
+
+
+/**
+ * ebiptablesWriteToTempFile:
+ * @conn: pointer to virConnect object
+ * @string : the string to write into the file
+ *
+ * Returns the tempory filename where the string was written into,
+ * NULL in case of error with the error reported.
+ *
+ * Write the string into a temporary file and return the name of
+ * the temporary file. The string is assumed to contain executable
+ * commands. A line '#!/bin/bash' will automatically be written
+ * as the first line in the file. The permissions of the file are
+ * set so that the file can be run as an executable script.
+ */
+static char *
+ebiptablesWriteToTempFile(virConnectPtr conn,
+ const char *string) {
+ char filename[] = "/tmp/virtdXXXXXX";
+ int len;
+ char *filnam;
+ const char header[] = "#!" BASH_CMD "\n";
+ size_t written;
+
+ int fd = mkstemp(filename);
+
+ if (fd < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("cannot create temporary file"));
+ return NULL;
+ }
+
+ if (fchmod(fd, S_IXUSR| S_IRUSR | S_IWUSR) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("cannot change permissions on temp.
file"));
+ goto err_exit;
+ }
+
+ len = strlen(header);
+ written = safewrite(fd, header, len);
+ if (written != len) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("cannot write string to file"));
+ goto err_exit;
+ }
+
+ len = strlen(string);
+ written = safewrite(fd, string, len);
+ if (written != len) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s",
+ _("cannot write string to file"));
+ goto err_exit;
+ }
+
+ filnam = strdup(filename);
+ if (!filnam) {
+ virReportOOMError();
+ goto err_exit;
+ }
+
+ close(fd);
+ return filnam;
+
+err_exit:
+ close(fd);
+ unlink(filename);
+ return NULL;
+}
+
+
+/**
+ * ebiptablesExecCLI:
+ * @conn : pointer to virConnect object
+ * @buf : pointer to virBuffer containing the string with the commands
to
+ * execute.
+ * @status: Pointer to an integer for returning the status of the
+ * commands executed via the script the was run.
+ *
+ * Returns 0 in case of success, != 0 in case of an error. The returned
+ * value is NOT the result of running the commands inside the bash
+ * script.
+ *
+ * Execute a sequence of commands (held in the given buffer) as a bash
+ * script and return the status of the execution.
+ */
+static int
+ebiptablesExecCLI(virConnectPtr conn,
+ virBufferPtr buf,
+ int *status)
+{
+ char *cmds;
+ char *filename;
+ int rc;
+ const char *argv[] = {NULL, NULL};
+
+ if (virBufferError(buf)) {
+ virReportOOMError();
+ virBufferFreeAndReset(buf);
+ return 1;
+ }
+
+ *status = 0;
+
+ cmds = virBufferContentAndReset(buf);
+
+ VIR_DEBUG("%s", cmds);
+
+ if (!cmds)
+ return 0;
+
+ filename = ebiptablesWriteToTempFile(conn, cmds);
+ VIR_FREE(cmds);
+
+ if (!filename)
+ return 1;
+
+ argv[0] = filename;
+ rc = virRun(argv, status);
+
+ *status >>= 8;
+
+ VIR_DEBUG("rc = %d, status = %d\n",rc, *status);
+
+ unlink(filename);
+
+ VIR_FREE(filename);
+
+ return rc;
+}
+
+
+static int
+ebtablesCreateTmpRootChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming, const char *ifname,
+ int stopOnError)
+{
+ char chain[MAX_CHAINNAME_LENGTH];
+ char chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+
+ PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
+
+ virBufferVSprintf(buf,
+ CMD_DEF(EBTABLES_CMD " -t %s -N %s")
CMD_SEPARATOR
+ CMD_EXEC
+ "%s",
+ EBTABLES_DEFAULT_TABLE, chain,
+ CMD_STOPONERR(stopOnError));
+
+ return 0;
+}
+
+
+static int
+ebtablesLinkTmpRootChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming, const char *ifname,
+ int stopOnError)
+{
+ char chain[MAX_CHAINNAME_LENGTH];
+ char chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+ char iodev = (incoming) ? 'i' : 'o';
+
+ PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
+
+ virBufferVSprintf(buf,
+ CMD_DEF(EBTABLES_CMD " -t %s -A %s -%c %s -j %s")
CMD_SEPARATOR
+ CMD_EXEC
+ "%s",
+ EBTABLES_DEFAULT_TABLE,
+ (incoming) ? EBTABLES_CHAIN_INCOMING
+ : EBTABLES_CHAIN_OUTGOING,
+ iodev, ifname, chain,
+
+ CMD_STOPONERR(stopOnError));
+
+ return 0;
+}
+
+
+static int
+_ebtablesRemoveRootChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming, const char *ifname,
+ int isTempChain)
+{
+ char chain[MAX_CHAINNAME_LENGTH];
+ char chainPrefix;
+ if (isTempChain)
+ chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+ else
+ chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN
+ : CHAINPREFIX_HOST_OUT;
+
+ PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
+
+ virBufferVSprintf(buf,
+ EBTABLES_CMD " -t %s -F %s" CMD_SEPARATOR
+ EBTABLES_CMD " -t %s -X %s" CMD_SEPARATOR,
+ EBTABLES_DEFAULT_TABLE, chain,
+ EBTABLES_DEFAULT_TABLE, chain);
+
+ return 0;
+}
+
+
+static int
+ebtablesRemoveRootChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming, const char *ifname)
+{
+ return _ebtablesRemoveRootChain(conn, buf, incoming, ifname, 0);
+}
+
+
+static int
+ebtablesRemoveTmpRootChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming, const char *ifname)
+{
+ return _ebtablesRemoveRootChain(conn, buf, incoming, ifname, 1);
+}
+
+
+static int
+_ebtablesUnlinkRootChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming, const char *ifname,
+ int isTempChain)
+{
+ char chain[MAX_CHAINNAME_LENGTH];
+ char iodev = (incoming) ? 'i' : 'o';
+ char chainPrefix;
+
+ if (isTempChain) {
+ chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+ } else {
+ chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN
+ : CHAINPREFIX_HOST_OUT;
+ }
+
+ PRINT_ROOT_CHAIN(chain, chainPrefix, ifname);
+
+ virBufferVSprintf(buf,
+ EBTABLES_CMD " -t %s -D %s -%c %s -j %s"
CMD_SEPARATOR,
+ EBTABLES_DEFAULT_TABLE,
+ (incoming) ? EBTABLES_CHAIN_INCOMING
+ : EBTABLES_CHAIN_OUTGOING,
+ iodev, ifname, chain);
+
+ return 0;
+}
+
+
+static int
+ebtablesUnlinkRootChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming, const char *ifname)
+{
+ return _ebtablesUnlinkRootChain(conn, buf, incoming, ifname, 0);
+}
+
+
+static int
+ebtablesUnlinkTmpRootChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming, const char *ifname)
+{
+ return _ebtablesUnlinkRootChain(conn, buf, incoming, ifname, 1);
+}
+
+
+static int
+ebtablesCreateTmpSubChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming,
+ const char *ifname,
+ const char *protocol,
+ int stopOnError)
+{
+ char rootchain[MAX_CHAINNAME_LENGTH], chain[MAX_CHAINNAME_LENGTH];
+ char chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+
+ PRINT_ROOT_CHAIN(rootchain, chainPrefix, ifname);
+ PRINT_CHAIN(chain, chainPrefix, ifname, protocol);
+
+ virBufferVSprintf(buf,
+ CMD_DEF(EBTABLES_CMD " -t %s -N %s")
CMD_SEPARATOR
+ CMD_EXEC
+ "%s"
+ CMD_DEF(EBTABLES_CMD " -t %s -A %s -p %s -j %s")
CMD_SEPARATOR
+ CMD_EXEC
+ "%s",
+
+ EBTABLES_DEFAULT_TABLE, chain,
+
+ CMD_STOPONERR(stopOnError),
+
+ EBTABLES_DEFAULT_TABLE,
+ rootchain,
+ protocol, chain,
+
+ CMD_STOPONERR(stopOnError));
+
+ return 0;
+}
+
+
+static int
+_ebtablesRemoveSubChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming,
+ const char *ifname,
+ const char *protocol,
+ int isTempChain)
+{
+ char rootchain[MAX_CHAINNAME_LENGTH], chain[MAX_CHAINNAME_LENGTH];
+ char chainPrefix;
+ if (isTempChain) {
+ chainPrefix =(incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+ } else {
+ chainPrefix =(incoming) ? CHAINPREFIX_HOST_IN
+ : CHAINPREFIX_HOST_OUT;
+ }
+
+ PRINT_ROOT_CHAIN(rootchain, chainPrefix, ifname);
+ PRINT_CHAIN(chain, chainPrefix, ifname, protocol);
+
+ virBufferVSprintf(buf,
+ EBTABLES_CMD " -t %s -D %s -p %s -j %s"
CMD_SEPARATOR
+ EBTABLES_CMD " -t %s -F %s" CMD_SEPARATOR
+ EBTABLES_CMD " -t %s -X %s" CMD_SEPARATOR,
+ EBTABLES_DEFAULT_TABLE,
+ rootchain,
+ protocol, chain,
+
+ EBTABLES_DEFAULT_TABLE, chain,
+
+ EBTABLES_DEFAULT_TABLE, chain);
+
+ return 0;
+}
+
+
+static int
+ebtablesRemoveSubChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming,
+ const char *ifname,
+ const char *protocol)
+{
+ return _ebtablesRemoveSubChain(conn, buf,
+ incoming, ifname, protocol, 0);
+}
+
+
+static int
+ebtablesRemoveSubChains(virConnectPtr conn,
+ virBufferPtr buf,
+ const char *ifname)
+{
+ int i;
+ for (i = 0; supported_protocols[i]; i++) {
+ ebtablesRemoveSubChain(conn, buf, 1, ifname,
supported_protocols[i]);
+ ebtablesRemoveSubChain(conn, buf, 0, ifname,
supported_protocols[i]);
+ }
+
+ return 0;
+}
+
+
+static int
+ebtablesRemoveTmpSubChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming,
+ const char *ifname,
+ const char *protocol)
+{
+ return _ebtablesRemoveSubChain(conn, buf,
+ incoming, ifname, protocol, 1);
+}
+
+
+static int
+ebtablesRemoveTmpSubChains(virConnectPtr conn,
+ virBufferPtr buf,
+ const char *ifname)
+{
+ int i;
+ for (i = 0; supported_protocols[i]; i++) {
+ ebtablesRemoveTmpSubChain(conn, buf, 1, ifname,
+ supported_protocols[i]);
+ ebtablesRemoveTmpSubChain(conn, buf, 0, ifname,
+ supported_protocols[i]);
+ }
+
+ return 0;
+}
+
+
+static int
+ebtablesRenameTmpSubChain(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ int incoming,
+ const char *ifname,
+ const char *protocol)
+{
+ char tmpchain[MAX_CHAINNAME_LENGTH], chain[MAX_CHAINNAME_LENGTH];
+ char tmpChainPrefix = (incoming) ? CHAINPREFIX_HOST_IN_TEMP
+ : CHAINPREFIX_HOST_OUT_TEMP;
+ char chainPrefix = (incoming) ? CHAINPREFIX_HOST_IN
+ : CHAINPREFIX_HOST_OUT;
+
+ if (protocol) {
+ PRINT_CHAIN(tmpchain, tmpChainPrefix, ifname, protocol);
+ PRINT_CHAIN( chain, chainPrefix, ifname, protocol);
+ } else {
+ PRINT_ROOT_CHAIN(tmpchain, tmpChainPrefix, ifname);
+ PRINT_ROOT_CHAIN( chain, chainPrefix, ifname);
+ }
+
+ virBufferVSprintf(buf,
+ EBTABLES_CMD " -t %s -E %s %s" CMD_SEPARATOR,
+ EBTABLES_DEFAULT_TABLE,
+ tmpchain,
+ chain);
+ return 0;
+}
+
+
+static int
+ebtablesRenameTmpSubChains(virConnectPtr conn,
+ virBufferPtr buf,
+ const char *ifname)
+{
+ int i;
+ for (i = 0; supported_protocols[i]; i++) {
+ ebtablesRenameTmpSubChain (conn, buf, 1, ifname,
+ supported_protocols[i]);
+ ebtablesRenameTmpSubChain (conn, buf, 0, ifname,
+ supported_protocols[i]);
+ }
+
+ return 0;
+}
+
+
+static int
+ebtablesRenameTmpRootChain(virConnectPtr conn,
+ virBufferPtr buf,
+ int incoming,
+ const char *ifname)
+{
+ return ebtablesRenameTmpSubChain(conn, buf, incoming, ifname,
NULL);
+}
+
+
+static void
+ebiptablesInstCommand(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virBufferPtr buf,
+ const char *templ, char cmd, int pos,
+ int stopOnError)
+{
+ char position[10] = { 0 };
+ if (pos >= 0)
+ snprintf(position, sizeof(position), "%d", pos);
+ virBufferVSprintf(buf, templ, cmd, position);
+ virBufferVSprintf(buf, CMD_SEPARATOR "%s",
+ CMD_STOPONERR(stopOnError));
+}
+
+
+static int
+ebiptablesRuleOrderSort(const void *a, const void *b)
+{
+ const ebiptablesRuleInstPtr *insta = a;
+ const ebiptablesRuleInstPtr *instb = b;
+ return ((*insta)->priority - (*instb)->priority);
+}
+
+
+static int
+ebiptablesApplyRules(virConnectPtr conn,
+ const char *ifname,
+ int nruleInstances,
+ void **_inst)
+{
+ int i;
+ int cli_status;
+ ebiptablesRuleInstPtr *inst = (ebiptablesRuleInstPtr *)_inst;
+ int chains_in = 0, chains_out = 0;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ if (inst)
+ qsort(inst, nruleInstances, sizeof(inst[0]),
+ ebiptablesRuleOrderSort);
+
+ for (i = 0; i < nruleInstances; i++) {
+ if (inst[i]->chainprefix == CHAINPREFIX_HOST_IN_TEMP)
+ chains_in |= (1 << inst[i]->neededProtocolChain);
+ else
+ chains_out |= (1 << inst[i]->neededProtocolChain);
+ }
+
+ ebtablesUnlinkTmpRootChain(conn, &buf, 1, ifname);
+ ebtablesUnlinkTmpRootChain(conn, &buf, 0, ifname);
+ ebtablesRemoveTmpSubChains(conn, &buf, ifname);
+ ebtablesRemoveTmpRootChain(conn, &buf, 1, ifname);
+ ebtablesRemoveTmpRootChain(conn, &buf, 0, ifname);
+
+ if (chains_in != 0)
+ ebtablesCreateTmpRootChain(conn, &buf, 1, ifname, 1);
+ if (chains_out != 0)
+ ebtablesCreateTmpRootChain(conn, &buf, 0, ifname, 1);
+
+ if (chains_in & (1 << VIR_NWFILTER_CHAINSUFFIX_IPv4))
+ ebtablesCreateTmpSubChain(conn, &buf, 1, ifname, "ipv4", 1);
+ if (chains_out & (1 << VIR_NWFILTER_CHAINSUFFIX_IPv4))
+ ebtablesCreateTmpSubChain(conn, &buf, 0, ifname, "ipv4", 1);
+
+ // keep arp as last
+ if (chains_in & (1 << VIR_NWFILTER_CHAINSUFFIX_ARP))
+ ebtablesCreateTmpSubChain(conn, &buf, 1, ifname, "arp", 1);
+ if (chains_out & (1 << VIR_NWFILTER_CHAINSUFFIX_ARP))
+ ebtablesCreateTmpSubChain(conn, &buf, 0, ifname, "arp", 1);
+
+ if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ goto tear_down_tmpebchains;
+
+ for (i = 0; i < nruleInstances; i++)
+ ebiptablesInstCommand(conn, &buf,
+ inst[i]->commandTemplate,
+ 'A', -1, 1);
+
+ if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ goto tear_down_tmpebchains;
+
+ // FIXME: establishment of iptables user define table tree goes
here
+
+ // END IPTABLES stuff
+
+ if (chains_in != 0)
+ ebtablesLinkTmpRootChain(conn, &buf, 1, ifname, 1);
+ if (chains_out != 0)
+ ebtablesLinkTmpRootChain(conn, &buf, 0, ifname, 1);
+
+ if (ebiptablesExecCLI(conn, &buf, &cli_status) || cli_status != 0)
+ goto tear_down_ebsubchains_and_unlink;
+
+ ebtablesUnlinkRootChain(conn, &buf, 1, ifname);
+ ebtablesUnlinkRootChain(conn, &buf, 0, ifname);
+
+ ebtablesRemoveSubChains(conn, &buf, ifname);
+
+ ebtablesRemoveRootChain(conn, &buf, 1, ifname);
+ ebtablesRemoveRootChain(conn, &buf, 0, ifname);
+
+ ebtablesRenameTmpSubChains(conn, &buf, ifname);
+ ebtablesRenameTmpRootChain(conn, &buf, 1, ifname);
+ ebtablesRenameTmpRootChain(conn, &buf, 0, ifname);
+
+ ebiptablesExecCLI(conn, &buf, &cli_status);
+
+ return 0;
+
+tear_down_ebsubchains_and_unlink:
+ ebtablesUnlinkTmpRootChain(conn, &buf, 1, ifname);
+ ebtablesUnlinkTmpRootChain(conn, &buf, 0, ifname);
+
+tear_down_tmpebchains:
+ ebtablesRemoveTmpSubChains(conn, &buf, ifname);
+ ebtablesRemoveTmpRootChain(conn, &buf, 1, ifname);
+ ebtablesRemoveTmpRootChain(conn, &buf, 0, ifname);
+
+ ebiptablesExecCLI(conn, &buf, &cli_status);
+
+ virNWFilterReportError(conn, VIR_ERR_BUILD_FIREWALL,
+ "%s",
+ _("Some rules could not be created."));
+
+ return 1;
+}
+
+
+/**
+ * ebiptablesRemoveRules:
+ * @conn : pointer to virConnect object
+ * @ifname : the name of the interface to which the rules apply
+ * @nRuleInstance : the number of given rules
+ * @_inst : array of rule instantiation data
+ *
+ * Remove all rules one after the other
+ *
+ * Return 0 on success, 1 if execution of one or more cleanup
+ * commands failed.
+ */
+static int
+ebiptablesRemoveRules(virConnectPtr conn,
+ const char *ifname ATTRIBUTE_UNUSED,
+ int nruleInstances,
+ void **_inst)
+{
+ int rc = 0;
+ int cli_status;
+ int i;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ ebiptablesRuleInstPtr *inst = (ebiptablesRuleInstPtr *)_inst;
+
+ for (i = 0; i < nruleInstances; i++)
+ ebiptablesInstCommand(conn, &buf,
+ inst[i]->commandTemplate,
+ 'D', -1,
+ 0);
+
+ if (ebiptablesExecCLI(conn, &buf, &cli_status))
+ goto err_exit;
+
+ if (cli_status) {
+ virNWFilterReportError(conn, VIR_ERR_BUILD_FIREWALL,
+ "%s",
+ _("error while executing CLI
commands"));
+ rc = 1;
+ }
+
+err_exit:
+ return rc;
+}
+
+
+/**
+ * ebiptablesAllTeardown:
+ * @ifname : the name of the interface to which the rules apply
+ *
+ * Unconditionally remove all possible user defined tables and rules
+ * that were created for the given interface (ifname).
+ *
+ * Always returns 0.
+ */
+static int
+ebiptablesAllTeardown(const char *ifname)
+{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+ int cli_status;
+ virConnectPtr conn = NULL;
+
+ ebtablesUnlinkRootChain(conn, &buf, 1, ifname);
+ ebtablesUnlinkRootChain(conn, &buf, 0, ifname);
+
+ ebtablesRemoveRootChain(conn, &buf, 1, ifname);
+ ebtablesRemoveRootChain(conn, &buf, 0, ifname);
+
+ ebtablesRemoveSubChains(conn, &buf, ifname);
+
+ ebiptablesExecCLI(conn, &buf, &cli_status);
+
+ return 0;
+}
+
+
+virNWFilterTechDriver ebiptables_driver = {
+ .name = EBIPTABLES_DRIVER_ID,
+
+ .createRuleInstance = ebiptablesCreateRuleInstance,
+ .applyRules = ebiptablesApplyRules,
+ .allTeardown = ebiptablesAllTeardown,
+ .removeRules = ebiptablesRemoveRules,
+ .freeRuleInstance = ebiptablesFreeRuleInstance,
+ .displayRuleInstance = ebiptablesDisplayRuleInstance,
+};
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -0,0 +1,656 @@
+/*
+ * nwfilter_gentech_driver.c: generic technology driver
+ *
+ * Copyright (C) 2010 IBM Corp.
+ * Copyright (C) 2010 Stefan Berger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Stefan Berger <stefanb(a)us.ibm.com>
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+#include "config.h"
+
+#include "memory.h"
+#include "logging.h"
+#include "datatypes.h"
+#include "domain_conf.h"
+#include "nwfilter_conf.h"
+#include "virterror_internal.h"
+#include "nwfilter_gentech_driver.h"
+#include "nwfilter_ebiptables_driver.h"
+
+
+#define VIR_FROM_THIS VIR_FROM_NWFILTER
+
+
+#define NWFILTER_STD_VAR_MAC "MAC"
+
+
+static virNWFilterTechDriverPtr filter_tech_drivers[] = {
+ &ebiptables_driver,
+ NULL
+};
+
+
+virNWFilterTechDriverPtr
+virNWFilterTechDriverForName(const char *name) {
+ int i = 0;
+ while (filter_tech_drivers[i]) {
+ if (!strcmp(filter_tech_drivers[i]->name, name))
+ return filter_tech_drivers[i];
+ i++;
+ }
+ return NULL;
+}
+
+
+/**
+ * virNWFilterRuleInstAddData:
+ * @conn : pointer to virConnect object
+ * @res : pointer to virNWFilterRuleInst object collecting the
instantiation
+ * data of a single firewall rule.
+ * @data : the opaque data that the driver wants to add
+ *
+ * Add instantiation data to a firewall rule. An instantiated firewall
+ * rule may hold multiple data structure representing its instantiation
+ * data. This may for example be the case if a rule has been defined
+ * for bidirectional traffic and data needs to be added to the incoming
+ * and outgoing chains.
+ *
+ * Returns 0 in case of success, 1 in case of an error with the error
+ * message attached to the virConnect object.
+ */
+int
+virNWFilterRuleInstAddData(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virNWFilterRuleInstPtr res,
+ void *data)
+{
+ if (VIR_REALLOC_N(res->data, res->ndata+1) < 0) {
+ virReportOOMError();
+ return 1;
+ }
+ res->data[res->ndata++] = data;
+ return 0;
+}
+
+
+static void
+virNWFilterRuleInstFree(virNWFilterRuleInstPtr inst)
+{
+ int i;
+ if (!inst)
+ return;
+
+ for (i = 0; i < inst->ndata; i++)
+ inst->techdriver->freeRuleInstance(inst->data[i]);
+
+ VIR_FREE(inst->data);
+ VIR_FREE(inst);
+}
+
+
+/**
+ * virNWFilterVarHashmapAddStdValues:
+ * @conn: Poijter to virConnect object
+ * @tables: pointer to hash tabel to add values to
+ * @macaddr: The string of the MAC address to add to the hash table,
+ * may be NULL
+ *
+ * Returns 0 in case of success, 1 in case an error happened with
+ * error having been reported.
+ *
+ * Adds a couple of standard keys (MAC, IP) to the hash table.
+ */
+static int
+virNWFilterVarHashmapAddStdValues(virConnectPtr conn,
+ virNWFilterHashTablePtr table,
+ char *macaddr)
+{
+ if (macaddr) {
+ if (virHashAddEntry(table->hashTable,
+ NWFILTER_STD_VAR_MAC,
+ macaddr) < 0) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Could not add variable
'MAC' to hashmap"));
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+
+/**
+ * virNWFilterCreateVarHashmap:
+ * @conn: pointer to virConnect object
+ * @macaddr: pointer to string containing formatted MAC address of
interface
+ *
+ * Create a hashmap used for evaluating the firewall rules. Initializes
+ * it with the standard variable 'MAC'.
+ *
+ * Returns pointer to hashmap, NULL if an error occcurred and error
message
+ * is attached to the virConnect object.
+ */
+virNWFilterHashTablePtr
+virNWFilterCreateVarHashmap(virConnectPtr conn,
+ char *macaddr) {
+ virNWFilterHashTablePtr table = virNWFilterHashTableCreate(0);
+ if (!table) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ if (virNWFilterVarHashmapAddStdValues(conn, table, macaddr)) {
+ virNWFilterHashTableFree(table);
+ return NULL;
+ }
+ return table;
+}
+
+
+/**
+ * virNWFilterRuleInstantiate:
+ * @conn: pointer to virConnect object
+ * @techdriver: the driver to use for instantiation
+ * @filter: The filter the rule is part of
+ * @rule : The rule that is to be instantiated
+ * @ifname: The name of the interface
+ * @vars: map containing variable names and value used for
instantiation
+ *
+ * Returns virNWFilterRuleInst object on success, NULL on error with
+ * error reported.
+ *
+ * Instantiate a single rule. Return a pointer to virNWFilterRuleInst
+ * object that will hold an array of driver-specific data resulting
+ * from the instantiation. Returns NULL on error with error reported.
+ */
+static virNWFilterRuleInstPtr
+virNWFilterRuleInstantiate(virConnectPtr conn,
+ virNWFilterTechDriverPtr techdriver,
+ enum virDomainNetType nettype,
+ virNWFilterDefPtr filter,
+ virNWFilterRuleDefPtr rule,
+ const char *ifname,
+ virNWFilterHashTablePtr vars)
+{
+ int rc;
+ int i;
+ virNWFilterRuleInstPtr ret;
+
+ if (VIR_ALLOC(ret) < 0) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ ret->techdriver = techdriver;
+
+ rc = techdriver->createRuleInstance(conn, nettype, filter,
+ rule, ifname, vars, ret);
+
+ if (rc) {
+ for (i = 0; i < ret->ndata; i++)
+ techdriver->freeRuleInstance(ret->data[i]);
+ VIR_FREE(ret);
+ ret = NULL;
+ }
+
+ return ret;
+}
+
+
+/**
+ * virNWFilterCreateVarsFrom:
+ * @conn: pointer to virConnect object
+ * @vars1: pointer to hash table
+ * @vars2: pointer to hash table
+ *
+ * Returns pointer to new hashtable or NULL in case of error with
+ * error already reported.
+ *
+ * Creates a new hash table with contents of var1 and var2 added where
+ * contents of var2 will overwrite those of var1.
+ */
+static virNWFilterHashTablePtr
+virNWFilterCreateVarsFrom(virConnectPtr conn,
+ virNWFilterHashTablePtr vars1,
+ virNWFilterHashTablePtr vars2)
+{
+ virNWFilterHashTablePtr res = virNWFilterHashTableCreate(0);
+ if (!res) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ if (virNWFilterHashTablePutAll(conn, vars1, res))
+ goto err_exit;
+
+ if (virNWFilterHashTablePutAll(conn, vars2, res))
+ goto err_exit;
+
+ return res;
+
+err_exit:
+ virNWFilterHashTableFree(res);
+ return NULL;
+}
+
+
+/**
+ * _virNWFilterPoolInstantiateRec:
+ * @conn: pointer to virConnect object
+ * @techdriver: The driver to use for instantiation
+ * @filter: The filter to instantiate
+ * @ifname: The name of the interface to apply the rules to
+ * @vars: A map holding variable names and values used for
instantiating
+ * the filter and its subfilters.
+ * @nEntries: number of virNWFilterInst objects collected
+ * @insts: pointer to array for virNWFilterIns object pointers
+ * @useNewFilter: instruct whether to use a newDef pointer rather than
a
+ * def ptr which is useful during a filter update
+ * @foundNewFilter: pointer to int indivating whether a newDef pointer
was
+ * ever used; variable expected to be initialized to 0 by caller
+ *
+ * Returns 0 on success, a value otherwise.
+ *
+ * Recursively instantiate a filter by instantiating the given filter
along
+ * with all its subfilters in a depth-first traversal of the tree of
+ * referenced filters. The name of the interface to which the rules
belong
+ * must be provided. Apply the values of variables as needed. Terminate
with
+ * error when a referenced filter is missing or a variable could not be
+ * resolved -- among other reasons.
+ */
+static int
+_virNWFilterInstantiateRec(virConnectPtr conn,
+ virNWFilterTechDriverPtr techdriver,
+ enum virDomainNetType nettype,
+ virNWFilterDefPtr filter,
+ const char *ifname,
+ virNWFilterHashTablePtr vars,
+ int *nEntries,
+ virNWFilterRuleInstPtr **insts,
+ enum instCase useNewFilter, int
*foundNewFilter)
+{
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ virNWFilterPoolObjPtr obj;
+ int rc = 0;
+ int i;
+ virNWFilterRuleInstPtr inst;
+ virNWFilterDefPtr next_filter;
+
+ for (i = 0; i < filter->nentries; i++) {
+ virNWFilterRuleDefPtr rule = filter->filterEntries[i]->rule;
+ virNWFilterIncludeDefPtr inc =
filter->filterEntries[i]->include;
+ if (rule) {
+ inst = virNWFilterRuleInstantiate(conn,
+ techdriver,
+ nettype,
+ filter,
+ rule,
+ ifname,
+ vars);
+ if (!inst) {
+ rc = 1;
+ break;
+ }
+
+ if (VIR_REALLOC_N(*insts, (*nEntries)+1) < 0) {
+ virReportOOMError();
+ rc = 1;
+ break;
+ }
+
+ (*insts)[(*nEntries)++] = inst;
+
+ } else if (inc) {
+ VIR_DEBUG("Instantiating filter %s\n", inc->filterref);
+ obj = virNWFilterPoolObjFindByName(&driver->pools,
+ inc->filterref);
+ if (obj) {
+
+ if (obj->wantRemoved) {
+ virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ _("Filter '%s' is in use."),
+ inc->filterref);
+ rc = 1;
+ virNWFilterPoolObjUnlock(obj);
+ break;
+ }
+
+ // create a temporary hashmap for depth-first tree
traversal
+ virNWFilterHashTablePtr tmpvars =
+ virNWFilterCreateVarsFrom(conn,
+
inc->params,
+ vars);
+ if (!tmpvars) {
+ virReportOOMError();
+ rc = 1;
+ virNWFilterPoolObjUnlock(obj);
+ break;
+ }
+
+ next_filter = obj->def;
+
+ switch (useNewFilter) {
+ case INSTANTIATE_FOLLOW_NEWFILTER:
+ if (obj->newDef) {
+ next_filter = obj->newDef;
+ *foundNewFilter = 1;
+ }
+ break;
+ case INSTANTIATE_ROLLBACK_NEWFILTER:
+ if (obj->newDef)
+ *foundNewFilter = 1;
+ break;
+ case INSTANTIATE_ALWAYS:
+ break;
+ }
+
+ rc = _virNWFilterInstantiateRec(conn,
+ techdriver,
+ nettype,
+ next_filter,
+ ifname,
+ tmpvars,
+ nEntries, insts,
+ useNewFilter,
+ foundNewFilter);
+
+ virNWFilterHashTableFree(tmpvars);
+
+ virNWFilterPoolObjUnlock(obj);
+ if (rc)
+ break;
+ } else {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("referenced filter '%s' is
missing"),
+ inc->filterref);
+ rc = 1;
+ break;
+ }
+ }
+ }
+ return rc;
+}
+
+
+static int
+virNWFilterRuleInstancesToArray(int nEntries,
+ virNWFilterRuleInstPtr *insts,
+ void ***ptrs,
+ int *nptrs)
+{
+ int i,j;
+
+ *nptrs = 0;
+
+ for (j = 0; j < nEntries; j++)
+ (*nptrs) += insts[j]->ndata;
+
+ if ((*nptrs) == 0)
+ return 0;
+
+ if (VIR_ALLOC_N((*ptrs), (*nptrs)) < 0) {
+ virReportOOMError();
+ return 1;
+ }
+
+ (*nptrs) = 0;
+
+ for (j = 0; j < nEntries; j++)
+ for (i = 0; i < insts[j]->ndata; i++)
+ (*ptrs)[(*nptrs)++] = insts[j]->data[i];
+
+ return 0;
+}
+
+
+/**
+ * virNWFilterInstantiate:
+ * @conn: pointer to virConnect object
+ * @techdriver: The driver to use for instantiation
+ * @filter: The filter to instantiate
+ * @ifname: The name of the interface to apply the rules to
+ * @vars: A map holding variable names and values used for
instantiating
+ * the filter and its subfilters.
+ *
+ * Returns 0 on success, a value otherwise.
+ *
+ * Instantiate a filter by instantiating the filter itself along with
+ * all its subfilters in a depth-first traversal of the tree of
referenced
+ * filters. The name of the interface to which the rules belong must be
+ * provided. Apply the values of variables as needed.
+ */
+static int
+virNWFilterInstantiate(virConnectPtr conn,
+ virNWFilterTechDriverPtr techdriver,
+ enum virDomainNetType nettype,
+ virNWFilterDefPtr filter,
+ const char *ifname,
+ virNWFilterHashTablePtr vars,
+ enum instCase useNewFilter, int *foundNewFilter)
+{
+ int rc;
+ int j, nptrs;
+ int nEntries = 0;
+ virNWFilterRuleInstPtr *insts = NULL;
+ void **ptrs = NULL;
+ int instantiate = 1;
+
+ rc = _virNWFilterInstantiateRec(conn,
+ techdriver,
+ nettype,
+ filter,
+ ifname,
+ vars,
+ &nEntries, &insts,
+ useNewFilter, foundNewFilter);
+
+ if (rc)
+ goto err_exit;
+
+ switch (useNewFilter) {
+ case INSTANTIATE_ROLLBACK_NEWFILTER:
+ case INSTANTIATE_FOLLOW_NEWFILTER:
+ instantiate = *foundNewFilter;
+ break;
+ case INSTANTIATE_ALWAYS:
+ instantiate = 1;
+ break;
+ }
+
+ if (instantiate) {
+
+ rc = virNWFilterRuleInstancesToArray(nEntries, insts,
+ &ptrs, &nptrs);
+ if (rc)
+ goto err_exit;
+
+ rc = techdriver->applyRules(conn, ifname, nptrs, ptrs);
+
+ VIR_FREE(ptrs);
+ }
+
+err_exit:
+
+ for (j = 0; j < nEntries; j++)
+ virNWFilterRuleInstFree(insts[j]);
+
+ VIR_FREE(insts);
+
+ return rc;
+}
+
+
+static int
+_virNWFilterInstantiateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net,
+ enum instCase useNewFilter)
+{
+ int rc;
+ const char *drvname = EBIPTABLES_DRIVER_ID;
+ virNWFilterDriverStatePtr driver = conn->nwfilterPrivateData;
+ virNWFilterTechDriverPtr techdriver;
+ virNWFilterPoolObjPtr obj;
+ virNWFilterHashTablePtr vars, vars1;
+ virNWFilterDefPtr filter;
+ char vmmacaddr[VIR_MAC_STRING_BUFLEN] = {0};
+ int foundNewFilter = 0;
+ char *str_macaddr = NULL;
+
+ techdriver = virNWFilterTechDriverForName(drvname);
+
+ if (!techdriver) {
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Could not get access to ACL tech "
+ "driver '%s'"),
+ drvname);
+ return 1;
+ }
+
+ VIR_DEBUG("filter name: %s\n", net->filter);
+
+ obj = virNWFilterPoolObjFindByName(&driver->pools, net->filter);
+ if (!obj) {
+ virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ _("Could not find filter '%s'"),
+ net->filter);
+ return 1;
+ }
+
+ if (obj->wantRemoved) {
+ virNWFilterReportError(conn, VIR_ERR_NO_NWFILTER,
+ _("Filter '%s' is in use."),
+ net->filter);
+ rc = 1;
+ goto err_exit;
+ }
+
+ virFormatMacAddr(net->mac, vmmacaddr);
+ str_macaddr = strdup(vmmacaddr);
+ if (!str_macaddr) {
+ virReportOOMError();
+ rc = 1;
+ goto err_exit;
+ }
+
+ vars1 = virNWFilterCreateVarHashmap(conn,
+ str_macaddr);
+ if (!vars1) {
+ rc = 1;
+ goto err_exit;
+ }
+
+ str_macaddr = NULL;
+
+ vars = virNWFilterCreateVarsFrom(conn,
+ vars1,
+ net->filterparams);
+ if (!vars) {
+ rc = 1;
+ goto err_exit_vars1;
+ }
+
+ filter = obj->def;
+
+ switch (useNewFilter) {
+ case INSTANTIATE_FOLLOW_NEWFILTER:
+ if (obj->newDef) {
+ filter = obj->newDef;
+ foundNewFilter = 1;
+ }
+ break;
+
+ case INSTANTIATE_ROLLBACK_NEWFILTER:
+ if (obj->newDef)
+ foundNewFilter = 1;
+ break;
+
+ case INSTANTIATE_ALWAYS:
+ break;
+ }
+
+ rc = virNWFilterInstantiate(conn,
+ techdriver,
+ net->type,
+ filter,
+ net->ifname,
+ vars,
+ useNewFilter, &foundNewFilter);
+
+ virNWFilterHashTableFree(vars);
+
+err_exit_vars1:
+ virNWFilterHashTableFree(vars1);
+
+err_exit:
+
+ virNWFilterPoolObjUnlock(obj);
+
+ VIR_FREE(str_macaddr);
+
+ return rc;
+}
+
+
+int
+virNWFilterInstantiateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net)
+{
+ return _virNWFilterInstantiateFilter(conn, net,
+ INSTANTIATE_ALWAYS);
+}
+
+
+int
+virNWFilterUpdateInstantiateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net)
+{
+ return _virNWFilterInstantiateFilter(conn, net,
+ INSTANTIATE_FOLLOW_NEWFILTER);
+}
+
+int virNWFilterRollbackUpdateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net)
+{
+ return _virNWFilterInstantiateFilter(conn, net,
+
INSTANTIATE_ROLLBACK_NEWFILTER);
+}
+
+
+int
+virNWFilterTeardownFilter(const virDomainNetDefPtr net)
+{
+ const char *drvname = EBIPTABLES_DRIVER_ID;
+ virNWFilterTechDriverPtr techdriver;
+ techdriver = virNWFilterTechDriverForName(drvname);
+
+ if (!techdriver) {
+#if 0
+ virNWFilterReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("Could not get access to ACL tech "
+ "driver '%s'"),
+ drvname);
+#endif
+ return 1;
+ }
+
+ techdriver->allTeardown(net->ifname);
+
+ return 0;
+}
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.h
@@ -0,0 +1,52 @@
+/*
+ * nwfilter_gentech_driver.h: generic technology driver include file
+ *
+ * Copyright (C) 2010 IBM Corp.
+ * Copyright (C) 2010 Stefan Berger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Stefan Berger <stefanb(a)us.ibm.com>
+ */
+#ifndef __NWFILTER_GENTECH_DRIVER_H
+#define __NWFILTER_GENTECH_DRIVER_H
+
+virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char
*name);
+
+int virNWFilterRuleInstAddData(virConnectPtr conn,
+ virNWFilterRuleInstPtr res,
+ void *data);
+
+
+enum instCase {
+ INSTANTIATE_ALWAYS,
+ INSTANTIATE_FOLLOW_NEWFILTER,
+ INSTANTIATE_ROLLBACK_NEWFILTER,
+};
+
+
+int virNWFilterInstantiateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net);
+int virNWFilterUpdateInstantiateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net);
+int virNWFilterRollbackUpdateFilter(virConnectPtr conn,
+ const virDomainNetDefPtr net);
+
+int virNWFilterTeardownFilter(const virDomainNetDefPtr net);
+
+virNWFilterHashTablePtr virNWFilterCreateVarHashmap(virConnectPtr conn,
+ char *macaddr);
+
+#endif
Index: libvirt-acl/daemon/libvirtd.c
===================================================================
--- libvirt-acl.orig/daemon/libvirtd.c
+++ libvirt-acl/daemon/libvirtd.c
@@ -96,6 +96,9 @@
# ifdef WITH_SECRETS
# include "secret/secret_driver.h"
# endif
+# ifdef WITH_NWFILTER
+# include "nwfilter/nwfilter_driver.h"
+# endif
#endif
@@ -876,6 +879,7 @@ static struct qemud_server *qemudInitial
virDriverLoadModule("lxc");
virDriverLoadModule("uml");
virDriverLoadModule("one");
+ virDriverLoadModule("nwfilter");
#else
# ifdef WITH_NETWORK
networkRegister();
@@ -892,6 +896,9 @@ static struct qemud_server *qemudInitial
# ifdef WITH_SECRETS
secretRegister();
# endif
+# ifdef WITH_NWFILTER
+ nwfilterRegister();
+# endif
# ifdef WITH_QEMU
qemuRegister();
# endif
Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.h
===================================================================
--- /dev/null
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.h
@@ -0,0 +1,41 @@
+/*
+ * nwfilter_ebiptables_driver.h: ebtables/iptables driver support
+ *
+ * Copyright (C) 2010 IBM Corporation
+ * Copyright (C) 2010 Stefan Berger
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+ *
+ * Author: Stefan Berger <stefanb(a)us.ibm.com>
+ */
+#ifndef VIR_NWFILTER_EBTABLES_DRIVER_H__
+#define VIR_NWFILTER_EBTABLES_DRIVER_H__
+
+#define MAX_CHAINNAME_LENGTH 32 /* see
linux/netfilter_bridge/ebtables.h */
+
+typedef struct _ebiptablesRuleInst ebiptablesRuleInst;
+typedef ebiptablesRuleInst *ebiptablesRuleInstPtr;
+struct _ebiptablesRuleInst {
+ char *commandTemplate;
+ enum virNWFilterChainSuffixType neededProtocolChain;
+ char chainprefix; // I for incoming, O for outgoing
+ unsigned int priority;
+};
+
+extern virNWFilterTechDriver ebiptables_driver;
+
+#define EBIPTABLES_DRIVER_ID "ebiptables"
+
+#endif
Index: libvirt-acl/python/generator.py
===================================================================
--- libvirt-acl.orig/python/generator.py
+++ libvirt-acl/python/generator.py
@@ -170,6 +170,7 @@ skipped_types = {
# 'int *': "usually a return type",
'virConnectDomainEventCallback': "No function types in python",
'virEventAddHandleFunc': "No function types in python",
+ 'virNWFilterPoolPtr': "No function types in python",
}
#######################################################################
@@ -268,6 +269,7 @@ skip_impl = (
'virConnectListStorageVols',
'virConnectListDefinedStorageVols',
'virConnectListDefinedInterfaces',
+ 'virConnectListNWFilters',
'virConnGetLastError',
'virGetLastError',
'virDomainGetInfo',
Index: libvirt-acl/configure.ac
===================================================================
--- libvirt-acl.orig/configure.ac
+++ libvirt-acl/configure.ac
@@ -291,6 +291,9 @@ if test x"$with_rhel5_api" = x"yes"; the
AC_DEFINE([WITH_RHEL5_API], [1], [whether building for the RHEL-5
API])
fi
+AC_PATH_PROG([BASH_PATH], [bash], /bin/bash, [/bin:$PATH])
+AC_DEFINE_UNQUOTED([BASH_PATH], "$BASH_PATH", [path to bash binary])
+
AC_PATH_PROG([IPTABLES_PATH], [iptables], /sbin/iptables, [/usr/sbin:
$PATH])
AC_DEFINE_UNQUOTED([IPTABLES_PATH], "$IPTABLES_PATH", [path to iptables
binary])
1
0
Attached are some sample filter templates. Some of these should probably
become available through libvirt repository later on as 'standard
filters'.
One may copy the XML files into /etc/libvirt/nwfilter or use 'virsh
nwfilter-define <filename>' to make them known to libvirt. Using 'virsh
nwfilter-list' one can then list the filters.
The simpleloop.xml filter will not be accepted since it would directly
introduce a loop. More complex loops are also detected.
Regards,
Stefan, Gerhard
1
0
This patch adds support for L3/L4 filtering using iptables. This adds
support for 'tcp', 'udp', 'icmp', 'igmp', 'sctp' etc. filtering.
As mentioned in the introduction, a .c file provided by this patch
is #include'd into a .c file. This will need work, but should be alright
for review.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
[libvirt] [PATCH 12/13] Core driver implementation with ebtables support
by Stefan Berger 11 Mar '10
by Stefan Berger 11 Mar '10
11 Mar '10
This patch implements the core driver and provides
- management functionality for managing the filter XMLs
- compiling the internal filter representation into ebtables rules
- applying ebtables rules on a network (tap,macvtap) interface
- tearing down ebtables rules that were applied on behalf of an
interface
- updating of filters while VMs are running and causing the firewalls to
be rebuilt
- other bits and pieces
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
Add support for Qemu to have firewall rules applied and removed on VM
startup and shutdown respectively. This patch also provides support for
the updating of a filter that causes all VMs that reference the filter
to have their ebtables/iptables rules updated.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
[libvirt] [PATCH 10/13] Add XML parser extensions to the domain XML processing
by Stefan Berger 11 Mar '10
by Stefan Berger 11 Mar '10
11 Mar '10
This patch extends the domain XML processing to parse the top level
referenced filter along with potentially provided parameters and also
converts the internal data back into XML representation.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
Signed-off-by: Gerhard Stenzel <gerhard.stenzel(a)de.ibm.com>
1
0
This patch extends the RPC client for the new network filtering (ACL) functionality.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
11 Mar '10
This patch extends the RPC dispatcher to support the newly added RPC
calls for network filtering (ACL) support.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
This patch adds the definition of the wire format for RPC calls for the
new network filtering (ACL) functionality added to libvirt.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
This patch adds the implementation of the public API for the network
filtering (ACL) extensions to libvirt.c .
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
This patch adds the internal API extensions for network filtering (ACL) support.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
This patch adds extensions to libvirt's public API necessary for
controlling the new functionality from remote for example.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
This patch adds build support for the network filtering framework.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
1
0
Hello,
Sorry for posting this twice (in libvir-list and libvirt-users) - I just
wasn't sure the proper forum should this be posted under.
I would like to set up sshd under an LXC application container and to be
able to connect into it from the host. I was able to achieve that with LXC
tools CLI after setting up a bridge via brctl and creating a proper
lxc.conf file for lxc-execute to use. However, I am unable to do so via
libvirt. I am using libvirt version 0.7.1 installed on fedora 12.
I first verified that the default network is up
[root@enc12 avi]# virsh net-list --all
Name State Autostart
-----------------------------------------
default active yes
and that the bridge exists
[root@enc12 avi]# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.000000000000 yes
I then went over the explanations under
http://www.libvirt.org/formatdomain.html#elementsNICS and
http://wiki.libvirt.org/page/Networking
and made sure net.ipv4.ip_forward = 1 under file /etc/sysctl.conf on the
host
after that, I created a container with the following xml specification:
<domain type='lxc'>
<name>ssh9</name>
<memory>500000</memory>
<os>
<type>exe</type>
<init>/usr/sbin/sshd</init>
</os>
<vcpu>1</vcpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<interface type='network'>
<source network='default'/>
</interface>
<console type='pty' />
</devices>
</domain>
Below is the command that verifies LXC is running followed by dumpxml:
[root@enc12 avi]# virsh -c lxc:/// list --all
Id Name State
----------------------------------
1551 ssh9 running
<domain type='lxc' id='1551'>
<name>ssh9</name>
<uuid>ead3dc4f-9b3f-eec0-e83a-1d87e0ffb1eb</uuid>
<memory>500000</memory>
<currentMemory>500000</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='i686'>exe</type>
<init>/usr/sbin/sshd</init>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<interface type='network'>
<mac address='52:54:00:e8:e3:dd'/>
<source network='default'/>
<target dev='veth0'/>
</interface>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target port='0'/>
</console>
</devices>
</domain>
However, I can not see the IP address of the container so was not able to
connect it. I can also see that the routing table configured on the host -
routes any address destined to network 192.168.122 - into the bridge and I
understood that the container should have constructed with one of the IPs
in the range of 192.168.122.2 to 192.168.122.254 (as defined in dhcp tag
under default network) but it did not happen.
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use
Iface
9.148.28.32 * 255.255.255.240 U 1 0 0
eth0
192.168.122.0 * 255.255.255.0 U 0 0 0
virbr0
default 9.148.28.33 0.0.0.0 UG 0 0 0
eth0
Can someone please help me to understand what am I missing here?
Thanks,
- Avi
1
0
Hi,
I installed libvirt 0.7.6 version on my fedora 12 machine.
When issue the version command in the virsh console, the following are
the results:
Compiled against library: libvir 0.7.6
Using library: libvir 0.7.6
Using API: LXC 0.7.6
Running hypervisor: LXC 2.6.31
But, the following pkg-config command for libvirt is giving following:
Package libvirt was not found in the pkg-config search path.
Perhaps you should add the directory containing `libvirt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libvirt' found
Can anyone please let me know, how can I configure pkg-config w.r.t
libvirt?
Regards,
Srikanth.
2
1
[libvirt] [PATCH] Include sysfs devices lacking a device symlink as node devices
by Ed Swierk 11 Mar '10
by Ed Swierk 11 Mar '10
11 Mar '10
The udev node device driver relies on the "device" symlink in sysfs to
populate the node device's parent property. Loopback, vlan and bridge
network interfaces don't have a real hardware parent but could be useful
to include as node devices anyway (and the hal node device driver does
include them).
This patch allows the udev node device driver to include network
interfaces lacking a "device" symlink as node devices, and sets the
parent property to "computer".
Signed-off-by: Ed Swierk <eswierk(a)aristanetworks.com>
---
Index: libvirt-0.7.6/src/node_device/node_device_udev.c
===================================================================
--- libvirt-0.7.6.orig/src/node_device/node_device_udev.c
+++ libvirt-0.7.6/src/node_device/node_device_udev.c
@@ -1220,14 +1220,13 @@ static int udevSetParent(struct udev_dev
if (parent_device == NULL) {
VIR_INFO("Could not find udev parent for device with sysfs path '%s'",
udev_device_get_syspath(device));
- goto out;
}
parent_sysfs_path = udev_device_get_syspath(parent_device);
if (parent_sysfs_path == NULL) {
VIR_INFO("Could not get syspath for parent of '%s'",
udev_device_get_syspath(device));
- goto out;
+ parent_sysfs_path = "";
}
def->parent_sysfs_path = strdup(parent_sysfs_path);
3
5
Hi,
I'm trying to compile 0.7.7 under XP/mingw and I have this issue :
In file included from util/conf.c:24:
util/util.h:119: error: syntax error before "uid_t"
util/util.h:121: warning: function declaration isn't a prototype
util/util.h:129: error: syntax error before "uid_t"
util/util.h:130: warning: function declaration isn't a prototype
I have configure in this way (msys based path) :
./configure --host=i686-pc-mingw32 --without-sasl --without-avahi --without-polkit --without-python --without-xen --without-qemu --without-lxc --without-openvz --without-libvirtd --without-phyp --without-vbox --prefix=/mingw/
Any help ?
Best reagards
Arnaud Champion
4
4
[let's keep the list in the loop]
On 03/10/2010 01:32 PM, Dev.Atom wrote:
> Hi,
>
> and thanks for your help.
>
> with "make V=1" I have this :
>
> libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../gnulib/lib
> -I../gnulib/lib -I../include -I../src/util -I../include
> -I/mingw//include/libxml2 -DLIBDIR=\\\\/mingw/lib\\\\
> -DBINDIR=\\\\/mingw/libexec\\\\ -DSBINDIR=\\\\/mingw/sbin\\\\
> -DSYSCONF_DIR=\\\\/mingw/etc\\\\
> -DLOCALEBASEDIR=\\\\/mingw/share/locale\\\\
> -DPKGDATADIR=\\\\/mingw/share/libvirt\\\\
> -DLOCAL_STATE_DIR=\\\\/mingw/var\\\\ "-DGETTEXT_PACKAGE=\\libvirt\\
> -Wall" -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs
> -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings
> -Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
> -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
> -fasynchronous-unwind-tables -I/mingw/include -g -O2 -MT
> libvirt_util_la-conf.lo -MD -MP -MF .deps/libvirt_util_la-conf.Tpo -c
> util/conf.c -DDLL_EXPORT -DPIC -o .libs/libvirt_util_la-conf.o
> In file included from util/conf.c:24:
> util/util.h:119: error: syntax error before "uid_t"
> util/util.h:121: warning: function declaration isn't a prototype
> util/util.h:129: error: syntax error before "uid_t"
> util/util.h:130: warning: function declaration isn't a prototype
All right, the next thing I asked for was the region of the preprocessed
sources close to the error. Something like:
gcc -E -DHAVE_CONFIG_H -I. -I.. -I../gnulib/lib -I../gnulib/lib
-I../include -I../src/util -I../include -I/mingw//include/libxml2
-DLIBDIR=\\\\/mingw/lib\\\\ -DBINDIR=\\\\/mingw/libexec\\\\
-DSBINDIR=\\\\/mingw/sbin\\\\ -DSYSCONF_DIR=\\\\/mingw/etc\\\\
-DLOCALEBASEDIR=\\\\/mingw/share/locale\\\\
-DPKGDATADIR=\\\\/mingw/share/libvirt\\\\
-DLOCAL_STATE_DIR=\\\\/mingw/var\\\\ -I/mingw/include -g -O2 util/conf.c
-DDLL_EXPORT -DPIC
>
> Here are the depndencies version (mayabe shoud I use another gnulib
> version, I don't know) :
>
> gnutls-2.8.5
> libgcrypt-1.4.5
> libgpg-error-1.7
> libxml2-2.7.6
> portablexdr-4.9.1
Are you building from a release or from git?
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
1
0
[libvirt] [PATCH] build: update gnulib submodule to newer (but not latest)
by Jim Meyering 11 Mar '10
by Jim Meyering 11 Mar '10
11 Mar '10
I've just pushed this, so that people who pull-from-git through
the recent bootstrap.conf change (adding the count-one-bits module)
don't have to run ./bootstrap manually.
>From 12023373cdc771e5ca818f4c8f4aa8abe174871a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 10 Mar 2010 17:26:40 +0100
Subject: [PATCH] build: update gnulib submodule to newer (but not latest)
This is a stop-gap measure to make autogen.sh rerun ./bootstrap,
(required due to recent bootstrap.conf addition) while we prepare
the fix to automatically detect the case of an updated modules list.
---
.gnulib | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/.gnulib b/.gnulib
index 80cd995..10d66ae 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 80cd995cdcbf4b9ded895a43621a11f11806ad8d
+Subproject commit 10d66aedfdd610f731c8c54152b9dfca3efbee12
--
1.7.0.2.329.gdaec6
2
2
11 Mar '10
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
cppi $f > $f.t && mv $f.t $f
done
---
Huge, but all automated. Spot-checking didn't see any obvious
problems. Are any of these files generated, in which case
regenerating them might regress?
daemon/dispatch.h | 4 +-
daemon/event.h | 4 +-
daemon/libvirtd.c | 126 ++--
daemon/libvirtd.h | 160 ++--
daemon/mdns.h | 2 +-
daemon/remote.c | 10 +-
daemon/remote.h | 8 +-
daemon/stream.h | 4 +-
examples/domain-events/events-c/event-test.c | 20 +-
include/libvirt/virterror.h | 12 +-
proxy/libvirt_proxy.c | 34 +-
python/typewrappers.h | 14 +-
src/conf/capabilities.h | 12 +-
src/conf/cpu_conf.h | 16 +-
src/conf/domain_conf.h | 32 +-
src/conf/domain_event.h | 4 +-
src/conf/interface_conf.h | 14 +-
src/conf/network_conf.h | 12 +-
src/conf/node_device_conf.h | 16 +-
src/conf/secret_conf.h | 8 +-
src/conf/storage_conf.h | 14 +-
src/conf/storage_encryption_conf.h | 12 +-
src/cpu/cpu.h | 12 +-
src/cpu/cpu_generic.h | 4 +-
src/cpu/cpu_map.h | 4 +-
src/cpu/cpu_x86.c | 6 +-
src/cpu/cpu_x86.h | 4 +-
src/cpu/cpu_x86_data.h | 8 +-
src/datatypes.h | 62 +-
src/driver.c | 2 +-
src/driver.h | 24 +-
src/esx/esx_device_monitor.h | 2 +-
src/esx/esx_driver.c | 8 +-
src/esx/esx_driver.h | 2 +-
src/esx/esx_interface_driver.h | 2 +-
src/esx/esx_network_driver.h | 2 +-
src/esx/esx_private.h | 8 +-
src/esx/esx_secret_driver.h | 2 +-
src/esx/esx_storage_driver.h | 2 +-
src/esx/esx_util.h | 8 +-
src/esx/esx_vi.h | 14 +-
src/esx/esx_vi_methods.h | 6 +-
src/esx/esx_vi_types.c | 4 +-
src/esx/esx_vi_types.h | 4 +-
src/esx/esx_vmx.h | 10 +-
src/gnutls_1_0_compat.h | 20 +-
src/interface/netcf_driver.h | 2 +-
src/internal.h | 190 +++---
src/libvirt.c | 118 ++--
src/libvirt_internal.h | 8 +-
src/lxc/lxc_conf.h | 26 +-
src/lxc/lxc_container.c | 20 +-
src/lxc/lxc_container.h | 26 +-
src/lxc/lxc_controller.c | 6 +-
src/lxc/lxc_driver.h | 4 +-
src/lxc/veth.h | 4 +-
src/network/bridge_driver.h | 6 +-
src/node_device/node_device_driver.c | 8 +-
src/node_device/node_device_driver.h | 64 +-
src/node_device/node_device_hal.h | 2 +-
src/nodeinfo.c | 6 +-
src/nodeinfo.h | 6 +-
src/opennebula/one_client.h | 6 +-
src/opennebula/one_conf.h | 16 +-
src/opennebula/one_driver.h | 6 +-
src/openvz/openvz_conf.h | 18 +-
src/openvz/openvz_driver.h | 4 +-
src/qemu/qemu_bridge_filter.h | 2 +-
src/qemu/qemu_conf.h | 46 +-
src/qemu/qemu_driver.c | 8 +-
src/qemu/qemu_driver.h | 26 +-
src/qemu/qemu_monitor.c | 2 +-
src/qemu/qemu_monitor.h | 8 +-
src/qemu/qemu_monitor_json.h | 6 +-
src/qemu/qemu_monitor_text.h | 8 +-
src/qemu/qemu_security_dac.h | 2 +-
src/qemu/qemu_security_stacked.h | 2 +-
src/remote/remote_driver.c | 22 +-
src/remote/remote_driver.h | 30 +-
src/remote/remote_protocol.h | 88 ++--
src/secret/secret_driver.h | 2 +-
src/security/security_apparmor.h | 8 +-
src/security/security_driver.c | 4 +-
src/security/security_driver.h | 8 +-
src/security/security_selinux.h | 2 +-
src/storage/storage_backend.c | 20 +-
src/storage/storage_backend.h | 8 +-
src/storage/storage_backend_disk.h | 4 +-
src/storage/storage_backend_fs.c | 2 +-
src/storage/storage_backend_fs.h | 8 +-
src/storage/storage_backend_iscsi.h | 10 +-
src/storage/storage_backend_logical.h | 4 +-
src/storage/storage_backend_mpath.h | 4 +-
src/storage/storage_backend_scsi.h | 10 +-
src/storage/storage_driver.c | 2 +-
src/storage/storage_driver.h | 4 +-
src/test/test_driver.h | 4 +-
src/uml/uml_conf.h | 24 +-
src/uml/uml_driver.h | 4 +-
src/util/bridge.c | 106 ++--
src/util/bridge.h | 16 +-
src/util/buf.h | 12 +-
src/util/cgroup.c | 2 +-
src/util/cgroup.h | 2 +-
src/util/conf.h | 2 +-
src/util/ebtables.c | 4 +-
src/util/ebtables.h | 2 +-
src/util/event.h | 4 +-
src/util/hash.h | 2 +-
src/util/hostusb.h | 4 +-
src/util/iptables.c | 4 +-
src/util/iptables.h | 2 +-
src/util/json.c | 4 +-
src/util/json.h | 4 +-
src/util/logging.c | 2 +-
src/util/logging.h | 44 +-
src/util/macvtap.c | 38 +-
src/util/macvtap.h | 16 +-
src/util/memory.h | 22 +-
src/util/network.h | 10 +-
src/util/pci.c | 24 +-
src/util/pci.h | 4 +-
src/util/processinfo.c | 14 +-
src/util/processinfo.h | 4 +-
src/util/qparams.h | 2 +-
src/util/stats_linux.c | 32 +-
src/util/stats_linux.h | 8 +-
src/util/storage_file.h | 6 +-
src/util/threads.c | 12 +-
src/util/threads.h | 22 +-
src/util/util.c | 68 +-
src/util/util.h | 42 +-
src/util/uuid.c | 2 +-
src/util/uuid.h | 2 +-
src/util/virterror_internal.h | 10 +-
src/util/xml.h | 10 +-
src/vbox/vbox_CAPI_v2_2.h | 800 ++++++++++----------
src/vbox/vbox_CAPI_v3_0.h | 1056 +++++++++++++-------------
src/vbox/vbox_CAPI_v3_1.h | 1032 +++++++++++++-------------
src/vbox/vbox_XPCOMCGlue.h | 12 +-
src/vbox/vbox_driver.h | 4 +-
src/vbox/vbox_tmpl.c | 128 ++--
src/xen/block_stats.c | 34 +-
src/xen/block_stats.h | 8 +-
src/xen/proxy_internal.h | 8 +-
src/xen/sexpr.h | 6 +-
src/xen/xen_driver.c | 2 +-
src/xen/xen_driver.h | 82 +-
src/xen/xen_hypervisor.c | 82 +-
src/xen/xen_hypervisor.h | 10 +-
src/xen/xen_inotify.h | 6 +-
src/xen/xend_internal.c | 12 +-
src/xen/xend_internal.h | 30 +-
src/xen/xm_internal.c | 8 +-
src/xen/xm_internal.h | 10 +-
src/xen/xs_internal.c | 8 +-
src/xen/xs_internal.h | 6 +-
tests/esxutilstest.c | 18 +-
tests/nodeinfotest.c | 2 +-
tests/qemuargv2xmltest.c | 14 +-
tests/qemuhelptest.c | 12 +-
tests/qemuxml2argvtest.c | 16 +-
tests/qemuxml2xmltest.c | 12 +-
tests/statstest.c | 2 +-
tests/testutils.c | 16 +-
tests/testutils.h | 8 +-
tests/testutilsqemu.c | 10 +-
tests/vmx2xmltest.c | 18 +-
tests/xml2vmxtest.c | 18 +-
tools/console.c | 34 +-
tools/console.h | 6 +-
tools/virsh.c | 10 +-
172 files changed, 2895 insertions(+), 2895 deletions(-)
diff --git a/daemon/dispatch.h b/daemon/dispatch.h
index ed9d89d..1371b05 100644
--- a/daemon/dispatch.h
+++ b/daemon/dispatch.h
@@ -22,10 +22,10 @@
*/
#ifndef __LIBVIRTD_DISPATCH_H__
-#define __LIBVIRTD_DISPATCH_H__
+# define __LIBVIRTD_DISPATCH_H__
-#include "libvirtd.h"
+# include "libvirtd.h"
int
diff --git a/daemon/event.h b/daemon/event.h
index 0992f1c..dc03589 100644
--- a/daemon/event.h
+++ b/daemon/event.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIRTD_EVENT_H__
-#define __VIRTD_EVENT_H__
+# define __VIRTD_EVENT_H__
-#include "internal.h"
+# include "internal.h"
/**
* virEventAddHandleImpl: register a callback for monitoring file handle events
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index b44d9b4..d59a2ab 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -63,60 +63,60 @@
#include "memory.h"
#include "stream.h"
#ifdef HAVE_AVAHI
-#include "mdns.h"
+# include "mdns.h"
#endif
#ifdef WITH_DRIVER_MODULES
-#include "driver.h"
+# include "driver.h"
#else
-#ifdef WITH_QEMU
-#include "qemu/qemu_driver.h"
-#endif
-#ifdef WITH_LXC
-#include "lxc/lxc_driver.h"
-#endif
-#ifdef WITH_UML
-#include "uml/uml_driver.h"
-#endif
-#ifdef WITH_ONE
-#include "opennebula/one_driver.h"
-#endif
-#ifdef WITH_NETWORK
-#include "network/bridge_driver.h"
-#endif
-#ifdef WITH_NETCF
-#include "interface/netcf_driver.h"
-#endif
-#ifdef WITH_STORAGE_DIR
-#include "storage/storage_driver.h"
-#endif
-#ifdef WITH_NODE_DEVICES
-#include "node_device/node_device_driver.h"
-#endif
-#ifdef WITH_SECRETS
-#include "secret/secret_driver.h"
-#endif
+# ifdef WITH_QEMU
+# include "qemu/qemu_driver.h"
+# endif
+# ifdef WITH_LXC
+# include "lxc/lxc_driver.h"
+# endif
+# ifdef WITH_UML
+# include "uml/uml_driver.h"
+# endif
+# ifdef WITH_ONE
+# include "opennebula/one_driver.h"
+# endif
+# ifdef WITH_NETWORK
+# include "network/bridge_driver.h"
+# endif
+# ifdef WITH_NETCF
+# include "interface/netcf_driver.h"
+# endif
+# ifdef WITH_STORAGE_DIR
+# include "storage/storage_driver.h"
+# endif
+# ifdef WITH_NODE_DEVICES
+# include "node_device/node_device_driver.h"
+# endif
+# ifdef WITH_SECRETS
+# include "secret/secret_driver.h"
+# endif
#endif
#ifdef __sun
-#include <ucred.h>
-#include <priv.h>
+# include <ucred.h>
+# include <priv.h>
-#ifndef PRIV_VIRT_MANAGE
-#define PRIV_VIRT_MANAGE ((const char *)"virt_manage")
-#endif
+# ifndef PRIV_VIRT_MANAGE
+# define PRIV_VIRT_MANAGE ((const char *)"virt_manage")
+# endif
-#ifndef PRIV_XVM_CONTROL
-#define PRIV_XVM_CONTROL ((const char *)"xvm_control")
-#endif
+# ifndef PRIV_XVM_CONTROL
+# define PRIV_XVM_CONTROL ((const char *)"xvm_control")
+# endif
-#define PU_RESETGROUPS 0x0001 /* Remove supplemental groups */
-#define PU_CLEARLIMITSET 0x0008 /* L=0 */
+# define PU_RESETGROUPS 0x0001 /* Remove supplemental groups */
+# define PU_CLEARLIMITSET 0x0008 /* L=0 */
extern int __init_daemon_priv(int, uid_t, gid_t, ...);
-#define SYSTEM_UID 60
+# define SYSTEM_UID 60
static gid_t unix_sock_gid = 60; /* Not used */
static int unix_sock_rw_mask = 0666;
@@ -877,33 +877,33 @@ static struct qemud_server *qemudInitialize(void) {
virDriverLoadModule("uml");
virDriverLoadModule("one");
#else
-#ifdef WITH_NETWORK
+# ifdef WITH_NETWORK
networkRegister();
-#endif
-#ifdef WITH_NETCF
+# endif
+# ifdef WITH_NETCF
interfaceRegister();
-#endif
-#ifdef WITH_STORAGE_DIR
+# endif
+# ifdef WITH_STORAGE_DIR
storageRegister();
-#endif
-#if defined(WITH_NODE_DEVICES)
+# endif
+# if defined(WITH_NODE_DEVICES)
nodedevRegister();
-#endif
-#ifdef WITH_SECRETS
+# endif
+# ifdef WITH_SECRETS
secretRegister();
-#endif
-#ifdef WITH_QEMU
+# endif
+# ifdef WITH_QEMU
qemuRegister();
-#endif
-#ifdef WITH_LXC
+# endif
+# ifdef WITH_LXC
lxcRegister();
-#endif
-#ifdef WITH_UML
+# endif
+# ifdef WITH_UML
umlRegister();
-#endif
-#ifdef WITH_ONE
+# endif
+# ifdef WITH_ONE
oneRegister();
-#endif
+# endif
#endif
virEventRegisterImpl(virEventAddHandleImpl,
@@ -1247,7 +1247,7 @@ remoteCheckAccess (struct qemud_client *client)
#if HAVE_POLKIT
int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid) {
-#ifdef SO_PEERCRED
+# ifdef SO_PEERCRED
struct ucred cr;
unsigned int cr_len = sizeof (cr);
@@ -1260,10 +1260,10 @@ int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid) {
*pid = cr.pid;
*uid = cr.uid;
-#else
+# else
/* XXX Many more OS support UNIX socket credentials we could port to. See dbus ....*/
-#error "UNIX socket credentials not supported/implemented on this platform yet..."
-#endif
+# error "UNIX socket credentials not supported/implemented on this platform yet..."
+# endif
return 0;
}
#endif
@@ -2858,7 +2858,7 @@ qemudSetupPrivs (void)
return 0;
}
#else
-#define qemudSetupPrivs() 0
+# define qemudSetupPrivs() 0
#endif
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index a7591fc..d30fcd7 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -23,53 +23,53 @@
#ifndef QEMUD_INTERNAL_H__
-#define QEMUD_INTERNAL_H__
-
-#include <config.h>
-
-#include <gnutls/gnutls.h>
-#include <gnutls/x509.h>
-#include "gnutls_1_0_compat.h"
-#if HAVE_SASL
-#include <sasl/sasl.h>
-#endif
-
-#if HAVE_POLKIT0
-#include <dbus/dbus.h>
-#endif
-
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
-
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include "remote_protocol.h"
-#include "logging.h"
-#include "threads.h"
-
-#ifdef __GNUC__
-#ifdef HAVE_ANSIDECL_H
-#include <ansidecl.h>
-#endif
-
-#ifndef __GNUC_PREREQ
-#if defined __GNUC__ && defined __GNUC_MINOR__
-# define __GNUC_PREREQ(maj, min) \
+# define QEMUD_INTERNAL_H__
+
+# include <config.h>
+
+# include <gnutls/gnutls.h>
+# include <gnutls/x509.h>
+# include "gnutls_1_0_compat.h"
+# if HAVE_SASL
+# include <sasl/sasl.h>
+# endif
+
+# if HAVE_POLKIT0
+# include <dbus/dbus.h>
+# endif
+
+# ifdef HAVE_SYS_SYSLIMITS_H
+# include <sys/syslimits.h>
+# endif
+
+# include <rpc/types.h>
+# include <rpc/xdr.h>
+# include "remote_protocol.h"
+# include "logging.h"
+# include "threads.h"
+
+# ifdef __GNUC__
+# ifdef HAVE_ANSIDECL_H
+# include <ansidecl.h>
+# endif
+
+# ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-#define __GNUC_PREREQ(maj,min) 0
-#endif
-#endif
+# else
+# define __GNUC_PREREQ(maj,min) 0
+# endif
+# endif
/**
* ATTRIBUTE_UNUSED:
*
* Macro to flag conciously unused parameters to functions
*/
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((__unused__))
-#endif
+# ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__((__unused__))
+# endif
/**
* ATTRIBUTE_FMT_PRINTF
@@ -81,35 +81,35 @@
* printf format specifiers even on broken Win32 platforms
* hence we have to force 'gnu_printf' for new GCC
*/
-#ifndef ATTRIBUTE_FMT_PRINTF
-#if __GNUC_PREREQ (4, 4)
-#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
-#else
-#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
-#endif
-#endif
-
-#ifndef ATTRIBUTE_RETURN_CHECK
-#if __GNUC_PREREQ (3, 4)
-#define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
-#else
-#define ATTRIBUTE_RETURN_CHECK
-#endif
-#endif
-
-#else
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED
-#endif
-#ifndef ATTRIBUTE_FMT_PRINTF
-#define ATTRIBUTE_FMT_PRINTF(...)
-#endif
-#ifndef ATTRIBUTE_RETURN_CHECK
-#define ATTRIBUTE_RETURN_CHECK
-#endif
-#endif
-
-#define qemudDebug DEBUG
+# ifndef ATTRIBUTE_FMT_PRINTF
+# if __GNUC_PREREQ (4, 4)
+# define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
+# else
+# define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
+# endif
+# endif
+
+# ifndef ATTRIBUTE_RETURN_CHECK
+# if __GNUC_PREREQ (3, 4)
+# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+# else
+# define ATTRIBUTE_RETURN_CHECK
+# endif
+# endif
+
+# else
+# ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED
+# endif
+# ifndef ATTRIBUTE_FMT_PRINTF
+# define ATTRIBUTE_FMT_PRINTF(...)
+# endif
+# ifndef ATTRIBUTE_RETURN_CHECK
+# define ATTRIBUTE_RETURN_CHECK
+# endif
+# endif
+
+# define qemudDebug DEBUG
/* Whether we're passing reads & writes through a sasl SSF */
enum qemud_sasl_ssf {
@@ -186,7 +186,7 @@ struct qemud_client {
gnutls_session_t tlssession;
int auth;
unsigned int handshake :1; /* If we're in progress for TLS handshake */
-#if HAVE_SASL
+# if HAVE_SASL
sasl_conn_t *saslconn;
int saslSSF;
const char *saslDecoded;
@@ -196,7 +196,7 @@ struct qemud_client {
unsigned int saslEncodedLength;
unsigned int saslEncodedOffset;
char *saslUsername;
-#endif
+# endif
/* Count of meages in 'dx' or 'tx' queue
* ie RPC calls in progress. Does not count
@@ -229,7 +229,7 @@ struct qemud_client {
};
-#define QEMUD_CLIENT_MAGIC 0x7788aaee
+# define QEMUD_CLIENT_MAGIC 0x7788aaee
struct qemud_socket {
@@ -273,15 +273,15 @@ struct qemud_server {
pthread_t eventThread;
unsigned int hasEventThread :1;
unsigned int quitEventThread :1;
-#ifdef HAVE_AVAHI
+# ifdef HAVE_AVAHI
struct libvirtd_mdns *mdns;
-#endif
-#if HAVE_SASL
+# endif
+# if HAVE_SASL
char **saslUsernameWhitelist;
-#endif
-#if HAVE_POLKIT0
+# endif
+# if HAVE_POLKIT0
DBusConnection *sysbus;
-#endif
+# endif
};
void qemudLog(int priority, const char *fmt, ...)
@@ -306,8 +306,8 @@ qemudClientMessageRelease(struct qemud_client *client,
struct qemud_client_message *msg);
-#if HAVE_POLKIT
+# if HAVE_POLKIT
int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid);
-#endif
+# endif
#endif
diff --git a/daemon/mdns.h b/daemon/mdns.h
index cabcee4..b096984 100644
--- a/daemon/mdns.h
+++ b/daemon/mdns.h
@@ -25,7 +25,7 @@
#include "internal.h"
#ifndef __VIRTD_MDNS_H__
-#define __VIRTD_MDNS_H__
+# define __VIRTD_MDNS_H__
struct libvirtd_mdns;
struct libvirtd_mdns_group;
diff --git a/daemon/remote.c b/daemon/remote.c
index d4713b2..7c4339f 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -44,8 +44,8 @@
#include "virterror_internal.h"
#if HAVE_POLKIT0
-#include <polkit/polkit.h>
-#include <polkit-dbus/polkit-dbus.h>
+# include <polkit/polkit.h>
+# include <polkit-dbus/polkit-dbus.h>
#endif
#include "remote.h"
@@ -3516,7 +3516,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
goto authfail;
}
-#if HAVE_POLKIT_CONTEXT_IS_CALLER_AUTHORIZED
+# if HAVE_POLKIT_CONTEXT_IS_CALLER_AUTHORIZED
pkresult = polkit_context_is_caller_authorized(pkcontext,
pkaction,
pkcaller,
@@ -3528,11 +3528,11 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
polkit_error_get_error_message(pkerr));
goto authfail;
}
-#else
+# else
pkresult = polkit_context_can_caller_do_action(pkcontext,
pkaction,
pkcaller);
-#endif
+# endif
polkit_context_unref(pkcontext);
polkit_caller_unref(pkcaller);
polkit_action_unref(pkaction);
diff --git a/daemon/remote.h b/daemon/remote.h
index 24e8c73..9db7432 100644
--- a/daemon/remote.h
+++ b/daemon/remote.h
@@ -22,17 +22,17 @@
*/
#ifndef __LIBVIRTD_REMOTE_H__
-#define __LIBVIRTD_REMOTE_H__
+# define __LIBVIRTD_REMOTE_H__
-#include "libvirtd.h"
+# include "libvirtd.h"
typedef union {
-#include "remote_dispatch_args.h"
+# include "remote_dispatch_args.h"
} dispatch_args;
typedef union {
-#include "remote_dispatch_ret.h"
+# include "remote_dispatch_ret.h"
} dispatch_ret;
diff --git a/daemon/stream.h b/daemon/stream.h
index 181080f..767a763 100644
--- a/daemon/stream.h
+++ b/daemon/stream.h
@@ -22,9 +22,9 @@
#ifndef __LIBVIRTD_STREAM_H__
-#define __LIBVIRTD_STREAM_H__
+# define __LIBVIRTD_STREAM_H__
-#include "libvirtd.h"
+# include "libvirtd.h"
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index e8f5505..7464f93 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -6,19 +6,19 @@
#include <signal.h>
#if HAVE_SYS_POLL_H
-#include <sys/types.h>
-#include <sys/poll.h>
-#include <libvirt/libvirt.h>
+# include <sys/types.h>
+# include <sys/poll.h>
+# include <libvirt/libvirt.h>
-#define DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
+# define DEBUG0(fmt) printf("%s:%d :: " fmt "\n", \
__func__, __LINE__)
-#define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
+# define DEBUG(fmt, ...) printf("%s:%d: " fmt "\n", \
__func__, __LINE__, __VA_ARGS__)
-#define STREQ(a,b) (strcmp(a,b) == 0)
+# define STREQ(a,b) (strcmp(a,b) == 0)
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((__unused__))
-#endif
+# ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__((__unused__))
+# endif
/* handle globals */
int h_fd = 0;
@@ -28,7 +28,7 @@ virFreeCallback h_ff = NULL;
void *h_opaque = NULL;
/* timeout globals */
-#define TIMEOUT_MS 1000
+# define TIMEOUT_MS 1000
int t_active = 0;
int t_timeout = -1;
virEventTimeoutCallback t_cb = NULL;
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 30f88e8..c766416 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -12,13 +12,13 @@
*/
#ifndef __VIR_VIRERR_H__
-#define __VIR_VIRERR_H__
+# define __VIR_VIRERR_H__
-#include <libvirt/libvirt.h>
+# include <libvirt/libvirt.h>
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
/**
* virErrorLevel:
@@ -210,8 +210,8 @@ void virConnSetErrorFunc (virConnectPtr conn,
virErrorFunc handler);
int virConnCopyLastError (virConnectPtr conn,
virErrorPtr to);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* __VIR_VIRERR_H__ */
diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c
index 658bdc4..695a652 100644
--- a/proxy/libvirt_proxy.c
+++ b/proxy/libvirt_proxy.c
@@ -14,30 +14,30 @@
#ifdef WITH_XEN
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <locale.h>
-
-#include "internal.h"
-#include "datatypes.h"
-#include "proxy_internal.h"
-#include "util.h"
-#include "xen_hypervisor.h"
-#include "xend_internal.h"
-#include "xs_internal.h"
-#include "xen_driver.h"
+# include <stdlib.h>
+# include <unistd.h>
+# include <errno.h>
+# include <sys/types.h>
+# include <sys/poll.h>
+# include <sys/socket.h>
+# include <sys/un.h>
+# include <locale.h>
+
+# include "internal.h"
+# include "datatypes.h"
+# include "proxy_internal.h"
+# include "util.h"
+# include "xen_hypervisor.h"
+# include "xend_internal.h"
+# include "xs_internal.h"
+# include "xen_driver.h"
static int fdServer = -1;
static int debug = 0;
static int persist = 0;
static int done = 0;
-#define MAX_CLIENT 64
+# define MAX_CLIENT 64
static int nbClients = 0; /* client 0 is the unix listen socket */
static struct pollfd pollInfos[MAX_CLIENT + 1];
diff --git a/python/typewrappers.h b/python/typewrappers.h
index dadcdd4..8e1998e 100644
--- a/python/typewrappers.h
+++ b/python/typewrappers.h
@@ -11,14 +11,14 @@
#include "libvirt/virterror.h"
#ifdef __GNUC__
-#ifdef ATTRIBUTE_UNUSED
-#undef ATTRIBUTE_UNUSED
-#endif
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
-#endif /* ATTRIBUTE_UNUSED */
+# ifdef ATTRIBUTE_UNUSED
+# undef ATTRIBUTE_UNUSED
+# endif
+# ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+# endif /* ATTRIBUTE_UNUSED */
#else
-#define ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED
#endif
#define PyvirConnect_Get(v) (((v) == Py_None) ? NULL : \
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 8c20cd4..0ed0166 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -22,14 +22,14 @@
*/
#ifndef __VIR_CAPABILITIES_H
-#define __VIR_CAPABILITIES_H
+# define __VIR_CAPABILITIES_H
-#include "internal.h"
-#include "util.h"
-#include "buf.h"
-#include "cpu_conf.h"
+# include "internal.h"
+# include "util.h"
+# include "buf.h"
+# include "cpu_conf.h"
-#include <libxml/xpath.h>
+# include <libxml/xpath.h>
typedef struct _virCapsGuestFeature virCapsGuestFeature;
typedef virCapsGuestFeature *virCapsGuestFeaturePtr;
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 6a66959..bb8a844 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -22,13 +22,13 @@
*/
#ifndef __VIR_CPU_CONF_H__
-#define __VIR_CPU_CONF_H__
+# define __VIR_CPU_CONF_H__
-#include "util.h"
-#include "buf.h"
-#ifndef PROXY
-#include "xml.h"
-#endif
+# include "util.h"
+# include "buf.h"
+# ifndef PROXY
+# include "xml.h"
+# endif
enum virCPUType {
VIR_CPU_TYPE_HOST,
@@ -83,12 +83,12 @@ struct _virCPUDef {
void
virCPUDefFree(virCPUDefPtr def);
-#ifndef PROXY
+# ifndef PROXY
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt,
enum virCPUType mode);
-#endif
+# endif
enum virCPUFormatFlags {
VIR_CPU_FORMAT_EMBEDED = (1 << 0) /* embed into existing <cpu/> element
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bb6b3aa..0540a77 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -22,20 +22,20 @@
*/
#ifndef __DOMAIN_CONF_H
-#define __DOMAIN_CONF_H
+# define __DOMAIN_CONF_H
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
+# include <libxml/parser.h>
+# include <libxml/tree.h>
+# include <libxml/xpath.h>
-#include "internal.h"
-#include "capabilities.h"
-#include "storage_encryption_conf.h"
-#include "cpu_conf.h"
-#include "util.h"
-#include "threads.h"
-#include "hash.h"
-#include "network.h"
+# include "internal.h"
+# include "capabilities.h"
+# include "storage_encryption_conf.h"
+# include "cpu_conf.h"
+# include "util.h"
+# include "threads.h"
+# include "hash.h"
+# include "network.h"
/* Private component of virDomainXMLFlags */
typedef enum {
@@ -566,7 +566,7 @@ struct _virDomainDeviceDef {
};
-#define VIR_DOMAIN_MAX_BOOT_DEVS 4
+# define VIR_DOMAIN_MAX_BOOT_DEVS 4
/* 3 possible boot devices */
enum virDomainBootOrder {
@@ -656,7 +656,7 @@ struct _virDomainClockDef {
} data;
};
-#define VIR_DOMAIN_CPUMASK_LEN 1024
+# define VIR_DOMAIN_CPUMASK_LEN 1024
/* Guest VM main configuration */
typedef struct _virDomainDef virDomainDef;
@@ -816,7 +816,7 @@ virDomainObjPtr virDomainAssignDef(virCapsPtr caps,
void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainObjPtr dom);
-#ifndef PROXY
+# ifndef PROXY
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
const virDomainDefPtr def,
const char *xmlStr,
@@ -840,7 +840,7 @@ virDomainObjPtr virDomainObjParseNode(virCapsPtr caps,
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
-#endif
+# endif
char *virDomainDefFormat(virDomainDefPtr def,
int flags);
diff --git a/src/conf/domain_event.h b/src/conf/domain_event.h
index aa0346b..8d1b330 100644
--- a/src/conf/domain_event.h
+++ b/src/conf/domain_event.h
@@ -23,9 +23,9 @@
#include "internal.h"
#ifndef __DOMAIN_EVENT_H__
-#define __DOMAIN_EVENT_H__
+# define __DOMAIN_EVENT_H__
-#include "domain_conf.h"
+# include "domain_conf.h"
struct _virDomainEventCallback {
virConnectPtr conn;
diff --git a/src/conf/interface_conf.h b/src/conf/interface_conf.h
index bd479a7..6073b49 100644
--- a/src/conf/interface_conf.h
+++ b/src/conf/interface_conf.h
@@ -22,15 +22,15 @@
*/
#ifndef __INTERFACE_CONF_H__
-#define __INTERFACE_CONF_H__
+# define __INTERFACE_CONF_H__
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
+# include <libxml/parser.h>
+# include <libxml/tree.h>
+# include <libxml/xpath.h>
-#include "internal.h"
-#include "util.h"
-#include "threads.h"
+# include "internal.h"
+# include "util.h"
+# include "threads.h"
/* There is currently 3 types of interfaces */
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index c1d31c1..127a23a 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -22,14 +22,14 @@
*/
#ifndef __NETWORK_CONF_H__
-#define __NETWORK_CONF_H__
+# define __NETWORK_CONF_H__
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
+# include <libxml/parser.h>
+# include <libxml/tree.h>
+# include <libxml/xpath.h>
-#include "internal.h"
-#include "threads.h"
+# include "internal.h"
+# include "threads.h"
/* 2 possible types of forwarding */
enum virNetworkForwardType {
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index cbaad9b..fe0f2bf 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -23,16 +23,16 @@
*/
#ifndef __VIR_NODE_DEVICE_CONF_H__
-#define __VIR_NODE_DEVICE_CONF_H__
+# define __VIR_NODE_DEVICE_CONF_H__
-#include "internal.h"
-#include "util.h"
-#include "threads.h"
+# include "internal.h"
+# include "util.h"
+# include "threads.h"
-#include <libxml/tree.h>
+# include <libxml/tree.h>
-#define CREATE_DEVICE 1
-#define EXISTING_DEVICE 0
+# define CREATE_DEVICE 1
+# define EXISTING_DEVICE 0
enum virNodeDevCapType {
/* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
@@ -218,7 +218,7 @@ struct _virDeviceMonitorState {
void *privateData; /* driver-specific private data */
};
-#define virNodeDeviceReportError(code, ...) \
+# define virNodeDeviceReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_NODEDEV, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/conf/secret_conf.h b/src/conf/secret_conf.h
index afcf8f1..66294ce 100644
--- a/src/conf/secret_conf.h
+++ b/src/conf/secret_conf.h
@@ -21,12 +21,12 @@
*/
#ifndef __VIR_SECRET_CONF_H__
-#define __VIR_SECRET_CONF_H__
+# define __VIR_SECRET_CONF_H__
-#include "internal.h"
-#include "util.h"
+# include "internal.h"
+# include "util.h"
-#define virSecretReportError(code, ...) \
+# define virSecretReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_SECRET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 5441c8e..1c9ba04 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -22,14 +22,14 @@
*/
#ifndef __VIR_STORAGE_CONF_H__
-#define __VIR_STORAGE_CONF_H__
+# define __VIR_STORAGE_CONF_H__
-#include "internal.h"
-#include "util.h"
-#include "storage_encryption_conf.h"
-#include "threads.h"
+# include "internal.h"
+# include "util.h"
+# include "storage_encryption_conf.h"
+# include "threads.h"
-#include <libxml/tree.h>
+# include <libxml/tree.h>
/* Shared structs */
@@ -318,7 +318,7 @@ static inline int virStoragePoolObjIsActive(virStoragePoolObjPtr pool) {
return pool->active;
}
-#define virStorageReportError(code, ...) \
+# define virStorageReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_STORAGE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h
index bb19850..fd435fc 100644
--- a/src/conf/storage_encryption_conf.h
+++ b/src/conf/storage_encryption_conf.h
@@ -21,14 +21,14 @@
*/
#ifndef __VIR_STORAGE_ENCRYPTION_H__
-#define __VIR_STORAGE_ENCRYPTION_H__
+# define __VIR_STORAGE_ENCRYPTION_H__
-#include "internal.h"
-#include "buf.h"
-#include "util.h"
+# include "internal.h"
+# include "buf.h"
+# include "util.h"
-#include <stdbool.h>
-#include <libxml/tree.h>
+# include <stdbool.h>
+# include <libxml/tree.h>
enum virStorageEncryptionSecretType {
VIR_STORAGE_ENCRYPTION_SECRET_TYPE_PASSPHRASE = 0,
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 4287ca3..a2d79fe 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -22,15 +22,15 @@
*/
#ifndef __VIR_CPU_H__
-#define __VIR_CPU_H__
+# define __VIR_CPU_H__
-#include "virterror_internal.h"
-#include "datatypes.h"
-#include "conf/cpu_conf.h"
-#include "cpu_x86_data.h"
+# include "virterror_internal.h"
+# include "datatypes.h"
+# include "conf/cpu_conf.h"
+# include "cpu_x86_data.h"
-#define virCPUReportError(code, ...) \
+# define virCPUReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/cpu/cpu_generic.h b/src/cpu/cpu_generic.h
index 8fc952a..b494468 100644
--- a/src/cpu/cpu_generic.h
+++ b/src/cpu/cpu_generic.h
@@ -23,9 +23,9 @@
*/
#ifndef __VIR_CPU_GENERIC_H__
-#define __VIR_CPU_GENERIC_H__
+# define __VIR_CPU_GENERIC_H__
-#include "cpu.h"
+# include "cpu.h"
extern struct cpuArchDriver cpuDriverGeneric;
diff --git a/src/cpu/cpu_map.h b/src/cpu/cpu_map.h
index affe534..3d72c7f 100644
--- a/src/cpu/cpu_map.h
+++ b/src/cpu/cpu_map.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_CPU_MAP_H__
-#define __VIR_CPU_MAP_H__
+# define __VIR_CPU_MAP_H__
-#include "xml.h"
+# include "xml.h"
typedef int
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index b263629..4bb556c 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1146,14 +1146,14 @@ error:
static inline void
cpuidCall(struct cpuX86cpuid *cpuid)
{
-#if __x86_64__
+# if __x86_64__
asm("cpuid"
: "=a" (cpuid->eax),
"=b" (cpuid->ebx),
"=c" (cpuid->ecx),
"=d" (cpuid->edx)
: "a" (cpuid->function));
-#else
+# else
/* we need to avoid direct use of ebx for CPUID output as it is used
* for global offset table on i386 with -fPIC
*/
@@ -1167,7 +1167,7 @@ cpuidCall(struct cpuX86cpuid *cpuid)
"=d" (cpuid->edx)
: "a" (cpuid->function)
: "cc");
-#endif
+# endif
}
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 58f1aae..dd47c2c 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_CPU_X86_H__
-#define __VIR_CPU_X86_H__
+# define __VIR_CPU_X86_H__
-#include "cpu.h"
+# include "cpu.h"
extern struct cpuArchDriver cpuDriverX86;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index 25ee2a5..46d2517 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_CPU_X86_DATA_H__
-#define __VIR_CPU_X86_DATA_H__
+# define __VIR_CPU_X86_DATA_H__
-#include <stdint.h>
+# include <stdint.h>
struct cpuX86cpuid {
uint32_t function;
@@ -34,8 +34,8 @@ struct cpuX86cpuid {
uint32_t edx;
};
-#define CPUX86_BASIC 0x0
-#define CPUX86_EXTENDED 0x80000000
+# define CPUX86_BASIC 0x0
+# define CPUX86_EXTENDED 0x80000000
struct cpuX86Data {
int basic_len;
diff --git a/src/datatypes.h b/src/datatypes.h
index afb51dc..e19c99a 100644
--- a/src/datatypes.h
+++ b/src/datatypes.h
@@ -20,13 +20,13 @@
*/
#ifndef __VIRT_DATATYPES_H_
-#define __VIRT_DATATYPES_H_
+# define __VIRT_DATATYPES_H_
-#include "internal.h"
+# include "internal.h"
-#include "hash.h"
-#include "driver.h"
-#include "threads.h"
+# include "hash.h"
+# include "driver.h"
+# include "threads.h"
/**
* VIR_CONNECT_MAGIC:
@@ -34,8 +34,8 @@
* magic value used to protect the API when pointers to connection structures
* are passed down by the uers.
*/
-#define VIR_CONNECT_MAGIC 0x4F23DEAD
-#define VIR_IS_CONNECT(obj) ((obj) && (obj)->magic==VIR_CONNECT_MAGIC)
+# define VIR_CONNECT_MAGIC 0x4F23DEAD
+# define VIR_IS_CONNECT(obj) ((obj) && (obj)->magic==VIR_CONNECT_MAGIC)
/**
@@ -44,9 +44,9 @@
* magic value used to protect the API when pointers to domain structures
* are passed down by the users.
*/
-#define VIR_DOMAIN_MAGIC 0xDEAD4321
-#define VIR_IS_DOMAIN(obj) ((obj) && (obj)->magic==VIR_DOMAIN_MAGIC)
-#define VIR_IS_CONNECTED_DOMAIN(obj) (VIR_IS_DOMAIN(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_DOMAIN_MAGIC 0xDEAD4321
+# define VIR_IS_DOMAIN(obj) ((obj) && (obj)->magic==VIR_DOMAIN_MAGIC)
+# define VIR_IS_CONNECTED_DOMAIN(obj) (VIR_IS_DOMAIN(obj) && VIR_IS_CONNECT((obj)->conn))
/**
* VIR_NETWORK_MAGIC:
@@ -54,9 +54,9 @@
* magic value used to protect the API when pointers to network structures
* are passed down by the users.
*/
-#define VIR_NETWORK_MAGIC 0xDEAD1234
-#define VIR_IS_NETWORK(obj) ((obj) && (obj)->magic==VIR_NETWORK_MAGIC)
-#define VIR_IS_CONNECTED_NETWORK(obj) (VIR_IS_NETWORK(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_NETWORK_MAGIC 0xDEAD1234
+# define VIR_IS_NETWORK(obj) ((obj) && (obj)->magic==VIR_NETWORK_MAGIC)
+# define VIR_IS_CONNECTED_NETWORK(obj) (VIR_IS_NETWORK(obj) && VIR_IS_CONNECT((obj)->conn))
/**
* VIR_INTERFACE_MAGIC:
@@ -64,9 +64,9 @@
* magic value used to protect the API when pointers to interface structures
* are passed down by the users.
*/
-#define VIR_INTERFACE_MAGIC 0xDEAD5309
-#define VIR_IS_INTERFACE(obj) ((obj) && (obj)->magic==VIR_INTERFACE_MAGIC)
-#define VIR_IS_CONNECTED_INTERFACE(obj) (VIR_IS_INTERFACE(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_INTERFACE_MAGIC 0xDEAD5309
+# define VIR_IS_INTERFACE(obj) ((obj) && (obj)->magic==VIR_INTERFACE_MAGIC)
+# define VIR_IS_CONNECTED_INTERFACE(obj) (VIR_IS_INTERFACE(obj) && VIR_IS_CONNECT((obj)->conn))
/**
* VIR_STORAGE_POOL_MAGIC:
@@ -74,9 +74,9 @@
* magic value used to protect the API when pointers to storage pool structures
* are passed down by the users.
*/
-#define VIR_STORAGE_POOL_MAGIC 0xDEAD5678
-#define VIR_IS_STORAGE_POOL(obj) ((obj) && (obj)->magic==VIR_STORAGE_POOL_MAGIC)
-#define VIR_IS_CONNECTED_STORAGE_POOL(obj) (VIR_IS_STORAGE_POOL(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_STORAGE_POOL_MAGIC 0xDEAD5678
+# define VIR_IS_STORAGE_POOL(obj) ((obj) && (obj)->magic==VIR_STORAGE_POOL_MAGIC)
+# define VIR_IS_CONNECTED_STORAGE_POOL(obj) (VIR_IS_STORAGE_POOL(obj) && VIR_IS_CONNECT((obj)->conn))
/**
* VIR_STORAGE_VOL_MAGIC:
@@ -84,9 +84,9 @@
* magic value used to protect the API when pointers to storage vol structures
* are passed down by the users.
*/
-#define VIR_STORAGE_VOL_MAGIC 0xDEAD8765
-#define VIR_IS_STORAGE_VOL(obj) ((obj) && (obj)->magic==VIR_STORAGE_VOL_MAGIC)
-#define VIR_IS_CONNECTED_STORAGE_VOL(obj) (VIR_IS_STORAGE_VOL(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_STORAGE_VOL_MAGIC 0xDEAD8765
+# define VIR_IS_STORAGE_VOL(obj) ((obj) && (obj)->magic==VIR_STORAGE_VOL_MAGIC)
+# define VIR_IS_CONNECTED_STORAGE_VOL(obj) (VIR_IS_STORAGE_VOL(obj) && VIR_IS_CONNECT((obj)->conn))
/**
* VIR_NODE_DEVICE_MAGIC:
@@ -94,9 +94,9 @@
* magic value used to protect the API when pointers to storage vol structures
* are passed down by the users.
*/
-#define VIR_NODE_DEVICE_MAGIC 0xDEAD5679
-#define VIR_IS_NODE_DEVICE(obj) ((obj) && (obj)->magic==VIR_NODE_DEVICE_MAGIC)
-#define VIR_IS_CONNECTED_NODE_DEVICE(obj) (VIR_IS_NODE_DEVICE(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_NODE_DEVICE_MAGIC 0xDEAD5679
+# define VIR_IS_NODE_DEVICE(obj) ((obj) && (obj)->magic==VIR_NODE_DEVICE_MAGIC)
+# define VIR_IS_CONNECTED_NODE_DEVICE(obj) (VIR_IS_NODE_DEVICE(obj) && VIR_IS_CONNECT((obj)->conn))
/**
* VIR_SECRET_MAGIC:
@@ -104,9 +104,9 @@
* magic value used to protect the API when pointers to secret structures are
* passed down by the users.
*/
-#define VIR_SECRET_MAGIC 0x5678DEAD
-#define VIR_IS_SECRET(obj) ((obj) && (obj)->magic==VIR_SECRET_MAGIC)
-#define VIR_IS_CONNECTED_SECRET(obj) (VIR_IS_SECRET(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_SECRET_MAGIC 0x5678DEAD
+# define VIR_IS_SECRET(obj) ((obj) && (obj)->magic==VIR_SECRET_MAGIC)
+# define VIR_IS_CONNECTED_SECRET(obj) (VIR_IS_SECRET(obj) && VIR_IS_CONNECT((obj)->conn))
/**
@@ -115,9 +115,9 @@
* magic value used to protect the API when pointers to stream structures
* are passed down by the users.
*/
-#define VIR_STREAM_MAGIC 0x1DEAD666
-#define VIR_IS_STREAM(obj) ((obj) && (obj)->magic==VIR_STREAM_MAGIC)
-#define VIR_IS_CONNECTED_STREAM(obj) (VIR_IS_STREAM(obj) && VIR_IS_CONNECT((obj)->conn))
+# define VIR_STREAM_MAGIC 0x1DEAD666
+# define VIR_IS_STREAM(obj) ((obj) && (obj)->magic==VIR_STREAM_MAGIC)
+# define VIR_IS_CONNECTED_STREAM(obj) (VIR_IS_STREAM(obj) && VIR_IS_CONNECT((obj)->conn))
/**
diff --git a/src/driver.c b/src/driver.c
index c662428..c247f14 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -35,7 +35,7 @@
/* XXX re-implment this for other OS, or use libtools helper lib ? */
-#include <dlfcn.h>
+# include <dlfcn.h>
void *
virDriverLoadModule(const char *name)
diff --git a/src/driver.h b/src/driver.h
index 7b7dfea..8b12a9c 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -4,14 +4,14 @@
*/
#ifndef __VIR_DRIVER_H__
-#define __VIR_DRIVER_H__
+# define __VIR_DRIVER_H__
-#include "config.h"
-#include <stdbool.h>
+# include "config.h"
+# include <stdbool.h>
-#include <libxml/uri.h>
+# include <libxml/uri.h>
-#include "internal.h"
+# include "internal.h"
/*
* List of registered drivers numbers
*/
@@ -55,7 +55,7 @@ typedef enum {
* 0 Feature is not supported.
* -1 Error.
*/
-#define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature) \
+# define VIR_DRV_SUPPORTS_FEATURE(drv,conn,feature) \
((drv)->supports_feature ? (drv)->supports_feature((conn),(feature)) : 0)
typedef virDrvOpenStatus
@@ -797,7 +797,7 @@ struct _virStorageDriver {
virDrvStoragePoolIsPersistent poolIsPersistent;
};
-#ifdef WITH_LIBVIRTD
+# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (int privileged);
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
@@ -813,7 +813,7 @@ struct _virStateDriver {
virDrvStateReload reload;
virDrvStateActive active;
};
-#endif
+# endif
typedef struct _virDeviceMonitor virDeviceMonitor;
@@ -871,10 +871,10 @@ struct _virDeviceMonitor {
};
/* bits 16 and above of virDomainXMLFlags are for internal use */
-#define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
+# define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
/* Bits 16 and above of virSecretGetValue flags are for internal use */
-#define VIR_SECRET_GET_VALUE_FLAGS_MASK 0xffff
+# define VIR_SECRET_GET_VALUE_FLAGS_MASK 0xffff
enum {
/* This getValue call is inside libvirt, override the "private" flag.
@@ -993,9 +993,9 @@ int virRegisterInterfaceDriver(virInterfaceDriverPtr);
int virRegisterStorageDriver(virStorageDriverPtr);
int virRegisterDeviceMonitor(virDeviceMonitorPtr);
int virRegisterSecretDriver(virSecretDriverPtr);
-#ifdef WITH_LIBVIRTD
+# ifdef WITH_LIBVIRTD
int virRegisterStateDriver(virStateDriverPtr);
-#endif
+# endif
void *virDriverLoadModule(const char *name);
#endif /* __VIR_DRIVER_H__ */
diff --git a/src/esx/esx_device_monitor.h b/src/esx/esx_device_monitor.h
index e72a5b6..c19599e 100644
--- a/src/esx/esx_device_monitor.h
+++ b/src/esx/esx_device_monitor.h
@@ -22,7 +22,7 @@
*/
#ifndef __ESX_DEVICE_MONITOR_H__
-#define __ESX_DEVICE_MONITOR_H__
+# define __ESX_DEVICE_MONITOR_H__
int esxDeviceRegister(void);
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 0afbda4..c47af1c 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -99,8 +99,8 @@ esxSupportsLongMode(esxPrivate *priv)
for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo != NULL;
hostCpuIdInfo = hostCpuIdInfo->_next) {
if (hostCpuIdInfo->level->value == -2147483647) { /* 0x80000001 */
- #define _SKIP4 "%*c%*c%*c%*c"
- #define _SKIP12 _SKIP4":"_SKIP4":"_SKIP4
+#define _SKIP4 "%*c%*c%*c%*c"
+#define _SKIP12 _SKIP4":"_SKIP4":"_SKIP4
/* Expected format: "--X-:----:----:----:----:----:----:----" */
if (sscanf(hostCpuIdInfo->edx,
@@ -114,8 +114,8 @@ esxSupportsLongMode(esxPrivate *priv)
goto failure;
}
- #undef _SKIP4
- #undef _SKIP12
+#undef _SKIP4
+#undef _SKIP12
if (edxLongModeBit == '1') {
priv->supportsLongMode = esxVI_Boolean_True;
diff --git a/src/esx/esx_driver.h b/src/esx/esx_driver.h
index 6ecd5a7..bf382f4 100644
--- a/src/esx/esx_driver.h
+++ b/src/esx/esx_driver.h
@@ -22,7 +22,7 @@
*/
#ifndef __ESX_DRIVER_H__
-#define __ESX_DRIVER_H__
+# define __ESX_DRIVER_H__
int esxRegister(void);
diff --git a/src/esx/esx_interface_driver.h b/src/esx/esx_interface_driver.h
index d30641a..998cbb9 100644
--- a/src/esx/esx_interface_driver.h
+++ b/src/esx/esx_interface_driver.h
@@ -22,7 +22,7 @@
*/
#ifndef __ESX_INTERFACE_DRIVER_H__
-#define __ESX_INTERFACE_DRIVER_H__
+# define __ESX_INTERFACE_DRIVER_H__
int esxInterfaceRegister(void);
diff --git a/src/esx/esx_network_driver.h b/src/esx/esx_network_driver.h
index f117e03..fab5ac0 100644
--- a/src/esx/esx_network_driver.h
+++ b/src/esx/esx_network_driver.h
@@ -22,7 +22,7 @@
*/
#ifndef __ESX_NETWORK_DRIVER_H__
-#define __ESX_NETWORK_DRIVER_H__
+# define __ESX_NETWORK_DRIVER_H__
int esxNetworkRegister(void);
diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h
index 7a82ed6..df06129 100644
--- a/src/esx/esx_private.h
+++ b/src/esx/esx_private.h
@@ -21,11 +21,11 @@
*/
#ifndef __ESX_PRIVATE_H__
-#define __ESX_PRIVATE_H__
+# define __ESX_PRIVATE_H__
-#include "internal.h"
-#include "capabilities.h"
-#include "esx_vi.h"
+# include "internal.h"
+# include "capabilities.h"
+# include "esx_vi.h"
typedef struct _esxPrivate {
esxVI_Context *host;
diff --git a/src/esx/esx_secret_driver.h b/src/esx/esx_secret_driver.h
index c0d4a48..d49f3cb 100644
--- a/src/esx/esx_secret_driver.h
+++ b/src/esx/esx_secret_driver.h
@@ -21,7 +21,7 @@
*/
#ifndef __ESX_SECRET_DRIVER_H__
-#define __ESX_SECRET_DRIVER_H__
+# define __ESX_SECRET_DRIVER_H__
int esxSecretRegister(void);
diff --git a/src/esx/esx_storage_driver.h b/src/esx/esx_storage_driver.h
index 91a5d03..21098e9 100644
--- a/src/esx/esx_storage_driver.h
+++ b/src/esx/esx_storage_driver.h
@@ -22,7 +22,7 @@
*/
#ifndef __ESX_STORAGE_DRIVER_H__
-#define __ESX_STORAGE_DRIVER_H__
+# define __ESX_STORAGE_DRIVER_H__
int esxStorageRegister(void);
diff --git a/src/esx/esx_util.h b/src/esx/esx_util.h
index 6c6cbb0..b5cb419 100644
--- a/src/esx/esx_util.h
+++ b/src/esx/esx_util.h
@@ -21,12 +21,12 @@
*/
#ifndef __ESX_UTIL_H__
-#define __ESX_UTIL_H__
+# define __ESX_UTIL_H__
-#include <libxml/uri.h>
+# include <libxml/uri.h>
-#include "internal.h"
-#include "conf.h"
+# include "internal.h"
+# include "conf.h"
char *esxUtil_RequestUsername(virConnectAuthPtr auth,
const char *defaultUsername,
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 4e8b675..c45b91d 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -21,15 +21,15 @@
*/
#ifndef __ESX_VI_H__
-#define __ESX_VI_H__
+# define __ESX_VI_H__
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
-#include <curl/curl.h>
+# include <libxml/tree.h>
+# include <libxml/xpath.h>
+# include <curl/curl.h>
-#include "internal.h"
-#include "datatypes.h"
-#include "esx_vi_types.h"
+# include "internal.h"
+# include "datatypes.h"
+# include "esx_vi_types.h"
typedef enum _esxVI_APIVersion esxVI_APIVersion;
typedef enum _esxVI_ProductVersion esxVI_ProductVersion;
diff --git a/src/esx/esx_vi_methods.h b/src/esx/esx_vi_methods.h
index f84753d..54b0417 100644
--- a/src/esx/esx_vi_methods.h
+++ b/src/esx/esx_vi_methods.h
@@ -21,10 +21,10 @@
*/
#ifndef __ESX_VI_METHODS_H__
-#define __ESX_VI_METHODS_H__
+# define __ESX_VI_METHODS_H__
-#include "esx_vi.h"
-#include "esx_vi_types.h"
+# include "esx_vi.h"
+# include "esx_vi_types.h"
diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index 958b901..dd0b763 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -628,7 +628,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
}
}
- #define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \
+#define _DESERIALIZE_NUMBER(_type, _xsdType, _name, _min, _max) \
do { \
if (virStrToLong_ll((*anyType)->value, NULL, 10, &number) < 0) { \
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, \
@@ -672,7 +672,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType)
_DESERIALIZE_NUMBER(Long, "xsd:long", int64, INT64_MIN, INT64_MAX);
}
- #undef _DESERIALIZE_NUMBER
+#undef _DESERIALIZE_NUMBER
return 0;
diff --git a/src/esx/esx_vi_types.h b/src/esx/esx_vi_types.h
index d0ec489..9a43241 100644
--- a/src/esx/esx_vi_types.h
+++ b/src/esx/esx_vi_types.h
@@ -21,9 +21,9 @@
*/
#ifndef __ESX_VI_TYPES_H__
-#define __ESX_VI_TYPES_H__
+# define __ESX_VI_TYPES_H__
-#include "buf.h"
+# include "buf.h"
diff --git a/src/esx/esx_vmx.h b/src/esx/esx_vmx.h
index 6193409..bff3688 100644
--- a/src/esx/esx_vmx.h
+++ b/src/esx/esx_vmx.h
@@ -21,12 +21,12 @@
*/
#ifndef __ESX_VMX_H__
-#define __ESX_VMX_H__
+# define __ESX_VMX_H__
-#include "internal.h"
-#include "conf.h"
-#include "domain_conf.h"
-#include "esx_vi.h"
+# include "internal.h"
+# include "conf.h"
+# include "domain_conf.h"
+# include "esx_vi.h"
int
esxVMX_SCSIDiskNameToControllerAndID(const char *name, int *controller, int *id);
diff --git a/src/gnutls_1_0_compat.h b/src/gnutls_1_0_compat.h
index 38f6954..fb423f1 100644
--- a/src/gnutls_1_0_compat.h
+++ b/src/gnutls_1_0_compat.h
@@ -22,16 +22,16 @@
#ifndef LIBVIRT_GNUTLS_1_0_COMPAT_H__
-#include <config.h>
+# include <config.h>
-#ifdef GNUTLS_1_0_COMPAT
-#define gnutls_session_t gnutls_session
-#define gnutls_x509_crt_t gnutls_x509_crt
-#define gnutls_dh_params_t gnutls_dh_params
-#define gnutls_transport_ptr_t gnutls_transport_ptr
-#define gnutls_datum_t gnutls_datum
-#define gnutls_certificate_credentials_t gnutls_certificate_credentials
-#define gnutls_cipher_algorithm_t gnutls_cipher_algorithm
-#endif
+# ifdef GNUTLS_1_0_COMPAT
+# define gnutls_session_t gnutls_session
+# define gnutls_x509_crt_t gnutls_x509_crt
+# define gnutls_dh_params_t gnutls_dh_params
+# define gnutls_transport_ptr_t gnutls_transport_ptr
+# define gnutls_datum_t gnutls_datum
+# define gnutls_certificate_credentials_t gnutls_certificate_credentials
+# define gnutls_cipher_algorithm_t gnutls_cipher_algorithm
+# endif
#endif /* LIBVIRT_GNUTLS_1_0_COMPAT_H__ */
diff --git a/src/interface/netcf_driver.h b/src/interface/netcf_driver.h
index b4ace5b..eb3a55d 100644
--- a/src/interface/netcf_driver.h
+++ b/src/interface/netcf_driver.h
@@ -22,7 +22,7 @@
#ifndef __VIR_INTERFACE__DRIVER_H
-#define __VIR_INTERFACE__DRIVER_H
+# define __VIR_INTERFACE__DRIVER_H
int interfaceRegister(void);
diff --git a/src/internal.h b/src/internal.h
index 6e06f66..4ec6edc 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -3,28 +3,28 @@
*/
#ifndef __VIR_INTERNAL_H__
-#define __VIR_INTERNAL_H__
+# define __VIR_INTERNAL_H__
-#include <errno.h>
-#include <limits.h>
-#include <verify.h>
+# include <errno.h>
+# include <limits.h>
+# include <verify.h>
-#ifdef HAVE_SYS_SYSLIMITS_H
-#include <sys/syslimits.h>
-#endif
+# ifdef HAVE_SYS_SYSLIMITS_H
+# include <sys/syslimits.h>
+# endif
/* The library itself is allowed to use deprecated functions /
* variables, so effectively undefine the deprecated attribute
* which would otherwise be defined in libvirt.h.
*/
-#define VIR_DEPRECATED /*empty*/
+# define VIR_DEPRECATED /*empty*/
-#include "gettext.h"
+# include "gettext.h"
-#include "libvirt/libvirt.h"
-#include "libvirt/virterror.h"
+# include "libvirt/libvirt.h"
+# include "libvirt/virterror.h"
-#include "libvirt_internal.h"
+# include "libvirt_internal.h"
/* On architectures which lack these limits, define them (ie. Cygwin).
* Note that the libvirt code should be robust enough to handle the
@@ -32,78 +32,78 @@
* length correctly in second argument to gethostname and by always
* using strncpy instead of strcpy).
*/
-#ifndef HOST_NAME_MAX
-#define HOST_NAME_MAX 256
-#endif
+# ifndef HOST_NAME_MAX
+# define HOST_NAME_MAX 256
+# endif
-#ifndef IF_NAMESIZE
-#define IF_NAMESIZE 16
-#endif
+# ifndef IF_NAMESIZE
+# define IF_NAMESIZE 16
+# endif
-#ifndef INET_ADDRSTRLEN
-#define INET_ADDRSTRLEN 16
-#endif
+# ifndef INET_ADDRSTRLEN
+# define INET_ADDRSTRLEN 16
+# endif
-#define _(str) dgettext(GETTEXT_PACKAGE, (str))
-#define N_(str) str
+# define _(str) dgettext(GETTEXT_PACKAGE, (str))
+# define N_(str) str
/* String equality tests, suggested by Jim Meyering. */
-#define STREQ(a,b) (strcmp(a,b) == 0)
-#define STRCASEEQ(a,b) (strcasecmp(a,b) == 0)
-#define STRNEQ(a,b) (strcmp(a,b) != 0)
-#define STRCASENEQ(a,b) (strcasecmp(a,b) != 0)
-#define STREQLEN(a,b,n) (strncmp(a,b,n) == 0)
-#define STRCASEEQLEN(a,b,n) (strncasecmp(a,b,n) == 0)
-#define STRNEQLEN(a,b,n) (strncmp(a,b,n) != 0)
-#define STRCASENEQLEN(a,b,n) (strncasecmp(a,b,n) != 0)
-#define STRPREFIX(a,b) (strncmp(a,b,strlen(b)) == 0)
-
-#define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
-#define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
+# define STREQ(a,b) (strcmp(a,b) == 0)
+# define STRCASEEQ(a,b) (strcasecmp(a,b) == 0)
+# define STRNEQ(a,b) (strcmp(a,b) != 0)
+# define STRCASENEQ(a,b) (strcasecmp(a,b) != 0)
+# define STREQLEN(a,b,n) (strncmp(a,b,n) == 0)
+# define STRCASEEQLEN(a,b,n) (strncasecmp(a,b,n) == 0)
+# define STRNEQLEN(a,b,n) (strncmp(a,b,n) != 0)
+# define STRCASENEQLEN(a,b,n) (strncasecmp(a,b,n) != 0)
+# define STRPREFIX(a,b) (strncmp(a,b,strlen(b)) == 0)
+
+# define NUL_TERMINATE(buf) do { (buf)[sizeof(buf)-1] = '\0'; } while (0)
+# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array))
/* C99 uses __func__. __FUNCTION__ is legacy. */
-#ifndef __GNUC__
-#define __FUNCTION__ __func__
-#endif
+# ifndef __GNUC__
+# define __FUNCTION__ __func__
+# endif
-#ifdef __GNUC__
+# ifdef __GNUC__
-#ifndef __GNUC_PREREQ
-#if defined __GNUC__ && defined __GNUC_MINOR__
-# define __GNUC_PREREQ(maj, min) \
+# ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
-#else
-#define __GNUC_PREREQ(maj,min) 0
-#endif
+# else
+# define __GNUC_PREREQ(maj,min) 0
+# endif
/* Work around broken limits.h on debian etch */
-#if defined _GCC_LIMITS_H_ && ! defined ULLONG_MAX
-#define ULLONG_MAX ULONG_LONG_MAX
-#endif
+# if defined _GCC_LIMITS_H_ && ! defined ULLONG_MAX
+# define ULLONG_MAX ULONG_LONG_MAX
+# endif
-#endif /* __GNUC__ */
+# endif /* __GNUC__ */
/**
* ATTRIBUTE_UNUSED:
*
* Macro to flag conciously unused parameters to functions
*/
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((__unused__))
-#endif
+# ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__((__unused__))
+# endif
/**
* ATTRIBUTE_SENTINEL:
*
* Macro to check for NULL-terminated varargs lists
*/
-#ifndef ATTRIBUTE_SENTINEL
-#if __GNUC_PREREQ (4, 0)
-#define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
-#else
-#define ATTRIBUTE_SENTINEL
-#endif
-#endif
+# ifndef ATTRIBUTE_SENTINEL
+# if __GNUC_PREREQ (4, 0)
+# define ATTRIBUTE_SENTINEL __attribute__((__sentinel__))
+# else
+# define ATTRIBUTE_SENTINEL
+# endif
+# endif
/**
* ATTRIBUTE_FMT_PRINTF
@@ -115,46 +115,46 @@
* printf format specifiers even on broken Win32 platforms
* hence we have to force 'gnu_printf' for new GCC
*/
-#ifndef ATTRIBUTE_FMT_PRINTF
-#if __GNUC_PREREQ (4, 4)
-#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
-#else
-#define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
-#endif
-#endif
-
-#ifndef ATTRIBUTE_RETURN_CHECK
-#if __GNUC_PREREQ (3, 4)
-#define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
-#else
-#define ATTRIBUTE_RETURN_CHECK
-#endif
-#endif
-
-#ifndef ATTRIBUTE_NONNULL
-# if __GNUC_PREREQ (3, 3)
-# define ATTRIBUTE_NONNULL(m) __attribute__((__nonnull__(m)))
+# ifndef ATTRIBUTE_FMT_PRINTF
+# if __GNUC_PREREQ (4, 4)
+# define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (gnu_printf, fmtpos,argpos)))
+# else
+# define ATTRIBUTE_FMT_PRINTF(fmtpos,argpos) __attribute__((__format__ (printf, fmtpos,argpos)))
+# endif
+# endif
+
+# ifndef ATTRIBUTE_RETURN_CHECK
+# if __GNUC_PREREQ (3, 4)
+# define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+# else
+# define ATTRIBUTE_RETURN_CHECK
+# endif
+# endif
+
+# ifndef ATTRIBUTE_NONNULL
+# if __GNUC_PREREQ (3, 3)
+# define ATTRIBUTE_NONNULL(m) __attribute__((__nonnull__(m)))
+# else
+# define ATTRIBUTE_NONNULL(m)
+# endif
+# endif
+
# else
-# define ATTRIBUTE_NONNULL(m)
-# endif
-#endif
-
-#else
-#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED
-#endif
-#ifndef ATTRIBUTE_FMT_PRINTF
-#define ATTRIBUTE_FMT_PRINTF(...)
-#endif
-#ifndef ATTRIBUTE_RETURN_CHECK
-#define ATTRIBUTE_RETURN_CHECK
-#endif
-#endif /* __GNUC__ */
+# ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED
+# endif
+# ifndef ATTRIBUTE_FMT_PRINTF
+# define ATTRIBUTE_FMT_PRINTF(...)
+# endif
+# ifndef ATTRIBUTE_RETURN_CHECK
+# define ATTRIBUTE_RETURN_CHECK
+# endif
+# endif /* __GNUC__ */
/*
* Use this when passing possibly-NULL strings to printf-a-likes.
*/
-#define NULLSTR(s) \
+# define NULLSTR(s) \
((void)verify_true(sizeof *(s) == sizeof (char)), \
(s) ? (s) : "(null)")
@@ -163,7 +163,7 @@
*
* macro to flag unimplemented blocks
*/
-#define TODO \
+# define TODO \
fprintf(stderr, "Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
diff --git a/src/libvirt.c b/src/libvirt.c
index 7f7a28c..935ec3a 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -19,7 +19,7 @@
#include <unistd.h>
#include <assert.h>
#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#include <time.h>
#include <gcrypt.h>
@@ -30,7 +30,7 @@
#include "getpass.h"
#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
+# include <winsock2.h>
#endif
#include "virterror_internal.h"
@@ -43,27 +43,27 @@
#include "memory.h"
#ifndef WITH_DRIVER_MODULES
-#ifdef WITH_TEST
-#include "test/test_driver.h"
-#endif
-#ifdef WITH_XEN
-#include "xen/xen_driver.h"
-#endif
-#ifdef WITH_REMOTE
-#include "remote/remote_driver.h"
-#endif
-#ifdef WITH_OPENVZ
-#include "openvz/openvz_driver.h"
-#endif
-#ifdef WITH_PHYP
-#include "phyp/phyp_driver.h"
-#endif
-#ifdef WITH_VBOX
-#include "vbox/vbox_driver.h"
-#endif
-#ifdef WITH_ESX
-#include "esx/esx_driver.h"
-#endif
+# ifdef WITH_TEST
+# include "test/test_driver.h"
+# endif
+# ifdef WITH_XEN
+# include "xen/xen_driver.h"
+# endif
+# ifdef WITH_REMOTE
+# include "remote/remote_driver.h"
+# endif
+# ifdef WITH_OPENVZ
+# include "openvz/openvz_driver.h"
+# endif
+# ifdef WITH_PHYP
+# include "phyp/phyp_driver.h"
+# endif
+# ifdef WITH_VBOX
+# include "vbox/vbox_driver.h"
+# endif
+# ifdef WITH_ESX
+# include "esx/esx_driver.h"
+# endif
#endif
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -359,27 +359,27 @@ virInitialize(void)
virDriverLoadModule("esx");
virDriverLoadModule("remote");
#else
-#ifdef WITH_TEST
+# ifdef WITH_TEST
if (testRegister() == -1) return -1;
-#endif
-#ifdef WITH_XEN
+# endif
+# ifdef WITH_XEN
if (xenRegister () == -1) return -1;
-#endif
-#ifdef WITH_OPENVZ
+# endif
+# ifdef WITH_OPENVZ
if (openvzRegister() == -1) return -1;
-#endif
-#ifdef WITH_PHYP
+# endif
+# ifdef WITH_PHYP
if (phypRegister() == -1) return -1;
-#endif
-#ifdef WITH_VBOX
+# endif
+# ifdef WITH_VBOX
if (vboxRegister() == -1) return -1;
-#endif
-#ifdef WITH_ESX
+# endif
+# ifdef WITH_ESX
if (esxRegister() == -1) return -1;
-#endif
-#ifdef WITH_REMOTE
+# endif
+# ifdef WITH_REMOTE
if (remoteRegister () == -1) return -1;
-#endif
+# endif
#endif
return(0);
@@ -991,50 +991,50 @@ virGetVersion(unsigned long *libVer, const char *type,
#else
*typeVer = 0;
-#if WITH_XEN
+# if WITH_XEN
if (STRCASEEQ(type, "Xen"))
*typeVer = xenUnifiedVersion();
-#endif
-#if WITH_TEST
+# endif
+# if WITH_TEST
if (STRCASEEQ(type, "Test"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_QEMU
+# endif
+# if WITH_QEMU
if (STRCASEEQ(type, "QEMU"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_LXC
+# endif
+# if WITH_LXC
if (STRCASEEQ(type, "LXC"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_PHYP
+# endif
+# if WITH_PHYP
if (STRCASEEQ(type, "phyp"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_OPENVZ
+# endif
+# if WITH_OPENVZ
if (STRCASEEQ(type, "OpenVZ"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_VBOX
+# endif
+# if WITH_VBOX
if (STRCASEEQ(type, "VBox"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_UML
+# endif
+# if WITH_UML
if (STRCASEEQ(type, "UML"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_ONE
+# endif
+# if WITH_ONE
if (STRCASEEQ(type, "ONE"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_ESX
+# endif
+# if WITH_ESX
if (STRCASEEQ(type, "ESX"))
*typeVer = LIBVIR_VERSION_NUMBER;
-#endif
-#if WITH_REMOTE
+# endif
+# if WITH_REMOTE
if (STRCASEEQ(type, "Remote"))
*typeVer = remoteVersion();
-#endif
+# endif
if (*typeVer == 0) {
virLibConnError(NULL, VIR_ERR_NO_SUPPORT, type);
goto error;
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 2ee09e9..1c4fa4f 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -23,16 +23,16 @@
*/
#ifndef __LIBVIRT_H_
-#define __LIBVIRT_H_
+# define __LIBVIRT_H_
-#include "internal.h"
+# include "internal.h"
-#ifdef WITH_LIBVIRTD
+# ifdef WITH_LIBVIRTD
int virStateInitialize(int privileged);
int virStateCleanup(void);
int virStateReload(void);
int virStateActive(void);
-#endif
+# endif
/* Feature detection. This is a libvirt-private interface for determining
* what features are supported by the driver.
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index 5cdf673..e4c2c52 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -23,21 +23,21 @@
*/
#ifndef LXC_CONF_H
-#define LXC_CONF_H
+# define LXC_CONF_H
-#include <config.h>
+# include <config.h>
-#include "internal.h"
-#include "domain_conf.h"
-#include "domain_event.h"
-#include "capabilities.h"
-#include "threads.h"
-#include "cgroup.h"
+# include "internal.h"
+# include "domain_conf.h"
+# include "domain_event.h"
+# include "capabilities.h"
+# include "threads.h"
+# include "cgroup.h"
-#define LXC_CONFIG_DIR SYSCONF_DIR "/libvirt/lxc"
-#define LXC_STATE_DIR LOCAL_STATE_DIR "/run/libvirt/lxc"
-#define LXC_LOG_DIR LOCAL_STATE_DIR "/log/libvirt/lxc"
-#define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
+# define LXC_CONFIG_DIR SYSCONF_DIR "/libvirt/lxc"
+# define LXC_STATE_DIR LOCAL_STATE_DIR "/run/libvirt/lxc"
+# define LXC_LOG_DIR LOCAL_STATE_DIR "/log/libvirt/lxc"
+# define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
typedef struct __lxc_driver lxc_driver_t;
struct __lxc_driver {
@@ -64,7 +64,7 @@ struct __lxc_driver {
int lxcLoadDriverConfig(lxc_driver_t *driver);
virCapsPtr lxcCapsInit(void);
-#define lxcError(code, ...) \
+# define lxcError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_LXC, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index b1e895d..68b4656 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -43,7 +43,7 @@
#include <linux/fs.h>
#if HAVE_CAPNG
-#include <cap-ng.h>
+# include <cap-ng.h>
#endif
#include "virterror_internal.h"
@@ -61,19 +61,19 @@
*/
#ifndef CLONE_NEWPID
-#define CLONE_NEWPID 0x20000000
+# define CLONE_NEWPID 0x20000000
#endif
#ifndef CLONE_NEWUTS
-#define CLONE_NEWUTS 0x04000000
+# define CLONE_NEWUTS 0x04000000
#endif
#ifndef CLONE_NEWUSER
-#define CLONE_NEWUSER 0x10000000
+# define CLONE_NEWUSER 0x10000000
#endif
#ifndef CLONE_NEWIPC
-#define CLONE_NEWIPC 0x08000000
+# define CLONE_NEWIPC 0x08000000
#endif
#ifndef CLONE_NEWNET
-#define CLONE_NEWNET 0x40000000 /* New network namespace */
+# define CLONE_NEWNET 0x40000000 /* New network namespace */
#endif
/* messages between parent and container */
@@ -289,19 +289,19 @@ static int lxcContainerChildMountSort(const void *a, const void *b)
}
#ifndef MS_REC
-#define MS_REC 16384
+# define MS_REC 16384
#endif
#ifndef MNT_DETACH
-#define MNT_DETACH 0x00000002
+# define MNT_DETACH 0x00000002
#endif
#ifndef MS_PRIVATE
-#define MS_PRIVATE (1<<18)
+# define MS_PRIVATE (1<<18)
#endif
#ifndef MS_SLAVE
-#define MS_SLAVE (1<<19)
+# define MS_SLAVE (1<<19)
#endif
static int lxcContainerPivotRoot(virDomainFSDefPtr root)
diff --git a/src/lxc/lxc_container.h b/src/lxc/lxc_container.h
index 9e15642..75c8836 100644
--- a/src/lxc/lxc_container.h
+++ b/src/lxc/lxc_container.h
@@ -22,28 +22,28 @@
*/
#ifndef LXC_CONTAINER_H
-#define LXC_CONTAINER_H
+# define LXC_CONTAINER_H
-#include "lxc_conf.h"
+# include "lxc_conf.h"
enum {
LXC_CONTAINER_FEATURE_NET = (1 << 0),
LXC_CONTAINER_FEATURE_USER = (1 << 1),
};
-#define LXC_DEV_MAJ_MEMORY 1
-#define LXC_DEV_MIN_NULL 3
-#define LXC_DEV_MIN_ZERO 5
-#define LXC_DEV_MIN_FULL 7
-#define LXC_DEV_MIN_RANDOM 8
-#define LXC_DEV_MIN_URANDOM 9
+# define LXC_DEV_MAJ_MEMORY 1
+# define LXC_DEV_MIN_NULL 3
+# define LXC_DEV_MIN_ZERO 5
+# define LXC_DEV_MIN_FULL 7
+# define LXC_DEV_MIN_RANDOM 8
+# define LXC_DEV_MIN_URANDOM 9
-#define LXC_DEV_MAJ_TTY 5
-#define LXC_DEV_MIN_TTY 0
-#define LXC_DEV_MIN_CONSOLE 1
-#define LXC_DEV_MIN_PTMX 2
+# define LXC_DEV_MAJ_TTY 5
+# define LXC_DEV_MIN_TTY 0
+# define LXC_DEV_MIN_CONSOLE 1
+# define LXC_DEV_MIN_PTMX 2
-#define LXC_DEV_MAJ_PTY 136
+# define LXC_DEV_MAJ_PTY 136
int lxcContainerSendContinue(int control);
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index f8fcd95..f016871 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -37,7 +37,7 @@
#include <sys/mount.h>
#if HAVE_CAPNG
-#include <cap-ng.h>
+# include <cap-ng.h>
#endif
#include "virterror_internal.h"
@@ -491,11 +491,11 @@ static int lxcControllerCleanupInterfaces(unsigned int nveths,
}
#ifndef MS_REC
-#define MS_REC 16384
+# define MS_REC 16384
#endif
#ifndef MS_SLAVE
-#define MS_SLAVE (1<<19)
+# define MS_SLAVE (1<<19)
#endif
static int
diff --git a/src/lxc/lxc_driver.h b/src/lxc/lxc_driver.h
index 1bb4753..7864fd0 100644
--- a/src/lxc/lxc_driver.h
+++ b/src/lxc/lxc_driver.h
@@ -22,9 +22,9 @@
*/
#ifndef LXC_DRIVER_H
-#define LXC_DRIVER_H
+# define LXC_DRIVER_H
-#include <config.h>
+# include <config.h>
/* Function declarations */
int lxcRegister(void);
diff --git a/src/lxc/veth.h b/src/lxc/veth.h
index 8075a5e..523bf9c 100644
--- a/src/lxc/veth.h
+++ b/src/lxc/veth.h
@@ -10,9 +10,9 @@
*/
#ifndef VETH_H
-#define VETH_H
+# define VETH_H
-#include <config.h>
+# include <config.h>
/* Function declarations */
int vethCreate(char* veth1, int veth1MaxLen, char* veth2,
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 5951833..32d2ae7 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -23,11 +23,11 @@
#ifndef __VIR_NETWORK__DRIVER_H
-#define __VIR_NETWORK__DRIVER_H
+# define __VIR_NETWORK__DRIVER_H
-#include <config.h>
+# include <config.h>
-#include "internal.h"
+# include "internal.h"
int networkRegister(void);
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index b9f6d17..b0ea986 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -662,11 +662,11 @@ int nodedevRegister(void) {
return udevNodeRegister();
return 0;
#else
-#ifdef HAVE_HAL
+# ifdef HAVE_HAL
return halNodeRegister();
-#endif
-#ifdef HAVE_UDEV
+# endif
+# ifdef HAVE_UDEV
return udevNodeRegister();
-#endif
+# endif
#endif
}
diff --git a/src/node_device/node_device_driver.h b/src/node_device/node_device_driver.h
index 7b68f41..f233641 100644
--- a/src/node_device/node_device_driver.h
+++ b/src/node_device/node_device_driver.h
@@ -22,33 +22,33 @@
*/
#ifndef __VIR_NODE_DEVICE_H__
-#define __VIR_NODE_DEVICE_H__
+# define __VIR_NODE_DEVICE_H__
-#include "internal.h"
-#include "driver.h"
-#include "node_device_conf.h"
+# include "internal.h"
+# include "driver.h"
+# include "node_device_conf.h"
-#define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host"
-#define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
-#define LINUX_SYSFS_FC_HOST_PREFIX "/sys/class/fc_host/"
+# define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host"
+# define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
+# define LINUX_SYSFS_FC_HOST_PREFIX "/sys/class/fc_host/"
-#define VPORT_CREATE 0
-#define VPORT_DELETE 1
-#define LINUX_SYSFS_VPORT_CREATE_POSTFIX "/vport_create"
-#define LINUX_SYSFS_VPORT_DELETE_POSTFIX "/vport_delete"
+# define VPORT_CREATE 0
+# define VPORT_DELETE 1
+# define LINUX_SYSFS_VPORT_CREATE_POSTFIX "/vport_create"
+# define LINUX_SYSFS_VPORT_DELETE_POSTFIX "/vport_delete"
-#define SRIOV_FOUND 0
-#define SRIOV_NOT_FOUND 1
-#define SRIOV_ERROR -1
+# define SRIOV_FOUND 0
+# define SRIOV_NOT_FOUND 1
+# define SRIOV_ERROR -1
-#define LINUX_NEW_DEVICE_WAIT_TIME 60
+# define LINUX_NEW_DEVICE_WAIT_TIME 60
-#ifdef HAVE_HAL
+# ifdef HAVE_HAL
int halNodeRegister(void);
-#endif
-#ifdef HAVE_UDEV
+# endif
+# ifdef HAVE_UDEV
int udevNodeRegister(void);
-#endif
+# endif
void nodeDeviceLock(virDeviceMonitorStatePtr driver);
void nodeDeviceUnlock(virDeviceMonitorStatePtr driver);
@@ -57,33 +57,33 @@ void registerCommonNodeFuncs(virDeviceMonitorPtr mon);
int nodedevRegister(void);
-#ifdef __linux__
+# ifdef __linux__
-#define check_fc_host(d) check_fc_host_linux(d)
+# define check_fc_host(d) check_fc_host_linux(d)
int check_fc_host_linux(union _virNodeDevCapData *d);
-#define check_vport_capable(d) check_vport_capable_linux(d)
+# define check_vport_capable(d) check_vport_capable_linux(d)
int check_vport_capable_linux(union _virNodeDevCapData *d);
-#define get_physical_function(s,d) get_physical_function_linux(s,d)
+# define get_physical_function(s,d) get_physical_function_linux(s,d)
int get_physical_function_linux(const char *sysfs_path,
union _virNodeDevCapData *d);
-#define get_virtual_functions(s,d) get_virtual_functions_linux(s,d)
+# define get_virtual_functions(s,d) get_virtual_functions_linux(s,d)
int get_virtual_functions_linux(const char *sysfs_path,
union _virNodeDevCapData *d);
-#define read_wwn(host, file, wwn) read_wwn_linux(host, file, wwn)
+# define read_wwn(host, file, wwn) read_wwn_linux(host, file, wwn)
int read_wwn_linux(int host, const char *file, char **wwn);
-#else /* __linux__ */
+# else /* __linux__ */
-#define check_fc_host(d)
-#define check_vport_capable(d)
-#define get_physical_function(sysfs_path, d)
-#define get_virtual_functions(sysfs_path, d)
-#define read_wwn(host, file, wwn)
+# define check_fc_host(d)
+# define check_vport_capable(d)
+# define get_physical_function(sysfs_path, d)
+# define get_virtual_functions(sysfs_path, d)
+# define read_wwn(host, file, wwn)
-#endif /* __linux__ */
+# endif /* __linux__ */
#endif /* __VIR_NODE_DEVICE_H__ */
diff --git a/src/node_device/node_device_hal.h b/src/node_device/node_device_hal.h
index 8ac8a35..3cb22a6 100644
--- a/src/node_device/node_device_hal.h
+++ b/src/node_device/node_device_hal.h
@@ -20,6 +20,6 @@
*/
#ifndef __VIR_NODE_DEVICE_HAL_H__
-#define __VIR_NODE_DEVICE_HAL_H__
+# define __VIR_NODE_DEVICE_HAL_H__
#endif /* __VIR_NODE_DEVICE_HAL_H__ */
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2dab5b2..510c965 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -36,7 +36,7 @@
#endif
#ifdef HAVE_SYS_UTSNAME_H
-#include <sys/utsname.h>
+# include <sys/utsname.h>
#endif
#include "c-ctype.h"
@@ -56,8 +56,8 @@
__FUNCTION__, __LINE__, __VA_ARGS__)
#ifdef __linux__
-#define CPUINFO_PATH "/proc/cpuinfo"
-#define CPU_SYS_PATH "/sys/devices/system/cpu"
+# define CPUINFO_PATH "/proc/cpuinfo"
+# define CPU_SYS_PATH "/sys/devices/system/cpu"
/* NB, this is not static as we need to call it from the testsuite */
int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index 7278121..88bac6c 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -22,10 +22,10 @@
*/
#ifndef __VIR_NODEINFO_H__
-#define __VIR_NODEINFO_H__
+# define __VIR_NODEINFO_H__
-#include "libvirt/libvirt.h"
-#include "capabilities.h"
+# include "libvirt/libvirt.h"
+# include "capabilities.h"
int nodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo);
int nodeCapsInitNUMA(virCapsPtr caps);
diff --git a/src/opennebula/one_client.h b/src/opennebula/one_client.h
index 7d5d840..e94956d 100644
--- a/src/opennebula/one_client.h
+++ b/src/opennebula/one_client.h
@@ -17,10 +17,10 @@
*/
#ifndef ONE_CLIENT_H_
-#define ONE_CLIENT_H_
+# define ONE_CLIENT_H_
-#include <xmlrpc-c/base.h>
-#include <xmlrpc-c/client.h>
+# include <xmlrpc-c/base.h>
+# include <xmlrpc-c/client.h>
struct _oneClient {
xmlrpc_env env;
diff --git a/src/opennebula/one_conf.h b/src/opennebula/one_conf.h
index 5f24e2b..0d45bff 100644
--- a/src/opennebula/one_conf.h
+++ b/src/opennebula/one_conf.h
@@ -21,15 +21,15 @@
/*-----------------------------------------------------------------------------------*/
#ifndef ONE_CONF_H
-#define ONE_CONF_H
+# define ONE_CONF_H
-#include <config.h>
+# include <config.h>
-#include "internal.h"
-#include "domain_conf.h"
-#include "capabilities.h"
-#include "threads.h"
-#include "one_client.h"
+# include "internal.h"
+# include "domain_conf.h"
+# include "capabilities.h"
+# include "threads.h"
+# include "one_client.h"
struct one_driver{
virMutex lock;
@@ -47,7 +47,7 @@ int oneSubmitVM(virConnectPtr conn ,one_driver_t* driver, virDomainObjPtr vm);
char* xmlOneTemplate(virDomainDefPtr def);
-#define oneError(conn, dom, code, ...) \
+# define oneError(conn, dom, code, ...) \
virReportErrorHelper(conn, VIR_FROM_ONE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/opennebula/one_driver.h b/src/opennebula/one_driver.h
index e30a59f..6cc1f46 100644
--- a/src/opennebula/one_driver.h
+++ b/src/opennebula/one_driver.h
@@ -20,10 +20,10 @@
#ifndef ONE_DRIVER_H
-#define ONE_DRIVER_H
+# define ONE_DRIVER_H
-#include <config.h>
-#include "one_client.h"
+# include <config.h>
+# include "one_client.h"
int oneRegister(void);
diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h
index fc5966b..8ce4fe2 100644
--- a/src/openvz/openvz_conf.h
+++ b/src/openvz/openvz_conf.h
@@ -27,25 +27,25 @@
*/
#ifndef OPENVZ_CONF_H
-#define OPENVZ_CONF_H
+# define OPENVZ_CONF_H
-#include "internal.h"
-#include "domain_conf.h"
-#include "threads.h"
+# include "internal.h"
+# include "domain_conf.h"
+# include "threads.h"
enum { OPENVZ_WARN, OPENVZ_ERR };
-#define openvzError(conn, code, ...) \
+# define openvzError(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_OPENVZ, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
/* OpenVZ commands - Replace with wrapper scripts later? */
-#define VZLIST "/usr/sbin/vzlist"
-#define VZCTL "/usr/sbin/vzctl"
-#define VZ_CONF_FILE "/etc/vz/vz.conf"
+# define VZLIST "/usr/sbin/vzlist"
+# define VZCTL "/usr/sbin/vzctl"
+# define VZ_CONF_FILE "/etc/vz/vz.conf"
-#define VZCTL_BRIDGE_MIN_VERSION ((3 * 1000 * 1000) + (0 * 1000) + 22 + 1)
+# define VZCTL_BRIDGE_MIN_VERSION ((3 * 1000 * 1000) + (0 * 1000) + 22 + 1)
struct openvz_driver {
virMutex lock;
diff --git a/src/openvz/openvz_driver.h b/src/openvz/openvz_driver.h
index d6e77fe..5be9ce7 100644
--- a/src/openvz/openvz_driver.h
+++ b/src/openvz/openvz_driver.h
@@ -27,9 +27,9 @@
#ifndef OPENVZ_DRIVER_H
-#define OPENVZ_DRIVER_H
+# define OPENVZ_DRIVER_H
-#include "internal.h"
+# include "internal.h"
int openvzRegister(void);
diff --git a/src/qemu/qemu_bridge_filter.h b/src/qemu/qemu_bridge_filter.h
index 23937f1..c0678ec 100644
--- a/src/qemu/qemu_bridge_filter.h
+++ b/src/qemu/qemu_bridge_filter.h
@@ -21,7 +21,7 @@
*/
#ifndef __QEMUD_BRIDGE_FILTER_H__
-#define __QEMUD_BRIDGE_FILTER_H__
+# define __QEMUD_BRIDGE_FILTER_H__
int networkAllowMacOnPort(struct qemud_driver *driver,
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 1134f62..6a9de5e 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -22,27 +22,27 @@
*/
#ifndef __QEMUD_CONF_H
-#define __QEMUD_CONF_H
+# define __QEMUD_CONF_H
-#include <config.h>
+# include <config.h>
-#include "ebtables.h"
-#include "internal.h"
-#include "bridge.h"
-#include "capabilities.h"
-#include "network_conf.h"
-#include "domain_conf.h"
-#include "domain_event.h"
-#include "threads.h"
-#include "security/security_driver.h"
-#include "cgroup.h"
-#include "pci.h"
-#include "cpu_conf.h"
-#include "driver.h"
+# include "ebtables.h"
+# include "internal.h"
+# include "bridge.h"
+# include "capabilities.h"
+# include "network_conf.h"
+# include "domain_conf.h"
+# include "domain_event.h"
+# include "threads.h"
+# include "security/security_driver.h"
+# include "cgroup.h"
+# include "pci.h"
+# include "cpu_conf.h"
+# include "driver.h"
-#define qemudDebug(fmt, ...) do {} while(0)
+# define qemudDebug(fmt, ...) do {} while(0)
-#define QEMUD_CPUMASK_LEN CPU_SETSIZE
+# define QEMUD_CPUMASK_LEN CPU_SETSIZE
/* Internal flags to keep track of qemu command line capabilities */
enum qemud_cmd_flags {
@@ -152,16 +152,16 @@ typedef struct _qemuDomainPCIAddressSet qemuDomainPCIAddressSet;
typedef qemuDomainPCIAddressSet *qemuDomainPCIAddressSetPtr;
/* Port numbers used for KVM migration. */
-#define QEMUD_MIGRATION_FIRST_PORT 49152
-#define QEMUD_MIGRATION_NUM_PORTS 64
+# define QEMUD_MIGRATION_FIRST_PORT 49152
+# define QEMUD_MIGRATION_NUM_PORTS 64
/* Config type for XML import/export conversions */
-#define QEMU_CONFIG_FORMAT_ARGV "qemu-argv"
+# define QEMU_CONFIG_FORMAT_ARGV "qemu-argv"
-#define QEMU_DRIVE_HOST_PREFIX "drive-"
-#define QEMU_VIRTIO_SERIAL_PREFIX "virtio-serial"
+# define QEMU_DRIVE_HOST_PREFIX "drive-"
+# define QEMU_VIRTIO_SERIAL_PREFIX "virtio-serial"
-#define qemuReportError(code, ...) \
+# define qemuReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_QEMU, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 57f3b2c..e360dae 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -48,10 +48,10 @@
#include <sys/un.h>
#ifdef __linux__
-#include <sys/vfs.h>
-#ifndef NFS_SUPER_MAGIC
-#define NFS_SUPER_MAGIC 0x6969
-#endif /* NFS_SUPER_MAGIC */
+# include <sys/vfs.h>
+# ifndef NFS_SUPER_MAGIC
+# define NFS_SUPER_MAGIC 0x6969
+# endif /* NFS_SUPER_MAGIC */
#endif /* __linux__ */
#include "virterror_internal.h"
diff --git a/src/qemu/qemu_driver.h b/src/qemu/qemu_driver.h
index 17b184f..95b8bff 100644
--- a/src/qemu/qemu_driver.h
+++ b/src/qemu/qemu_driver.h
@@ -23,29 +23,29 @@
#ifndef QEMUD_DRIVER_H
-#define QEMUD_DRIVER_H
+# define QEMUD_DRIVER_H
-#include <config.h>
+# include <config.h>
-#include "internal.h"
+# include "internal.h"
-#if HAVE_LINUX_KVM_H
-#include <linux/kvm.h>
-#endif
+# if HAVE_LINUX_KVM_H
+# include <linux/kvm.h>
+# endif
/* device for kvm ioctls */
-#define KVM_DEVICE "/dev/kvm"
+# define KVM_DEVICE "/dev/kvm"
/* add definitions missing in older linux/kvm.h */
-#ifndef KVMIO
+# ifndef KVMIO
# define KVMIO 0xAE
-#endif
-#ifndef KVM_CHECK_EXTENSION
+# endif
+# ifndef KVM_CHECK_EXTENSION
# define KVM_CHECK_EXTENSION _IO(KVMIO, 0x03)
-#endif
-#ifndef KVM_CAP_NR_VCPUS
+# endif
+# ifndef KVM_CAP_NR_VCPUS
# define KVM_CAP_NR_VCPUS 9 /* returns max vcpus per vm */
-#endif
+# endif
int qemuRegister(void);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index c252bce..acc841b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -166,7 +166,7 @@ char *qemuMonitorEscapeShell(const char *in)
#if QEMU_DEBUG_RAW_IO
-#include <c-ctype.h>
+# include <c-ctype.h>
static char * qemuMonitorEscapeNonPrintable(const char *text)
{
int i;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 15a2ff0..cfb76b6 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -23,12 +23,12 @@
#ifndef QEMU_MONITOR_H
-#define QEMU_MONITOR_H
+# define QEMU_MONITOR_H
-#include "internal.h"
+# include "internal.h"
-#include "domain_conf.h"
-#include "hash.h"
+# include "domain_conf.h"
+# include "hash.h"
typedef struct _qemuMonitor qemuMonitor;
typedef qemuMonitor *qemuMonitorPtr;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index f18c799..2906fee 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -23,11 +23,11 @@
#ifndef QEMU_MONITOR_JSON_H
-#define QEMU_MONITOR_JSON_H
+# define QEMU_MONITOR_JSON_H
-#include "internal.h"
+# include "internal.h"
-#include "qemu_monitor.h"
+# include "qemu_monitor.h"
int qemuMonitorJSONIOProcess(qemuMonitorPtr mon,
const char *data,
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index ddacb42..3215cae 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -23,12 +23,12 @@
#ifndef QEMU_MONITOR_TEXT_H
-#define QEMU_MONITOR_TEXT_H
+# define QEMU_MONITOR_TEXT_H
-#include "internal.h"
+# include "internal.h"
-#include "qemu_monitor.h"
-#include "hash.h"
+# include "qemu_monitor.h"
+# include "hash.h"
int qemuMonitorTextIOProcess(qemuMonitorPtr mon,
const char *data,
diff --git a/src/qemu/qemu_security_dac.h b/src/qemu/qemu_security_dac.h
index 246ebe2..a742f7a 100644
--- a/src/qemu/qemu_security_dac.h
+++ b/src/qemu/qemu_security_dac.h
@@ -13,7 +13,7 @@
#include "qemu_conf.h"
#ifndef __QEMU_SECURITY_DAC
-#define __QEMU_SECURITY_DAC
+# define __QEMU_SECURITY_DAC
extern virSecurityDriver qemuDACSecurityDriver;
diff --git a/src/qemu/qemu_security_stacked.h b/src/qemu/qemu_security_stacked.h
index d67a5f1..07f76d5 100644
--- a/src/qemu/qemu_security_stacked.h
+++ b/src/qemu/qemu_security_stacked.h
@@ -13,7 +13,7 @@
#include "qemu_conf.h"
#ifndef __QEMU_SECURITY_STACKED
-#define __QEMU_SECURITY_STACKED
+# define __QEMU_SECURITY_STACKED
extern virSecurityDriver qemuStackedSecurityDriver;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index a6830dc..4a96bdc 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -45,15 +45,15 @@
#endif
#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#ifdef HAVE_PWD_H
-#include <pwd.h>
+# include <pwd.h>
#endif
#ifdef HAVE_PATHS_H
-#include <paths.h>
+# include <paths.h>
#endif
#include <rpc/types.h>
@@ -62,7 +62,7 @@
#include <gnutls/x509.h>
#include "gnutls_1_0_compat.h"
#if HAVE_SASL
-#include <sasl/sasl.h>
+# include <sasl/sasl.h>
#endif
#include <libxml/uri.h>
@@ -92,7 +92,7 @@
#define VIR_FROM_THIS VIR_FROM_REMOTE
#ifdef WIN32
-#define pipe(fds) _pipe(fds,4096, _O_BINARY)
+# define pipe(fds) _pipe(fds,4096, _O_BINARY)
#endif
@@ -679,9 +679,9 @@ doRemoteOpen (virConnectPtr conn,
}
}
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX(addr) (sizeof (addr).sun_path)
-#endif
+# ifndef UNIX_PATH_MAX
+# define UNIX_PATH_MAX(addr) (sizeof (addr).sun_path)
+# endif
struct sockaddr_un addr;
int trials = 0;
@@ -6710,7 +6710,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
#if HAVE_POLKIT
-#if HAVE_POLKIT1
+# if HAVE_POLKIT1
static int
remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
virConnectAuthPtr auth ATTRIBUTE_UNUSED)
@@ -6728,7 +6728,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
DEBUG0("PolicyKit-1 authentication complete");
return 0;
}
-#elif HAVE_POLKIT0
+# elif HAVE_POLKIT0
/* Perform the PolicyKit authentication process
*/
static int
@@ -6780,7 +6780,7 @@ remoteAuthPolkit (virConnectPtr conn, struct private_data *priv, int in_open,
DEBUG0("PolicyKit-0 authentication complete");
return 0;
}
-#endif /* HAVE_POLKIT0 */
+# endif /* HAVE_POLKIT0 */
#endif /* HAVE_POLKIT */
/*----------------------------------------------------------------------*/
diff --git a/src/remote/remote_driver.h b/src/remote/remote_driver.h
index 4d62e15..49a63bd 100644
--- a/src/remote/remote_driver.h
+++ b/src/remote/remote_driver.h
@@ -22,29 +22,29 @@
*/
#ifndef __VIR_REMOTE_INTERNAL_H__
-#define __VIR_REMOTE_INTERNAL_H__
+# define __VIR_REMOTE_INTERNAL_H__
-#include "libvirt/virterror.h"
+# include "libvirt/virterror.h"
int remoteRegister (void);
unsigned long remoteVersion(void);
-#define LIBVIRTD_LISTEN_ADDR NULL
-#define LIBVIRTD_TLS_PORT "16514"
-#define LIBVIRTD_TCP_PORT "16509"
-#define LIBVIRTD_PRIV_UNIX_SOCKET LOCAL_STATE_DIR "/run/libvirt/libvirt-sock"
-#define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro"
-#define LIBVIRTD_USER_UNIX_SOCKET "/.libvirt/libvirt-sock"
-#define LIBVIRTD_CONFIGURATION_FILE SYSCONF_DIR "/libvirtd.conf"
+# define LIBVIRTD_LISTEN_ADDR NULL
+# define LIBVIRTD_TLS_PORT "16514"
+# define LIBVIRTD_TCP_PORT "16509"
+# define LIBVIRTD_PRIV_UNIX_SOCKET LOCAL_STATE_DIR "/run/libvirt/libvirt-sock"
+# define LIBVIRTD_PRIV_UNIX_SOCKET_RO LOCAL_STATE_DIR "/run/libvirt/libvirt-sock-ro"
+# define LIBVIRTD_USER_UNIX_SOCKET "/.libvirt/libvirt-sock"
+# define LIBVIRTD_CONFIGURATION_FILE SYSCONF_DIR "/libvirtd.conf"
/* Defaults for PKI directory. */
-#define LIBVIRT_PKI_DIR SYSCONF_DIR "/pki"
-#define LIBVIRT_CACERT LIBVIRT_PKI_DIR "/CA/cacert.pem"
-#define LIBVIRT_CLIENTKEY LIBVIRT_PKI_DIR "/libvirt/private/clientkey.pem"
-#define LIBVIRT_CLIENTCERT LIBVIRT_PKI_DIR "/libvirt/clientcert.pem"
-#define LIBVIRT_SERVERKEY LIBVIRT_PKI_DIR "/libvirt/private/serverkey.pem"
-#define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
+# define LIBVIRT_PKI_DIR SYSCONF_DIR "/pki"
+# define LIBVIRT_CACERT LIBVIRT_PKI_DIR "/CA/cacert.pem"
+# define LIBVIRT_CLIENTKEY LIBVIRT_PKI_DIR "/libvirt/private/clientkey.pem"
+# define LIBVIRT_CLIENTCERT LIBVIRT_PKI_DIR "/libvirt/clientcert.pem"
+# define LIBVIRT_SERVERKEY LIBVIRT_PKI_DIR "/libvirt/private/serverkey.pem"
+# define LIBVIRT_SERVERCERT LIBVIRT_PKI_DIR "/libvirt/servercert.pem"
#endif /* __VIR_REMOTE_INTERNAL_H__ */
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index e06d73f..f76e6e5 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -4,51 +4,51 @@
*/
#ifndef _RP_H_RPCGEN
-#define _RP_H_RPCGEN
+# define _RP_H_RPCGEN
-#include <rpc/rpc.h>
+# include <rpc/rpc.h>
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-#include "internal.h"
-#include <arpa/inet.h>
-#define REMOTE_MESSAGE_MAX 262144
-#define REMOTE_MESSAGE_HEADER_MAX 24
-#define REMOTE_MESSAGE_PAYLOAD_MAX 262120
-#define REMOTE_STRING_MAX 65536
+# include "internal.h"
+# include <arpa/inet.h>
+# define REMOTE_MESSAGE_MAX 262144
+# define REMOTE_MESSAGE_HEADER_MAX 24
+# define REMOTE_MESSAGE_PAYLOAD_MAX 262120
+# define REMOTE_STRING_MAX 65536
typedef char *remote_nonnull_string;
typedef remote_nonnull_string *remote_string;
-#define REMOTE_DOMAIN_ID_LIST_MAX 16384
-#define REMOTE_DOMAIN_NAME_LIST_MAX 1024
-#define REMOTE_CPUMAP_MAX 256
-#define REMOTE_VCPUINFO_MAX 2048
-#define REMOTE_CPUMAPS_MAX 16384
-#define REMOTE_MIGRATE_COOKIE_MAX 256
-#define REMOTE_NETWORK_NAME_LIST_MAX 256
-#define REMOTE_INTERFACE_NAME_LIST_MAX 256
-#define REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX 256
-#define REMOTE_STORAGE_POOL_NAME_LIST_MAX 256
-#define REMOTE_STORAGE_VOL_NAME_LIST_MAX 1024
-#define REMOTE_NODE_DEVICE_NAME_LIST_MAX 16384
-#define REMOTE_NODE_DEVICE_CAPS_LIST_MAX 16384
-#define REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX 16
-#define REMOTE_NODE_MAX_CELLS 1024
-#define REMOTE_AUTH_SASL_DATA_MAX 65536
-#define REMOTE_AUTH_TYPE_LIST_MAX 20
-#define REMOTE_DOMAIN_MEMORY_STATS_MAX 1024
-#define REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX 65536
-#define REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX 65536
-#define REMOTE_SECURITY_MODEL_MAX VIR_SECURITY_MODEL_BUFLEN
-#define REMOTE_SECURITY_LABEL_MAX VIR_SECURITY_LABEL_BUFLEN
-#define REMOTE_SECURITY_DOI_MAX VIR_SECURITY_DOI_BUFLEN
-#define REMOTE_SECRET_VALUE_MAX 65536
-#define REMOTE_SECRET_UUID_LIST_MAX 16384
-#define REMOTE_CPU_BASELINE_MAX 256
+# define REMOTE_DOMAIN_ID_LIST_MAX 16384
+# define REMOTE_DOMAIN_NAME_LIST_MAX 1024
+# define REMOTE_CPUMAP_MAX 256
+# define REMOTE_VCPUINFO_MAX 2048
+# define REMOTE_CPUMAPS_MAX 16384
+# define REMOTE_MIGRATE_COOKIE_MAX 256
+# define REMOTE_NETWORK_NAME_LIST_MAX 256
+# define REMOTE_INTERFACE_NAME_LIST_MAX 256
+# define REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX 256
+# define REMOTE_STORAGE_POOL_NAME_LIST_MAX 256
+# define REMOTE_STORAGE_VOL_NAME_LIST_MAX 1024
+# define REMOTE_NODE_DEVICE_NAME_LIST_MAX 16384
+# define REMOTE_NODE_DEVICE_CAPS_LIST_MAX 16384
+# define REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX 16
+# define REMOTE_NODE_MAX_CELLS 1024
+# define REMOTE_AUTH_SASL_DATA_MAX 65536
+# define REMOTE_AUTH_TYPE_LIST_MAX 20
+# define REMOTE_DOMAIN_MEMORY_STATS_MAX 1024
+# define REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX 65536
+# define REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX 65536
+# define REMOTE_SECURITY_MODEL_MAX VIR_SECURITY_MODEL_BUFLEN
+# define REMOTE_SECURITY_LABEL_MAX VIR_SECURITY_LABEL_BUFLEN
+# define REMOTE_SECURITY_DOI_MAX VIR_SECURITY_DOI_BUFLEN
+# define REMOTE_SECRET_VALUE_MAX 65536
+# define REMOTE_SECRET_UUID_LIST_MAX 16384
+# define REMOTE_CPU_BASELINE_MAX 256
typedef char remote_uuid[VIR_UUID_BUFLEN];
@@ -1704,8 +1704,8 @@ struct remote_domain_abort_job_args {
remote_nonnull_domain dom;
};
typedef struct remote_domain_abort_job_args remote_domain_abort_job_args;
-#define REMOTE_PROGRAM 0x20008086
-#define REMOTE_PROTOCOL_VERSION 1
+# define REMOTE_PROGRAM 0x20008086
+# define REMOTE_PROTOCOL_VERSION 1
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
@@ -1889,7 +1889,7 @@ enum remote_message_status {
REMOTE_CONTINUE = 2,
};
typedef enum remote_message_status remote_message_status;
-#define REMOTE_MESSAGE_HEADER_XDR_LEN 4
+# define REMOTE_MESSAGE_HEADER_XDR_LEN 4
struct remote_message_header {
u_int prog;
@@ -1903,7 +1903,7 @@ typedef struct remote_message_header remote_message_header;
/* the xdr functions */
-#if defined(__STDC__) || defined(__cplusplus)
+# if defined(__STDC__) || defined(__cplusplus)
extern bool_t xdr_remote_nonnull_string (XDR *, remote_nonnull_string*);
extern bool_t xdr_remote_string (XDR *, remote_string*);
extern bool_t xdr_remote_uuid (XDR *, remote_uuid);
@@ -2186,7 +2186,7 @@ extern bool_t xdr_remote_message_type (XDR *, remote_message_type*);
extern bool_t xdr_remote_message_status (XDR *, remote_message_status*);
extern bool_t xdr_remote_message_header (XDR *, remote_message_header*);
-#else /* K&R C */
+# else /* K&R C */
extern bool_t xdr_remote_nonnull_string ();
extern bool_t xdr_remote_string ();
extern bool_t xdr_remote_uuid ();
@@ -2469,10 +2469,10 @@ extern bool_t xdr_remote_message_type ();
extern bool_t xdr_remote_message_status ();
extern bool_t xdr_remote_message_header ();
-#endif /* K&R C */
+# endif /* K&R C */
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* !_RP_H_RPCGEN */
diff --git a/src/secret/secret_driver.h b/src/secret/secret_driver.h
index 0d0b80a..54a60a1 100644
--- a/src/secret/secret_driver.h
+++ b/src/secret/secret_driver.h
@@ -21,7 +21,7 @@
*/
#ifndef __VIR_SECRET_DRIVER_H__
-#define __VIR_SECRET_DRIVER_H__
+# define __VIR_SECRET_DRIVER_H__
int secretRegister(void);
diff --git a/src/security/security_apparmor.h b/src/security/security_apparmor.h
index 6d431da..eb7e140 100644
--- a/src/security/security_apparmor.h
+++ b/src/security/security_apparmor.h
@@ -12,12 +12,12 @@
*
*/
#ifndef __VIR_SECURITY_APPARMOR_H__
-#define __VIR_SECURITY_APPARMOR_H__
+# define __VIR_SECURITY_APPARMOR_H__
extern virSecurityDriver virAppArmorSecurityDriver;
-#define AA_PREFIX "libvirt-"
-#define PROFILE_NAME_SIZE 8 + VIR_UUID_STRING_BUFLEN /* AA_PREFIX + uuid */
-#define MAX_FILE_LEN (1024*1024*10) /* 10MB limit for sanity check */
+# define AA_PREFIX "libvirt-"
+# define PROFILE_NAME_SIZE 8 + VIR_UUID_STRING_BUFLEN /* AA_PREFIX + uuid */
+# define MAX_FILE_LEN (1024*1024*10) /* 10MB limit for sanity check */
#endif /* __VIR_SECURITY_APPARMOR_H__ */
diff --git a/src/security/security_driver.c b/src/security/security_driver.c
index 4c98190..aac9f78 100644
--- a/src/security/security_driver.c
+++ b/src/security/security_driver.c
@@ -17,11 +17,11 @@
#include "security_driver.h"
#ifdef WITH_SECDRIVER_SELINUX
-#include "security_selinux.h"
+# include "security_selinux.h"
#endif
#ifdef WITH_SECDRIVER_APPARMOR
-#include "security_apparmor.h"
+# include "security_apparmor.h"
#endif
static virSecurityDriverPtr security_drivers[] = {
diff --git a/src/security/security_driver.h b/src/security/security_driver.h
index 1b434c4..3de234a 100644
--- a/src/security/security_driver.h
+++ b/src/security/security_driver.h
@@ -11,10 +11,10 @@
*
*/
#ifndef __VIR_SECURITY_H__
-#define __VIR_SECURITY_H__
+# define __VIR_SECURITY_H__
-#include "internal.h"
-#include "domain_conf.h"
+# include "internal.h"
+# include "domain_conf.h"
/*
* Return values for security driver probing: the driver will determine
@@ -88,7 +88,7 @@ int virSecurityDriverStartup(virSecurityDriverPtr *drv,
int
virSecurityDriverVerify(virDomainDefPtr def);
-#define virSecurityReportError(code, ...) \
+# define virSecurityReportError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_SECURITY, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/security/security_selinux.h b/src/security/security_selinux.h
index 1e32209..056ba75 100644
--- a/src/security/security_selinux.h
+++ b/src/security/security_selinux.h
@@ -11,7 +11,7 @@
*
*/
#ifndef __VIR_SECURITY_SELINUX_H__
-#define __VIR_SECURITY_SELINUX_H__
+# define __VIR_SECURITY_SELINUX_H__
extern virSecurityDriver virSELinuxSecurityDriver;
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index ee9e90f..ec9fc43 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -26,11 +26,11 @@
#include <string.h>
#include <stdio.h>
#if HAVE_REGEX_H
-#include <regex.h>
+# include <regex.h>
#endif
#include <sys/types.h>
#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#include <unistd.h>
#include <fcntl.h>
@@ -40,7 +40,7 @@
#include <dirent.h>
#if HAVE_SELINUX
-#include <selinux/selinux.h>
+# include <selinux/selinux.h>
#endif
#include "datatypes.h"
@@ -55,26 +55,26 @@
#include "logging.h"
#if WITH_STORAGE_LVM
-#include "storage_backend_logical.h"
+# include "storage_backend_logical.h"
#endif
#if WITH_STORAGE_ISCSI
-#include "storage_backend_iscsi.h"
+# include "storage_backend_iscsi.h"
#endif
#if WITH_STORAGE_SCSI
-#include "storage_backend_scsi.h"
+# include "storage_backend_scsi.h"
#endif
#if WITH_STORAGE_MPATH
-#include "storage_backend_mpath.h"
+# include "storage_backend_mpath.h"
#endif
#if WITH_STORAGE_DISK
-#include "storage_backend_disk.h"
+# include "storage_backend_disk.h"
#endif
#if WITH_STORAGE_DIR
-#include "storage_backend_fs.h"
+# include "storage_backend_fs.h"
#endif
#ifndef DEV_BSIZE
-#define DEV_BSIZE 512
+# define DEV_BSIZE 512
#endif
#define VIR_FROM_THIS VIR_FROM_STORAGE
diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h
index 00bc725..766f374 100644
--- a/src/storage/storage_backend.h
+++ b/src/storage/storage_backend.h
@@ -22,11 +22,11 @@
*/
#ifndef __VIR_STORAGE_BACKEND_H__
-#define __VIR_STORAGE_BACKEND_H__
+# define __VIR_STORAGE_BACKEND_H__
-#include <stdint.h>
-#include "internal.h"
-#include "storage_conf.h"
+# include <stdint.h>
+# include "internal.h"
+# include "storage_conf.h"
typedef char * (*virStorageBackendFindPoolSources)(virConnectPtr conn, const char *srcSpec, unsigned int flags);
typedef int (*virStorageBackendStartPool)(virConnectPtr conn, virStoragePoolObjPtr pool);
diff --git a/src/storage/storage_backend_disk.h b/src/storage/storage_backend_disk.h
index e1c7391..9d4773e 100644
--- a/src/storage/storage_backend_disk.h
+++ b/src/storage/storage_backend_disk.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_STORAGE_BACKEND_DISK_H__
-#define __VIR_STORAGE_BACKEND_DISK_H__
+# define __VIR_STORAGE_BACKEND_DISK_H__
-#include "storage_backend.h"
+# include "storage_backend.h"
extern virStorageBackend virStorageBackendDisk;
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index dfd417f..a83fc01 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -125,7 +125,7 @@ virStorageBackendProbeTarget(virStorageVolTargetPtr target,
#if WITH_STORAGE_FS
-#include <mntent.h>
+# include <mntent.h>
struct _virNetfsDiscoverState {
const char *host;
diff --git a/src/storage/storage_backend_fs.h b/src/storage/storage_backend_fs.h
index 2136d68..7def53e 100644
--- a/src/storage/storage_backend_fs.h
+++ b/src/storage/storage_backend_fs.h
@@ -22,14 +22,14 @@
*/
#ifndef __VIR_STORAGE_BACKEND_FS_H__
-#define __VIR_STORAGE_BACKEND_FS_H__
+# define __VIR_STORAGE_BACKEND_FS_H__
-#include "storage_backend.h"
+# include "storage_backend.h"
-#if WITH_STORAGE_FS
+# if WITH_STORAGE_FS
extern virStorageBackend virStorageBackendFileSystem;
extern virStorageBackend virStorageBackendNetFileSystem;
-#endif
+# endif
extern virStorageBackend virStorageBackendDirectory;
#endif /* __VIR_STORAGE_BACKEND_FS_H__ */
diff --git a/src/storage/storage_backend_iscsi.h b/src/storage/storage_backend_iscsi.h
index 8878342..6f18280 100644
--- a/src/storage/storage_backend_iscsi.h
+++ b/src/storage/storage_backend_iscsi.h
@@ -22,14 +22,14 @@
*/
#ifndef __VIR_STORAGE_BACKEND_ISCSI_H__
-#define __VIR_STORAGE_BACKEND_ISCSI_H__
+# define __VIR_STORAGE_BACKEND_ISCSI_H__
-#include "storage_backend.h"
+# include "storage_backend.h"
extern virStorageBackend virStorageBackendISCSI;
-#define IQN_FOUND 1
-#define IQN_MISSING 0
-#define IQN_ERROR -1
+# define IQN_FOUND 1
+# define IQN_MISSING 0
+# define IQN_ERROR -1
#endif /* __VIR_STORAGE_BACKEND_ISCSI_H__ */
diff --git a/src/storage/storage_backend_logical.h b/src/storage/storage_backend_logical.h
index 19814df..1d14163 100644
--- a/src/storage/storage_backend_logical.h
+++ b/src/storage/storage_backend_logical.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_STORAGE_BACKEND_LOGICAL_H__
-#define __VIR_STORAGE_BACKEND_LOGICAL_H__
+# define __VIR_STORAGE_BACKEND_LOGICAL_H__
-#include "storage_backend.h"
+# include "storage_backend.h"
extern virStorageBackend virStorageBackendLogical;
diff --git a/src/storage/storage_backend_mpath.h b/src/storage/storage_backend_mpath.h
index 04960fb..a060a13 100644
--- a/src/storage/storage_backend_mpath.h
+++ b/src/storage/storage_backend_mpath.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_STORAGE_BACKEND_MPATH_H__
-#define __VIR_STORAGE_BACKEND_MPATH_H__
+# define __VIR_STORAGE_BACKEND_MPATH_H__
-#include "storage_backend.h"
+# include "storage_backend.h"
extern virStorageBackend virStorageBackendMpath;
diff --git a/src/storage/storage_backend_scsi.h b/src/storage/storage_backend_scsi.h
index a886660..c3af173 100644
--- a/src/storage/storage_backend_scsi.h
+++ b/src/storage/storage_backend_scsi.h
@@ -22,13 +22,13 @@
*/
#ifndef __VIR_STORAGE_BACKEND_SCSI_H__
-#define __VIR_STORAGE_BACKEND_SCSI_H__
+# define __VIR_STORAGE_BACKEND_SCSI_H__
-#include "storage_backend.h"
+# include "storage_backend.h"
-#define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host"
-#define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
-#define LINUX_SYSFS_SCSI_HOST_SCAN_STRING "- - -"
+# define LINUX_SYSFS_SCSI_HOST_PREFIX "/sys/class/scsi_host"
+# define LINUX_SYSFS_SCSI_HOST_POSTFIX "device"
+# define LINUX_SYSFS_SCSI_HOST_SCAN_STRING "- - -"
extern virStorageBackend virStorageBackendSCSI;
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index f3be6de..ca2540f 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -27,7 +27,7 @@
#include <unistd.h>
#include <sys/types.h>
#if HAVE_PWD_H
-#include <pwd.h>
+# include <pwd.h>
#endif
#include <errno.h>
#include <string.h>
diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
index 500ea02..b3e2554 100644
--- a/src/storage/storage_driver.h
+++ b/src/storage/storage_driver.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_STORAGE_DRIVER_H__
-#define __VIR_STORAGE_DRIVER_H__
+# define __VIR_STORAGE_DRIVER_H__
-#include "storage_conf.h"
+# include "storage_conf.h"
int storageRegister(void);
diff --git a/src/test/test_driver.h b/src/test/test_driver.h
index c6bdbd0..deb0caf 100644
--- a/src/test/test_driver.h
+++ b/src/test/test_driver.h
@@ -22,9 +22,9 @@
*/
#ifndef __VIR_TEST_INTERNAL_H__
-#define __VIR_TEST_INTERNAL_H__
+# define __VIR_TEST_INTERNAL_H__
-#include "internal.h"
+# include "internal.h"
int testRegister(void);
diff --git a/src/uml/uml_conf.h b/src/uml/uml_conf.h
index f3967ee..70c3f7d 100644
--- a/src/uml/uml_conf.h
+++ b/src/uml/uml_conf.h
@@ -22,21 +22,21 @@
*/
#ifndef __UML_CONF_H
-#define __UML_CONF_H
+# define __UML_CONF_H
-#include "internal.h"
-#include "bridge.h"
-#include "capabilities.h"
-#include "network_conf.h"
-#include "domain_conf.h"
-#include "virterror_internal.h"
-#include "threads.h"
+# include "internal.h"
+# include "bridge.h"
+# include "capabilities.h"
+# include "network_conf.h"
+# include "domain_conf.h"
+# include "virterror_internal.h"
+# include "threads.h"
-#define umlDebug(fmt, ...) do {} while(0)
+# define umlDebug(fmt, ...) do {} while(0)
-#define UML_CPUMASK_LEN CPU_SETSIZE
+# define UML_CPUMASK_LEN CPU_SETSIZE
-#define UML_MAX_CHAR_DEVICE 16
+# define UML_MAX_CHAR_DEVICE 16
/* Main driver state */
struct uml_driver {
@@ -62,7 +62,7 @@ struct uml_driver {
};
-#define umlReportError(conn, dom, net, code, ...) \
+# define umlReportError(conn, dom, net, code, ...) \
virReportErrorHelper(conn, VIR_FROM_UML, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/uml/uml_driver.h b/src/uml/uml_driver.h
index 2195410..b7b8d9d 100644
--- a/src/uml/uml_driver.h
+++ b/src/uml/uml_driver.h
@@ -23,9 +23,9 @@
#ifndef UML_DRIVER_H
-#define UML_DRIVER_H
+# define UML_DRIVER_H
-#include "internal.h"
+# include "internal.h"
int umlRegister(void);
diff --git a/src/util/bridge.c b/src/util/bridge.c
index 4a5ab4b..b236f80 100644
--- a/src/util/bridge.c
+++ b/src/util/bridge.c
@@ -23,34 +23,34 @@
#if defined(WITH_BRIDGE)
-#include "bridge.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <paths.h>
-#include <sys/wait.h>
-
-#include <linux/param.h> /* HZ */
-#include <linux/sockios.h> /* SIOCBRADDBR etc. */
-#include <linux/if_bridge.h> /* SYSFS_BRIDGE_ATTR */
-#include <linux/if_tun.h> /* IFF_TUN, IFF_NO_PI */
-#include <net/if_arp.h> /* ARPHRD_ETHER */
-
-#include "internal.h"
-#include "memory.h"
-#include "util.h"
-#include "logging.h"
-
-#define JIFFIES_TO_MS(j) (((j)*1000)/HZ)
-#define MS_TO_JIFFIES(ms) (((ms)*HZ)/1000)
+# include "bridge.h"
+
+# include <stdlib.h>
+# include <stdio.h>
+# include <string.h>
+# include <unistd.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <arpa/inet.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <sys/ioctl.h>
+# include <paths.h>
+# include <sys/wait.h>
+
+# include <linux/param.h> /* HZ */
+# include <linux/sockios.h> /* SIOCBRADDBR etc. */
+# include <linux/if_bridge.h> /* SYSFS_BRIDGE_ATTR */
+# include <linux/if_tun.h> /* IFF_TUN, IFF_NO_PI */
+# include <net/if_arp.h> /* ARPHRD_ETHER */
+
+# include "internal.h"
+# include "memory.h"
+# include "util.h"
+# include "logging.h"
+
+# define JIFFIES_TO_MS(j) (((j)*1000)/HZ)
+# define MS_TO_JIFFIES(ms) (((ms)*HZ)/1000)
struct _brControl {
int fd;
@@ -122,7 +122,7 @@ brShutdown(brControl *ctl)
*
* Returns 0 in case of success or an errno code in case of failure.
*/
-#ifdef SIOCBRADDBR
+# ifdef SIOCBRADDBR
int
brAddBridge(brControl *ctl,
const char *name)
@@ -135,15 +135,15 @@ brAddBridge(brControl *ctl,
return errno;
}
-#else
+# else
int brAddBridge (brControl *ctl ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED)
{
return EINVAL;
}
-#endif
+# endif
-#ifdef SIOCBRDELBR
+# ifdef SIOCBRDELBR
int
brHasBridge(brControl *ctl,
const char *name)
@@ -167,14 +167,14 @@ brHasBridge(brControl *ctl,
return 0;
}
-#else
+# else
int
brHasBridge(brControl *ctl ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED)
{
return EINVAL;
}
-#endif
+# endif
/**
* brDeleteBridge:
@@ -185,7 +185,7 @@ brHasBridge(brControl *ctl ATTRIBUTE_UNUSED,
*
* Returns 0 in case of success or an errno code in case of failure.
*/
-#ifdef SIOCBRDELBR
+# ifdef SIOCBRDELBR
int
brDeleteBridge(brControl *ctl,
const char *name)
@@ -195,16 +195,16 @@ brDeleteBridge(brControl *ctl,
return ioctl(ctl->fd, SIOCBRDELBR, name) == 0 ? 0 : errno;
}
-#else
+# else
int
brDeleteBridge(brControl *ctl ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED)
{
return EINVAL;
}
-#endif
+# endif
-#if defined(SIOCBRADDIF) && defined(SIOCBRDELIF)
+# if defined(SIOCBRADDIF) && defined(SIOCBRDELIF)
static int
brAddDelInterface(brControl *ctl,
int cmd,
@@ -226,7 +226,7 @@ brAddDelInterface(brControl *ctl,
return ioctl(ctl->fd, cmd, &ifr) == 0 ? 0 : errno;
}
-#endif
+# endif
/**
* brAddInterface:
@@ -238,7 +238,7 @@ brAddDelInterface(brControl *ctl,
*
* Returns 0 in case of success or an errno code in case of failure.
*/
-#ifdef SIOCBRADDIF
+# ifdef SIOCBRADDIF
int
brAddInterface(brControl *ctl,
const char *bridge,
@@ -246,7 +246,7 @@ brAddInterface(brControl *ctl,
{
return brAddDelInterface(ctl, SIOCBRADDIF, bridge, iface);
}
-#else
+# else
int
brAddInterface(brControl *ctl ATTRIBUTE_UNUSED,
const char *bridge ATTRIBUTE_UNUSED,
@@ -254,7 +254,7 @@ brAddInterface(brControl *ctl ATTRIBUTE_UNUSED,
{
return EINVAL;
}
-#endif
+# endif
/**
* brDeleteInterface:
@@ -266,7 +266,7 @@ brAddInterface(brControl *ctl ATTRIBUTE_UNUSED,
*
* Returns 0 in case of success or an errno code in case of failure.
*/
-#ifdef SIOCBRDELIF
+# ifdef SIOCBRDELIF
int
brDeleteInterface(brControl *ctl,
const char *bridge,
@@ -274,7 +274,7 @@ brDeleteInterface(brControl *ctl,
{
return brAddDelInterface(ctl, SIOCBRDELIF, bridge, iface);
}
-#else
+# else
int
brDeleteInterface(brControl *ctl ATTRIBUTE_UNUSED,
const char *bridge ATTRIBUTE_UNUSED,
@@ -282,7 +282,7 @@ brDeleteInterface(brControl *ctl ATTRIBUTE_UNUSED,
{
return EINVAL;
}
-#endif
+# endif
/**
* ifGetMtu
@@ -385,11 +385,11 @@ static int brSetInterfaceMtu(brControl *ctl,
*
* Returns 0 in case of success or an errno code in case of failure.
*/
-#ifdef IFF_VNET_HDR
+# ifdef IFF_VNET_HDR
static int
brProbeVnetHdr(int tapfd)
{
-#if defined(IFF_VNET_HDR) && defined(TUNGETFEATURES) && defined(TUNGETIFF)
+# if defined(IFF_VNET_HDR) && defined(TUNGETFEATURES) && defined(TUNGETIFF)
unsigned int features;
struct ifreq dummy;
@@ -417,13 +417,13 @@ brProbeVnetHdr(int tapfd)
VIR_INFO0(_("Enabling IFF_VNET_HDR"));
return 1;
-#else
+# else
(void) tapfd;
VIR_INFO0(_("Not enabling IFF_VNET_HDR; disabled at build time"));
return 0;
-#endif
+# endif
}
-#endif
+# endif
/**
* brAddTap:
@@ -463,12 +463,12 @@ brAddTap(brControl *ctl,
ifr.ifr_flags = IFF_TAP|IFF_NO_PI;
-#ifdef IFF_VNET_HDR
+# ifdef IFF_VNET_HDR
if (vnet_hdr && brProbeVnetHdr(fd))
ifr.ifr_flags |= IFF_VNET_HDR;
-#else
+# else
(void) vnet_hdr;
-#endif
+# endif
if (virStrcpyStatic(ifr.ifr_name, *ifname) == NULL) {
errno = EINVAL;
diff --git a/src/util/bridge.h b/src/util/bridge.h
index 2d9bec1..d37d7db 100644
--- a/src/util/bridge.h
+++ b/src/util/bridge.h
@@ -20,26 +20,26 @@
*/
#ifndef __QEMUD_BRIDGE_H__
-#define __QEMUD_BRIDGE_H__
+# define __QEMUD_BRIDGE_H__
-#include <config.h>
+# include <config.h>
-#if defined(WITH_BRIDGE)
+# if defined(WITH_BRIDGE)
-#include <net/if.h>
-#include <netinet/in.h>
+# include <net/if.h>
+# include <netinet/in.h>
/**
* BR_IFNAME_MAXLEN:
* maximum size in byte of the name for an interface
*/
-#define BR_IFNAME_MAXLEN IF_NAMESIZE
+# define BR_IFNAME_MAXLEN IF_NAMESIZE
/**
* BR_INET_ADDR_MAXLEN:
* maximum size in bytes for an inet addess name
*/
-#define BR_INET_ADDR_MAXLEN INET_ADDRSTRLEN
+# define BR_INET_ADDR_MAXLEN INET_ADDRSTRLEN
typedef struct _brControl brControl;
@@ -109,6 +109,6 @@ int brGetEnableSTP (brControl *ctl,
const char *bridge,
int *enable);
-#endif /* WITH_BRIDGE */
+# endif /* WITH_BRIDGE */
#endif /* __QEMUD_BRIDGE_H__ */
diff --git a/src/util/buf.h b/src/util/buf.h
index d9a1708..6616898 100644
--- a/src/util/buf.h
+++ b/src/util/buf.h
@@ -9,9 +9,9 @@
*/
#ifndef __VIR_BUFFER_H__
-#define __VIR_BUFFER_H__
+# define __VIR_BUFFER_H__
-#include "internal.h"
+# include "internal.h"
/**
* virBuffer:
@@ -21,8 +21,8 @@
typedef struct _virBuffer virBuffer;
typedef virBuffer *virBufferPtr;
-#ifndef __VIR_BUFFER_C__
-#define VIR_BUFFER_INITIALIZER { 0, 0, 0, NULL }
+# ifndef __VIR_BUFFER_C__
+# define VIR_BUFFER_INITIALIZER { 0, 0, 0, NULL }
/* This struct must be kept in syn with the real struct
in the buf.c impl file */
@@ -32,7 +32,7 @@ struct _virBuffer {
unsigned int c;
char *d;
};
-#endif
+# endif
char *virBufferContentAndReset(const virBufferPtr buf);
void virBufferFreeAndReset(const virBufferPtr buf);
@@ -47,7 +47,7 @@ void virBufferStrcat(const virBufferPtr buf, ...)
void virBufferEscapeString(const virBufferPtr buf, const char *format, const char *str);
void virBufferURIEncodeString (const virBufferPtr buf, const char *str);
-#define virBufferAddLit(buf_, literal_string_) \
+# define virBufferAddLit(buf_, literal_string_) \
virBufferAdd (buf_, "" literal_string_ "", sizeof literal_string_ - 1)
#endif /* __VIR_BUFFER_H__ */
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index b4c3353..8777781 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -14,7 +14,7 @@
#include <stdint.h>
#include <inttypes.h>
#ifdef HAVE_MNTENT_H
-#include <mntent.h>
+# include <mntent.h>
#endif
#include <fcntl.h>
#include <string.h>
diff --git a/src/util/cgroup.h b/src/util/cgroup.h
index aa36632..2bea49f 100644
--- a/src/util/cgroup.h
+++ b/src/util/cgroup.h
@@ -10,7 +10,7 @@
*/
#ifndef CGROUP_H
-#define CGROUP_H
+# define CGROUP_H
struct virCgroup;
typedef struct virCgroup *virCgroupPtr;
diff --git a/src/util/conf.h b/src/util/conf.h
index 40d9586..8282bd4 100644
--- a/src/util/conf.h
+++ b/src/util/conf.h
@@ -9,7 +9,7 @@
*/
#ifndef __VIR_CONF_H__
-#define __VIR_CONF_H__
+# define __VIR_CONF_H__
/**
* virConfType:
diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index 988783c..a6afdf8 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -35,11 +35,11 @@
#include <sys/stat.h>
#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#ifdef HAVE_PATHS_H
-#include <paths.h>
+# include <paths.h>
#endif
#include "internal.h"
diff --git a/src/util/ebtables.h b/src/util/ebtables.h
index cafe418..a444432 100644
--- a/src/util/ebtables.h
+++ b/src/util/ebtables.h
@@ -22,7 +22,7 @@
*/
#ifndef __QEMUD_EBTABLES_H__
-#define __QEMUD_EBTABLES_H__
+# define __QEMUD_EBTABLES_H__
typedef struct
{
diff --git a/src/util/event.h b/src/util/event.h
index dc20622..4552d1a 100644
--- a/src/util/event.h
+++ b/src/util/event.h
@@ -22,8 +22,8 @@
*/
#ifndef __VIR_EVENT_H__
-#define __VIR_EVENT_H__
-#include "internal.h"
+# define __VIR_EVENT_H__
+# include "internal.h"
/**
* virEventAddHandle: register a callback for monitoring file handle events
*
diff --git a/src/util/hash.h b/src/util/hash.h
index a163f10..b0ef441 100644
--- a/src/util/hash.h
+++ b/src/util/hash.h
@@ -10,7 +10,7 @@
*/
#ifndef __VIR_HASH_H__
-#define __VIR_HASH_H__
+# define __VIR_HASH_H__
/*
* The hash table.
diff --git a/src/util/hostusb.h b/src/util/hostusb.h
index 9a1b1b7..f4a13ca 100644
--- a/src/util/hostusb.h
+++ b/src/util/hostusb.h
@@ -20,9 +20,9 @@
*/
#ifndef __VIR_USB_H__
-#define __VIR_USB_H__
+# define __VIR_USB_H__
-#include "internal.h"
+# include "internal.h"
typedef struct _usbDevice usbDevice;
diff --git a/src/util/iptables.c b/src/util/iptables.c
index b579173..facc4da 100644
--- a/src/util/iptables.c
+++ b/src/util/iptables.c
@@ -33,11 +33,11 @@
#include <sys/stat.h>
#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#ifdef HAVE_PATHS_H
-#include <paths.h>
+# include <paths.h>
#endif
#include "internal.h"
diff --git a/src/util/iptables.h b/src/util/iptables.h
index 68d9e0d..7d55a6d 100644
--- a/src/util/iptables.h
+++ b/src/util/iptables.h
@@ -20,7 +20,7 @@
*/
#ifndef __QEMUD_IPTABLES_H__
-#define __QEMUD_IPTABLES_H__
+# define __QEMUD_IPTABLES_H__
typedef struct _iptablesContext iptablesContext;
diff --git a/src/util/json.c b/src/util/json.c
index e388287..f90594c 100644
--- a/src/util/json.c
+++ b/src/util/json.c
@@ -30,8 +30,8 @@
#include "util.h"
#if HAVE_YAJL
-#include <yajl/yajl_gen.h>
-#include <yajl/yajl_parse.h>
+# include <yajl/yajl_gen.h>
+# include <yajl/yajl_parse.h>
#endif
/* XXX fixme */
diff --git a/src/util/json.h b/src/util/json.h
index 1af9d9d..ea28de6 100644
--- a/src/util/json.h
+++ b/src/util/json.h
@@ -22,9 +22,9 @@
#ifndef __VIR_JSON_H_
-#define __VIR_JSON_H_
+# define __VIR_JSON_H_
-#include "internal.h"
+# include "internal.h"
enum {
diff --git a/src/util/logging.c b/src/util/logging.c
index 11a4b06..6bc2ccf 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -31,7 +31,7 @@
#include <fcntl.h>
#include <unistd.h>
#if HAVE_SYSLOG_H
-#include <syslog.h>
+# include <syslog.h>
#endif
#include "ignore-value.h"
diff --git a/src/util/logging.h b/src/util/logging.h
index 5f61f59..574f68d 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -20,52 +20,52 @@
*/
#ifndef __VIRTLOG_H_
-#define __VIRTLOG_H_
+# define __VIRTLOG_H_
-#include "internal.h"
-#include "buf.h"
+# include "internal.h"
+# include "buf.h"
/*
* If configured with --enable-debug=yes then library calls
* are printed to stderr for debugging or to an appropriate channel
* defined at runtime of from the libvirt daemon configuration file
*/
-#ifdef ENABLE_DEBUG
-#define VIR_DEBUG_INT(category, f, l, fmt,...) \
+# ifdef ENABLE_DEBUG
+# define VIR_DEBUG_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_DEBUG, f, l, 0, fmt, __VA_ARGS__)
-#else
-#define VIR_DEBUG_INT(category, f, l, fmt,...) \
+# else
+# define VIR_DEBUG_INT(category, f, l, fmt,...) \
do { } while (0)
-#endif /* !ENABLE_DEBUG */
+# endif /* !ENABLE_DEBUG */
-#define VIR_INFO_INT(category, f, l, fmt,...) \
+# define VIR_INFO_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_INFO, f, l, 0, fmt, __VA_ARGS__)
-#define VIR_WARN_INT(category, f, l, fmt,...) \
+# define VIR_WARN_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_WARN, f, l, 0, fmt, __VA_ARGS__)
-#define VIR_ERROR_INT(category, f, l, fmt,...) \
+# define VIR_ERROR_INT(category, f, l, fmt,...) \
virLogMessage(category, VIR_LOG_ERROR, f, l, 0, fmt, __VA_ARGS__)
-#define VIR_DEBUG(fmt,...) \
+# define VIR_DEBUG(fmt,...) \
VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define VIR_DEBUG0(msg) \
+# define VIR_DEBUG0(msg) \
VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
-#define VIR_INFO(fmt,...) \
+# define VIR_INFO(fmt,...) \
VIR_INFO_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define VIR_INFO0(msg) \
+# define VIR_INFO0(msg) \
VIR_INFO_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
-#define VIR_WARN(fmt,...) \
+# define VIR_WARN(fmt,...) \
VIR_WARN_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define VIR_WARN0(msg) \
+# define VIR_WARN0(msg) \
VIR_WARN_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
-#define VIR_ERROR(fmt,...) \
+# define VIR_ERROR(fmt,...) \
VIR_ERROR_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define VIR_ERROR0(msg) \
+# define VIR_ERROR0(msg) \
VIR_ERROR_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
/* Legacy compat */
-#define DEBUG(fmt,...) \
+# define DEBUG(fmt,...) \
VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, fmt, __VA_ARGS__)
-#define DEBUG0(msg) \
+# define DEBUG0(msg) \
VIR_DEBUG_INT("file." __FILE__, __func__, __LINE__, "%s", msg)
/*
@@ -78,7 +78,7 @@ typedef enum {
VIR_LOG_ERROR,
} virLogPriority;
-#define VIR_LOG_DEFAULT VIR_LOG_WARN
+# define VIR_LOG_DEFAULT VIR_LOG_WARN
typedef enum {
VIR_LOG_TO_STDERR = 1,
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 3b526ce..736cbaf 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -29,32 +29,32 @@
#if WITH_MACVTAP
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdint.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-
-#include <linux/if.h>
-#include <linux/netlink.h>
-#include <linux/rtnetlink.h>
-#include <linux/if_tun.h>
-
-#include "util.h"
-#include "memory.h"
-#include "macvtap.h"
-#include "conf/domain_conf.h"
-#include "virterror_internal.h"
-
-#define VIR_FROM_THIS VIR_FROM_NET
-
-#define ReportError(conn, code, ...) \
+# include <stdio.h>
+# include <errno.h>
+# include <fcntl.h>
+# include <stdint.h>
+# include <sys/socket.h>
+# include <sys/ioctl.h>
+
+# include <linux/if.h>
+# include <linux/netlink.h>
+# include <linux/rtnetlink.h>
+# include <linux/if_tun.h>
+
+# include "util.h"
+# include "memory.h"
+# include "macvtap.h"
+# include "conf/domain_conf.h"
+# include "virterror_internal.h"
+
+# define VIR_FROM_THIS VIR_FROM_NET
+
+# define ReportError(conn, code, ...) \
virReportErrorHelper(conn, VIR_FROM_NET, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-#define MACVTAP_NAME_PREFIX "macvtap"
-#define MACVTAP_NAME_PATTERN "macvtap%d"
+# define MACVTAP_NAME_PREFIX "macvtap"
+# define MACVTAP_NAME_PATTERN "macvtap%d"
static int nlOpen(void)
{
diff --git a/src/util/macvtap.h b/src/util/macvtap.h
index 4c2fe8a..bd5f4d6 100644
--- a/src/util/macvtap.h
+++ b/src/util/macvtap.h
@@ -20,13 +20,13 @@
*/
#ifndef __UTIL_MACVTAP_H__
-#define __UTIL_MACVTAP_H__
+# define __UTIL_MACVTAP_H__
-#include <config.h>
+# include <config.h>
-#if defined(WITH_MACVTAP)
+# if defined(WITH_MACVTAP)
-#include "internal.h"
+# include "internal.h"
int openMacvtapTap(virConnectPtr conn,
const char *ifname,
@@ -38,11 +38,11 @@ int openMacvtapTap(virConnectPtr conn,
void delMacvtap(const char *ifname);
-#endif /* WITH_MACVTAP */
+# endif /* WITH_MACVTAP */
-#define MACVTAP_MODE_PRIVATE_STR "private"
-#define MACVTAP_MODE_VEPA_STR "vepa"
-#define MACVTAP_MODE_BRIDGE_STR "bridge"
+# define MACVTAP_MODE_PRIVATE_STR "private"
+# define MACVTAP_MODE_VEPA_STR "vepa"
+# define MACVTAP_MODE_BRIDGE_STR "bridge"
#endif /* __UTIL_MACVTAP_H__ */
diff --git a/src/util/memory.h b/src/util/memory.h
index fc9e6c1..0228173 100644
--- a/src/util/memory.h
+++ b/src/util/memory.h
@@ -21,9 +21,9 @@
#ifndef __VIR_MEMORY_H_
-#define __VIR_MEMORY_H_
+# define __VIR_MEMORY_H_
-#include "internal.h"
+# include "internal.h"
/* Return 1 if an array of N objects, each of size S, cannot exist due
to size arithmetic overflow. S must be positive and N must be
@@ -37,10 +37,10 @@
sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
exactly-SIZE_MAX allocations on such hosts; this avoids a test and
branch when S is known to be 1. */
-#ifndef xalloc_oversized
-# define xalloc_oversized(n, s) \
+# ifndef xalloc_oversized
+# define xalloc_oversized(n, s) \
((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
-#endif
+# endif
@@ -60,7 +60,7 @@ void virFree(void *ptrptr);
*
* Returns -1 on failure, 0 on success
*/
-#define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr)))
+# define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr)))
/**
* VIR_ALLOC_N:
@@ -73,7 +73,7 @@ void virFree(void *ptrptr);
*
* Returns -1 on failure, 0 on success
*/
-#define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count))
+# define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count))
/**
* VIR_REALLOC_N:
@@ -86,7 +86,7 @@ void virFree(void *ptrptr);
*
* Returns -1 on failure, 0 on success
*/
-#define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count))
+# define VIR_REALLOC_N(ptr, count) virReallocN(&(ptr), sizeof(*(ptr)), (count))
/**
* VIR_FREE:
@@ -95,15 +95,15 @@ void virFree(void *ptrptr);
* Free the memory stored in 'ptr' and update to point
* to NULL.
*/
-#define VIR_FREE(ptr) virFree(&(ptr))
+# define VIR_FREE(ptr) virFree(&(ptr))
-#if TEST_OOM
+# if TEST_OOM
void virAllocTestInit(void);
int virAllocTestCount(void);
void virAllocTestOOM(int n, int m);
void virAllocTestHook(void (*func)(int, void*), void *data);
-#endif
+# endif
diff --git a/src/util/network.h b/src/util/network.h
index d5c2c9b..7a7c074 100644
--- a/src/util/network.h
+++ b/src/util/network.h
@@ -9,13 +9,13 @@
*/
#ifndef __VIR_NETWORK_H__
-#define __VIR_NETWORK_H__
+# define __VIR_NETWORK_H__
-#include "internal.h"
+# include "internal.h"
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
+# include <sys/types.h>
+# include <sys/socket.h>
+# include <netdb.h>
typedef union {
struct sockaddr_storage stor;
diff --git a/src/util/pci.c b/src/util/pci.c
index c6b2072..99ec22a 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -40,7 +40,7 @@
/* avoid compilation breakage on some systems */
#ifndef MODPROBE
-#define MODPROBE "modprobe"
+# define MODPROBE "modprobe"
#endif
#define PCI_SYSFS "/sys/bus/pci/"
@@ -93,9 +93,9 @@ struct _pciDeviceList {
/* PCI30 6.2.1 */
#define PCI_HEADER_TYPE 0x0e /* Header type */
-#define PCI_HEADER_TYPE_BRIDGE 0x1
-#define PCI_HEADER_TYPE_MASK 0x7f
-#define PCI_HEADER_TYPE_MULTI 0x80
+#define PCI_HEADER_TYPE_BRIDGE 0x1
+#define PCI_HEADER_TYPE_MASK 0x7f
+#define PCI_HEADER_TYPE_MULTI 0x80
/* PCI30 6.2.1 Device Identification */
#define PCI_CLASS_DEVICE 0x0a /* Device class */
@@ -105,7 +105,7 @@ struct _pciDeviceList {
/* PCI30 6.2.3 Device Status */
#define PCI_STATUS 0x06 /* 16 bits */
-#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
+#define PCI_STATUS_CAP_LIST 0x10 /* Support Capability List */
/* PCI30 6.7 Capabilities List */
#define PCI_CAPABILITY_LIST 0x34 /* Offset of first capability list entry */
@@ -119,7 +119,7 @@ struct _pciDeviceList {
/* PCIe20 7.8.3 Device Capabilities Register (Offset 04h) */
#define PCI_EXP_DEVCAP 0x4 /* Device capabilities */
-#define PCI_EXP_DEVCAP_FLR (1<<28) /* Function Level Reset */
+#define PCI_EXP_DEVCAP_FLR (1<<28) /* Function Level Reset */
/* Header type 1 BR12 3.2 PCI-to-PCI Bridge Configuration Space Header Format */
#define PCI_PRIMARY_BUS 0x18 /* BR12 3.2.5.2 Primary bus number */
@@ -127,18 +127,18 @@ struct _pciDeviceList {
#define PCI_SUBORDINATE_BUS 0x1a /* BR12 3.2.5.4 Highest bus number behind the bridge */
#define PCI_BRIDGE_CONTROL 0x3e
/* BR12 3.2.5.18 Bridge Control Register */
-#define PCI_BRIDGE_CTL_RESET 0x40 /* Secondary bus reset */
+#define PCI_BRIDGE_CTL_RESET 0x40 /* Secondary bus reset */
/* PM12 3.2.4 Power Management Control/Status (Offset = 4) */
#define PCI_PM_CTRL 4 /* PM control and status register */
-#define PCI_PM_CTRL_STATE_MASK 0x3 /* Current power state (D0 to D3) */
-#define PCI_PM_CTRL_STATE_D0 0x0 /* D0 state */
-#define PCI_PM_CTRL_STATE_D3hot 0x3 /* D3 state */
-#define PCI_PM_CTRL_NO_SOFT_RESET 0x8 /* No reset for D3hot->D0 */
+#define PCI_PM_CTRL_STATE_MASK 0x3 /* Current power state (D0 to D3) */
+#define PCI_PM_CTRL_STATE_D0 0x0 /* D0 state */
+#define PCI_PM_CTRL_STATE_D3hot 0x3 /* D3 state */
+#define PCI_PM_CTRL_NO_SOFT_RESET 0x8 /* No reset for D3hot->D0 */
/* ECN_AF 6.x.1 Advanced Features Capability Structure */
#define PCI_AF_CAP 0x3 /* Advanced features capabilities */
-#define PCI_AF_CAP_FLR 0x2 /* Function Level Reset */
+#define PCI_AF_CAP_FLR 0x2 /* Function Level Reset */
#define PCI_EXP_FLAGS 0x2
#define PCI_EXP_FLAGS_TYPE 0x00f0
diff --git a/src/util/pci.h b/src/util/pci.h
index b31d0cf..0ddbaa7 100644
--- a/src/util/pci.h
+++ b/src/util/pci.h
@@ -20,9 +20,9 @@
*/
#ifndef __VIR_PCI_H__
-#define __VIR_PCI_H__
+# define __VIR_PCI_H__
-#include "internal.h"
+# include "internal.h"
typedef struct _pciDevice pciDevice;
typedef struct _pciDeviceList pciDeviceList;
diff --git a/src/util/processinfo.c b/src/util/processinfo.c
index 5ae19f8..78e691e 100644
--- a/src/util/processinfo.c
+++ b/src/util/processinfo.c
@@ -22,7 +22,7 @@
#include <config.h>
#if HAVE_SCHED_H
-#include <sched.h>
+# include <sched.h>
#endif
#include "processinfo.h"
@@ -38,7 +38,7 @@ int virProcessInfoSetAffinity(pid_t pid,
int maxcpu)
{
int i;
-#ifdef CPU_ALLOC
+# ifdef CPU_ALLOC
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
int numcpus = 1024;
size_t masklen;
@@ -78,7 +78,7 @@ realloc:
return -1;
}
CPU_FREE(mask);
-#else
+# else
/* Legacy method uses a fixed size cpu mask, only allows upto 1024 cpus */
cpu_set_t mask;
@@ -93,7 +93,7 @@ realloc:
_("cannot set CPU affinity on process %d"), pid);
return -1;
}
-#endif
+# endif
return 0;
}
@@ -104,7 +104,7 @@ int virProcessInfoGetAffinity(pid_t pid,
int maxcpu)
{
int i;
-#ifdef CPU_ALLOC
+# ifdef CPU_ALLOC
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
int numcpus = 1024;
size_t masklen;
@@ -142,7 +142,7 @@ realloc:
for (i = 0 ; i < maxcpu ; i++)
if (CPU_ISSET_S(i, masklen, mask))
VIR_USE_CPU(map, i);
-#else
+# else
/* Legacy method uses a fixed size cpu mask, only allows upto 1024 cpus */
cpu_set_t mask;
@@ -156,7 +156,7 @@ realloc:
for (i = 0 ; i < maxcpu ; i++)
if (CPU_ISSET(i, &mask))
VIR_USE_CPU(map, i);
-#endif
+# endif
return 0;
}
diff --git a/src/util/processinfo.h b/src/util/processinfo.h
index 17800bd..65a7171 100644
--- a/src/util/processinfo.h
+++ b/src/util/processinfo.h
@@ -20,9 +20,9 @@
*/
#ifndef __VIR_PROCESSINFO_H__
-#define __VIR_PROCESSINFO_H__
+# define __VIR_PROCESSINFO_H__
-#include "internal.h"
+# include "internal.h"
int virProcessInfoSetAffinity(pid_t pid,
const unsigned char *map,
diff --git a/src/util/qparams.h b/src/util/qparams.h
index a2f5aa2..6a3d790 100644
--- a/src/util/qparams.h
+++ b/src/util/qparams.h
@@ -21,7 +21,7 @@
*/
#ifndef _QPARAMS_H_
-#define _QPARAMS_H_
+# define _QPARAMS_H_
/* Single web service query parameter 'name=value'. */
struct qparam {
diff --git a/src/util/stats_linux.c b/src/util/stats_linux.c
index feb5589..a12eb8c 100644
--- a/src/util/stats_linux.c
+++ b/src/util/stats_linux.c
@@ -13,22 +13,22 @@
/* This file only applies on Linux. */
#ifdef __linux__
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <regex.h>
-
-#include "virterror_internal.h"
-#include "datatypes.h"
-#include "util.h"
-#include "stats_linux.h"
-#include "memory.h"
-
-#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
-
-#define virStatsError(code, ...) \
+# include <stdio.h>
+# include <stdlib.h>
+# include <fcntl.h>
+# include <string.h>
+# include <unistd.h>
+# include <regex.h>
+
+# include "virterror_internal.h"
+# include "datatypes.h"
+# include "util.h"
+# include "stats_linux.h"
+# include "memory.h"
+
+# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
+
+# define virStatsError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_THIS, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
diff --git a/src/util/stats_linux.h b/src/util/stats_linux.h
index 3b00620..0aff832 100644
--- a/src/util/stats_linux.h
+++ b/src/util/stats_linux.h
@@ -9,15 +9,15 @@
*/
#ifndef __STATS_LINUX_H__
-#define __STATS_LINUX_H__
+# define __STATS_LINUX_H__
-#ifdef __linux__
+# ifdef __linux__
-#include "internal.h"
+# include "internal.h"
extern int linuxDomainInterfaceStats(const char *path,
struct _virDomainInterfaceStats *stats);
-#endif /* __linux__ */
+# endif /* __linux__ */
#endif /* __STATS_LINUX_H__ */
diff --git a/src/util/storage_file.h b/src/util/storage_file.h
index ca69a1b..ef97100 100644
--- a/src/util/storage_file.h
+++ b/src/util/storage_file.h
@@ -22,10 +22,10 @@
*/
#ifndef __VIR_STORAGE_FILE_H__
-#define __VIR_STORAGE_FILE_H__
+# define __VIR_STORAGE_FILE_H__
-#include "util.h"
-#include <stdbool.h>
+# include "util.h"
+# include <stdbool.h>
enum virStorageFileFormat {
VIR_STORAGE_FILE_RAW = 0,
diff --git a/src/util/threads.c b/src/util/threads.c
index d61b743..18f8b64 100644
--- a/src/util/threads.c
+++ b/src/util/threads.c
@@ -24,11 +24,11 @@
#include "threads.h"
#ifdef HAVE_PTHREAD_H
-#include "threads-pthread.c"
+# include "threads-pthread.c"
#else
-#ifdef WIN32
-#include "threads-win32.c"
-#else
-#error "Either pthreads or Win32 threads are required"
-#endif
+# ifdef WIN32
+# include "threads-win32.c"
+# else
+# error "Either pthreads or Win32 threads are required"
+# endif
#endif
diff --git a/src/util/threads.h b/src/util/threads.h
index d97463d..36fc600 100644
--- a/src/util/threads.h
+++ b/src/util/threads.h
@@ -20,9 +20,9 @@
*/
#ifndef __THREADS_H_
-#define __THREADS_H_
+# define __THREADS_H_
-#include "internal.h"
+# include "internal.h"
typedef struct virMutex virMutex;
typedef virMutex *virMutexPtr;
@@ -60,14 +60,14 @@ int virThreadLocalInit(virThreadLocalPtr l,
void *virThreadLocalGet(virThreadLocalPtr l);
void virThreadLocalSet(virThreadLocalPtr l, void*);
-#ifdef HAVE_PTHREAD_H
-#include "threads-pthread.h"
-#else
-#ifdef WIN32
-#include "threads-win32.h"
-#else
-#error "Either pthreads or Win32 threads are required"
-#endif
-#endif
+# ifdef HAVE_PTHREAD_H
+# include "threads-pthread.h"
+# else
+# ifdef WIN32
+# include "threads-win32.h"
+# else
+# error "Either pthreads or Win32 threads are required"
+# endif
+# endif
#endif
diff --git a/src/util/util.c b/src/util/util.c
index 360cc53..87b0714 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -38,31 +38,31 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#if HAVE_SYS_WAIT_H
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#if HAVE_MMAP
-#include <sys/mman.h>
+# include <sys/mman.h>
#endif
#include <string.h>
#include <signal.h>
#if HAVE_TERMIOS_H
-#include <termios.h>
+# include <termios.h>
#endif
#include "c-ctype.h"
#ifdef HAVE_PATHS_H
-#include <paths.h>
+# include <paths.h>
#endif
#include <netdb.h>
#ifdef HAVE_GETPWUID_R
-#include <pwd.h>
-#include <grp.h>
+# include <pwd.h>
+# include <grp.h>
#endif
#if HAVE_CAPNG
-#include <cap-ng.h>
+# include <cap-ng.h>
#endif
#ifdef HAVE_MNTENT_H
-#include <mntent.h>
+# include <mntent.h>
#endif
#include "areadlink.h"
@@ -135,7 +135,7 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
}
#else
-#ifdef HAVE_MMAP
+# ifdef HAVE_MMAP
int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
{
int r;
@@ -158,7 +158,7 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
return 0;
}
-#else /* HAVE_MMAP */
+# else /* HAVE_MMAP */
int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
{
@@ -195,7 +195,7 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
VIR_FREE(buf);
return 0;
}
-#endif /* HAVE_MMAP */
+# endif /* HAVE_MMAP */
#endif /* HAVE_POSIX_FALLOCATE */
#ifndef PROXY
@@ -244,14 +244,14 @@ virArgvToString(const char *const *argv)
}
int virSetNonBlock(int fd) {
-#ifndef WIN32
+# ifndef WIN32
int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0)
return -1;
flags |= O_NONBLOCK;
if ((fcntl(fd, F_SETFL, flags)) < 0)
return -1;
-#else
+# else
unsigned long flag = 1;
/* This is actually Gnulib's replacement rpl_ioctl function.
@@ -259,12 +259,12 @@ int virSetNonBlock(int fd) {
*/
if (ioctl (fd, FIONBIO, (void *) &flag) == -1)
return -1;
-#endif
+# endif
return 0;
}
-#ifndef WIN32
+# ifndef WIN32
int virSetCloseExec(int fd) {
int flags;
@@ -277,7 +277,7 @@ int virSetCloseExec(int fd) {
}
-#if HAVE_CAPNG
+# if HAVE_CAPNG
static int virClearCapabilities(void)
{
int ret;
@@ -291,13 +291,13 @@ static int virClearCapabilities(void)
return 0;
}
-#else
+# else
static int virClearCapabilities(void)
{
// VIR_WARN0("libcap-ng support not compiled in, unable to clear capabilities");
return 0;
}
-#endif
+# endif
/* virFork() - fork a new process while avoiding various race/deadlock conditions
@@ -944,7 +944,7 @@ virRunWithHook(const char *const*argv,
return ret;
}
-#else /* __MINGW32__ */
+# else /* __MINGW32__ */
int
virRunWithHook(const char *const *argv ATTRIBUTE_UNUSED,
@@ -973,7 +973,7 @@ virExec(const char *const*argv ATTRIBUTE_UNUSED,
return -1;
}
-#endif /* __MINGW32__ */
+# endif /* __MINGW32__ */
int
virRun(const char *const*argv,
@@ -1124,7 +1124,7 @@ int virFileHasSuffix(const char *str,
return STREQ(str + len - suffixlen, suffix);
}
-#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
+# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
@@ -1311,7 +1311,7 @@ error:
return ret;
}
-#ifndef WIN32
+# ifndef WIN32
int virFileOperation(const char *path, int openflags, mode_t mode,
uid_t uid, gid_t gid,
virFileOperationHook hook, void *hookdata,
@@ -1530,7 +1530,7 @@ childerror:
_exit(ret);
}
-#else /* WIN32 */
+# else /* WIN32 */
int virFileOperation(const char *path, int openflags, mode_t mode,
uid_t uid, gid_t gid,
@@ -1544,7 +1544,7 @@ int virDirCreate(const char *path, mode_t mode,
uid_t uid, gid_t gid, unsigned int flags) {
return virDirCreateNoFork(path, mode, uid, gid, flags);
}
-#endif
+# endif
static int virFileMakePathHelper(char *path) {
struct stat st;
@@ -1638,7 +1638,7 @@ int virFileOpenTty(int *ttymaster,
rawmode);
}
-#ifdef __linux__
+# ifdef __linux__
int virFileOpenTtyAt(const char *ptmx,
int *ttymaster,
char **ttyName,
@@ -1688,7 +1688,7 @@ cleanup:
return rc;
}
-#else
+# else
int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED,
int *ttymaster ATTRIBUTE_UNUSED,
char **ttyName ATTRIBUTE_UNUSED,
@@ -1696,7 +1696,7 @@ int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED,
{
return -1;
}
-#endif
+# endif
char* virFilePid(const char *dir, const char* name)
{
@@ -2276,7 +2276,7 @@ char *virIndexToDiskName(int idx, const char *prefix)
}
#ifndef AI_CANONIDN
-#define AI_CANONIDN 0
+# define AI_CANONIDN 0
#endif
char *virGetHostnameLocalhost(int allow_localhost)
@@ -2622,14 +2622,14 @@ cleanup:
#endif
#ifndef PROXY
-#if defined(UDEVADM) || defined(UDEVSETTLE)
+# if defined(UDEVADM) || defined(UDEVSETTLE)
void virFileWaitForDevices(void)
{
-#ifdef UDEVADM
+# ifdef UDEVADM
const char *const settleprog[] = { UDEVADM, "settle", NULL };
-#else
+# else
const char *const settleprog[] = { UDEVSETTLE, NULL };
-#endif
+# endif
int exitstatus;
if (access(settleprog[0], X_OK) != 0)
@@ -2644,9 +2644,9 @@ void virFileWaitForDevices(void)
if (virRun(settleprog, &exitstatus) < 0)
{}
}
-#else
+# else
void virFileWaitForDevices(void) {}
-#endif
+# endif
#endif
int virBuildPathInternal(char **path, ...)
diff --git a/src/util/util.h b/src/util/util.h
index 34b77fa..a1d9ed0 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -24,13 +24,13 @@
*/
#ifndef __VIR_UTIL_H__
-#define __VIR_UTIL_H__
+# define __VIR_UTIL_H__
-#include "verify.h"
-#include "internal.h"
-#include <unistd.h>
-#include <sys/select.h>
-#include <sys/types.h>
+# include "verify.h"
+# include "internal.h"
+# include <unistd.h>
+# include <sys/select.h>
+# include <sys/types.h>
int saferead(int fd, void *buf, size_t count) ATTRIBUTE_RETURN_CHECK;
ssize_t safewrite(int fd, const void *buf, size_t count)
@@ -195,11 +195,11 @@ char *virStrncpy(char *dest, const char *src, size_t n, size_t destbytes)
ATTRIBUTE_RETURN_CHECK;
char *virStrcpy(char *dest, const char *src, size_t destbytes)
ATTRIBUTE_RETURN_CHECK;
-#define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
+# define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
-#define VIR_MAC_BUFLEN 6
-#define VIR_MAC_PREFIX_BUFLEN 3
-#define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3
+# define VIR_MAC_BUFLEN 6
+# define VIR_MAC_PREFIX_BUFLEN 3
+# define VIR_MAC_STRING_BUFLEN VIR_MAC_BUFLEN * 3
int virParseMacAddr(const char* str,
unsigned char *addr) ATTRIBUTE_RETURN_CHECK;
@@ -219,7 +219,7 @@ const char *virEnumToString(const char *const*types,
unsigned int ntypes,
int type);
-#define VIR_ENUM_IMPL(name, lastVal, ...) \
+# define VIR_ENUM_IMPL(name, lastVal, ...) \
static const char *const name ## TypeList[] = { __VA_ARGS__ }; \
extern int (* name ## Verify (void)) [verify_true (ARRAY_CARDINALITY(name ## TypeList) == lastVal)]; \
const char *name ## TypeToString(int type) { \
@@ -233,42 +233,42 @@ const char *virEnumToString(const char *const*types,
type); \
}
-#define VIR_ENUM_DECL(name) \
+# define VIR_ENUM_DECL(name) \
const char *name ## TypeToString(int type); \
int name ## TypeFromString(const char*type);
-#ifndef HAVE_GETUID
+# ifndef HAVE_GETUID
static inline int getuid (void) { return 0; }
-#endif
+# endif
-#ifndef HAVE_GETGID
+# ifndef HAVE_GETGID
static inline int getgid (void) { return 0; }
-#endif
+# endif
char *virGetHostnameLocalhost(int allow_localhost);
char *virGetHostname(virConnectPtr conn);
int virKillProcess(pid_t pid, int sig);
-#ifdef HAVE_GETPWUID_R
+# ifdef HAVE_GETPWUID_R
char *virGetUserDirectory(uid_t uid);
char *virGetUserName(uid_t uid);
int virGetUserID(const char *name,
uid_t *uid) ATTRIBUTE_RETURN_CHECK;
int virGetGroupID(const char *name,
gid_t *gid) ATTRIBUTE_RETURN_CHECK;
-#endif
+# endif
int virRandomInitialize(unsigned int seed) ATTRIBUTE_RETURN_CHECK;
int virRandom(int max);
-#ifdef HAVE_MNTENT_H
+# ifdef HAVE_MNTENT_H
char *virFileFindMountPoint(const char *type);
-#endif
+# endif
void virFileWaitForDevices(void);
-#define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
+# define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
int virBuildPathInternal(char **path, ...) ATTRIBUTE_SENTINEL;
#endif /* __VIR_UTIL_H__ */
diff --git a/src/util/uuid.c b/src/util/uuid.c
index 56e53a3..459273a 100644
--- a/src/util/uuid.c
+++ b/src/util/uuid.c
@@ -40,7 +40,7 @@
#include "logging.h"
#ifndef ENODATA
-#define ENODATA EIO
+# define ENODATA EIO
#endif
static int
diff --git a/src/util/uuid.h b/src/util/uuid.h
index c5230a8..b6ac372 100644
--- a/src/util/uuid.h
+++ b/src/util/uuid.h
@@ -20,7 +20,7 @@
*/
#ifndef __VIR_UUID_H__
-#define __VIR_UUID_H__
+# define __VIR_UUID_H__
int virUUIDGenerate(unsigned char *uuid);
diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h
index fba3078..601a884 100644
--- a/src/util/virterror_internal.h
+++ b/src/util/virterror_internal.h
@@ -20,9 +20,9 @@
*/
#ifndef __VIRT_ERROR_H_
-#define __VIRT_ERROR_H_
+# define __VIRT_ERROR_H_
-#include "internal.h"
+# include "internal.h"
extern virErrorFunc virErrorHandler;
extern void *virUserData;
@@ -49,7 +49,7 @@ void virRaiseErrorFull(virConnectPtr conn,
ATTRIBUTE_FMT_PRINTF(13, 14);
/* Includes 'dom' and 'net' for compatbility, but they're ignored */
-#define virRaiseError(conn, dom, net, domain, code, level, \
+# define virRaiseError(conn, dom, net, domain, code, level, \
str1, str2, str3, int1, int2, msg, ...) \
virRaiseErrorFull(conn, __FILE__, __FUNCTION__, __LINE__, \
domain, code, level, str1, str2, str3, int1, int2, \
@@ -71,7 +71,7 @@ void virReportSystemErrorFull(int domcode,
const char *fmt, ...)
ATTRIBUTE_FMT_PRINTF(6, 7);
-#define virReportSystemError(theerrno, fmt,...) \
+# define virReportSystemError(theerrno, fmt,...) \
virReportSystemErrorFull(VIR_FROM_THIS, \
(theerrno), \
__FILE__, __FUNCTION__, __LINE__, \
@@ -82,7 +82,7 @@ void virReportOOMErrorFull(int domcode,
const char *funcname,
size_t linenr);
-#define virReportOOMError() \
+# define virReportOOMError() \
virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
diff --git a/src/util/xml.h b/src/util/xml.h
index af721bb..a42a2d7 100644
--- a/src/util/xml.h
+++ b/src/util/xml.h
@@ -3,13 +3,13 @@
*/
#ifndef __VIR_XML_H__
-#define __VIR_XML_H__
+# define __VIR_XML_H__
-#include "internal.h"
+# include "internal.h"
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
+# include <libxml/parser.h>
+# include <libxml/tree.h>
+# include <libxml/xpath.h>
int virXPathBoolean(const char *xpath,
xmlXPathContextPtr ctxt);
diff --git a/src/vbox/vbox_CAPI_v2_2.h b/src/vbox/vbox_CAPI_v2_2.h
index 41b2c1c..674b4e3 100644
--- a/src/vbox/vbox_CAPI_v2_2.h
+++ b/src/vbox/vbox_CAPI_v2_2.h
@@ -43,193 +43,193 @@
*/
#ifndef ___VirtualBox_CXPCOM_h
-#define ___VirtualBox_CXPCOM_h
+# define ___VirtualBox_CXPCOM_h
-#ifdef __cplusplus
-# include "VirtualBox_XPCOM.h"
-#else /* !__cplusplus */
+# ifdef __cplusplus
+# include "VirtualBox_XPCOM.h"
+# else /* !__cplusplus */
-#include <stddef.h>
-#include "wchar.h"
+# include <stddef.h>
+# include "wchar.h"
-#if defined(WIN32)
+# if defined(WIN32)
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) __declspec(dllimport) __type
-#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) __declspec(dllimport) __type
+# define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
-#elif defined(XP_BEOS)
+# elif defined(XP_BEOS)
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(WIN16)
-
-#define PR_CALLBACK_DECL __cdecl
-
-#if defined(_WINDLL)
-#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
-#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
-#define PR_EXPORT_DATA(__type) extern __type _export
-#define PR_IMPORT_DATA(__type) extern __type _export
-
-#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
-#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
-#define PR_EXTERN_DATA(__type) extern __type _export
-#define PR_IMPLEMENT_DATA(__type) __type _export
-
-#define PR_CALLBACK __cdecl __loadds
-#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
-
-#else /* this must be .EXE */
-#define PR_EXPORT(__type) extern __type _cdecl _export
-#define PR_IMPORT(__type) extern __type _cdecl _export
-#define PR_EXPORT_DATA(__type) extern __type _export
-#define PR_IMPORT_DATA(__type) extern __type _export
-
-#define PR_EXTERN(__type) extern __type _cdecl _export
-#define PR_IMPLEMENT(__type) __type _cdecl _export
-#define PR_EXTERN_DATA(__type) extern __type _export
-#define PR_IMPLEMENT_DATA(__type) __type _export
-
-#define PR_CALLBACK __cdecl __loadds
-#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
-#endif /* _WINDLL */
-
-#elif defined(XP_MAC)
-
-#define PR_EXPORT(__type) extern __declspec(export) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
-#define PR_IMPORT(__type) extern __declspec(export) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
-
-#define PR_EXTERN(__type) extern __declspec(export) __type
-#define PR_IMPLEMENT(__type) __declspec(export) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(XP_OS2) && defined(__declspec)
-
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) __declspec(dllimport) __type
-#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(XP_OS2_VACPP)
-
-#define PR_EXPORT(__type) extern __type
-#define PR_EXPORT_DATA(__type) extern __type
-#define PR_IMPORT(__type) extern __type
-#define PR_IMPORT_DATA(__type) extern __type
-
-#define PR_EXTERN(__type) extern __type
-#define PR_IMPLEMENT(__type) __type
-#define PR_EXTERN_DATA(__type) extern __type
-#define PR_IMPLEMENT_DATA(__type) __type
-#define PR_CALLBACK _Optlink
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
-
-#else /* Unix */
-
-# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
-# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
-# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPORT(__type) extern __type
-# define PR_IMPORT_DATA(__type) extern __type
-# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
-# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
-# define PR_CALLBACK
-# define PR_CALLBACK_DECL
-# define PR_STATIC_CALLBACK(__x) static __x
-# else
-# define PR_EXPORT(__type) extern __type
-# define PR_EXPORT_DATA(__type) extern __type
-# define PR_IMPORT(__type) extern __type
-# define PR_IMPORT_DATA(__type) extern __type
-# define PR_EXTERN(__type) extern __type
-# define PR_IMPLEMENT(__type) __type
-# define PR_EXTERN_DATA(__type) extern __type
-# define PR_IMPLEMENT_DATA(__type) __type
-# define PR_CALLBACK
-# define PR_CALLBACK_DECL
-# define PR_STATIC_CALLBACK(__x) static __x
-# endif
-#endif
-
-#if defined(_NSPR_BUILD_)
-#define NSPR_API(__type) PR_EXPORT(__type)
-#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
-#else
-#define NSPR_API(__type) PR_IMPORT(__type)
-#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
-#endif
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
+
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(WIN16)
+
+# define PR_CALLBACK_DECL __cdecl
+
+# if defined(_WINDLL)
+# define PR_EXPORT(__type) extern __type _cdecl _export _loadds
+# define PR_IMPORT(__type) extern __type _cdecl _export _loadds
+# define PR_EXPORT_DATA(__type) extern __type _export
+# define PR_IMPORT_DATA(__type) extern __type _export
+
+# define PR_EXTERN(__type) extern __type _cdecl _export _loadds
+# define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
+# define PR_EXTERN_DATA(__type) extern __type _export
+# define PR_IMPLEMENT_DATA(__type) __type _export
+
+# define PR_CALLBACK __cdecl __loadds
+# define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
+# else /* this must be .EXE */
+# define PR_EXPORT(__type) extern __type _cdecl _export
+# define PR_IMPORT(__type) extern __type _cdecl _export
+# define PR_EXPORT_DATA(__type) extern __type _export
+# define PR_IMPORT_DATA(__type) extern __type _export
+
+# define PR_EXTERN(__type) extern __type _cdecl _export
+# define PR_IMPLEMENT(__type) __type _cdecl _export
+# define PR_EXTERN_DATA(__type) extern __type _export
+# define PR_IMPLEMENT_DATA(__type) __type _export
+
+# define PR_CALLBACK __cdecl __loadds
+# define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
+# endif /* _WINDLL */
+
+# elif defined(XP_MAC)
+
+# define PR_EXPORT(__type) extern __declspec(export) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(export) __type
+# define PR_IMPORT(__type) extern __declspec(export) __type
+# define PR_IMPORT_DATA(__type) extern __declspec(export) __type
+
+# define PR_EXTERN(__type) extern __declspec(export) __type
+# define PR_IMPLEMENT(__type) __declspec(export) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(export) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(XP_OS2) && defined(__declspec)
+
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) __declspec(dllimport) __type
+# define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
+
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(XP_OS2_VACPP)
+
+# define PR_EXPORT(__type) extern __type
+# define PR_EXPORT_DATA(__type) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+
+# define PR_EXTERN(__type) extern __type
+# define PR_IMPLEMENT(__type) __type
+# define PR_EXTERN_DATA(__type) extern __type
+# define PR_IMPLEMENT_DATA(__type) __type
+# define PR_CALLBACK _Optlink
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
+# else /* Unix */
+
+# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
+# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
+# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
+# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+# else
+# define PR_EXPORT(__type) extern __type
+# define PR_EXPORT_DATA(__type) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+# define PR_EXTERN(__type) extern __type
+# define PR_IMPLEMENT(__type) __type
+# define PR_EXTERN_DATA(__type) extern __type
+# define PR_IMPLEMENT_DATA(__type) __type
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+# endif
+# endif
+
+# if defined(_NSPR_BUILD_)
+# define NSPR_API(__type) PR_EXPORT(__type)
+# define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
+# else
+# define NSPR_API(__type) PR_IMPORT(__type)
+# define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
+# endif
typedef unsigned char PRUint8;
-#if (defined(HPUX) && defined(__cplusplus) \
+# if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
-#else
+# else
typedef signed char PRInt8;
-#endif
+# endif
-#define PR_INT8_MAX 127
-#define PR_INT8_MIN (-128)
-#define PR_UINT8_MAX 255U
+# define PR_INT8_MAX 127
+# define PR_INT8_MIN (-128)
+# define PR_UINT8_MAX 255U
typedef unsigned short PRUint16;
typedef short PRInt16;
-#define PR_INT16_MAX 32767
-#define PR_INT16_MIN (-32768)
-#define PR_UINT16_MAX 65535U
+# define PR_INT16_MAX 32767
+# define PR_INT16_MIN (-32768)
+# define PR_UINT16_MAX 65535U
typedef unsigned int PRUint32;
typedef int PRInt32;
-#define PR_INT32(x) x
-#define PR_UINT32(x) x ## U
+# define PR_INT32(x) x
+# define PR_UINT32(x) x ## U
-#define PR_INT32_MAX PR_INT32(2147483647)
-#define PR_INT32_MIN (-PR_INT32_MAX - 1)
-#define PR_UINT32_MAX PR_UINT32(4294967295)
+# define PR_INT32_MAX PR_INT32(2147483647)
+# define PR_INT32_MIN (-PR_INT32_MAX - 1)
+# define PR_UINT32_MAX PR_UINT32(4294967295)
typedef long PRInt64;
typedef unsigned long PRUint64;
@@ -245,8 +245,8 @@ typedef unsigned long PRUptrdiff;
typedef PRIntn PRBool;
-#define PR_TRUE 1
-#define PR_FALSE 0
+# define PR_TRUE 1
+# define PR_FALSE 0
typedef PRUint8 PRPackedBool;
@@ -256,31 +256,31 @@ typedef PRUint8 PRPackedBool;
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
-#ifndef __PRUNICHAR__
-#define __PRUNICHAR__
-#if defined(WIN32) || defined(XP_MAC)
+# ifndef __PRUNICHAR__
+# define __PRUNICHAR__
+# if defined(WIN32) || defined(XP_MAC)
typedef wchar_t PRUnichar;
-#else
+# else
typedef PRUint16 PRUnichar;
-#endif
-#endif
+# endif
+# endif
typedef long PRWord;
typedef unsigned long PRUword;
-#define nsnull 0
+# define nsnull 0
typedef PRUint32 nsresult;
-#if defined(__GNUC__) && (__GNUC__ > 2)
-#define NS_LIKELY(x) (__builtin_expect((x), 1))
-#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
-#else
-#define NS_LIKELY(x) (x)
-#define NS_UNLIKELY(x) (x)
-#endif
+# if defined(__GNUC__) && (__GNUC__ > 2)
+# define NS_LIKELY(x) (__builtin_expect((x), 1))
+# define NS_UNLIKELY(x) (__builtin_expect((x), 0))
+# else
+# define NS_LIKELY(x) (x)
+# define NS_UNLIKELY(x) (x)
+# endif
-#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
-#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
+# define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
+# define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
/**
* An "interface id" which can be used to uniquely identify a given
@@ -312,7 +312,7 @@ typedef struct nsIException nsIException; /* forward declaration */
* To maintain binary compatibility with COM's IUnknown, we define the IID
* of nsISupports to be the same as that of COM's IUnknown.
*/
-#define NS_ISUPPORTS_IID \
+# define NS_ISUPPORTS_IID \
{ 0x00000000, 0x0000, 0x0000, \
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
@@ -372,9 +372,9 @@ struct nsISupports {
};
/* starting interface: nsIException */
-#define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
+# define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
-#define NS_IEXCEPTION_IID \
+# define NS_IEXCEPTION_IID \
{0xf3a8d3b4, 0xc424, 0x4edc, \
{ 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }}
@@ -419,9 +419,9 @@ struct nsIException {
};
/* starting interface: nsIStackFrame */
-#define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
+# define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
-#define NS_ISTACKFRAME_IID \
+# define NS_ISTACKFRAME_IID \
{0x91d82105, 0x7c62, 0x4f8b, \
{ 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }}
@@ -460,18 +460,18 @@ struct nsIStackFrame {
};
-#define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001
-#define VBOX_E_INVALID_VM_STATE 0x80BB0002
-#define VBOX_E_VM_ERROR 0x80BB0003
-#define VBOX_E_FILE_ERROR 0x80BB0004
-#define VBOX_E_IPRT_ERROR 0x80BB0005
-#define VBOX_E_PDM_ERROR 0x80BB0006
-#define VBOX_E_INVALID_OBJECT_STATE 0x80BB0007
-#define VBOX_E_HOST_ERROR 0x80BB0008
-#define VBOX_E_NOT_SUPPORTED 0x80BB0009
-#define VBOX_E_XML_ERROR 0x80BB000A
-#define VBOX_E_INVALID_SESSION_STATE 0x80BB000B
-#define VBOX_E_OBJECT_IN_USE 0x80BB000C
+# define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001
+# define VBOX_E_INVALID_VM_STATE 0x80BB0002
+# define VBOX_E_VM_ERROR 0x80BB0003
+# define VBOX_E_FILE_ERROR 0x80BB0004
+# define VBOX_E_IPRT_ERROR 0x80BB0005
+# define VBOX_E_PDM_ERROR 0x80BB0006
+# define VBOX_E_INVALID_OBJECT_STATE 0x80BB0007
+# define VBOX_E_HOST_ERROR 0x80BB0008
+# define VBOX_E_NOT_SUPPORTED 0x80BB0009
+# define VBOX_E_XML_ERROR 0x80BB000A
+# define VBOX_E_INVALID_SESSION_STATE 0x80BB000B
+# define VBOX_E_OBJECT_IN_USE 0x80BB000C
struct IVirtualBoxErrorInfo;
@@ -583,8 +583,8 @@ typedef struct IPerformanceMetric IPerformanceMetric;
typedef struct IPerformanceCollector IPerformanceCollector;
/* Start of enum TSBool Declaration */
-#define TSBOOL_IID_STR "523ff64d-842a-4b1a-80e7-c311b028cb3a"
-#define TSBOOL_IID { \
+# define TSBOOL_IID_STR "523ff64d-842a-4b1a-80e7-c311b028cb3a"
+# define TSBOOL_IID { \
0x523ff64d, 0x842a, 0x4b1a, \
{ 0x80, 0xe7, 0xc3, 0x11, 0xb0, 0x28, 0xcb, 0x3a } \
}
@@ -598,8 +598,8 @@ enum TSBool
/* Start of enum AccessMode Declaration */
-#define ACCESSMODE_IID_STR "1da0007c-ddf7-4be8-bcac-d84a1558785f"
-#define ACCESSMODE_IID { \
+# define ACCESSMODE_IID_STR "1da0007c-ddf7-4be8-bcac-d84a1558785f"
+# define ACCESSMODE_IID { \
0x1da0007c, 0xddf7, 0x4be8, \
{ 0xbc, 0xac, 0xd8, 0x4a, 0x15, 0x58, 0x78, 0x5f } \
}
@@ -612,8 +612,8 @@ enum AccessMode
/* Start of enum MachineState Declaration */
-#define MACHINESTATE_IID_STR "73bf04d0-7c4f-4684-9abf-d65a9ad74343"
-#define MACHINESTATE_IID { \
+# define MACHINESTATE_IID_STR "73bf04d0-7c4f-4684-9abf-d65a9ad74343"
+# define MACHINESTATE_IID { \
0x73bf04d0, 0x7c4f, 0x4684, \
{ 0x9a, 0xbf, 0xd6, 0x5a, 0x9a, 0xd7, 0x43, 0x43 } \
}
@@ -641,8 +641,8 @@ enum MachineState
/* Start of enum SessionState Declaration */
-#define SESSIONSTATE_IID_STR "CF2700C0-EA4B-47ae-9725-7810114B94D8"
-#define SESSIONSTATE_IID { \
+# define SESSIONSTATE_IID_STR "CF2700C0-EA4B-47ae-9725-7810114B94D8"
+# define SESSIONSTATE_IID { \
0xCF2700C0, 0xEA4B, 0x47ae, \
{ 0x97, 0x25, 0x78, 0x10, 0x11, 0x4B, 0x94, 0xD8 } \
}
@@ -658,8 +658,8 @@ enum SessionState
/* Start of enum SessionType Declaration */
-#define SESSIONTYPE_IID_STR "A13C02CB-0C2C-421E-8317-AC0E8AAA153A"
-#define SESSIONTYPE_IID { \
+# define SESSIONTYPE_IID_STR "A13C02CB-0C2C-421E-8317-AC0E8AAA153A"
+# define SESSIONTYPE_IID { \
0xA13C02CB, 0x0C2C, 0x421E, \
{ 0x83, 0x17, 0xAC, 0x0E, 0x8A, 0xAA, 0x15, 0x3A } \
}
@@ -674,8 +674,8 @@ enum SessionType
/* Start of enum DeviceType Declaration */
-#define DEVICETYPE_IID_STR "6d9420f7-0b56-4636-99f9-7346f1b01e57"
-#define DEVICETYPE_IID { \
+# define DEVICETYPE_IID_STR "6d9420f7-0b56-4636-99f9-7346f1b01e57"
+# define DEVICETYPE_IID { \
0x6d9420f7, 0x0b56, 0x4636, \
{ 0x99, 0xf9, 0x73, 0x46, 0xf1, 0xb0, 0x1e, 0x57 } \
}
@@ -693,8 +693,8 @@ enum DeviceType
/* Start of enum DeviceActivity Declaration */
-#define DEVICEACTIVITY_IID_STR "6FC8AEAA-130A-4eb5-8954-3F921422D707"
-#define DEVICEACTIVITY_IID { \
+# define DEVICEACTIVITY_IID_STR "6FC8AEAA-130A-4eb5-8954-3F921422D707"
+# define DEVICEACTIVITY_IID { \
0x6FC8AEAA, 0x130A, 0x4eb5, \
{ 0x89, 0x54, 0x3F, 0x92, 0x14, 0x22, 0xD7, 0x07 } \
}
@@ -709,8 +709,8 @@ enum DeviceActivity
/* Start of enum ClipboardMode Declaration */
-#define CLIPBOARDMODE_IID_STR "33364716-4008-4701-8f14-be0fa3d62950"
-#define CLIPBOARDMODE_IID { \
+# define CLIPBOARDMODE_IID_STR "33364716-4008-4701-8f14-be0fa3d62950"
+# define CLIPBOARDMODE_IID { \
0x33364716, 0x4008, 0x4701, \
{ 0x8f, 0x14, 0xbe, 0x0f, 0xa3, 0xd6, 0x29, 0x50 } \
}
@@ -725,8 +725,8 @@ enum ClipboardMode
/* Start of enum Scope Declaration */
-#define SCOPE_IID_STR "7c91096e-499e-4eca-9f9b-9001438d7855"
-#define SCOPE_IID { \
+# define SCOPE_IID_STR "7c91096e-499e-4eca-9f9b-9001438d7855"
+# define SCOPE_IID { \
0x7c91096e, 0x499e, 0x4eca, \
{ 0x9f, 0x9b, 0x90, 0x01, 0x43, 0x8d, 0x78, 0x55 } \
}
@@ -740,8 +740,8 @@ enum Scope
/* Start of enum GuestStatisticType Declaration */
-#define GUESTSTATISTICTYPE_IID_STR "aa7c1d71-aafe-47a8-9608-27d2d337cf55"
-#define GUESTSTATISTICTYPE_IID { \
+# define GUESTSTATISTICTYPE_IID_STR "aa7c1d71-aafe-47a8-9608-27d2d337cf55"
+# define GUESTSTATISTICTYPE_IID { \
0xaa7c1d71, 0xaafe, 0x47a8, \
{ 0x96, 0x08, 0x27, 0xd2, 0xd3, 0x37, 0xcf, 0x55 } \
}
@@ -770,8 +770,8 @@ enum GuestStatisticType
/* Start of enum BIOSBootMenuMode Declaration */
-#define BIOSBOOTMENUMODE_IID_STR "ae4fb9f7-29d2-45b4-b2c7-d579603135d5"
-#define BIOSBOOTMENUMODE_IID { \
+# define BIOSBOOTMENUMODE_IID_STR "ae4fb9f7-29d2-45b4-b2c7-d579603135d5"
+# define BIOSBOOTMENUMODE_IID { \
0xae4fb9f7, 0x29d2, 0x45b4, \
{ 0xb2, 0xc7, 0xd5, 0x79, 0x60, 0x31, 0x35, 0xd5 } \
}
@@ -785,8 +785,8 @@ enum BIOSBootMenuMode
/* Start of enum DriveState Declaration */
-#define DRIVESTATE_IID_STR "cb7233b7-c519-42a5-8310-1830953cacbc"
-#define DRIVESTATE_IID { \
+# define DRIVESTATE_IID_STR "cb7233b7-c519-42a5-8310-1830953cacbc"
+# define DRIVESTATE_IID { \
0xcb7233b7, 0xc519, 0x42a5, \
{ 0x83, 0x10, 0x18, 0x30, 0x95, 0x3c, 0xac, 0xbc } \
}
@@ -801,8 +801,8 @@ enum DriveState
/* Start of enum ProcessorFeature Declaration */
-#define PROCESSORFEATURE_IID_STR "b8353b35-705d-4796-9967-ebfb7ba54af4"
-#define PROCESSORFEATURE_IID { \
+# define PROCESSORFEATURE_IID_STR "b8353b35-705d-4796-9967-ebfb7ba54af4"
+# define PROCESSORFEATURE_IID { \
0xb8353b35, 0x705d, 0x4796, \
{ 0x99, 0x67, 0xeb, 0xfb, 0x7b, 0xa5, 0x4a, 0xf4 } \
}
@@ -816,8 +816,8 @@ enum ProcessorFeature
/* Start of enum CIMOSType Declaration */
-#define CIMOSTYPE_IID_STR "86ef5f8c-18b2-4db8-a314-33721b59f89b"
-#define CIMOSTYPE_IID { \
+# define CIMOSTYPE_IID_STR "86ef5f8c-18b2-4db8-a314-33721b59f89b"
+# define CIMOSTYPE_IID { \
0x86ef5f8c, 0x18b2, 0x4db8, \
{ 0xa3, 0x14, 0x33, 0x72, 0x1b, 0x59, 0xf8, 0x9b } \
}
@@ -931,8 +931,8 @@ enum CIMOSType
/* Start of enum OVFResourceType Declaration */
-#define OVFRESOURCETYPE_IID_STR "646a78d7-6f04-49f4-82c4-75c28a75a4cd"
-#define OVFRESOURCETYPE_IID { \
+# define OVFRESOURCETYPE_IID_STR "646a78d7-6f04-49f4-82c4-75c28a75a4cd"
+# define OVFRESOURCETYPE_IID { \
0x646a78d7, 0x6f04, 0x49f4, \
{ 0x82, 0xc4, 0x75, 0xc2, 0x8a, 0x75, 0xa4, 0xcd } \
}
@@ -963,8 +963,8 @@ enum OVFResourceType
/* Start of enum VirtualSystemDescriptionType Declaration */
-#define VIRTUALSYSTEMDESCRIPTIONTYPE_IID_STR "aacc58de-5b45-4f82-ae2e-dd9a824fc3b5"
-#define VIRTUALSYSTEMDESCRIPTIONTYPE_IID { \
+# define VIRTUALSYSTEMDESCRIPTIONTYPE_IID_STR "aacc58de-5b45-4f82-ae2e-dd9a824fc3b5"
+# define VIRTUALSYSTEMDESCRIPTIONTYPE_IID { \
0xaacc58de, 0x5b45, 0x4f82, \
{ 0xae, 0x2e, 0xdd, 0x9a, 0x82, 0x4f, 0xc3, 0xb5 } \
}
@@ -997,8 +997,8 @@ enum VirtualSystemDescriptionType
/* Start of enum VirtualSystemDescriptionValueType Declaration */
-#define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID_STR "56d9403f-3425-4118-9919-36f2a9b8c77c"
-#define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID { \
+# define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID_STR "56d9403f-3425-4118-9919-36f2a9b8c77c"
+# define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID { \
0x56d9403f, 0x3425, 0x4118, \
{ 0x99, 0x19, 0x36, 0xf2, 0xa9, 0xb8, 0xc7, 0x7c } \
}
@@ -1013,8 +1013,8 @@ enum VirtualSystemDescriptionValueType
/* Start of enum HostNetworkInterfaceMediumType Declaration */
-#define HOSTNETWORKINTERFACEMEDIUMTYPE_IID_STR "1aa54aaf-2497-45a2-bfb1-8eb225e93d5b"
-#define HOSTNETWORKINTERFACEMEDIUMTYPE_IID { \
+# define HOSTNETWORKINTERFACEMEDIUMTYPE_IID_STR "1aa54aaf-2497-45a2-bfb1-8eb225e93d5b"
+# define HOSTNETWORKINTERFACEMEDIUMTYPE_IID { \
0x1aa54aaf, 0x2497, 0x45a2, \
{ 0xbf, 0xb1, 0x8e, 0xb2, 0x25, 0xe9, 0x3d, 0x5b } \
}
@@ -1029,8 +1029,8 @@ enum HostNetworkInterfaceMediumType
/* Start of enum HostNetworkInterfaceStatus Declaration */
-#define HOSTNETWORKINTERFACESTATUS_IID_STR "CC474A69-2710-434B-8D99-C38E5D5A6F41"
-#define HOSTNETWORKINTERFACESTATUS_IID { \
+# define HOSTNETWORKINTERFACESTATUS_IID_STR "CC474A69-2710-434B-8D99-C38E5D5A6F41"
+# define HOSTNETWORKINTERFACESTATUS_IID { \
0xCC474A69, 0x2710, 0x434B, \
{ 0x8D, 0x99, 0xC3, 0x8E, 0x5D, 0x5A, 0x6F, 0x41 } \
}
@@ -1044,8 +1044,8 @@ enum HostNetworkInterfaceStatus
/* Start of enum HostNetworkInterfaceType Declaration */
-#define HOSTNETWORKINTERFACETYPE_IID_STR "67431b00-9946-48a2-bc02-b25c5919f4f3"
-#define HOSTNETWORKINTERFACETYPE_IID { \
+# define HOSTNETWORKINTERFACETYPE_IID_STR "67431b00-9946-48a2-bc02-b25c5919f4f3"
+# define HOSTNETWORKINTERFACETYPE_IID { \
0x67431b00, 0x9946, 0x48a2, \
{ 0xbc, 0x02, 0xb2, 0x5c, 0x59, 0x19, 0xf4, 0xf3 } \
}
@@ -1058,8 +1058,8 @@ enum HostNetworkInterfaceType
/* Start of enum MediaState Declaration */
-#define MEDIASTATE_IID_STR "8b86e03c-2f1c-412a-8fbd-326f62701200"
-#define MEDIASTATE_IID { \
+# define MEDIASTATE_IID_STR "8b86e03c-2f1c-412a-8fbd-326f62701200"
+# define MEDIASTATE_IID { \
0x8b86e03c, 0x2f1c, 0x412a, \
{ 0x8f, 0xbd, 0x32, 0x6f, 0x62, 0x70, 0x12, 0x00 } \
}
@@ -1077,8 +1077,8 @@ enum MediaState
/* Start of enum HardDiskType Declaration */
-#define HARDDISKTYPE_IID_STR "a348fafd-a64e-4643-ba65-eb3896bd7e0a"
-#define HARDDISKTYPE_IID { \
+# define HARDDISKTYPE_IID_STR "a348fafd-a64e-4643-ba65-eb3896bd7e0a"
+# define HARDDISKTYPE_IID { \
0xa348fafd, 0xa64e, 0x4643, \
{ 0xba, 0x65, 0xeb, 0x38, 0x96, 0xbd, 0x7e, 0x0a } \
}
@@ -1092,8 +1092,8 @@ enum HardDiskType
/* Start of enum HardDiskVariant Declaration */
-#define HARDDISKVARIANT_IID_STR "eb7fc6b3-ae23-4c5d-a1f6-e3522dd1efb0"
-#define HARDDISKVARIANT_IID { \
+# define HARDDISKVARIANT_IID_STR "eb7fc6b3-ae23-4c5d-a1f6-e3522dd1efb0"
+# define HARDDISKVARIANT_IID { \
0xeb7fc6b3, 0xae23, 0x4c5d, \
{ 0xa1, 0xf6, 0xe3, 0x52, 0x2d, 0xd1, 0xef, 0xb0 } \
}
@@ -1110,8 +1110,8 @@ enum HardDiskVariant
/* Start of enum DataType Declaration */
-#define DATATYPE_IID_STR "d90ea51e-a3f1-4a01-beb1-c1723c0d3ba7"
-#define DATATYPE_IID { \
+# define DATATYPE_IID_STR "d90ea51e-a3f1-4a01-beb1-c1723c0d3ba7"
+# define DATATYPE_IID { \
0xd90ea51e, 0xa3f1, 0x4a01, \
{ 0xbe, 0xb1, 0xc1, 0x72, 0x3c, 0x0d, 0x3b, 0xa7 } \
}
@@ -1125,8 +1125,8 @@ enum DataType
/* Start of enum DataFlags Declaration */
-#define DATAFLAGS_IID_STR "86884dcf-1d6b-4f1b-b4bf-f5aa44959d60"
-#define DATAFLAGS_IID { \
+# define DATAFLAGS_IID_STR "86884dcf-1d6b-4f1b-b4bf-f5aa44959d60"
+# define DATAFLAGS_IID { \
0x86884dcf, 0x1d6b, 0x4f1b, \
{ 0xb4, 0xbf, 0xf5, 0xaa, 0x44, 0x95, 0x9d, 0x60 } \
}
@@ -1142,8 +1142,8 @@ enum DataFlags
/* Start of enum HardDiskFormatCapabilities Declaration */
-#define HARDDISKFORMATCAPABILITIES_IID_STR "1df1e4aa-d25a-4ba6-b2a2-02f60eb5903b"
-#define HARDDISKFORMATCAPABILITIES_IID { \
+# define HARDDISKFORMATCAPABILITIES_IID_STR "1df1e4aa-d25a-4ba6-b2a2-02f60eb5903b"
+# define HARDDISKFORMATCAPABILITIES_IID { \
0x1df1e4aa, 0xd25a, 0x4ba6, \
{ 0xb2, 0xa2, 0x02, 0xf6, 0x0e, 0xb5, 0x90, 0x3b } \
}
@@ -1163,8 +1163,8 @@ enum HardDiskFormatCapabilities
/* Start of enum MouseButtonState Declaration */
-#define MOUSEBUTTONSTATE_IID_STR "03131722-2EC5-4173-9794-0DACA46673EF"
-#define MOUSEBUTTONSTATE_IID { \
+# define MOUSEBUTTONSTATE_IID_STR "03131722-2EC5-4173-9794-0DACA46673EF"
+# define MOUSEBUTTONSTATE_IID { \
0x03131722, 0x2EC5, 0x4173, \
{ 0x97, 0x94, 0x0D, 0xAC, 0xA4, 0x66, 0x73, 0xEF } \
}
@@ -1181,8 +1181,8 @@ enum MouseButtonState
/* Start of enum FramebufferAccelerationOperation Declaration */
-#define FRAMEBUFFERACCELERATIONOPERATION_IID_STR "f0e5ebbe-dc8e-4e2d-916e-53baa3844df8"
-#define FRAMEBUFFERACCELERATIONOPERATION_IID { \
+# define FRAMEBUFFERACCELERATIONOPERATION_IID_STR "f0e5ebbe-dc8e-4e2d-916e-53baa3844df8"
+# define FRAMEBUFFERACCELERATIONOPERATION_IID { \
0xf0e5ebbe, 0xdc8e, 0x4e2d, \
{ 0x91, 0x6e, 0x53, 0xba, 0xa3, 0x84, 0x4d, 0xf8 } \
}
@@ -1195,8 +1195,8 @@ enum FramebufferAccelerationOperation
/* Start of enum FramebufferPixelFormat Declaration */
-#define FRAMEBUFFERPIXELFORMAT_IID_STR "7acfd5ed-29e3-45e3-8136-73c9224f3d2d"
-#define FRAMEBUFFERPIXELFORMAT_IID { \
+# define FRAMEBUFFERPIXELFORMAT_IID_STR "7acfd5ed-29e3-45e3-8136-73c9224f3d2d"
+# define FRAMEBUFFERPIXELFORMAT_IID { \
0x7acfd5ed, 0x29e3, 0x45e3, \
{ 0x81, 0x36, 0x73, 0xc9, 0x22, 0x4f, 0x3d, 0x2d } \
}
@@ -1209,8 +1209,8 @@ enum FramebufferPixelFormat
/* Start of enum NetworkAttachmentType Declaration */
-#define NETWORKATTACHMENTTYPE_IID_STR "44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
-#define NETWORKATTACHMENTTYPE_IID { \
+# define NETWORKATTACHMENTTYPE_IID_STR "44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
+# define NETWORKATTACHMENTTYPE_IID { \
0x44bce1ee, 0x99f7, 0x4e8e, \
{ 0x89, 0xfc, 0x80, 0x59, 0x7f, 0xd9, 0xee, 0xaf } \
}
@@ -1226,8 +1226,8 @@ enum NetworkAttachmentType
/* Start of enum NetworkAdapterType Declaration */
-#define NETWORKADAPTERTYPE_IID_STR "50c3dfd8-07ac-4a31-baac-519c828fbf97"
-#define NETWORKADAPTERTYPE_IID { \
+# define NETWORKADAPTERTYPE_IID_STR "50c3dfd8-07ac-4a31-baac-519c828fbf97"
+# define NETWORKADAPTERTYPE_IID { \
0x50c3dfd8, 0x07ac, 0x4a31, \
{ 0xba, 0xac, 0x51, 0x9c, 0x82, 0x8f, 0xbf, 0x97 } \
}
@@ -1244,8 +1244,8 @@ enum NetworkAdapterType
/* Start of enum PortMode Declaration */
-#define PORTMODE_IID_STR "b266f43c-2e93-46b3-812b-c20e600e867b"
-#define PORTMODE_IID { \
+# define PORTMODE_IID_STR "b266f43c-2e93-46b3-812b-c20e600e867b"
+# define PORTMODE_IID { \
0xb266f43c, 0x2e93, 0x46b3, \
{ 0x81, 0x2b, 0xc2, 0x0e, 0x60, 0x0e, 0x86, 0x7b } \
}
@@ -1259,8 +1259,8 @@ enum PortMode
/* Start of enum USBDeviceState Declaration */
-#define USBDEVICESTATE_IID_STR "b99a2e65-67fb-4882-82fd-f3e5e8193ab4"
-#define USBDEVICESTATE_IID { \
+# define USBDEVICESTATE_IID_STR "b99a2e65-67fb-4882-82fd-f3e5e8193ab4"
+# define USBDEVICESTATE_IID { \
0xb99a2e65, 0x67fb, 0x4882, \
{ 0x82, 0xfd, 0xf3, 0xe5, 0xe8, 0x19, 0x3a, 0xb4 } \
}
@@ -1277,8 +1277,8 @@ enum USBDeviceState
/* Start of enum USBDeviceFilterAction Declaration */
-#define USBDEVICEFILTERACTION_IID_STR "cbc30a49-2f4e-43b5-9da6-121320475933"
-#define USBDEVICEFILTERACTION_IID { \
+# define USBDEVICEFILTERACTION_IID_STR "cbc30a49-2f4e-43b5-9da6-121320475933"
+# define USBDEVICEFILTERACTION_IID { \
0xcbc30a49, 0x2f4e, 0x43b5, \
{ 0x9d, 0xa6, 0x12, 0x13, 0x20, 0x47, 0x59, 0x33 } \
}
@@ -1292,8 +1292,8 @@ enum USBDeviceFilterAction
/* Start of enum AudioDriverType Declaration */
-#define AUDIODRIVERTYPE_IID_STR "4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
-#define AUDIODRIVERTYPE_IID { \
+# define AUDIODRIVERTYPE_IID_STR "4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
+# define AUDIODRIVERTYPE_IID { \
0x4bcc3d73, 0xc2fe, 0x40db, \
{ 0xb7, 0x2f, 0x0c, 0x2c, 0xa9, 0xd6, 0x84, 0x96 } \
}
@@ -1313,8 +1313,8 @@ enum AudioDriverType
/* Start of enum AudioControllerType Declaration */
-#define AUDIOCONTROLLERTYPE_IID_STR "7afd395c-42c3-444e-8788-3ce80292f36c"
-#define AUDIOCONTROLLERTYPE_IID { \
+# define AUDIOCONTROLLERTYPE_IID_STR "7afd395c-42c3-444e-8788-3ce80292f36c"
+# define AUDIOCONTROLLERTYPE_IID { \
0x7afd395c, 0x42c3, 0x444e, \
{ 0x87, 0x88, 0x3c, 0xe8, 0x02, 0x92, 0xf3, 0x6c } \
}
@@ -1327,8 +1327,8 @@ enum AudioControllerType
/* Start of enum VRDPAuthType Declaration */
-#define VRDPAUTHTYPE_IID_STR "3d91887a-b67f-4b33-85bf-2da7ab1ea83a"
-#define VRDPAUTHTYPE_IID { \
+# define VRDPAUTHTYPE_IID_STR "3d91887a-b67f-4b33-85bf-2da7ab1ea83a"
+# define VRDPAUTHTYPE_IID { \
0x3d91887a, 0xb67f, 0x4b33, \
{ 0x85, 0xbf, 0x2d, 0xa7, 0xab, 0x1e, 0xa8, 0x3a } \
}
@@ -1342,8 +1342,8 @@ enum VRDPAuthType
/* Start of enum StorageBus Declaration */
-#define STORAGEBUS_IID_STR "f381fdca-5953-41d0-b2bd-0542b012698d"
-#define STORAGEBUS_IID { \
+# define STORAGEBUS_IID_STR "f381fdca-5953-41d0-b2bd-0542b012698d"
+# define STORAGEBUS_IID { \
0xf381fdca, 0x5953, 0x41d0, \
{ 0xb2, 0xbd, 0x05, 0x42, 0xb0, 0x12, 0x69, 0x8d } \
}
@@ -1358,8 +1358,8 @@ enum StorageBus
/* Start of enum StorageControllerType Declaration */
-#define STORAGECONTROLLERTYPE_IID_STR "685387db-a837-4320-a258-08f46a22f62a"
-#define STORAGECONTROLLERTYPE_IID { \
+# define STORAGECONTROLLERTYPE_IID_STR "685387db-a837-4320-a258-08f46a22f62a"
+# define STORAGECONTROLLERTYPE_IID { \
0x685387db, 0xa837, 0x4320, \
{ 0xa2, 0x58, 0x08, 0xf4, 0x6a, 0x22, 0xf6, 0x2a } \
}
@@ -1377,8 +1377,8 @@ enum StorageControllerType
/* Start of struct IVirtualBoxErrorInfo Declaration */
-#define IVIRTUALBOXERRORINFO_IID_STR "e98b5376-8eb4-4eea-812a-3964bf3bb26f"
-#define IVIRTUALBOXERRORINFO_IID { \
+# define IVIRTUALBOXERRORINFO_IID_STR "e98b5376-8eb4-4eea-812a-3964bf3bb26f"
+# define IVIRTUALBOXERRORINFO_IID { \
0xe98b5376, 0x8eb4, 0x4eea, \
{ 0x81, 0x2a, 0x39, 0x64, 0xbf, 0x3b, 0xb2, 0x6f } \
}
@@ -1406,8 +1406,8 @@ struct IVirtualBoxErrorInfo
/* Start of struct IVirtualBoxCallback Declaration */
-#define IVIRTUALBOXCALLBACK_IID_STR "5516cc08-fb81-47a6-b184-031e7bbd2997"
-#define IVIRTUALBOXCALLBACK_IID { \
+# define IVIRTUALBOXCALLBACK_IID_STR "5516cc08-fb81-47a6-b184-031e7bbd2997"
+# define IVIRTUALBOXCALLBACK_IID { \
0x5516cc08, 0xfb81, 0x47a6, \
{ 0xb1, 0x84, 0x03, 0x1e, 0x7b, 0xbd, 0x29, 0x97 } \
}
@@ -1497,8 +1497,8 @@ struct IVirtualBoxCallback
/* Start of struct IDHCPServer Declaration */
-#define IDHCPSERVER_IID_STR "6cfe387c-74fb-4ca7-bff6-973bec8af7a3"
-#define IDHCPSERVER_IID { \
+# define IDHCPSERVER_IID_STR "6cfe387c-74fb-4ca7-bff6-973bec8af7a3"
+# define IDHCPSERVER_IID { \
0x6cfe387c, 0x74fb, 0x4ca7, \
{ 0xbf, 0xf6, 0x97, 0x3b, 0xec, 0x8a, 0xf7, 0xa3 } \
}
@@ -1546,8 +1546,8 @@ struct IDHCPServer
/* Start of struct IVirtualBox Declaration */
-#define IVIRTUALBOX_IID_STR "779264f4-65ed-48ed-be39-518ca549e296"
-#define IVIRTUALBOX_IID { \
+# define IVIRTUALBOX_IID_STR "779264f4-65ed-48ed-be39-518ca549e296"
+# define IVIRTUALBOX_IID { \
0x779264f4, 0x65ed, 0x48ed, \
{ 0xbe, 0x39, 0x51, 0x8c, 0xa5, 0x49, 0xe2, 0x96 } \
}
@@ -1817,8 +1817,8 @@ struct IVirtualBox
/* Start of struct IAppliance Declaration */
-#define IAPPLIANCE_IID_STR "30bfa6b8-9eda-4b0a-b218-a86813248ccd"
-#define IAPPLIANCE_IID { \
+# define IAPPLIANCE_IID_STR "30bfa6b8-9eda-4b0a-b218-a86813248ccd"
+# define IAPPLIANCE_IID { \
0x30bfa6b8, 0x9eda, 0x4b0a, \
{ 0xb2, 0x18, 0xa8, 0x68, 0x13, 0x24, 0x8c, 0xcd } \
}
@@ -1867,8 +1867,8 @@ struct IAppliance
/* Start of struct IVirtualSystemDescription Declaration */
-#define IVIRTUALSYSTEMDESCRIPTION_IID_STR "d7525e6c-531a-4c51-8e04-41235083a3d8"
-#define IVIRTUALSYSTEMDESCRIPTION_IID { \
+# define IVIRTUALSYSTEMDESCRIPTION_IID_STR "d7525e6c-531a-4c51-8e04-41235083a3d8"
+# define IVIRTUALSYSTEMDESCRIPTION_IID { \
0xd7525e6c, 0x531a, 0x4c51, \
{ 0x8e, 0x04, 0x41, 0x23, 0x50, 0x83, 0xa3, 0xd8 } \
}
@@ -1942,8 +1942,8 @@ struct IVirtualSystemDescription
/* Start of struct IInternalMachineControl Declaration */
-#define IINTERNALMACHINECONTROL_IID_STR "2c88b969-7a74-4ef3-b95f-8a209a1535f3"
-#define IINTERNALMACHINECONTROL_IID { \
+# define IINTERNALMACHINECONTROL_IID_STR "2c88b969-7a74-4ef3-b95f-8a209a1535f3"
+# define IINTERNALMACHINECONTROL_IID { \
0x2c88b969, 0x7a74, 0x4ef3, \
{ 0xb9, 0x5f, 0x8a, 0x20, 0x9a, 0x15, 0x35, 0xf3 } \
}
@@ -2089,8 +2089,8 @@ struct IInternalMachineControl
/* Start of struct IBIOSSettings Declaration */
-#define IBIOSSETTINGS_IID_STR "38b54279-dc35-4f5e-a431-835b867c6b5e"
-#define IBIOSSETTINGS_IID { \
+# define IBIOSSETTINGS_IID_STR "38b54279-dc35-4f5e-a431-835b867c6b5e"
+# define IBIOSSETTINGS_IID { \
0x38b54279, 0xdc35, 0x4f5e, \
{ 0xa4, 0x31, 0x83, 0x5b, 0x86, 0x7c, 0x6b, 0x5e } \
}
@@ -2135,8 +2135,8 @@ struct IBIOSSettings
/* Start of struct IMachine Declaration */
-#define IMACHINE_IID_STR "13420cbb-175a-4456-85d0-301126dfdec7"
-#define IMACHINE_IID { \
+# define IMACHINE_IID_STR "13420cbb-175a-4456-85d0-301126dfdec7"
+# define IMACHINE_IID { \
0x13420cbb, 0x175a, 0x4456, \
{ 0x85, 0xd0, 0x30, 0x11, 0x26, 0xdf, 0xde, 0xc7 } \
}
@@ -2459,8 +2459,8 @@ struct IMachine
/* Start of struct IConsoleCallback Declaration */
-#define ICONSOLECALLBACK_IID_STR "13dfbef3-b74d-487d-bada-2304529aefa6"
-#define ICONSOLECALLBACK_IID { \
+# define ICONSOLECALLBACK_IID_STR "13dfbef3-b74d-487d-bada-2304529aefa6"
+# define ICONSOLECALLBACK_IID { \
0x13dfbef3, 0xb74d, 0x487d, \
{ 0xba, 0xda, 0x23, 0x04, 0x52, 0x9a, 0xef, 0xa6 } \
}
@@ -2563,8 +2563,8 @@ struct IConsoleCallback
/* Start of struct IRemoteDisplayInfo Declaration */
-#define IREMOTEDISPLAYINFO_IID_STR "550104cd-2dfd-4a6c-857d-f6f8e088e62c"
-#define IREMOTEDISPLAYINFO_IID { \
+# define IREMOTEDISPLAYINFO_IID_STR "550104cd-2dfd-4a6c-857d-f6f8e088e62c"
+# define IREMOTEDISPLAYINFO_IID { \
0x550104cd, 0x2dfd, 0x4a6c, \
{ 0x85, 0x7d, 0xf6, 0xf8, 0xe0, 0x88, 0xe6, 0x2c } \
}
@@ -2610,8 +2610,8 @@ struct IRemoteDisplayInfo
/* Start of struct IConsole Declaration */
-#define ICONSOLE_IID_STR "9511bc54-15ee-4ddf-808e-472aba03809c"
-#define ICONSOLE_IID { \
+# define ICONSOLE_IID_STR "9511bc54-15ee-4ddf-808e-472aba03809c"
+# define ICONSOLE_IID { \
0x9511bc54, 0x15ee, 0x4ddf, \
{ 0x80, 0x8e, 0x47, 0x2a, 0xba, 0x03, 0x80, 0x9c } \
}
@@ -2774,8 +2774,8 @@ struct IConsole
/* Start of struct IHostDVDDrive Declaration */
-#define IHOSTDVDDRIVE_IID_STR "21f86694-202d-4ce4-8b05-a63ff82dbf4c"
-#define IHOSTDVDDRIVE_IID { \
+# define IHOSTDVDDRIVE_IID_STR "21f86694-202d-4ce4-8b05-a63ff82dbf4c"
+# define IHOSTDVDDRIVE_IID { \
0x21f86694, 0x202d, 0x4ce4, \
{ 0x8b, 0x05, 0xa6, 0x3f, 0xf8, 0x2d, 0xbf, 0x4c } \
}
@@ -2799,8 +2799,8 @@ struct IHostDVDDrive
/* Start of struct IHostFloppyDrive Declaration */
-#define IHOSTFLOPPYDRIVE_IID_STR "3f02d604-e908-4919-9fd1-8a4afd68fc63"
-#define IHOSTFLOPPYDRIVE_IID { \
+# define IHOSTFLOPPYDRIVE_IID_STR "3f02d604-e908-4919-9fd1-8a4afd68fc63"
+# define IHOSTFLOPPYDRIVE_IID { \
0x3f02d604, 0xe908, 0x4919, \
{ 0x9f, 0xd1, 0x8a, 0x4a, 0xfd, 0x68, 0xfc, 0x63 } \
}
@@ -2824,8 +2824,8 @@ struct IHostFloppyDrive
/* Start of struct IHostNetworkInterface Declaration */
-#define IHOSTNETWORKINTERFACE_IID_STR "88adaf3f-166b-4542-9457-0f1323507fae"
-#define IHOSTNETWORKINTERFACE_IID { \
+# define IHOSTNETWORKINTERFACE_IID_STR "88adaf3f-166b-4542-9457-0f1323507fae"
+# define IHOSTNETWORKINTERFACE_IID { \
0x88adaf3f, 0x166b, 0x4542, \
{ 0x94, 0x57, 0x0f, 0x13, 0x23, 0x50, 0x7f, 0xae } \
}
@@ -2885,8 +2885,8 @@ struct IHostNetworkInterface
/* Start of struct IHost Declaration */
-#define IHOST_IID_STR "926469ca-9091-42ef-928e-582d78b66c70"
-#define IHOST_IID { \
+# define IHOST_IID_STR "926469ca-9091-42ef-928e-582d78b66c70"
+# define IHOST_IID { \
0x926469ca, 0x9091, 0x42ef, \
{ 0x92, 0x8e, 0x58, 0x2d, 0x78, 0xb6, 0x6c, 0x70 } \
}
@@ -3007,8 +3007,8 @@ struct IHost
/* Start of struct ISystemProperties Declaration */
-#define ISYSTEMPROPERTIES_IID_STR "0760e03f-06d0-481e-9f81-be43fef092ba"
-#define ISYSTEMPROPERTIES_IID { \
+# define ISYSTEMPROPERTIES_IID_STR "0760e03f-06d0-481e-9f81-be43fef092ba"
+# define ISYSTEMPROPERTIES_IID { \
0x0760e03f, 0x06d0, 0x481e, \
{ 0x9f, 0x81, 0xbe, 0x43, 0xfe, 0xf0, 0x92, 0xba } \
}
@@ -3071,8 +3071,8 @@ struct ISystemProperties
/* Start of struct IGuestOSType Declaration */
-#define IGUESTOSTYPE_IID_STR "cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
-#define IGUESTOSTYPE_IID { \
+# define IGUESTOSTYPE_IID_STR "cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
+# define IGUESTOSTYPE_IID { \
0xcfe9e64c, 0x4430, 0x435b, \
{ 0x9e, 0x7c, 0xe3, 0xd8, 0xe4, 0x17, 0xbd, 0x58 } \
}
@@ -3112,8 +3112,8 @@ struct IGuestOSType
/* Start of struct IGuest Declaration */
-#define IGUEST_IID_STR "d8556fca-81bc-12af-fca3-365528fa38ca"
-#define IGUEST_IID { \
+# define IGUEST_IID_STR "d8556fca-81bc-12af-fca3-365528fa38ca"
+# define IGUEST_IID { \
0xd8556fca, 0x81bc, 0x12af, \
{ 0xfc, 0xa3, 0x36, 0x55, 0x28, 0xfa, 0x38, 0xca } \
}
@@ -3162,8 +3162,8 @@ struct IGuest
/* Start of struct IProgress Declaration */
-#define IPROGRESS_IID_STR "c4f94e6b-2273-446b-9539-4c05bb416fe7"
-#define IPROGRESS_IID { \
+# define IPROGRESS_IID_STR "c4f94e6b-2273-446b-9539-4c05bb416fe7"
+# define IPROGRESS_IID { \
0xc4f94e6b, 0x2273, 0x446b, \
{ 0x95, 0x39, 0x4c, 0x05, 0xbb, 0x41, 0x6f, 0xe7 } \
}
@@ -3222,8 +3222,8 @@ struct IProgress
/* Start of struct ISnapshot Declaration */
-#define ISNAPSHOT_IID_STR "5db6b1d9-c76b-4424-a6f4-8257f642d6ea"
-#define ISNAPSHOT_IID { \
+# define ISNAPSHOT_IID_STR "5db6b1d9-c76b-4424-a6f4-8257f642d6ea"
+# define ISNAPSHOT_IID { \
0x5db6b1d9, 0xc76b, 0x4424, \
{ 0xa6, 0xf4, 0x82, 0x57, 0xf6, 0x42, 0xd6, 0xea } \
}
@@ -3259,8 +3259,8 @@ struct ISnapshot
/* Start of struct IMedium Declaration */
-#define IMEDIUM_IID_STR "a7fb3bfb-c180-4274-bae4-7fbc89046e13"
-#define IMEDIUM_IID { \
+# define IMEDIUM_IID_STR "a7fb3bfb-c180-4274-bae4-7fbc89046e13"
+# define IMEDIUM_IID { \
0xa7fb3bfb, 0xc180, 0x4274, \
{ 0xba, 0xe4, 0x7f, 0xbc, 0x89, 0x04, 0x6e, 0x13 } \
}
@@ -3325,8 +3325,8 @@ struct IMedium
/* Start of struct IHardDiskAttachment Declaration */
-#define IHARDDISKATTACHMENT_IID_STR "b1dd04bb-93c0-4ad3-a9cf-82316e595836"
-#define IHARDDISKATTACHMENT_IID { \
+# define IHARDDISKATTACHMENT_IID_STR "b1dd04bb-93c0-4ad3-a9cf-82316e595836"
+# define IHARDDISKATTACHMENT_IID { \
0xb1dd04bb, 0x93c0, 0x4ad3, \
{ 0xa9, 0xcf, 0x82, 0x31, 0x6e, 0x59, 0x58, 0x36 } \
}
@@ -3352,8 +3352,8 @@ struct IHardDiskAttachment
/* Start of struct IHardDisk Declaration */
-#define IHARDDISK_IID_STR "91648dc6-bb19-46bf-9e1c-4bf5b960c8e2"
-#define IHARDDISK_IID { \
+# define IHARDDISK_IID_STR "91648dc6-bb19-46bf-9e1c-4bf5b960c8e2"
+# define IHARDDISK_IID { \
0x91648dc6, 0xbb19, 0x46bf, \
{ 0x9e, 0x1c, 0x4b, 0xf5, 0xb9, 0x60, 0xc8, 0xe2 } \
}
@@ -3461,8 +3461,8 @@ struct IHardDisk
/* Start of struct IHardDiskFormat Declaration */
-#define IHARDDISKFORMAT_IID_STR "7f3ba790-3a0b-4a8a-bac2-bb50150123c5"
-#define IHARDDISKFORMAT_IID { \
+# define IHARDDISKFORMAT_IID_STR "7f3ba790-3a0b-4a8a-bac2-bb50150123c5"
+# define IHARDDISKFORMAT_IID { \
0x7f3ba790, 0x3a0b, 0x4a8a, \
{ 0xba, 0xc2, 0xbb, 0x50, 0x15, 0x01, 0x23, 0xc5 } \
}
@@ -3502,8 +3502,8 @@ struct IHardDiskFormat
/* Start of struct IFloppyImage Declaration */
-#define IFLOPPYIMAGE_IID_STR "faa6101f-078c-4b3a-ab75-75670c8170b3"
-#define IFLOPPYIMAGE_IID { \
+# define IFLOPPYIMAGE_IID_STR "faa6101f-078c-4b3a-ab75-75670c8170b3"
+# define IFLOPPYIMAGE_IID { \
0xfaa6101f, 0x078c, 0x4b3a, \
{ 0xab, 0x75, 0x75, 0x67, 0x0c, 0x81, 0x70, 0xb3 } \
}
@@ -3521,8 +3521,8 @@ struct IFloppyImage
/* Start of struct IDVDImage Declaration */
-#define IDVDIMAGE_IID_STR "b1f90bbb-e8a9-4484-9af1-3638e943f763"
-#define IDVDIMAGE_IID { \
+# define IDVDIMAGE_IID_STR "b1f90bbb-e8a9-4484-9af1-3638e943f763"
+# define IDVDIMAGE_IID { \
0xb1f90bbb, 0xe8a9, 0x4484, \
{ 0x9a, 0xf1, 0x36, 0x38, 0xe9, 0x43, 0xf7, 0x63 } \
}
@@ -3540,8 +3540,8 @@ struct IDVDImage
/* Start of struct IDVDDrive Declaration */
-#define IDVDDRIVE_IID_STR "d650ef30-be9b-4dae-b463-11d5824681a5"
-#define IDVDDRIVE_IID { \
+# define IDVDDRIVE_IID_STR "d650ef30-be9b-4dae-b463-11d5824681a5"
+# define IDVDDRIVE_IID { \
0xd650ef30, 0xbe9b, 0x4dae, \
{ 0xb4, 0x63, 0x11, 0xd5, 0x82, 0x46, 0x81, 0xa5 } \
}
@@ -3586,8 +3586,8 @@ struct IDVDDrive
/* Start of struct IFloppyDrive Declaration */
-#define IFLOPPYDRIVE_IID_STR "159412cd-bab8-452e-8097-218a020825a6"
-#define IFLOPPYDRIVE_IID { \
+# define IFLOPPYDRIVE_IID_STR "159412cd-bab8-452e-8097-218a020825a6"
+# define IFLOPPYDRIVE_IID { \
0x159412cd, 0xbab8, 0x452e, \
{ 0x80, 0x97, 0x21, 0x8a, 0x02, 0x08, 0x25, 0xa6 } \
}
@@ -3632,8 +3632,8 @@ struct IFloppyDrive
/* Start of struct IKeyboard Declaration */
-#define IKEYBOARD_IID_STR "2d1a531b-4c6e-49cc-8af6-5c857b78b5d7"
-#define IKEYBOARD_IID { \
+# define IKEYBOARD_IID_STR "2d1a531b-4c6e-49cc-8af6-5c857b78b5d7"
+# define IKEYBOARD_IID { \
0x2d1a531b, 0x4c6e, 0x49cc, \
{ 0x8a, 0xf6, 0x5c, 0x85, 0x7b, 0x78, 0xb5, 0xd7 } \
}
@@ -3665,8 +3665,8 @@ struct IKeyboard
/* Start of struct IMouse Declaration */
-#define IMOUSE_IID_STR "FD443EC1-0006-4F5B-9282-D72760A66916"
-#define IMOUSE_IID { \
+# define IMOUSE_IID_STR "FD443EC1-0006-4F5B-9282-D72760A66916"
+# define IMOUSE_IID { \
0xFD443EC1, 0x0006, 0x4F5B, \
{ 0x92, 0x82, 0xD7, 0x27, 0x60, 0xA6, 0x69, 0x16 } \
}
@@ -3702,8 +3702,8 @@ struct IMouse
/* Start of struct IFramebuffer Declaration */
-#define IFRAMEBUFFER_IID_STR "af431304-5b09-40e2-94da-3c3cb03822c1"
-#define IFRAMEBUFFER_IID { \
+# define IFRAMEBUFFER_IID_STR "af431304-5b09-40e2-94da-3c3cb03822c1"
+# define IFRAMEBUFFER_IID { \
0xaf431304, 0x5b09, 0x40e2, \
{ 0x94, 0xda, 0x3c, 0x3c, 0xb0, 0x38, 0x22, 0xc1 } \
}
@@ -3814,8 +3814,8 @@ struct IFramebuffer
/* Start of struct IFramebufferOverlay Declaration */
-#define IFRAMEBUFFEROVERLAY_IID_STR "0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47"
-#define IFRAMEBUFFEROVERLAY_IID { \
+# define IFRAMEBUFFEROVERLAY_IID_STR "0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47"
+# define IFRAMEBUFFEROVERLAY_IID { \
0x0bcc1c7e, 0xe415, 0x47d2, \
{ 0xbf, 0xdb, 0xe4, 0xc7, 0x05, 0xfb, 0x0f, 0x47 } \
}
@@ -3849,8 +3849,8 @@ struct IFramebufferOverlay
/* Start of struct IDisplay Declaration */
-#define IDISPLAY_IID_STR "09789f63-4525-48e5-a5e4-1080453b0eab"
-#define IDISPLAY_IID { \
+# define IDISPLAY_IID_STR "09789f63-4525-48e5-a5e4-1080453b0eab"
+# define IDISPLAY_IID { \
0x09789f63, 0x4525, 0x48e5, \
{ 0xa5, 0xe4, 0x10, 0x80, 0x45, 0x3b, 0x0e, 0xab } \
}
@@ -3943,8 +3943,8 @@ struct IDisplay
/* Start of struct INetworkAdapter Declaration */
-#define INETWORKADAPTER_IID_STR "65607a27-2b73-4d43-b4cc-0ba2c817fbde"
-#define INETWORKADAPTER_IID { \
+# define INETWORKADAPTER_IID_STR "65607a27-2b73-4d43-b4cc-0ba2c817fbde"
+# define INETWORKADAPTER_IID { \
0x65607a27, 0x2b73, 0x4d43, \
{ 0xb4, 0xcc, 0x0b, 0xa2, 0xc8, 0x17, 0xfb, 0xde } \
}
@@ -4006,8 +4006,8 @@ struct INetworkAdapter
/* Start of struct ISerialPort Declaration */
-#define ISERIALPORT_IID_STR "937f6970-5103-4745-b78e-d28dcf1479a8"
-#define ISERIALPORT_IID { \
+# define ISERIALPORT_IID_STR "937f6970-5103-4745-b78e-d28dcf1479a8"
+# define ISERIALPORT_IID { \
0x937f6970, 0x5103, 0x4745, \
{ 0xb7, 0x8e, 0xd2, 0x8d, 0xcf, 0x14, 0x79, 0xa8 } \
}
@@ -4045,8 +4045,8 @@ struct ISerialPort
/* Start of struct IParallelPort Declaration */
-#define IPARALLELPORT_IID_STR "0c925f06-dd10-4b77-8de8-294d738c3214"
-#define IPARALLELPORT_IID { \
+# define IPARALLELPORT_IID_STR "0c925f06-dd10-4b77-8de8-294d738c3214"
+# define IPARALLELPORT_IID { \
0x0c925f06, 0xdd10, 0x4b77, \
{ 0x8d, 0xe8, 0x29, 0x4d, 0x73, 0x8c, 0x32, 0x14 } \
}
@@ -4078,8 +4078,8 @@ struct IParallelPort
/* Start of struct IMachineDebugger Declaration */
-#define IMACHINEDEBUGGER_IID_STR "b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
-#define IMACHINEDEBUGGER_IID { \
+# define IMACHINEDEBUGGER_IID_STR "b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
+# define IMACHINEDEBUGGER_IID { \
0xb0b2a2dd, 0x0627, 0x4502, \
{ 0x91, 0xc2, 0xdd, 0xc5, 0xe7, 0x76, 0x09, 0xe0 } \
}
@@ -4147,8 +4147,8 @@ struct IMachineDebugger
/* Start of struct IUSBController Declaration */
-#define IUSBCONTROLLER_IID_STR "238540fa-4b73-435a-a38e-4e1d9eab5c17"
-#define IUSBCONTROLLER_IID { \
+# define IUSBCONTROLLER_IID_STR "238540fa-4b73-435a-a38e-4e1d9eab5c17"
+# define IUSBCONTROLLER_IID { \
0x238540fa, 0x4b73, 0x435a, \
{ 0xa3, 0x8e, 0x4e, 0x1d, 0x9e, 0xab, 0x5c, 0x17 } \
}
@@ -4194,8 +4194,8 @@ struct IUSBController
/* Start of struct IUSBDevice Declaration */
-#define IUSBDEVICE_IID_STR "850af07b-9ee8-48c2-b6b0-f6d0acbf63c3"
-#define IUSBDEVICE_IID { \
+# define IUSBDEVICE_IID_STR "850af07b-9ee8-48c2-b6b0-f6d0acbf63c3"
+# define IUSBDEVICE_IID { \
0x850af07b, 0x9ee8, 0x48c2, \
{ 0xb6, 0xb0, 0xf6, 0xd0, 0xac, 0xbf, 0x63, 0xc3 } \
}
@@ -4237,8 +4237,8 @@ struct IUSBDevice
/* Start of struct IUSBDeviceFilter Declaration */
-#define IUSBDEVICEFILTER_IID_STR "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
-#define IUSBDEVICEFILTER_IID { \
+# define IUSBDEVICEFILTER_IID_STR "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
+# define IUSBDEVICEFILTER_IID { \
0xd6831fb4, 0x1a94, 0x4c2c, \
{ 0x96, 0xef, 0x8d, 0x0d, 0x61, 0x92, 0x06, 0x6d } \
}
@@ -4289,8 +4289,8 @@ struct IUSBDeviceFilter
/* Start of struct IHostUSBDevice Declaration */
-#define IHOSTUSBDEVICE_IID_STR "173b4b44-d268-4334-a00d-b6521c9a740a"
-#define IHOSTUSBDEVICE_IID { \
+# define IHOSTUSBDEVICE_IID_STR "173b4b44-d268-4334-a00d-b6521c9a740a"
+# define IHOSTUSBDEVICE_IID { \
0x173b4b44, 0xd268, 0x4334, \
{ 0xa0, 0x0d, 0xb6, 0x52, 0x1c, 0x9a, 0x74, 0x0a } \
}
@@ -4310,8 +4310,8 @@ struct IHostUSBDevice
/* Start of struct IHostUSBDeviceFilter Declaration */
-#define IHOSTUSBDEVICEFILTER_IID_STR "4cc70246-d74a-400f-8222-3900489c0374"
-#define IHOSTUSBDEVICEFILTER_IID { \
+# define IHOSTUSBDEVICEFILTER_IID_STR "4cc70246-d74a-400f-8222-3900489c0374"
+# define IHOSTUSBDEVICEFILTER_IID { \
0x4cc70246, 0xd74a, 0x400f, \
{ 0x82, 0x22, 0x39, 0x00, 0x48, 0x9c, 0x03, 0x74 } \
}
@@ -4332,8 +4332,8 @@ struct IHostUSBDeviceFilter
/* Start of struct IAudioAdapter Declaration */
-#define IAUDIOADAPTER_IID_STR "921873db-5f3f-4b69-91f9-7be9e535a2cb"
-#define IAUDIOADAPTER_IID { \
+# define IAUDIOADAPTER_IID_STR "921873db-5f3f-4b69-91f9-7be9e535a2cb"
+# define IAUDIOADAPTER_IID { \
0x921873db, 0x5f3f, 0x4b69, \
{ 0x91, 0xf9, 0x7b, 0xe9, 0xe5, 0x35, 0xa2, 0xcb } \
}
@@ -4360,8 +4360,8 @@ struct IAudioAdapter
/* Start of struct IVRDPServer Declaration */
-#define IVRDPSERVER_IID_STR "f4584ae7-6bce-474b-83d6-17d235e6aa89"
-#define IVRDPSERVER_IID { \
+# define IVRDPSERVER_IID_STR "f4584ae7-6bce-474b-83d6-17d235e6aa89"
+# define IVRDPSERVER_IID { \
0xf4584ae7, 0x6bce, 0x474b, \
{ 0x83, 0xd6, 0x17, 0xd2, 0x35, 0xe6, 0xaa, 0x89 } \
}
@@ -4400,8 +4400,8 @@ struct IVRDPServer
/* Start of struct ISharedFolder Declaration */
-#define ISHAREDFOLDER_IID_STR "64637bb2-9e17-471c-b8f3-f8968dd9884e"
-#define ISHAREDFOLDER_IID { \
+# define ISHAREDFOLDER_IID_STR "64637bb2-9e17-471c-b8f3-f8968dd9884e"
+# define ISHAREDFOLDER_IID { \
0x64637bb2, 0x9e17, 0x471c, \
{ 0xb8, 0xf3, 0xf8, 0x96, 0x8d, 0xd9, 0x88, 0x4e } \
}
@@ -4429,8 +4429,8 @@ struct ISharedFolder
/* Start of struct IInternalSessionControl Declaration */
-#define IINTERNALSESSIONCONTROL_IID_STR "2581845a-5a9d-45fb-bc3b-2476552dd970"
-#define IINTERNALSESSIONCONTROL_IID { \
+# define IINTERNALSESSIONCONTROL_IID_STR "2581845a-5a9d-45fb-bc3b-2476552dd970"
+# define IINTERNALSESSIONCONTROL_IID { \
0x2581845a, 0x5a9d, 0x45fb, \
{ 0xbc, 0x3b, 0x24, 0x76, 0x55, 0x2d, 0xd9, 0x70 } \
}
@@ -4550,8 +4550,8 @@ struct IInternalSessionControl
/* Start of struct ISession Declaration */
-#define ISESSION_IID_STR "12F4DCDB-12B2-4ec1-B7CD-DDD9F6C5BF4D"
-#define ISESSION_IID { \
+# define ISESSION_IID_STR "12F4DCDB-12B2-4ec1-B7CD-DDD9F6C5BF4D"
+# define ISESSION_IID { \
0x12F4DCDB, 0x12B2, 0x4ec1, \
{ 0xB7, 0xCD, 0xDD, 0xD9, 0xF6, 0xC5, 0xBF, 0x4D } \
}
@@ -4579,8 +4579,8 @@ struct ISession
/* Start of struct IStorageController Declaration */
-#define ISTORAGECONTROLLER_IID_STR "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
-#define ISTORAGECONTROLLER_IID { \
+# define ISTORAGECONTROLLER_IID_STR "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
+# define ISTORAGECONTROLLER_IID { \
0x6bf8335b, 0xd14a, 0x44a5, \
{ 0x9b, 0x45, 0xdd, 0xc4, 0x9c, 0xe7, 0xd5, 0xb2 } \
}
@@ -4629,8 +4629,8 @@ struct IStorageController
/* Start of struct IPerformanceMetric Declaration */
-#define IPERFORMANCEMETRIC_IID_STR "2a1a60ae-9345-4019-ad53-d34ba41cbfe9"
-#define IPERFORMANCEMETRIC_IID { \
+# define IPERFORMANCEMETRIC_IID_STR "2a1a60ae-9345-4019-ad53-d34ba41cbfe9"
+# define IPERFORMANCEMETRIC_IID { \
0x2a1a60ae, 0x9345, 0x4019, \
{ 0xad, 0x53, 0xd3, 0x4b, 0xa4, 0x1c, 0xbf, 0xe9 } \
}
@@ -4664,8 +4664,8 @@ struct IPerformanceMetric
/* Start of struct IPerformanceCollector Declaration */
-#define IPERFORMANCECOLLECTOR_IID_STR "e22e1acb-ac4a-43bb-a31c-17321659b0c6"
-#define IPERFORMANCECOLLECTOR_IID { \
+# define IPERFORMANCECOLLECTOR_IID_STR "e22e1acb-ac4a-43bb-a31c-17321659b0c6"
+# define IPERFORMANCECOLLECTOR_IID { \
0xe22e1acb, 0xac4a, 0x43bb, \
{ 0xa3, 0x1c, 0x17, 0x32, 0x16, 0x59, 0xb0, 0xc6 } \
}
@@ -4751,37 +4751,37 @@ struct IPerformanceCollector
-#define NS_VIRTUALBOX_CID { \
+# define NS_VIRTUALBOX_CID { \
0xB1A7A4F2, 0x47B9, 0x4A1E, \
{ 0x82, 0xB2, 0x07, 0xCC, 0xD5, 0x32, 0x3C, 0x3F } \
}
-#define NS_VIRTUALBOX_CONTRACTID "@virtualbox.org/VirtualBox;1"
+# define NS_VIRTUALBOX_CONTRACTID "@virtualbox.org/VirtualBox;1"
/* for compatibility with Win32 */
-#define CLSID_VirtualBox (nsCID) NS_VIRTUALBOX_CID
+# define CLSID_VirtualBox (nsCID) NS_VIRTUALBOX_CID
-#define NS_SESSION_CID { \
+# define NS_SESSION_CID { \
0x3C02F46D, 0xC9D2, 0x4f11, \
{ 0xA3, 0x84, 0x53, 0xF0, 0xCF, 0x91, 0x72, 0x14 } \
}
-#define NS_SESSION_CONTRACTID "@virtualbox.org/Session;1"
+# define NS_SESSION_CONTRACTID "@virtualbox.org/Session;1"
/* for compatibility with Win32 */
-#define CLSID_Session (nsCID) NS_SESSION_CID
+# define CLSID_Session (nsCID) NS_SESSION_CID
-#endif /* !__cplusplus */
+# endif /* !__cplusplus */
-#ifdef IN_VBOXXPCOMC
-# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
-#else
-# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
-#endif
+# ifdef IN_VBOXXPCOMC
+# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
+# else
+# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
/**
@@ -4816,22 +4816,22 @@ typedef VBOXXPCOMC const *PCVBOXXPCOM;
/** The current interface version.
* For use with VBoxGetXPCOMCFunctions and to be found in
* VBOXXPCOMC::uVersion. */
-#define VBOX_XPCOMC_VERSION 0x00010000U
+# define VBOX_XPCOMC_VERSION 0x00010000U
VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion);
/** Typedef for VBoxGetXPCOMCFunctions. */
typedef PCVBOXXPCOM (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion);
/** The symbol name of VBoxGetXPCOMCFunctions. */
-#if defined(__OS2__)
-# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
-#else
-# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
-#endif
+# if defined(__OS2__)
+# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
+# else
+# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* !___VirtualBox_CXPCOM_h */
diff --git a/src/vbox/vbox_CAPI_v3_0.h b/src/vbox/vbox_CAPI_v3_0.h
index 0644dd9..7032fe6 100644
--- a/src/vbox/vbox_CAPI_v3_0.h
+++ b/src/vbox/vbox_CAPI_v3_0.h
@@ -43,193 +43,193 @@
*/
#ifndef ___VirtualBox_CXPCOM_h
-#define ___VirtualBox_CXPCOM_h
+# define ___VirtualBox_CXPCOM_h
-#ifdef __cplusplus
-# include "VirtualBox_XPCOM.h"
-#else /* !__cplusplus */
+# ifdef __cplusplus
+# include "VirtualBox_XPCOM.h"
+# else /* !__cplusplus */
-#include <stddef.h>
-#include "wchar.h"
+# include <stddef.h>
+# include "wchar.h"
-#if defined(WIN32)
+# if defined(WIN32)
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) __declspec(dllimport) __type
-#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) __declspec(dllimport) __type
+# define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
-#elif defined(XP_BEOS)
+# elif defined(XP_BEOS)
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(WIN16)
-
-#define PR_CALLBACK_DECL __cdecl
-
-#if defined(_WINDLL)
-#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
-#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
-#define PR_EXPORT_DATA(__type) extern __type _export
-#define PR_IMPORT_DATA(__type) extern __type _export
-
-#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
-#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
-#define PR_EXTERN_DATA(__type) extern __type _export
-#define PR_IMPLEMENT_DATA(__type) __type _export
-
-#define PR_CALLBACK __cdecl __loadds
-#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
-
-#else /* this must be .EXE */
-#define PR_EXPORT(__type) extern __type _cdecl _export
-#define PR_IMPORT(__type) extern __type _cdecl _export
-#define PR_EXPORT_DATA(__type) extern __type _export
-#define PR_IMPORT_DATA(__type) extern __type _export
-
-#define PR_EXTERN(__type) extern __type _cdecl _export
-#define PR_IMPLEMENT(__type) __type _cdecl _export
-#define PR_EXTERN_DATA(__type) extern __type _export
-#define PR_IMPLEMENT_DATA(__type) __type _export
-
-#define PR_CALLBACK __cdecl __loadds
-#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
-#endif /* _WINDLL */
-
-#elif defined(XP_MAC)
-
-#define PR_EXPORT(__type) extern __declspec(export) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
-#define PR_IMPORT(__type) extern __declspec(export) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
-
-#define PR_EXTERN(__type) extern __declspec(export) __type
-#define PR_IMPLEMENT(__type) __declspec(export) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(XP_OS2) && defined(__declspec)
-
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) __declspec(dllimport) __type
-#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(XP_OS2_VACPP)
-
-#define PR_EXPORT(__type) extern __type
-#define PR_EXPORT_DATA(__type) extern __type
-#define PR_IMPORT(__type) extern __type
-#define PR_IMPORT_DATA(__type) extern __type
-
-#define PR_EXTERN(__type) extern __type
-#define PR_IMPLEMENT(__type) __type
-#define PR_EXTERN_DATA(__type) extern __type
-#define PR_IMPLEMENT_DATA(__type) __type
-#define PR_CALLBACK _Optlink
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
-
-#else /* Unix */
-
-# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
-# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
-# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPORT(__type) extern __type
-# define PR_IMPORT_DATA(__type) extern __type
-# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
-# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
-# define PR_CALLBACK
-# define PR_CALLBACK_DECL
-# define PR_STATIC_CALLBACK(__x) static __x
-# else
-# define PR_EXPORT(__type) extern __type
-# define PR_EXPORT_DATA(__type) extern __type
-# define PR_IMPORT(__type) extern __type
-# define PR_IMPORT_DATA(__type) extern __type
-# define PR_EXTERN(__type) extern __type
-# define PR_IMPLEMENT(__type) __type
-# define PR_EXTERN_DATA(__type) extern __type
-# define PR_IMPLEMENT_DATA(__type) __type
-# define PR_CALLBACK
-# define PR_CALLBACK_DECL
-# define PR_STATIC_CALLBACK(__x) static __x
-# endif
-#endif
-
-#if defined(_NSPR_BUILD_)
-#define NSPR_API(__type) PR_EXPORT(__type)
-#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
-#else
-#define NSPR_API(__type) PR_IMPORT(__type)
-#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
-#endif
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
+
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(WIN16)
+
+# define PR_CALLBACK_DECL __cdecl
+
+# if defined(_WINDLL)
+# define PR_EXPORT(__type) extern __type _cdecl _export _loadds
+# define PR_IMPORT(__type) extern __type _cdecl _export _loadds
+# define PR_EXPORT_DATA(__type) extern __type _export
+# define PR_IMPORT_DATA(__type) extern __type _export
+
+# define PR_EXTERN(__type) extern __type _cdecl _export _loadds
+# define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
+# define PR_EXTERN_DATA(__type) extern __type _export
+# define PR_IMPLEMENT_DATA(__type) __type _export
+
+# define PR_CALLBACK __cdecl __loadds
+# define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
+# else /* this must be .EXE */
+# define PR_EXPORT(__type) extern __type _cdecl _export
+# define PR_IMPORT(__type) extern __type _cdecl _export
+# define PR_EXPORT_DATA(__type) extern __type _export
+# define PR_IMPORT_DATA(__type) extern __type _export
+
+# define PR_EXTERN(__type) extern __type _cdecl _export
+# define PR_IMPLEMENT(__type) __type _cdecl _export
+# define PR_EXTERN_DATA(__type) extern __type _export
+# define PR_IMPLEMENT_DATA(__type) __type _export
+
+# define PR_CALLBACK __cdecl __loadds
+# define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
+# endif /* _WINDLL */
+
+# elif defined(XP_MAC)
+
+# define PR_EXPORT(__type) extern __declspec(export) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(export) __type
+# define PR_IMPORT(__type) extern __declspec(export) __type
+# define PR_IMPORT_DATA(__type) extern __declspec(export) __type
+
+# define PR_EXTERN(__type) extern __declspec(export) __type
+# define PR_IMPLEMENT(__type) __declspec(export) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(export) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(XP_OS2) && defined(__declspec)
+
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) __declspec(dllimport) __type
+# define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
+
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(XP_OS2_VACPP)
+
+# define PR_EXPORT(__type) extern __type
+# define PR_EXPORT_DATA(__type) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+
+# define PR_EXTERN(__type) extern __type
+# define PR_IMPLEMENT(__type) __type
+# define PR_EXTERN_DATA(__type) extern __type
+# define PR_IMPLEMENT_DATA(__type) __type
+# define PR_CALLBACK _Optlink
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
+# else /* Unix */
+
+# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
+# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
+# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
+# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+# else
+# define PR_EXPORT(__type) extern __type
+# define PR_EXPORT_DATA(__type) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+# define PR_EXTERN(__type) extern __type
+# define PR_IMPLEMENT(__type) __type
+# define PR_EXTERN_DATA(__type) extern __type
+# define PR_IMPLEMENT_DATA(__type) __type
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+# endif
+# endif
+
+# if defined(_NSPR_BUILD_)
+# define NSPR_API(__type) PR_EXPORT(__type)
+# define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
+# else
+# define NSPR_API(__type) PR_IMPORT(__type)
+# define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
+# endif
typedef unsigned char PRUint8;
-#if (defined(HPUX) && defined(__cplusplus) \
+# if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
-#else
+# else
typedef signed char PRInt8;
-#endif
+# endif
-#define PR_INT8_MAX 127
-#define PR_INT8_MIN (-128)
-#define PR_UINT8_MAX 255U
+# define PR_INT8_MAX 127
+# define PR_INT8_MIN (-128)
+# define PR_UINT8_MAX 255U
typedef unsigned short PRUint16;
typedef short PRInt16;
-#define PR_INT16_MAX 32767
-#define PR_INT16_MIN (-32768)
-#define PR_UINT16_MAX 65535U
+# define PR_INT16_MAX 32767
+# define PR_INT16_MIN (-32768)
+# define PR_UINT16_MAX 65535U
typedef unsigned int PRUint32;
typedef int PRInt32;
-#define PR_INT32(x) x
-#define PR_UINT32(x) x ## U
+# define PR_INT32(x) x
+# define PR_UINT32(x) x ## U
-#define PR_INT32_MAX PR_INT32(2147483647)
-#define PR_INT32_MIN (-PR_INT32_MAX - 1)
-#define PR_UINT32_MAX PR_UINT32(4294967295)
+# define PR_INT32_MAX PR_INT32(2147483647)
+# define PR_INT32_MIN (-PR_INT32_MAX - 1)
+# define PR_UINT32_MAX PR_UINT32(4294967295)
typedef long PRInt64;
typedef unsigned long PRUint64;
@@ -245,8 +245,8 @@ typedef unsigned long PRUptrdiff;
typedef PRIntn PRBool;
-#define PR_TRUE 1
-#define PR_FALSE 0
+# define PR_TRUE 1
+# define PR_FALSE 0
typedef PRUint8 PRPackedBool;
@@ -256,56 +256,56 @@ typedef PRUint8 PRPackedBool;
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
-#ifndef __PRUNICHAR__
-#define __PRUNICHAR__
-#if defined(WIN32) || defined(XP_MAC)
+# ifndef __PRUNICHAR__
+# define __PRUNICHAR__
+# if defined(WIN32) || defined(XP_MAC)
typedef wchar_t PRUnichar;
-#else
+# else
typedef PRUint16 PRUnichar;
-#endif
-#endif
+# endif
+# endif
typedef long PRWord;
typedef unsigned long PRUword;
-#define nsnull 0
+# define nsnull 0
typedef PRUint32 nsresult;
-#if defined(__GNUC__) && (__GNUC__ > 2)
-#define NS_LIKELY(x) (__builtin_expect((x), 1))
-#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
-#else
-#define NS_LIKELY(x) (x)
-#define NS_UNLIKELY(x) (x)
-#endif
-
-#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
-#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
-
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_IntervalNow VBoxNsprPR_IntervalNow
-# define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
-# define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
-# define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
-# define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
-# define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
-# define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
-# define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
-# define PR_EnterMonitor VBoxNsprPR_EnterMonitor
-# define PR_ExitMonitor VBoxNsprPR_ExitMonitor
-# define PR_Notify VBoxNsprPR_Notify
-# define PR_NotifyAll VBoxNsprPR_NotifyAll
-# define PR_Wait VBoxNsprPR_Wait
-# define PR_NewMonitor VBoxNsprPR_NewMonitor
-# define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# if defined(__GNUC__) && (__GNUC__ > 2)
+# define NS_LIKELY(x) (__builtin_expect((x), 1))
+# define NS_UNLIKELY(x) (__builtin_expect((x), 0))
+# else
+# define NS_LIKELY(x) (x)
+# define NS_UNLIKELY(x) (x)
+# endif
+
+# define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
+# define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
+
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_IntervalNow VBoxNsprPR_IntervalNow
+# define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
+# define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
+# define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
+# define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
+# define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
+# define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
+# define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
+# define PR_EnterMonitor VBoxNsprPR_EnterMonitor
+# define PR_ExitMonitor VBoxNsprPR_ExitMonitor
+# define PR_Notify VBoxNsprPR_Notify
+# define PR_NotifyAll VBoxNsprPR_NotifyAll
+# define PR_Wait VBoxNsprPR_Wait
+# define PR_NewMonitor VBoxNsprPR_NewMonitor
+# define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef PRUint32 PRIntervalTime;
-#define PR_INTERVAL_MIN 1000UL
-#define PR_INTERVAL_MAX 100000UL
-#define PR_INTERVAL_NO_WAIT 0UL
-#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
+# define PR_INTERVAL_MIN 1000UL
+# define PR_INTERVAL_MAX 100000UL
+# define PR_INTERVAL_NO_WAIT 0UL
+# define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
NSPR_API(PRIntervalTime) PR_IntervalNow(void);
NSPR_API(PRUint32) PR_TicksPerSecond(void);
@@ -326,24 +326,24 @@ NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);
NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);
NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_CreateThread VBoxNsprPR_CreateThread
-# define PR_JoinThread VBoxNsprPR_JoinThread
-# define PR_Sleep VBoxNsprPR_Sleep
-# define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
-# define PR_GetThreadState VBoxNsprPR_GetThreadState
-# define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
-# define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
-# define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
-# define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
-# define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
-# define PR_Interrupt VBoxNsprPR_Interrupt
-# define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
-# define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
-# define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
-# define PR_GetThreadScope VBoxNsprPR_GetThreadScope
-# define PR_GetThreadType VBoxNsprPR_GetThreadType
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_CreateThread VBoxNsprPR_CreateThread
+# define PR_JoinThread VBoxNsprPR_JoinThread
+# define PR_Sleep VBoxNsprPR_Sleep
+# define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
+# define PR_GetThreadState VBoxNsprPR_GetThreadState
+# define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
+# define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
+# define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
+# define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
+# define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
+# define PR_Interrupt VBoxNsprPR_Interrupt
+# define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
+# define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
+# define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
+# define PR_GetThreadScope VBoxNsprPR_GetThreadScope
+# define PR_GetThreadType VBoxNsprPR_GetThreadType
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PRThread PRThread;
typedef struct PRThreadStack PRThreadStack;
@@ -383,9 +383,9 @@ NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,
PRUint32 stackSize);
NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
NSPR_API(PRThread*) PR_GetCurrentThread(void);
-#ifndef NO_NSPR_10_SUPPORT
-#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
-#endif /* NO_NSPR_10_SUPPORT */
+# ifndef NO_NSPR_10_SUPPORT
+# define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
+# endif /* NO_NSPR_10_SUPPORT */
NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
@@ -404,12 +404,12 @@ NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);
NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);
NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_DestroyLock VBoxNsprPR_DestroyLock
-# define PR_Lock VBoxNsprPR_Lock
-# define PR_NewLock VBoxNsprPR_NewLock
-# define PR_Unlock VBoxNsprPR_Unlock
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_DestroyLock VBoxNsprPR_DestroyLock
+# define PR_Lock VBoxNsprPR_Lock
+# define PR_NewLock VBoxNsprPR_NewLock
+# define PR_Unlock VBoxNsprPR_Unlock
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PRLock PRLock;
@@ -418,13 +418,13 @@ NSPR_API(void) PR_DestroyLock(PRLock *lock);
NSPR_API(void) PR_Lock(PRLock *lock);
NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_NewCondVar VBoxNsprPR_NewCondVar
-# define PR_DestroyCondVar VBoxNsprPR_DestroyCondVar
-# define PR_WaitCondVar VBoxNsprPR_WaitCondVar
-# define PR_NotifyCondVar VBoxNsprPR_NotifyCondVar
-# define PR_NotifyAllCondVar VBoxNsprPR_NotifyAllCondVar
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_NewCondVar VBoxNsprPR_NewCondVar
+# define PR_DestroyCondVar VBoxNsprPR_DestroyCondVar
+# define PR_WaitCondVar VBoxNsprPR_WaitCondVar
+# define PR_NotifyCondVar VBoxNsprPR_NotifyCondVar
+# define PR_NotifyAllCondVar VBoxNsprPR_NotifyAllCondVar
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PRCondVar PRCondVar;
@@ -441,34 +441,34 @@ struct PRCListStr {
PRCList *prev;
};
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PL_DestroyEvent VBoxNsplPL_DestroyEvent
-# define PL_HandleEvent VBoxNsplPL_HandleEvent
-# define PL_InitEvent VBoxNsplPL_InitEvent
-# define PL_CreateEventQueue VBoxNsplPL_CreateEventQueue
-# define PL_CreateMonitoredEventQueue VBoxNsplPL_CreateMonitoredEventQueue
-# define PL_CreateNativeEventQueue VBoxNsplPL_CreateNativeEventQueue
-# define PL_DequeueEvent VBoxNsplPL_DequeueEvent
-# define PL_DestroyEventQueue VBoxNsplPL_DestroyEventQueue
-# define PL_EventAvailable VBoxNsplPL_EventAvailable
-# define PL_EventLoop VBoxNsplPL_EventLoop
-# define PL_GetEvent VBoxNsplPL_GetEvent
-# define PL_GetEventOwner VBoxNsplPL_GetEventOwner
-# define PL_GetEventQueueMonitor VBoxNsplPL_GetEventQueueMonitor
-# define PL_GetEventQueueSelectFD VBoxNsplPL_GetEventQueueSelectFD
-# define PL_MapEvents VBoxNsplPL_MapEvents
-# define PL_PostEvent VBoxNsplPL_PostEvent
-# define PL_PostSynchronousEvent VBoxNsplPL_PostSynchronousEvent
-# define PL_ProcessEventsBeforeID VBoxNsplPL_ProcessEventsBeforeID
-# define PL_ProcessPendingEvents VBoxNsplPL_ProcessPendingEvents
-# define PL_RegisterEventIDFunc VBoxNsplPL_RegisterEventIDFunc
-# define PL_RevokeEvents VBoxNsplPL_RevokeEvents
-# define PL_UnregisterEventIDFunc VBoxNsplPL_UnregisterEventIDFunc
-# define PL_WaitForEvent VBoxNsplPL_WaitForEvent
-# define PL_IsQueueNative VBoxNsplPL_IsQueueNative
-# define PL_IsQueueOnCurrentThread VBoxNsplPL_IsQueueOnCurrentThread
-# define PL_FavorPerformanceHint VBoxNsplPL_FavorPerformanceHint
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PL_DestroyEvent VBoxNsplPL_DestroyEvent
+# define PL_HandleEvent VBoxNsplPL_HandleEvent
+# define PL_InitEvent VBoxNsplPL_InitEvent
+# define PL_CreateEventQueue VBoxNsplPL_CreateEventQueue
+# define PL_CreateMonitoredEventQueue VBoxNsplPL_CreateMonitoredEventQueue
+# define PL_CreateNativeEventQueue VBoxNsplPL_CreateNativeEventQueue
+# define PL_DequeueEvent VBoxNsplPL_DequeueEvent
+# define PL_DestroyEventQueue VBoxNsplPL_DestroyEventQueue
+# define PL_EventAvailable VBoxNsplPL_EventAvailable
+# define PL_EventLoop VBoxNsplPL_EventLoop
+# define PL_GetEvent VBoxNsplPL_GetEvent
+# define PL_GetEventOwner VBoxNsplPL_GetEventOwner
+# define PL_GetEventQueueMonitor VBoxNsplPL_GetEventQueueMonitor
+# define PL_GetEventQueueSelectFD VBoxNsplPL_GetEventQueueSelectFD
+# define PL_MapEvents VBoxNsplPL_MapEvents
+# define PL_PostEvent VBoxNsplPL_PostEvent
+# define PL_PostSynchronousEvent VBoxNsplPL_PostSynchronousEvent
+# define PL_ProcessEventsBeforeID VBoxNsplPL_ProcessEventsBeforeID
+# define PL_ProcessPendingEvents VBoxNsplPL_ProcessPendingEvents
+# define PL_RegisterEventIDFunc VBoxNsplPL_RegisterEventIDFunc
+# define PL_RevokeEvents VBoxNsplPL_RevokeEvents
+# define PL_UnregisterEventIDFunc VBoxNsplPL_UnregisterEventIDFunc
+# define PL_WaitForEvent VBoxNsplPL_WaitForEvent
+# define PL_IsQueueNative VBoxNsplPL_IsQueueNative
+# define PL_IsQueueOnCurrentThread VBoxNsplPL_IsQueueOnCurrentThread
+# define PL_FavorPerformanceHint VBoxNsplPL_FavorPerformanceHint
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PLEvent PLEvent;
typedef struct PLEventQueue PLEventQueue;
@@ -490,10 +490,10 @@ PL_DestroyEventQueue(PLEventQueue* self);
PR_EXTERN(PRMonitor*)
PL_GetEventQueueMonitor(PLEventQueue* self);
-#define PL_ENTER_EVENT_QUEUE_MONITOR(queue) \
+# define PL_ENTER_EVENT_QUEUE_MONITOR(queue) \
PR_EnterMonitor(PL_GetEventQueueMonitor(queue))
-#define PL_EXIT_EVENT_QUEUE_MONITOR(queue) \
+# define PL_EXIT_EVENT_QUEUE_MONITOR(queue) \
PR_ExitMonitor(PL_GetEventQueueMonitor(queue))
PR_EXTERN(PRStatus) PL_PostEvent(PLEventQueue* self, PLEvent* event);
@@ -533,24 +533,24 @@ struct PLEvent {
PRLock* lock;
PRCondVar* condVar;
PRBool handled;
-#ifdef PL_POST_TIMINGS
+# ifdef PL_POST_TIMINGS
PRIntervalTime postTime;
-#endif
-#ifdef XP_UNIX
+# endif
+# ifdef XP_UNIX
unsigned long id;
-#endif /* XP_UNIX */
+# endif /* XP_UNIX */
/* other fields follow... */
};
-#if defined(XP_WIN) || defined(XP_OS2)
+# if defined(XP_WIN) || defined(XP_OS2)
PR_EXTERN(HWND)
PL_GetNativeEventReceiverWindow(
PLEventQueue *eqp
);
-#endif /* XP_WIN || XP_OS2 */
+# endif /* XP_WIN || XP_OS2 */
-#ifdef XP_UNIX
+# ifdef XP_UNIX
PR_EXTERN(PRInt32)
PL_ProcessEventsBeforeID(PLEventQueue *aSelf, unsigned long aID);
@@ -562,66 +562,66 @@ PL_RegisterEventIDFunc(PLEventQueue *aSelf, PLGetEventIDFunc aFunc,
void *aClosure);
PR_EXTERN(void) PL_UnregisterEventIDFunc(PLEventQueue *aSelf);
-#endif /* XP_UNIX */
+# endif /* XP_UNIX */
/* Standard "it worked" return value */
-#define NS_OK 0
+# define NS_OK 0
-#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
+# define NS_ERROR_BASE ((nsresult) 0xC1F30000)
/* Returned when an instance is not initialized */
-#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
+# define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
/* Returned when an instance is already initialized */
-#define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
+# define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
/* Returned by a not implemented function */
-#define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
+# define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
/* Returned when a given interface is not supported. */
-#define NS_NOINTERFACE ((nsresult) 0x80004002L)
-#define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
+# define NS_NOINTERFACE ((nsresult) 0x80004002L)
+# define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
-#define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
-#define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
+# define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
+# define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
/* Returned when a function aborts */
-#define NS_ERROR_ABORT ((nsresult) 0x80004004L)
+# define NS_ERROR_ABORT ((nsresult) 0x80004004L)
/* Returned when a function fails */
-#define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
+# define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
/* Returned when an unexpected error occurs */
-#define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
+# define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
/* Returned when a memory allocation fails */
-#define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
+# define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
/* Returned when an illegal value is passed */
-#define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
-#define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
+# define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
+# define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
/* Returned when a class doesn't allow aggregation */
-#define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
+# define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
/* Returned when an operation can't complete due to an unavailable resource */
-#define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
+# define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
/* Returned when a class is not registered */
-#define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
+# define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
/* Returned when a class cannot be registered, but may be tried again later */
-#define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
+# define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
/* Returned when a dynamically loaded factory couldn't be found */
-#define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
+# define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
/* Returned when a factory doesn't support signatures */
-#define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
+# define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
(NS_ERROR_BASE + 0x101)
/* Returned when a factory already is registered */
-#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
+# define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
/**
@@ -654,7 +654,7 @@ typedef struct nsIException nsIException; /* forward declaration */
* To maintain binary compatibility with COM's IUnknown, we define the IID
* of nsISupports to be the same as that of COM's IUnknown.
*/
-#define NS_ISUPPORTS_IID \
+# define NS_ISUPPORTS_IID \
{ 0x00000000, 0x0000, 0x0000, \
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
@@ -714,9 +714,9 @@ struct nsISupports {
};
/* starting interface: nsIException */
-#define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
+# define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
-#define NS_IEXCEPTION_IID \
+# define NS_IEXCEPTION_IID \
{0xf3a8d3b4, 0xc424, 0x4edc, \
{ 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }}
@@ -761,9 +761,9 @@ struct nsIException {
};
/* starting interface: nsIStackFrame */
-#define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
+# define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
-#define NS_ISTACKFRAME_IID \
+# define NS_ISTACKFRAME_IID \
{0x91d82105, 0x7c62, 0x4f8b, \
{ 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }}
@@ -802,9 +802,9 @@ struct nsIStackFrame {
};
/* starting interface: nsIEventTarget */
-#define NS_IEVENTTARGET_IID_STR "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"
+# define NS_IEVENTTARGET_IID_STR "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"
-#define NS_IEVENTTARGET_IID \
+# define NS_IEVENTTARGET_IID \
{0xea99ad5b, 0xcc67, 0x4efb, \
{ 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a }}
@@ -826,9 +826,9 @@ struct nsIEventTarget {
};
/* starting interface: nsIEventQueue */
-#define NS_IEVENTQUEUE_IID_STR "176afb41-00a4-11d3-9f2a-00400553eef0"
+# define NS_IEVENTQUEUE_IID_STR "176afb41-00a4-11d3-9f2a-00400553eef0"
-#define NS_IEVENTQUEUE_IID \
+# define NS_IEVENTQUEUE_IID \
{0x176afb41, 0x00a4, 0x11d3, \
{ 0x9f, 0x2a, 0x00, 0x40, 0x05, 0x53, 0xee, 0xf0 }}
@@ -884,18 +884,18 @@ struct nsIEventQueue {
};
-#define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001
-#define VBOX_E_INVALID_VM_STATE 0x80BB0002
-#define VBOX_E_VM_ERROR 0x80BB0003
-#define VBOX_E_FILE_ERROR 0x80BB0004
-#define VBOX_E_IPRT_ERROR 0x80BB0005
-#define VBOX_E_PDM_ERROR 0x80BB0006
-#define VBOX_E_INVALID_OBJECT_STATE 0x80BB0007
-#define VBOX_E_HOST_ERROR 0x80BB0008
-#define VBOX_E_NOT_SUPPORTED 0x80BB0009
-#define VBOX_E_XML_ERROR 0x80BB000A
-#define VBOX_E_INVALID_SESSION_STATE 0x80BB000B
-#define VBOX_E_OBJECT_IN_USE 0x80BB000C
+# define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001
+# define VBOX_E_INVALID_VM_STATE 0x80BB0002
+# define VBOX_E_VM_ERROR 0x80BB0003
+# define VBOX_E_FILE_ERROR 0x80BB0004
+# define VBOX_E_IPRT_ERROR 0x80BB0005
+# define VBOX_E_PDM_ERROR 0x80BB0006
+# define VBOX_E_INVALID_OBJECT_STATE 0x80BB0007
+# define VBOX_E_HOST_ERROR 0x80BB0008
+# define VBOX_E_NOT_SUPPORTED 0x80BB0009
+# define VBOX_E_XML_ERROR 0x80BB000A
+# define VBOX_E_INVALID_SESSION_STATE 0x80BB000B
+# define VBOX_E_OBJECT_IN_USE 0x80BB000C
struct IVirtualBoxErrorInfo;
@@ -1011,8 +1011,8 @@ typedef struct IPerformanceMetric IPerformanceMetric;
typedef struct IPerformanceCollector IPerformanceCollector;
/* Start of enum AccessMode Declaration */
-#define ACCESSMODE_IID_STR "1da0007c-ddf7-4be8-bcac-d84a1558785f"
-#define ACCESSMODE_IID { \
+# define ACCESSMODE_IID_STR "1da0007c-ddf7-4be8-bcac-d84a1558785f"
+# define ACCESSMODE_IID { \
0x1da0007c, 0xddf7, 0x4be8, \
{ 0xbc, 0xac, 0xd8, 0x4a, 0x15, 0x58, 0x78, 0x5f } \
}
@@ -1025,8 +1025,8 @@ enum AccessMode
/* Start of enum MachineState Declaration */
-#define MACHINESTATE_IID_STR "73bf04d0-7c4f-4684-9abf-d65a9ad74343"
-#define MACHINESTATE_IID { \
+# define MACHINESTATE_IID_STR "73bf04d0-7c4f-4684-9abf-d65a9ad74343"
+# define MACHINESTATE_IID { \
0x73bf04d0, 0x7c4f, 0x4684, \
{ 0x9a, 0xbf, 0xd6, 0x5a, 0x9a, 0xd7, 0x43, 0x43 } \
}
@@ -1054,8 +1054,8 @@ enum MachineState
/* Start of enum SessionState Declaration */
-#define SESSIONSTATE_IID_STR "CF2700C0-EA4B-47ae-9725-7810114B94D8"
-#define SESSIONSTATE_IID { \
+# define SESSIONSTATE_IID_STR "CF2700C0-EA4B-47ae-9725-7810114B94D8"
+# define SESSIONSTATE_IID { \
0xCF2700C0, 0xEA4B, 0x47ae, \
{ 0x97, 0x25, 0x78, 0x10, 0x11, 0x4B, 0x94, 0xD8 } \
}
@@ -1071,8 +1071,8 @@ enum SessionState
/* Start of enum SessionType Declaration */
-#define SESSIONTYPE_IID_STR "A13C02CB-0C2C-421E-8317-AC0E8AAA153A"
-#define SESSIONTYPE_IID { \
+# define SESSIONTYPE_IID_STR "A13C02CB-0C2C-421E-8317-AC0E8AAA153A"
+# define SESSIONTYPE_IID { \
0xA13C02CB, 0x0C2C, 0x421E, \
{ 0x83, 0x17, 0xAC, 0x0E, 0x8A, 0xAA, 0x15, 0x3A } \
}
@@ -1087,8 +1087,8 @@ enum SessionType
/* Start of enum DeviceType Declaration */
-#define DEVICETYPE_IID_STR "6d9420f7-0b56-4636-99f9-7346f1b01e57"
-#define DEVICETYPE_IID { \
+# define DEVICETYPE_IID_STR "6d9420f7-0b56-4636-99f9-7346f1b01e57"
+# define DEVICETYPE_IID { \
0x6d9420f7, 0x0b56, 0x4636, \
{ 0x99, 0xf9, 0x73, 0x46, 0xf1, 0xb0, 0x1e, 0x57 } \
}
@@ -1106,8 +1106,8 @@ enum DeviceType
/* Start of enum DeviceActivity Declaration */
-#define DEVICEACTIVITY_IID_STR "6FC8AEAA-130A-4eb5-8954-3F921422D707"
-#define DEVICEACTIVITY_IID { \
+# define DEVICEACTIVITY_IID_STR "6FC8AEAA-130A-4eb5-8954-3F921422D707"
+# define DEVICEACTIVITY_IID { \
0x6FC8AEAA, 0x130A, 0x4eb5, \
{ 0x89, 0x54, 0x3F, 0x92, 0x14, 0x22, 0xD7, 0x07 } \
}
@@ -1122,8 +1122,8 @@ enum DeviceActivity
/* Start of enum ClipboardMode Declaration */
-#define CLIPBOARDMODE_IID_STR "33364716-4008-4701-8f14-be0fa3d62950"
-#define CLIPBOARDMODE_IID { \
+# define CLIPBOARDMODE_IID_STR "33364716-4008-4701-8f14-be0fa3d62950"
+# define CLIPBOARDMODE_IID { \
0x33364716, 0x4008, 0x4701, \
{ 0x8f, 0x14, 0xbe, 0x0f, 0xa3, 0xd6, 0x29, 0x50 } \
}
@@ -1138,8 +1138,8 @@ enum ClipboardMode
/* Start of enum Scope Declaration */
-#define SCOPE_IID_STR "7c91096e-499e-4eca-9f9b-9001438d7855"
-#define SCOPE_IID { \
+# define SCOPE_IID_STR "7c91096e-499e-4eca-9f9b-9001438d7855"
+# define SCOPE_IID { \
0x7c91096e, 0x499e, 0x4eca, \
{ 0x9f, 0x9b, 0x90, 0x01, 0x43, 0x8d, 0x78, 0x55 } \
}
@@ -1153,8 +1153,8 @@ enum Scope
/* Start of enum GuestStatisticType Declaration */
-#define GUESTSTATISTICTYPE_IID_STR "aa7c1d71-aafe-47a8-9608-27d2d337cf55"
-#define GUESTSTATISTICTYPE_IID { \
+# define GUESTSTATISTICTYPE_IID_STR "aa7c1d71-aafe-47a8-9608-27d2d337cf55"
+# define GUESTSTATISTICTYPE_IID { \
0xaa7c1d71, 0xaafe, 0x47a8, \
{ 0x96, 0x08, 0x27, 0xd2, 0xd3, 0x37, 0xcf, 0x55 } \
}
@@ -1183,8 +1183,8 @@ enum GuestStatisticType
/* Start of enum BIOSBootMenuMode Declaration */
-#define BIOSBOOTMENUMODE_IID_STR "ae4fb9f7-29d2-45b4-b2c7-d579603135d5"
-#define BIOSBOOTMENUMODE_IID { \
+# define BIOSBOOTMENUMODE_IID_STR "ae4fb9f7-29d2-45b4-b2c7-d579603135d5"
+# define BIOSBOOTMENUMODE_IID { \
0xae4fb9f7, 0x29d2, 0x45b4, \
{ 0xb2, 0xc7, 0xd5, 0x79, 0x60, 0x31, 0x35, 0xd5 } \
}
@@ -1198,8 +1198,8 @@ enum BIOSBootMenuMode
/* Start of enum DriveState Declaration */
-#define DRIVESTATE_IID_STR "cb7233b7-c519-42a5-8310-1830953cacbc"
-#define DRIVESTATE_IID { \
+# define DRIVESTATE_IID_STR "cb7233b7-c519-42a5-8310-1830953cacbc"
+# define DRIVESTATE_IID { \
0xcb7233b7, 0xc519, 0x42a5, \
{ 0x83, 0x10, 0x18, 0x30, 0x95, 0x3c, 0xac, 0xbc } \
}
@@ -1214,8 +1214,8 @@ enum DriveState
/* Start of enum ProcessorFeature Declaration */
-#define PROCESSORFEATURE_IID_STR "b8353b35-705d-4796-9967-ebfb7ba54af4"
-#define PROCESSORFEATURE_IID { \
+# define PROCESSORFEATURE_IID_STR "b8353b35-705d-4796-9967-ebfb7ba54af4"
+# define PROCESSORFEATURE_IID { \
0xb8353b35, 0x705d, 0x4796, \
{ 0x99, 0x67, 0xeb, 0xfb, 0x7b, 0xa5, 0x4a, 0xf4 } \
}
@@ -1229,8 +1229,8 @@ enum ProcessorFeature
/* Start of enum VFSType Declaration */
-#define VFSTYPE_IID_STR "813999ba-b949-48a8-9230-aadc6285e2f2"
-#define VFSTYPE_IID { \
+# define VFSTYPE_IID_STR "813999ba-b949-48a8-9230-aadc6285e2f2"
+# define VFSTYPE_IID { \
0x813999ba, 0xb949, 0x48a8, \
{ 0x92, 0x30, 0xaa, 0xdc, 0x62, 0x85, 0xe2, 0xf2 } \
}
@@ -1245,8 +1245,8 @@ enum VFSType
/* Start of enum VFSFileType Declaration */
-#define VFSFILETYPE_IID_STR "714333cd-44e2-415f-a245-d378fa9b1242"
-#define VFSFILETYPE_IID { \
+# define VFSFILETYPE_IID_STR "714333cd-44e2-415f-a245-d378fa9b1242"
+# define VFSFILETYPE_IID { \
0x714333cd, 0x44e2, 0x415f, \
{ 0xa2, 0x45, 0xd3, 0x78, 0xfa, 0x9b, 0x12, 0x42 } \
}
@@ -1266,8 +1266,8 @@ enum VFSFileType
/* Start of enum CIMOSType Declaration */
-#define CIMOSTYPE_IID_STR "86ef5f8c-18b2-4db8-a314-33721b59f89b"
-#define CIMOSTYPE_IID { \
+# define CIMOSTYPE_IID_STR "86ef5f8c-18b2-4db8-a314-33721b59f89b"
+# define CIMOSTYPE_IID { \
0x86ef5f8c, 0x18b2, 0x4db8, \
{ 0xa3, 0x14, 0x33, 0x72, 0x1b, 0x59, 0xf8, 0x9b } \
}
@@ -1381,8 +1381,8 @@ enum CIMOSType
/* Start of enum OVFResourceType Declaration */
-#define OVFRESOURCETYPE_IID_STR "646a78d7-6f04-49f4-82c4-75c28a75a4cd"
-#define OVFRESOURCETYPE_IID { \
+# define OVFRESOURCETYPE_IID_STR "646a78d7-6f04-49f4-82c4-75c28a75a4cd"
+# define OVFRESOURCETYPE_IID { \
0x646a78d7, 0x6f04, 0x49f4, \
{ 0x82, 0xc4, 0x75, 0xc2, 0x8a, 0x75, 0xa4, 0xcd } \
}
@@ -1413,8 +1413,8 @@ enum OVFResourceType
/* Start of enum VirtualSystemDescriptionType Declaration */
-#define VIRTUALSYSTEMDESCRIPTIONTYPE_IID_STR "aacc58de-5b45-4f82-ae2e-dd9a824fc3b5"
-#define VIRTUALSYSTEMDESCRIPTIONTYPE_IID { \
+# define VIRTUALSYSTEMDESCRIPTIONTYPE_IID_STR "aacc58de-5b45-4f82-ae2e-dd9a824fc3b5"
+# define VIRTUALSYSTEMDESCRIPTIONTYPE_IID { \
0xaacc58de, 0x5b45, 0x4f82, \
{ 0xae, 0x2e, 0xdd, 0x9a, 0x82, 0x4f, 0xc3, 0xb5 } \
}
@@ -1447,8 +1447,8 @@ enum VirtualSystemDescriptionType
/* Start of enum VirtualSystemDescriptionValueType Declaration */
-#define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID_STR "56d9403f-3425-4118-9919-36f2a9b8c77c"
-#define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID { \
+# define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID_STR "56d9403f-3425-4118-9919-36f2a9b8c77c"
+# define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID { \
0x56d9403f, 0x3425, 0x4118, \
{ 0x99, 0x19, 0x36, 0xf2, 0xa9, 0xb8, 0xc7, 0x7c } \
}
@@ -1463,8 +1463,8 @@ enum VirtualSystemDescriptionValueType
/* Start of enum HostNetworkInterfaceMediumType Declaration */
-#define HOSTNETWORKINTERFACEMEDIUMTYPE_IID_STR "1aa54aaf-2497-45a2-bfb1-8eb225e93d5b"
-#define HOSTNETWORKINTERFACEMEDIUMTYPE_IID { \
+# define HOSTNETWORKINTERFACEMEDIUMTYPE_IID_STR "1aa54aaf-2497-45a2-bfb1-8eb225e93d5b"
+# define HOSTNETWORKINTERFACEMEDIUMTYPE_IID { \
0x1aa54aaf, 0x2497, 0x45a2, \
{ 0xbf, 0xb1, 0x8e, 0xb2, 0x25, 0xe9, 0x3d, 0x5b } \
}
@@ -1479,8 +1479,8 @@ enum HostNetworkInterfaceMediumType
/* Start of enum HostNetworkInterfaceStatus Declaration */
-#define HOSTNETWORKINTERFACESTATUS_IID_STR "CC474A69-2710-434B-8D99-C38E5D5A6F41"
-#define HOSTNETWORKINTERFACESTATUS_IID { \
+# define HOSTNETWORKINTERFACESTATUS_IID_STR "CC474A69-2710-434B-8D99-C38E5D5A6F41"
+# define HOSTNETWORKINTERFACESTATUS_IID { \
0xCC474A69, 0x2710, 0x434B, \
{ 0x8D, 0x99, 0xC3, 0x8E, 0x5D, 0x5A, 0x6F, 0x41 } \
}
@@ -1494,8 +1494,8 @@ enum HostNetworkInterfaceStatus
/* Start of enum HostNetworkInterfaceType Declaration */
-#define HOSTNETWORKINTERFACETYPE_IID_STR "67431b00-9946-48a2-bc02-b25c5919f4f3"
-#define HOSTNETWORKINTERFACETYPE_IID { \
+# define HOSTNETWORKINTERFACETYPE_IID_STR "67431b00-9946-48a2-bc02-b25c5919f4f3"
+# define HOSTNETWORKINTERFACETYPE_IID { \
0x67431b00, 0x9946, 0x48a2, \
{ 0xbc, 0x02, 0xb2, 0x5c, 0x59, 0x19, 0xf4, 0xf3 } \
}
@@ -1508,8 +1508,8 @@ enum HostNetworkInterfaceType
/* Start of enum MediaState Declaration */
-#define MEDIASTATE_IID_STR "8b86e03c-2f1c-412a-8fbd-326f62701200"
-#define MEDIASTATE_IID { \
+# define MEDIASTATE_IID_STR "8b86e03c-2f1c-412a-8fbd-326f62701200"
+# define MEDIASTATE_IID { \
0x8b86e03c, 0x2f1c, 0x412a, \
{ 0x8f, 0xbd, 0x32, 0x6f, 0x62, 0x70, 0x12, 0x00 } \
}
@@ -1527,8 +1527,8 @@ enum MediaState
/* Start of enum HardDiskType Declaration */
-#define HARDDISKTYPE_IID_STR "a348fafd-a64e-4643-ba65-eb3896bd7e0a"
-#define HARDDISKTYPE_IID { \
+# define HARDDISKTYPE_IID_STR "a348fafd-a64e-4643-ba65-eb3896bd7e0a"
+# define HARDDISKTYPE_IID { \
0xa348fafd, 0xa64e, 0x4643, \
{ 0xba, 0x65, 0xeb, 0x38, 0x96, 0xbd, 0x7e, 0x0a } \
}
@@ -1542,8 +1542,8 @@ enum HardDiskType
/* Start of enum HardDiskVariant Declaration */
-#define HARDDISKVARIANT_IID_STR "eb7fc6b3-ae23-4c5d-a1f6-e3522dd1efb0"
-#define HARDDISKVARIANT_IID { \
+# define HARDDISKVARIANT_IID_STR "eb7fc6b3-ae23-4c5d-a1f6-e3522dd1efb0"
+# define HARDDISKVARIANT_IID { \
0xeb7fc6b3, 0xae23, 0x4c5d, \
{ 0xa1, 0xf6, 0xe3, 0x52, 0x2d, 0xd1, 0xef, 0xb0 } \
}
@@ -1560,8 +1560,8 @@ enum HardDiskVariant
/* Start of enum DataType Declaration */
-#define DATATYPE_IID_STR "d90ea51e-a3f1-4a01-beb1-c1723c0d3ba7"
-#define DATATYPE_IID { \
+# define DATATYPE_IID_STR "d90ea51e-a3f1-4a01-beb1-c1723c0d3ba7"
+# define DATATYPE_IID { \
0xd90ea51e, 0xa3f1, 0x4a01, \
{ 0xbe, 0xb1, 0xc1, 0x72, 0x3c, 0x0d, 0x3b, 0xa7 } \
}
@@ -1575,8 +1575,8 @@ enum DataType
/* Start of enum DataFlags Declaration */
-#define DATAFLAGS_IID_STR "86884dcf-1d6b-4f1b-b4bf-f5aa44959d60"
-#define DATAFLAGS_IID { \
+# define DATAFLAGS_IID_STR "86884dcf-1d6b-4f1b-b4bf-f5aa44959d60"
+# define DATAFLAGS_IID { \
0x86884dcf, 0x1d6b, 0x4f1b, \
{ 0xb4, 0xbf, 0xf5, 0xaa, 0x44, 0x95, 0x9d, 0x60 } \
}
@@ -1592,8 +1592,8 @@ enum DataFlags
/* Start of enum HardDiskFormatCapabilities Declaration */
-#define HARDDISKFORMATCAPABILITIES_IID_STR "1df1e4aa-d25a-4ba6-b2a2-02f60eb5903b"
-#define HARDDISKFORMATCAPABILITIES_IID { \
+# define HARDDISKFORMATCAPABILITIES_IID_STR "1df1e4aa-d25a-4ba6-b2a2-02f60eb5903b"
+# define HARDDISKFORMATCAPABILITIES_IID { \
0x1df1e4aa, 0xd25a, 0x4ba6, \
{ 0xb2, 0xa2, 0x02, 0xf6, 0x0e, 0xb5, 0x90, 0x3b } \
}
@@ -1613,8 +1613,8 @@ enum HardDiskFormatCapabilities
/* Start of enum MouseButtonState Declaration */
-#define MOUSEBUTTONSTATE_IID_STR "03131722-2EC5-4173-9794-0DACA46673EF"
-#define MOUSEBUTTONSTATE_IID { \
+# define MOUSEBUTTONSTATE_IID_STR "03131722-2EC5-4173-9794-0DACA46673EF"
+# define MOUSEBUTTONSTATE_IID { \
0x03131722, 0x2EC5, 0x4173, \
{ 0x97, 0x94, 0x0D, 0xAC, 0xA4, 0x66, 0x73, 0xEF } \
}
@@ -1631,8 +1631,8 @@ enum MouseButtonState
/* Start of enum FramebufferPixelFormat Declaration */
-#define FRAMEBUFFERPIXELFORMAT_IID_STR "7acfd5ed-29e3-45e3-8136-73c9224f3d2d"
-#define FRAMEBUFFERPIXELFORMAT_IID { \
+# define FRAMEBUFFERPIXELFORMAT_IID_STR "7acfd5ed-29e3-45e3-8136-73c9224f3d2d"
+# define FRAMEBUFFERPIXELFORMAT_IID { \
0x7acfd5ed, 0x29e3, 0x45e3, \
{ 0x81, 0x36, 0x73, 0xc9, 0x22, 0x4f, 0x3d, 0x2d } \
}
@@ -1645,8 +1645,8 @@ enum FramebufferPixelFormat
/* Start of enum NetworkAttachmentType Declaration */
-#define NETWORKATTACHMENTTYPE_IID_STR "44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
-#define NETWORKATTACHMENTTYPE_IID { \
+# define NETWORKATTACHMENTTYPE_IID_STR "44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
+# define NETWORKATTACHMENTTYPE_IID { \
0x44bce1ee, 0x99f7, 0x4e8e, \
{ 0x89, 0xfc, 0x80, 0x59, 0x7f, 0xd9, 0xee, 0xaf } \
}
@@ -1662,8 +1662,8 @@ enum NetworkAttachmentType
/* Start of enum NetworkAdapterType Declaration */
-#define NETWORKADAPTERTYPE_IID_STR "50c3dfd8-07ac-4a31-baac-519c828fbf97"
-#define NETWORKADAPTERTYPE_IID { \
+# define NETWORKADAPTERTYPE_IID_STR "50c3dfd8-07ac-4a31-baac-519c828fbf97"
+# define NETWORKADAPTERTYPE_IID { \
0x50c3dfd8, 0x07ac, 0x4a31, \
{ 0xba, 0xac, 0x51, 0x9c, 0x82, 0x8f, 0xbf, 0x97 } \
}
@@ -1680,8 +1680,8 @@ enum NetworkAdapterType
/* Start of enum PortMode Declaration */
-#define PORTMODE_IID_STR "533b5fe3-0185-4197-86a7-17e37dd39d76"
-#define PORTMODE_IID { \
+# define PORTMODE_IID_STR "533b5fe3-0185-4197-86a7-17e37dd39d76"
+# define PORTMODE_IID { \
0x533b5fe3, 0x0185, 0x4197, \
{ 0x86, 0xa7, 0x17, 0xe3, 0x7d, 0xd3, 0x9d, 0x76 } \
}
@@ -1696,8 +1696,8 @@ enum PortMode
/* Start of enum USBDeviceState Declaration */
-#define USBDEVICESTATE_IID_STR "b99a2e65-67fb-4882-82fd-f3e5e8193ab4"
-#define USBDEVICESTATE_IID { \
+# define USBDEVICESTATE_IID_STR "b99a2e65-67fb-4882-82fd-f3e5e8193ab4"
+# define USBDEVICESTATE_IID { \
0xb99a2e65, 0x67fb, 0x4882, \
{ 0x82, 0xfd, 0xf3, 0xe5, 0xe8, 0x19, 0x3a, 0xb4 } \
}
@@ -1714,8 +1714,8 @@ enum USBDeviceState
/* Start of enum USBDeviceFilterAction Declaration */
-#define USBDEVICEFILTERACTION_IID_STR "cbc30a49-2f4e-43b5-9da6-121320475933"
-#define USBDEVICEFILTERACTION_IID { \
+# define USBDEVICEFILTERACTION_IID_STR "cbc30a49-2f4e-43b5-9da6-121320475933"
+# define USBDEVICEFILTERACTION_IID { \
0xcbc30a49, 0x2f4e, 0x43b5, \
{ 0x9d, 0xa6, 0x12, 0x13, 0x20, 0x47, 0x59, 0x33 } \
}
@@ -1729,8 +1729,8 @@ enum USBDeviceFilterAction
/* Start of enum AudioDriverType Declaration */
-#define AUDIODRIVERTYPE_IID_STR "4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
-#define AUDIODRIVERTYPE_IID { \
+# define AUDIODRIVERTYPE_IID_STR "4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
+# define AUDIODRIVERTYPE_IID { \
0x4bcc3d73, 0xc2fe, 0x40db, \
{ 0xb7, 0x2f, 0x0c, 0x2c, 0xa9, 0xd6, 0x84, 0x96 } \
}
@@ -1750,8 +1750,8 @@ enum AudioDriverType
/* Start of enum AudioControllerType Declaration */
-#define AUDIOCONTROLLERTYPE_IID_STR "7afd395c-42c3-444e-8788-3ce80292f36c"
-#define AUDIOCONTROLLERTYPE_IID { \
+# define AUDIOCONTROLLERTYPE_IID_STR "7afd395c-42c3-444e-8788-3ce80292f36c"
+# define AUDIOCONTROLLERTYPE_IID { \
0x7afd395c, 0x42c3, 0x444e, \
{ 0x87, 0x88, 0x3c, 0xe8, 0x02, 0x92, 0xf3, 0x6c } \
}
@@ -1764,8 +1764,8 @@ enum AudioControllerType
/* Start of enum VRDPAuthType Declaration */
-#define VRDPAUTHTYPE_IID_STR "3d91887a-b67f-4b33-85bf-2da7ab1ea83a"
-#define VRDPAUTHTYPE_IID { \
+# define VRDPAUTHTYPE_IID_STR "3d91887a-b67f-4b33-85bf-2da7ab1ea83a"
+# define VRDPAUTHTYPE_IID { \
0x3d91887a, 0xb67f, 0x4b33, \
{ 0x85, 0xbf, 0x2d, 0xa7, 0xab, 0x1e, 0xa8, 0x3a } \
}
@@ -1779,8 +1779,8 @@ enum VRDPAuthType
/* Start of enum StorageBus Declaration */
-#define STORAGEBUS_IID_STR "f381fdca-5953-41d0-b2bd-0542b012698d"
-#define STORAGEBUS_IID { \
+# define STORAGEBUS_IID_STR "f381fdca-5953-41d0-b2bd-0542b012698d"
+# define STORAGEBUS_IID { \
0xf381fdca, 0x5953, 0x41d0, \
{ 0xb2, 0xbd, 0x05, 0x42, 0xb0, 0x12, 0x69, 0x8d } \
}
@@ -1795,8 +1795,8 @@ enum StorageBus
/* Start of enum StorageControllerType Declaration */
-#define STORAGECONTROLLERTYPE_IID_STR "685387db-a837-4320-a258-08f46a22f62a"
-#define STORAGECONTROLLERTYPE_IID { \
+# define STORAGECONTROLLERTYPE_IID_STR "685387db-a837-4320-a258-08f46a22f62a"
+# define STORAGECONTROLLERTYPE_IID { \
0x685387db, 0xa837, 0x4320, \
{ 0xa2, 0x58, 0x08, 0xf4, 0x6a, 0x22, 0xf6, 0x2a } \
}
@@ -1814,8 +1814,8 @@ enum StorageControllerType
/* Start of struct IVirtualBoxErrorInfo Declaration */
-#define IVIRTUALBOXERRORINFO_IID_STR "bcae7fc3-3fd0-4bac-923c-ec1596c7bc83"
-#define IVIRTUALBOXERRORINFO_IID { \
+# define IVIRTUALBOXERRORINFO_IID_STR "bcae7fc3-3fd0-4bac-923c-ec1596c7bc83"
+# define IVIRTUALBOXERRORINFO_IID { \
0xbcae7fc3, 0x3fd0, 0x4bac, \
{ 0x92, 0x3c, 0xec, 0x15, 0x96, 0xc7, 0xbc, 0x83 } \
}
@@ -1843,8 +1843,8 @@ struct IVirtualBoxErrorInfo
/* Start of struct ILocalOwner Declaration */
-#define ILOCALOWNER_IID_STR "308FF42A-DC45-49D4-A950-B1EEE5E00BB5"
-#define ILOCALOWNER_IID { \
+# define ILOCALOWNER_IID_STR "308FF42A-DC45-49D4-A950-B1EEE5E00BB5"
+# define ILOCALOWNER_IID { \
0x308FF42A, 0xDC45, 0x49D4, \
{ 0xA9, 0x50, 0xB1, 0xEE, 0xE5, 0xE0, 0x0B, 0xB5 } \
}
@@ -1867,8 +1867,8 @@ struct ILocalOwner
/* Start of struct IVirtualBoxCallback Declaration */
-#define IVIRTUALBOXCALLBACK_IID_STR "2990059f-5bc8-4635-8415-658917cd3186"
-#define IVIRTUALBOXCALLBACK_IID { \
+# define IVIRTUALBOXCALLBACK_IID_STR "2990059f-5bc8-4635-8415-658917cd3186"
+# define IVIRTUALBOXCALLBACK_IID { \
0x2990059f, 0x5bc8, 0x4635, \
{ 0x84, 0x15, 0x65, 0x89, 0x17, 0xcd, 0x31, 0x86 } \
}
@@ -1958,8 +1958,8 @@ struct IVirtualBoxCallback
/* Start of struct IDHCPServer Declaration */
-#define IDHCPSERVER_IID_STR "6cfe387c-74fb-4ca7-bff6-973bec8af7a3"
-#define IDHCPSERVER_IID { \
+# define IDHCPSERVER_IID_STR "6cfe387c-74fb-4ca7-bff6-973bec8af7a3"
+# define IDHCPSERVER_IID { \
0x6cfe387c, 0x74fb, 0x4ca7, \
{ 0xbf, 0xf6, 0x97, 0x3b, 0xec, 0x8a, 0xf7, 0xa3 } \
}
@@ -2007,8 +2007,8 @@ struct IDHCPServer
/* Start of struct IVirtualBox Declaration */
-#define IVIRTUALBOX_IID_STR "3f4ab53a-199b-4526-a91a-93ff62e456b8"
-#define IVIRTUALBOX_IID { \
+# define IVIRTUALBOX_IID_STR "3f4ab53a-199b-4526-a91a-93ff62e456b8"
+# define IVIRTUALBOX_IID { \
0x3f4ab53a, 0x199b, 0x4526, \
{ 0xa9, 0x1a, 0x93, 0xff, 0x62, 0xe4, 0x56, 0xb8 } \
}
@@ -2282,8 +2282,8 @@ struct IVirtualBox
/* Start of struct IVFSExplorer Declaration */
-#define IVFSEXPLORER_IID_STR "2bb864a1-02a3-4474-a1d4-fb5f23b742e1"
-#define IVFSEXPLORER_IID { \
+# define IVFSEXPLORER_IID_STR "2bb864a1-02a3-4474-a1d4-fb5f23b742e1"
+# define IVFSEXPLORER_IID { \
0x2bb864a1, 0x02a3, 0x4474, \
{ 0xa1, 0xd4, 0xfb, 0x5f, 0x23, 0xb7, 0x42, 0xe1 } \
}
@@ -2344,8 +2344,8 @@ struct IVFSExplorer
/* Start of struct IAppliance Declaration */
-#define IAPPLIANCE_IID_STR "07495095-d16c-4911-8964-5914341ced5d"
-#define IAPPLIANCE_IID { \
+# define IAPPLIANCE_IID_STR "07495095-d16c-4911-8964-5914341ced5d"
+# define IAPPLIANCE_IID { \
0x07495095, 0xd16c, 0x4911, \
{ 0x89, 0x64, 0x59, 0x14, 0x34, 0x1c, 0xed, 0x5d } \
}
@@ -2400,8 +2400,8 @@ struct IAppliance
/* Start of struct IVirtualSystemDescription Declaration */
-#define IVIRTUALSYSTEMDESCRIPTION_IID_STR "d7525e6c-531a-4c51-8e04-41235083a3d8"
-#define IVIRTUALSYSTEMDESCRIPTION_IID { \
+# define IVIRTUALSYSTEMDESCRIPTION_IID_STR "d7525e6c-531a-4c51-8e04-41235083a3d8"
+# define IVIRTUALSYSTEMDESCRIPTION_IID { \
0xd7525e6c, 0x531a, 0x4c51, \
{ 0x8e, 0x04, 0x41, 0x23, 0x50, 0x83, 0xa3, 0xd8 } \
}
@@ -2475,8 +2475,8 @@ struct IVirtualSystemDescription
/* Start of struct IInternalMachineControl Declaration */
-#define IINTERNALMACHINECONTROL_IID_STR "ce8087d7-de92-4bbb-8140-a22fb07f37ba"
-#define IINTERNALMACHINECONTROL_IID { \
+# define IINTERNALMACHINECONTROL_IID_STR "ce8087d7-de92-4bbb-8140-a22fb07f37ba"
+# define IINTERNALMACHINECONTROL_IID { \
0xce8087d7, 0xde92, 0x4bbb, \
{ 0x81, 0x40, 0xa2, 0x2f, 0xb0, 0x7f, 0x37, 0xba } \
}
@@ -2627,8 +2627,8 @@ struct IInternalMachineControl
/* Start of struct IBIOSSettings Declaration */
-#define IBIOSSETTINGS_IID_STR "38b54279-dc35-4f5e-a431-835b867c6b5e"
-#define IBIOSSETTINGS_IID { \
+# define IBIOSSETTINGS_IID_STR "38b54279-dc35-4f5e-a431-835b867c6b5e"
+# define IBIOSSETTINGS_IID { \
0x38b54279, 0xdc35, 0x4f5e, \
{ 0xa4, 0x31, 0x83, 0x5b, 0x86, 0x7c, 0x6b, 0x5e } \
}
@@ -2673,8 +2673,8 @@ struct IBIOSSettings
/* Start of struct IMachine Declaration */
-#define IMACHINE_IID_STR "540dcfda-3df2-49c6-88fa-033a28c2ff85"
-#define IMACHINE_IID { \
+# define IMACHINE_IID_STR "540dcfda-3df2-49c6-88fa-033a28c2ff85"
+# define IMACHINE_IID { \
0x540dcfda, 0x3df2, 0x49c6, \
{ 0x88, 0xfa, 0x03, 0x3a, 0x28, 0xc2, 0xff, 0x85 } \
}
@@ -2997,8 +2997,8 @@ struct IMachine
/* Start of struct IConsoleCallback Declaration */
-#define ICONSOLECALLBACK_IID_STR "13dfbef3-b74d-487d-bada-2304529aefa6"
-#define ICONSOLECALLBACK_IID { \
+# define ICONSOLECALLBACK_IID_STR "13dfbef3-b74d-487d-bada-2304529aefa6"
+# define ICONSOLECALLBACK_IID { \
0x13dfbef3, 0xb74d, 0x487d, \
{ 0xba, 0xda, 0x23, 0x04, 0x52, 0x9a, 0xef, 0xa6 } \
}
@@ -3101,8 +3101,8 @@ struct IConsoleCallback
/* Start of struct IRemoteDisplayInfo Declaration */
-#define IREMOTEDISPLAYINFO_IID_STR "550104cd-2dfd-4a6c-857d-f6f8e088e62c"
-#define IREMOTEDISPLAYINFO_IID { \
+# define IREMOTEDISPLAYINFO_IID_STR "550104cd-2dfd-4a6c-857d-f6f8e088e62c"
+# define IREMOTEDISPLAYINFO_IID { \
0x550104cd, 0x2dfd, 0x4a6c, \
{ 0x85, 0x7d, 0xf6, 0xf8, 0xe0, 0x88, 0xe6, 0x2c } \
}
@@ -3148,8 +3148,8 @@ struct IRemoteDisplayInfo
/* Start of struct IConsole Declaration */
-#define ICONSOLE_IID_STR "0a51994b-cbc6-4686-94eb-d4e4023280e2"
-#define ICONSOLE_IID { \
+# define ICONSOLE_IID_STR "0a51994b-cbc6-4686-94eb-d4e4023280e2"
+# define ICONSOLE_IID { \
0x0a51994b, 0xcbc6, 0x4686, \
{ 0x94, 0xeb, 0xd4, 0xe4, 0x02, 0x32, 0x80, 0xe2 } \
}
@@ -3313,8 +3313,8 @@ struct IConsole
/* Start of struct IHostDVDDrive Declaration */
-#define IHOSTDVDDRIVE_IID_STR "21f86694-202d-4ce4-8b05-a63ff82dbf4c"
-#define IHOSTDVDDRIVE_IID { \
+# define IHOSTDVDDRIVE_IID_STR "21f86694-202d-4ce4-8b05-a63ff82dbf4c"
+# define IHOSTDVDDRIVE_IID { \
0x21f86694, 0x202d, 0x4ce4, \
{ 0x8b, 0x05, 0xa6, 0x3f, 0xf8, 0x2d, 0xbf, 0x4c } \
}
@@ -3338,8 +3338,8 @@ struct IHostDVDDrive
/* Start of struct IHostFloppyDrive Declaration */
-#define IHOSTFLOPPYDRIVE_IID_STR "3f02d604-e908-4919-9fd1-8a4afd68fc63"
-#define IHOSTFLOPPYDRIVE_IID { \
+# define IHOSTFLOPPYDRIVE_IID_STR "3f02d604-e908-4919-9fd1-8a4afd68fc63"
+# define IHOSTFLOPPYDRIVE_IID { \
0x3f02d604, 0xe908, 0x4919, \
{ 0x9f, 0xd1, 0x8a, 0x4a, 0xfd, 0x68, 0xfc, 0x63 } \
}
@@ -3363,8 +3363,8 @@ struct IHostFloppyDrive
/* Start of struct IHostNetworkInterface Declaration */
-#define IHOSTNETWORKINTERFACE_IID_STR "ce6fae58-7642-4102-b5db-c9005c2320a8"
-#define IHOSTNETWORKINTERFACE_IID { \
+# define IHOSTNETWORKINTERFACE_IID_STR "ce6fae58-7642-4102-b5db-c9005c2320a8"
+# define IHOSTNETWORKINTERFACE_IID { \
0xce6fae58, 0x7642, 0x4102, \
{ 0xb5, 0xdb, 0xc9, 0x00, 0x5c, 0x23, 0x20, 0xa8 } \
}
@@ -3424,8 +3424,8 @@ struct IHostNetworkInterface
/* Start of struct IHost Declaration */
-#define IHOST_IID_STR "a13b5556-5c0b-4f80-9df6-6f804f3336a1"
-#define IHOST_IID { \
+# define IHOST_IID_STR "a13b5556-5c0b-4f80-9df6-6f804f3336a1"
+# define IHOST_IID { \
0xa13b5556, 0x5c0b, 0x4f80, \
{ 0x9d, 0xf6, 0x6f, 0x80, 0x4f, 0x33, 0x36, 0xa1 } \
}
@@ -3561,8 +3561,8 @@ struct IHost
/* Start of struct ISystemProperties Declaration */
-#define ISYSTEMPROPERTIES_IID_STR "9ca0f712-83f3-4631-b143-b75ef6568332"
-#define ISYSTEMPROPERTIES_IID { \
+# define ISYSTEMPROPERTIES_IID_STR "9ca0f712-83f3-4631-b143-b75ef6568332"
+# define ISYSTEMPROPERTIES_IID { \
0x9ca0f712, 0x83f3, 0x4631, \
{ 0xb1, 0x43, 0xb7, 0x5e, 0xf6, 0x56, 0x83, 0x32 } \
}
@@ -3624,8 +3624,8 @@ struct ISystemProperties
/* Start of struct IGuestOSType Declaration */
-#define IGUESTOSTYPE_IID_STR "cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
-#define IGUESTOSTYPE_IID { \
+# define IGUESTOSTYPE_IID_STR "cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
+# define IGUESTOSTYPE_IID { \
0xcfe9e64c, 0x4430, 0x435b, \
{ 0x9e, 0x7c, 0xe3, 0xd8, 0xe4, 0x17, 0xbd, 0x58 } \
}
@@ -3665,8 +3665,8 @@ struct IGuestOSType
/* Start of struct IGuest Declaration */
-#define IGUEST_IID_STR "d8556fca-81bc-12af-fca3-365528fa38ca"
-#define IGUEST_IID { \
+# define IGUEST_IID_STR "d8556fca-81bc-12af-fca3-365528fa38ca"
+# define IGUEST_IID { \
0xd8556fca, 0x81bc, 0x12af, \
{ 0xfc, 0xa3, 0x36, 0x55, 0x28, 0xfa, 0x38, 0xca } \
}
@@ -3715,8 +3715,8 @@ struct IGuest
/* Start of struct IProgress Declaration */
-#define IPROGRESS_IID_STR "6fcd0198-7fc5-4c53-8c37-653ac76854b5"
-#define IPROGRESS_IID { \
+# define IPROGRESS_IID_STR "6fcd0198-7fc5-4c53-8c37-653ac76854b5"
+# define IPROGRESS_IID { \
0x6fcd0198, 0x7fc5, 0x4c53, \
{ 0x8c, 0x37, 0x65, 0x3a, 0xc7, 0x68, 0x54, 0xb5 } \
}
@@ -3775,8 +3775,8 @@ struct IProgress
/* Start of struct ISnapshot Declaration */
-#define ISNAPSHOT_IID_STR "1a2d0551-58a4-4107-857e-ef414fc42ffc"
-#define ISNAPSHOT_IID { \
+# define ISNAPSHOT_IID_STR "1a2d0551-58a4-4107-857e-ef414fc42ffc"
+# define ISNAPSHOT_IID { \
0x1a2d0551, 0x58a4, 0x4107, \
{ 0x85, 0x7e, 0xef, 0x41, 0x4f, 0xc4, 0x2f, 0xfc } \
}
@@ -3812,8 +3812,8 @@ struct ISnapshot
/* Start of struct IMedium Declaration */
-#define IMEDIUM_IID_STR "f585787c-7728-40f6-853a-13705426e936"
-#define IMEDIUM_IID { \
+# define IMEDIUM_IID_STR "f585787c-7728-40f6-853a-13705426e936"
+# define IMEDIUM_IID { \
0xf585787c, 0x7728, 0x40f6, \
{ 0x85, 0x3a, 0x13, 0x70, 0x54, 0x26, 0xe9, 0x36 } \
}
@@ -3878,8 +3878,8 @@ struct IMedium
/* Start of struct IHardDiskAttachment Declaration */
-#define IHARDDISKATTACHMENT_IID_STR "b1dd04bb-93c0-4ad3-a9cf-82316e595836"
-#define IHARDDISKATTACHMENT_IID { \
+# define IHARDDISKATTACHMENT_IID_STR "b1dd04bb-93c0-4ad3-a9cf-82316e595836"
+# define IHARDDISKATTACHMENT_IID { \
0xb1dd04bb, 0x93c0, 0x4ad3, \
{ 0xa9, 0xcf, 0x82, 0x31, 0x6e, 0x59, 0x58, 0x36 } \
}
@@ -3905,8 +3905,8 @@ struct IHardDiskAttachment
/* Start of struct IHardDisk Declaration */
-#define IHARDDISK_IID_STR "62551115-83b8-4d20-925f-79e9d3c00f96"
-#define IHARDDISK_IID { \
+# define IHARDDISK_IID_STR "62551115-83b8-4d20-925f-79e9d3c00f96"
+# define IHARDDISK_IID { \
0x62551115, 0x83b8, 0x4d20, \
{ 0x92, 0x5f, 0x79, 0xe9, 0xd3, 0xc0, 0x0f, 0x96 } \
}
@@ -4014,8 +4014,8 @@ struct IHardDisk
/* Start of struct IHardDiskFormat Declaration */
-#define IHARDDISKFORMAT_IID_STR "7f3ba790-3a0b-4a8a-bac2-bb50150123c5"
-#define IHARDDISKFORMAT_IID { \
+# define IHARDDISKFORMAT_IID_STR "7f3ba790-3a0b-4a8a-bac2-bb50150123c5"
+# define IHARDDISKFORMAT_IID { \
0x7f3ba790, 0x3a0b, 0x4a8a, \
{ 0xba, 0xc2, 0xbb, 0x50, 0x15, 0x01, 0x23, 0xc5 } \
}
@@ -4055,8 +4055,8 @@ struct IHardDiskFormat
/* Start of struct IFloppyImage Declaration */
-#define IFLOPPYIMAGE_IID_STR "faa6101f-078c-4b3a-ab75-75670c8170b3"
-#define IFLOPPYIMAGE_IID { \
+# define IFLOPPYIMAGE_IID_STR "faa6101f-078c-4b3a-ab75-75670c8170b3"
+# define IFLOPPYIMAGE_IID { \
0xfaa6101f, 0x078c, 0x4b3a, \
{ 0xab, 0x75, 0x75, 0x67, 0x0c, 0x81, 0x70, 0xb3 } \
}
@@ -4074,8 +4074,8 @@ struct IFloppyImage
/* Start of struct IDVDImage Declaration */
-#define IDVDIMAGE_IID_STR "b1f90bbb-e8a9-4484-9af1-3638e943f763"
-#define IDVDIMAGE_IID { \
+# define IDVDIMAGE_IID_STR "b1f90bbb-e8a9-4484-9af1-3638e943f763"
+# define IDVDIMAGE_IID { \
0xb1f90bbb, 0xe8a9, 0x4484, \
{ 0x9a, 0xf1, 0x36, 0x38, 0xe9, 0x43, 0xf7, 0x63 } \
}
@@ -4093,8 +4093,8 @@ struct IDVDImage
/* Start of struct IDVDDrive Declaration */
-#define IDVDDRIVE_IID_STR "156944d1-4c6d-4812-8f12-ab3890767ab4"
-#define IDVDDRIVE_IID { \
+# define IDVDDRIVE_IID_STR "156944d1-4c6d-4812-8f12-ab3890767ab4"
+# define IDVDDRIVE_IID { \
0x156944d1, 0x4c6d, 0x4812, \
{ 0x8f, 0x12, 0xab, 0x38, 0x90, 0x76, 0x7a, 0xb4 } \
}
@@ -4139,8 +4139,8 @@ struct IDVDDrive
/* Start of struct IFloppyDrive Declaration */
-#define IFLOPPYDRIVE_IID_STR "a8676d38-5cf0-4b53-85b1-aa693611ab86"
-#define IFLOPPYDRIVE_IID { \
+# define IFLOPPYDRIVE_IID_STR "a8676d38-5cf0-4b53-85b1-aa693611ab86"
+# define IFLOPPYDRIVE_IID { \
0xa8676d38, 0x5cf0, 0x4b53, \
{ 0x85, 0xb1, 0xaa, 0x69, 0x36, 0x11, 0xab, 0x86 } \
}
@@ -4185,8 +4185,8 @@ struct IFloppyDrive
/* Start of struct IKeyboard Declaration */
-#define IKEYBOARD_IID_STR "2d1a531b-4c6e-49cc-8af6-5c857b78b5d7"
-#define IKEYBOARD_IID { \
+# define IKEYBOARD_IID_STR "2d1a531b-4c6e-49cc-8af6-5c857b78b5d7"
+# define IKEYBOARD_IID { \
0x2d1a531b, 0x4c6e, 0x49cc, \
{ 0x8a, 0xf6, 0x5c, 0x85, 0x7b, 0x78, 0xb5, 0xd7 } \
}
@@ -4218,8 +4218,8 @@ struct IKeyboard
/* Start of struct IMouse Declaration */
-#define IMOUSE_IID_STR "FD443EC1-0006-4F5B-9282-D72760A66916"
-#define IMOUSE_IID { \
+# define IMOUSE_IID_STR "FD443EC1-0006-4F5B-9282-D72760A66916"
+# define IMOUSE_IID { \
0xFD443EC1, 0x0006, 0x4F5B, \
{ 0x92, 0x82, 0xD7, 0x27, 0x60, 0xA6, 0x69, 0x16 } \
}
@@ -4255,8 +4255,8 @@ struct IMouse
/* Start of struct IFramebuffer Declaration */
-#define IFRAMEBUFFER_IID_STR "b7ed347a-5765-40a0-ae1c-f543eb4ddeaf"
-#define IFRAMEBUFFER_IID { \
+# define IFRAMEBUFFER_IID_STR "b7ed347a-5765-40a0-ae1c-f543eb4ddeaf"
+# define IFRAMEBUFFER_IID { \
0xb7ed347a, 0x5765, 0x40a0, \
{ 0xae, 0x1c, 0xf5, 0x43, 0xeb, 0x4d, 0xde, 0xaf } \
}
@@ -4344,8 +4344,8 @@ struct IFramebuffer
/* Start of struct IFramebufferOverlay Declaration */
-#define IFRAMEBUFFEROVERLAY_IID_STR "0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47"
-#define IFRAMEBUFFEROVERLAY_IID { \
+# define IFRAMEBUFFEROVERLAY_IID_STR "0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47"
+# define IFRAMEBUFFEROVERLAY_IID { \
0x0bcc1c7e, 0xe415, 0x47d2, \
{ 0xbf, 0xdb, 0xe4, 0xc7, 0x05, 0xfb, 0x0f, 0x47 } \
}
@@ -4379,8 +4379,8 @@ struct IFramebufferOverlay
/* Start of struct IDisplay Declaration */
-#define IDISPLAY_IID_STR "26881797-bc98-444d-ac69-820633b93ec7"
-#define IDISPLAY_IID { \
+# define IDISPLAY_IID_STR "26881797-bc98-444d-ac69-820633b93ec7"
+# define IDISPLAY_IID { \
0x26881797, 0xbc98, 0x444d, \
{ 0xac, 0x69, 0x82, 0x06, 0x33, 0xb9, 0x3e, 0xc7 } \
}
@@ -4469,8 +4469,8 @@ struct IDisplay
/* Start of struct INetworkAdapter Declaration */
-#define INETWORKADAPTER_IID_STR "65607a27-2b73-4d43-b4cc-0ba2c817fbde"
-#define INETWORKADAPTER_IID { \
+# define INETWORKADAPTER_IID_STR "65607a27-2b73-4d43-b4cc-0ba2c817fbde"
+# define INETWORKADAPTER_IID { \
0x65607a27, 0x2b73, 0x4d43, \
{ 0xb4, 0xcc, 0x0b, 0xa2, 0xc8, 0x17, 0xfb, 0xde } \
}
@@ -4532,8 +4532,8 @@ struct INetworkAdapter
/* Start of struct ISerialPort Declaration */
-#define ISERIALPORT_IID_STR "937f6970-5103-4745-b78e-d28dcf1479a8"
-#define ISERIALPORT_IID { \
+# define ISERIALPORT_IID_STR "937f6970-5103-4745-b78e-d28dcf1479a8"
+# define ISERIALPORT_IID { \
0x937f6970, 0x5103, 0x4745, \
{ 0xb7, 0x8e, 0xd2, 0x8d, 0xcf, 0x14, 0x79, 0xa8 } \
}
@@ -4571,8 +4571,8 @@ struct ISerialPort
/* Start of struct IParallelPort Declaration */
-#define IPARALLELPORT_IID_STR "0c925f06-dd10-4b77-8de8-294d738c3214"
-#define IPARALLELPORT_IID { \
+# define IPARALLELPORT_IID_STR "0c925f06-dd10-4b77-8de8-294d738c3214"
+# define IPARALLELPORT_IID { \
0x0c925f06, 0xdd10, 0x4b77, \
{ 0x8d, 0xe8, 0x29, 0x4d, 0x73, 0x8c, 0x32, 0x14 } \
}
@@ -4604,8 +4604,8 @@ struct IParallelPort
/* Start of struct IMachineDebugger Declaration */
-#define IMACHINEDEBUGGER_IID_STR "b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
-#define IMACHINEDEBUGGER_IID { \
+# define IMACHINEDEBUGGER_IID_STR "b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
+# define IMACHINEDEBUGGER_IID { \
0xb0b2a2dd, 0x0627, 0x4502, \
{ 0x91, 0xc2, 0xdd, 0xc5, 0xe7, 0x76, 0x09, 0xe0 } \
}
@@ -4673,8 +4673,8 @@ struct IMachineDebugger
/* Start of struct IUSBController Declaration */
-#define IUSBCONTROLLER_IID_STR "238540fa-4b73-435a-a38e-4e1d9eab5c17"
-#define IUSBCONTROLLER_IID { \
+# define IUSBCONTROLLER_IID_STR "238540fa-4b73-435a-a38e-4e1d9eab5c17"
+# define IUSBCONTROLLER_IID { \
0x238540fa, 0x4b73, 0x435a, \
{ 0xa3, 0x8e, 0x4e, 0x1d, 0x9e, 0xab, 0x5c, 0x17 } \
}
@@ -4720,8 +4720,8 @@ struct IUSBController
/* Start of struct IUSBDevice Declaration */
-#define IUSBDEVICE_IID_STR "f8967b0b-4483-400f-92b5-8b675d98a85b"
-#define IUSBDEVICE_IID { \
+# define IUSBDEVICE_IID_STR "f8967b0b-4483-400f-92b5-8b675d98a85b"
+# define IUSBDEVICE_IID { \
0xf8967b0b, 0x4483, 0x400f, \
{ 0x92, 0xb5, 0x8b, 0x67, 0x5d, 0x98, 0xa8, 0x5b } \
}
@@ -4763,8 +4763,8 @@ struct IUSBDevice
/* Start of struct IUSBDeviceFilter Declaration */
-#define IUSBDEVICEFILTER_IID_STR "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
-#define IUSBDEVICEFILTER_IID { \
+# define IUSBDEVICEFILTER_IID_STR "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
+# define IUSBDEVICEFILTER_IID { \
0xd6831fb4, 0x1a94, 0x4c2c, \
{ 0x96, 0xef, 0x8d, 0x0d, 0x61, 0x92, 0x06, 0x6d } \
}
@@ -4815,8 +4815,8 @@ struct IUSBDeviceFilter
/* Start of struct IHostUSBDevice Declaration */
-#define IHOSTUSBDEVICE_IID_STR "173b4b44-d268-4334-a00d-b6521c9a740a"
-#define IHOSTUSBDEVICE_IID { \
+# define IHOSTUSBDEVICE_IID_STR "173b4b44-d268-4334-a00d-b6521c9a740a"
+# define IHOSTUSBDEVICE_IID { \
0x173b4b44, 0xd268, 0x4334, \
{ 0xa0, 0x0d, 0xb6, 0x52, 0x1c, 0x9a, 0x74, 0x0a } \
}
@@ -4836,8 +4836,8 @@ struct IHostUSBDevice
/* Start of struct IHostUSBDeviceFilter Declaration */
-#define IHOSTUSBDEVICEFILTER_IID_STR "4cc70246-d74a-400f-8222-3900489c0374"
-#define IHOSTUSBDEVICEFILTER_IID { \
+# define IHOSTUSBDEVICEFILTER_IID_STR "4cc70246-d74a-400f-8222-3900489c0374"
+# define IHOSTUSBDEVICEFILTER_IID { \
0x4cc70246, 0xd74a, 0x400f, \
{ 0x82, 0x22, 0x39, 0x00, 0x48, 0x9c, 0x03, 0x74 } \
}
@@ -4858,8 +4858,8 @@ struct IHostUSBDeviceFilter
/* Start of struct IAudioAdapter Declaration */
-#define IAUDIOADAPTER_IID_STR "921873db-5f3f-4b69-91f9-7be9e535a2cb"
-#define IAUDIOADAPTER_IID { \
+# define IAUDIOADAPTER_IID_STR "921873db-5f3f-4b69-91f9-7be9e535a2cb"
+# define IAUDIOADAPTER_IID { \
0x921873db, 0x5f3f, 0x4b69, \
{ 0x91, 0xf9, 0x7b, 0xe9, 0xe5, 0x35, 0xa2, 0xcb } \
}
@@ -4886,8 +4886,8 @@ struct IAudioAdapter
/* Start of struct IVRDPServer Declaration */
-#define IVRDPSERVER_IID_STR "f4584ae7-6bce-474b-83d6-17d235e6aa89"
-#define IVRDPSERVER_IID { \
+# define IVRDPSERVER_IID_STR "f4584ae7-6bce-474b-83d6-17d235e6aa89"
+# define IVRDPSERVER_IID { \
0xf4584ae7, 0x6bce, 0x474b, \
{ 0x83, 0xd6, 0x17, 0xd2, 0x35, 0xe6, 0xaa, 0x89 } \
}
@@ -4926,8 +4926,8 @@ struct IVRDPServer
/* Start of struct ISharedFolder Declaration */
-#define ISHAREDFOLDER_IID_STR "64637bb2-9e17-471c-b8f3-f8968dd9884e"
-#define ISHAREDFOLDER_IID { \
+# define ISHAREDFOLDER_IID_STR "64637bb2-9e17-471c-b8f3-f8968dd9884e"
+# define ISHAREDFOLDER_IID { \
0x64637bb2, 0x9e17, 0x471c, \
{ 0xb8, 0xf3, 0xf8, 0x96, 0x8d, 0xd9, 0x88, 0x4e } \
}
@@ -4955,8 +4955,8 @@ struct ISharedFolder
/* Start of struct IInternalSessionControl Declaration */
-#define IINTERNALSESSIONCONTROL_IID_STR "b26552e7-9534-4f47-b766-98eac648a90d"
-#define IINTERNALSESSIONCONTROL_IID { \
+# define IINTERNALSESSIONCONTROL_IID_STR "b26552e7-9534-4f47-b766-98eac648a90d"
+# define IINTERNALSESSIONCONTROL_IID { \
0xb26552e7, 0x9534, 0x4f47, \
{ 0xb7, 0x66, 0x98, 0xea, 0xc6, 0x48, 0xa9, 0x0d } \
}
@@ -5076,8 +5076,8 @@ struct IInternalSessionControl
/* Start of struct ISession Declaration */
-#define ISESSION_IID_STR "12F4DCDB-12B2-4EC1-B7CD-DDD9F6C5BF4D"
-#define ISESSION_IID { \
+# define ISESSION_IID_STR "12F4DCDB-12B2-4EC1-B7CD-DDD9F6C5BF4D"
+# define ISESSION_IID { \
0x12F4DCDB, 0x12B2, 0x4EC1, \
{ 0xB7, 0xCD, 0xDD, 0xD9, 0xF6, 0xC5, 0xBF, 0x4D } \
}
@@ -5105,8 +5105,8 @@ struct ISession
/* Start of struct IStorageController Declaration */
-#define ISTORAGECONTROLLER_IID_STR "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
-#define ISTORAGECONTROLLER_IID { \
+# define ISTORAGECONTROLLER_IID_STR "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
+# define ISTORAGECONTROLLER_IID { \
0x6bf8335b, 0xd14a, 0x44a5, \
{ 0x9b, 0x45, 0xdd, 0xc4, 0x9c, 0xe7, 0xd5, 0xb2 } \
}
@@ -5155,8 +5155,8 @@ struct IStorageController
/* Start of struct IPerformanceMetric Declaration */
-#define IPERFORMANCEMETRIC_IID_STR "2a1a60ae-9345-4019-ad53-d34ba41cbfe9"
-#define IPERFORMANCEMETRIC_IID { \
+# define IPERFORMANCEMETRIC_IID_STR "2a1a60ae-9345-4019-ad53-d34ba41cbfe9"
+# define IPERFORMANCEMETRIC_IID { \
0x2a1a60ae, 0x9345, 0x4019, \
{ 0xad, 0x53, 0xd3, 0x4b, 0xa4, 0x1c, 0xbf, 0xe9 } \
}
@@ -5190,8 +5190,8 @@ struct IPerformanceMetric
/* Start of struct IPerformanceCollector Declaration */
-#define IPERFORMANCECOLLECTOR_IID_STR "e22e1acb-ac4a-43bb-a31c-17321659b0c6"
-#define IPERFORMANCECOLLECTOR_IID { \
+# define IPERFORMANCECOLLECTOR_IID_STR "e22e1acb-ac4a-43bb-a31c-17321659b0c6"
+# define IPERFORMANCECOLLECTOR_IID { \
0xe22e1acb, 0xac4a, 0x43bb, \
{ 0xa3, 0x1c, 0x17, 0x32, 0x16, 0x59, 0xb0, 0xc6 } \
}
@@ -5277,47 +5277,47 @@ struct IPerformanceCollector
-#define NS_VIRTUALBOX_CID { \
+# define NS_VIRTUALBOX_CID { \
0xB1A7A4F2, 0x47B9, 0x4A1E, \
{ 0x82, 0xB2, 0x07, 0xCC, 0xD5, 0x32, 0x3C, 0x3F } \
}
-#define NS_VIRTUALBOX_CONTRACTID "@virtualbox.org/VirtualBox;1"
+# define NS_VIRTUALBOX_CONTRACTID "@virtualbox.org/VirtualBox;1"
/* for compatibility with Win32 */
-#define CLSID_VirtualBox (nsCID) NS_VIRTUALBOX_CID
+# define CLSID_VirtualBox (nsCID) NS_VIRTUALBOX_CID
-#define NS_SESSION_CID { \
+# define NS_SESSION_CID { \
0x3C02F46D, 0xC9D2, 0x4F11, \
{ 0xA3, 0x84, 0x53, 0xF0, 0xCF, 0x91, 0x72, 0x14 } \
}
-#define NS_SESSION_CONTRACTID "@virtualbox.org/Session;1"
+# define NS_SESSION_CONTRACTID "@virtualbox.org/Session;1"
/* for compatibility with Win32 */
-#define CLSID_Session (nsCID) NS_SESSION_CID
+# define CLSID_Session (nsCID) NS_SESSION_CID
-#define NS_CALLBACKWRAPPER_CID { \
+# define NS_CALLBACKWRAPPER_CID { \
0x49EE8561, 0x5563, 0x4715, \
{ 0xB1, 0x8C, 0xA4, 0xB1, 0xA4, 0x90, 0xDA, 0xFE } \
}
-#define NS_CALLBACKWRAPPER_CONTRACTID "@virtualbox.org/CallbackWrapper;1"
+# define NS_CALLBACKWRAPPER_CONTRACTID "@virtualbox.org/CallbackWrapper;1"
/* for compatibility with Win32 */
-#define CLSID_CallbackWrapper (nsCID) NS_CALLBACKWRAPPER_CID
+# define CLSID_CallbackWrapper (nsCID) NS_CALLBACKWRAPPER_CID
-#endif /* !__cplusplus */
+# endif /* !__cplusplus */
-#ifdef IN_VBOXXPCOMC
-# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
-#else
-# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
-#endif
+# ifdef IN_VBOXXPCOMC
+# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
+# else
+# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
/**
@@ -5357,22 +5357,22 @@ typedef VBOXXPCOMC const *PCVBOXXPCOM;
/** The current interface version.
* For use with VBoxGetXPCOMCFunctions and to be found in
* VBOXXPCOMC::uVersion. */
-#define VBOX_XPCOMC_VERSION 0x00020000U
+# define VBOX_XPCOMC_VERSION 0x00020000U
VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion);
/** Typedef for VBoxGetXPCOMCFunctions. */
typedef PCVBOXXPCOM (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion);
/** The symbol name of VBoxGetXPCOMCFunctions. */
-#if defined(__OS2__)
-# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
-#else
-# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
-#endif
+# if defined(__OS2__)
+# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
+# else
+# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* !___VirtualBox_CXPCOM_h */
diff --git a/src/vbox/vbox_CAPI_v3_1.h b/src/vbox/vbox_CAPI_v3_1.h
index 2df9da8..f957f4b 100644
--- a/src/vbox/vbox_CAPI_v3_1.h
+++ b/src/vbox/vbox_CAPI_v3_1.h
@@ -43,193 +43,193 @@
*/
#ifndef ___VirtualBox_CXPCOM_h
-#define ___VirtualBox_CXPCOM_h
+# define ___VirtualBox_CXPCOM_h
-#ifdef __cplusplus
-# include "VirtualBox_XPCOM.h"
-#else /* !__cplusplus */
+# ifdef __cplusplus
+# include "VirtualBox_XPCOM.h"
+# else /* !__cplusplus */
-#include <stddef.h>
-#include "wchar.h"
+# include <stddef.h>
+# include "wchar.h"
-#if defined(WIN32)
+# if defined(WIN32)
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) __declspec(dllimport) __type
-#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) __declspec(dllimport) __type
+# define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
-#elif defined(XP_BEOS)
+# elif defined(XP_BEOS)
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(WIN16)
-
-#define PR_CALLBACK_DECL __cdecl
-
-#if defined(_WINDLL)
-#define PR_EXPORT(__type) extern __type _cdecl _export _loadds
-#define PR_IMPORT(__type) extern __type _cdecl _export _loadds
-#define PR_EXPORT_DATA(__type) extern __type _export
-#define PR_IMPORT_DATA(__type) extern __type _export
-
-#define PR_EXTERN(__type) extern __type _cdecl _export _loadds
-#define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
-#define PR_EXTERN_DATA(__type) extern __type _export
-#define PR_IMPLEMENT_DATA(__type) __type _export
-
-#define PR_CALLBACK __cdecl __loadds
-#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
-
-#else /* this must be .EXE */
-#define PR_EXPORT(__type) extern __type _cdecl _export
-#define PR_IMPORT(__type) extern __type _cdecl _export
-#define PR_EXPORT_DATA(__type) extern __type _export
-#define PR_IMPORT_DATA(__type) extern __type _export
-
-#define PR_EXTERN(__type) extern __type _cdecl _export
-#define PR_IMPLEMENT(__type) __type _cdecl _export
-#define PR_EXTERN_DATA(__type) extern __type _export
-#define PR_IMPLEMENT_DATA(__type) __type _export
-
-#define PR_CALLBACK __cdecl __loadds
-#define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
-#endif /* _WINDLL */
-
-#elif defined(XP_MAC)
-
-#define PR_EXPORT(__type) extern __declspec(export) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(export) __type
-#define PR_IMPORT(__type) extern __declspec(export) __type
-#define PR_IMPORT_DATA(__type) extern __declspec(export) __type
-
-#define PR_EXTERN(__type) extern __declspec(export) __type
-#define PR_IMPLEMENT(__type) __declspec(export) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(export) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(XP_OS2) && defined(__declspec)
-
-#define PR_EXPORT(__type) extern __declspec(dllexport) __type
-#define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPORT(__type) __declspec(dllimport) __type
-#define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
-
-#define PR_EXTERN(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT(__type) __declspec(dllexport) __type
-#define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
-#define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
-
-#define PR_CALLBACK
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x
-
-#elif defined(XP_OS2_VACPP)
-
-#define PR_EXPORT(__type) extern __type
-#define PR_EXPORT_DATA(__type) extern __type
-#define PR_IMPORT(__type) extern __type
-#define PR_IMPORT_DATA(__type) extern __type
-
-#define PR_EXTERN(__type) extern __type
-#define PR_IMPLEMENT(__type) __type
-#define PR_EXTERN_DATA(__type) extern __type
-#define PR_IMPLEMENT_DATA(__type) __type
-#define PR_CALLBACK _Optlink
-#define PR_CALLBACK_DECL
-#define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
-
-#else /* Unix */
-
-# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
-# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
-# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPORT(__type) extern __type
-# define PR_IMPORT_DATA(__type) extern __type
-# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
-# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
-# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
-# define PR_CALLBACK
-# define PR_CALLBACK_DECL
-# define PR_STATIC_CALLBACK(__x) static __x
-# else
-# define PR_EXPORT(__type) extern __type
-# define PR_EXPORT_DATA(__type) extern __type
-# define PR_IMPORT(__type) extern __type
-# define PR_IMPORT_DATA(__type) extern __type
-# define PR_EXTERN(__type) extern __type
-# define PR_IMPLEMENT(__type) __type
-# define PR_EXTERN_DATA(__type) extern __type
-# define PR_IMPLEMENT_DATA(__type) __type
-# define PR_CALLBACK
-# define PR_CALLBACK_DECL
-# define PR_STATIC_CALLBACK(__x) static __x
-# endif
-#endif
-
-#if defined(_NSPR_BUILD_)
-#define NSPR_API(__type) PR_EXPORT(__type)
-#define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
-#else
-#define NSPR_API(__type) PR_IMPORT(__type)
-#define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
-#endif
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT_DATA(__type) extern __declspec(dllexport) __type
+
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(WIN16)
+
+# define PR_CALLBACK_DECL __cdecl
+
+# if defined(_WINDLL)
+# define PR_EXPORT(__type) extern __type _cdecl _export _loadds
+# define PR_IMPORT(__type) extern __type _cdecl _export _loadds
+# define PR_EXPORT_DATA(__type) extern __type _export
+# define PR_IMPORT_DATA(__type) extern __type _export
+
+# define PR_EXTERN(__type) extern __type _cdecl _export _loadds
+# define PR_IMPLEMENT(__type) __type _cdecl _export _loadds
+# define PR_EXTERN_DATA(__type) extern __type _export
+# define PR_IMPLEMENT_DATA(__type) __type _export
+
+# define PR_CALLBACK __cdecl __loadds
+# define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
+# else /* this must be .EXE */
+# define PR_EXPORT(__type) extern __type _cdecl _export
+# define PR_IMPORT(__type) extern __type _cdecl _export
+# define PR_EXPORT_DATA(__type) extern __type _export
+# define PR_IMPORT_DATA(__type) extern __type _export
+
+# define PR_EXTERN(__type) extern __type _cdecl _export
+# define PR_IMPLEMENT(__type) __type _cdecl _export
+# define PR_EXTERN_DATA(__type) extern __type _export
+# define PR_IMPLEMENT_DATA(__type) __type _export
+
+# define PR_CALLBACK __cdecl __loadds
+# define PR_STATIC_CALLBACK(__x) __x PR_CALLBACK
+# endif /* _WINDLL */
+
+# elif defined(XP_MAC)
+
+# define PR_EXPORT(__type) extern __declspec(export) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(export) __type
+# define PR_IMPORT(__type) extern __declspec(export) __type
+# define PR_IMPORT_DATA(__type) extern __declspec(export) __type
+
+# define PR_EXTERN(__type) extern __declspec(export) __type
+# define PR_IMPLEMENT(__type) __declspec(export) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(export) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(export) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(XP_OS2) && defined(__declspec)
+
+# define PR_EXPORT(__type) extern __declspec(dllexport) __type
+# define PR_EXPORT_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPORT(__type) __declspec(dllimport) __type
+# define PR_IMPORT_DATA(__type) __declspec(dllimport) __type
+
+# define PR_EXTERN(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT(__type) __declspec(dllexport) __type
+# define PR_EXTERN_DATA(__type) extern __declspec(dllexport) __type
+# define PR_IMPLEMENT_DATA(__type) __declspec(dllexport) __type
+
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+
+# elif defined(XP_OS2_VACPP)
+
+# define PR_EXPORT(__type) extern __type
+# define PR_EXPORT_DATA(__type) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+
+# define PR_EXTERN(__type) extern __type
+# define PR_IMPLEMENT(__type) __type
+# define PR_EXTERN_DATA(__type) extern __type
+# define PR_IMPLEMENT_DATA(__type) __type
+# define PR_CALLBACK _Optlink
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x PR_CALLBACK
+
+# else /* Unix */
+
+# ifdef VBOX_HAVE_VISIBILITY_HIDDEN
+# define PR_EXPORT(__type) __attribute__((visibility("default"))) extern __type
+# define PR_EXPORT_DATA(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+# define PR_EXTERN(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPLEMENT(__type) __attribute__((visibility("default"))) __type
+# define PR_EXTERN_DATA(__type) __attribute__((visibility("default"))) extern __type
+# define PR_IMPLEMENT_DATA(__type) __attribute__((visibility("default"))) __type
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+# else
+# define PR_EXPORT(__type) extern __type
+# define PR_EXPORT_DATA(__type) extern __type
+# define PR_IMPORT(__type) extern __type
+# define PR_IMPORT_DATA(__type) extern __type
+# define PR_EXTERN(__type) extern __type
+# define PR_IMPLEMENT(__type) __type
+# define PR_EXTERN_DATA(__type) extern __type
+# define PR_IMPLEMENT_DATA(__type) __type
+# define PR_CALLBACK
+# define PR_CALLBACK_DECL
+# define PR_STATIC_CALLBACK(__x) static __x
+# endif
+# endif
+
+# if defined(_NSPR_BUILD_)
+# define NSPR_API(__type) PR_EXPORT(__type)
+# define NSPR_DATA_API(__type) PR_EXPORT_DATA(__type)
+# else
+# define NSPR_API(__type) PR_IMPORT(__type)
+# define NSPR_DATA_API(__type) PR_IMPORT_DATA(__type)
+# endif
typedef unsigned char PRUint8;
-#if (defined(HPUX) && defined(__cplusplus) \
+# if (defined(HPUX) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus < 199707L) \
|| (defined(SCO) && defined(__cplusplus) \
&& !defined(__GNUC__) && __cplusplus == 1L)
typedef char PRInt8;
-#else
+# else
typedef signed char PRInt8;
-#endif
+# endif
-#define PR_INT8_MAX 127
-#define PR_INT8_MIN (-128)
-#define PR_UINT8_MAX 255U
+# define PR_INT8_MAX 127
+# define PR_INT8_MIN (-128)
+# define PR_UINT8_MAX 255U
typedef unsigned short PRUint16;
typedef short PRInt16;
-#define PR_INT16_MAX 32767
-#define PR_INT16_MIN (-32768)
-#define PR_UINT16_MAX 65535U
+# define PR_INT16_MAX 32767
+# define PR_INT16_MIN (-32768)
+# define PR_UINT16_MAX 65535U
typedef unsigned int PRUint32;
typedef int PRInt32;
-#define PR_INT32(x) x
-#define PR_UINT32(x) x ## U
+# define PR_INT32(x) x
+# define PR_UINT32(x) x ## U
-#define PR_INT32_MAX PR_INT32(2147483647)
-#define PR_INT32_MIN (-PR_INT32_MAX - 1)
-#define PR_UINT32_MAX PR_UINT32(4294967295)
+# define PR_INT32_MAX PR_INT32(2147483647)
+# define PR_INT32_MIN (-PR_INT32_MAX - 1)
+# define PR_UINT32_MAX PR_UINT32(4294967295)
typedef long PRInt64;
typedef unsigned long PRUint64;
@@ -245,8 +245,8 @@ typedef unsigned long PRUptrdiff;
typedef PRIntn PRBool;
-#define PR_TRUE 1
-#define PR_FALSE 0
+# define PR_TRUE 1
+# define PR_FALSE 0
typedef PRUint8 PRPackedBool;
@@ -256,56 +256,56 @@ typedef PRUint8 PRPackedBool;
*/
typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
-#ifndef __PRUNICHAR__
-#define __PRUNICHAR__
-#if defined(WIN32) || defined(XP_MAC)
+# ifndef __PRUNICHAR__
+# define __PRUNICHAR__
+# if defined(WIN32) || defined(XP_MAC)
typedef wchar_t PRUnichar;
-#else
+# else
typedef PRUint16 PRUnichar;
-#endif
-#endif
+# endif
+# endif
typedef long PRWord;
typedef unsigned long PRUword;
-#define nsnull 0
+# define nsnull 0
typedef PRUint32 nsresult;
-#if defined(__GNUC__) && (__GNUC__ > 2)
-#define NS_LIKELY(x) (__builtin_expect((x), 1))
-#define NS_UNLIKELY(x) (__builtin_expect((x), 0))
-#else
-#define NS_LIKELY(x) (x)
-#define NS_UNLIKELY(x) (x)
-#endif
-
-#define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
-#define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
-
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_IntervalNow VBoxNsprPR_IntervalNow
-# define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
-# define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
-# define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
-# define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
-# define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
-# define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
-# define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
-# define PR_EnterMonitor VBoxNsprPR_EnterMonitor
-# define PR_ExitMonitor VBoxNsprPR_ExitMonitor
-# define PR_Notify VBoxNsprPR_Notify
-# define PR_NotifyAll VBoxNsprPR_NotifyAll
-# define PR_Wait VBoxNsprPR_Wait
-# define PR_NewMonitor VBoxNsprPR_NewMonitor
-# define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# if defined(__GNUC__) && (__GNUC__ > 2)
+# define NS_LIKELY(x) (__builtin_expect((x), 1))
+# define NS_UNLIKELY(x) (__builtin_expect((x), 0))
+# else
+# define NS_LIKELY(x) (x)
+# define NS_UNLIKELY(x) (x)
+# endif
+
+# define NS_FAILED(_nsresult) (NS_UNLIKELY((_nsresult) & 0x80000000))
+# define NS_SUCCEEDED(_nsresult) (NS_LIKELY(!((_nsresult) & 0x80000000)))
+
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_IntervalNow VBoxNsprPR_IntervalNow
+# define PR_TicksPerSecond VBoxNsprPR_TicksPerSecond
+# define PR_SecondsToInterval VBoxNsprPR_SecondsToInterval
+# define PR_MillisecondsToInterval VBoxNsprPR_MillisecondsToInterval
+# define PR_MicrosecondsToInterval VBoxNsprPR_MicrosecondsToInterval
+# define PR_IntervalToSeconds VBoxNsprPR_IntervalToSeconds
+# define PR_IntervalToMilliseconds VBoxNsprPR_IntervalToMilliseconds
+# define PR_IntervalToMicroseconds VBoxNsprPR_IntervalToMicroseconds
+# define PR_EnterMonitor VBoxNsprPR_EnterMonitor
+# define PR_ExitMonitor VBoxNsprPR_ExitMonitor
+# define PR_Notify VBoxNsprPR_Notify
+# define PR_NotifyAll VBoxNsprPR_NotifyAll
+# define PR_Wait VBoxNsprPR_Wait
+# define PR_NewMonitor VBoxNsprPR_NewMonitor
+# define PR_DestroyMonitor VBoxNsprPR_DestroyMonitor
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef PRUint32 PRIntervalTime;
-#define PR_INTERVAL_MIN 1000UL
-#define PR_INTERVAL_MAX 100000UL
-#define PR_INTERVAL_NO_WAIT 0UL
-#define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
+# define PR_INTERVAL_MIN 1000UL
+# define PR_INTERVAL_MAX 100000UL
+# define PR_INTERVAL_NO_WAIT 0UL
+# define PR_INTERVAL_NO_TIMEOUT 0xffffffffUL
NSPR_API(PRIntervalTime) PR_IntervalNow(void);
NSPR_API(PRUint32) PR_TicksPerSecond(void);
@@ -326,24 +326,24 @@ NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);
NSPR_API(PRStatus) PR_Notify(PRMonitor *mon);
NSPR_API(PRStatus) PR_NotifyAll(PRMonitor *mon);
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_CreateThread VBoxNsprPR_CreateThread
-# define PR_JoinThread VBoxNsprPR_JoinThread
-# define PR_Sleep VBoxNsprPR_Sleep
-# define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
-# define PR_GetThreadState VBoxNsprPR_GetThreadState
-# define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
-# define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
-# define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
-# define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
-# define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
-# define PR_Interrupt VBoxNsprPR_Interrupt
-# define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
-# define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
-# define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
-# define PR_GetThreadScope VBoxNsprPR_GetThreadScope
-# define PR_GetThreadType VBoxNsprPR_GetThreadType
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_CreateThread VBoxNsprPR_CreateThread
+# define PR_JoinThread VBoxNsprPR_JoinThread
+# define PR_Sleep VBoxNsprPR_Sleep
+# define PR_GetCurrentThread VBoxNsprPR_GetCurrentThread
+# define PR_GetThreadState VBoxNsprPR_GetThreadState
+# define PR_SetThreadPrivate VBoxNsprPR_SetThreadPrivate
+# define PR_GetThreadPrivate VBoxNsprPR_GetThreadPrivate
+# define PR_NewThreadPrivateIndex VBoxNsprPR_NewThreadPrivateIndex
+# define PR_GetThreadPriority VBoxNsprPR_GetThreadPriority
+# define PR_SetThreadPriority VBoxNsprPR_SetThreadPriority
+# define PR_Interrupt VBoxNsprPR_Interrupt
+# define PR_ClearInterrupt VBoxNsprPR_ClearInterrupt
+# define PR_BlockInterrupt VBoxNsprPR_BlockInterrupt
+# define PR_UnblockInterrupt VBoxNsprPR_UnblockInterrupt
+# define PR_GetThreadScope VBoxNsprPR_GetThreadScope
+# define PR_GetThreadType VBoxNsprPR_GetThreadType
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PRThread PRThread;
typedef struct PRThreadStack PRThreadStack;
@@ -383,9 +383,9 @@ NSPR_API(PRThread*) PR_CreateThread(PRThreadType type,
PRUint32 stackSize);
NSPR_API(PRStatus) PR_JoinThread(PRThread *thread);
NSPR_API(PRThread*) PR_GetCurrentThread(void);
-#ifndef NO_NSPR_10_SUPPORT
-#define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
-#endif /* NO_NSPR_10_SUPPORT */
+# ifndef NO_NSPR_10_SUPPORT
+# define PR_CurrentThread() PR_GetCurrentThread() /* for nspr1.0 compat. */
+# endif /* NO_NSPR_10_SUPPORT */
NSPR_API(PRThreadPriority) PR_GetThreadPriority(const PRThread *thread);
NSPR_API(void) PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
@@ -404,12 +404,12 @@ NSPR_API(PRThreadScope) PR_GetThreadScope(const PRThread *thread);
NSPR_API(PRThreadType) PR_GetThreadType(const PRThread *thread);
NSPR_API(PRThreadState) PR_GetThreadState(const PRThread *thread);
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_DestroyLock VBoxNsprPR_DestroyLock
-# define PR_Lock VBoxNsprPR_Lock
-# define PR_NewLock VBoxNsprPR_NewLock
-# define PR_Unlock VBoxNsprPR_Unlock
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_DestroyLock VBoxNsprPR_DestroyLock
+# define PR_Lock VBoxNsprPR_Lock
+# define PR_NewLock VBoxNsprPR_NewLock
+# define PR_Unlock VBoxNsprPR_Unlock
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PRLock PRLock;
@@ -418,13 +418,13 @@ NSPR_API(void) PR_DestroyLock(PRLock *lock);
NSPR_API(void) PR_Lock(PRLock *lock);
NSPR_API(PRStatus) PR_Unlock(PRLock *lock);
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PR_NewCondVar VBoxNsprPR_NewCondVar
-# define PR_DestroyCondVar VBoxNsprPR_DestroyCondVar
-# define PR_WaitCondVar VBoxNsprPR_WaitCondVar
-# define PR_NotifyCondVar VBoxNsprPR_NotifyCondVar
-# define PR_NotifyAllCondVar VBoxNsprPR_NotifyAllCondVar
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PR_NewCondVar VBoxNsprPR_NewCondVar
+# define PR_DestroyCondVar VBoxNsprPR_DestroyCondVar
+# define PR_WaitCondVar VBoxNsprPR_WaitCondVar
+# define PR_NotifyCondVar VBoxNsprPR_NotifyCondVar
+# define PR_NotifyAllCondVar VBoxNsprPR_NotifyAllCondVar
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PRCondVar PRCondVar;
@@ -441,34 +441,34 @@ struct PRCListStr {
PRCList *prev;
};
-#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
-# define PL_DestroyEvent VBoxNsplPL_DestroyEvent
-# define PL_HandleEvent VBoxNsplPL_HandleEvent
-# define PL_InitEvent VBoxNsplPL_InitEvent
-# define PL_CreateEventQueue VBoxNsplPL_CreateEventQueue
-# define PL_CreateMonitoredEventQueue VBoxNsplPL_CreateMonitoredEventQueue
-# define PL_CreateNativeEventQueue VBoxNsplPL_CreateNativeEventQueue
-# define PL_DequeueEvent VBoxNsplPL_DequeueEvent
-# define PL_DestroyEventQueue VBoxNsplPL_DestroyEventQueue
-# define PL_EventAvailable VBoxNsplPL_EventAvailable
-# define PL_EventLoop VBoxNsplPL_EventLoop
-# define PL_GetEvent VBoxNsplPL_GetEvent
-# define PL_GetEventOwner VBoxNsplPL_GetEventOwner
-# define PL_GetEventQueueMonitor VBoxNsplPL_GetEventQueueMonitor
-# define PL_GetEventQueueSelectFD VBoxNsplPL_GetEventQueueSelectFD
-# define PL_MapEvents VBoxNsplPL_MapEvents
-# define PL_PostEvent VBoxNsplPL_PostEvent
-# define PL_PostSynchronousEvent VBoxNsplPL_PostSynchronousEvent
-# define PL_ProcessEventsBeforeID VBoxNsplPL_ProcessEventsBeforeID
-# define PL_ProcessPendingEvents VBoxNsplPL_ProcessPendingEvents
-# define PL_RegisterEventIDFunc VBoxNsplPL_RegisterEventIDFunc
-# define PL_RevokeEvents VBoxNsplPL_RevokeEvents
-# define PL_UnregisterEventIDFunc VBoxNsplPL_UnregisterEventIDFunc
-# define PL_WaitForEvent VBoxNsplPL_WaitForEvent
-# define PL_IsQueueNative VBoxNsplPL_IsQueueNative
-# define PL_IsQueueOnCurrentThread VBoxNsplPL_IsQueueOnCurrentThread
-# define PL_FavorPerformanceHint VBoxNsplPL_FavorPerformanceHint
-#endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
+# ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
+# define PL_DestroyEvent VBoxNsplPL_DestroyEvent
+# define PL_HandleEvent VBoxNsplPL_HandleEvent
+# define PL_InitEvent VBoxNsplPL_InitEvent
+# define PL_CreateEventQueue VBoxNsplPL_CreateEventQueue
+# define PL_CreateMonitoredEventQueue VBoxNsplPL_CreateMonitoredEventQueue
+# define PL_CreateNativeEventQueue VBoxNsplPL_CreateNativeEventQueue
+# define PL_DequeueEvent VBoxNsplPL_DequeueEvent
+# define PL_DestroyEventQueue VBoxNsplPL_DestroyEventQueue
+# define PL_EventAvailable VBoxNsplPL_EventAvailable
+# define PL_EventLoop VBoxNsplPL_EventLoop
+# define PL_GetEvent VBoxNsplPL_GetEvent
+# define PL_GetEventOwner VBoxNsplPL_GetEventOwner
+# define PL_GetEventQueueMonitor VBoxNsplPL_GetEventQueueMonitor
+# define PL_GetEventQueueSelectFD VBoxNsplPL_GetEventQueueSelectFD
+# define PL_MapEvents VBoxNsplPL_MapEvents
+# define PL_PostEvent VBoxNsplPL_PostEvent
+# define PL_PostSynchronousEvent VBoxNsplPL_PostSynchronousEvent
+# define PL_ProcessEventsBeforeID VBoxNsplPL_ProcessEventsBeforeID
+# define PL_ProcessPendingEvents VBoxNsplPL_ProcessPendingEvents
+# define PL_RegisterEventIDFunc VBoxNsplPL_RegisterEventIDFunc
+# define PL_RevokeEvents VBoxNsplPL_RevokeEvents
+# define PL_UnregisterEventIDFunc VBoxNsplPL_UnregisterEventIDFunc
+# define PL_WaitForEvent VBoxNsplPL_WaitForEvent
+# define PL_IsQueueNative VBoxNsplPL_IsQueueNative
+# define PL_IsQueueOnCurrentThread VBoxNsplPL_IsQueueOnCurrentThread
+# define PL_FavorPerformanceHint VBoxNsplPL_FavorPerformanceHint
+# endif /* VBOX_WITH_XPCOM_NAMESPACE_CLEANUP */
typedef struct PLEvent PLEvent;
typedef struct PLEventQueue PLEventQueue;
@@ -490,10 +490,10 @@ PL_DestroyEventQueue(PLEventQueue* self);
PR_EXTERN(PRMonitor*)
PL_GetEventQueueMonitor(PLEventQueue* self);
-#define PL_ENTER_EVENT_QUEUE_MONITOR(queue) \
+# define PL_ENTER_EVENT_QUEUE_MONITOR(queue) \
PR_EnterMonitor(PL_GetEventQueueMonitor(queue))
-#define PL_EXIT_EVENT_QUEUE_MONITOR(queue) \
+# define PL_EXIT_EVENT_QUEUE_MONITOR(queue) \
PR_ExitMonitor(PL_GetEventQueueMonitor(queue))
PR_EXTERN(PRStatus) PL_PostEvent(PLEventQueue* self, PLEvent* event);
@@ -533,24 +533,24 @@ struct PLEvent {
PRLock* lock;
PRCondVar* condVar;
PRBool handled;
-#ifdef PL_POST_TIMINGS
+# ifdef PL_POST_TIMINGS
PRIntervalTime postTime;
-#endif
-#ifdef XP_UNIX
+# endif
+# ifdef XP_UNIX
unsigned long id;
-#endif /* XP_UNIX */
+# endif /* XP_UNIX */
/* other fields follow... */
};
-#if defined(XP_WIN) || defined(XP_OS2)
+# if defined(XP_WIN) || defined(XP_OS2)
PR_EXTERN(HWND)
PL_GetNativeEventReceiverWindow(
PLEventQueue *eqp
);
-#endif /* XP_WIN || XP_OS2 */
+# endif /* XP_WIN || XP_OS2 */
-#ifdef XP_UNIX
+# ifdef XP_UNIX
PR_EXTERN(PRInt32)
PL_ProcessEventsBeforeID(PLEventQueue *aSelf, unsigned long aID);
@@ -562,66 +562,66 @@ PL_RegisterEventIDFunc(PLEventQueue *aSelf, PLGetEventIDFunc aFunc,
void *aClosure);
PR_EXTERN(void) PL_UnregisterEventIDFunc(PLEventQueue *aSelf);
-#endif /* XP_UNIX */
+# endif /* XP_UNIX */
/* Standard "it worked" return value */
-#define NS_OK 0
+# define NS_OK 0
-#define NS_ERROR_BASE ((nsresult) 0xC1F30000)
+# define NS_ERROR_BASE ((nsresult) 0xC1F30000)
/* Returned when an instance is not initialized */
-#define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
+# define NS_ERROR_NOT_INITIALIZED (NS_ERROR_BASE + 1)
/* Returned when an instance is already initialized */
-#define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
+# define NS_ERROR_ALREADY_INITIALIZED (NS_ERROR_BASE + 2)
/* Returned by a not implemented function */
-#define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
+# define NS_ERROR_NOT_IMPLEMENTED ((nsresult) 0x80004001L)
/* Returned when a given interface is not supported. */
-#define NS_NOINTERFACE ((nsresult) 0x80004002L)
-#define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
+# define NS_NOINTERFACE ((nsresult) 0x80004002L)
+# define NS_ERROR_NO_INTERFACE NS_NOINTERFACE
-#define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
-#define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
+# define NS_ERROR_INVALID_POINTER ((nsresult) 0x80004003L)
+# define NS_ERROR_NULL_POINTER NS_ERROR_INVALID_POINTER
/* Returned when a function aborts */
-#define NS_ERROR_ABORT ((nsresult) 0x80004004L)
+# define NS_ERROR_ABORT ((nsresult) 0x80004004L)
/* Returned when a function fails */
-#define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
+# define NS_ERROR_FAILURE ((nsresult) 0x80004005L)
/* Returned when an unexpected error occurs */
-#define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
+# define NS_ERROR_UNEXPECTED ((nsresult) 0x8000ffffL)
/* Returned when a memory allocation fails */
-#define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
+# define NS_ERROR_OUT_OF_MEMORY ((nsresult) 0x8007000eL)
/* Returned when an illegal value is passed */
-#define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
-#define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
+# define NS_ERROR_ILLEGAL_VALUE ((nsresult) 0x80070057L)
+# define NS_ERROR_INVALID_ARG NS_ERROR_ILLEGAL_VALUE
/* Returned when a class doesn't allow aggregation */
-#define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
+# define NS_ERROR_NO_AGGREGATION ((nsresult) 0x80040110L)
/* Returned when an operation can't complete due to an unavailable resource */
-#define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
+# define NS_ERROR_NOT_AVAILABLE ((nsresult) 0x80040111L)
/* Returned when a class is not registered */
-#define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
+# define NS_ERROR_FACTORY_NOT_REGISTERED ((nsresult) 0x80040154L)
/* Returned when a class cannot be registered, but may be tried again later */
-#define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
+# define NS_ERROR_FACTORY_REGISTER_AGAIN ((nsresult) 0x80040155L)
/* Returned when a dynamically loaded factory couldn't be found */
-#define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
+# define NS_ERROR_FACTORY_NOT_LOADED ((nsresult) 0x800401f8L)
/* Returned when a factory doesn't support signatures */
-#define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
+# define NS_ERROR_FACTORY_NO_SIGNATURE_SUPPORT \
(NS_ERROR_BASE + 0x101)
/* Returned when a factory already is registered */
-#define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
+# define NS_ERROR_FACTORY_EXISTS (NS_ERROR_BASE + 0x100)
/**
@@ -654,7 +654,7 @@ typedef struct nsIException nsIException; /* forward declaration */
* To maintain binary compatibility with COM's IUnknown, we define the IID
* of nsISupports to be the same as that of COM's IUnknown.
*/
-#define NS_ISUPPORTS_IID \
+# define NS_ISUPPORTS_IID \
{ 0x00000000, 0x0000, 0x0000, \
{0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
@@ -714,9 +714,9 @@ struct nsISupports {
};
/* starting interface: nsIException */
-#define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
+# define NS_IEXCEPTION_IID_STR "f3a8d3b4-c424-4edc-8bf6-8974c983ba78"
-#define NS_IEXCEPTION_IID \
+# define NS_IEXCEPTION_IID \
{0xf3a8d3b4, 0xc424, 0x4edc, \
{ 0x8b, 0xf6, 0x89, 0x74, 0xc9, 0x83, 0xba, 0x78 }}
@@ -761,9 +761,9 @@ struct nsIException {
};
/* starting interface: nsIStackFrame */
-#define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
+# define NS_ISTACKFRAME_IID_STR "91d82105-7c62-4f8b-9779-154277c0ee90"
-#define NS_ISTACKFRAME_IID \
+# define NS_ISTACKFRAME_IID \
{0x91d82105, 0x7c62, 0x4f8b, \
{ 0x97, 0x79, 0x15, 0x42, 0x77, 0xc0, 0xee, 0x90 }}
@@ -802,9 +802,9 @@ struct nsIStackFrame {
};
/* starting interface: nsIEventTarget */
-#define NS_IEVENTTARGET_IID_STR "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"
+# define NS_IEVENTTARGET_IID_STR "ea99ad5b-cc67-4efb-97c9-2ef620a59f2a"
-#define NS_IEVENTTARGET_IID \
+# define NS_IEVENTTARGET_IID \
{0xea99ad5b, 0xcc67, 0x4efb, \
{ 0x97, 0xc9, 0x2e, 0xf6, 0x20, 0xa5, 0x9f, 0x2a }}
@@ -826,9 +826,9 @@ struct nsIEventTarget {
};
/* starting interface: nsIEventQueue */
-#define NS_IEVENTQUEUE_IID_STR "176afb41-00a4-11d3-9f2a-00400553eef0"
+# define NS_IEVENTQUEUE_IID_STR "176afb41-00a4-11d3-9f2a-00400553eef0"
-#define NS_IEVENTQUEUE_IID \
+# define NS_IEVENTQUEUE_IID \
{0x176afb41, 0x00a4, 0x11d3, \
{ 0x9f, 0x2a, 0x00, 0x40, 0x05, 0x53, 0xee, 0xf0 }}
@@ -884,18 +884,18 @@ struct nsIEventQueue {
};
-#define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001
-#define VBOX_E_INVALID_VM_STATE 0x80BB0002
-#define VBOX_E_VM_ERROR 0x80BB0003
-#define VBOX_E_FILE_ERROR 0x80BB0004
-#define VBOX_E_IPRT_ERROR 0x80BB0005
-#define VBOX_E_PDM_ERROR 0x80BB0006
-#define VBOX_E_INVALID_OBJECT_STATE 0x80BB0007
-#define VBOX_E_HOST_ERROR 0x80BB0008
-#define VBOX_E_NOT_SUPPORTED 0x80BB0009
-#define VBOX_E_XML_ERROR 0x80BB000A
-#define VBOX_E_INVALID_SESSION_STATE 0x80BB000B
-#define VBOX_E_OBJECT_IN_USE 0x80BB000C
+# define VBOX_E_OBJECT_NOT_FOUND 0x80BB0001
+# define VBOX_E_INVALID_VM_STATE 0x80BB0002
+# define VBOX_E_VM_ERROR 0x80BB0003
+# define VBOX_E_FILE_ERROR 0x80BB0004
+# define VBOX_E_IPRT_ERROR 0x80BB0005
+# define VBOX_E_PDM_ERROR 0x80BB0006
+# define VBOX_E_INVALID_OBJECT_STATE 0x80BB0007
+# define VBOX_E_HOST_ERROR 0x80BB0008
+# define VBOX_E_NOT_SUPPORTED 0x80BB0009
+# define VBOX_E_XML_ERROR 0x80BB000A
+# define VBOX_E_INVALID_SESSION_STATE 0x80BB000B
+# define VBOX_E_OBJECT_IN_USE 0x80BB000C
struct IVirtualBoxErrorInfo;
@@ -997,8 +997,8 @@ typedef struct IPerformanceMetric IPerformanceMetric;
typedef struct IPerformanceCollector IPerformanceCollector;
/* Start of enum SettingsVersion Declaration */
-#define SETTINGSVERSION_IID_STR "52bd6f5f-1adb-4493-975d-581a9c4b803f"
-#define SETTINGSVERSION_IID { \
+# define SETTINGSVERSION_IID_STR "52bd6f5f-1adb-4493-975d-581a9c4b803f"
+# define SETTINGSVERSION_IID { \
0x52bd6f5f, 0x1adb, 0x4493, \
{ 0x97, 0x5d, 0x58, 0x1a, 0x9c, 0x4b, 0x80, 0x3f } \
}
@@ -1022,8 +1022,8 @@ enum SettingsVersion
/* Start of enum AccessMode Declaration */
-#define ACCESSMODE_IID_STR "1da0007c-ddf7-4be8-bcac-d84a1558785f"
-#define ACCESSMODE_IID { \
+# define ACCESSMODE_IID_STR "1da0007c-ddf7-4be8-bcac-d84a1558785f"
+# define ACCESSMODE_IID { \
0x1da0007c, 0xddf7, 0x4be8, \
{ 0xbc, 0xac, 0xd8, 0x4a, 0x15, 0x58, 0x78, 0x5f } \
}
@@ -1036,8 +1036,8 @@ enum AccessMode
/* Start of enum MachineState Declaration */
-#define MACHINESTATE_IID_STR "36518cf6-cdf0-4d0d-ad2a-5ee9c60c7494"
-#define MACHINESTATE_IID { \
+# define MACHINESTATE_IID_STR "36518cf6-cdf0-4d0d-ad2a-5ee9c60c7494"
+# define MACHINESTATE_IID { \
0x36518cf6, 0xcdf0, 0x4d0d, \
{ 0xad, 0x2a, 0x5e, 0xe9, 0xc6, 0x0c, 0x74, 0x94 } \
}
@@ -1071,8 +1071,8 @@ enum MachineState
/* Start of enum SessionState Declaration */
-#define SESSIONSTATE_IID_STR "cf2700c0-ea4b-47ae-9725-7810114b94d8"
-#define SESSIONSTATE_IID { \
+# define SESSIONSTATE_IID_STR "cf2700c0-ea4b-47ae-9725-7810114b94d8"
+# define SESSIONSTATE_IID { \
0xcf2700c0, 0xea4b, 0x47ae, \
{ 0x97, 0x25, 0x78, 0x10, 0x11, 0x4b, 0x94, 0xd8 } \
}
@@ -1088,8 +1088,8 @@ enum SessionState
/* Start of enum CpuPropertyType Declaration */
-#define CPUPROPERTYTYPE_IID_STR "af7bb668-eeb1-4404-b77f-a114b30c92d6"
-#define CPUPROPERTYTYPE_IID { \
+# define CPUPROPERTYTYPE_IID_STR "af7bb668-eeb1-4404-b77f-a114b30c92d6"
+# define CPUPROPERTYTYPE_IID { \
0xaf7bb668, 0xeeb1, 0x4404, \
{ 0xb7, 0x7f, 0xa1, 0x14, 0xb3, 0x0c, 0x92, 0xd6 } \
}
@@ -1103,8 +1103,8 @@ enum CpuPropertyType
/* Start of enum HWVirtExPropertyType Declaration */
-#define HWVIRTEXPROPERTYTYPE_IID_STR "ce81dfdd-d2b8-4a90-bbea-40ee8b7ffcee"
-#define HWVIRTEXPROPERTYTYPE_IID { \
+# define HWVIRTEXPROPERTYTYPE_IID_STR "ce81dfdd-d2b8-4a90-bbea-40ee8b7ffcee"
+# define HWVIRTEXPROPERTYTYPE_IID { \
0xce81dfdd, 0xd2b8, 0x4a90, \
{ 0xbb, 0xea, 0x40, 0xee, 0x8b, 0x7f, 0xfc, 0xee } \
}
@@ -1120,8 +1120,8 @@ enum HWVirtExPropertyType
/* Start of enum SessionType Declaration */
-#define SESSIONTYPE_IID_STR "A13C02CB-0C2C-421E-8317-AC0E8AAA153A"
-#define SESSIONTYPE_IID { \
+# define SESSIONTYPE_IID_STR "A13C02CB-0C2C-421E-8317-AC0E8AAA153A"
+# define SESSIONTYPE_IID { \
0xA13C02CB, 0x0C2C, 0x421E, \
{ 0x83, 0x17, 0xAC, 0x0E, 0x8A, 0xAA, 0x15, 0x3A } \
}
@@ -1136,8 +1136,8 @@ enum SessionType
/* Start of enum DeviceType Declaration */
-#define DEVICETYPE_IID_STR "6d9420f7-0b56-4636-99f9-7346f1b01e57"
-#define DEVICETYPE_IID { \
+# define DEVICETYPE_IID_STR "6d9420f7-0b56-4636-99f9-7346f1b01e57"
+# define DEVICETYPE_IID { \
0x6d9420f7, 0x0b56, 0x4636, \
{ 0x99, 0xf9, 0x73, 0x46, 0xf1, 0xb0, 0x1e, 0x57 } \
}
@@ -1155,8 +1155,8 @@ enum DeviceType
/* Start of enum DeviceActivity Declaration */
-#define DEVICEACTIVITY_IID_STR "6FC8AEAA-130A-4eb5-8954-3F921422D707"
-#define DEVICEACTIVITY_IID { \
+# define DEVICEACTIVITY_IID_STR "6FC8AEAA-130A-4eb5-8954-3F921422D707"
+# define DEVICEACTIVITY_IID { \
0x6FC8AEAA, 0x130A, 0x4eb5, \
{ 0x89, 0x54, 0x3F, 0x92, 0x14, 0x22, 0xD7, 0x07 } \
}
@@ -1171,8 +1171,8 @@ enum DeviceActivity
/* Start of enum ClipboardMode Declaration */
-#define CLIPBOARDMODE_IID_STR "33364716-4008-4701-8f14-be0fa3d62950"
-#define CLIPBOARDMODE_IID { \
+# define CLIPBOARDMODE_IID_STR "33364716-4008-4701-8f14-be0fa3d62950"
+# define CLIPBOARDMODE_IID { \
0x33364716, 0x4008, 0x4701, \
{ 0x8f, 0x14, 0xbe, 0x0f, 0xa3, 0xd6, 0x29, 0x50 } \
}
@@ -1187,8 +1187,8 @@ enum ClipboardMode
/* Start of enum Scope Declaration */
-#define SCOPE_IID_STR "7c91096e-499e-4eca-9f9b-9001438d7855"
-#define SCOPE_IID { \
+# define SCOPE_IID_STR "7c91096e-499e-4eca-9f9b-9001438d7855"
+# define SCOPE_IID { \
0x7c91096e, 0x499e, 0x4eca, \
{ 0x9f, 0x9b, 0x90, 0x01, 0x43, 0x8d, 0x78, 0x55 } \
}
@@ -1202,8 +1202,8 @@ enum Scope
/* Start of enum GuestStatisticType Declaration */
-#define GUESTSTATISTICTYPE_IID_STR "aa7c1d71-aafe-47a8-9608-27d2d337cf55"
-#define GUESTSTATISTICTYPE_IID { \
+# define GUESTSTATISTICTYPE_IID_STR "aa7c1d71-aafe-47a8-9608-27d2d337cf55"
+# define GUESTSTATISTICTYPE_IID { \
0xaa7c1d71, 0xaafe, 0x47a8, \
{ 0x96, 0x08, 0x27, 0xd2, 0xd3, 0x37, 0xcf, 0x55 } \
}
@@ -1232,8 +1232,8 @@ enum GuestStatisticType
/* Start of enum BIOSBootMenuMode Declaration */
-#define BIOSBOOTMENUMODE_IID_STR "ae4fb9f7-29d2-45b4-b2c7-d579603135d5"
-#define BIOSBOOTMENUMODE_IID { \
+# define BIOSBOOTMENUMODE_IID_STR "ae4fb9f7-29d2-45b4-b2c7-d579603135d5"
+# define BIOSBOOTMENUMODE_IID { \
0xae4fb9f7, 0x29d2, 0x45b4, \
{ 0xb2, 0xc7, 0xd5, 0x79, 0x60, 0x31, 0x35, 0xd5 } \
}
@@ -1247,8 +1247,8 @@ enum BIOSBootMenuMode
/* Start of enum ProcessorFeature Declaration */
-#define PROCESSORFEATURE_IID_STR "64c38e6b-8bcf-45ad-ac03-9b406287c5bf"
-#define PROCESSORFEATURE_IID { \
+# define PROCESSORFEATURE_IID_STR "64c38e6b-8bcf-45ad-ac03-9b406287c5bf"
+# define PROCESSORFEATURE_IID { \
0x64c38e6b, 0x8bcf, 0x45ad, \
{ 0xac, 0x03, 0x9b, 0x40, 0x62, 0x87, 0xc5, 0xbf } \
}
@@ -1263,8 +1263,8 @@ enum ProcessorFeature
/* Start of enum FirmwareType Declaration */
-#define FIRMWARETYPE_IID_STR "b903f264-c230-483e-ac74-2b37ce60d371"
-#define FIRMWARETYPE_IID { \
+# define FIRMWARETYPE_IID_STR "b903f264-c230-483e-ac74-2b37ce60d371"
+# define FIRMWARETYPE_IID { \
0xb903f264, 0xc230, 0x483e, \
{ 0xac, 0x74, 0x2b, 0x37, 0xce, 0x60, 0xd3, 0x71 } \
}
@@ -1280,8 +1280,8 @@ enum FirmwareType
/* Start of enum VFSType Declaration */
-#define VFSTYPE_IID_STR "813999ba-b949-48a8-9230-aadc6285e2f2"
-#define VFSTYPE_IID { \
+# define VFSTYPE_IID_STR "813999ba-b949-48a8-9230-aadc6285e2f2"
+# define VFSTYPE_IID { \
0x813999ba, 0xb949, 0x48a8, \
{ 0x92, 0x30, 0xaa, 0xdc, 0x62, 0x85, 0xe2, 0xf2 } \
}
@@ -1296,8 +1296,8 @@ enum VFSType
/* Start of enum VFSFileType Declaration */
-#define VFSFILETYPE_IID_STR "714333cd-44e2-415f-a245-d378fa9b1242"
-#define VFSFILETYPE_IID { \
+# define VFSFILETYPE_IID_STR "714333cd-44e2-415f-a245-d378fa9b1242"
+# define VFSFILETYPE_IID { \
0x714333cd, 0x44e2, 0x415f, \
{ 0xa2, 0x45, 0xd3, 0x78, 0xfa, 0x9b, 0x12, 0x42 } \
}
@@ -1317,8 +1317,8 @@ enum VFSFileType
/* Start of enum VirtualSystemDescriptionType Declaration */
-#define VIRTUALSYSTEMDESCRIPTIONTYPE_IID_STR "aacc58de-5b45-4f82-ae2e-dd9a824fc3b5"
-#define VIRTUALSYSTEMDESCRIPTIONTYPE_IID { \
+# define VIRTUALSYSTEMDESCRIPTIONTYPE_IID_STR "aacc58de-5b45-4f82-ae2e-dd9a824fc3b5"
+# define VIRTUALSYSTEMDESCRIPTIONTYPE_IID { \
0xaacc58de, 0x5b45, 0x4f82, \
{ 0xae, 0x2e, 0xdd, 0x9a, 0x82, 0x4f, 0xc3, 0xb5 } \
}
@@ -1351,8 +1351,8 @@ enum VirtualSystemDescriptionType
/* Start of enum VirtualSystemDescriptionValueType Declaration */
-#define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID_STR "56d9403f-3425-4118-9919-36f2a9b8c77c"
-#define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID { \
+# define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID_STR "56d9403f-3425-4118-9919-36f2a9b8c77c"
+# define VIRTUALSYSTEMDESCRIPTIONVALUETYPE_IID { \
0x56d9403f, 0x3425, 0x4118, \
{ 0x99, 0x19, 0x36, 0xf2, 0xa9, 0xb8, 0xc7, 0x7c } \
}
@@ -1367,8 +1367,8 @@ enum VirtualSystemDescriptionValueType
/* Start of enum HostNetworkInterfaceMediumType Declaration */
-#define HOSTNETWORKINTERFACEMEDIUMTYPE_IID_STR "1aa54aaf-2497-45a2-bfb1-8eb225e93d5b"
-#define HOSTNETWORKINTERFACEMEDIUMTYPE_IID { \
+# define HOSTNETWORKINTERFACEMEDIUMTYPE_IID_STR "1aa54aaf-2497-45a2-bfb1-8eb225e93d5b"
+# define HOSTNETWORKINTERFACEMEDIUMTYPE_IID { \
0x1aa54aaf, 0x2497, 0x45a2, \
{ 0xbf, 0xb1, 0x8e, 0xb2, 0x25, 0xe9, 0x3d, 0x5b } \
}
@@ -1383,8 +1383,8 @@ enum HostNetworkInterfaceMediumType
/* Start of enum HostNetworkInterfaceStatus Declaration */
-#define HOSTNETWORKINTERFACESTATUS_IID_STR "CC474A69-2710-434B-8D99-C38E5D5A6F41"
-#define HOSTNETWORKINTERFACESTATUS_IID { \
+# define HOSTNETWORKINTERFACESTATUS_IID_STR "CC474A69-2710-434B-8D99-C38E5D5A6F41"
+# define HOSTNETWORKINTERFACESTATUS_IID { \
0xCC474A69, 0x2710, 0x434B, \
{ 0x8D, 0x99, 0xC3, 0x8E, 0x5D, 0x5A, 0x6F, 0x41 } \
}
@@ -1398,8 +1398,8 @@ enum HostNetworkInterfaceStatus
/* Start of enum HostNetworkInterfaceType Declaration */
-#define HOSTNETWORKINTERFACETYPE_IID_STR "67431b00-9946-48a2-bc02-b25c5919f4f3"
-#define HOSTNETWORKINTERFACETYPE_IID { \
+# define HOSTNETWORKINTERFACETYPE_IID_STR "67431b00-9946-48a2-bc02-b25c5919f4f3"
+# define HOSTNETWORKINTERFACETYPE_IID { \
0x67431b00, 0x9946, 0x48a2, \
{ 0xbc, 0x02, 0xb2, 0x5c, 0x59, 0x19, 0xf4, 0xf3 } \
}
@@ -1412,8 +1412,8 @@ enum HostNetworkInterfaceType
/* Start of enum MediumState Declaration */
-#define MEDIUMSTATE_IID_STR "ef41e980-e012-43cd-9dea-479d4ef14d13"
-#define MEDIUMSTATE_IID { \
+# define MEDIUMSTATE_IID_STR "ef41e980-e012-43cd-9dea-479d4ef14d13"
+# define MEDIUMSTATE_IID { \
0xef41e980, 0xe012, 0x43cd, \
{ 0x9d, 0xea, 0x47, 0x9d, 0x4e, 0xf1, 0x4d, 0x13 } \
}
@@ -1431,8 +1431,8 @@ enum MediumState
/* Start of enum MediumType Declaration */
-#define MEDIUMTYPE_IID_STR "11f6f7a5-0327-409a-9d42-7db6a0cec578"
-#define MEDIUMTYPE_IID { \
+# define MEDIUMTYPE_IID_STR "11f6f7a5-0327-409a-9d42-7db6a0cec578"
+# define MEDIUMTYPE_IID { \
0x11f6f7a5, 0x0327, 0x409a, \
{ 0x9d, 0x42, 0x7d, 0xb6, 0xa0, 0xce, 0xc5, 0x78 } \
}
@@ -1446,8 +1446,8 @@ enum MediumType
/* Start of enum MediumVariant Declaration */
-#define MEDIUMVARIANT_IID_STR "584ea502-143b-4ab0-ad14-d1028fdf0316"
-#define MEDIUMVARIANT_IID { \
+# define MEDIUMVARIANT_IID_STR "584ea502-143b-4ab0-ad14-d1028fdf0316"
+# define MEDIUMVARIANT_IID { \
0x584ea502, 0x143b, 0x4ab0, \
{ 0xad, 0x14, 0xd1, 0x02, 0x8f, 0xdf, 0x03, 0x16 } \
}
@@ -1464,8 +1464,8 @@ enum MediumVariant
/* Start of enum DataType Declaration */
-#define DATATYPE_IID_STR "d90ea51e-a3f1-4a01-beb1-c1723c0d3ba7"
-#define DATATYPE_IID { \
+# define DATATYPE_IID_STR "d90ea51e-a3f1-4a01-beb1-c1723c0d3ba7"
+# define DATATYPE_IID { \
0xd90ea51e, 0xa3f1, 0x4a01, \
{ 0xbe, 0xb1, 0xc1, 0x72, 0x3c, 0x0d, 0x3b, 0xa7 } \
}
@@ -1479,8 +1479,8 @@ enum DataType
/* Start of enum DataFlags Declaration */
-#define DATAFLAGS_IID_STR "86884dcf-1d6b-4f1b-b4bf-f5aa44959d60"
-#define DATAFLAGS_IID { \
+# define DATAFLAGS_IID_STR "86884dcf-1d6b-4f1b-b4bf-f5aa44959d60"
+# define DATAFLAGS_IID { \
0x86884dcf, 0x1d6b, 0x4f1b, \
{ 0xb4, 0xbf, 0xf5, 0xaa, 0x44, 0x95, 0x9d, 0x60 } \
}
@@ -1496,8 +1496,8 @@ enum DataFlags
/* Start of enum MediumFormatCapabilities Declaration */
-#define MEDIUMFORMATCAPABILITIES_IID_STR "70fcf810-99e8-4edc-aee4-7f51d489e657"
-#define MEDIUMFORMATCAPABILITIES_IID { \
+# define MEDIUMFORMATCAPABILITIES_IID_STR "70fcf810-99e8-4edc-aee4-7f51d489e657"
+# define MEDIUMFORMATCAPABILITIES_IID { \
0x70fcf810, 0x99e8, 0x4edc, \
{ 0xae, 0xe4, 0x7f, 0x51, 0xd4, 0x89, 0xe6, 0x57 } \
}
@@ -1517,8 +1517,8 @@ enum MediumFormatCapabilities
/* Start of enum MouseButtonState Declaration */
-#define MOUSEBUTTONSTATE_IID_STR "9ee094b8-b28a-4d56-a166-973cb588d7f8"
-#define MOUSEBUTTONSTATE_IID { \
+# define MOUSEBUTTONSTATE_IID_STR "9ee094b8-b28a-4d56-a166-973cb588d7f8"
+# define MOUSEBUTTONSTATE_IID { \
0x9ee094b8, 0xb28a, 0x4d56, \
{ 0xa1, 0x66, 0x97, 0x3c, 0xb5, 0x88, 0xd7, 0xf8 } \
}
@@ -1537,8 +1537,8 @@ enum MouseButtonState
/* Start of enum FramebufferPixelFormat Declaration */
-#define FRAMEBUFFERPIXELFORMAT_IID_STR "7acfd5ed-29e3-45e3-8136-73c9224f3d2d"
-#define FRAMEBUFFERPIXELFORMAT_IID { \
+# define FRAMEBUFFERPIXELFORMAT_IID_STR "7acfd5ed-29e3-45e3-8136-73c9224f3d2d"
+# define FRAMEBUFFERPIXELFORMAT_IID { \
0x7acfd5ed, 0x29e3, 0x45e3, \
{ 0x81, 0x36, 0x73, 0xc9, 0x22, 0x4f, 0x3d, 0x2d } \
}
@@ -1551,8 +1551,8 @@ enum FramebufferPixelFormat
/* Start of enum NetworkAttachmentType Declaration */
-#define NETWORKATTACHMENTTYPE_IID_STR "44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
-#define NETWORKATTACHMENTTYPE_IID { \
+# define NETWORKATTACHMENTTYPE_IID_STR "44bce1ee-99f7-4e8e-89fc-80597fd9eeaf"
+# define NETWORKATTACHMENTTYPE_IID { \
0x44bce1ee, 0x99f7, 0x4e8e, \
{ 0x89, 0xfc, 0x80, 0x59, 0x7f, 0xd9, 0xee, 0xaf } \
}
@@ -1568,8 +1568,8 @@ enum NetworkAttachmentType
/* Start of enum NetworkAdapterType Declaration */
-#define NETWORKADAPTERTYPE_IID_STR "3c2281e4-d952-4e87-8c7d-24379cb6a81c"
-#define NETWORKADAPTERTYPE_IID { \
+# define NETWORKADAPTERTYPE_IID_STR "3c2281e4-d952-4e87-8c7d-24379cb6a81c"
+# define NETWORKADAPTERTYPE_IID { \
0x3c2281e4, 0xd952, 0x4e87, \
{ 0x8c, 0x7d, 0x24, 0x37, 0x9c, 0xb6, 0xa8, 0x1c } \
}
@@ -1587,8 +1587,8 @@ enum NetworkAdapterType
/* Start of enum PortMode Declaration */
-#define PORTMODE_IID_STR "533b5fe3-0185-4197-86a7-17e37dd39d76"
-#define PORTMODE_IID { \
+# define PORTMODE_IID_STR "533b5fe3-0185-4197-86a7-17e37dd39d76"
+# define PORTMODE_IID { \
0x533b5fe3, 0x0185, 0x4197, \
{ 0x86, 0xa7, 0x17, 0xe3, 0x7d, 0xd3, 0x9d, 0x76 } \
}
@@ -1603,8 +1603,8 @@ enum PortMode
/* Start of enum USBDeviceState Declaration */
-#define USBDEVICESTATE_IID_STR "b99a2e65-67fb-4882-82fd-f3e5e8193ab4"
-#define USBDEVICESTATE_IID { \
+# define USBDEVICESTATE_IID_STR "b99a2e65-67fb-4882-82fd-f3e5e8193ab4"
+# define USBDEVICESTATE_IID { \
0xb99a2e65, 0x67fb, 0x4882, \
{ 0x82, 0xfd, 0xf3, 0xe5, 0xe8, 0x19, 0x3a, 0xb4 } \
}
@@ -1621,8 +1621,8 @@ enum USBDeviceState
/* Start of enum USBDeviceFilterAction Declaration */
-#define USBDEVICEFILTERACTION_IID_STR "cbc30a49-2f4e-43b5-9da6-121320475933"
-#define USBDEVICEFILTERACTION_IID { \
+# define USBDEVICEFILTERACTION_IID_STR "cbc30a49-2f4e-43b5-9da6-121320475933"
+# define USBDEVICEFILTERACTION_IID { \
0xcbc30a49, 0x2f4e, 0x43b5, \
{ 0x9d, 0xa6, 0x12, 0x13, 0x20, 0x47, 0x59, 0x33 } \
}
@@ -1636,8 +1636,8 @@ enum USBDeviceFilterAction
/* Start of enum AudioDriverType Declaration */
-#define AUDIODRIVERTYPE_IID_STR "4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
-#define AUDIODRIVERTYPE_IID { \
+# define AUDIODRIVERTYPE_IID_STR "4bcc3d73-c2fe-40db-b72f-0c2ca9d68496"
+# define AUDIODRIVERTYPE_IID { \
0x4bcc3d73, 0xc2fe, 0x40db, \
{ 0xb7, 0x2f, 0x0c, 0x2c, 0xa9, 0xd6, 0x84, 0x96 } \
}
@@ -1657,8 +1657,8 @@ enum AudioDriverType
/* Start of enum AudioControllerType Declaration */
-#define AUDIOCONTROLLERTYPE_IID_STR "7afd395c-42c3-444e-8788-3ce80292f36c"
-#define AUDIOCONTROLLERTYPE_IID { \
+# define AUDIOCONTROLLERTYPE_IID_STR "7afd395c-42c3-444e-8788-3ce80292f36c"
+# define AUDIOCONTROLLERTYPE_IID { \
0x7afd395c, 0x42c3, 0x444e, \
{ 0x87, 0x88, 0x3c, 0xe8, 0x02, 0x92, 0xf3, 0x6c } \
}
@@ -1671,8 +1671,8 @@ enum AudioControllerType
/* Start of enum VRDPAuthType Declaration */
-#define VRDPAUTHTYPE_IID_STR "3d91887a-b67f-4b33-85bf-2da7ab1ea83a"
-#define VRDPAUTHTYPE_IID { \
+# define VRDPAUTHTYPE_IID_STR "3d91887a-b67f-4b33-85bf-2da7ab1ea83a"
+# define VRDPAUTHTYPE_IID { \
0x3d91887a, 0xb67f, 0x4b33, \
{ 0x85, 0xbf, 0x2d, 0xa7, 0xab, 0x1e, 0xa8, 0x3a } \
}
@@ -1686,8 +1686,8 @@ enum VRDPAuthType
/* Start of enum StorageBus Declaration */
-#define STORAGEBUS_IID_STR "eee67ab3-668d-4ef5-91e0-7025fe4a0d7a"
-#define STORAGEBUS_IID { \
+# define STORAGEBUS_IID_STR "eee67ab3-668d-4ef5-91e0-7025fe4a0d7a"
+# define STORAGEBUS_IID { \
0xeee67ab3, 0x668d, 0x4ef5, \
{ 0x91, 0xe0, 0x70, 0x25, 0xfe, 0x4a, 0x0d, 0x7a } \
}
@@ -1703,8 +1703,8 @@ enum StorageBus
/* Start of enum StorageControllerType Declaration */
-#define STORAGECONTROLLERTYPE_IID_STR "8a412b8a-f43e-4456-bd37-b474f0879a58"
-#define STORAGECONTROLLERTYPE_IID { \
+# define STORAGECONTROLLERTYPE_IID_STR "8a412b8a-f43e-4456-bd37-b474f0879a58"
+# define STORAGECONTROLLERTYPE_IID { \
0x8a412b8a, 0xf43e, 0x4456, \
{ 0xbd, 0x37, 0xb4, 0x74, 0xf0, 0x87, 0x9a, 0x58 } \
}
@@ -1723,8 +1723,8 @@ enum StorageControllerType
/* Start of struct IVirtualBoxErrorInfo Declaration */
-#define IVIRTUALBOXERRORINFO_IID_STR "4b86d186-407e-4f9e-8be8-e50061be8725"
-#define IVIRTUALBOXERRORINFO_IID { \
+# define IVIRTUALBOXERRORINFO_IID_STR "4b86d186-407e-4f9e-8be8-e50061be8725"
+# define IVIRTUALBOXERRORINFO_IID { \
0x4b86d186, 0x407e, 0x4f9e, \
{ 0x8b, 0xe8, 0xe5, 0x00, 0x61, 0xbe, 0x87, 0x25 } \
}
@@ -1752,8 +1752,8 @@ struct IVirtualBoxErrorInfo
/* Start of struct ILocalOwner Declaration */
-#define ILOCALOWNER_IID_STR "308FF42A-DC45-49D4-A950-B1EEE5E00BB5"
-#define ILOCALOWNER_IID { \
+# define ILOCALOWNER_IID_STR "308FF42A-DC45-49D4-A950-B1EEE5E00BB5"
+# define ILOCALOWNER_IID { \
0x308FF42A, 0xDC45, 0x49D4, \
{ 0xA9, 0x50, 0xB1, 0xEE, 0xE5, 0xE0, 0x0B, 0xB5 } \
}
@@ -1776,8 +1776,8 @@ struct ILocalOwner
/* Start of struct IVirtualBoxCallback Declaration */
-#define IVIRTUALBOXCALLBACK_IID_STR "9a65adf2-3ee6-406b-bca2-2b1fa05f0d0b"
-#define IVIRTUALBOXCALLBACK_IID { \
+# define IVIRTUALBOXCALLBACK_IID_STR "9a65adf2-3ee6-406b-bca2-2b1fa05f0d0b"
+# define IVIRTUALBOXCALLBACK_IID { \
0x9a65adf2, 0x3ee6, 0x406b, \
{ 0xbc, 0xa2, 0x2b, 0x1f, 0xa0, 0x5f, 0x0d, 0x0b } \
}
@@ -1867,8 +1867,8 @@ struct IVirtualBoxCallback
/* Start of struct IDHCPServer Declaration */
-#define IDHCPSERVER_IID_STR "6cfe387c-74fb-4ca7-bff6-973bec8af7a3"
-#define IDHCPSERVER_IID { \
+# define IDHCPSERVER_IID_STR "6cfe387c-74fb-4ca7-bff6-973bec8af7a3"
+# define IDHCPSERVER_IID { \
0x6cfe387c, 0x74fb, 0x4ca7, \
{ 0xbf, 0xf6, 0x97, 0x3b, 0xec, 0x8a, 0xf7, 0xa3 } \
}
@@ -1916,8 +1916,8 @@ struct IDHCPServer
/* Start of struct IVirtualBox Declaration */
-#define IVIRTUALBOX_IID_STR "2158464a-f706-414b-a8c4-fb589dfc6b62"
-#define IVIRTUALBOX_IID { \
+# define IVIRTUALBOX_IID_STR "2158464a-f706-414b-a8c4-fb589dfc6b62"
+# define IVIRTUALBOX_IID { \
0x2158464a, 0xf706, 0x414b, \
{ 0xa8, 0xc4, 0xfb, 0x58, 0x9d, 0xfc, 0x6b, 0x62 } \
}
@@ -2188,8 +2188,8 @@ struct IVirtualBox
/* Start of struct IVFSExplorer Declaration */
-#define IVFSEXPLORER_IID_STR "2bb864a1-02a3-4474-a1d4-fb5f23b742e1"
-#define IVFSEXPLORER_IID { \
+# define IVFSEXPLORER_IID_STR "2bb864a1-02a3-4474-a1d4-fb5f23b742e1"
+# define IVFSEXPLORER_IID { \
0x2bb864a1, 0x02a3, 0x4474, \
{ 0xa1, 0xd4, 0xfb, 0x5f, 0x23, 0xb7, 0x42, 0xe1 } \
}
@@ -2250,8 +2250,8 @@ struct IVFSExplorer
/* Start of struct IAppliance Declaration */
-#define IAPPLIANCE_IID_STR "e3ba9ab9-ac2c-4266-8bd2-91c4bf721ceb"
-#define IAPPLIANCE_IID { \
+# define IAPPLIANCE_IID_STR "e3ba9ab9-ac2c-4266-8bd2-91c4bf721ceb"
+# define IAPPLIANCE_IID { \
0xe3ba9ab9, 0xac2c, 0x4266, \
{ 0x8b, 0xd2, 0x91, 0xc4, 0xbf, 0x72, 0x1c, 0xeb } \
}
@@ -2307,8 +2307,8 @@ struct IAppliance
/* Start of struct IVirtualSystemDescription Declaration */
-#define IVIRTUALSYSTEMDESCRIPTION_IID_STR "d7525e6c-531a-4c51-8e04-41235083a3d8"
-#define IVIRTUALSYSTEMDESCRIPTION_IID { \
+# define IVIRTUALSYSTEMDESCRIPTION_IID_STR "d7525e6c-531a-4c51-8e04-41235083a3d8"
+# define IVIRTUALSYSTEMDESCRIPTION_IID { \
0xd7525e6c, 0x531a, 0x4c51, \
{ 0x8e, 0x04, 0x41, 0x23, 0x50, 0x83, 0xa3, 0xd8 } \
}
@@ -2382,8 +2382,8 @@ struct IVirtualSystemDescription
/* Start of struct IInternalMachineControl Declaration */
-#define IINTERNALMACHINECONTROL_IID_STR "35d8d838-d066-447d-927a-fd93afdbec90"
-#define IINTERNALMACHINECONTROL_IID { \
+# define IINTERNALMACHINECONTROL_IID_STR "35d8d838-d066-447d-927a-fd93afdbec90"
+# define IINTERNALMACHINECONTROL_IID { \
0x35d8d838, 0xd066, 0x447d, \
{ 0x92, 0x7a, 0xfd, 0x93, 0xaf, 0xdb, 0xec, 0x90 } \
}
@@ -2530,8 +2530,8 @@ struct IInternalMachineControl
/* Start of struct IBIOSSettings Declaration */
-#define IBIOSSETTINGS_IID_STR "38b54279-dc35-4f5e-a431-835b867c6b5e"
-#define IBIOSSETTINGS_IID { \
+# define IBIOSSETTINGS_IID_STR "38b54279-dc35-4f5e-a431-835b867c6b5e"
+# define IBIOSSETTINGS_IID { \
0x38b54279, 0xdc35, 0x4f5e, \
{ 0xa4, 0x31, 0x83, 0x5b, 0x86, 0x7c, 0x6b, 0x5e } \
}
@@ -2576,8 +2576,8 @@ struct IBIOSSettings
/* Start of struct IMachine Declaration */
-#define IMACHINE_IID_STR "99404f50-dd10-40d3-889b-dd2f79f1e95e"
-#define IMACHINE_IID { \
+# define IMACHINE_IID_STR "99404f50-dd10-40d3-889b-dd2f79f1e95e"
+# define IMACHINE_IID { \
0x99404f50, 0xdd10, 0x40d3, \
{ 0x88, 0x9b, 0xdd, 0x2f, 0x79, 0xf1, 0xe9, 0x5e } \
}
@@ -3009,8 +3009,8 @@ struct IMachine
/* Start of struct IConsoleCallback Declaration */
-#define ICONSOLECALLBACK_IID_STR "d6239535-bda2-4ef7-83f4-f4722e4a3b2c"
-#define ICONSOLECALLBACK_IID { \
+# define ICONSOLECALLBACK_IID_STR "d6239535-bda2-4ef7-83f4-f4722e4a3b2c"
+# define ICONSOLECALLBACK_IID { \
0xd6239535, 0xbda2, 0x4ef7, \
{ 0x83, 0xf4, 0xf4, 0x72, 0x2e, 0x4a, 0x3b, 0x2c } \
}
@@ -3116,8 +3116,8 @@ struct IConsoleCallback
/* Start of struct IRemoteDisplayInfo Declaration */
-#define IREMOTEDISPLAYINFO_IID_STR "b3741084-806f-4c3b-8c42-ebad1a81e45a"
-#define IREMOTEDISPLAYINFO_IID { \
+# define IREMOTEDISPLAYINFO_IID_STR "b3741084-806f-4c3b-8c42-ebad1a81e45a"
+# define IREMOTEDISPLAYINFO_IID { \
0xb3741084, 0x806f, 0x4c3b, \
{ 0x8c, 0x42, 0xeb, 0xad, 0x1a, 0x81, 0xe4, 0x5a } \
}
@@ -3165,8 +3165,8 @@ struct IRemoteDisplayInfo
/* Start of struct IConsole Declaration */
-#define ICONSOLE_IID_STR "6375231a-c17c-464b-92cb-ae9e128d71c3"
-#define ICONSOLE_IID { \
+# define ICONSOLE_IID_STR "6375231a-c17c-464b-92cb-ae9e128d71c3"
+# define ICONSOLE_IID { \
0x6375231a, 0xc17c, 0x464b, \
{ 0x92, 0xcb, 0xae, 0x9e, 0x12, 0x8d, 0x71, 0xc3 } \
}
@@ -3335,8 +3335,8 @@ struct IConsole
/* Start of struct IHostNetworkInterface Declaration */
-#define IHOSTNETWORKINTERFACE_IID_STR "ce6fae58-7642-4102-b5db-c9005c2320a8"
-#define IHOSTNETWORKINTERFACE_IID { \
+# define IHOSTNETWORKINTERFACE_IID_STR "ce6fae58-7642-4102-b5db-c9005c2320a8"
+# define IHOSTNETWORKINTERFACE_IID { \
0xce6fae58, 0x7642, 0x4102, \
{ 0xb5, 0xdb, 0xc9, 0x00, 0x5c, 0x23, 0x20, 0xa8 } \
}
@@ -3396,8 +3396,8 @@ struct IHostNetworkInterface
/* Start of struct IHost Declaration */
-#define IHOST_IID_STR "e380cbfc-ae65-4fa6-899e-45ded6b3132a"
-#define IHOST_IID { \
+# define IHOST_IID_STR "e380cbfc-ae65-4fa6-899e-45ded6b3132a"
+# define IHOST_IID { \
0xe380cbfc, 0xae65, 0x4fa6, \
{ 0x89, 0x9e, 0x45, 0xde, 0xd6, 0xb3, 0x13, 0x2a } \
}
@@ -3542,8 +3542,8 @@ struct IHost
/* Start of struct ISystemProperties Declaration */
-#define ISYSTEMPROPERTIES_IID_STR "8030645c-8fef-4320-bb7b-c829f00069dc"
-#define ISYSTEMPROPERTIES_IID { \
+# define ISYSTEMPROPERTIES_IID_STR "8030645c-8fef-4320-bb7b-c829f00069dc"
+# define ISYSTEMPROPERTIES_IID { \
0x8030645c, 0x8fef, 0x4320, \
{ 0xbb, 0x7b, 0xc8, 0x29, 0xf0, 0x00, 0x69, 0xdc } \
}
@@ -3636,8 +3636,8 @@ struct ISystemProperties
/* Start of struct IGuestOSType Declaration */
-#define IGUESTOSTYPE_IID_STR "cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
-#define IGUESTOSTYPE_IID { \
+# define IGUESTOSTYPE_IID_STR "cfe9e64c-4430-435b-9e7c-e3d8e417bd58"
+# define IGUESTOSTYPE_IID { \
0xcfe9e64c, 0x4430, 0x435b, \
{ 0x9e, 0x7c, 0xe3, 0xd8, 0xe4, 0x17, 0xbd, 0x58 } \
}
@@ -3677,8 +3677,8 @@ struct IGuestOSType
/* Start of struct IGuest Declaration */
-#define IGUEST_IID_STR "d8556fca-81bc-12af-fca3-365528fa38ca"
-#define IGUEST_IID { \
+# define IGUEST_IID_STR "d8556fca-81bc-12af-fca3-365528fa38ca"
+# define IGUEST_IID { \
0xd8556fca, 0x81bc, 0x12af, \
{ 0xfc, 0xa3, 0x36, 0x55, 0x28, 0xfa, 0x38, 0xca } \
}
@@ -3727,8 +3727,8 @@ struct IGuest
/* Start of struct IProgress Declaration */
-#define IPROGRESS_IID_STR "856aa038-853f-42e2-acf7-6e7b02dbe294"
-#define IPROGRESS_IID { \
+# define IPROGRESS_IID_STR "856aa038-853f-42e2-acf7-6e7b02dbe294"
+# define IPROGRESS_IID { \
0x856aa038, 0x853f, 0x42e2, \
{ 0xac, 0xf7, 0x6e, 0x7b, 0x02, 0xdb, 0xe2, 0x94 } \
}
@@ -3801,8 +3801,8 @@ struct IProgress
/* Start of struct ISnapshot Declaration */
-#define ISNAPSHOT_IID_STR "1a2d0551-58a4-4107-857e-ef414fc42ffc"
-#define ISNAPSHOT_IID { \
+# define ISNAPSHOT_IID_STR "1a2d0551-58a4-4107-857e-ef414fc42ffc"
+# define ISNAPSHOT_IID { \
0x1a2d0551, 0x58a4, 0x4107, \
{ 0x85, 0x7e, 0xef, 0x41, 0x4f, 0xc4, 0x2f, 0xfc } \
}
@@ -3838,8 +3838,8 @@ struct ISnapshot
/* Start of struct IMediumAttachment Declaration */
-#define IMEDIUMATTACHMENT_IID_STR "e58eb3eb-8627-428b-bdf8-34487c848de5"
-#define IMEDIUMATTACHMENT_IID { \
+# define IMEDIUMATTACHMENT_IID_STR "e58eb3eb-8627-428b-bdf8-34487c848de5"
+# define IMEDIUMATTACHMENT_IID { \
0xe58eb3eb, 0x8627, 0x428b, \
{ 0xbd, 0xf8, 0x34, 0x48, 0x7c, 0x84, 0x8d, 0xe5 } \
}
@@ -3869,8 +3869,8 @@ struct IMediumAttachment
/* Start of struct IMedium Declaration */
-#define IMEDIUM_IID_STR "aa8167ba-df72-4738-b740-9b84377ba9f1"
-#define IMEDIUM_IID { \
+# define IMEDIUM_IID_STR "aa8167ba-df72-4738-b740-9b84377ba9f1"
+# define IMEDIUM_IID { \
0xaa8167ba, 0xdf72, 0x4738, \
{ 0xb7, 0x40, 0x9b, 0x84, 0x37, 0x7b, 0xa9, 0xf1 } \
}
@@ -4040,8 +4040,8 @@ struct IMedium
/* Start of struct IMediumFormat Declaration */
-#define IMEDIUMFORMAT_IID_STR "89f52554-d469-4799-9fad-1705e86a08b1"
-#define IMEDIUMFORMAT_IID { \
+# define IMEDIUMFORMAT_IID_STR "89f52554-d469-4799-9fad-1705e86a08b1"
+# define IMEDIUMFORMAT_IID { \
0x89f52554, 0xd469, 0x4799, \
{ 0x9f, 0xad, 0x17, 0x05, 0xe8, 0x6a, 0x08, 0xb1 } \
}
@@ -4081,8 +4081,8 @@ struct IMediumFormat
/* Start of struct IKeyboard Declaration */
-#define IKEYBOARD_IID_STR "2d1a531b-4c6e-49cc-8af6-5c857b78b5d7"
-#define IKEYBOARD_IID { \
+# define IKEYBOARD_IID_STR "2d1a531b-4c6e-49cc-8af6-5c857b78b5d7"
+# define IKEYBOARD_IID { \
0x2d1a531b, 0x4c6e, 0x49cc, \
{ 0x8a, 0xf6, 0x5c, 0x85, 0x7b, 0x78, 0xb5, 0xd7 } \
}
@@ -4114,8 +4114,8 @@ struct IKeyboard
/* Start of struct IMouse Declaration */
-#define IMOUSE_IID_STR "7c0f2eae-f92d-498c-b802-e1a3763774dc"
-#define IMOUSE_IID { \
+# define IMOUSE_IID_STR "7c0f2eae-f92d-498c-b802-e1a3763774dc"
+# define IMOUSE_IID { \
0x7c0f2eae, 0xf92d, 0x498c, \
{ 0xb8, 0x02, 0xe1, 0xa3, 0x76, 0x37, 0x74, 0xdc } \
}
@@ -4153,8 +4153,8 @@ struct IMouse
/* Start of struct IFramebuffer Declaration */
-#define IFRAMEBUFFER_IID_STR "b7ed347a-5765-40a0-ae1c-f543eb4ddeaf"
-#define IFRAMEBUFFER_IID { \
+# define IFRAMEBUFFER_IID_STR "b7ed347a-5765-40a0-ae1c-f543eb4ddeaf"
+# define IFRAMEBUFFER_IID { \
0xb7ed347a, 0x5765, 0x40a0, \
{ 0xae, 0x1c, 0xf5, 0x43, 0xeb, 0x4d, 0xde, 0xaf } \
}
@@ -4242,8 +4242,8 @@ struct IFramebuffer
/* Start of struct IFramebufferOverlay Declaration */
-#define IFRAMEBUFFEROVERLAY_IID_STR "0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47"
-#define IFRAMEBUFFEROVERLAY_IID { \
+# define IFRAMEBUFFEROVERLAY_IID_STR "0bcc1c7e-e415-47d2-bfdb-e4c705fb0f47"
+# define IFRAMEBUFFEROVERLAY_IID { \
0x0bcc1c7e, 0xe415, 0x47d2, \
{ 0xbf, 0xdb, 0xe4, 0xc7, 0x05, 0xfb, 0x0f, 0x47 } \
}
@@ -4277,8 +4277,8 @@ struct IFramebufferOverlay
/* Start of struct IDisplay Declaration */
-#define IDISPLAY_IID_STR "e2a38ebc-d854-4a3e-bc2e-fdf5ac4a0000"
-#define IDISPLAY_IID { \
+# define IDISPLAY_IID_STR "e2a38ebc-d854-4a3e-bc2e-fdf5ac4a0000"
+# define IDISPLAY_IID { \
0xe2a38ebc, 0xd854, 0x4a3e, \
{ 0xbc, 0x2e, 0xfd, 0xf5, 0xac, 0x4a, 0x00, 0x00 } \
}
@@ -4367,8 +4367,8 @@ struct IDisplay
/* Start of struct INetworkAdapter Declaration */
-#define INETWORKADAPTER_IID_STR "65607a27-2b73-4d43-b4cc-0ba2c817fbde"
-#define INETWORKADAPTER_IID { \
+# define INETWORKADAPTER_IID_STR "65607a27-2b73-4d43-b4cc-0ba2c817fbde"
+# define INETWORKADAPTER_IID { \
0x65607a27, 0x2b73, 0x4d43, \
{ 0xb4, 0xcc, 0x0b, 0xa2, 0xc8, 0x17, 0xfb, 0xde } \
}
@@ -4430,8 +4430,8 @@ struct INetworkAdapter
/* Start of struct ISerialPort Declaration */
-#define ISERIALPORT_IID_STR "937f6970-5103-4745-b78e-d28dcf1479a8"
-#define ISERIALPORT_IID { \
+# define ISERIALPORT_IID_STR "937f6970-5103-4745-b78e-d28dcf1479a8"
+# define ISERIALPORT_IID { \
0x937f6970, 0x5103, 0x4745, \
{ 0xb7, 0x8e, 0xd2, 0x8d, 0xcf, 0x14, 0x79, 0xa8 } \
}
@@ -4469,8 +4469,8 @@ struct ISerialPort
/* Start of struct IParallelPort Declaration */
-#define IPARALLELPORT_IID_STR "0c925f06-dd10-4b77-8de8-294d738c3214"
-#define IPARALLELPORT_IID { \
+# define IPARALLELPORT_IID_STR "0c925f06-dd10-4b77-8de8-294d738c3214"
+# define IPARALLELPORT_IID { \
0x0c925f06, 0xdd10, 0x4b77, \
{ 0x8d, 0xe8, 0x29, 0x4d, 0x73, 0x8c, 0x32, 0x14 } \
}
@@ -4502,8 +4502,8 @@ struct IParallelPort
/* Start of struct IMachineDebugger Declaration */
-#define IMACHINEDEBUGGER_IID_STR "b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
-#define IMACHINEDEBUGGER_IID { \
+# define IMACHINEDEBUGGER_IID_STR "b0b2a2dd-0627-4502-91c2-ddc5e77609e0"
+# define IMACHINEDEBUGGER_IID { \
0xb0b2a2dd, 0x0627, 0x4502, \
{ 0x91, 0xc2, 0xdd, 0xc5, 0xe7, 0x76, 0x09, 0xe0 } \
}
@@ -4571,8 +4571,8 @@ struct IMachineDebugger
/* Start of struct IUSBController Declaration */
-#define IUSBCONTROLLER_IID_STR "238540fa-4b73-435a-a38e-4e1d9eab5c17"
-#define IUSBCONTROLLER_IID { \
+# define IUSBCONTROLLER_IID_STR "238540fa-4b73-435a-a38e-4e1d9eab5c17"
+# define IUSBCONTROLLER_IID { \
0x238540fa, 0x4b73, 0x435a, \
{ 0xa3, 0x8e, 0x4e, 0x1d, 0x9e, 0xab, 0x5c, 0x17 } \
}
@@ -4618,8 +4618,8 @@ struct IUSBController
/* Start of struct IUSBDevice Declaration */
-#define IUSBDEVICE_IID_STR "f8967b0b-4483-400f-92b5-8b675d98a85b"
-#define IUSBDEVICE_IID { \
+# define IUSBDEVICE_IID_STR "f8967b0b-4483-400f-92b5-8b675d98a85b"
+# define IUSBDEVICE_IID { \
0xf8967b0b, 0x4483, 0x400f, \
{ 0x92, 0xb5, 0x8b, 0x67, 0x5d, 0x98, 0xa8, 0x5b } \
}
@@ -4661,8 +4661,8 @@ struct IUSBDevice
/* Start of struct IUSBDeviceFilter Declaration */
-#define IUSBDEVICEFILTER_IID_STR "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
-#define IUSBDEVICEFILTER_IID { \
+# define IUSBDEVICEFILTER_IID_STR "d6831fb4-1a94-4c2c-96ef-8d0d6192066d"
+# define IUSBDEVICEFILTER_IID { \
0xd6831fb4, 0x1a94, 0x4c2c, \
{ 0x96, 0xef, 0x8d, 0x0d, 0x61, 0x92, 0x06, 0x6d } \
}
@@ -4713,8 +4713,8 @@ struct IUSBDeviceFilter
/* Start of struct IHostUSBDevice Declaration */
-#define IHOSTUSBDEVICE_IID_STR "173b4b44-d268-4334-a00d-b6521c9a740a"
-#define IHOSTUSBDEVICE_IID { \
+# define IHOSTUSBDEVICE_IID_STR "173b4b44-d268-4334-a00d-b6521c9a740a"
+# define IHOSTUSBDEVICE_IID { \
0x173b4b44, 0xd268, 0x4334, \
{ 0xa0, 0x0d, 0xb6, 0x52, 0x1c, 0x9a, 0x74, 0x0a } \
}
@@ -4734,8 +4734,8 @@ struct IHostUSBDevice
/* Start of struct IHostUSBDeviceFilter Declaration */
-#define IHOSTUSBDEVICEFILTER_IID_STR "4cc70246-d74a-400f-8222-3900489c0374"
-#define IHOSTUSBDEVICEFILTER_IID { \
+# define IHOSTUSBDEVICEFILTER_IID_STR "4cc70246-d74a-400f-8222-3900489c0374"
+# define IHOSTUSBDEVICEFILTER_IID { \
0x4cc70246, 0xd74a, 0x400f, \
{ 0x82, 0x22, 0x39, 0x00, 0x48, 0x9c, 0x03, 0x74 } \
}
@@ -4756,8 +4756,8 @@ struct IHostUSBDeviceFilter
/* Start of struct IAudioAdapter Declaration */
-#define IAUDIOADAPTER_IID_STR "921873db-5f3f-4b69-91f9-7be9e535a2cb"
-#define IAUDIOADAPTER_IID { \
+# define IAUDIOADAPTER_IID_STR "921873db-5f3f-4b69-91f9-7be9e535a2cb"
+# define IAUDIOADAPTER_IID { \
0x921873db, 0x5f3f, 0x4b69, \
{ 0x91, 0xf9, 0x7b, 0xe9, 0xe5, 0x35, 0xa2, 0xcb } \
}
@@ -4784,8 +4784,8 @@ struct IAudioAdapter
/* Start of struct IVRDPServer Declaration */
-#define IVRDPSERVER_IID_STR "72e671bc-1712-4052-ad6b-e45e76d9d3e4"
-#define IVRDPSERVER_IID { \
+# define IVRDPSERVER_IID_STR "72e671bc-1712-4052-ad6b-e45e76d9d3e4"
+# define IVRDPSERVER_IID { \
0x72e671bc, 0x1712, 0x4052, \
{ 0xad, 0x6b, 0xe4, 0x5e, 0x76, 0xd9, 0xd3, 0xe4 } \
}
@@ -4824,8 +4824,8 @@ struct IVRDPServer
/* Start of struct ISharedFolder Declaration */
-#define ISHAREDFOLDER_IID_STR "64637bb2-9e17-471c-b8f3-f8968dd9884e"
-#define ISHAREDFOLDER_IID { \
+# define ISHAREDFOLDER_IID_STR "64637bb2-9e17-471c-b8f3-f8968dd9884e"
+# define ISHAREDFOLDER_IID { \
0x64637bb2, 0x9e17, 0x471c, \
{ 0xb8, 0xf3, 0xf8, 0x96, 0x8d, 0xd9, 0x88, 0x4e } \
}
@@ -4853,8 +4853,8 @@ struct ISharedFolder
/* Start of struct IInternalSessionControl Declaration */
-#define IINTERNALSESSIONCONTROL_IID_STR "f9aac6d0-41b3-46b7-bea4-6370b4036de6"
-#define IINTERNALSESSIONCONTROL_IID { \
+# define IINTERNALSESSIONCONTROL_IID_STR "f9aac6d0-41b3-46b7-bea4-6370b4036de6"
+# define IINTERNALSESSIONCONTROL_IID { \
0xf9aac6d0, 0x41b3, 0x46b7, \
{ 0xbe, 0xa4, 0x63, 0x70, 0xb4, 0x03, 0x6d, 0xe6 } \
}
@@ -4977,8 +4977,8 @@ struct IInternalSessionControl
/* Start of struct ISession Declaration */
-#define ISESSION_IID_STR "12F4DCDB-12B2-4EC1-B7CD-DDD9F6C5BF4D"
-#define ISESSION_IID { \
+# define ISESSION_IID_STR "12F4DCDB-12B2-4EC1-B7CD-DDD9F6C5BF4D"
+# define ISESSION_IID { \
0x12F4DCDB, 0x12B2, 0x4EC1, \
{ 0xB7, 0xCD, 0xDD, 0xD9, 0xF6, 0xC5, 0xBF, 0x4D } \
}
@@ -5006,8 +5006,8 @@ struct ISession
/* Start of struct IStorageController Declaration */
-#define ISTORAGECONTROLLER_IID_STR "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
-#define ISTORAGECONTROLLER_IID { \
+# define ISTORAGECONTROLLER_IID_STR "6bf8335b-d14a-44a5-9b45-ddc49ce7d5b2"
+# define ISTORAGECONTROLLER_IID { \
0x6bf8335b, 0xd14a, 0x44a5, \
{ 0x9b, 0x45, 0xdd, 0xc4, 0x9c, 0xe7, 0xd5, 0xb2 } \
}
@@ -5056,8 +5056,8 @@ struct IStorageController
/* Start of struct IPerformanceMetric Declaration */
-#define IPERFORMANCEMETRIC_IID_STR "2a1a60ae-9345-4019-ad53-d34ba41cbfe9"
-#define IPERFORMANCEMETRIC_IID { \
+# define IPERFORMANCEMETRIC_IID_STR "2a1a60ae-9345-4019-ad53-d34ba41cbfe9"
+# define IPERFORMANCEMETRIC_IID { \
0x2a1a60ae, 0x9345, 0x4019, \
{ 0xad, 0x53, 0xd3, 0x4b, 0xa4, 0x1c, 0xbf, 0xe9 } \
}
@@ -5091,8 +5091,8 @@ struct IPerformanceMetric
/* Start of struct IPerformanceCollector Declaration */
-#define IPERFORMANCECOLLECTOR_IID_STR "e22e1acb-ac4a-43bb-a31c-17321659b0c6"
-#define IPERFORMANCECOLLECTOR_IID { \
+# define IPERFORMANCECOLLECTOR_IID_STR "e22e1acb-ac4a-43bb-a31c-17321659b0c6"
+# define IPERFORMANCECOLLECTOR_IID { \
0xe22e1acb, 0xac4a, 0x43bb, \
{ 0xa3, 0x1c, 0x17, 0x32, 0x16, 0x59, 0xb0, 0xc6 } \
}
@@ -5178,47 +5178,47 @@ struct IPerformanceCollector
-#define NS_VIRTUALBOX_CID { \
+# define NS_VIRTUALBOX_CID { \
0xB1A7A4F2, 0x47B9, 0x4A1E, \
{ 0x82, 0xB2, 0x07, 0xCC, 0xD5, 0x32, 0x3C, 0x3F } \
}
-#define NS_VIRTUALBOX_CONTRACTID "@virtualbox.org/VirtualBox;1"
+# define NS_VIRTUALBOX_CONTRACTID "@virtualbox.org/VirtualBox;1"
/* for compatibility with Win32 */
-#define CLSID_VirtualBox (nsCID) NS_VIRTUALBOX_CID
+# define CLSID_VirtualBox (nsCID) NS_VIRTUALBOX_CID
-#define NS_SESSION_CID { \
+# define NS_SESSION_CID { \
0x3C02F46D, 0xC9D2, 0x4F11, \
{ 0xA3, 0x84, 0x53, 0xF0, 0xCF, 0x91, 0x72, 0x14 } \
}
-#define NS_SESSION_CONTRACTID "@virtualbox.org/Session;1"
+# define NS_SESSION_CONTRACTID "@virtualbox.org/Session;1"
/* for compatibility with Win32 */
-#define CLSID_Session (nsCID) NS_SESSION_CID
+# define CLSID_Session (nsCID) NS_SESSION_CID
-#define NS_CALLBACKWRAPPER_CID { \
+# define NS_CALLBACKWRAPPER_CID { \
0x49EE8561, 0x5563, 0x4715, \
{ 0xB1, 0x8C, 0xA4, 0xB1, 0xA4, 0x90, 0xDA, 0xFE } \
}
-#define NS_CALLBACKWRAPPER_CONTRACTID "@virtualbox.org/CallbackWrapper;1"
+# define NS_CALLBACKWRAPPER_CONTRACTID "@virtualbox.org/CallbackWrapper;1"
/* for compatibility with Win32 */
-#define CLSID_CallbackWrapper (nsCID) NS_CALLBACKWRAPPER_CID
+# define CLSID_CallbackWrapper (nsCID) NS_CALLBACKWRAPPER_CID
-#endif /* !__cplusplus */
+# endif /* !__cplusplus */
-#ifdef IN_VBOXXPCOMC
-# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
-#else
-# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
-#endif
+# ifdef IN_VBOXXPCOMC
+# define VBOXXPCOMC_DECL(type) PR_EXPORT(type)
+# else
+# define VBOXXPCOMC_DECL(type) PR_IMPORT(type)
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
/**
@@ -5258,22 +5258,22 @@ typedef VBOXXPCOMC const *PCVBOXXPCOM;
/** The current interface version.
* For use with VBoxGetXPCOMCFunctions and to be found in
* VBOXXPCOMC::uVersion. */
-#define VBOX_XPCOMC_VERSION 0x00020000U
+# define VBOX_XPCOMC_VERSION 0x00020000U
VBOXXPCOMC_DECL(PCVBOXXPCOM) VBoxGetXPCOMCFunctions(unsigned uVersion);
/** Typedef for VBoxGetXPCOMCFunctions. */
typedef PCVBOXXPCOM (*PFNVBOXGETXPCOMCFUNCTIONS)(unsigned uVersion);
/** The symbol name of VBoxGetXPCOMCFunctions. */
-#if defined(__OS2__)
-# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
-#else
-# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
-#endif
+# if defined(__OS2__)
+# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "_VBoxGetXPCOMCFunctions"
+# else
+# define VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME "VBoxGetXPCOMCFunctions"
+# endif
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
#endif /* !___VirtualBox_CXPCOM_h */
diff --git a/src/vbox/vbox_XPCOMCGlue.h b/src/vbox/vbox_XPCOMCGlue.h
index afaa96b..c04eefa 100644
--- a/src/vbox/vbox_XPCOMCGlue.h
+++ b/src/vbox/vbox_XPCOMCGlue.h
@@ -27,14 +27,14 @@
*/
#ifndef ___VBoxXPCOMC_cglue_h
-#define ___VBoxXPCOMC_cglue_h
+# define ___VBoxXPCOMC_cglue_h
/* This has to be the oldest version we support. */
-#include "vbox_CAPI_v2_2.h"
+# include "vbox_CAPI_v2_2.h"
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
/** The dlopen handle for VBoxXPCOMC. */
extern void *g_hVBoxXPCOMC;
@@ -50,8 +50,8 @@ int VBoxCGlueInit(void);
void VBoxCGlueTerm(void);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
#endif
diff --git a/src/vbox/vbox_driver.h b/src/vbox/vbox_driver.h
index 7a7a1dc..2eabf1c 100644
--- a/src/vbox/vbox_driver.h
+++ b/src/vbox/vbox_driver.h
@@ -27,9 +27,9 @@
*/
#ifndef VBOX_DRIVER_H
-#define VBOX_DRIVER_H
+# define VBOX_DRIVER_H
-#include "internal.h"
+# include "internal.h"
int vboxRegister(void);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 6ebf50c..b808910 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -101,25 +101,25 @@ if (!host) {\
#if VBOX_API_VERSION < 3001
-#define VBOX_MEDIUM_RELEASE(arg) \
+# define VBOX_MEDIUM_RELEASE(arg) \
if(arg)\
(arg)->vtbl->imedium.nsisupports.Release((nsISupports *)(arg))
-#define VBOX_MEDIUM_FUNC_ARG1(object, func, arg1) \
+# define VBOX_MEDIUM_FUNC_ARG1(object, func, arg1) \
(object)->vtbl->imedium.func((IMedium *)(object), arg1)
-#define VBOX_MEDIUM_FUNC_ARG2(object, func, arg1, arg2) \
+# define VBOX_MEDIUM_FUNC_ARG2(object, func, arg1, arg2) \
(object)->vtbl->imedium.func((IMedium *)(object), arg1, arg2)
#else /* VBOX_API_VERSION >= 3001 */
typedef IMedium IHardDisk;
typedef IMediumAttachment IHardDiskAttachment;
-#define MediaState_Inaccessible MediumState_Inaccessible
-#define HardDiskVariant_Standard MediumVariant_Standard
-#define HardDiskVariant_Fixed MediumVariant_Fixed
-#define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg)
-#define VBOX_MEDIUM_FUNC_ARG1(object, func, arg1) \
+# define MediaState_Inaccessible MediumState_Inaccessible
+# define HardDiskVariant_Standard MediumVariant_Standard
+# define HardDiskVariant_Fixed MediumVariant_Fixed
+# define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg)
+# define VBOX_MEDIUM_FUNC_ARG1(object, func, arg1) \
(object)->vtbl->func(object, arg1)
-#define VBOX_MEDIUM_FUNC_ARG2(object, func, arg1, arg2) \
+# define VBOX_MEDIUM_FUNC_ARG2(object, func, arg1, arg2) \
(object)->vtbl->func(object, arg1, arg2)
#endif /* VBOX_API_VERSION >= 3001 */
@@ -217,13 +217,13 @@ static void vboxDriverUnlock(vboxGlobalData *data) {
#if VBOX_API_VERSION == 2002
-#define vboxIIDFromUUID(uuid, iid) nsIDFromChar((iid), (uuid))
-#define vboxIIDToUUID(uuid, iid) nsIDtoChar((uuid), (iid))
-#define vboxIIDUnalloc(iid) data->pFuncs->pfnComUnallocMem(iid)
-#define vboxIIDFree(iid) VIR_FREE(iid)
-#define vboxIIDUtf8Free(iid) VIR_FREE(iid)
-#define vboxIIDUtf16Free(iid) VIR_FREE(iid)
-#define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
+# define vboxIIDFromUUID(uuid, iid) nsIDFromChar((iid), (uuid))
+# define vboxIIDToUUID(uuid, iid) nsIDtoChar((uuid), (iid))
+# define vboxIIDUnalloc(iid) data->pFuncs->pfnComUnallocMem(iid)
+# define vboxIIDFree(iid) VIR_FREE(iid)
+# define vboxIIDUtf8Free(iid) VIR_FREE(iid)
+# define vboxIIDUtf16Free(iid) VIR_FREE(iid)
+# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
static void nsIDtoChar(unsigned char *uuid, const nsID *iid) {
char uuidstrsrc[VIR_UUID_STRING_BUFLEN];
@@ -340,7 +340,7 @@ static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
#else /* VBOX_API_VERSION != 2002 */
-#define vboxIIDFromUUID(uuid, iid)\
+# define vboxIIDFromUUID(uuid, iid)\
{\
char vboxIIDUtf8[VIR_UUID_STRING_BUFLEN];\
\
@@ -348,7 +348,7 @@ static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
data->pFuncs->pfnUtf8ToUtf16(vboxIIDUtf8, (&(iid)));\
}
-#define vboxIIDToUUID(uuid, iid)\
+# define vboxIIDToUUID(uuid, iid)\
{\
char *vboxIIDUtf8 = NULL;\
data->pFuncs->pfnUtf16ToUtf8((iid), &vboxIIDUtf8);\
@@ -356,11 +356,11 @@ static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
data->pFuncs->pfnUtf8Free(vboxIIDUtf8);\
}
-#define vboxIIDFree(iid) data->pFuncs->pfnUtf16Free(iid)
-#define vboxIIDUtf8Free(iid) data->pFuncs->pfnUtf8Free(iid)
-#define vboxIIDUtf16Free(iid) data->pFuncs->pfnUtf16Free(iid)
-#define vboxIIDUnalloc(iid) data->pFuncs->pfnUtf16Free(iid)
-#define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
+# define vboxIIDFree(iid) data->pFuncs->pfnUtf16Free(iid)
+# define vboxIIDUtf8Free(iid) data->pFuncs->pfnUtf8Free(iid)
+# define vboxIIDUtf16Free(iid) data->pFuncs->pfnUtf16Free(iid)
+# define vboxIIDUnalloc(iid) data->pFuncs->pfnUtf16Free(iid)
+# define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
typedef PRUnichar vboxIID;
@@ -407,7 +407,7 @@ static void vboxUtf8toIID(char *uuidstr, vboxIID **iid) {
virReportOOMError();
}
-#if VBOX_API_VERSION >= 3001
+# if VBOX_API_VERSION >= 3001
/**
* function to generate the name for medium,
@@ -618,7 +618,7 @@ static PRUnichar *PRUnicharFromInt(int n) {
return strUtf16;
}
-#endif /* VBOX_API_VERSION >= 3001 */
+# endif /* VBOX_API_VERSION >= 3001 */
#endif /* !(VBOX_API_VERSION == 2002) */
@@ -677,11 +677,11 @@ static int vboxInitialize(virConnectPtr conn, vboxGlobalData *data) {
data->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &data->vboxObj,
ISESSION_IID_STR, &data->vboxSession);
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
/* No event queue functionality in 2.2.* as of now */
-#else /* !(VBOX_API_VERSION == 2002) */
+# else /* !(VBOX_API_VERSION == 2002) */
/* Initial the fWatch needed for Event Callbacks */
data->fdWatch = -1;
@@ -693,7 +693,7 @@ static int vboxInitialize(virConnectPtr conn, vboxGlobalData *data) {
goto cleanup;
}
-#endif /* !(VBOX_API_VERSION == 2002) */
+# endif /* !(VBOX_API_VERSION == 2002) */
#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */
if (data->vboxObj == NULL) {
@@ -3533,23 +3533,23 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
IDVDImage *dvdImage = NULL;
PRUnichar *dvdfileUtf16 = NULL;
vboxIID *dvduuid = NULL;
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
nsID dvdemptyuuid;
memset(&dvdemptyuuid, 0, sizeof(dvdemptyuuid));
-#else
+# else
PRUnichar *dvdemptyuuidUtf16 = NULL;
-#endif
+# endif
VBOX_UTF8_TO_UTF16(def->disks[i]->src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
if (!dvdImage) {
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, &dvdemptyuuid, &dvdImage);
-#else
+# else
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuidUtf16, &dvdImage);
-#endif
+# endif
}
if (dvdImage) {
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid);
@@ -3594,12 +3594,12 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
data->vboxObj->vtbl->FindHardDisk(data->vboxObj, hddfileUtf16, &hardDisk);
if (!hardDisk) {
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
hddfileUtf16,
AccessMode_ReadWrite,
&hardDisk);
-#else
+# else
data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
hddfileUtf16,
AccessMode_ReadWrite,
@@ -3608,7 +3608,7 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
0,
hddEmpty,
&hardDisk);
-#endif
+# endif
}
if (hardDisk) {
@@ -3683,13 +3683,13 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
IFloppyImage *floppyImage = NULL;
PRUnichar *fdfileUtf16 = NULL;
vboxIID *fduuid = NULL;
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
nsID fdemptyuuid;
memset(&fdemptyuuid, 0, sizeof(fdemptyuuid));
-#else
+# else
PRUnichar *fdemptyuuidUtf16 = NULL;
-#endif
+# endif
VBOX_UTF8_TO_UTF16(def->disks[i]->src, &fdfileUtf16);
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
@@ -3699,11 +3699,11 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) {
if (!floppyImage) {
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
fdfileUtf16,
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
&fdemptyuuid,
-#else
+# else
fdemptyuuidUtf16,
-#endif
+# endif
&floppyImage);
}
@@ -4707,23 +4707,23 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) {
IDVDImage *dvdImage = NULL;
PRUnichar *dvdfileUtf16 = NULL;
vboxIID *dvduuid = NULL;
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
nsID dvdemptyuuid;
memset(&dvdemptyuuid, 0, sizeof(dvdemptyuuid));
-#else
+# else
PRUnichar *dvdemptyuuidUtf16 = NULL;
-#endif
+# endif
VBOX_UTF8_TO_UTF16(dev->data.disk->src, &dvdfileUtf16);
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
if (!dvdImage) {
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, &dvdemptyuuid, &dvdImage);
-#else
+# else
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuidUtf16, &dvdImage);
-#endif
+# endif
}
if (dvdImage) {
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid);
@@ -4763,13 +4763,13 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) {
IFloppyImage *floppyImage = NULL;
PRUnichar *fdfileUtf16 = NULL;
vboxIID *fduuid = NULL;
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
nsID fdemptyuuid;
memset(&fdemptyuuid, 0, sizeof(fdemptyuuid));
-#else
+# else
PRUnichar *fdemptyuuidUtf16 = NULL;
-#endif
+# endif
VBOX_UTF8_TO_UTF16(dev->data.disk->src, &fdfileUtf16);
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
fdfileUtf16,
@@ -4778,11 +4778,11 @@ static int vboxDomainAttachDevice(virDomainPtr dom, const char *xml) {
if (!floppyImage) {
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
fdfileUtf16,
-#if VBOX_API_VERSION == 2002
+# if VBOX_API_VERSION == 2002
&fdemptyuuid,
-#else
+# else
fdemptyuuidUtf16,
-#endif
+# endif
&floppyImage);
}
@@ -5100,7 +5100,7 @@ static nsresult vboxCallbackOnExtraDataChange (IVirtualBoxCallback *pThis,
return NS_OK;
}
-#if VBOX_API_VERSION < 3001
+# if VBOX_API_VERSION < 3001
static nsresult vboxCallbackOnMediaRegistered (IVirtualBoxCallback *pThis,
PRUnichar * mediaId,
PRUint32 mediaType,
@@ -5111,8 +5111,8 @@ static nsresult vboxCallbackOnMediaRegistered (IVirtualBoxCallback *pThis,
return NS_OK;
}
-#else /* VBOX_API_VERSION >= 3001 */
-#endif /* VBOX_API_VERSION >= 3001 */
+# else /* VBOX_API_VERSION >= 3001 */
+# endif /* VBOX_API_VERSION >= 3001 */
static nsresult vboxCallbackOnMachineRegistered (IVirtualBoxCallback *pThis,
PRUnichar * machineId,
@@ -5294,10 +5294,10 @@ static IVirtualBoxCallback *vboxAllocCallbackObj(void) {
vboxCallback->vtbl->OnMachineDataChange = &vboxCallbackOnMachineDataChange;
vboxCallback->vtbl->OnExtraDataCanChange = &vboxCallbackOnExtraDataCanChange;
vboxCallback->vtbl->OnExtraDataChange = &vboxCallbackOnExtraDataChange;
-#if VBOX_API_VERSION < 3001
+# if VBOX_API_VERSION < 3001
vboxCallback->vtbl->OnMediaRegistered = &vboxCallbackOnMediaRegistered;
-#else /* VBOX_API_VERSION >= 3001 */
-#endif /* VBOX_API_VERSION >= 3001 */
+# else /* VBOX_API_VERSION >= 3001 */
+# endif /* VBOX_API_VERSION >= 3001 */
vboxCallback->vtbl->OnMachineRegistered = &vboxCallbackOnMachineRegistered;
vboxCallback->vtbl->OnSessionStateChange = &vboxCallbackOnSessionStateChange;
vboxCallback->vtbl->OnSnapshotTaken = &vboxCallbackOnSnapshotTaken;
@@ -5929,13 +5929,13 @@ static int vboxNetworkUndefineDestroy(virNetworkPtr network, bool removeinterfac
networkInterface->vtbl->GetId(networkInterface, &iidUtf16);
if (iidUtf16) {
-#if VBOX_API_VERSION == 3000
+# if VBOX_API_VERSION == 3000
IHostNetworkInterface *netInt = NULL;
host->vtbl->RemoveHostOnlyNetworkInterface(host, iidUtf16, &netInt, &progress);
VBOX_RELEASE(netInt);
-#else /* VBOX_API_VERSION > 3000 */
+# else /* VBOX_API_VERSION > 3000 */
host->vtbl->RemoveHostOnlyNetworkInterface(host, iidUtf16, &progress);
-#endif /* VBOX_API_VERSION > 3000 */
+# endif /* VBOX_API_VERSION > 3000 */
VBOX_UTF16_FREE(iidUtf16);
}
diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c
index 8e699b1..6e7a5c3 100644
--- a/src/xen/block_stats.c
+++ b/src/xen/block_stats.c
@@ -13,22 +13,22 @@
/* This file only applies on Linux. */
#ifdef __linux__
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <string.h>
-#include <unistd.h>
-#include <regex.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <fcntl.h>
+# include <string.h>
+# include <unistd.h>
+# include <regex.h>
-#include <xs.h>
+# include <xs.h>
-#include "virterror_internal.h"
-#include "datatypes.h"
-#include "util.h"
-#include "block_stats.h"
-#include "memory.h"
+# include "virterror_internal.h"
+# include "datatypes.h"
+# include "util.h"
+# include "block_stats.h"
+# include "memory.h"
-#define VIR_FROM_THIS VIR_FROM_STATS_LINUX
+# define VIR_FROM_THIS VIR_FROM_STATS_LINUX
/**
* statsErrorFunc:
@@ -62,14 +62,14 @@ statsErrorFunc (virConnectPtr conn,
/*-------------------- Xen: block stats --------------------*/
-#include <linux/major.h>
+# include <linux/major.h>
/* This is normally defined in <linux/major.h> but previously we
* hard-coded it. So if it's not defined, hard-code again.
*/
-#ifndef XENVBD_MAJOR
-#define XENVBD_MAJOR 202
-#endif
+# ifndef XENVBD_MAJOR
+# define XENVBD_MAJOR 202
+# endif
static int
xstrtoint64 (char const *s, int base, int64_t *result)
diff --git a/src/xen/block_stats.h b/src/xen/block_stats.h
index e29c0b5..ba113d7 100644
--- a/src/xen/block_stats.h
+++ b/src/xen/block_stats.h
@@ -9,11 +9,11 @@
*/
#ifndef __BLOCK_STATS_H__
-#define __BLOCK_STATS_H__
+# define __BLOCK_STATS_H__
-#ifdef __linux__
+# ifdef __linux__
-#include "xen_driver.h"
+# include "xen_driver.h"
extern int xenLinuxDomainBlockStats (xenUnifiedPrivatePtr priv,
virDomainPtr dom, const char *path,
@@ -21,6 +21,6 @@ extern int xenLinuxDomainBlockStats (xenUnifiedPrivatePtr priv,
extern int xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *dev);
-#endif /* __linux__ */
+# endif /* __linux__ */
#endif /* __STATS_LINUX_H__ */
diff --git a/src/xen/proxy_internal.h b/src/xen/proxy_internal.h
index 19df751..f822473 100644
--- a/src/xen/proxy_internal.h
+++ b/src/xen/proxy_internal.h
@@ -10,12 +10,12 @@
#ifndef __LIBVIR_PROXY_H__
-#define __LIBVIR_PROXY_H__
+# define __LIBVIR_PROXY_H__
-#include "internal.h"
+# include "internal.h"
-#define PROXY_SOCKET_PATH "/tmp/livirt_proxy_conn"
-#define PROXY_PROTO_VERSION 1
+# define PROXY_SOCKET_PATH "/tmp/livirt_proxy_conn"
+# define PROXY_PROTO_VERSION 1
/*
* the command allowed though the proxy
diff --git a/src/xen/sexpr.h b/src/xen/sexpr.h
index 1d9adaa..04125ea 100644
--- a/src/xen/sexpr.h
+++ b/src/xen/sexpr.h
@@ -11,11 +11,11 @@
*/
#ifndef _LIBVIR_SEXPR_H_
-#define _LIBVIR_SEXPR_H_
+# define _LIBVIR_SEXPR_H_
-#include "internal.h"
+# include "internal.h"
-#include <sys/types.h>
+# include <sys/types.h>
enum sexpr_type {
SEXPR_NIL,
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index a798e41..5b9649c 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -38,7 +38,7 @@
#include "xs_internal.h"
#include "xm_internal.h"
#if WITH_XEN_INOTIFY
-#include "xen_inotify.h"
+# include "xen_inotify.h"
#endif
#include "xml.h"
#include "util.h"
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index defe6e2..590777c 100644
--- a/src/xen/xen_driver.h
+++ b/src/xen/xen_driver.h
@@ -9,47 +9,47 @@
*/
#ifndef __VIR_XEN_UNIFIED_H__
-#define __VIR_XEN_UNIFIED_H__
-
-#include "internal.h"
-#include "capabilities.h"
-#include "driver.h"
-#include "domain_conf.h"
-#include "xs_internal.h"
-#if WITH_XEN_INOTIFY
-#include "xen_inotify.h"
-#endif
-#include "domain_event.h"
-#include "hash.h"
-
-#ifndef HAVE_WINSOCK2_H
-#include <sys/un.h>
-#include <netinet/in.h>
-#else
-#include <winsock2.h>
-#endif
+# define __VIR_XEN_UNIFIED_H__
+
+# include "internal.h"
+# include "capabilities.h"
+# include "driver.h"
+# include "domain_conf.h"
+# include "xs_internal.h"
+# if WITH_XEN_INOTIFY
+# include "xen_inotify.h"
+# endif
+# include "domain_event.h"
+# include "hash.h"
+
+# ifndef HAVE_WINSOCK2_H
+# include <sys/un.h>
+# include <netinet/in.h>
+# else
+# include <winsock2.h>
+# endif
extern int xenRegister (void);
-#define XEN_UNIFIED_HYPERVISOR_OFFSET 0
-#define XEN_UNIFIED_PROXY_OFFSET 1
-#define XEN_UNIFIED_XEND_OFFSET 2
-#define XEN_UNIFIED_XS_OFFSET 3
-#define XEN_UNIFIED_XM_OFFSET 4
+# define XEN_UNIFIED_HYPERVISOR_OFFSET 0
+# define XEN_UNIFIED_PROXY_OFFSET 1
+# define XEN_UNIFIED_XEND_OFFSET 2
+# define XEN_UNIFIED_XS_OFFSET 3
+# define XEN_UNIFIED_XM_OFFSET 4
-#if WITH_XEN_INOTIFY
-#define XEN_UNIFIED_INOTIFY_OFFSET 5
-#define XEN_UNIFIED_NR_DRIVERS 6
-#else
-#define XEN_UNIFIED_NR_DRIVERS 5
-#endif
+# if WITH_XEN_INOTIFY
+# define XEN_UNIFIED_INOTIFY_OFFSET 5
+# define XEN_UNIFIED_NR_DRIVERS 6
+# else
+# define XEN_UNIFIED_NR_DRIVERS 5
+# endif
-#define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
+# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
-#define XEN_CONFIG_FORMAT_XM "xen-xm"
-#define XEN_CONFIG_FORMAT_SEXPR "xen-sxpr"
+# define XEN_CONFIG_FORMAT_XM "xen-xm"
+# define XEN_CONFIG_FORMAT_SEXPR "xen-sxpr"
-#define XEND_DOMAINS_DIR "/var/lib/xend/domains"
+# define XEND_DOMAINS_DIR "/var/lib/xend/domains"
/* _xenUnifiedDriver:
*
@@ -187,14 +187,14 @@ struct _xenUnifiedPrivate {
* or /var/lib/xen */
const char *configDir;
-#if WITH_XEN_INOTIFY
+# if WITH_XEN_INOTIFY
/* The inotify fd */
int inotifyFD;
int inotifyWatch;
int useXenConfigCache ;
xenUnifiedDomainInfoListPtr configInfoList;
-#endif
+# endif
/* For the 'xm' driver */
/* Primary config file name -> virDomainDef map */
@@ -220,12 +220,12 @@ void xenUnifiedDomainEventDispatch (xenUnifiedPrivatePtr priv,
virDomainEventPtr event);
unsigned long xenUnifiedVersion(void);
-#ifndef PROXY
+# ifndef PROXY
void xenUnifiedLock(xenUnifiedPrivatePtr priv);
void xenUnifiedUnlock(xenUnifiedPrivatePtr priv);
-#else
-#define xenUnifiedLock(p) do {} while(0)
-#define xenUnifiedUnlock(p) do {} while(0)
-#endif
+# else
+# define xenUnifiedLock(p) do {} while(0)
+# define xenUnifiedUnlock(p) do {} while(0)
+# endif
#endif /* __VIR_XEN_UNIFIED_H__ */
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index fe49ac2..4af3dba 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -27,13 +27,13 @@
#include <sys/utsname.h>
#ifdef __sun
-#include <sys/systeminfo.h>
+# include <sys/systeminfo.h>
-#include <priv.h>
+# include <priv.h>
-#ifndef PRIV_XVM_CONTROL
-#define PRIV_XVM_CONTROL ((const char *)"xvm_control")
-#endif
+# ifndef PRIV_XVM_CONTROL
+# define PRIV_XVM_CONTROL ((const char *)"xvm_control")
+# endif
#endif /* __sun */
@@ -41,11 +41,11 @@
#include <xen/dom0_ops.h>
#include <xen/version.h>
#ifdef HAVE_XEN_LINUX_PRIVCMD_H
-#include <xen/linux/privcmd.h>
+# include <xen/linux/privcmd.h>
#else
-#ifdef HAVE_XEN_SYS_PRIVCMD_H
-#include <xen/sys/privcmd.h>
-#endif
+# ifdef HAVE_XEN_SYS_PRIVCMD_H
+# include <xen/sys/privcmd.h>
+# endif
#endif
/* required for shutdown flags */
@@ -79,7 +79,7 @@ typedef struct v0_hypercall_struct {
} v0_hypercall_t;
#ifdef __linux__
-#define XEN_V0_IOCTL_HYPERCALL_CMD \
+# define XEN_V0_IOCTL_HYPERCALL_CMD \
_IOC(_IOC_NONE, 'P', 0, sizeof(v0_hypercall_t))
/* the new one */
typedef struct v1_hypercall_struct
@@ -87,26 +87,26 @@ typedef struct v1_hypercall_struct
uint64_t op;
uint64_t arg[5];
} v1_hypercall_t;
-#define XEN_V1_IOCTL_HYPERCALL_CMD \
+# define XEN_V1_IOCTL_HYPERCALL_CMD \
_IOC(_IOC_NONE, 'P', 0, sizeof(v1_hypercall_t))
typedef v1_hypercall_t hypercall_t;
#elif defined(__sun)
typedef privcmd_hypercall_t hypercall_t;
#else
-#error "unsupported platform"
+# error "unsupported platform"
#endif
#ifndef __HYPERVISOR_sysctl
-#define __HYPERVISOR_sysctl 35
+# define __HYPERVISOR_sysctl 35
#endif
#ifndef __HYPERVISOR_domctl
-#define __HYPERVISOR_domctl 36
+# define __HYPERVISOR_domctl 36
#endif
#ifdef WITH_RHEL5_API
-#define SYS_IFACE_MIN_VERS_NUMA 3
+# define SYS_IFACE_MIN_VERS_NUMA 3
#else
-#define SYS_IFACE_MIN_VERS_NUMA 4
+# define SYS_IFACE_MIN_VERS_NUMA 4
#endif
/* xen-unstable changeset 19788 removed MAX_VIRT_CPUS from public
@@ -114,7 +114,7 @@ typedef privcmd_hypercall_t hypercall_t;
* Ensure MAX_VIRT_CPUS is defined accordingly.
*/
#if !defined(MAX_VIRT_CPUS) && defined(XEN_LEGACY_MAX_VCPUS)
-#define MAX_VIRT_CPUS XEN_LEGACY_MAX_VCPUS
+# define MAX_VIRT_CPUS XEN_LEGACY_MAX_VCPUS
#endif
static int xen_ioctl_hypercall_cmd = 0;
@@ -141,16 +141,16 @@ static regex_t xen_cap_rec;
* The content of the structures for a getdomaininfolist system hypercall
*/
#ifndef DOMFLAGS_DYING
-#define DOMFLAGS_DYING (1<<0) /* Domain is scheduled to die. */
-#define DOMFLAGS_HVM (1<<1) /* Domain is HVM */
-#define DOMFLAGS_SHUTDOWN (1<<2) /* The guest OS has shut down. */
-#define DOMFLAGS_PAUSED (1<<3) /* Currently paused by control software. */
-#define DOMFLAGS_BLOCKED (1<<4) /* Currently blocked pending an event. */
-#define DOMFLAGS_RUNNING (1<<5) /* Domain is currently running. */
-#define DOMFLAGS_CPUMASK 255 /* CPU to which this domain is bound. */
-#define DOMFLAGS_CPUSHIFT 8
-#define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code. */
-#define DOMFLAGS_SHUTDOWNSHIFT 16
+# define DOMFLAGS_DYING (1<<0) /* Domain is scheduled to die. */
+# define DOMFLAGS_HVM (1<<1) /* Domain is HVM */
+# define DOMFLAGS_SHUTDOWN (1<<2) /* The guest OS has shut down. */
+# define DOMFLAGS_PAUSED (1<<3) /* Currently paused by control software. */
+# define DOMFLAGS_BLOCKED (1<<4) /* Currently blocked pending an event. */
+# define DOMFLAGS_RUNNING (1<<5) /* Domain is currently running. */
+# define DOMFLAGS_CPUMASK 255 /* CPU to which this domain is bound. */
+# define DOMFLAGS_CPUSHIFT 8
+# define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code. */
+# define DOMFLAGS_SHUTDOWNSHIFT 16
#endif
/*
@@ -158,10 +158,10 @@ static regex_t xen_cap_rec;
* They are defined in xen/sched.h
*/
#ifndef SHUTDOWN_poweroff
-#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
-#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
-#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
-#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
+# define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
+# define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
+# define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
+# define SHUTDOWN_crash 3 /* Tell controller we've crashed. */
#endif
#define XEN_V0_OP_GETDOMAININFOLIST 38
@@ -748,12 +748,12 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
#ifdef __linux__
-#define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
-#define HYPERVISOR_CAPABILITIES "/sys/hypervisor/properties/capabilities"
+# define XEN_HYPERVISOR_SOCKET "/proc/xen/privcmd"
+# define HYPERVISOR_CAPABILITIES "/sys/hypervisor/properties/capabilities"
#elif defined(__sun)
-#define XEN_HYPERVISOR_SOCKET "/dev/xen/privcmd"
+# define XEN_HYPERVISOR_SOCKET "/dev/xen/privcmd"
#else
-#error "unsupported platform"
+# error "unsupported platform"
#endif
#ifndef PROXY
@@ -1430,7 +1430,7 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
const char *path,
struct _virDomainBlockStats *stats)
{
-#ifdef __linux__
+# ifdef __linux__
xenUnifiedPrivatePtr priv;
int ret;
@@ -1440,12 +1440,12 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
ret = xenLinuxDomainBlockStats (priv, dom, path, stats);
xenUnifiedUnlock(priv);
return ret;
-#else
+# else
virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"block statistics not supported on this platform",
dom->id);
return -1;
-#endif
+# endif
}
/* Paths have the form vif<domid>.<n> (this interface checks that
@@ -1460,7 +1460,7 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
const char *path,
struct _virDomainInterfaceStats *stats)
{
-#ifdef __linux__
+# ifdef __linux__
int rqdomid, device;
/* Verify that the vif requested is one belonging to the current
@@ -1478,11 +1478,11 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
}
return linuxDomainInterfaceStats(path, stats);
-#else
+# else
virXenErrorFunc (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__,
"/proc/net/dev: Interface not found", 0);
return -1;
-#endif
+# endif
}
/**
diff --git a/src/xen/xen_hypervisor.h b/src/xen/xen_hypervisor.h
index 4504733..7cc39db 100644
--- a/src/xen/xen_hypervisor.h
+++ b/src/xen/xen_hypervisor.h
@@ -9,13 +9,13 @@
*/
#ifndef __VIR_XEN_INTERNAL_H__
-#define __VIR_XEN_INTERNAL_H__
+# define __VIR_XEN_INTERNAL_H__
-#include <libxml/uri.h>
+# include <libxml/uri.h>
-#include "internal.h"
-#include "capabilities.h"
-#include "driver.h"
+# include "internal.h"
+# include "capabilities.h"
+# include "driver.h"
extern struct xenUnifiedDriver xenHypervisorDriver;
int xenHypervisorInit (void);
diff --git a/src/xen/xen_inotify.h b/src/xen/xen_inotify.h
index 48490e7..328fa5d 100644
--- a/src/xen/xen_inotify.h
+++ b/src/xen/xen_inotify.h
@@ -20,10 +20,10 @@
* Author: Ben Guthro
*/
#ifndef __VIR_XEN_INOTIFY_H__
-#define __VIR_XEN_INOTIFY_H__
+# define __VIR_XEN_INOTIFY_H__
-#include "internal.h"
-#include "driver.h"
+# include "internal.h"
+# include "driver.h"
extern struct xenUnifiedDriver xenInotifyDriver;
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 8b4e49e..85ae2a1 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -55,17 +55,17 @@
/*
* The number of Xen scheduler parameters
*/
-#define XEN_SCHED_SEDF_NPARAM 6
-#define XEN_SCHED_CRED_NPARAM 2
+# define XEN_SCHED_SEDF_NPARAM 6
+# define XEN_SCHED_CRED_NPARAM 2
#endif /* PROXY */
#ifdef WITH_RHEL5_API
-#define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
-#define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
+# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
+# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
#else
-#define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
-#define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
+# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
+# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
#endif
diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h
index 8b00737..483253f 100644
--- a/src/xen/xend_internal.h
+++ b/src/xen/xend_internal.h
@@ -14,24 +14,24 @@
*/
#ifndef __XEND_INTERNAL_H_
-#define __XEND_INTERNAL_H_
-
-#include <sys/types.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <libxml/uri.h>
-
-#include "internal.h"
-#include "capabilities.h"
-#include "domain_conf.h"
-#include "driver.h"
-#include "buf.h"
-
-#ifdef __sun
-#define DEFAULT_VIF_SCRIPT "vif-vnic"
-#else
-#define DEFAULT_VIF_SCRIPT "vif-bridge"
-#endif
+# define __XEND_INTERNAL_H_
+
+# include <sys/types.h>
+# include <stdint.h>
+# include <stdbool.h>
+# include <libxml/uri.h>
+
+# include "internal.h"
+# include "capabilities.h"
+# include "domain_conf.h"
+# include "driver.h"
+# include "buf.h"
+
+# ifdef __sun
+# define DEFAULT_VIF_SCRIPT "vif-vnic"
+# else
+# define DEFAULT_VIF_SCRIPT "vif-bridge"
+# endif
int
xenDaemonOpen_unix(virConnectPtr conn, const char *path);
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 2d0f1d5..3d4624d 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -50,11 +50,11 @@
#define VIR_FROM_THIS VIR_FROM_XENXM
#ifdef WITH_RHEL5_API
-#define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
-#define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
+# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
+# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 2
#else
-#define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
-#define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
+# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 3
+# define XEND_CONFIG_MIN_VERS_PVFB_NEWCONF 3
#endif
/* The true Xen limit varies but so far is always way
diff --git a/src/xen/xm_internal.h b/src/xen/xm_internal.h
index 7d52ac8..37132ef 100644
--- a/src/xen/xm_internal.h
+++ b/src/xen/xm_internal.h
@@ -23,12 +23,12 @@
*/
#ifndef _LIBVIRT_XM_INTERNAL_H_
-#define _LIBVIRT_XM_INTERNAL_H_
+# define _LIBVIRT_XM_INTERNAL_H_
-#include "internal.h"
-#include "driver.h"
-#include "conf.h"
-#include "domain_conf.h"
+# include "internal.h"
+# include "driver.h"
+# include "conf.h"
+# include "domain_conf.h"
extern struct xenUnifiedDriver xenXMDriver;
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index 0c62565..3b241c7 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -447,7 +447,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
info->memory = 0;
info->maxMem = 0;
}
-#if 0
+# if 0
/* doesn't seems to work */
tmp = virDomainDoStoreQuery(domain->conn, domain->id, "cpu_time");
if (tmp != NULL) {
@@ -456,7 +456,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
} else {
info->cpuTime = 0;
}
-#endif
+# endif
snprintf(request, 199, "/local/domain/%d/cpu", domain->id);
request[199] = 0;
tmp2 = virConnectDoStoreList(domain->conn, request, &nb_vcpus);
@@ -689,10 +689,10 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
if ((endptr == idlist[i]) || (*endptr != 0)) {
goto done;
}
-#if 0
+# if 0
if (virConnectCheckStoreID(conn, (int) id) < 0)
continue;
-#endif
+# endif
snprintf(prop, 199, "/local/domain/%s/name", idlist[i]);
prop[199] = 0;
tmp = xs_read(priv->xshandle, 0, prop, &len);
diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h
index 6e0f40d..d7a110d 100644
--- a/src/xen/xs_internal.h
+++ b/src/xen/xs_internal.h
@@ -9,10 +9,10 @@
*/
#ifndef __VIR_XS_INTERNAL_H__
-#define __VIR_XS_INTERNAL_H__
+# define __VIR_XS_INTERNAL_H__
-#include "internal.h"
-#include "driver.h"
+# include "internal.h"
+# include "driver.h"
extern struct xenUnifiedDriver xenStoreDriver;
int xenStoreInit (void);
diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c
index d8cfa2a..10f6a3c 100644
--- a/tests/esxutilstest.c
+++ b/tests/esxutilstest.c
@@ -2,15 +2,15 @@
#ifdef WITH_ESX
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+# include <stdio.h>
+# include <string.h>
+# include <unistd.h>
-#include "internal.h"
-#include "memory.h"
-#include "testutils.h"
-#include "util.h"
-#include "esx/esx_util.h"
+# include "internal.h"
+# include "memory.h"
+# include "testutils.h"
+# include "util.h"
+# include "esx/esx_util.h"
static char *progname;
@@ -183,7 +183,7 @@ mymain(int argc, char **argv)
virSetErrorFunc(NULL, testQuietError);
- #define DO_TEST(_name) \
+# define DO_TEST(_name) \
do { \
if (virtTestRun("VMware "#_name, 1, test##_name, \
NULL) < 0) { \
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index b3b91ad..a6b9b7e 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -23,7 +23,7 @@ mymain(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
static char *progname;
static char *abs_srcdir;
-#define MAX_FILE 4096
+# define MAX_FILE 4096
extern int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo);
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 50c4453..2197438 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -10,17 +10,17 @@
#ifdef WITH_QEMU
-#include "internal.h"
-#include "testutils.h"
-#include "qemu/qemu_conf.h"
+# include "internal.h"
+# include "testutils.h"
+# include "qemu/qemu_conf.h"
-#include "testutilsqemu.h"
+# include "testutilsqemu.h"
static char *progname;
static char *abs_srcdir;
static struct qemud_driver driver;
-#define MAX_FILE 4096
+# define MAX_FILE 4096
static int blankProblemElements(char *data)
{
@@ -114,7 +114,7 @@ mymain(int argc, char **argv)
if((driver.stateDir = strdup("/nowhere")) == NULL)
return EXIT_FAILURE;
-#define DO_TEST_FULL(name, extraFlags, migrateFrom) \
+# define DO_TEST_FULL(name, extraFlags, migrateFrom) \
do { \
const struct testInfo info = { name, extraFlags, migrateFrom }; \
if (virtTestRun("QEMU ARGV-2-XML " name, \
@@ -122,7 +122,7 @@ mymain(int argc, char **argv)
ret = -1; \
} while (0)
-#define DO_TEST(name, extraFlags) \
+# define DO_TEST(name, extraFlags) \
DO_TEST_FULL(name, extraFlags, NULL)
setenv("PATH", "/bin", 1);
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index e61f4e2..dfdac75 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -2,13 +2,13 @@
#ifdef WITH_QEMU
-#include <stdio.h>
-#include <stdlib.h>
+# include <stdio.h>
+# include <stdlib.h>
-#include "testutils.h"
-#include "qemu/qemu_conf.h"
+# include "testutils.h"
+# include "qemu/qemu_conf.h"
-#define MAX_HELP_OUTPUT_SIZE 1024*64
+# define MAX_HELP_OUTPUT_SIZE 1024*64
struct testInfo {
const char *name;
@@ -101,7 +101,7 @@ mymain(int argc, char **argv)
if (!abs_srcdir)
abs_srcdir = getcwd(cwd, sizeof(cwd));
-#define DO_TEST(name, flags, version, is_kvm, kvm_version) \
+# define DO_TEST(name, flags, version, is_kvm, kvm_version) \
do { \
const struct testInfo info = { name, flags, version, is_kvm, kvm_version }; \
if (virtTestRun("QEMU Help String Parsing " name, \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7a33522..4ca946a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -10,18 +10,18 @@
#ifdef WITH_QEMU
-#include "internal.h"
-#include "testutils.h"
-#include "qemu/qemu_conf.h"
-#include "datatypes.h"
+# include "internal.h"
+# include "testutils.h"
+# include "qemu/qemu_conf.h"
+# include "datatypes.h"
-#include "testutilsqemu.h"
+# include "testutilsqemu.h"
static char *progname;
static char *abs_srcdir;
static struct qemud_driver driver;
-#define MAX_FILE 4096
+# define MAX_FILE 4096
static int testCompareXMLToArgvFiles(const char *xml,
const char *cmd,
@@ -193,7 +193,7 @@ mymain(int argc, char **argv)
if ((driver.hugepage_path = strdup("/dev/hugepages/libvirt/qemu")) == NULL)
return EXIT_FAILURE;
-#define DO_TEST_FULL(name, extraFlags, migrateFrom) \
+# define DO_TEST_FULL(name, extraFlags, migrateFrom) \
do { \
const struct testInfo info = { name, extraFlags, migrateFrom }; \
if (virtTestRun("QEMU XML-2-ARGV " name, \
@@ -201,7 +201,7 @@ mymain(int argc, char **argv)
ret = -1; \
} while (0)
-#define DO_TEST(name, extraFlags) \
+# define DO_TEST(name, extraFlags) \
DO_TEST_FULL(name, extraFlags, NULL)
/* Unset or set all envvars here that are copied in qemudBuildCommandLine
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index ace2be8..1ac6edc 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -10,16 +10,16 @@
#ifdef WITH_QEMU
-#include "internal.h"
-#include "testutils.h"
-#include "qemu/qemu_conf.h"
-#include "testutilsqemu.h"
+# include "internal.h"
+# include "testutils.h"
+# include "qemu/qemu_conf.h"
+# include "testutilsqemu.h"
static char *progname;
static char *abs_srcdir;
static struct qemud_driver driver;
-#define MAX_FILE 4096
+# define MAX_FILE 4096
static int testCompareXMLToXMLFiles(const char *xml) {
@@ -80,7 +80,7 @@ mymain(int argc, char **argv)
if ((driver.caps = testQemuCapsInit()) == NULL)
return (EXIT_FAILURE);
-#define DO_TEST(name) \
+# define DO_TEST(name) \
if (virtTestRun("QEMU XML-2-XML " name, \
1, testCompareXMLToXMLHelper, (name)) < 0) \
ret = -1
diff --git a/tests/statstest.c b/tests/statstest.c
index c7a5430..5fad190 100644
--- a/tests/statstest.c
+++ b/tests/statstest.c
@@ -58,7 +58,7 @@ mymain(int argc ATTRIBUTE_UNUSED,
if (!virTestGetDebug())
virSetErrorFunc(NULL, testQuietError);
-#define DO_TEST(dev, num) \
+# define DO_TEST(dev, num) \
do { \
struct testInfo info = { dev, num }; \
if (virtTestRun("Device " dev " -> " # num, \
diff --git a/tests/testutils.c b/tests/testutils.c
index f31099e..8764673 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -16,10 +16,10 @@
#include <sys/types.h>
#include <sys/stat.h>
#ifndef WIN32
-#include <sys/wait.h>
+# include <sys/wait.h>
#endif
#ifdef HAVE_REGEX_H
-#include <regex.h>
+# include <regex.h>
#endif
#include <unistd.h>
#include <string.h>
@@ -33,11 +33,11 @@
#include "virterror_internal.h"
#if TEST_OOM_TRACE
-#include <execinfo.h>
+# include <execinfo.h>
#endif
#ifdef HAVE_PATHS_H
-#include <paths.h>
+# include <paths.h>
#endif
#define GETTIMEOFDAY(T) gettimeofday(T, NULL)
@@ -204,9 +204,9 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
int stdinfd = -1;
const char *const env[] = {
"LANG=C",
-#if WITH_DRIVER_MODULES
+# if WITH_DRIVER_MODULES
"LIBVIRT_DRIVER_DIR=" TEST_DRIVER_DIR,
-#endif
+# endif
NULL
};
@@ -445,10 +445,10 @@ int virtTestMain(int argc,
if (ret != EXIT_SUCCESS)
goto cleanup;
-#if TEST_OOM_TRACE
+# if TEST_OOM_TRACE
if (virTestGetDebug())
virAllocTestHook(virtTestErrorHook, NULL);
-#endif
+# endif
if (testOOM) {
/* Makes next test runs quiet... */
diff --git a/tests/testutils.h b/tests/testutils.h
index 1f03746..95f1680 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -9,11 +9,11 @@
*/
#ifndef __VIT_TEST_UTILS_H__
-#define __VIT_TEST_UTILS_H__
+# define __VIT_TEST_UTILS_H__
-#include <stdio.h>
+# include <stdio.h>
-#define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
+# define EXIT_AM_SKIP 77 /* tell Automake we're skipping a test */
double virtTestCountAverage(double *items,
int nitems);
@@ -44,7 +44,7 @@ int virtTestMain(int argc,
char **argv,
int (*func)(int, char **));
-#define VIRT_TEST_MAIN(func) \
+# define VIRT_TEST_MAIN(func) \
int main(int argc, char **argv) { \
return virtTestMain(argc,argv, func); \
}
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index b07ab48..8dd26d4 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -1,11 +1,11 @@
#include <config.h>
#ifdef WITH_QEMU
-#include <sys/utsname.h>
-#include <stdlib.h>
+# include <sys/utsname.h>
+# include <stdlib.h>
-#include "testutilsqemu.h"
-#include "testutils.h"
-#include "memory.h"
+# include "testutilsqemu.h"
+# include "testutils.h"
+# include "memory.h"
static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
{
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 3980993..b4eb5d5 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -2,19 +2,19 @@
#ifdef WITH_ESX
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+# include <stdio.h>
+# include <string.h>
+# include <unistd.h>
-#include "internal.h"
-#include "memory.h"
-#include "testutils.h"
-#include "esx/esx_vmx.h"
+# include "internal.h"
+# include "memory.h"
+# include "testutils.h"
+# include "esx/esx_vmx.h"
static char *progname = NULL;
static char *abs_srcdir = NULL;
-#define MAX_FILE 4096
+# define MAX_FILE 4096
static int
testCompareFiles(const char *vmx, const char *xml, esxVI_APIVersion apiVersion)
@@ -107,7 +107,7 @@ mymain(int argc, char **argv)
return EXIT_FAILURE;
}
- #define DO_TEST(_in, _out, _version) \
+# define DO_TEST(_in, _out, _version) \
do { \
struct testInfo info = { _in, _out, _version }; \
virResetLastError(); \
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index 8e0acbd..b8b9d6f 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -2,20 +2,20 @@
#ifdef WITH_ESX
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+# include <stdio.h>
+# include <string.h>
+# include <unistd.h>
-#include "internal.h"
-#include "memory.h"
-#include "testutils.h"
-#include "esx/esx_vmx.h"
+# include "internal.h"
+# include "memory.h"
+# include "testutils.h"
+# include "esx/esx_vmx.h"
static char *progname = NULL;
static char *abs_srcdir = NULL;
static virCapsPtr caps = NULL;
-#define MAX_FILE 4096
+# define MAX_FILE 4096
static void
testESXCapsInit(void)
@@ -154,7 +154,7 @@ mymain(int argc, char **argv)
return EXIT_FAILURE;
}
- #define DO_TEST(_in, _out, _version) \
+# define DO_TEST(_in, _out, _version) \
do { \
struct testInfo info = { _in, _out, _version }; \
virResetLastError(); \
diff --git a/tools/console.c b/tools/console.c
index 3bb97ec..4201ba4 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -24,31 +24,31 @@
#ifndef __MINGW32__
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <termios.h>
-#include <poll.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <signal.h>
-
-#include "console.h"
-#include "internal.h"
-#include "logging.h"
-#include "util.h"
+# include <stdio.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <fcntl.h>
+# include <termios.h>
+# include <poll.h>
+# include <string.h>
+# include <errno.h>
+# include <unistd.h>
+# include <signal.h>
+
+# include "console.h"
+# include "internal.h"
+# include "logging.h"
+# include "util.h"
/* ie Ctrl-] as per telnet */
-#define CTRL_CLOSE_BRACKET '\35'
+# define CTRL_CLOSE_BRACKET '\35'
static int got_signal = 0;
static void do_signal(int sig ATTRIBUTE_UNUSED) {
got_signal = 1;
}
-#ifndef HAVE_CFMAKERAW
+# ifndef HAVE_CFMAKERAW
static void
cfmakeraw (struct termios *attr)
{
@@ -59,7 +59,7 @@ cfmakeraw (struct termios *attr)
attr->c_cflag &= ~(CSIZE | PARENB);
attr->c_cflag |= CS8;
}
-#endif /* !HAVE_CFMAKERAW */
+# endif /* !HAVE_CFMAKERAW */
int vshRunConsole(const char *tty) {
int ttyfd, ret = -1;
diff --git a/tools/console.h b/tools/console.h
index 6bb1865..683f1cb 100644
--- a/tools/console.h
+++ b/tools/console.h
@@ -21,12 +21,12 @@
*/
#ifndef __VIR_CONSOLE_H__
-#define __VIR_CONSOLE_H__
+# define __VIR_CONSOLE_H__
-#ifndef __MINGW32__
+# ifndef __MINGW32__
int vshRunConsole(const char *tty);
-#endif /* !__MINGW32__ */
+# endif /* !__MINGW32__ */
#endif /* __VIR_CONSOLE_H__ */
diff --git a/tools/virsh.c b/tools/virsh.c
index 01e31c8..b5b7ef4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -37,8 +37,8 @@
#include <libxml/xmlsave.h>
#ifdef HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
-#include <readline/history.h>
+# include <readline/readline.h>
+# include <readline/history.h>
#endif
#include "internal.h"
@@ -52,8 +52,8 @@
static char *progname;
#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
+# define TRUE 1
+# define FALSE 0
#endif
#define VIRSH_MAX_XML_FILE 10*1024*1024
@@ -8772,7 +8772,7 @@ vshInit(vshControl *ctl)
}
#ifndef O_SYNC
-#define O_SYNC 0
+# define O_SYNC 0
#endif
#define LOGFILE_FLAGS (O_WRONLY | O_APPEND | O_CREAT | O_SYNC)
--
1.6.6.1
3
11
The udev node device driver tries to glean a few tidbits of information
from /sys/devices/virtual/dmi/id. If either the BIOS or the kernel does
not support DMI, libvirtd logs the error
Failed to get udev device for syspath '/sys/devices/virtual/dmi/id' or '/sys/class/dmi/id'
and refuses to start.
This seems a bit extreme; information obtained from DMI, like the system
board vendor and BIOS version, is useful but not critical to libvirt's
operation.
This patch eliminates the hard dependency on DMI. On systems without
DMI, libvirtd logs a warning, and leaves the "computer" node device's
properties empty.
Signed-off-by: Ed Swierk <eswierk(a)aristanetworks.com>
---
Index: libvirt-0.7.6/src/node_device/node_device_udev.c
===================================================================
--- libvirt-0.7.6.orig/src/node_device/node_device_udev.c
+++ libvirt-0.7.6/src/node_device/node_device_udev.c
@@ -1471,9 +1471,9 @@ static int udevSetupSystemDev(void)
if (device == NULL) {
device = udev_device_new_from_syspath(udev, DMI_DEVPATH_FALLBACK);
if (device == NULL) {
- VIR_ERROR("Failed to get udev device for syspath '%s' or '%s'",
- DMI_DEVPATH, DMI_DEVPATH_FALLBACK);
- goto out;
+ VIR_WARN("Failed to get udev device for syspath '%s' or '%s'",
+ DMI_DEVPATH, DMI_DEVPATH_FALLBACK);
+ goto out2;
}
}
@@ -1532,6 +1532,7 @@ static int udevSetupSystemDev(void)
udev_device_unref(device);
+out2:
dev = virNodeDeviceAssignDef(&driverState->devs, def);
if (dev == NULL) {
VIR_ERROR("Failed to create device for '%s'", def->name);
4
8
Hi guys! I'm Paolo, and I'm working on my graduation thesis.
One of my thesis' subject is to define a migration check which will be
used to perform "secure migration" using IMA measurement.
Someone can suggest me a documentation (code examples, technical
paper, etc) about migration cheks?
Now I'm analyzing libvirt source code to uderstand migration-cheks
mechanism, but the analysis has a ways to go......
Thanks!
1
0
11 Mar '10
This is a usability issue for virsh in case of disconnections,
for example if the remote libvirtd is restarted:
https://bugzilla.redhat.com/show_bug.cgi?id=526656
the patch catch those and tries to automatically reconnect instead
of virsh exitting. The typical interaction with this patch is that
the command fails, but virsh automatically reconnects instead of
exitting, but it won't try to restart the failed command (since this
could have significant side effects). Example of such interraction:
-------------------------------------------------------
virsh # list --all
Id Name State
----------------------------------
- RHEL-5.4-64 shut off
- WinXP shut off
virsh # list --all
error: Failed to list active domains
error: cannot send data: Broken pipe
error: Reconnected to the hypervisor
virsh # list --all
Id Name State
----------------------------------
- RHEL-5.4-64 shut off
- WinXP shut off
virsh #
-------------------------------------------------------
The only thing I'm unsure is if the signal handler should be reset
once it was received once. I don't in this patch and that seems to
work fine, but I somehow remember the fact that in some circumstances
a signal handler needs to be rearmed when received once. As is this
seems to work fine with SIGPIPE and linux.
Make virsh reconnect when loosing connection
Right now when the connected libvirtd restarts virsh gets a SIGPIPE
and dies, this change the behaviour to try to reconnect if the
signal was received or command error indicated a connection or RPC
failure. Note that the failing command is not restarted.
* tools/virsh.c: catch SIGPIPE signals as well as connection related
failures, add some automatic reconnection code and appropriate error
messages.
diff --git a/tools/virsh.c b/tools/virsh.c
index 65487ed..2ec9cfc 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <sys/stat.h>
#include <inttypes.h>
+#include <signal.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
@@ -397,6 +398,58 @@ out:
last_error = NULL;
}
+/*
+ * Detection of disconnections and automatic reconnection support
+ */
+static int disconnected = 0; /* we may have been disconnected */
+
+/*
+ * vshCatchDisconnect:
+ *
+ * We get here when a SIGPIPE is being raised, we can't do much in the
+ * handler, just save the fact it was raised
+ */
+static void vshCatchDisconnect(int sig, siginfo_t * siginfo,
+ void* context ATTRIBUTE_UNUSED) {
+ if ((sig == SIGPIPE) || (siginfo->si_signo == SIGPIPE))
+ disconnected++;
+}
+
+/*
+ * vshSetupSignals:
+ *
+ * Catch SIGPIPE signals which may arise when desconnection from libvirtd occurs */
+static int
+vshSetupSignals(void) {
+ struct sigaction sig_action;
+
+ sig_action.sa_sigaction = vshCatchDisconnect;
+ sig_action.sa_flags = SA_SIGINFO;
+ sigemptyset(&sig_action.sa_mask);
+
+ sigaction(SIGPIPE, &sig_action, NULL);
+}
+
+/*
+ * vshReconnect:
+ *
+ * Reconnect after an
+ *
+ */
+static int
+vshReconnect(vshControl *ctl) {
+ if (ctl->conn != NULL)
+ virConnectClose(ctl->conn);
+
+ ctl->conn = virConnectOpenAuth(ctl->name,
+ virConnectAuthPtrDefault,
+ ctl->readonly ? VIR_CONNECT_RO : 0);
+ if (!ctl->conn)
+ vshError(ctl, "%s", _("Failed to reconnect to the hypervisor"));
+ else
+ vshError(ctl, "%s", _("Reconnected to the hypervisor"));
+ disconnected = 0;
+}
/* ---------------
* Commands
@@ -8332,6 +8385,9 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
while (cmd) {
struct timeval before, after;
+ if ((ctl->conn == NULL) || (disconnected != 0))
+ vshReconnect(ctl);
+
if (ctl->timing)
GETTIMEOFDAY(&before);
@@ -8343,6 +8399,17 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
if (ret == FALSE)
virshReportError(ctl);
+ /* try to catch automatically disconnections */
+ if ((ret == FALSE) &&
+ ((disconnected != 0) ||
+ ((last_error != NULL) &&
+ (((last_error->code == VIR_ERR_SYSTEM_ERROR) &&
+ (last_error->domain == 13)) ||
+ (last_error->code == VIR_ERR_RPC) ||
+ (last_error->code == VIR_ERR_NO_CONNECT) ||
+ (last_error->code == VIR_ERR_INVALID_CONN)))))
+ vshReconnect(ctl);
+
if (STREQ(cmd->def->name, "quit")) /* hack ... */
return ret;
@@ -8673,9 +8740,11 @@ vshError(vshControl *ctl, const char *format, ...)
{
va_list ap;
- va_start(ap, format);
- vshOutputLogFile(ctl, VSH_ERR_ERROR, format, ap);
- va_end(ap);
+ if (ctl != NULL) {
+ va_start(ap, format);
+ vshOutputLogFile(ctl, VSH_ERR_ERROR, format, ap);
+ va_end(ap);
+ }
fputs(_("error: "), stderr);
@@ -8751,6 +8820,9 @@ vshInit(vshControl *ctl)
/* set up the library error handler */
virSetErrorFunc(NULL, virshErrorHandler);
+ /* set up the signals handlers to catch disconnections */
+ vshSetupSignals();
+
ctl->conn = virConnectOpenAuth(ctl->name,
virConnectAuthPtrDefault,
ctl->readonly ? VIR_CONNECT_RO : 0);
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
2
4
As pointed out by eblake, I made a real hash of the
nodeinfo code with commit
aa2f6f96ddd7a57011c3d25586d588100651feb2. This patch
cleans it up:
1) Do more work at compile time instead of runtime (minor)
2) Properly handle the hex digits that come from
/sys/devices/system/cpu/cpu*/topology/thread_siblings
3) Fix up some error paths that could cause SEGV
4) Used unsigned's for the cpu numbers (cpu -1 doesn't
make any sense)
Along with the recent patch from jdenemar to zero out
the nodeinfo structure, I've re-tested this on the
machines having the problems, and it seems to be good.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/nodeinfo.c | 45 +++++++++++++++++++++++++++++++--------------
1 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 1ee3709..3fabeec 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -63,15 +63,15 @@
int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
virNodeInfoPtr nodeinfo);
-static unsigned long count_thread_siblings(int cpu)
+static unsigned long count_thread_siblings(unsigned int cpu)
{
unsigned long ret = 0;
- char *path = NULL;
- FILE *pathfp = NULL;
+ char *path;
+ FILE *pathfp;
char str[1024];
int i;
- if (virAsprintf(&path, "%s/cpu%d/topology/thread_siblings", CPU_SYS_PATH,
+ if (virAsprintf(&path, CPU_SYS_PATH "/cpu%u/topology/thread_siblings",
cpu) < 0) {
virReportOOMError();
return 0;
@@ -91,8 +91,12 @@ static unsigned long count_thread_siblings(int cpu)
i = 0;
while (str[i] != '\0') {
- if (str[i] != '\n' && str[i] != ',')
+ if (c_isdigit(str[i]))
ret += count_one_bits(str[i] - '0');
+ else if (str[i] >= 'A' && str[i] <= 'F')
+ ret += count_one_bits(str[i] - 'A' + 10);
+ else if (str[i] >= 'a' && str[i] <= 'f')
+ ret += count_one_bits(str[i] - 'a' + 10);
i++;
}
@@ -103,16 +107,16 @@ cleanup:
return ret;
}
-static int parse_socket(int cpu)
+static int parse_socket(unsigned int cpu)
{
- char *path = NULL;
+ char *path;
FILE *pathfp;
char socket_str[1024];
char *tmp;
- int socket;
+ int socket = -1;
- if (virAsprintf(&path, "%s/cpu%d/topology/physical_package_id",
- CPU_SYS_PATH, cpu) < 0) {
+ if (virAsprintf(&path, CPU_SYS_PATH "/cpu%u/topology/physical_package_id",
+ cpu) < 0) {
virReportOOMError();
return -1;
}
@@ -120,7 +124,8 @@ static int parse_socket(int cpu)
pathfp = fopen(path, "r");
if (pathfp == NULL) {
virReportSystemError(errno, _("cannot open %s"), path);
- goto cleanup;
+ VIR_FREE(path);
+ return -1;
}
if (fgets(socket_str, sizeof(socket_str), pathfp) == NULL) {
@@ -147,7 +152,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
char line[1024];
DIR *cpudir = NULL;
struct dirent *cpudirent = NULL;
- int cpu;
+ unsigned int cpu;
unsigned long cur_threads;
int socket;
unsigned long long socket_mask = 0;
@@ -157,7 +162,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
nodeinfo->nodes = nodeinfo->cores = 1;
/* NB: It is impossible to fill our nodes, since cpuinfo
- * has not knowledge of NUMA nodes */
+ * has no knowledge of NUMA nodes */
/* NOTE: hyperthreads are ignored here; they are parsed out of /sys */
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
@@ -220,7 +225,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
return -1;
}
while ((cpudirent = readdir(cpudir))) {
- if (sscanf(cpudirent->d_name, "cpu%d", &cpu) != 1)
+ if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
socket = parse_socket(cpu);
@@ -244,6 +249,18 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
closedir(cpudir);
+ /* there should always be at least one socket and one thread */
+ if (nodeinfo->sockets == 0) {
+ nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no sockets found"));
+ return -1;
+ }
+ if (nodeinfo->threads == 0) {
+ nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no threads found"));
+ return -1;
+ }
+
return 0;
}
--
1.6.6.1
2
2
10 Mar '10
Based on a warning from coverity. The safe* functions
guarantee complete transactions on success, but don't guarantee
freedom from failure.
* src/util/util.h (saferead, safewrite, safezero): Add
ATTRIBUTE_RETURN_CHECK.
* src/remote/remote_driver.c (remoteIO, remoteIOEventLoop): Ignore
some failures.
(remoteIOReadBuffer): Adjust error messages on read failure.
* daemon/event.c (virEventHandleWakeup): Ignore read failure.
---
Changes from previous attempt: rework remote_driver to no longer
trigger 'make syntax-check' failures.
This can wait until after 0.7.7.
daemon/event.c | 5 +++--
src/remote/remote_driver.c | 18 ++++++++++++++----
src/util/util.h | 9 ++++++---
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/daemon/event.c b/daemon/event.c
index 2218a3e..36e9dd3 100644
--- a/daemon/event.c
+++ b/daemon/event.c
@@ -1,13 +1,13 @@
/*
* event.c: event loop for monitoring file handles
*
+ * Copyright (C) 2007, 2010 Red Hat, Inc.
* Copyright (C) 2007 Daniel P. Berrange
- * Copyright (C) 2007 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -30,16 +30,17 @@
#include <errno.h>
#include <unistd.h>
#include "threads.h"
#include "logging.h"
#include "event.h"
#include "memory.h"
#include "util.h"
+#include "ignore-value.h"
#define EVENT_DEBUG(fmt, ...) DEBUG(fmt, __VA_ARGS__)
static int virEventInterruptLocked(void);
/* State for a single file handle being monitored */
struct virEventHandle {
int watch;
@@ -625,17 +626,17 @@ error_unlocked:
static void virEventHandleWakeup(int watch ATTRIBUTE_UNUSED,
int fd,
int events ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
char c;
virEventLock();
- saferead(fd, &c, sizeof(c));
+ ignore_value (saferead(fd, &c, sizeof(c)));
virEventUnlock();
}
int virEventInit(void)
{
if (pthread_mutex_init(&eventLoop.lock, NULL) != 0)
return -1;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b7b2e09..d9cae8b 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7868,26 +7868,35 @@ remoteIOReadBuffer(virConnectPtr conn,
if (ret == -1) {
if (errno == EINTR)
goto resend;
if (errno == EWOULDBLOCK)
return 0;
char errout[1024] = "\0";
if (priv->errfd != -1) {
- saferead(priv->errfd, errout, sizeof(errout));
+ if (saferead(priv->errfd, errout, sizeof(errout)) < 0) {
+ virReportSystemError(errno, "%s",
+ _("cannot recv data: unknown reason"));
+ return -1;
+ }
}
virReportSystemError(errno,
_("cannot recv data: %s"), errout);
} else {
char errout[1024] = "\0";
if (priv->errfd != -1) {
- saferead(priv->errfd, errout, sizeof(errout));
+ if (saferead(priv->errfd, errout, sizeof(errout)) < 0) {
+ errorf (in_open ? NULL : conn,
+ VIR_ERR_SYSTEM_ERROR,
+ _("server closed connection: unknown reason"));
+ return -1;
+ }
}
errorf (in_open ? NULL : conn,
VIR_ERR_SYSTEM_ERROR,
_("server closed connection: %s"), errout);
}
return -1;
}
@@ -8490,17 +8499,18 @@ remoteIOEventLoop(virConnectPtr conn,
goto repoll;
ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
remoteDriverLock(priv);
if (fds[1].revents) {
DEBUG0("Woken up from poll by other thread");
- saferead(priv->wakeupReadFD, &ignore, sizeof(ignore));
+ ignore_value (saferead(priv->wakeupReadFD, &ignore,
+ sizeof(ignore)));
}
if (ret < 0) {
if (errno == EWOULDBLOCK)
continue;
virReportSystemError(errno,
"%s", _("poll on socket failed"));
goto error;
@@ -8634,17 +8644,17 @@ remoteIO(virConnectPtr conn,
while (tmp && tmp->next)
tmp = tmp->next;
if (tmp)
tmp->next = thiscall;
else
priv->waitDispatch = thiscall;
/* Force other thread to wakup from poll */
- safewrite(priv->wakeupSendFD, &ignore, sizeof(ignore));
+ ignore_value (safewrite(priv->wakeupSendFD, &ignore, sizeof(ignore)));
DEBUG("Going to sleep %d %p %p", thiscall->proc_nr, priv->waitDispatch, thiscall);
/* Go to sleep while other thread is working... */
if (virCondWait(&thiscall->cond, &priv->lock) < 0) {
if (priv->waitDispatch == thiscall) {
priv->waitDispatch = thiscall->next;
} else {
tmp = priv->waitDispatch;
diff --git a/src/util/util.h b/src/util/util.h
index cc05abe..34b77fa 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -1,12 +1,13 @@
/*
* utils.h: common, generic utility functions
*
+ * Copyright (C) 2010 Red Hat, Inc.
* Copyright (C) 2006, 2007 Binary Karma
* Copyright (C) 2006 Shuveb Hussain
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
@@ -26,19 +27,21 @@
#define __VIR_UTIL_H__
#include "verify.h"
#include "internal.h"
#include <unistd.h>
#include <sys/select.h>
#include <sys/types.h>
-int saferead(int fd, void *buf, size_t count);
-ssize_t safewrite(int fd, const void *buf, size_t count);
-int safezero(int fd, int flags, off_t offset, off_t len);
+int saferead(int fd, void *buf, size_t count) ATTRIBUTE_RETURN_CHECK;
+ssize_t safewrite(int fd, const void *buf, size_t count)
+ ATTRIBUTE_RETURN_CHECK;
+int safezero(int fd, int flags, off_t offset, off_t len)
+ ATTRIBUTE_RETURN_CHECK;
enum {
VIR_EXEC_NONE = 0,
VIR_EXEC_NONBLOCK = (1 << 0),
VIR_EXEC_DAEMON = (1 << 1),
VIR_EXEC_CLEAR_CAPS = (1 << 2),
};
--
1.6.6.1
2
8
10 Mar '10
Otherwise, a malicious packet could cause a DoS via spurious
out-of-memory failure.
* src/uml/uml_driver.c (umlMonitorCommand): Validate that incoming
data is reliable before using it to allocate/dereference memory.
Don't report bogus errno on short read.
Reported by Jim Meyering.
---
src/uml/uml_driver.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index eec239f..4a5db9d 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -740,15 +740,15 @@ static int umlMonitorCommand(virConnectPtr conn,
if (nbytes < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;
- virReportSystemError(errno,
- _("cannot read reply %s"),
- cmd);
+ virReportSystemError(errno, _("cannot read reply %s"), cmd);
goto error;
}
if (nbytes < sizeof res) {
- virReportSystemError(errno,
- _("incomplete reply %s"),
- cmd);
+ virReportSystemError(0, _("incomplete reply %s"), cmd);
+ goto error;
+ }
+ if (sizeof res.data < res.length) {
+ virReportSystemError(0, _("invalid length in reply %s"), cmd);
goto error;
}
--
1.6.6.1
2
3
[libvirt] [RFC][PATCH v2 2/2] Automatically recreate macvtap interface and reconnect to qemu
by Ed Swierk 10 Mar '10
by Ed Swierk 10 Mar '10
10 Mar '10
(See the PATCH 0 email for further discussion.)
---
The libvirt qemu driver creates a macvtap interface for each defined
"direct" network interface, but unlike a tap interface that is owned
by the process that creates it, a macvtap interface vanishes when the
underlying network device goes away. When this happens, qemu is left
holding a file descriptor for a nonexistent tap interface.
This patch implements dynamically recreating a macvtap interface when
the underlying network device reappears, and reconnecting it to the
still-running qemu process.
It's a total hack job: after starting qemu, it spawns a thread
that wakes up once per second and attempts to create a new macvtap
interface for each defined direct interface. If the macvtap
interface already exists (because it never disappeared) or can't
be created (because the underlying network device doesn't exist),
this is a no-op. Only when the underlying network device reappears
does the reconnection complete.
At minimum, this should be done without the once-per-second polling.
Index: libvirt-0.7.7/src/qemu/qemu_driver.c
===================================================================
--- libvirt-0.7.7.orig/src/qemu/qemu_driver.c
+++ libvirt-0.7.7/src/qemu/qemu_driver.c
@@ -83,6 +83,7 @@
#include "xml.h"
#include "cpu/cpu.h"
#include "macvtap.h"
+#include "threads.h"
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -107,6 +108,8 @@ struct _qemuDomainObjPrivate {
qemuDomainPCIAddressSetPtr pciaddrs;
int persistentAddrs;
+
+ pthread_t reconnectNetBackendsThread;
};
static int qemudShutdown(void);
@@ -151,6 +154,8 @@ static int qemudDomainDisconnectNetBacke
virDomainObjPtr vm,
virDomainNetDefPtr net);
+static void *qemudDomainReconnectNetBackends(void *opaque);
+
static struct qemud_driver *qemu_driver = NULL;
@@ -2697,6 +2702,7 @@ static int qemudStartVMDaemon(virConnect
char *pidfile = NULL;
int logfile;
qemuDomainObjPrivatePtr priv = vm->privateData;
+ pthread_attr_t threadAttr;
struct qemudHookData hookData;
hookData.conn = conn;
@@ -2950,6 +2956,15 @@ static int qemudStartVMDaemon(virConnect
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
goto abort;
+ pthread_attr_init(&threadAttr);
+ pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED);
+ if (pthread_create(&priv->reconnectNetBackendsThread, &threadAttr,
+ qemudDomainReconnectNetBackends, vm->def->uuid)) {
+ pthread_attr_destroy(&threadAttr);
+ goto abort;
+ }
+ pthread_attr_destroy(&threadAttr);
+
return 0;
cleanup:
@@ -6248,7 +6263,7 @@ static int qemudDomainConnectNetBackend(
unsigned long long qemuCmdFlags)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- char *tapfd_name = NULL;
+ char *hostnet_name = NULL;
int tapfd = -1;
char *netstr = NULL;
int ret = -1;
@@ -6286,27 +6301,30 @@ static int qemudDomainConnectNetBackend(
if (tapfd < 0)
return -1;
- if (virAsprintf(&tapfd_name, "fd-%s", net->info.alias) < 0) {
+ if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0) {
virReportOOMError();
close(tapfd);
return -1;
}
if (!(netstr = qemuBuildHostNetStr(net, ' ',
- vlan, tapfd_name))) {
- VIR_FREE(tapfd_name);
+ vlan, hostnet_name))) {
+ VIR_FREE(hostnet_name);
close(tapfd);
return -1;
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorSendFileHandle(priv->mon, tapfd_name, tapfd) < 0)
+ if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
+ VIR_INFO0("Did not remove existing host network");
+
+ if (qemuMonitorSendFileHandle(priv->mon, hostnet_name, tapfd) < 0)
goto out;
if (qemuMonitorAddHostNetwork(priv->mon, netstr) < 0) {
- if (qemuMonitorCloseFileHandle(priv->mon, tapfd_name) < 0)
- VIR_WARN(_("Failed to close tapfd with '%s'"), tapfd_name);
+ if (qemuMonitorCloseFileHandle(priv->mon, hostnet_name) < 0)
+ VIR_WARN(_("Failed to close tapfd with '%s'"), hostnet_name);
goto out;
}
@@ -6315,7 +6333,7 @@ static int qemudDomainConnectNetBackend(
out:
qemuDomainObjExitMonitorWithDriver(driver, vm);
VIR_FREE(netstr);
- VIR_FREE(tapfd_name);
+ VIR_FREE(hostnet_name);
close(tapfd);
return ret;
}
@@ -9339,6 +9357,73 @@ out:
return ret;
}
+static void *qemudDomainReconnectNetBackends(void *opaque)
+{
+ virConnectPtr conn = virConnectOpen("qemu:///system");
+ struct qemud_driver *driver = conn->privateData;
+ const unsigned char *uuid = opaque;
+
+ while (1) {
+ virDomainObjPtr vm;
+ unsigned long long qemuCmdFlags;
+ int i;
+
+ usleep(1000000);
+
+ VIR_DEBUG(_("qemuDomainReconnectNetBackends (%p %p)"),
+ conn, driver);
+
+ qemuDriverLock(driver);
+ vm = virDomainFindByUUID(&driver->domains, uuid);
+ if (!vm) {
+ VIR_DEBUG0("qemuDomainReconnectNetBackends done");
+ qemuDriverUnlock(driver);
+ break;
+ }
+
+ VIR_DEBUG(_("qemuDomainReconnectNetBackends (%s)"),
+ vm->def->name);
+
+ if (qemudExtractVersionInfo(vm->def->emulator,
+ NULL,
+ &qemuCmdFlags) < 0)
+ goto cleanup;
+
+ if (qemuDomainObjBeginJobWithDriver(driver, vm) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm))
+ goto endjob;
+
+ for (i = 0 ; i < vm->def->nnets ; i++) {
+ virDomainNetDefPtr net = vm->def->nets[i];
+
+ if (net->type != VIR_DOMAIN_NET_TYPE_DIRECT)
+ continue;
+
+ if (qemudDomainConnectNetBackend(conn, driver, vm,
+ net, qemuCmdFlags) == 0) {
+ VIR_WARN(_("Reconnected interface %s (%s) for domain %s"),
+ net->data.direct.linkdev, net->ifname, vm->def->name);
+ } else {
+ VIR_DEBUG(_("Unable to reconnect interface %s for domain %s"),
+ net->data.direct.linkdev, vm->def->name);
+ }
+ }
+
+ endjob:
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
+
+ cleanup:
+ if (vm)
+ virDomainObjUnlock(vm);
+ qemuDriverUnlock(driver);
+ }
+
+ return NULL;
+}
+
static int
qemuCPUCompare(virConnectPtr conn,
const char *xmlDesc,
Index: libvirt-0.7.7/src/util/macvtap.c
===================================================================
--- libvirt-0.7.7.orig/src/util/macvtap.c
+++ libvirt-0.7.7/src/util/macvtap.c
@@ -215,10 +215,12 @@ getIfIndex(virConnectPtr conn,
if (ioctl(fd, SIOCGIFINDEX, &ifreq) >= 0)
*idx = ifreq.ifr_ifindex;
else {
+#if 0
if (conn)
ReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("interface %s does not exist"),
ifname);
+#endif
rc = ENODEV;
}
@@ -747,11 +749,13 @@ create_name:
rc = ifUp(cr_ifname, 1);
if (rc != 0) {
+#if 0
virReportSystemError(errno,
_("cannot 'up' interface %s -- another "
"macvtap device may be 'up' and have the same "
"MAC address"),
cr_ifname);
+#endif
rc = -1;
goto link_del_exit;
}
Index: libvirt-0.7.7/src/qemu/qemu_conf.c
===================================================================
--- libvirt-0.7.7.orig/src/qemu/qemu_conf.c
+++ libvirt-0.7.7/src/qemu/qemu_conf.c
@@ -3854,18 +3854,21 @@ int qemudBuildCommandLine(virConnectPtr
net->data.direct.linkdev,
net->data.direct.mode,
qemuCmdFlags);
- if (tapfd < 0)
- goto error;
-
- if (VIR_REALLOC_N(*tapfds, (*ntapfds)+1) < 0) {
- close(tapfd);
- goto no_memory;
- }
+ if (tapfd < 0) {
+ VIR_WARN(_("Unable to connect interface %s for domain %s"),
+ net->data.direct.linkdev, def->name);
+ tapfd_name[0] = 0;
+ } else {
+ if (VIR_REALLOC_N(*tapfds, (*ntapfds)+1) < 0) {
+ close(tapfd);
+ goto no_memory;
+ }
- (*tapfds)[(*ntapfds)++] = tapfd;
+ (*tapfds)[(*ntapfds)++] = tapfd;
- if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name))
- goto no_memory;
+ if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name))
+ goto no_memory;
+ }
}
/* Possible combinations:
@@ -3876,8 +3879,9 @@ int qemudBuildCommandLine(virConnectPtr
*
* NB, no support for -netdev without use of -device
*/
- if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
- (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
+ if ((tapfd_name[0] != 0) &&
+ ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))) {
ADD_ARG_LIT("-netdev");
if (!(host = qemuBuildHostNetStr(net, ',',
vlan, tapfd_name)))
@@ -3895,8 +3899,9 @@ int qemudBuildCommandLine(virConnectPtr
goto error;
ADD_ARG(nic);
}
- if (!((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
- (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))) {
+ if ((tapfd_name[0] != 0) &&
+ (!((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)))) {
ADD_ARG_LIT("-net");
if (!(host = qemuBuildHostNetStr(net, ',',
vlan, tapfd_name)))
2
1
10 Mar '10
When starting a VM 3 times, on the 3rd time the number of sockets is
completely out of control. Initialize the socket numbers to zero so the
cpu affinity does not occur due to max cpus being completely out of
range and the VM can start.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
3
2
It is a bad idea to call gettext on an already-translated
string. In cases where a string must be translated separately
from where it is exposed to xgettext, the gettext manual
recommends the idiom of N_() wrapping gettext_noop for
marking the string.
* src/internal.h (N_): Fix definition to match gettext manual.
* tools/virsh.c: (cmdHelp, cmdList, cmdDomstate, cmdDominfo)
(cmdVcpuinfo, vshUsage): Replace incorrect use of N_ with _.
(vshCmddefHelp): Likewise. Mark C format strings appropriately.
---
src/internal.h | 2 +-
tools/virsh.c | 29 +++++++++++++++--------------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/internal.h b/src/internal.h
index ec8a49f..6e06f66 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -45,7 +45,7 @@
#endif
#define _(str) dgettext(GETTEXT_PACKAGE, (str))
-#define N_(str) dgettext(GETTEXT_PACKAGE, (str))
+#define N_(str) str
/* String equality tests, suggested by Jim Meyering. */
#define STREQ(a,b) (strcmp(a,b) == 0)
diff --git a/tools/virsh.c b/tools/virsh.c
index 65487ed..183f228 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -429,7 +429,7 @@ cmdHelp(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%s", _("Commands:\n\n"));
for (def = commands; def->name; def++)
vshPrint(ctl, " %-15s %s\n", def->name,
- N_(vshCmddefGetInfo(def, "help")));
+ _(vshCmddefGetInfo(def, "help")));
return TRUE;
}
return vshCmddefHelp(ctl, cmdname);
@@ -725,7 +725,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (virDomainGetInfo(dom, &info) < 0)
state = _("no state");
else
- state = N_(vshDomainStateToString(info.state));
+ state = _(vshDomainStateToString(info.state));
vshPrint(ctl, "%3d %-20s %s\n",
virDomainGetID(dom),
@@ -747,7 +747,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if (virDomainGetInfo(dom, &info) < 0)
state = _("no state");
else
- state = N_(vshDomainStateToString(info.state));
+ state = _(vshDomainStateToString(info.state));
vshPrint(ctl, "%3s %-20s %s\n", "-", names[i], state);
@@ -788,7 +788,7 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd)
if (virDomainGetInfo(dom, &info) == 0)
vshPrint(ctl, "%s\n",
- N_(vshDomainStateToString(info.state)));
+ _(vshDomainStateToString(info.state)));
else
ret = FALSE;
@@ -1761,7 +1761,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
if (virDomainGetInfo(dom, &info) == 0) {
vshPrint(ctl, "%-15s %s\n", _("State:"),
- N_(vshDomainStateToString(info.state)));
+ _(vshDomainStateToString(info.state)));
vshPrint(ctl, "%-15s %d\n", _("CPU(s):"), info.nrVirtCpu);
@@ -2040,7 +2040,7 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, "%-15s %d\n", _("VCPU:"), n);
vshPrint(ctl, "%-15s %d\n", _("CPU:"), cpuinfo[n].cpu);
vshPrint(ctl, "%-15s %s\n", _("State:"),
- N_(vshDomainVcpuStateToString(cpuinfo[n].state)));
+ _(vshDomainVcpuStateToString(cpuinfo[n].state)));
if (cpuinfo[n].cpuTime != 0) {
double cpuUsed = cpuinfo[n].cpuTime;
@@ -7869,8 +7869,8 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
vshError(ctl, _("command '%s' doesn't exist"), cmdname);
return FALSE;
} else {
- const char *desc = N_(vshCmddefGetInfo(def, "desc"));
- const char *help = N_(vshCmddefGetInfo(def, "help"));
+ const char *desc = _(vshCmddefGetInfo(def, "desc"));
+ const char *help = _(vshCmddefGetInfo(def, "help"));
char buf[256];
fputs(_(" NAME\n"), stdout);
@@ -7885,15 +7885,17 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
if (opt->type == VSH_OT_BOOL)
fmt = "[--%s]";
else if (opt->type == VSH_OT_INT)
- fmt = N_("[--%s <number>]");
+ /* xgettext:c-format */
+ fmt = _("[--%s <number>]");
else if (opt->type == VSH_OT_STRING)
- fmt = N_("[--%s <string>]");
+ /* xgettext:c-format */
+ fmt = _("[--%s <string>]");
else if (opt->type == VSH_OT_DATA)
fmt = ((opt->flag & VSH_OFLAG_REQ) ? "<%s>" : "[<%s>]");
else
assert(0);
fputc(' ', stdout);
- fprintf(stdout, _(fmt), opt->name);
+ fprintf(stdout, fmt, opt->name);
}
}
fputc('\n', stdout);
@@ -7917,7 +7919,7 @@ vshCmddefHelp(vshControl *ctl, const char *cmdname)
else if (opt->type == VSH_OT_DATA)
snprintf(buf, sizeof(buf), "<%s>", opt->name);
- fprintf(stdout, " %-15s %s\n", buf, N_(opt->help));
+ fprintf(stdout, " %-15s %s\n", buf, _(opt->help));
}
}
fputc('\n', stdout);
@@ -9148,8 +9150,7 @@ vshUsage(void)
for (cmd = commands; cmd->name; cmd++)
fprintf(stdout,
- " %-15s %s\n", cmd->name, N_(vshCmddefGetInfo(cmd,
- "help")));
+ " %-15s %s\n", cmd->name, _(vshCmddefGetInfo(cmd, "help")));
fprintf(stdout, "%s",
_("\n (specify help <command> for details about the command)\n\n"));
--
1.6.6.1
2
2
I added a section on good and bad uses of goto to the hacking document and website.
Also, should we dispense with the HACKING file's content altogether and replace it with a link to hacking.html on the website? It seems like unnecessary work to maintain identical content in both places.
Dave
David Allan (1):
The use of goto
HACKING | 32 ++++++++++++++++++++++++++++++++
docs/hacking.html.in | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 0 deletions(-)
6
16
10 Mar '10
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/util/processinfo.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/processinfo.c b/src/util/processinfo.c
index 5ae19f8..97ee779 100644
--- a/src/util/processinfo.c
+++ b/src/util/processinfo.c
@@ -130,31 +130,31 @@ realloc:
if (sched_getaffinity(pid, masklen, mask) < 0) {
CPU_FREE(mask);
if (errno == EINVAL &&
numcpus < (1024 << 8)) { /* 262144 cpus ought to be enough for anyone */
numcpus = numcpus << 2;
goto realloc;
}
virReportSystemError(errno,
- _("cannot set CPU affinity on process %d"), pid);
+ _("cannot get CPU affinity of process %d"), pid);
return -1;
}
for (i = 0 ; i < maxcpu ; i++)
if (CPU_ISSET_S(i, masklen, mask))
VIR_USE_CPU(map, i);
#else
/* Legacy method uses a fixed size cpu mask, only allows upto 1024 cpus */
cpu_set_t mask;
CPU_ZERO(&mask);
if (sched_getaffinity(pid, sizeof(mask), &mask) < 0) {
virReportSystemError(errno,
- _("cannot set CPU affinity on process %d"), pid);
+ _("cannot get CPU affinity of process %d"), pid);
return -1;
}
for (i = 0 ; i < maxcpu ; i++)
if (CPU_ISSET(i, &mask))
VIR_USE_CPU(map, i);
#endif
--
1.7.0.2
3
3
10 Mar '10
Resending patches in plain text. ~/Libvirt/Src/Makefile.am contains some changes suggested by
Daniel Veillard.
This is a patch to add XenAPI driver support for libvirt version 0.7.6. XenAPI can be used against XenCloud platform and
managed through virsh and virt-manger. This patch supports domain related APIs in libvirt. It is possible to get domain information,
list active and inactive domains, get Domain XML configuration and Start/stop/pause/shutdown/destroy VMs.
There will be more patches after this review to support more libvirt APIs and add remote storage support to XenAPI.
In order to run this patch you would require libxenserver library.
Libxenserver library can be downloaded from http://community.citrix.com/download/attachments/38633496/libxenserver-5.5.…
Copy the libxenserver folder in the same directory level as libvirt.
The XenCloud platform can be downloaded from http://xen.org/products/cloudxen.html
diff -ur ./libvirt_org/configure.ac ./libvirt/configure.ac
--- ./libvirt_org/configure.ac 2010-02-17 17:39:21.000000000 +0000
+++ ./libvirt/configure.ac 2010-02-18 11:51:29.000000000 +0000
@@ -219,6 +219,8 @@
AC_HELP_STRING([--with-libssh2=@<:@PFX@:>@], [libssh2 location @<:@default=/usr/local/lib@:>@]),[],[with_libssh2=yes])
AC_ARG_WITH([phyp],
AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check])
+AC_ARG_WITH([xenapi],
+ AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=yes@:>@]),[],[with_xenapi=check])
AC_ARG_WITH([vbox],
AC_HELP_STRING([--with-vbox], [add VirtualBox support @<:@default=yes@:>@]),[],[with_vbox=yes])
AC_ARG_WITH([lxc],
@@ -307,6 +309,11 @@
fi
AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"])
+if test "$with_xenapi" = "yes"; then
+ AC_DEFINE_UNQUOTED([WITH_XENAPI], 1, [whether XenAPI driver is enabled])
+fi
+AM_CONDITIONAL([WITH_XENAPI], [test "$with_xenapi" = "yes"])
+
if test "$with_libvirtd" = "no" ; then
with_qemu=no
fi
@@ -1894,6 +1901,7 @@
AC_MSG_NOTICE([ UML: $with_uml])
AC_MSG_NOTICE([ OpenVZ: $with_openvz])
AC_MSG_NOTICE([ VBox: $with_vbox])
+AC_MSG_NOTICE([ XenAPI: $with_xenapi])
AC_MSG_NOTICE([ LXC: $with_lxc])
AC_MSG_NOTICE([ PHYP: $with_phyp])
AC_MSG_NOTICE([ ONE: $with_one])
Binary files ./libvirt_org/daemon/.libs/libvirtd and ./libvirt/daemon/.libs/libvirtd differ
Only in ./libvirt_org/daemon/.libs: lt-libvirtd
--- ./libvirt_org/src/Makefile.am 2010-02-17 17:38:13.000000000 +0000
+++ ./libvirt/src/Makefile.am 2010-02-19 10:55:51.000000000 +0000
@@ -3,12 +3,19 @@
# No libraries with the exception of LIBXML should be listed
# here. List them against the individual XXX_la_CFLAGS targets
# that actually use them
+
+XENAPI_CFLAGS = -I@top_srcdir@/../libxenserver/include
+
INCLUDES = \
-I$(top_srcdir)/gnulib/lib \
-I../gnulib/lib \
-I../include \
+ -I/usr/include \
-I@top_srcdir@/src/util \
+ -I@top_srcdir@/src \
+ -I@top_srcdir@/src/xenapi \
-I@top_srcdir@/include \
+ $(XENAPI_CFLAGS) \
$(DRIVER_MODULE_CFLAGS) \
$(LIBXML_CFLAGS) \
-DLIBDIR=\""$(libdir)"\" \
@@ -42,6 +49,9 @@
augeastestdir = $(datadir)/augeas/lenses/tests
augeastest_DATA =
+XENAPI_LIBS = @top_srcdir@/../libxenserver/libxenserver.so
+XENAPI_LDFLAGS = -L@top_srcdir@/../libxenserver/ -lxenserver
+
# These files are not related to driver APIs. Simply generic
# helper APIs for various purposes
UTIL_SOURCES = \
@@ -205,6 +215,10 @@
qemu/qemu_security_dac.h \
qemu/qemu_security_dac.c
+XENAPI_DRIVER_SOURCES = \
+ xenapi/xenapi_driver.c xenapi/xenapi_driver.h \
+ xenapi/xenapi_utils.c xenapi/xenapi_utils.h
+
UML_DRIVER_SOURCES = \
uml/uml_conf.c uml/uml_conf.h \
uml/uml_driver.c uml/uml_driver.h
@@ -466,6 +480,28 @@
libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES)
endif
+if WITH_XENAPI
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_xenapi.la
+else
+noinst_LTLIBRARIES += libvirt_driver_xenapi.la
+
+libvirt_la_LIBADD += libvirt_driver_xenapi.la \
+ $(XENAPI_LIBS)
+endif
+#libvirt_driver_xenapi_la_LIBADD = $(XENAPI_LIBS)
+libvirt_driver_xenapi_la_CFLAGS = $(XEN_CFLAGS) \
+ $(LIBXML_CFLAGS) \
+ $(shell curl-config --cflags)
+libvirt_driver_xenapi_la_LDFLAGS = $(XENAPI_LDFLAGS) -g $(LIBXML_LIBS) \
+ $(shell curl-config --libs)
+
+if WITH_DRIVER_MODULES
+libvirt_driver_xenapi_la_LDFLAGS += -module -avoid-version
+endif
+libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES)
+endif
+
if WITH_QEMU
if WITH_DRIVER_MODULES
mod_LTLIBRARIES += libvirt_driver_qemu.la
@@ -722,6 +758,7 @@
$(OPENVZ_DRIVER_SOURCES) \
$(PHYP_DRIVER_SOURCES) \
$(VBOX_DRIVER_SOURCES) \
+ $(XENAPI_DRIVER_SOURCES) \
$(ESX_DRIVER_SOURCES) \
$(NETWORK_DRIVER_SOURCES) \
$(INTERFACE_DRIVER_SOURCES) \
diff -ur ./libvirt_org/tools/Makefile.am ./libvirt/tools/Makefile.am
--- ./libvirt_org/tools/Makefile.am 2010-02-17 17:36:13.000000000 +0000
+++ ./libvirt/tools/Makefile.am 2010-02-18 11:56:30.000000000 +0000
@@ -40,7 +40,8 @@
$(WARN_CFLAGS) \
../src/libvirt.la \
../gnulib/lib/libgnu.la \
- $(VIRSH_LIBS)
+ $(VIRSH_LIBS) \
+ ../../libxenserver/libxenserver.so
virsh_CFLAGS = \
-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
-I../include -I$(top_srcdir)/include \
5
24
The nodeinfo structure wasn't initialized in qemu driver and with the
recent change in CPU topology parsing, old value of nodeinfo->sockets
could be used and incremented giving totally bogus results.
Let's just wipe the structure completely.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/nodeinfo.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2dab5b2..1ee3709 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -251,18 +251,17 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
int nodeGetInfo(virConnectPtr conn,
virNodeInfoPtr nodeinfo) {
+ memset(nodeinfo, 0, sizeof(*nodeinfo));
+
#ifdef HAVE_UNAME
+ {
struct utsname info;
uname(&info);
if (virStrcpyStatic(nodeinfo->model, info.machine) == NULL)
return -1;
-
-#else /* !HAVE_UNAME */
-
- nodeinfo->model[0] = '\0';
-
+ }
#endif /* !HAVE_UNAME */
#ifdef __linux__
--
1.7.0.2
2
2
[libvirt] [PATCH] Get thread and socket information in virsh nodeinfo.
by Chris Lalancette 10 Mar '10
by Chris Lalancette 10 Mar '10
10 Mar '10
The current code for "nodeinfo" is pretty naive
about socket and thread information. To determine the
sockets, it just takes the number of cpus and divides
by the number of cores. For the thread count, it always
sets it to 1. With more recent Intel machines, however,
hyperthreading is again an option, meaning that these
heuristics no longer work and give bogus numbers. This
patch goes through /sys to get the additional
information so we properly report it.
Note that I had to edit the tests not to report on
socket and thread counts, since these are determined
dynamically now.
v2: As pointed out by Eric Blake, gnulib provides
count-one-bits (which is LGPLv2+). Use it instead
of a hand-coded popcnt.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
bootstrap.conf | 1 +
src/nodeinfo.c | 133 ++++++++++++++++++++++++++++--
tests/nodeinfodata/linux-nodeinfo-1.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-2.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-3.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-4.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-5.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-6.txt | 2 +-
tests/nodeinfotest.c | 5 +-
9 files changed, 133 insertions(+), 18 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 58ef2ab..157092f 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -25,6 +25,7 @@ c-ctype
canonicalize-lgpl
close
connect
+count-one-bits
dirname-lgpl
getaddrinfo
gethostname
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2d44609..b645e0e 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
+#include <dirent.h>
#if HAVE_NUMACTL
# define NUMA_VERSION1_COMPATIBILITY 1
@@ -45,6 +46,7 @@
#include "util.h"
#include "logging.h"
#include "virterror_internal.h"
+#include "count-one-bits.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -55,22 +57,109 @@
#ifdef __linux__
#define CPUINFO_PATH "/proc/cpuinfo"
+#define CPU_SYS_PATH "/sys/devices/system/cpu"
-/* NB, these are not static as we need to call them from testsuite */
+/* NB, this is not static as we need to call it from the testsuite */
int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
virNodeInfoPtr nodeinfo);
-int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo) {
+static unsigned long count_thread_siblings(int cpu)
+{
+ unsigned long ret = 0;
+ char *path = NULL;
+ FILE *pathfp = NULL;
+ char str[1024];
+ int i;
+
+ if (virAsprintf(&path, "%s/cpu%d/topology/thread_siblings", CPU_SYS_PATH,
+ cpu) < 0) {
+ virReportOOMError();
+ return 0;
+ }
+
+ pathfp = fopen(path, "r");
+ if (pathfp == NULL) {
+ virReportSystemError(errno, _("cannot open %s"), path);
+ VIR_FREE(path);
+ return 0;
+ }
+
+ if (fgets(str, sizeof(str), pathfp) == NULL) {
+ virReportSystemError(errno, _("cannot read from %s"), path);
+ goto cleanup;
+ }
+
+ i = 0;
+ while (str[i] != '\0') {
+ if (str[i] != '\n' && str[i] != ',')
+ ret += count_one_bits(str[i] - '0');
+ i++;
+ }
+
+cleanup:
+ fclose(pathfp);
+ VIR_FREE(path);
+
+ return ret;
+}
+
+static int parse_socket(int cpu)
+{
+ char *path = NULL;
+ FILE *pathfp;
+ char socket_str[1024];
+ char *tmp;
+ int socket;
+
+ if (virAsprintf(&path, "%s/cpu%d/topology/physical_package_id",
+ CPU_SYS_PATH, cpu) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ pathfp = fopen(path, "r");
+ if (pathfp == NULL) {
+ virReportSystemError(errno, _("cannot open %s"), path);
+ goto cleanup;
+ }
+
+ if (fgets(socket_str, sizeof(socket_str), pathfp) == NULL) {
+ virReportSystemError(errno, _("cannot read from %s"), path);
+ goto cleanup;
+ }
+ if (virStrToLong_i(socket_str, &tmp, 10, &socket) < 0) {
+ nodeReportError(NULL, VIR_ERR_INTERNAL_ERROR,
+ _("could not convert '%s' to an integer"),
+ socket_str);
+ goto cleanup;
+ }
+
+cleanup:
+ fclose(pathfp);
+ VIR_FREE(path);
+
+ return socket;
+}
+
+int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
+ virNodeInfoPtr nodeinfo)
+{
char line[1024];
+ DIR *cpudir = NULL;
+ struct dirent *cpudirent = NULL;
+ int cpu;
+ unsigned long cur_threads;
+ int socket;
+ unsigned long long socket_mask = 0;
nodeinfo->cpus = 0;
nodeinfo->mhz = 0;
- nodeinfo->nodes = nodeinfo->sockets = nodeinfo->cores = nodeinfo->threads = 1;
+ nodeinfo->nodes = nodeinfo->cores = 1;
/* NB: It is impossible to fill our nodes, since cpuinfo
* has not knowledge of NUMA nodes */
- /* XXX hyperthreads */
+ /* NOTE: hyperthreads are ignored here; they are parsed out of /sys */
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
char *buf = line;
if (STRPREFIX(buf, "processor")) { /* aka a single logical CPU */
@@ -122,12 +211,38 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
return -1;
}
- /*
- * Can't reliably count sockets from proc metadata, so
- * infer it based on total CPUs vs cores.
- * XXX hyperthreads
+ /* OK, we've parsed what we can out of /proc/cpuinfo. Get the socket
+ * and thread information from /sys
*/
- nodeinfo->sockets = nodeinfo->cpus / nodeinfo->cores;
+ cpudir = opendir(CPU_SYS_PATH);
+ if (cpudir == NULL) {
+ virReportSystemError(errno, _("cannot opendir %s"), CPU_SYS_PATH);
+ return -1;
+ }
+ while ((cpudirent = readdir(cpudir))) {
+ if (sscanf(cpudirent->d_name, "cpu%d", &cpu) != 1)
+ continue;
+
+ socket = parse_socket(cpu);
+ if (socket < 0) {
+ closedir(cpudir);
+ return -1;
+ }
+ if (!(socket_mask & (1 << socket))) {
+ socket_mask |= (1 << socket);
+ nodeinfo->sockets++;
+ }
+
+ cur_threads = count_thread_siblings(cpu);
+ if (cur_threads == 0) {
+ closedir(cpudir);
+ return -1;
+ }
+ if (cur_threads > nodeinfo->threads)
+ nodeinfo->threads = cur_threads;
+ }
+
+ closedir(cpudir);
return 0;
}
diff --git a/tests/nodeinfodata/linux-nodeinfo-1.txt b/tests/nodeinfodata/linux-nodeinfo-1.txt
index e52e20a..09e2946 100644
--- a/tests/nodeinfodata/linux-nodeinfo-1.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-1.txt
@@ -1 +1 @@
-CPUs: 2, MHz: 2800, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1
+CPUs: 2, MHz: 2800, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-2.txt b/tests/nodeinfodata/linux-nodeinfo-2.txt
index 12e819b..e4eea94 100644
--- a/tests/nodeinfodata/linux-nodeinfo-2.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-2.txt
@@ -1 +1 @@
-CPUs: 2, MHz: 2211, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1
+CPUs: 2, MHz: 2211, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-3.txt b/tests/nodeinfodata/linux-nodeinfo-3.txt
index d285781..17d4d8e 100644
--- a/tests/nodeinfodata/linux-nodeinfo-3.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-3.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 1595, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1
+CPUs: 4, MHz: 1595, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-4.txt b/tests/nodeinfodata/linux-nodeinfo-4.txt
index 991d4f9..5a5c919 100644
--- a/tests/nodeinfodata/linux-nodeinfo-4.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-4.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 1, Cores: 4, Threads: 1
+CPUs: 4, MHz: 1000, Nodes: 1, Cores: 4
diff --git a/tests/nodeinfodata/linux-nodeinfo-5.txt b/tests/nodeinfodata/linux-nodeinfo-5.txt
index dce7ada..54abb5d 100644
--- a/tests/nodeinfodata/linux-nodeinfo-5.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-5.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 2814, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1
+CPUs: 4, MHz: 2814, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-6.txt b/tests/nodeinfodata/linux-nodeinfo-6.txt
index 75cdaa9..f89e35e 100644
--- a/tests/nodeinfodata/linux-nodeinfo-6.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-6.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1
+CPUs: 4, MHz: 1000, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 4cb248a..b3b91ad 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -47,9 +47,8 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
fclose(cpuinfo);
snprintf(actualData, MAX_FILE,
- "CPUs: %u, MHz: %u, Nodes: %u, Sockets: %u, Cores: %u, Threads: %u\n",
- nodeinfo.cpus, nodeinfo.mhz, nodeinfo.nodes, nodeinfo.sockets,
- nodeinfo.cores, nodeinfo.threads);
+ "CPUs: %u, MHz: %u, Nodes: %u, Cores: %u\n",
+ nodeinfo.cpus, nodeinfo.mhz, nodeinfo.nodes, nodeinfo.cores);
if (STRNEQ(actualData, expectData)) {
if (getenv("DEBUG_TESTS")) {
--
1.6.6.1
4
8
---
AUTHORS | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 8ccbd88..2ca555f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -89,6 +89,11 @@ Patches have also been contributed by:
Steve Yarmie <steve.yarmie(a)gmail.com>
Dan Kenigsberg <danken(a)redhat.com>
Yuji NISHIDA <nishidy(a)nict.go.jp>
+ Eric Blake <eblake(a)redhat.com>
+ Dustin Xiong <x_k_123(a)hotmail.com>
+ Rolf Eike Beer <eike(a)sf-mail.de>
+ Stefan Berger <stefanb(a)us.ibm.com>
+ Wolfgang Mauerer <wolfgang.mauerer(a)siemens.com>
[....send patches to get your name here....]
--
1.6.6.1
2
1
Ever since I first started playing with libvirt last month, 'make check'
has been failing for me on the same test:
$ VIR_TEST_DEBUG=2 make -C tests check TESTS=daemon-conf
...
1) corrupted config listen_tls ... OK
2) corrupted config listen_tcp ... OK
3) corrupted config tls_port ... OK
4) corrupted config tcp_port ... OK
5) corrupted config listen_addr ... OK
6) corrupted config mdns_adv ... FAILED
7) corrupted config mdns_name ... FAILED
8) corrupted config unix_sock_group ... FAILED
9) corrupted config unix_sock_ro_perms ... FAILED
10) corrupted config unix_sock_rw_perms ... FAILED
11) corrupted config unix_sock_dir ... FAILED
12) corrupted config auth_unix_ro ... OK
13) corrupted config auth_unix_rw ... OK
14) corrupted config auth_tcp ... OK
15) corrupted config auth_tls ... FAILED
16) corrupted config key_file ... FAILED
17) corrupted config cert_file ... FAILED
18) corrupted config ca_file ... FAILED
19) corrupted config crl_file ... FAILED
20) corrupted config tls_no_verify_certificate ... FAILED
21) corrupted config tls_allowed_dn_list ... FAILED
22) corrupted config sasl_allowed_username_list ... FAILED
23) corrupted config max_clients ... FAILED
24) corrupted config min_workers ... FAILED
25) corrupted config max_workers ... FAILED
26) corrupted config max_requests ... FAILED
27) corrupted config max_client_requests ... FAILED
./daemon-conf: line 81: kill: (3145) - No such process
28) valid config file (sleeping 2 seconds) ... FAILED
FAIL: daemon-conf
==================
1 of 1 test failed
==================
Any hints on what I should do to help find the root cause for the
failure? Am I missing a package? Does the test need to be made
more robust to skip if a prereq is missing?
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
4
7
Hi,
Debian's (and therefore likely the derivatives') kernel headers are
lacking the typdef for sa_family_t in linux/socket.h so the
compilation of the macvtap check fails. Additionally including
sockaddr.h fixes this and doesn't hurt the other cases where there's
also a typedef in socket.h since these two must be identical.
Cheers,
-- Guido
2
1
A few more non-literal format strings in error log messages have crept
in. Fix them in the standard way - turn the format string into "%s"
with the original string as the arg.
---
src/qemu/qemu_conf.c | 2 +-
src/xen/xend_internal.c | 2 +-
src/xen/xm_internal.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index c93baec..40ca221 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3033,7 +3033,7 @@ qemuBuildVirtioSerialPortDevStr(virDomainChrDefPtr dev)
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL)
{
qemuReportError(VIR_ERR_INTERNAL_ERROR,
- _("virtio serial device has invalid address type"));
+ "%s", _("virtio serial device has invalid address type"));
goto error;
}
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index cd7177b..8b4e49e 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -5848,7 +5848,7 @@ xenDaemonFormatSxpr(virConnectPtr conn,
if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME) {
if (def->clock.data.timezone) {
virXendError(conn, VIR_ERR_CONFIG_UNSUPPORTED,
- _("configurable timezones are not supported"));
+ "%s", _("configurable timezones are not supported"));
goto error;
}
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 0973b43..2d0f1d5 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -2330,7 +2330,7 @@ virConfPtr xenXMDomainConfigFormat(virConnectPtr conn,
if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME) {
if (def->clock.data.timezone) {
xenXMError(conn, VIR_ERR_CONFIG_UNSUPPORTED,
- _("configurable timezones are not supported"));
+ "%s", _("configurable timezones are not supported"));
goto cleanup;
}
--
1.6.6.1
2
1
This fixes the #include's for the macvtap build detection.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
2
1
[libvirt] [PATCH] Make virDomainGetXMLDesc output cache settings even if no special driverName is set
by Soren Hansen 09 Mar '10
by Soren Hansen 09 Mar '10
09 Mar '10
If a special cache strategy for a disk has been specified in a domain
definition, but no driverName has been set, virDomainGetXMLDesc will not
include the <driver> tag at all.
This patch makes sure that the <driver> tag is included if any of the
settings it can contain has been set.
Signed-off-by: Soren Hansen <soren(a)linux2go.dk>
---
src/conf/domain_conf.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 96ba0b0..56c5239 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4718,8 +4718,10 @@ virDomainDiskDefFormat(virBufferPtr buf,
" <disk type='%s' device='%s'>\n",
type, device);
- if (def->driverName) {
- virBufferVSprintf(buf, " <driver name='%s'", def->driverName);
+ if (def->driverName || def->driverType || def->cachemode) {
+ virBufferVSprintf(buf, " <driver");
+ if (def->driverName)
+ virBufferVSprintf(buf, " name='%s'", def->driverName);
if (def->driverType)
virBufferVSprintf(buf, " type='%s'", def->driverType);
if (def->cachemode)
--
1.7.0
3
2
Hi there,
I trying to enable domain events callbacks under a cross compiled (mingwin under fedora12 env) libvirt 0.7.4 (I haven't been able to compile more recent versions under mingwin) dll. Here a little sample of code I'm trying to write :
#include "stdafx.h"
#include "windows.h"
#include "libvirt.h"
#include "virterror.h"
static int domain_event(virConnectPtr conn,
virDomainPtr dom,
int evt,
int detail,
void *opaque)
{
bool test = true;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
virConnectPtr conn = virConnectOpen("qemu+tcp://192.168.220.198/session");
// Set Callback
int cbresult = virConnectDomainEventRegister(conn, domain_event, NULL, NULL);
// Lookup Domain
virDomainPtr dom = virDomainLookupByName(conn, "Test1");
// Start Domain
int startDom = virDomainCreate(dom);
if (startDom != 0)
{
virErrorPtr e = virGetLastError();
bool test = true;
}
// Wait
Sleep(60000);
// Stop Domain
int StopDom = virDomainDestroy(dom);
if (StopDom != 0)
{
virErrorPtr e = virGetLastError();
bool test = true;
}
return 0;
}
I'm able to connect to the host and I'm able to start the domain, but when I enable callback with "virConnectDomainEventRegister", it fails, I have a message "unmarshalling msg" coming from the "remoteDomainReadEvent" method of remote_driver.c in libvirt.
I think about a problem near __stdcall or __cdecl calls or this kind of thing, but I'm not sure.
Any clues ?
Best regards,
Arnaud Champion
1
0
[libvirt] [RFC][PATCH v2 1/2] Separate backend setup from NIC device add/remove
by Ed Swierk 09 Mar '10
by Ed Swierk 09 Mar '10
09 Mar '10
This patch moves backend setup code from qemudDomainAttachNetDevice and
qemudDomainDetachNetDevice into separate functions. While the intent is
to allow the new functions to be called separately without affecting VM
NIC devices, this is arguably a worthwhile refactoring on its own.
Signed-off-by: Ed Swierk <eswierk(a)aristanetworks.com>
---
Move the code that creates and destroys the network backend and
connects it to qemu from the code that creates the virtual NIC.
Index: libvirt-0.7.7/src/qemu/qemu_driver.c
===================================================================
--- libvirt-0.7.7.orig/src/qemu/qemu_driver.c
+++ libvirt-0.7.7/src/qemu/qemu_driver.c
@@ -141,6 +141,16 @@ static int qemuDetectVcpuPIDs(struct qem
static int qemuUpdateActivePciHostdevs(struct qemud_driver *driver,
virDomainDefPtr def);
+static int qemudDomainConnectNetBackend(virConnectPtr conn,
+ struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainNetDefPtr net,
+ unsigned long long qemuCmdFlags);
+
+static int qemudDomainDisconnectNetBackend(struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainNetDefPtr net);
+
static struct qemud_driver *qemu_driver = NULL;
@@ -6231,20 +6241,17 @@ error:
}
-/* XXX conn required for network -> bridge resolution */
-static int qemudDomainAttachNetDevice(virConnectPtr conn,
- struct qemud_driver *driver,
- virDomainObjPtr vm,
- virDomainNetDefPtr net,
- unsigned long long qemuCmdFlags)
+static int qemudDomainConnectNetBackend(virConnectPtr conn,
+ struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainNetDefPtr net,
+ unsigned long long qemuCmdFlags)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
char *tapfd_name = NULL;
int tapfd = -1;
- char *nicstr = NULL;
char *netstr = NULL;
int ret = -1;
- virDomainDevicePCIAddress guestAddr;
int vlan;
if (!(qemuCmdFlags & QEMUD_CMD_FLAG_HOST_NET_ADD)) {
@@ -6253,36 +6260,84 @@ static int qemudDomainAttachNetDevice(vi
return -1;
}
+ if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
+ qemuReportError(VIR_ERR_NO_SUPPORT,
+ _("network device type '%s' cannot be attached: "
+ "qemu is not using a unix socket monitor"),
+ virDomainNetTypeToString(net->type));
+ return -1;
+ }
+
+ if ((vlan = qemuDomainNetVLAN(net)) < 0) {
+ qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("Unable to connect network backend without vlan"));
+ goto out;
+ }
+
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE ||
net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
- if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
- qemuReportError(VIR_ERR_NO_SUPPORT,
- _("network device type '%s' cannot be attached: "
- "qemu is not using a unix socket monitor"),
- virDomainNetTypeToString(net->type));
- return -1;
- }
-
- if ((tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags)) < 0)
- return -1;
+ tapfd = qemudNetworkIfaceConnect(conn, driver, net, qemuCmdFlags);
} else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
- if (priv->monConfig->type != VIR_DOMAIN_CHR_TYPE_UNIX) {
- qemuReportError(VIR_ERR_NO_SUPPORT,
- _("network device type '%s' cannot be attached: "
- "qemu is not using a unix socket monitor"),
- virDomainNetTypeToString(net->type));
- return -1;
- }
+ tapfd = qemudPhysIfaceConnect(conn, driver, net,
+ net->data.direct.linkdev,
+ net->data.direct.mode,
+ qemuCmdFlags);
+ }
+ if (tapfd < 0)
+ return -1;
- if ((tapfd = qemudPhysIfaceConnect(conn, driver, net,
- net->data.direct.linkdev,
- net->data.direct.mode,
- qemuCmdFlags)) < 0)
- return -1;
+ if (virAsprintf(&tapfd_name, "fd-%s", net->info.alias) < 0) {
+ virReportOOMError();
+ close(tapfd);
+ return -1;
+ }
+
+ if (!(netstr = qemuBuildHostNetStr(net, ' ',
+ vlan, tapfd_name))) {
+ VIR_FREE(tapfd_name);
+ close(tapfd);
+ return -1;
+ }
+
+ qemuDomainObjEnterMonitorWithDriver(driver, vm);
+
+ if (qemuMonitorSendFileHandle(priv->mon, tapfd_name, tapfd) < 0)
+ goto out;
+
+ if (qemuMonitorAddHostNetwork(priv->mon, netstr) < 0) {
+ if (qemuMonitorCloseFileHandle(priv->mon, tapfd_name) < 0)
+ VIR_WARN(_("Failed to close tapfd with '%s'"), tapfd_name);
+ goto out;
}
- if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets+1) < 0)
- goto no_memory;
+ ret = 0;
+
+out:
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ VIR_FREE(netstr);
+ VIR_FREE(tapfd_name);
+ close(tapfd);
+ return ret;
+}
+
+
+/* XXX conn required for network -> bridge resolution */
+static int qemudDomainAttachNetDevice(virConnectPtr conn,
+ struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainNetDefPtr net,
+ unsigned long long qemuCmdFlags)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ char *nicstr = NULL;
+ int ret = -1;
+ virDomainDevicePCIAddress guestAddr;
+ int vlan;
+
+ if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets+1) < 0) {
+ virReportOOMError();
+ return -1;
+ }
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NET_NAME) ||
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
@@ -6294,40 +6349,16 @@ static int qemudDomainAttachNetDevice(vi
qemuDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0)
goto cleanup;
- vlan = qemuDomainNetVLAN(net);
-
- if (vlan < 0) {
+ if ((vlan = qemuDomainNetVLAN(net)) < 0) {
qemuReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Unable to attach network devices without vlan"));
goto cleanup;
}
- if (tapfd != -1) {
- if (virAsprintf(&tapfd_name, "fd-%s", net->info.alias) < 0)
- goto no_memory;
-
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorSendFileHandle(priv->mon, tapfd_name, tapfd) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
- }
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- }
-
- if (!(netstr = qemuBuildHostNetStr(net, ' ',
- vlan, tapfd_name)))
- goto try_tapfd_close;
-
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorAddHostNetwork(priv->mon, netstr) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto try_tapfd_close;
+ if (qemudDomainConnectNetBackend(conn, driver, vm, net, qemuCmdFlags) < 0) {
+ VIR_WARN0(_("Failed to connect network backend"));
+ goto cleanup;
}
- qemuDomainObjExitMonitorWithDriver(driver, vm);
-
- if (tapfd != -1)
- close(tapfd);
- tapfd = -1;
if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
goto try_remove;
@@ -6342,9 +6373,13 @@ static int qemudDomainAttachNetDevice(vi
memcpy(&net->info.addr.pci, &guestAddr, sizeof(guestAddr));
qemuDomainObjExitMonitorWithDriver(driver, vm);
+ vm->def->nets[vm->def->nnets++] = net;
ret = 0;
+ goto cleanup;
- vm->def->nets[vm->def->nnets++] = net;
+try_remove:
+ if (qemudDomainDisconnectNetBackend(driver, vm, net) < 0)
+ VIR_WARN0("Unable to disconnect network backend");
cleanup:
if ((ret != 0) &&
@@ -6352,44 +6387,8 @@ cleanup:
(net->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
qemuDomainPCIAddressReleaseAddr(priv->pciaddrs, &net->info) < 0)
VIR_WARN0("Unable to release PCI address on NIC");
-
VIR_FREE(nicstr);
- VIR_FREE(netstr);
- VIR_FREE(tapfd_name);
- if (tapfd != -1)
- close(tapfd);
-
return ret;
-
-try_remove:
- if (vlan < 0) {
- VIR_WARN0(_("Unable to remove network backend"));
- } else {
- char *hostnet_name;
- if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0)
- goto no_memory;
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
- VIR_WARN(_("Failed to remove network backend for vlan %d, net %s"),
- vlan, hostnet_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- VIR_FREE(hostnet_name);
- }
- goto cleanup;
-
-try_tapfd_close:
- if (tapfd_name) {
- qemuDomainObjEnterMonitorWithDriver(driver, vm);
- if (qemuMonitorCloseFileHandle(priv->mon, tapfd_name) < 0)
- VIR_WARN(_("Failed to close tapfd with '%s'"), tapfd_name);
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- }
-
- goto cleanup;
-
-no_memory:
- virReportOOMError();
- goto cleanup;
}
@@ -6887,18 +6886,50 @@ cleanup:
return ret;
}
-static int
-qemudDomainDetachNetDevice(struct qemud_driver *driver,
- virDomainObjPtr vm,
- virDomainDeviceDefPtr dev,
- unsigned long long qemuCmdFlags)
+static int qemudDomainDisconnectNetBackend(struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainNetDefPtr detach)
{
- int i, ret = -1;
- virDomainNetDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
int vlan;
char *hostnet_name = NULL;
+ if ((vlan = qemuDomainNetVLAN(detach)) < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("unable to determine original VLAN"));
+ return -1;
+ }
+
+ if (virAsprintf(&hostnet_name, "host%s", detach->info.alias) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ qemuDomainObjEnterMonitorWithDriver(driver, vm);
+ if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0)
+ VIR_WARN0("Failed to remove host network");
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+
+#if WITH_MACVTAP
+ if (detach->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
+ if (detach->ifname)
+ delMacvtap(detach->ifname);
+ }
+#endif
+
+ VIR_FREE(hostnet_name);
+ return 0;
+}
+
+static int qemudDomainDetachNetDevice(struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev,
+ unsigned long long qemuCmdFlags)
+{
+ int i;
+ virDomainNetDefPtr detach = NULL;
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+
for (i = 0 ; i < vm->def->nnets ; i++) {
virDomainNetDefPtr net = vm->def->nets[i];
@@ -6914,53 +6945,33 @@ qemudDomainDetachNetDevice(struct qemud_
dev->data.net->mac[0], dev->data.net->mac[1],
dev->data.net->mac[2], dev->data.net->mac[3],
dev->data.net->mac[4], dev->data.net->mac[5]);
- goto cleanup;
+ return -1;
}
if (!virDomainDeviceAddressIsValid(&detach->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
"%s", _("device cannot be detached without a PCI address"));
- goto cleanup;
- }
-
- if ((vlan = qemuDomainNetVLAN(detach)) < 0) {
- qemuReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("unable to determine original VLAN"));
- goto cleanup;
- }
-
- if (virAsprintf(&hostnet_name, "host%s", detach->info.alias) < 0) {
- virReportOOMError();
- goto cleanup;
+ return -1;
}
qemuDomainObjEnterMonitorWithDriver(driver, vm);
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
if (qemuMonitorDelDevice(priv->mon, detach->info.alias) < 0) {
- qemuDomainObjExitMonitor(vm);
- goto cleanup;
+ qemuDomainObjExitMonitorWithDriver(driver, vm);
+ return -1;
}
} else {
if (qemuMonitorRemovePCIDevice(priv->mon,
&detach->info.addr.pci) < 0) {
qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
+ return -1;
}
}
-
- if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
- qemuDomainObjExitMonitorWithDriver(driver, vm);
- goto cleanup;
- }
qemuDomainObjExitMonitorWithDriver(driver, vm);
-#if WITH_MACVTAP
- if (detach->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
- if (detach->ifname)
- delMacvtap(detach->ifname);
- }
-#endif
+ if (qemudDomainDisconnectNetBackend(driver, vm, detach) < 0)
+ VIR_WARN0("Failed to disconnect network backend");
if ((driver->macFilter) && (detach->ifname != NULL)) {
if ((errno = networkDisallowMacOnPort(driver,
@@ -6987,11 +6998,7 @@ qemudDomainDetachNetDevice(struct qemud_
}
virDomainNetDefFree(detach);
- ret = 0;
-
-cleanup:
- VIR_FREE(hostnet_name);
- return ret;
+ return 0;
}
static int qemudDomainDetachHostPciDevice(struct qemud_driver *driver,
1
0
--
LuÃs Carlos Moreira da Costa
Eclipse RAP, RCP, GMF, OSGI, Spring-DM and Pentaho Developer
Regional Communities/Brazil
http://wiki.eclipse.org/Regional_Communities/Brazil
Java, write once, run everywhereâ„¢
1
0
When adding domainMemoryStats API support for the qemu driver, I didn't
follow the locking rules exactly. The job condition must be held when
executing monitor commands. This corrects the segfaults I was seeing
when calling domainMemoryStats in a multi-threaded environment.
If this patch is accepted, I would also consider it a candidate for the
0.7.6 stable patch stream (if such a thing exists). Thanks.
Signed-off-by: Adam Litke <agl(a)us.ibm.com>
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b8b7916..a9023da 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7526,6 +7526,9 @@ qemudDomainMemoryStats (virDomainPtr dom,
goto cleanup;
}
+ if (qemuDomainObjBeginJob(vm) < 0)
+ goto cleanup;
+
if (virDomainObjIsActive(vm)) {
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuDomainObjEnterMonitor(vm);
@@ -7536,6 +7539,9 @@ qemudDomainMemoryStats (virDomainPtr dom,
"%s", _("domain is not running"));
}
+ if (qemuDomainObjEndJob(vm) == 0)
+ vm = NULL;
+
cleanup:
if (vm)
virDomainObjUnlock(vm);
--
Thanks,
Adam
3
2
Hi,
I just packaged libvirt 0.7.7 for Debian.
But I can't start a VM with an USB device attached:
# virsh start test-vm
error: Failed to start domain test-vm
error: unable to set security context '107:113' on '/dev/bus/usb/000/000': No
such file or directory
I know there were changes about USB passthrough so I suppose it's a bug.
Thank you,
--
Laurent Léonard
3
4
09 Mar '10
doTunnelSendAll function (used by QEMU migration) uses a 64k buffer on
the stack, which could be problematic. This patch replaces that with a
buffer from the heap.
While in the neighborhood, this patch also improves error reporting in
the case that saferead fails - previously, virStreamAbort() was called
(resetting errno) before reporting the error. It's been changed to
report the error first.
---
Eric noticed that I was inconsistent in the ordering of cleanup
vs. error reporting, so I fixed that in this version.
src/qemu/qemu_driver.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bb3edde..5a18938 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8399,19 +8399,28 @@ cleanup:
}
+#define TUNNEL_SEND_BUF_SIZE 65536
+
static int doTunnelSendAll(virStreamPtr st,
int sock)
{
- char buffer[65536];
- int nbytes = sizeof(buffer);
+ char *buffer;
+ int nbytes = TUNNEL_SEND_BUF_SIZE;
+
+ if (VIR_ALLOC_N(buffer, TUNNEL_SEND_BUF_SIZE) < 0) {
+ virReportOOMError();
+ virStreamAbort(st);
+ return -1;
+ }
/* XXX should honour the 'resource' parameter here */
for (;;) {
nbytes = saferead(sock, buffer, nbytes);
if (nbytes < 0) {
- virStreamAbort(st);
virReportSystemError(errno, "%s",
_("tunnelled migration failed to read from qemu"));
+ virStreamAbort(st);
+ VIR_FREE(buffer);
return -1;
}
else if (nbytes == 0)
@@ -8421,10 +8430,13 @@ static int doTunnelSendAll(virStreamPtr st,
if (virStreamSend(st, buffer, nbytes) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to write migration data to remote libvirtd"));
+ VIR_FREE(buffer);
return -1;
}
}
+ VIR_FREE(buffer);
+
if (virStreamFinish(st) < 0)
/* virStreamFinish set the error for us */
return -1;
--
1.6.6.1
2
2
Here's the full cleanup, based on my earlier RFC. I've tested
that everything still builds and passes 'make syntax-check'.
This is broken out in chunks, although whoever ends up pushing
may want to squash it all into one.
src/conf/cpu_conf.c | 4 ++--
src/conf/domain_conf.c | 4 ++--
src/conf/domain_event.c | 5 +++--
src/conf/interface_conf.c | 4 ++--
src/conf/network_conf.c | 6 +++---
src/conf/node_device_conf.h | 5 +++--
src/conf/secret_conf.h | 6 +++---
src/conf/storage_conf.h | 6 +++---
src/cpu/cpu.h | 6 +++---
src/datatypes.c | 6 +++---
src/esx/esx_device_monitor.c | 5 +++--
src/esx/esx_driver.c | 5 +++--
src/esx/esx_interface_driver.c | 5 +++--
src/esx/esx_network_driver.c | 5 +++--
src/esx/esx_secret_driver.c | 5 +++--
src/esx/esx_storage_driver.c | 5 +++--
src/esx/esx_util.c | 5 +++--
src/esx/esx_vi.c | 5 +++--
src/esx/esx_vi_methods.c | 5 +++--
src/esx/esx_vi_types.c | 5 +++--
src/esx/esx_vmx.c | 5 +++--
src/interface/netcf_driver.c | 6 +++---
src/libvirt.c | 6 +++---
src/lxc/lxc_conf.h | 5 +++--
src/network/bridge_driver.c | 4 ++--
src/nodeinfo.c | 6 +++---
src/opennebula/one_conf.h | 8 +++++---
src/openvz/openvz_conf.h | 5 +++--
src/phyp/phyp_driver.c | 5 +++--
src/qemu/qemu_conf.h | 4 ++--
src/remote/remote_driver.c | 4 ++--
src/security/security_driver.h | 6 +++---
src/test/test_driver.c | 4 ++--
src/uml/uml_conf.h | 6 +++---
src/util/hostusb.c | 4 ++--
src/util/json.c | 6 +++---
src/util/macvtap.c | 5 +++--
src/util/pci.c | 4 ++--
src/util/stats_linux.c | 6 +++---
src/util/util.c | 4 ++--
src/util/xml.c | 6 +++---
src/vbox/vbox_driver.c | 5 +++--
src/vbox/vbox_tmpl.c | 5 +++--
src/xen/proxy_internal.c | 4 ++--
src/xen/sexpr.c | 9 ++++-----
src/xen/xen_driver.c | 4 ++--
src/xen/xen_hypervisor.c | 6 +++---
src/xen/xen_inotify.c | 5 +++--
src/xen/xend_internal.c | 9 ++++-----
src/xen/xm_internal.c | 6 +++---
src/xen/xs_internal.c | 4 ++--
51 files changed, 144 insertions(+), 124 deletions(-)
3
7
[libvirt] [PATCH] Get thread and socket information in virsh nodeinfo.
by Chris Lalancette 08 Mar '10
by Chris Lalancette 08 Mar '10
08 Mar '10
The current code for "nodeinfo" is pretty naive
about socket and thread information. To determine the
sockets, it just takes the number of cpus and divides
by the number of cores. For the thread count, it always
sets it to 1. With more recent Intel machines, however,
hyperthreading is again an option, meaning that these
heuristics no longer work and give bogus numbers. This
patch goes through /sys to get the additional
information so we properly report it.
Note that I had to edit the tests not to report on
socket and thread counts, since these are determined
dynamically now.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/nodeinfo.c | 140 +++++++++++++++++++++++++++++--
tests/nodeinfodata/linux-nodeinfo-1.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-2.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-3.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-4.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-5.txt | 2 +-
tests/nodeinfodata/linux-nodeinfo-6.txt | 2 +-
tests/nodeinfotest.c | 5 +-
8 files changed, 139 insertions(+), 18 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 2d44609..18efd28 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -28,6 +28,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
+#include <dirent.h>
#if HAVE_NUMACTL
# define NUMA_VERSION1_COMPATIBILITY 1
@@ -55,22 +56,117 @@
#ifdef __linux__
#define CPUINFO_PATH "/proc/cpuinfo"
+#define CPU_SYS_PATH "/sys/devices/system/cpu"
-/* NB, these are not static as we need to call them from testsuite */
+/* NB, this is not static as we need to call it from the testsuite */
int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
virNodeInfoPtr nodeinfo);
-int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo) {
+static int popcnt(char x)
+{
+ char count;
+ for (count = 0; x; count++)
+ x &= x-1;
+ return count;
+}
+
+static unsigned long count_thread_siblings(int cpu)
+{
+ unsigned long ret = 0;
+ char *path = NULL;
+ FILE *pathfp = NULL;
+ char str[1024];
+ int i;
+
+ if (virAsprintf(&path, "%s/cpu%d/topology/thread_siblings", CPU_SYS_PATH,
+ cpu) < 0) {
+ virReportOOMError();
+ return 0;
+ }
+
+ pathfp = fopen(path, "r");
+ if (pathfp == NULL) {
+ virReportSystemError(errno, _("cannot open %s"), path);
+ VIR_FREE(path);
+ return 0;
+ }
+
+ if (fgets(str, sizeof(str), pathfp) == NULL) {
+ virReportSystemError(errno, _("cannot read from %s"), path);
+ goto cleanup;
+ }
+
+ i = 0;
+ while (str[i] != '\0') {
+ if (str[i] != '\n' && str[i] != ',')
+ ret += popcnt(str[i] - '0');
+ i++;
+ }
+
+cleanup:
+ fclose(pathfp);
+ VIR_FREE(path);
+
+ return ret;
+}
+
+static int parse_socket(int cpu)
+{
+ char *path = NULL;
+ FILE *pathfp;
+ char socket_str[1024];
+ char *tmp;
+ int socket;
+
+ if (virAsprintf(&path, "%s/cpu%d/topology/physical_package_id",
+ CPU_SYS_PATH, cpu) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+
+ pathfp = fopen(path, "r");
+ if (pathfp == NULL) {
+ virReportSystemError(errno, _("cannot open %s"), path);
+ goto cleanup;
+ }
+
+ if (fgets(socket_str, sizeof(socket_str), pathfp) == NULL) {
+ virReportSystemError(errno, _("cannot read from %s"), path);
+ goto cleanup;
+ }
+ if (virStrToLong_i(socket_str, &tmp, 10, &socket) < 0) {
+ nodeReportError(NULL, VIR_ERR_INTERNAL_ERROR,
+ _("could not convert '%s' to an integer"),
+ socket_str);
+ goto cleanup;
+ }
+
+cleanup:
+ fclose(pathfp);
+ VIR_FREE(path);
+
+ return socket;
+}
+
+int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
+ virNodeInfoPtr nodeinfo)
+{
char line[1024];
+ DIR *cpudir = NULL;
+ struct dirent *cpudirent = NULL;
+ int cpu;
+ unsigned long cur_threads;
+ int socket;
+ unsigned long long socket_mask = 0;
nodeinfo->cpus = 0;
nodeinfo->mhz = 0;
- nodeinfo->nodes = nodeinfo->sockets = nodeinfo->cores = nodeinfo->threads = 1;
+ nodeinfo->nodes = nodeinfo->cores = 1;
/* NB: It is impossible to fill our nodes, since cpuinfo
* has not knowledge of NUMA nodes */
- /* XXX hyperthreads */
+ /* NOTE: hyperthreads are ignored here; they are parsed out of /sys */
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
char *buf = line;
if (STRPREFIX(buf, "processor")) { /* aka a single logical CPU */
@@ -122,12 +218,38 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
return -1;
}
- /*
- * Can't reliably count sockets from proc metadata, so
- * infer it based on total CPUs vs cores.
- * XXX hyperthreads
+ /* OK, we've parsed what we can out of /proc/cpuinfo. Get the socket
+ * and thread information from /sys
*/
- nodeinfo->sockets = nodeinfo->cpus / nodeinfo->cores;
+ cpudir = opendir(CPU_SYS_PATH);
+ if (cpudir == NULL) {
+ virReportSystemError(errno, _("cannot opendir %s"), CPU_SYS_PATH);
+ return -1;
+ }
+ while ((cpudirent = readdir(cpudir))) {
+ if (sscanf(cpudirent->d_name, "cpu%d", &cpu) != 1)
+ continue;
+
+ socket = parse_socket(cpu);
+ if (socket < 0) {
+ closedir(cpudir);
+ return -1;
+ }
+ if (!(socket_mask & (1 << socket))) {
+ socket_mask |= (1 << socket);
+ nodeinfo->sockets++;
+ }
+
+ cur_threads = count_thread_siblings(cpu);
+ if (cur_threads == 0) {
+ closedir(cpudir);
+ return -1;
+ }
+ if (cur_threads > nodeinfo->threads)
+ nodeinfo->threads = cur_threads;
+ }
+
+ closedir(cpudir);
return 0;
}
diff --git a/tests/nodeinfodata/linux-nodeinfo-1.txt b/tests/nodeinfodata/linux-nodeinfo-1.txt
index e52e20a..09e2946 100644
--- a/tests/nodeinfodata/linux-nodeinfo-1.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-1.txt
@@ -1 +1 @@
-CPUs: 2, MHz: 2800, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1
+CPUs: 2, MHz: 2800, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-2.txt b/tests/nodeinfodata/linux-nodeinfo-2.txt
index 12e819b..e4eea94 100644
--- a/tests/nodeinfodata/linux-nodeinfo-2.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-2.txt
@@ -1 +1 @@
-CPUs: 2, MHz: 2211, Nodes: 1, Sockets: 1, Cores: 2, Threads: 1
+CPUs: 2, MHz: 2211, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-3.txt b/tests/nodeinfodata/linux-nodeinfo-3.txt
index d285781..17d4d8e 100644
--- a/tests/nodeinfodata/linux-nodeinfo-3.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-3.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 1595, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1
+CPUs: 4, MHz: 1595, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-4.txt b/tests/nodeinfodata/linux-nodeinfo-4.txt
index 991d4f9..5a5c919 100644
--- a/tests/nodeinfodata/linux-nodeinfo-4.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-4.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 1, Cores: 4, Threads: 1
+CPUs: 4, MHz: 1000, Nodes: 1, Cores: 4
diff --git a/tests/nodeinfodata/linux-nodeinfo-5.txt b/tests/nodeinfodata/linux-nodeinfo-5.txt
index dce7ada..54abb5d 100644
--- a/tests/nodeinfodata/linux-nodeinfo-5.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-5.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 2814, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1
+CPUs: 4, MHz: 2814, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfodata/linux-nodeinfo-6.txt b/tests/nodeinfodata/linux-nodeinfo-6.txt
index 75cdaa9..f89e35e 100644
--- a/tests/nodeinfodata/linux-nodeinfo-6.txt
+++ b/tests/nodeinfodata/linux-nodeinfo-6.txt
@@ -1 +1 @@
-CPUs: 4, MHz: 1000, Nodes: 1, Sockets: 2, Cores: 2, Threads: 1
+CPUs: 4, MHz: 1000, Nodes: 1, Cores: 2
diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 4cb248a..b3b91ad 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -47,9 +47,8 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
fclose(cpuinfo);
snprintf(actualData, MAX_FILE,
- "CPUs: %u, MHz: %u, Nodes: %u, Sockets: %u, Cores: %u, Threads: %u\n",
- nodeinfo.cpus, nodeinfo.mhz, nodeinfo.nodes, nodeinfo.sockets,
- nodeinfo.cores, nodeinfo.threads);
+ "CPUs: %u, MHz: %u, Nodes: %u, Cores: %u\n",
+ nodeinfo.cpus, nodeinfo.mhz, nodeinfo.nodes, nodeinfo.cores);
if (STRNEQ(actualData, expectData)) {
if (getenv("DEBUG_TESTS")) {
--
1.6.6.1
3
3
Hi all,
Maybe this is a known issue, but I had pxe boot working with libvirt 0.7.1
This config:
<domain type='kvm'>
<name>pxetest</name>
<vcpu>1</vcpu>
<memory>196608</memory>
<os>
<type>hvm</type>
<boot dev="network" />
</os>
<devices>
<console type='pty' />
<interface type='bridge'>
<source bridge='br1' />
</interface>
</devices>
</domain>
Creates the following output with libvirt 0.7.7:
[root@localhost data]# virsh create --console pxetest.xml
error: Failed to create domain from pxetest.xml
error: internal error Process exited while reading console log output:
char device redirected to /dev/pts/0
Cannot boot from non-existent NIC
Here's the log:
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-kvm -S -M
fedora-13 -enable-kvm -m 192 -smp 1,sockets=1,cores=1,threads=1 -name
pxetest -uuid 0722f833-059e-a172-0d4c-bd2ffe106959 -nographic
-nodefaults -chardev
socket,id=monitor,path=/var/lib/libvirt/qemu/pxetest.monitor,server,nowait
-mon chardev=monitor,mode=readline -rtc base=utc -no-acpi -boot n
-device rtl8139,vlan=0,id=net0,mac=52:54:00:9f:b0:bb,bus=pci.0,addr=0x4
-net tap,fd=20,vlan=0,name=hostnet0 -chardev pty,id=serial0 -device
isa-serial,chardev=serial0 -usb -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
char device redirected to /dev/pts/0
Cannot boot from non-existent NIC
libvirt 0.7.1 nicely presents the pxe menu on the console. Here's the
qemu cmd under libvirt 0.7.1:
LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/bin/qemu-kvm -S -M
fedora-13 -m 192 -smp 1 -name pxetest -uuid
73a5f203-9417-c362-9d22-eb7da3cdbfde -nographic -monitor
unix:/var/lib/libvirt/qemu/pxetest.monitor,server,nowait -no-acpi
-boot n -net nic,macaddr=52:54:00:84:1e:ca,vlan=0,name=nic.0 -net
tap,fd=18,vlan=0,name=tap.0 -serial pty -parallel none -usb
char device redirected to /dev/pts/0
Regards,
Ruben Kerkhof
1
0
06 Mar '10
doTunnelSendAll function (used by QEMU migration) uses a 64k buffer on
the stack, which could be problematic. This patch replaces that with a
buffer from the heap.
While in the neighborhood, this patch also improves error reporting in
the case that saferead fails - previously, virStreamAbort() was called
(resetting errno) before reporting the error. It's been changed to
report the error first.
---
src/qemu/qemu_driver.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bb3edde..463c716 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8399,19 +8399,28 @@ cleanup:
}
+#define TUNNEL_SEND_BUF_SIZE 65536
+
static int doTunnelSendAll(virStreamPtr st,
int sock)
{
- char buffer[65536];
- int nbytes = sizeof(buffer);
+ char *buffer;
+ int nbytes = TUNNEL_SEND_BUF_SIZE;
+
+ if (VIR_ALLOC_N(buffer, TUNNEL_SEND_BUF_SIZE) < 0) {
+ virStreamAbort(st);
+ virReportOOMError();
+ return -1;
+ }
/* XXX should honour the 'resource' parameter here */
for (;;) {
nbytes = saferead(sock, buffer, nbytes);
if (nbytes < 0) {
- virStreamAbort(st);
virReportSystemError(errno, "%s",
_("tunnelled migration failed to read from qemu"));
+ virStreamAbort(st);
+ VIR_FREE(buffer);
return -1;
}
else if (nbytes == 0)
@@ -8421,10 +8430,13 @@ static int doTunnelSendAll(virStreamPtr st,
if (virStreamSend(st, buffer, nbytes) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("Failed to write migration data to remote libvirtd"));
+ VIR_FREE(buffer);
return -1;
}
}
+ VIR_FREE(buffer);
+
if (virStreamFinish(st) < 0)
/* virStreamFinish set the error for us */
return -1;
--
1.6.6.1
2
2
Re: [libvirt] [virt-devel] RFC: Modelling timers / clocks & tick policies in libvirt
by Zachary Amsden 06 Mar '10
by Zachary Amsden 06 Mar '10
06 Mar '10
On 03/05/2010 04:27 AM, Daniel P. Berrange wrote:
> This mail describes how I'm suggesting libvirt addresses Dor's RFE to
> timers/tick policies in libvirt
>
> https://bugzilla.redhat.com/show_bug.cgi?id=557285
>
> Thanks to those who've answered my previous mail / irc questions. Please
> point out any mistakes I made in understanding / modelling this problem
>
> Daniel
>
>
> Virtual machine timer management in libvirt
> ===========================================
>
> On PC hardware there are a number of terrible timers / clock sources available
> to operating systems
>
> * PIT
> Timer with periodic interrupts
>
> * RTC
>
> Time of Day clock, continuous running
> Timer with periodic interrupts
>
> * Local APIC Timer
> Timer with periodic interrupts
>
> * ACPI Timer
> Timer with periodic interrupts
>
> * TSC
> Read via rdtsc instruction. No interrupts
>
Never, ever tell anyone this, but it is possible to generate interrupts
from the TSC. Doing so is a million orders of perverse because of the
problems you list:
> Unreliable on some hardware. eg changes frequency.
> Not synced between cores
> Different HZ across hosts
>
> * HPET
> Multiple timers with periodic interrupts
> Can replace PIT/RTC timers
>
> They all generally suck in real hardware, and this gets worse in virtual machines.
> Many different approaches to making them suck less in VMWare, Xen& KVM, but there
> are some reasonably common concepts....
>
HPET doesn't suck.
>
> Virtual timekeeping problems
> ----------------------------
>
> Three primary problems / areas to deal with:
>
> * Time of day clock (RTC)
>
> - Initialized to UTC/Localtime/Timezone/UTC+offset
> - Two modes of operation:
> 1. Guest wallclock: only runs when guest is executing. ie stopped across save/restore, etc
> 2. Host wallclock: runs continuously with host wall time.
>
Windows wants RTC in localtime, Linux can do either but RTC in UTC is
easiest to maintain.
Guest / host wall clock is a general consideration for all timers,
obviously RTC is supposed to be a wallclock, but there is a question: do
we allow the guest to see host time exactly or do we hide it?
> * Interrupt timers
>
> - Ticks can not always be delivered on time
>
> Policies to deal with "missed" ticks:
>
> 1. Deliver at normal rate without catchup
> 2. Deliver at higher rate to catch up
> 3. Merge into 1 tick& deliver asap
>
> 4. Discard all missed ticks
>
The issue is actually more complex than just these policies. A naive
implementation of the policy leads to a guest DOS of the host.
We actually have such a bug, and it demands a policy which merges ticks
over a certain threshold and does not deliver ASAP. It's tricky and
complex to fix because it means our notion of timers for the guest is
wrong, and we need to introduce a higher order scheduling behaviour.
In general, there isn't much we can tune here, but what we can tune is
whether the other counters (RTC / HPET / TSC / ACPI) stay in sync with
ticks delivered. It's not perfect or completely well defined because
the tick can't actually be delivered until a fairly complex set of
hardware rules is obeyed. This may not be apparent now, because it gets
worse as we implement more hardware support for NMIs and SMIs. An ideal
solution would sync the other counters when the tick is generated, not
when it is injected. However, this leads us back to the DOS attack.
There are also problems with SMP timing here (which CPU gets timer
interrupts can change, and are they broadcast?). These problems are
made worse because we don't gang schedule.
> * TSC
> - rdtsc instruction can be exposed to guests in two ways
>
> 1. Trap + emulate (slow, but more reliable)
> 2. Native (fast, but possibly unreliable)
>
> Optionally also expose a 'rdtscp' instruction
>
> Possiblly set a fixed HZ independant of host.
>
There is also
3) a mixed approach; trap and emulate only when required, allow native
access and offset appropriately at each exit; and
4) a SMP safe approach; trap and emulate always, and interlock SMP
access to the clock so it is globally consistent
5) a secure approach; trap and emulate always and hide host time. This
precludes the possibility of SMP, as timing differences can be observed
since we don't gang schedule. This obviously has implications for the
other timers.
So this variable is not a simple boolean, but a multi-choice.
> VMWare timekeeping
> ------------------
>
> * All timers run in "apparant time" ie track guest wallclock
> * Missed tick policy is to deliver at higher rate to catchup
> * TSC can be switched between native/emulate (virtual_rdtsc=TRUE|FALSE)
> * TSC can have hardcoded HZ in emulate mode (apparantHZ=VALUE)
> * RTC time of day is synced to host at startup (rtc.diffFromUTC or rtc.startTime)
> * VMWare tools reset guest TOD if it gets out of sync
>
There is also lateness hiding; (timeTracker.hideLateness); adjust TSC to
compensate for lateness of injected interrupts (it's the slightly buggy
counter compensation at each tick I mention above).
> Xen timekeeping
> ---------------
>
> * Virtual platform timer (VPT) used as source for other timers
> * VPT has 4 modes
>
> 0: delay_for_missed_ticks
>
> Missed ticks are delivered when next scheduled, at the normal
> rate. RTC runs in guest wallclock, so is delayed. No catchup is
> attempted
>
> 1: no_delay_for_missed_ticks
>
> Missed ticks are delivered when next scheduled, at the normal
> rate. RTC runs in host wallclock, so is not delayed.
>
> 2: no_missed_ticks_pending
>
> Missed ticks are discarded& next tick is delivered normally. RTC
> runs in host wallclock.
>
>
> 3: one_missed_tick_pending
>
> Missed interrupts are collapsed into a single late tick. RTC
> run in host wallclock.
>
> * HPET
>
> Optionally enabled
>
> * TSC. Can run in 4 modes
>
> - auto: emulate if host TSC is unstable. native with invariant TSC
> - native: always native regardless of host TSC stability
> - emulate: trap + emulate regardless of host TSC invariant
> - pvrdtsc: native, requiring invariant TSC. Also exposes rdtscp instruction
>
TSC is complex enough without RDTSCP. Let's consider rdtscp as a host
optimization for vendors of hardware with buggy clocks who want fast
gettimeofday system calls. We already are compensating to try to keep
virtual TSC in sync on KVM and probably don't need this mode.
>
> KVM timekeeping
> ---------------
>
> * PIT: can be in kernel, or userspace (userspace deprecated for KVM)
>
> Default tick policies differ for both impls
>
> - Userspace: Default: missed ticks are delivered when next scheduled at normal rate
>
> -tdf flag enable tick reinjection to catchup
>
> - Kernel: Default: Missed ticks are delivered at higher rate to catch up
>
> -no-kvm-pit-reinjection to disable tick reinjection catchup
>
> * RTC
>
> TOD clock can run in host or guest wallclock (clock=host|guest)
>
> Default: missed ticks are delivered when next scheduled at normal rate
>
> -rtc-td-hack or -clock driftfix=slew: missed ticks are delivered at a
> higher rate to catchup
>
> * TSC
>
> - Always runs native.
>
> * HPET
>
> - Optionally enabled/disabled
>
>
> Mapping in libvirt XML
> ----------------------
>
> Currently supports setting Time of Day clock via
>
> <clock offset="utc"/>
>
> Always sync to UTC
>
> <clock offset="localtime"/>
>
> Always sync to host timezone
>
> <clock offset="timezone" timezone='Europe/Paris'/>
>
> Sync to arbitrary timezone
>
> <clock offset="variable" adjustment='123456'/>
>
> Sync to UTC + arbitrary offset
>
>
>
> Proposal to model all timers policies as sub-elements of this<clock/>
> In general we wil allow zero or more<timer/> elements following the
> syntax:
>
> <timer name='platform|pit|rtc|hpet|tsc'
> wallclock='host|guest'
> tickpolicy='none|catchup|merge|discard'
> frequency='123'
> mode='auto|native|emulate|paravirt'
> present='yes|no' />
>
> Meaning of 'name':
>
> Names map to regular PC timers / clocks. 'Platform' refers to the
> (optional) master virtual clock source that may be used to drive
> policy of "other" clocks (eg used in Xen, which clocks are controlled
> by the platform clock is to be undefined because it has varied in
> Xen over time).
>
> Meaning of 'tickpolicy':
>
> none: continue to deliver at normal rate (ie ticks are delayed)
> catchup: deliver at higher rate to catchup
> merge: ticks merged into 1 single tick
> discard: all missed ticks are discarded
>
> Meaning of 'wallclock':
>
> Only valid for name='rtc' or 'platform'
>
> host: RTC wallclock always tracks host time
> guest: RTC wallclock always tracks host time
>
> Meaning of 'frequency':
>
> Set a fixed frequency in HZ.
>
> NB: Only relevant for TSC. All other timers are fixed (PIT, RTC), or
> fully guest controlled frequency (HPET)
>
Actually, the guest doesn't control the HPET base frequency, only the
divider. I think. I'd need to recheck the spec.
> Meaning of 'mode':
>
> Control how the clock is exposed to guest.
>
> auto: native if safe, otherwise emulate
> native: always native
> emulate: always emulate
> paravirt: native + paravirtualize
>
> NB: Only relevant for TSC. All other timers are always emulated.
>
auto, native, emulate can map nicely for us, but it would be good to
have an smp safe mode. (A secure mode is more of a global setting for
all timers).
> Meaing of 'present':
>
> Used to override default set of timers visible to the guest. eg to
> enable or disable the HPET
>
>
>
> Mapping to VMWare
> -----------------
>
> eg with guest config showing
>
> diffFromUTC='123456'
> apparentHZ='123456'
> virtual_rdtsc=False
>
> libvirt XML gets:
>
> <clock mode='variable' adjustment='123456'>
> <timer name='tsc' frequency='123456' mode='native'/>
> </clock>
>
>
> Mapping to Xen
> --------------
>
> eg with guest config showing
>
> timer_mode=3
> hpet=1
> tsc_mode=2
> localtime=1
>
> <clock mode='localtime'>
> <timer name='platform' tickpolicy='merge' wallclock='host'/>
> <timer name='hpet'/>
> <timer name='tsc' mode='native'/>
> </clock>
>
>
> Mapping to KVM
> --------------
>
> eg with guest ARGV showing
>
> -no-kvm-pit-reinjection
> -clock base=localtime,clock=guest,driftfix=slew
> -no-hpet
>
>
> <clock mode='localtime'>
> <timer name='rtc' tickpolicy='catchup' wallclock='guest'/>
> <timer name='pit' tickpolicy='none'/>
> <timer name='hpet' present='no'/>
> </clock>
>
>
>
> Further reading
> ---------------
>
> VMWare has the best doc:
>
> http://www.vmware.com/pdf/vmware_timekeeping.pdf
>
> Xen:
>
> Docs on 'tsc_mode' at
>
> $SOURCETREE/docs/misc/tscmode.txt
>
> Docs for 'timer_mode' in the source code only:
>
> xen/include/public/hvm/params.h
>
> KVM:
>
> No docs at all. Guess from -help descriptions, reading source code& asking
> clever people about it :-)
>
Let me propose an XML mapping a bit later today. I haven't had coffee
yet, and we know what that can do.
Zach
2
2
Here's a patch to consolidate the contributor guidelines into one place on the website and add a section on the use of goto.
There was a small amount of content that was in HACKING but not in hacking.html.in, which I added. I also added Dan's suggested goto labels for common cases to the section on goto, and I removed the contents of HACKING and replaced them with a link to the website.
Dave
David Allan (1):
Consolidating contributor guidelines
HACKING | 395 +-------------------------------------------------
docs/hacking.html.in | 125 ++++++++++++++++-
2 files changed, 125 insertions(+), 395 deletions(-)
2
2
06 Mar '10
Here are three dead-store removals:
>From f0645665521b07febb86f05778ca354126f01179 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 5 Mar 2010 16:15:09 +0100
Subject: [PATCH 1/3] xenXMDomainConfigParse: avoid dead store
* src/xen/xm_internal.c (xenXMDomainConfigParse): Avoid dead store
to local, "data". Remove declaration, too.
---
src/xen/xm_internal.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 014cbfc..3710dcb 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -1,7 +1,7 @@
/*
* xm_internal.h: helper routines for dealing with inactive domains
*
- * Copyright (C) 2006-2007, 2009 Red Hat
+ * Copyright (C) 2006-2007, 2009, 2010 Red Hat
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -1367,7 +1367,6 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
graphics->type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
while (key) {
- char *data;
char *nextkey = strchr(key, ',');
char *end = nextkey;
if (nextkey) {
@@ -1375,7 +1374,7 @@ xenXMDomainConfigParse(virConnectPtr conn, virConfPtr conf) {
nextkey++;
}
- if (!(data = strchr(key, '=')))
+ if (!strchr(key, '='))
break;
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
--
1.7.0.1.300.gd855a
>From 78b1bea3186255891e48ddae1c822e21c5ff10db Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 5 Mar 2010 16:18:47 +0100
Subject: [PATCH 2/3] virInterfaceDefParseBond: avoid dead stores
* src/conf/interface_conf.c (virInterfaceDefParseBond): Avoid dead stores
to local, "node". Remove declaration, too.
---
src/conf/interface_conf.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index a0d2dfa..f60b36a 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -570,7 +570,6 @@ error:
static int
virInterfaceDefParseBond(virInterfaceDefPtr def,
xmlXPathContextPtr ctxt) {
- xmlNodePtr node;
int ret = -1;
unsigned long tmp;
@@ -582,8 +581,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
if (ret != 0)
goto error;
- node = virXPathNode("./miimon[1]", ctxt);
- if (node != NULL) {
+ if (virXPathNode("./miimon[1]", ctxt) != NULL) {
def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_MII;
ret = virXPathULong("string(./miimon/@freq)", ctxt, &tmp);
@@ -618,7 +616,7 @@ virInterfaceDefParseBond(virInterfaceDefPtr def,
goto error;
}
- } else if ((node = virXPathNode("./arpmon[1]", ctxt)) != NULL) {
+ } else if (virXPathNode("./arpmon[1]", ctxt) != NULL) {
def->data.bond.monit = VIR_INTERFACE_BOND_MONIT_ARP;
--
1.7.0.1.300.gd855a
>From 197167ec109b2e69ad2a6a43d02f54dee457c120 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 5 Mar 2010 17:36:40 +0100
Subject: [PATCH 3/3] ebtablesAddRemoveRule: avoid dead store
* src/util/ebtables.c (ebtablesAddRemoveRule): Avoid dead store
to local, "s".
---
src/util/ebtables.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/ebtables.c b/src/util/ebtables.c
index dba9f82..988783c 100644
--- a/src/util/ebtables.c
+++ b/src/util/ebtables.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2009 IBM Corp.
- * Copyright (C) 2007-2009 Red Hat, Inc.
+ * Copyright (C) 2007-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -185,7 +185,7 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)
1; /* arg */
va_start(args, arg);
- while ((s = va_arg(args, const char *)))
+ while (va_arg(args, const char *))
n++;
va_end(args);
--
1.7.0.1.300.gd855a
2
2
[libvirt] Libvirt segfault in qemuMonitorSend() with multi-threaded API use
by Adam Litke 06 Mar '10
by Adam Litke 06 Mar '10
06 Mar '10
I have a multi-threaded Python program that shares a single libvirt
connection object among several threads (one thread per active domain on
the system plus a management thread). On a heavily loaded host with 8
running domains I am getting a consistent libvirtd segfault in the qemu
monitor handling code. This happens with libvirt-0.7.6 and git.
Mar 4 12:23:13 bc1cn7-mgmt kernel: [ 3947.836151] libvirtd[7716]:
segfault at 24 ip 000000000045de5c sp 00007fe5aa7d2b20 error 4 in
libvirtd[400000+b3000]
Using addr2line, this translates to: libvirt/src/qemu/qemu_monitor.c:698
Which is in qemuMonitorSend():
--> while (!mon->msg->finished) {
if (virCondWait(&mon->notify, &mon->lock) < 0)
goto cleanup;
}
It seems that mon->msg is being reset to NULL in the middle of this loop
execution. I suspect that is because qemuMonitorSend() is not reentrant
and multiple threads in my program are racing here. I would guess the
'mon->msg = NULL;' on line 707 causes the NULL that trips up the other
racer.
I presume the Monitor interface has some locking protection around it to
ensure that only one thread can use it at a time?
Is there an easy way to fix this? I am not familiar with the measures
employed to make libvirt thread-safe. Thanks!
--
Thanks,
Adam
2
2
A little while ago now I wrote about the initial libvirt TCK (Technology
Compatability Kit):
http://www.mail-archive.com/libvir-list@redhat.com/msg12703.html
Since that time, it has moved on somewhat and I am regularly running it
during development & immediately before release. It has caught a large
number of bugs and was very helpful porting QEMU to the JSON mode monitor
and -device syntax
First and foremost, I moved the source repository to libvirt.org after we
switched to GIT
http://libvirt.org/git/?p=libvirt-tck.git
The list of Perl module pre-requisites is still accurate as per the original
mail.
To simplify its use, it is now possible to run it on a system which you
already have VMs on. The only restriction is that none of your virtual
machines, storage pools, networks etc have a name that starts with the
string prefix 'tck'. The test suite will complain & refuse to run if
it finds any clashes. The --force option will tell it to blow away your
existing VMs with names matching 'tck*'.
I still, however, only recommend its use on machines that you don't care
about. While I make reasonable effort not to trash your system, this kind
of testing always has a fairly high level of risk / danger, either from
bugs in libvirt, the HV, or the TCK itself.
For many of the tests you can actually run within another virtual machine.
eg, I have a Fedora 12 host, on which I run KVM. For running TCK tests, I
installed a Fedora 12 guests, and then run the TCK in this. Obviously you
won't be testing anything that requires hardware virt this way, but it is
good enough for the vast majority of tests so far. It also makes it easy
to setup tests against a large number of different OSs.
It is no longer neccessary to manually download kernels/initrds. The test
suite knows where to grab kernels/initrds off the interweb for Xen and any
fullvirtualization. It uses the hypervisor capabilities data to determine
the best kernels to use, and if it detects container based virt will setup
a busybox chroot for testing instead. It will also create any disk images
it needs, usually as sparse files, but sometimes as full files. The config
file controls where these are created if you are short on space
There are now somes tests which require access to hardware, so the config
file allows the admin running the TCK to specify any disks, USB devices,m
and PCI devices that can be used. If none are specified, any tests that
require them are skipped automagically.
Again, testing within a virtual machine makes this easy. Just add 4 extra
PCI nics and a bunch of USB disks to your guests. You can then tell the
TCK to play with them for its tests.
The number of tests has increased sigificantly
* domain/030-dominfo.t
The virDomainGetInfo API works
* domain/050-transient-lifecycle.t
Basic lifecycle operations on transient guests
* domain/051-transient-autostart.t
Verify autostart is blocked on transient guests
* domain/060-persistent-lifecycle.t
Basic lifecycle operations on persistent guests
* domain/061-persistent-autostart.t
Verify autostart is allowed on persistent guests
* domain/065-persistent-redefine.t
Verify a persistent guest config can be updated
* domain/070-transient-to-persistent.t
Conversion of transient guests to persistent guests
* domain/080-unique-id-define.t
* domain/081-unique-id-create.t
Verify name/uuid/id uniqueness when creating / defining guests
* domain/090-invalid-ops-when-inactive.t
Get suitabe errors for APIs which should not run on inactive guests
* domain/100-transient-save-restore.t
* domain/101-persistent-save-restore.t
Save/restore to/from files for guests
* domain/102-broken-save-restore.t
Verify a nice error message for delibrately corrupt save files
* domain/120-disks-stats.t
The disk IO stats reporting
* domain/200-disk-hotplug.t
Basic hotplug of disks
* domain/205-disk-hotplug-ordering.t
Ordering of disks when hotplug different types (virtio/scsi)
* domain/210-nic-hotplug.t
Basic NIC hotplug
* domain/215-nic-hotplug-many.t
Hotplug of many NICs
* domain/240-usb-host-hotplug.t
USB hostdevice assignment to guests, by vendor/product and dev/bus
* domain/250-pci-host-hotplug.t
PCI hostdevice assignment to guests
* qemu/100-disk-encryption.t
A QEMU specific test for qcow2 disk encryption
* storage/100-create-vol-dir.t
Create of all types of files in a directory pool
* storage/110-disk-pool.t
Operation of the disk pool type (ie adding/removing partitions)
* storage/200-clone-vol-dir.t
Cloning of disk volumes
There is of course scope for many many more tests to be added. Not least
for storage we have NFS, iSCSI, SCSI, filesystem pools, LVM. The entire
of the network interface APIs. Many more aspects of guest domain mgmt.
Host devices, etc
There is also work to be done to ensure the tests are fully portable across
hypervisors. I've only really tested with QEMU/KVM, and to a lesser extent
Xen and LXC.
Running the tests is quite simple
- Install the pre-requisite Perl modules (all in Fedora 12 and other distros)
- Get a GIT checkout of the libvirt-tck
- Build it
perl ./Build.PL
./Build
- Take the default config file conf/default.cfg in source tree, or5B
/etc/libvirt-tck/default.cfg after installation and set the hypervisor
URI. Optionally list some usb, pci & block devices if available for
testing
- Run it
libvirt-tck -c /path/to/your/config.cfg
The '-v' flag prints detailed progress info.
The '-t' flag lets you point it to a single test script to avoid running
all of them every time
It is possible to run without installing it too
export PERL5LIB=$TCK_GIT_TREE/lib
perl $TCK_GIT_TREE/bin/libvirt-tck -c my.cfg -t $TCK_GIT_TREE/scripts
Regards,
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
1
0
So as planned, we are somehow a wekk late but February is short.
Available at:
ftp://libvirt.org/libvirt/
Despite that short month this includes a number of few features
including new APIs and support for macvtap devices, a lot of bug
fixes and a very large amount of cleanups in the code, result of
Jim and Eric tracking plus cleanups in the internals interfaces
by Matthias and Dan.
Features:
- Introduce public API for domain async job handling (Daniel P. Berrange)
- macvtap support (Stefan Berger)
- Add QEMU support for virtio channel (Matthew Booth)
- Add persistence of PCI addresses to QEMU (Daniel P. Berrange)
- Functions for computing baseline CPU from a set of host CPUs (Jiri Denemark)
- Public API for virDomain{Attach,Detach}DeviceFlags (Jim Fehlig)
Documentation:
- web docs -- macvtap mode explanation (Stefan Berger)
- Expand docs about clock modes (Daniel P. Berrange)
- docs: Fix syntax warnings from recent changes. (Cole Robinson)
- docs: network: Document <domain> element (Cole Robinson)
- docs: network: Document STP and delay attributes (Cole Robinson)
- docs: domain: Document <description> element (Cole Robinson)
- docs: storage: Document multipath pools (Cole Robinson)
- docs: storage: Document SCSI pools (Cole Robinson)
- docs: storage: Fix backingStore <format> docs (Cole Robinson)
- docs: storage: <volume><key> is always generated. (Cole Robinson)
- docs: storage: Document capacity/alloc 'unit' (Cole Robinson)
- docs: add 3 missing spaces (Dan Kenigsberg)
- Fix typo in comment (Matthew Booth)
- libvirt: Update docs for hotplug only commands (Cole Robinson)
- Fix up a misspelled comment. (Chris Lalancette)
- doc: restrict virDomain{Attach,Detach}Device to active domains (Jim Fehlig)
- docs: Refer to virReportOOMError in the HACKING file (Matthias Bolte)
- docs: Emphasize that devices have to be inside the <devices> element (Matthias Bolte)
Portability:
- build: vbox: avoid build failure when linking with --no-add-needed (Diego Elio Pettenò)
- build: avoid dlopen-related link failure on rawhide/F13 (Diego Elio Pettenò)
- Add a define for NFS_SUPER_MAGIC (Chris Lalancette)
- Fix compliation of AppArmor related code (Matthias Bolte)
Bug Fixes:
- Fix USB passthrough based on product/vendor (Daniel P. Berrange)
- Misc fixes for LXC cgroups setup (Daniel P. Berrange)
- Change default for storage uid/gid from getuid()/getgid() to -1/-1 (Laine Stump)
- Fix parser checking of storage pool device (Daniel P. Berrange)
- Add missing device type check in QEMU PCI hotunplug (Daniel P. Berrange)
- Make domain save work on root-squash NFS (Laine Stump)
- Fix domain restore for files on root-squash NFS (Laine Stump)
- Fix USB/PCI device address aliases in QEMU hotplug driver (Daniel P. Berrange)
- Fix detection of errors in QEMU device_add command (Daniel P. Berrange)
- uml: avoid crash on partial read (Eric Blake)
- Fix QEMU domain state after a save attempt fails (Daniel P. Berrange)
- Fix error messages when parsing USB devices in QEMU (Rolf Eike Beer)
- Fix USB hotplug device string in QEMU driver (Rolf Eike Beer)
- phypUUIDTable_Push: do not corrupt output stream upon partial write (Jim Meyering)
- qemu: avoid null dereference on failed migration (Eric Blake)
- Free the macvtap mode string (Stefan Berger)
- libvirtd: do not ignore failure to set group ID in privileged mode (Jim Meyering)
- Ignore SIGWINCH in remote client call to poll(2) (RHBZ#567931). (Richard Jones)
- storage: conf: Correctly calculate exabyte unit (Cole Robinson)
- virsh.c: avoid all leaks in OOM path in cmdCPUBaseline (Jiri Denemark)
- Fixed reference count in virsh pool-build command (David Allan)
- Fix daemon-conf invalid failures (David Allan)
- virBufferVSprintf: do not omit va_end(argptr) call (Jim Meyering)
- xend_internal.c: don't dereference NULL for unexpected input (Jim Meyering)
- virsh: be careful to return "FALSE" upon OOM (Jim Meyering)
- virBufferStrcat: do not skip va_end (Jim Meyering)
- qparams.c: do not skip va_end, twice (Jim Meyering)
- get_virtual_functions_linux: would mistakenly always return zero (Jim Meyering)
- network: bridge: Fix IsActive, IsPersistent (Cole Robinson)
- qemuMonitorTextAddUSBDisk: avoid unconditional leak (Jim Meyering)
- tests: avoid NULL deref upon OOM failure (Jim Meyering)
- qemuInitPasswords: avoid unconditional leak (Jim Meyering)
- qemuMonitorTextAddDevice: avoid unconditional leak (Jim Meyering)
- libvirt-override.c: avoid a leak upon call with invalid argument (Jim Meyering)
- vboxDomainDumpXML: avoid a leak on OOM error path (Jim Meyering)
- virNodeDevCapScsiHostParseXML: avoid an unconditional leak (Jim Meyering)
- uml_driver.c: avoid leak upon failure (Jim Meyering)
- vbox_tmpl.c: avoid an unconditional leak (Jim Meyering)
- openvz (openvzFreeDriver): avoid leaks (Jim Meyering)
- Fix crash in LXC driver open method when URI has no path (Daniel P. Berrange)
- Fix USB device path formatting mixup (Daniel P. Berrange)
- qemu_driver.c: honor dname parameter once again (Jim Meyering)
- plug four virStoragePoolSourceFree-related leaks (Jim Meyering)
- remote_driver.c: avoid leak on OOM error path (Jim Meyering)
- qemu: Increase guest startup timeout to 30 seconds (Cole Robinson)
- Fix security driver configuration (Daniel P. Berrange)
- Escape strings serialized in XML (Daniel Veillard)
- absolutePathFromBaseFile: don't leak when first arg contains no "/" (Jim Meyering)
- sexpr_string: avoid leak on OOM error path (Jim Meyering)
- virDomainChrDefParseXML: don't leak upon invalid input (Jim Meyering)
- virExecWithHook: avoid leak on OOM error path (Jim Meyering)
- cgroup.c: don't leak mem+FD upon OOM (Jim Meyering)
- cgroup.c: avoid unconditional leaks (Jim Meyering)
- virt-pki-validate contains unexpanded SYSCONFDIR variable (Doug Goldstein)
Improvements:
- Convert QEMU driver all hotunplug code from pci_del to device_del (Daniel P. Berrange)
- Support hot-unplug for USB devices in QEMU (Daniel P. Berrange)
- Tweak container initialization to make upstart/init happier (Daniel P. Berrange)
- Avoid creating top level cgroups if just querying for existance (Daniel P. Berrange)
- Support VCPU hotplug in QEMU guests (Daniel P. Berrange)
- Fix mis-leading error message in pool delete API (Daniel P. Berrange)
- Fix typo in QEMU migration command name (Daniel P. Berrange)
- Don't raise error message from cgroups if QEMU fails to start (Daniel P. Berrange)
- esx: don't ignore failure on close (Eric Blake)
- Fix safezero() (Jiri Denemark)
- Support job cancellation in QEMU driver (Daniel P. Berrange)
- Remote driver implementation for the virDomainAbortJob APi (Daniel P. Berrange)
- Wire up internal entry points for virDomainAbortJob API (Daniel P. Berrange)
- Introduce public API for cancelling async domain jobs (Daniel P. Berrange)
- Add QEMU driver support for job info on migration ops (Daniel P. Berrange)
- Remote driver implmentation of job info API (Daniel P. Berrange)
- Stub out internal driver entry points for job processing (Daniel P. Berrange)
- Use device_del to remove SCSI controllers (Wolfgang Mauerer)
- Fix PCI address handling when controllers are deleted (Wolfgang Mauerer)
- Fix data structure handling when controllers are attached (Wolfgang Mauerer)
- Allow configurable timezones with QEMU (Daniel P. Berrange)
- Allow a timezone to be specified instead of sync to host timezone (Daniel P. Berrange)
- Support variable clock offset mode in QEMU (Daniel P. Berrange)
- Add new clock mode allowing variable adjustments (Daniel P. Berrange)
- Change the internal domain conf representation of localtime/utc (Daniel P. Berrange)
- Use standard spacing for user/pass prompt (Cole Robinson)
- libvirtd: Better initscript error reporting (Cole Robinson)
- qemu: Report binary path if error parsing -help (Cole Robinson)
- remote: Improve daemon startup error reporting (Cole Robinson)
- virsh: Show errors reported by nonAPI functions (Cole Robinson)
- remote: Improve error message when libvirtd isn't running (Cole Robinson)
- build: make git submodule checking more reliable (Jim Meyering)
- Add descriptions for macvtap direct type interfaces (Stefan Berger)
- maint: import modern bootstrap (Eric Blake)
- maint: start factoring bootstrap (Eric Blake)
- build: update gnulib submodule to latest (Jim Meyering)
- Create raw storage files with O_DSYNC (again) (Jiri Denemark)
- Use virFileOperation hook function in virStorageBackendFileSystemVolBuild (Laine Stump)
- Rename virFileCreate to virFileOperation, add hook function (Laine Stump)
- qemu: Check for IA64 kvm (Dustin Xiong)
- remote: Print ssh stderr on connection failure (Cole Robinson)
- fix multiple veth problem for OpenVZ (Yuji NISHIDA)
- Better error reporting for failed migration (Chris Lalancette)
- Make an error message in PCI util code clearer (Chris Lalancette)
- macvtap mac_filter support (Stefan Berger)
- macvtap IFF_VNET_HDR configuration (Stefan Berger)
- Use virFork() in __virExec(), virFileCreate() and virDirCreate() (Laine Stump)
- Add virFork() function to utils (Laine Stump)
- Add domain support for virtio channel (Matthew Booth)
- qemu: Explicitly error if guest virtual network is inactive (Cole Robinson)
- virterror: Make SetError work if no previous error was set (Cole Robinson)
- macvtap teardown rework (Stefan Berger)
- Update QEMU JSON balloon command handling (Daniel P. Berrange)
- python: Actually add virConnectGetVersion to generated bindings (Cole Robinson)
- build: inform libtool of m4 directory (Eric Blake)
- Adds a cpu-baseline command for virsh (Jiri Denemark)
- qemu: Make SetVcpu command hotplug only (Cole Robinson)
- qemu: Make Set*Mem commands hotplug only (Cole Robinson)
- Treat missing QEMU 'thread_id' as non-fatal in JSON monitor (Daniel P. Berrange)
- Fix check for primary IDE controller in QEMU PCI slot assignment (Daniel P. Berrange)
- Make error reporting for QEMU JSON mode more friendly (Daniel P. Berrange)
- Run 'qmp_capabilities' command at QEMU monitor startup (Daniel P. Berrange)
- macvtap support for libvirt -- schema extensions (Stefan Berger)
- macvtap support for libvirt -- qemu support (Stefan Berger)
- macvtap support for libvirt -- helper code (Stefan Berger)
- macvtap support for libvirt -- parse new interface XML (Stefan Berger)
- interface: Use proper return codes in the open function (Matthias Bolte)
- Support 'block_passwd' command for QEMU disk encryption (Daniel P. Berrange)
- Implement cpuBaseline in remote and qemu drivers (Jiri Denemark)
- Wire protocol format and dispatcher for virConnectBaselineCPU (Jiri Denemark)
- virConnectBaselineCPU public API implementation (Jiri Denemark)
- Internal driver API for virConnectBaselineCPU (Jiri Denemark)
- virConnectBaselineCPU public API (Jiri Denemark)
- Implement cpuArchBaseline in x86 CPU driver (Jiri Denemark)
- Implement cpuArchBaseline in generic CPU driver (Jiri Denemark)
- Mark all error messages for translation (Jiri Denemark)
- Add cpu_generic.c to the list of translated files (Jiri Denemark)
- Fix <cpu> element in domain XML schema (Jiri Denemark)
- Fix disk stats retrieval with QEMU >= 0.12 (Daniel P. Berrange)
- qemu: Properly report a startup timeout error (Cole Robinson)
- test: Fake security driver support in capabilities (Cole Robinson)
- Annotate some virConnectPtr as mandatory non-null (Daniel P. Berrange)
- Convert qemu command line flags to 64-bit int (Daniel P. Berrange)
- Create raw storage files with O_DSYNC (Jiri Denemark)
- Re-generate remote protocol files for new APIs (Daniel P. Berrange)
- Modify virsh commands (Jim Fehlig)
- domain{Attach,Detach}DeviceFlags handler for drivers (Jim Fehlig)
- Server side dispatcher (Jim Fehlig)
- Remote driver (Jim Fehlig)
- Wire protocol format (Jim Fehlig)
- Public API Implementation (Jim Fehlig)
Cleanups:
- virsh: silence compiler warning (Eric Blake)
- build: silence coverity warning in node_device (Eric Blake)
- Tiny spelling fix (Wolfgang Mauerer)
- libvirtd: avoid false-positive NULL-deref warning from clang (Eric Blake)
- x86Decode: avoid NULL-dereference upon questionable input (Jim Meyering)
- openvzDomainDefineCmd: remove useless increment (Jim Meyering)
- maint: disallow TAB-in-indentation also in *.rng files (Jim Meyering)
- maint: convert leading TABs in *.rng files to equivalent spaces (Jim Meyering)
- udevEnumerateDevices: remove dead code (Jim Meyering)
- qemudNetworkIfaceConnect: remove dead store (Jim Meyering)
- cmdPoolDiscoverSources: initialize earlier to avoid FP from clang (Jim Meyering)
- build: avoid warning about return-with-value in void function (Jim Meyering)
- Only build virDomainObjFormat if not building proxy. (Chris Lalancette)
- openvzGetVEID: don't leak (memory + file descriptor) (Jim Meyering)
- build: avoid warning about unused variables (Jim Meyering)
- build: avoid "make rpm" failure in docs/ (Jim Meyering)
- build: teach apibuild.py to work in a non-srcdir build (Jim Meyering)
- build: avoid non-srcdir "make distcheck" failures (CLEANFILES) (Jim Meyering)
- build: avoid non-srcdir "make distcheck" failures (srcdir vs wildcard) (Jim Meyering)
- build: avoid non-srcdir "make distcheck" failure (test_conf.sh) (Jim Meyering)
- build: avoid non-srcdir installation failure (sitemap.html.in) (Jim Meyering)
- build: avoid non-srcdir installation failure (apibuild.py) (Jim Meyering)
- build: fix typos in makefile variable names (Jim Meyering)
- build: ensure that MKINSTALLDIRS is AC_SUBST-defined (Jim Meyering)
- maint: relax git minimum version (Eric Blake)
- maint: sort .gitignore (Eric Blake)
- maint: fix quoting in autogen.sh (Eric Blake)
- virFork: placate static analyzers: ignore pthread_sigmask return value (Jim Meyering)
- virsh.c: avoid leak on OOM error path (Jim Meyering)
- Make virDomainObjFormat static (Chris Lalancette)
- xenDaemonDomainSetAutostart: avoid appearance of impropriety (Jim Meyering)
- Remove unused functions from domain_conf (Matthew Booth)
- Fix whitespace in domain.rng (Matthew Booth)
- openvzLoadDomains: don't ignore failing virUUIDFormat (Jim Meyering)
- vshCommandParse: placate coverity (Jim Meyering)
- virStorageBackendIsMultipath: avoid dead store (Jim Meyering)
- Convert virSecurityReportError into a macro (Matthias Bolte)
- Swap position of nmodels and models parameters in cpuDecode() (Jiri Denemark)
- Remove virConnectPtr from secret XML APIs (Daniel P. Berrange)
- Remove virConnectPtr from interface XML APIs (Daniel P. Berrange)
- Remove virConnectPtr from CPU XML APIs (Daniel P. Berrange)
- Remove virConnectPtr from storage APIs & driver (Daniel P. Berrange)
- Remove virConnectPtr from all node device XML APIs (Daniel P. Berrange)
- Remove virConnectPtr from network XML APis (Daniel P. Berrange)
- Remove virConnectPtr from USB/PCI device iterators (Daniel P. Berrange)
- Fix generation of floppy disk arg for QEMU's -global arg (Daniel P. Berrange)
- Fix compile error in Xen proxy from virConnectPtr changes (Daniel P. Berrange)
- Remove use of virConnectPtr from security driver APIs (Daniel P. Berrange)
- Remove virConnectPtr from all domain XML parsing/formatting APIs (Daniel P. Berrange)
- Remove virConnectPtr from LXC driver (Daniel P. Berrange)
- Remove passing of virConnectPtr throughout QEMU driver (Daniel P. Berrange)
- virAsprintf: remove its warn_unused_result attribute (Jim Meyering)
- absolutePathFromBaseFile: avoid an unnecessary use of assert (Jim Meyering)
- Remove conn parameter from USB functions (Matthias Bolte)
- Remove conn parameter from JSON error macro (Matthias Bolte)
- Remove conn parameter from PCI functions (Matthias Bolte)
- Remove conn parameter from Linux stats functions (Matthias Bolte)
- Remove conn parameter from storage file functions (Matthias Bolte)
- Remove conn parameter from util functions (Matthias Bolte)
- Remove conn parameter from virXPath* functions (Matthias Bolte)
- Remove conn parameter from virReportSystemError (Matthias Bolte)
- Remove conn parameter from virReportOOMError (Matthias Bolte)
- website: Add a 1em right margin (Matthias Bolte)
- storage: Replace storageLog with VIR_ERROR (Matthias Bolte)
- opennebula: Remove unnecessary casts (Matthias Bolte)
- esx: Remove unnecessary casts (Matthias Bolte)
- cpu conf: Use virBufferFreeAndReset instead of virBufferContentAndReset and VIR_FREE (Matthias Bolte)
- esx: Cleanup preprocessing structure in esxVI_EnsureSession (Matthias Bolte)
Thanks everybody for getting this out !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
1
0
06 Mar '10
This adds more information about the different macvtap device modes,
spells out VEPA and adds a link to a pdf at the ieee site.
Regards,
Stefan
2
1
[libvirt] [PATCH] qemuMonitorTextGetMemoryStats: decrease risk of false positive in parsing
by Jim Meyering 06 Mar '10
by Jim Meyering 06 Mar '10
06 Mar '10
Not urgent.
This was highlighted by clang as a dead store, since
the first result stored in "offset" was never used.
But if "info balloon" were ever to print some introductory
text (containing a comma) before the balloon: actual... line,
the bug would have made a difference.
>From c81c6af87f20740a6b75652937ec8346f8bf59e3 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 5 Mar 2010 15:25:48 +0100
Subject: [PATCH] qemuMonitorTextGetMemoryStats: decrease risk of false positive in parsing
The code erroneously searched the entire "reply" for a comma, when
its intent was to search only that portion after "balloon: actual="
* src/qemu/qemu_monitor_text.c (qemuMonitorTextGetMemoryStats):
Search for "," only starting *after* the BALLOON_PREFIX string.
Otherwise, we'd be more prone to false positives.
---
src/qemu/qemu_monitor_text.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7f0e7f6..e629c6b 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -593,7 +593,8 @@ int qemuMonitorTextGetMemoryStats(qemuMonitorPtr mon,
}
if ((offset = strstr(reply, BALLOON_PREFIX)) != NULL) {
- if ((offset = strchr(reply, ',')) != NULL) {
+ offset += strlen(BALLOON_PREFIX);
+ if ((offset = strchr(offset, ',')) != NULL) {
ret = qemuMonitorParseExtraBalloonInfo(offset, stats, nr_stats);
}
}
--
1.7.0.1.300.gd855a
2
1
06 Mar '10
Changeset
commit 5073aa994af460e775cb3e548528e28d7660fcc8
Author: Cole Robinson <crobinso(a)redhat.com>
Date: Mon Jan 11 11:40:46 2010 -0500
Added support for product/vendor based passthrough, but it only
worked at the security driver layer. The main guest XML config
was not updated with the resolved bus/device ID. When the QEMU
argv refactoring removed use of product/vendor, this then broke
launching guests.
THe solution is to move the product/vendor resolution up a layer
into the QEMU driver. So the first thing QEMU does is resolve
the product/vendor to a bus/device and updates the XML config
with this info. The rest of the code, including security drivers
and QEMU argv generated can now rely on bus/device always being
set.
* src/util/hostusb.c, src/util/hostusb.h: Split vendor/product
resolution code out of usbGetDevice and into usbFindDevice.
Add accessors for bus/device ID
* src/security/virt-aa-helper.c, src/security/security_selinux.c,
src/qemu/qemu_security_dac.c: Remove vendor/product from the
usbGetDevice() calls
* src/qemu/qemu_driver.c: Use usbFindDevice to resolve vendor/product
into a bus/device ID
---
src/libvirt_private.syms | 3 +
src/qemu/qemu_driver.c | 102 +++++++++++++++++++++++++++++++++++----
src/qemu/qemu_security_dac.c | 8 +--
src/security/security_selinux.c | 8 +--
src/security/virt-aa-helper.c | 4 +-
src/util/hostusb.c | 39 +++++++++++----
src/util/hostusb.h | 13 +++--
7 files changed, 136 insertions(+), 41 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ce9f013..c5ee23d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -599,7 +599,10 @@ virArgvToString;
# usb.h
usbGetDevice;
+usbFindDevice;
usbFreeDevice;
+usbDeviceGetBus;
+usbDeviceGetDevno;
usbDeviceFileIterate;
# uuid.h
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ef3cd6c..50bd55b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2283,17 +2283,15 @@ cleanup:
return ret;
}
+
static int
-qemuPrepareHostDevices(struct qemud_driver *driver,
- virDomainDefPtr def)
+qemuPrepareHostPCIDevices(struct qemud_driver *driver,
+ virDomainDefPtr def)
{
pciDeviceList *pcidevs;
int i;
int ret = -1;
- if (!def->nhostdevs)
- return 0;
-
if (!(pcidevs = qemuGetPciHostDeviceList(def)))
return -1;
@@ -2344,6 +2342,62 @@ cleanup:
return ret;
}
+
+static int
+qemuPrepareHostUSBDevices(struct qemud_driver *driver ATTRIBUTE_UNUSED,
+ virDomainDefPtr def)
+{
+ int i;
+ for (i = 0 ; i < def->nhostdevs ; i++) {
+ virDomainHostdevDefPtr hostdev = def->hostdevs[i];
+
+ if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
+ continue;
+ if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+ continue;
+
+ /* Resolve a vendor/product to bus/device */
+ if (hostdev->source.subsys.u.usb.vendor) {
+ usbDevice *usb
+ = usbFindDevice(hostdev->source.subsys.u.usb.vendor,
+ hostdev->source.subsys.u.usb.product);
+
+ if (!usb)
+ return -1;
+
+ hostdev->source.subsys.u.usb.bus = usbDeviceGetBus(usb);
+ hostdev->source.subsys.u.usb.device = usbDeviceGetDevno(usb);
+
+ fprintf(stderr, "Resolve %u %u -> %u %u\n",
+ hostdev->source.subsys.u.usb.vendor,
+ hostdev->source.subsys.u.usb.product,
+ hostdev->source.subsys.u.usb.bus,
+ hostdev->source.subsys.u.usb.device );
+
+ usbFreeDevice(usb);
+ }
+ }
+
+ return 0;
+}
+
+static int
+qemuPrepareHostDevices(struct qemud_driver *driver,
+ virDomainDefPtr def)
+{
+ if (!def->nhostdevs)
+ return 0;
+
+ if (qemuPrepareHostPCIDevices(driver, def) < 0)
+ return -1;
+
+ if (qemuPrepareHostUSBDevices(driver, def) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static void
qemudReattachManagedDevice(pciDevice *dev)
{
@@ -6114,6 +6168,23 @@ static int qemudDomainAttachHostDevice(struct qemud_driver *driver,
return -1;
}
+ /* Resolve USB product/vendor to bus/device */
+ if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB &&
+ hostdev->source.subsys.u.usb.vendor) {
+ usbDevice *usb
+ = usbFindDevice(hostdev->source.subsys.u.usb.vendor,
+ hostdev->source.subsys.u.usb.product);
+
+ if (!usb)
+ return -1;
+
+ hostdev->source.subsys.u.usb.bus = usbDeviceGetBus(usb);
+ hostdev->source.subsys.u.usb.device = usbDeviceGetDevno(usb);
+
+ usbFreeDevice(usb);
+ }
+
+
if (driver->securityDriver &&
driver->securityDriver->domainSetSecurityHostdevLabel &&
driver->securityDriver->domainSetSecurityHostdevLabel(vm, hostdev) < 0)
@@ -6677,11 +6748,22 @@ static int qemudDomainDetachHostUsbDevice(struct qemud_driver *driver,
unsigned bus = vm->def->hostdevs[i]->source.subsys.u.usb.bus;
unsigned device = vm->def->hostdevs[i]->source.subsys.u.usb.device;
-
- if (dev->data.hostdev->source.subsys.u.usb.bus == bus &&
- dev->data.hostdev->source.subsys.u.usb.device == device) {
- detach = vm->def->hostdevs[i];
- break;
+ unsigned product = vm->def->hostdevs[i]->source.subsys.u.usb.product;
+ unsigned vendor = vm->def->hostdevs[i]->source.subsys.u.usb.vendor;
+
+ if (dev->data.hostdev->source.subsys.u.usb.bus &&
+ dev->data.hostdev->source.subsys.u.usb.device) {
+ if (dev->data.hostdev->source.subsys.u.usb.bus == bus &&
+ dev->data.hostdev->source.subsys.u.usb.device == device) {
+ detach = vm->def->hostdevs[i];
+ break;
+ }
+ } else {
+ if (dev->data.hostdev->source.subsys.u.usb.product == product &&
+ dev->data.hostdev->source.subsys.u.usb.vendor == vendor) {
+ detach = vm->def->hostdevs[i];
+ break;
+ }
}
}
diff --git a/src/qemu/qemu_security_dac.c b/src/qemu/qemu_security_dac.c
index f281b96..6911f48 100644
--- a/src/qemu/qemu_security_dac.c
+++ b/src/qemu/qemu_security_dac.c
@@ -206,9 +206,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virDomainObjPtr vm,
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device,
- dev->source.subsys.u.usb.vendor,
- dev->source.subsys.u.usb.product);
+ dev->source.subsys.u.usb.device);
if (!usb)
goto done;
@@ -277,9 +275,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virDomainObjPtr vm ATTRIBUTE_UNUSED,
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device,
- dev->source.subsys.u.usb.vendor,
- dev->source.subsys.u.usb.product);
+ dev->source.subsys.u.usb.device);
if (!usb)
goto done;
diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c
index 06a2479..b2c8581 100644
--- a/src/security/security_selinux.c
+++ b/src/security/security_selinux.c
@@ -491,9 +491,7 @@ SELinuxSetSecurityHostdevLabel(virDomainObjPtr vm,
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device,
- dev->source.subsys.u.usb.vendor,
- dev->source.subsys.u.usb.product);
+ dev->source.subsys.u.usb.device);
if (!usb)
goto done;
@@ -561,9 +559,7 @@ SELinuxRestoreSecurityHostdevLabel(virDomainObjPtr vm,
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device,
- dev->source.subsys.u.usb.vendor,
- dev->source.subsys.u.usb.product);
+ dev->source.subsys.u.usb.device);
if (!usb)
goto done;
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 066e18b..78bef41 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -836,9 +836,7 @@ get_files(vahControl * ctl)
switch (dev->source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
usbDevice *usb = usbGetDevice(dev->source.subsys.u.usb.bus,
- dev->source.subsys.u.usb.device,
- dev->source.subsys.u.usb.vendor,
- dev->source.subsys.u.usb.product);
+ dev->source.subsys.u.usb.device);
if (usb == NULL)
continue;
diff --git a/src/util/hostusb.c b/src/util/hostusb.c
index bf96539..afba325 100644
--- a/src/util/hostusb.c
+++ b/src/util/hostusb.c
@@ -159,9 +159,7 @@ cleanup:
usbDevice *
usbGetDevice(unsigned bus,
- unsigned devno,
- unsigned vendor,
- unsigned product)
+ unsigned devno)
{
usbDevice *dev;
@@ -170,14 +168,6 @@ usbGetDevice(unsigned bus,
return NULL;
}
- if (vendor) {
- /* Look up bus.dev by vendor:product */
- if (usbFindBusByVendor(vendor, product, &bus, &devno) < 0) {
- VIR_FREE(dev);
- return NULL;
- }
- }
-
dev->bus = bus;
dev->dev = devno;
@@ -194,6 +184,21 @@ usbGetDevice(unsigned bus,
return dev;
}
+
+usbDevice *
+usbFindDevice(unsigned vendor,
+ unsigned product)
+{
+ unsigned bus = 0, devno = 0;
+
+ if (usbFindBusByVendor(vendor, product, &bus, &devno) < 0) {
+ return NULL;
+ }
+
+ return usbGetDevice(bus, devno);
+}
+
+
void
usbFreeDevice(usbDevice *dev)
{
@@ -202,6 +207,18 @@ usbFreeDevice(usbDevice *dev)
}
+unsigned usbDeviceGetBus(usbDevice *dev)
+{
+ return dev->bus;
+}
+
+
+unsigned usbDeviceGetDevno(usbDevice *dev)
+{
+ return dev->dev;
+}
+
+
int usbDeviceFileIterate(usbDevice *dev,
usbDeviceFileActor actor,
void *opaque)
diff --git a/src/util/hostusb.h b/src/util/hostusb.h
index bc22671..9a1b1b7 100644
--- a/src/util/hostusb.h
+++ b/src/util/hostusb.h
@@ -26,11 +26,14 @@
typedef struct _usbDevice usbDevice;
-usbDevice *usbGetDevice (unsigned bus,
- unsigned devno,
- unsigned vendor,
- unsigned product);
-void usbFreeDevice (usbDevice *dev);
+usbDevice *usbGetDevice(unsigned bus,
+ unsigned devno);
+usbDevice *usbFindDevice(unsigned vendor,
+ unsigned product);
+void usbFreeDevice (usbDevice *dev);
+
+unsigned usbDeviceGetBus(usbDevice *dev);
+unsigned usbDeviceGetDevno(usbDevice *dev);
/*
* Callback that will be invoked once for each file
--
1.6.5.2
2
1
06 Mar '10
One of the things we've not dealt with in libvirt yet is how to model the
various evil hacks most virt products have for dealing with timers in
guests. This email tries to outlines the problems & way each virt system
has dealt with them. Finally it suggests how to manage this in libvirt
domain XML. Comments please :-)
Virtual machine timer management in libvirt
===========================================
On PC hardware there are a number of terrible timers / clock sources available
to operating systems
* PIT
Timer with periodic interrupts
* RTC
Time of Day clock, continuous running
Timer with periodic interrupts
* Local APIC Timer
Timer with periodic interrupts
* ACPI Timer
Timer with periodic interrupts
* TSC
Read via rdtsc instruction. No interrupts
Unreliable on some hardware. eg changes frequency.
Not synced between cores
Different HZ across hosts
* HPET
Multiple timers with periodic interrupts
Can replace PIT/RTC timers
They all generally suck in real hardware, and this gets worse in virtual machines.
Many different approaches to making them suck less in VMWare, Xen & KVM, but there
are some reasonably common concepts....
Virtual timekeeping problems
----------------------------
Three primary problems / areas to deal with:
* Time of day clock (RTC)
- Initialized to UTC/Localtime/Timezone/UTC+offset
- Two modes of operation:
1. Guest wallclock: only runs when guest is executing. ie stopped across save/restore, etc
2. Host wallclock: runs continuously with host wall time.
* Interrupt timers
- Ticks can not always be delivered on time
Policies to deal with "missed" ticks:
1. Deliver at normal rate without catchup
2. Deliver at higher rate to catch up
3. Merge into 1 tick & deliver asap
4. Discard all missed ticks
* TSC
- rdtsc instruction can be exposed to guests in two ways
1. Trap + emulate (slow, but more reliable)
2. Native (fast, but possibly unreliable)
Optionally also expose a 'rdtscp' instruction
Possiblly set a fixed HZ independant of host.
VMWare timekeeping
------------------
* All timers run in "apparant time" ie track guest wallclock
* Missed tick policy is to deliver at higher rate to catchup
* TSC can be switched between native/emulate (virtual_rdtsc=TRUE|FALSE)
* TSC can have hardcoded HZ in emulate mode (apparantHZ=VALUE)
* RTC time of day is synced to host at startup (rtc.diffFromUTC or rtc.startTime)
* VMWare tools reset guest TOD if it gets out of sync
Xen timekeeping
---------------
* Virtual platform timer (VPT) used as source for other timers
* VPT has 4 modes
0: delay_for_missed_ticks
Missed ticks are delivered when next scheduled, at the normal
rate. RTC runs in guest wallclock, so is delayed. No catchup is
attempted
1: no_delay_for_missed_ticks
Missed ticks are delivered when next scheduled, at the normal
rate. RTC runs in host wallclock, so is not delayed.
2: no_missed_ticks_pending
Missed ticks are discarded & next tick is delivered normally. RTC
runs in host wallclock.
3: one_missed_tick_pending
Missed interrupts are collapsed into a single late tick. RTC
run in host wallclock.
* HPET
Optionally enabled
* TSC. Can run in 4 modes
- auto: emulate if host TSC is unstable. native with invariant TSC
- native: always native regardless of host TSC stability
- emulate: trap + emulate regardless of host TSC invariant
- pvrdtsc: native, requiring invariant TSC. Also exposes rdtscp instruction
KVM timekeeping
---------------
* PIT: can be in kernel, or userspace (userspace deprecated for KVM)
Default tick policies differ for both impls
- Userspace: Default: missed ticks are delivered when next scheduled at normal rate
-tdf flag enable tick reinjection to catchup
- Kernel: Default: Missed ticks are delivered at higher rate to catch up
-no-kvm-pit-reinjection to disable tick reinjection catchup
* RTC
TOD clock can run in host or guest wallclock (clock=host|guest)
Default: missed ticks are delivered when next scheduled at normal rate
-rtc-td-hack or -clock driftfix=slew: missed ticks are delivered at a
higher rate to catchup
* TSC
- Always runs native.
* HPET
- Optionally enabled/disabled
Mapping in libvirt XML
----------------------
Currently supports setting Time of Day clock via
<clock offset="utc"/>
Always sync to UTC
<clock offset="localtime"/>
Always sync to host timezone
<clock offset="timezone" timezone='Europe/Paris'/>
Sync to arbitrary timezone
<clock offset="variable" adjustment='123456'/>
Sync to UTC + arbitrary offset
Proposal to model all timers policies as sub-elements of this <clock/>
In general we wil allow zero or more <timer/> elements following the
syntax:
<timer name='platform|pit|rtc|hpet|tsc'
wallclock='host|guest'
tickpolicy='none|catchup|merge|discard'
frequency='123'
mode='auto|native|emulate|paravirt'
present='yes|no' />
Meaning of 'name':
Names map to regular PC timers / clocks. 'Platform' refers to the
(optional) master virtual clock source that may be used to drive
policy of "other" clocks (eg used in Xen, which clocks are controlled
by the platform clock is to be undefined because it has varied in
Xen over time).
Meaning of 'tickpolicy':
none: continue to deliver at normal rate (ie ticks are delayed)
catchup: deliver at higher rate to catchup
merge: ticks merged into 1 single tick
discard: all missed ticks are discarded
Meaning of 'wallclock':
Only valid for name='rtc' or 'platform'
host: RTC wallclock always tracks host time
guest: RTC wallclock always tracks host time
Meaning of 'frequency':
Set a fixed frequency in HZ.
NB: Only relevant for TSC. All other timers are fixed (PIT, RTC), or
fully guest controlled frequency (HPET)
Meaning of 'mode':
Control how the clock is exposed to guest.
auto: native if safe, otherwise emulate
native: always native
emulate: always emulate
paravirt: native + paravirtualize
NB: Only relevant for TSC. All other timers are always emulated.
Meaing of 'present':
Used to override default set of timers visible to the guest. eg to
enable or disable the HPET
Mapping to VMWare
-----------------
eg with guest config showing
diffFromUTC='123456'
apparentHZ='123456'
virtual_rdtsc=False
libvirt XML gets:
<clock mode='variable' adjustment='123456'>
<timer name='tsc' frequency='123456' mode='native'/>
</clock>
Mapping to Xen
--------------
eg with guest config showing
timer_mode=3
hpet=1
tsc_mode=2
localtime=1
<clock mode='localtime'>
<timer name='platform' tickpolicy='merge' wallclock='host'/>
<timer name='hpet'/>
<timer name='tsc' mode='native'/>
</clock>
Mapping to KVM
--------------
eg with guest ARGV showing
-no-kvm-pit-reinjection
-clock base=localtime,clock=guest,driftfix=slew
-no-hpet
<clock mode='localtime'>
<timer name='rtc' tickpolicy='catchup' wallclock='guest'/>
<timer name='pit' tickpolicy='none'/>
<timer name='hpet' present='no'/>
</clock>
Further reading
---------------
VMWare has the best doc:
http://www.vmware.com/pdf/vmware_timekeeping.pdf
Xen:
Docs on 'tsc_mode' at
$SOURCETREE/docs/misc/tscmode.txt
Docs for 'timer_mode' in the source code only:
xen/include/public/hvm/params.h
KVM:
No docs at all. Guess from -help descriptions, reading source code & asking
clever people about it :-)
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
1
0
This series provides some small fixes to the LXC driver which bring
it closer to being able to run a full Fedora OS with regular init
(upstart) startup process
2
6
Hello everyone, sorry for my English,
I need to create a script (preferably in Python) that runs on a host
machine, I return the IP address of a Ghost running, providing its hostname.
In this VM is assigned the IP in DHCP with a network with this
configuration:
$ virsh net-dumpxml network1
Connecting to uri: qemu:///system
<network>
<name>network1</name>
<uuid>6050d8d4-4030-fdd5-ddfa-041c89bbdfa7</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' forwardDelay='0' />
<ip address='192.168.100.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.100.2' end='192.168.100.254' />
</dhcp>
</ip>
</network>
While the configuration of one of the VM is:
$ virsh dumpxml test1
Connecting to uri: qemu:///system
<domain type='kvm' id='1'>
<name>test1</name>
<uuid>cf71c7d3-0d05-d51c-492e-f5ad2be3ec0e</uuid>
<memory>524288</memory>
<currentMemory>524288</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch='x86_64' machine='pc-0.11'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file' device='cdrom'>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>
<disk type='file' device='disk'>
<source file='/var/lib/libvirt/images/test1.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='network'>
<mac address='54:52:00:4e:59:0d'/>
<source network='network1'/>
<target dev='vnet0'/>
<model type='virtio'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/1'/>
<target port='0'/>
</serial>
<console type='pty' tty='/dev/pts/1'>
<source path='/dev/pts/1'/>
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='5900' autoport='yes' keymap='it'/>
<sound model='es1370'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
</video>
</devices>
<seclabel type='dynamic' model='apparmor'>
<label>libvirt-cf71c7d3-0d05-d51c-492e-f5ad2be3ec0e</label>
<imagelabel>libvirt-cf71c7d3-0d05-d51c-492e-f5ad2be3ec0e</imagelabel>
</seclabel>
</domain>
Give me a hand?
Thanks
--
Angelo
1
0
[libvirt] Assigning a static IP to the Linux Container through libvirt.
by Kumar L Srikanth-B22348 05 Mar '10
by Kumar L Srikanth-B22348 05 Mar '10
05 Mar '10
Hi,
I want to assign a static IP 172.16.1.20 to one of the containers
created using libvirt.
For that, I defined a network 'mynetwork' using net-define. The XML
format for that network is shown below:
<network>
<name>mynetwork</name>
<uuid>f76c44dd-bcef-6b45-4a50-00d575a369ad</uuid>
<bridge name='virbr1' stp='on' delay='0' />
<ip address='172.16.1.20' netmask='255.255.255.0'>
</ip>
</network>
I started the network 'mynetwork' using net-start.
virsh # net-list --all
Name State Autostart
-----------------------------------------
default active yes
mynetwork active no
I created a domain 'vm1_fedora' with libvirt XML:
<domain type='lxc' id='1'>
<name>vm1_fedora</name>
<memory>500000</memory>
<os>
<type>exe</type>
<init>/bin/bash</init>
</os>
<vcpu>1</vcpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/libexec/libvirt_lxc</emulator>
<filesystem type='mount'>
<source dir='/root/lxc/fedora12'/>
<target dir='/'/>
</filesystem>
<filesystem type='mount'>
<source dir='/root/lxc/fedora12/dev'/>
<target dir='/dev'/>
</filesystem>
<interface type='network'>
<source network='mynetwork'/>
</interface>
<console type='pty' />
</devices>
</domain>
But, when I start that domain and see for 'ifconfig', I am not able to
see the IP address 172.16.1.20 there.
[root@localhost /]# ifconfig
eth0 Link encap:Ethernet HWaddr 52:54:00:53:4D:BF
inet6 addr: fe80::5054:ff:fe53:4dbf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:840 (840.0 b) TX bytes:384 (384.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
can you please let me know, how can I assign a static IP to the Linux
Container?
Regards,
Srikanth.
2
2
Hi,
I am using libvirt version 0.7.6, to create a Linux Container. With the
domain XML format, I am able to create a Domain and able to access.
But, I am struck at assigning an IP address to the Domain. I want to
assign a static IP to eth0 of the Domain and ale to ping that from the
host machine.
For that, I created a bridge br0 [which can be linked to the interface
eth0 of the Domain created by libvirt] with the IP 172.16.1.10. I want
to assign an IP 172.16.1.16 to the Domain.
Can any one please guide me?
Regards,
Srikanth.
1
0
[libvirt] [PATCH] Change default for storage uid/gid from getuid()/getgid() to -1/-1
by Laine Stump 05 Mar '10
by Laine Stump 05 Mar '10
05 Mar '10
This allows the config to have a setting that means "leave it alone",
eg when building a pool where the directory already exists the user
may want the current uid/gid of the directory left intact. This
actually gets us back to older behavior - before recent changes to the
pool building code, we weren't as insistent about honoring the uid/gid
settings in the XML, and virt-manager was taking advantage of this
behavior.
As a side benefit, removing calls to getuid/getgid from the XML
parsing functions also seems like a good idea. And having a default
that is different from a common/useful value (0 == root) is a good
thing in general, as it removes ambiguity from decisions (at least one
place in the code was checking for (perms.uid == 0) to see if a
special uid was requested).
Note that this will only affect newly created pools and volumes. Due
to the way that the XML is parsed, then formatted for newly created
volumes, all existing pools/volumes already have an explicit uid and
gid set.
src/conf/storage_conf.c: Remove calls to setuid/setgid for default values
of uid/gid, and set them to -1 instead
src/storage/storage_backend.c:
src/storage/storage_backend_fs.c:
Make account for the new default values of perms.uid
and perms.gid.
---
src/conf/storage_conf.c | 8 +++---
src/storage/storage_backend.c | 25 +++++++++++++----------
src/storage/storage_backend_fs.c | 39 +++++++++++++++++++++++++++----------
3 files changed, 46 insertions(+), 26 deletions(-)
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 19a1db9..f59f109 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -539,8 +539,8 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
if (node == NULL) {
/* Set default values if there is not <permissions> element */
perms->mode = defaultmode;
- perms->uid = getuid();
- perms->gid = getgid();
+ perms->uid = -1;
+ perms->gid = -1;
perms->label = NULL;
return 0;
}
@@ -564,7 +564,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
}
if (virXPathNode("./owner", ctxt) == NULL) {
- perms->uid = getuid();
+ perms->uid = -1;
} else {
if (virXPathLong("number(./owner)", ctxt, &v) < 0) {
virStorageReportError(VIR_ERR_XML_ERROR,
@@ -575,7 +575,7 @@ virStorageDefParsePerms(xmlXPathContextPtr ctxt,
}
if (virXPathNode("./group", ctxt) == NULL) {
- perms->gid = getgid();
+ perms->gid = -1;
} else {
if (virXPathLong("number(./group)", ctxt, &v) < 0) {
virStorageReportError(VIR_ERR_XML_ERROR,
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 3742493..ee6a32e 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -241,11 +241,10 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED,
uid = (vol->target.perms.uid != st.st_uid) ? vol->target.perms.uid : -1;
gid = (vol->target.perms.gid != st.st_gid) ? vol->target.perms.gid : -1;
if (((uid != -1) || (gid != -1))
- && (fchown(fd, vol->target.perms.uid, vol->target.perms.gid) < 0)) {
+ && (fchown(fd, uid, gid) < 0)) {
virReportSystemError(errno,
_("cannot chown '%s' to (%u, %u)"),
- vol->target.path, vol->target.perms.uid,
- vol->target.perms.gid);
+ vol->target.path, uid, gid);
goto cleanup;
}
if (fchmod(fd, vol->target.perms.mode) < 0) {
@@ -356,10 +355,12 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
}
+ uid_t uid = (vol->target.perms.uid == -1) ? getuid() : vol->target.perms.uid;
+ gid_t gid = (vol->target.perms.gid == -1) ? getgid() : vol->target.perms.gid;
+
if ((createstat = virFileOperation(vol->target.path,
O_RDWR | O_CREAT | O_EXCL | O_DSYNC,
- vol->target.perms.mode,
- vol->target.perms.uid, vol->target.perms.gid,
+ vol->target.perms.mode, uid, gid,
createRawFileOpHook, &hdata,
VIR_FILE_OP_FORCE_PERMS |
(pool->def->type == VIR_STORAGE_POOL_NETFS
@@ -491,14 +492,14 @@ cleanup:
static int virStorageBuildSetUIDHook(void *data) {
virStorageVolDefPtr vol = data;
- if ((vol->target.perms.gid != 0)
+ if ((vol->target.perms.gid != -1)
&& (setgid(vol->target.perms.gid) != 0)) {
virReportSystemError(errno,
_("Cannot set gid to %u before creating %s"),
vol->target.perms.gid, vol->target.path);
return -1;
}
- if ((vol->target.perms.uid != 0)
+ if ((vol->target.perms.uid != -1)
&& (setuid(vol->target.perms.uid) != 0)) {
virReportSystemError(errno,
_("Cannot set uid to %u before creating %s"),
@@ -517,8 +518,11 @@ static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
int filecreated = 0;
if ((pool->def->type == VIR_STORAGE_POOL_NETFS)
- && (getuid() == 0)
- && ((vol->target.perms.uid != 0) || (vol->target.perms.gid != 0))) {
+ && (((getuid() == 0)
+ && (vol->target.perms.uid != -1)
+ && (vol->target.perms.uid != 0))
+ || ((vol->target.perms.gid != -1)
+ && (vol->target.perms.gid != getgid())))) {
if (virRunWithHook(cmdargv,
virStorageBuildSetUIDHook, vol, NULL) == 0) {
/* command was successfully run, check if the file was created */
@@ -547,8 +551,7 @@ static int virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool,
&& (chown(vol->target.path, uid, gid) < 0)) {
virReportSystemError(errno,
_("cannot chown %s to (%u, %u)"),
- vol->target.path, vol->target.perms.uid,
- vol->target.perms.gid);
+ vol->target.path, uid, gid);
return -1;
}
if (chmod(vol->target.path, vol->target.perms.mode) < 0) {
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 8279d78..dfd417f 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -529,16 +529,28 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED,
/* Now create the final dir in the path with the uid/gid/mode
* requested in the config. If the dir already exists, just set
* the perms. */
- if ((err = virDirCreate(pool->def->target.path,
- pool->def->target.perms.mode,
- pool->def->target.perms.uid,
- pool->def->target.perms.gid,
- VIR_DIR_CREATE_FORCE_PERMS | VIR_DIR_CREATE_ALLOW_EXIST |
- (pool->def->type == VIR_STORAGE_POOL_NETFS
- ? VIR_DIR_CREATE_AS_UID : 0)) != 0)) {
- virReportSystemError(err, _("cannot create path '%s'"),
- pool->def->target.path);
- goto error;
+
+ struct stat st;
+
+ if ((stat(pool->def->target.path, &st) < 0)
+ || (pool->def->target.perms.uid != -1)) {
+
+ uid_t uid = (pool->def->target.perms.uid == -1)
+ ? getuid() : pool->def->target.perms.uid;
+ gid_t gid = (pool->def->target.perms.gid == -1)
+ ? getgid() : pool->def->target.perms.gid;
+
+ if ((err = virDirCreate(pool->def->target.path,
+ pool->def->target.perms.mode,
+ uid, gid,
+ VIR_DIR_CREATE_FORCE_PERMS |
+ VIR_DIR_CREATE_ALLOW_EXIST |
+ (pool->def->type == VIR_STORAGE_POOL_NETFS
+ ? VIR_DIR_CREATE_AS_UID : 0)) != 0)) {
+ virReportSystemError(err, _("cannot create path '%s'"),
+ pool->def->target.path);
+ goto error;
+ }
}
ret = 0;
error:
@@ -777,8 +789,13 @@ static int createFileDir(virConnectPtr conn ATTRIBUTE_UNUSED,
return -1;
}
+ uid_t uid = (vol->target.perms.uid == -1)
+ ? getuid() : vol->target.perms.uid;
+ gid_t gid = (vol->target.perms.gid == -1)
+ ? getgid() : vol->target.perms.gid;
+
if ((err = virDirCreate(vol->target.path, vol->target.perms.mode,
- vol->target.perms.uid, vol->target.perms.gid,
+ uid, gid,
VIR_DIR_CREATE_FORCE_PERMS |
(pool->def->type == VIR_STORAGE_POOL_NETFS
? VIR_DIR_CREATE_AS_UID : 0))) != 0) {
--
1.6.6.1
3
4
Here's the revised volume wiping API patchset (thanks to Dan for the improved name). I'm sending a replacement patchset since the name change made for a very large and messy incremental. This set contains everybody's feedback, which was all very helpful. Many thanks.
Dave
David Allan (9):
Add public API for volume wiping
Define the internal driver API for vol wiping
Add vol wiping to ESX storage driver struct
Implement the public API for vol wiping
Define wire protocol format for vol wiping
Implement RPC client for vol wiping
Implement the remote dispatch bits of vol wiping
Simplified version of volume wiping based on feedback from the list.
Virsh support for vol wiping
daemon/remote.c | 32 +++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 ++
daemon/remote_dispatch_table.h | 5 +
include/libvirt/libvirt.h.in | 2 +
src/driver.h | 5 +
src/esx/esx_storage_driver.c | 1 +
src/libvirt.c | 47 ++++++++
src/libvirt_public.syms | 1 +
src/remote/remote_driver.c | 27 ++++
src/remote/remote_protocol.c | 11 ++
src/remote/remote_protocol.h | 9 ++
src/remote/remote_protocol.x | 8 +-
src/storage/storage_driver.c | 224 +++++++++++++++++++++++++++++++++++
tools/virsh.c | 42 +++++++
15 files changed, 422 insertions(+), 1 deletions(-)
1
9