[libvirt] [PATCH] network: add domain to unqalified names define with <host>
by Laine Stump
If a domain name is defined for a network, add the --expand-hosts
option to the dnsmasq commandline. This results in the domain being
added to any hostname that is defined in a dns <host> element and
contains no '.' characters (i.e. it is an "unqualified"
hostname). Since PTR records are automatically created for any name
define in <host>, the result of a PTR request will change from the
unqualified name to the qualified name.
This also has the same effect on any hostnames that dnsmasq reads
from the host's /etc/hosts file. Hosts.
I want to make sure that everyone notices that previous paragraph and
has a chance to object if they believe this change in existing
behavior will be detrimental. Note that guests will still be able to
query the unqualified name, with the same results as before; it is
only when a reverse lookup of an IP address is done that the result
will be different, e.g. it will return "f15.example.com" instead of
"f15".
(In the case of guest hostnames that were learned by dnsmasq via DHCP
requests, they were already getting the domain name added on, even
without --expand-hosts).
---
src/network/bridge_driver.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f15a7a6..a9a0374 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -614,6 +614,10 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
if (ipdef->nranges || ipdef->nhosts)
virCommandAddArg(cmd, "--dhcp-no-override");
+ /* add domain to any non-qualified hostnames in /etc/hosts or addn-hosts file */
+ if (network->def->domain)
+ virCommandAddArg(cmd, "--expand-hosts");
+
if ((dctx = networkSaveDnsmasqHostsfile(ipdef, network->def->dns, network->def->name, false))) {
if (dctx->hostsfile->nhosts)
virCommandAddArgPair(cmd, "--dhcp-hostsfile",
--
1.7.3.4
13 years, 6 months
[libvirt] [PATCH 0/4] Switch over to use the new RPC code
by Daniel P. Berrange
This patch set actually switches the libvirtd daemon and remote
driver client code to use the new RPC code.
While it has had a fair amount of testing, it has also been
rebased many many many times. There are bound to be things in
it which break, hopefully not the actual RPC wire data format,
but in the client/daemon dispatch code and thread safety, etc
....
13 years, 6 months
[libvirt] [PATCH] Add node prefix to virNodeGet(CPU|Memory)Stats structs and defines
by Matthias Bolte
---
daemon/remote.c | 4 +-
include/libvirt/libvirt.h.in | 99 ++++++++++++++++++++----------------------
src/driver.h | 4 +-
src/libvirt.c | 38 ++++++++--------
src/nodeinfo.c | 40 ++++++++--------
src/nodeinfo.h | 4 +-
src/remote/remote_driver.c | 4 +-
tools/virsh.c | 18 ++++----
8 files changed, 103 insertions(+), 108 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 1914b25..180fefa 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1557,7 +1557,7 @@ remoteDispatchNodeGetCPUStats (struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_cpu_stats_args *args,
remote_node_get_cpu_stats_ret *ret)
{
- virCPUStatsPtr params = NULL;
+ virNodeCPUStatsPtr params = NULL;
int i;
int cpuNum = args->cpuNum;
int nparams = args->nparams;
@@ -1634,7 +1634,7 @@ remoteDispatchNodeGetMemoryStats (struct qemud_server *server ATTRIBUTE_UNUSED,
remote_node_get_memory_stats_args *args,
remote_node_get_memory_stats_ret *ret)
{
- virMemoryStatsPtr params = NULL;
+ virNodeMemoryStatsPtr params = NULL;
int i;
int cellNum = args->cellNum;
int nparams = args->nparams;
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index cf1a682..f029d69 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -302,135 +302,130 @@ struct _virNodeInfo {
};
/**
- * VIR_CPU_STATS_FIELD_LENGTH:
+ * VIR_NODE_CPU_STATS_FIELD_LENGTH:
*
* Macro providing the field length of virNodeCPUStats
*/
-#define VIR_CPU_STATS_FIELD_LENGTH 80
+#define VIR_NODE_CPU_STATS_FIELD_LENGTH 80
/**
- * VIR_CPU_STATS_ALL_CPUS:
+ * VIR_NODE_CPU_STATS_ALL_CPUS:
*
* Macro for the total CPU time/utilization
*/
-#define VIR_CPU_STATS_ALL_CPUS (-1)
+#define VIR_NODE_CPU_STATS_ALL_CPUS (-1)
/**
- * VIR_CPU_STATS_KERNEL:
+ * VIR_NODE_CPU_STATS_KERNEL:
*
* Macro for the cumulative CPU time which was spend by kernel,
* since the node booting up (in nanoseconds).
*/
-#define VIR_CPU_STATS_KERNEL "kernel"
+#define VIR_NODE_CPU_STATS_KERNEL "kernel"
/**
- * VIR_CPU_STATS_USER:
+ * VIR_NODE_CPU_STATS_USER:
*
* The cumulative CPU time which was spend by user processes,
* since the node booting up (in nanoseconds).
*/
-#define VIR_CPU_STATS_USER "user"
+#define VIR_NODE_CPU_STATS_USER "user"
/**
- * VIR_CPU_STATS_IDLE:
+ * VIR_NODE_CPU_STATS_IDLE:
*
* The cumulative idle CPU time,
* since the node booting up (in nanoseconds).
*/
-#define VIR_CPU_STATS_IDLE "idle"
+#define VIR_NODE_CPU_STATS_IDLE "idle"
/**
- * VIR_CPU_STATS_IOWAIT:
+ * VIR_NODE_CPU_STATS_IOWAIT:
*
* The cumulative I/O wait CPU time,
* since the node booting up (in nanoseconds).
*/
-#define VIR_CPU_STATS_IOWAIT "iowait"
+#define VIR_NODE_CPU_STATS_IOWAIT "iowait"
/**
- * VIR_CPU_STATS_UTILIZATION:
+ * VIR_NODE_CPU_STATS_UTILIZATION:
*
* The CPU utilization of a node.
* The usage value is in percent and 100% represents all CPUs of
* the node.
*/
-#define VIR_CPU_STATS_UTILIZATION "utilization"
+#define VIR_NODE_CPU_STATS_UTILIZATION "utilization"
/**
- * virCPUStats:
+ * virNodeCPUStats:
*
* a virNodeCPUStats is a structure filled by virNodeGetCPUStats()
* providing information about the CPU stats of the node.
*/
-typedef struct _virCPUStats virCPUStats;
+typedef struct _virNodeCPUStats virNodeCPUStats;
-struct _virCPUStats {
- char field[VIR_CPU_STATS_FIELD_LENGTH];
+struct _virNodeCPUStats {
+ char field[VIR_NODE_CPU_STATS_FIELD_LENGTH];
unsigned long long value;
};
/**
- * VIR_MEMORY_STATS_FIELD_LENGTH:
+ * VIR_NODE_MEMORY_STATS_FIELD_LENGTH:
*
- * Macro providing the field length of virMemoryStats
+ * Macro providing the field length of virNodeMemoryStats
*/
-#define VIR_MEMORY_STATS_FIELD_LENGTH 80
+#define VIR_NODE_MEMORY_STATS_FIELD_LENGTH 80
/**
- * VIR_MEMORY_STATS_ALL_CELLS:
+ * VIR_NODE_MEMORY_STATS_ALL_CELLS:
*
* Macro for the total memory of all cells.
*/
-#define VIR_MEMORY_STATS_ALL_CELLS (-1)
+#define VIR_NODE_MEMORY_STATS_ALL_CELLS (-1)
/**
- * VIR_MEMORY_STATS_TOTAL:
+ * VIR_NODE_MEMORY_STATS_TOTAL:
*
* Macro for the total memory of specified cell:
* it represents the maximum memory.
*/
-
-#define VIR_MEMORY_STATS_TOTAL "total"
+#define VIR_NODE_MEMORY_STATS_TOTAL "total"
/**
- * VIR_MEMORY_STATS_FREE:
+ * VIR_NODE_MEMORY_STATS_FREE:
*
* Macro for the free memory of specified cell:
* On Linux, it includes buffer and cached memory, in case of
- * VIR_MEMORY_STATS_ALL_CELLS.
+ * VIR_NODE_MEMORY_STATS_ALL_CELLS.
*/
-
-#define VIR_MEMORY_STATS_FREE "free"
+#define VIR_NODE_MEMORY_STATS_FREE "free"
/**
- * VIR_MEMORY_STATS_BUFFERS:
+ * VIR_NODE_MEMORY_STATS_BUFFERS:
*
* Macro for the buffer memory: On Linux, it is only returned in case of
- * VIR_MEMORY_STATS_ALL_CELLS.
+ * VIR_NODE_MEMORY_STATS_ALL_CELLS.
*/
-
-#define VIR_MEMORY_STATS_BUFFERS "buffers"
+#define VIR_NODE_MEMORY_STATS_BUFFERS "buffers"
/**
- * VIR_MEMORY_STATS_CACHED:
+ * VIR_NODE_MEMORY_STATS_CACHED:
*
* Macro for the cached memory: On Linux, it is only returned in case of
- * VIR_MEMORY_STATS_ALL_CELLS.
+ * VIR_NODE_MEMORY_STATS_ALL_CELLS.
*/
-
-#define VIR_MEMORY_STATS_CACHED "cached"
+#define VIR_NODE_MEMORY_STATS_CACHED "cached"
/**
- * virMemoryStats:
+ * virNodeMemoryStats:
*
- * a virMemoryStats is a structure filled by virNodeGetMemoryStats()
+ * a virNodeMemoryStats is a structure filled by virNodeGetMemoryStats()
* providing information about the memory of the node.
*/
+typedef struct _virNodeMemoryStats virNodeMemoryStats;
-typedef struct _virMemoryStats virMemoryStats;
-
-struct _virMemoryStats {
- char field[VIR_MEMORY_STATS_FIELD_LENGTH];
+struct _virNodeMemoryStats {
+ char field[VIR_NODE_MEMORY_STATS_FIELD_LENGTH];
unsigned long long value;
};
@@ -693,20 +688,20 @@ int virDomainMigrateSetMaxSpeed(virDomainPtr domain,
typedef virNodeInfo *virNodeInfoPtr;
/**
- * virCPUStatsPtr:
+ * virNodeCPUStatsPtr:
*
- * a virCPUStatsPtr is a pointer to a virCPUStats structure.
+ * a virNodeCPUStatsPtr is a pointer to a virNodeCPUStats structure.
*/
-typedef virCPUStats *virCPUStatsPtr;
+typedef virNodeCPUStats *virNodeCPUStatsPtr;
/**
- * virMemoryStatsPtr:
+ * virNodeMemoryStatsPtr:
*
- * a virMemoryStatsPtr is a pointer to a virMemoryStats structure.
+ * a virNodeMemoryStatsPtr is a pointer to a virNodeMemoryStats structure.
*/
-typedef virMemoryStats *virMemoryStatsPtr;
+typedef virNodeMemoryStats *virNodeMemoryStatsPtr;
/**
* virConnectFlags
@@ -844,13 +839,13 @@ char * virConnectGetCapabilities (virConnectPtr conn);
int virNodeGetCPUStats (virConnectPtr conn,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams,
unsigned int flags);
int virNodeGetMemoryStats (virConnectPtr conn,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams,
unsigned int flags);
diff --git a/src/driver.h b/src/driver.h
index d45575a..5fd2433 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -380,7 +380,7 @@ typedef int
(*virDrvNodeGetCPUStats)
(virConnectPtr conn,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams,
unsigned int flags);
@@ -388,7 +388,7 @@ typedef int
(*virDrvNodeGetMemoryStats)
(virConnectPtr conn,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams,
unsigned int flags);
diff --git a/src/libvirt.c b/src/libvirt.c
index 36a90d1..1f4730d 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -5287,7 +5287,7 @@ error:
/**
* virNodeGetCPUStats:
* @conn: pointer to the hypervisor connection.
- * @cpuNum: number of node cpu. (VIR_CPU_STATS_ALL_CPUS means total cpu
+ * @cpuNum: number of node cpu. (VIR_NODE_CPU_STATS_ALL_CPUS means total cpu
* statistics)
* @params: pointer to node cpu time parameter objects
* @nparams: number of node cpu time parameter (this value should be same or
@@ -5296,23 +5296,23 @@ error:
*
* This function provides individual cpu statistics of the node.
* If you want to get total cpu statistics of the node, you must specify
- * VIR_CPU_STATS_ALL_CPUS to @cpuNum.
+ * VIR_NODE_CPU_STATS_ALL_CPUS to @cpuNum.
* The @params array will be filled with the values equal to the number of
* parameters suggested by @nparams
*
* As the value of @nparams is dynamic, call the API setting @nparams to 0 and
* @params as NULL, the API returns the number of parameters supported by the
* HV by updating @nparams on SUCCESS. The caller should then allocate @params
- * array, i.e. (sizeof(@virCPUStats) * @nparams) bytes and call
+ * array, i.e. (sizeof(@virNodeCPUStats) * @nparams) bytes and call
* the API again.
*
* Here is a sample code snippet:
*
* if ((virNodeGetCPUStats(conn, cpuNum, NULL, &nparams, 0) == 0) &&
* (nparams != 0)) {
- * if ((params = malloc(sizeof(virCPUStats) * nparams)) == NULL)
+ * if ((params = malloc(sizeof(virNodeCPUStats) * nparams)) == NULL)
* goto error;
- * memset(params, 0, sizeof(virCPUStats) * nparams);
+ * memset(params, 0, sizeof(virNodeCPUStats) * nparams);
* if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, 0))
* goto error;
* }
@@ -5340,7 +5340,7 @@ error:
*/
int virNodeGetCPUStats (virConnectPtr conn,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams, unsigned int flags)
{
VIR_DEBUG("conn=%p, cpuNum=%d, params=%p, nparams=%d, flags=%u",
@@ -5355,7 +5355,7 @@ int virNodeGetCPUStats (virConnectPtr conn,
}
if ((nparams == NULL) || (*nparams < 0) ||
- ((cpuNum < 0) && (cpuNum != VIR_CPU_STATS_ALL_CPUS))) {
+ ((cpuNum < 0) && (cpuNum != VIR_NODE_CPU_STATS_ALL_CPUS))) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
@@ -5377,8 +5377,8 @@ error:
/**
* virNodeGetMemoryStats:
* @conn: pointer to the hypervisor connection.
- * @cellNum: number of node cell. (VIR_MEMORY_STATS_ALL_CELLS means total cell
- * statistics)
+ * @cellNum: number of node cell. (VIR_NODE_MEMORY_STATS_ALL_CELLS means total
+ * cell statistics)
* @params: pointer to node memory stats objects
* @nparams: number of node memory stats (this value should be same or
* less than the number of stats supported)
@@ -5386,23 +5386,23 @@ error:
*
* This function provides memory stats of the node.
* If you want to get total cpu statistics of the node, you must specify
- * VIR_MEMORY_STATS_ALL_CELLS to @cellNum.
+ * VIR_NODE_MEMORY_STATS_ALL_CELLS to @cellNum.
* The @params array will be filled with the values equal to the number of
* stats suggested by @nparams
*
* As the value of @nparams is dynamic, call the API setting @nparams to 0 and
* @params as NULL, the API returns the number of parameters supported by the
* HV by updating @nparams on SUCCESS. The caller should then allocate @params
- * array, i.e. (sizeof(@virMemoryStats) * @nparams) bytes and call
+ * array, i.e. (sizeof(@virNodeMemoryStats) * @nparams) bytes and call
* the API again.
*
* Here is the sample code snippet:
*
* if ((virNodeGetMemoryStats(conn, cellNum, NULL, &nparams, 0) == 0) &&
* (nparams != 0)) {
- * if ((params = malloc(sizeof(virMemoryStats) * nparams)) == NULL)
+ * if ((params = malloc(sizeof(virNodeMemoryStats) * nparams)) == NULL)
* goto error;
- * memset(params, cellNum, 0, sizeof(virMemoryStats) * nparams);
+ * memset(params, cellNum, 0, sizeof(virNodeMemoryStats) * nparams);
* if (virNodeGetMemoryStats(conn, params, &nparams, 0))
* goto error;
* }
@@ -5412,21 +5412,21 @@ error:
*
* Memory Stats:
*
- * VIR_MEMORY_STATS_TOTAL:
+ * VIR_NODE_MEMORY_STATS_TOTAL:
* The total memory usage.(KB)
- * VIR_MEMORY_STATS_FREE:
+ * VIR_NODE_MEMORY_STATS_FREE:
* The free memory usage.(KB)
* On linux, this usage includes buffers and cached.
- * VIR_MEMORY_STATS_BUFFERS:
+ * VIR_NODE_MEMORY_STATS_BUFFERS:
* The buffers memory usage.(KB)
- * VIR_MEMORY_STATS_CACHED:
+ * VIR_NODE_MEMORY_STATS_CACHED:
* The cached memory usage.(KB)
*
* Returns -1 in case of error, 0 in case of success.
*/
int virNodeGetMemoryStats (virConnectPtr conn,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams, unsigned int flags)
{
VIR_DEBUG("conn=%p, cellNum=%d, params=%p, nparams=%d, flags=%u",
@@ -5441,7 +5441,7 @@ int virNodeGetMemoryStats (virConnectPtr conn,
}
if ((nparams == NULL) || (*nparams < 0) ||
- ((cellNum < 0) && (cellNum != VIR_MEMORY_STATS_ALL_CELLS))) {
+ ((cellNum < 0) && (cellNum != VIR_NODE_MEMORY_STATS_ALL_CELLS))) {
virLibConnError(VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index cb2f805..4620d93 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -72,11 +72,11 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
static int linuxNodeGetCPUStats(FILE *procstat,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams);
static int linuxNodeGetMemoryStats(FILE *meminfo,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams);
/* Return the positive decimal contents of the given
@@ -396,7 +396,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
int linuxNodeGetCPUStats(FILE *procstat,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams)
{
int ret = -1;
@@ -418,7 +418,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
goto cleanup;
}
- if (cpuNum == VIR_CPU_STATS_ALL_CPUS) {
+ if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) {
strcpy(cpu_header, "cpu");
} else {
snprintf(cpu_header, sizeof(cpu_header), "cpu%d", cpuNum);
@@ -439,11 +439,11 @@ int linuxNodeGetCPUStats(FILE *procstat,
}
for (i = 0; i < *nparams; i++) {
- virCPUStatsPtr param = ¶ms[i];
+ virNodeCPUStatsPtr param = ¶ms[i];
switch (i) {
case 0: /* fill kernel cpu time here */
- if (virStrcpyStatic(param->field, VIR_CPU_STATS_KERNEL) == NULL) {
+ if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_KERNEL) == NULL) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field kernel cpu time too long for destination"));
goto cleanup;
@@ -452,7 +452,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
break;
case 1: /* fill user cpu time here */
- if (virStrcpyStatic(param->field, VIR_CPU_STATS_USER) == NULL) {
+ if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_USER) == NULL) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field kernel cpu time too long for destination"));
goto cleanup;
@@ -461,7 +461,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
break;
case 2: /* fill idle cpu time here */
- if (virStrcpyStatic(param->field, VIR_CPU_STATS_IDLE) == NULL) {
+ if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_IDLE) == NULL) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field kernel cpu time too long for destination"));
goto cleanup;
@@ -470,7 +470,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
break;
case 3: /* fill iowait cpu time here */
- if (virStrcpyStatic(param->field, VIR_CPU_STATS_IOWAIT) == NULL) {
+ if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_IOWAIT) == NULL) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field kernel cpu time too long for destination"));
goto cleanup;
@@ -496,7 +496,7 @@ cleanup:
int linuxNodeGetMemoryStats(FILE *meminfo,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams)
{
int ret = -1;
@@ -504,20 +504,20 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
int found = 0;
int nr_param;
char line[1024];
- char meminfo_hdr[VIR_MEMORY_STATS_FIELD_LENGTH];
+ char meminfo_hdr[VIR_NODE_MEMORY_STATS_FIELD_LENGTH];
unsigned long val;
struct field_conv {
const char *meminfo_hdr; // meminfo header
const char *field; // MemoryStats field name
} field_conv[] = {
- {"MemTotal:", VIR_MEMORY_STATS_TOTAL},
- {"MemFree:", VIR_MEMORY_STATS_FREE},
- {"Buffers:", VIR_MEMORY_STATS_BUFFERS},
- {"Cached:", VIR_MEMORY_STATS_CACHED},
+ {"MemTotal:", VIR_NODE_MEMORY_STATS_TOTAL},
+ {"MemFree:", VIR_NODE_MEMORY_STATS_FREE},
+ {"Buffers:", VIR_NODE_MEMORY_STATS_BUFFERS},
+ {"Cached:", VIR_NODE_MEMORY_STATS_CACHED},
{NULL, NULL}
};
- if (cellNum == VIR_MEMORY_STATS_ALL_CELLS) {
+ if (cellNum == VIR_NODE_MEMORY_STATS_ALL_CELLS) {
nr_param = LINUX_NB_MEMORY_STATS_ALL;
} else {
nr_param = LINUX_NB_MEMORY_STATS_CELL;
@@ -570,7 +570,7 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
struct field_conv *convp = &field_conv[j];
if (STREQ(meminfo_hdr, convp->meminfo_hdr)) {
- virMemoryStatsPtr param = ¶ms[k++];
+ virNodeMemoryStatsPtr param = ¶ms[k++];
if (virStrcpyStatic(param->field, convp->field) == NULL) {
nodeReportError(VIR_ERR_INTERNAL_ERROR,
@@ -637,7 +637,7 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) {
int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams,
unsigned int flags)
{
@@ -666,7 +666,7 @@ int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams,
unsigned int flags)
{
@@ -678,7 +678,7 @@ int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
char *meminfo_path = NULL;
FILE *meminfo;
- if (cellNum == VIR_MEMORY_STATS_ALL_CELLS) {
+ if (cellNum == VIR_NODE_MEMORY_STATS_ALL_CELLS) {
meminfo_path = strdup(MEMINFO_PATH);
if (!meminfo_path) {
virReportOOMError();
diff --git a/src/nodeinfo.h b/src/nodeinfo.h
index 1ebcdb1..9b2658f 100644
--- a/src/nodeinfo.h
+++ b/src/nodeinfo.h
@@ -32,12 +32,12 @@ int nodeCapsInitNUMA(virCapsPtr caps);
int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int cpuNum,
- virCPUStatsPtr params,
+ virNodeCPUStatsPtr params,
int *nparams,
unsigned int flags ATTRIBUTE_UNUSED);
int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
int cellNum,
- virMemoryStatsPtr params,
+ virNodeMemoryStatsPtr params,
int *nparams,
unsigned int flags ATTRIBUTE_UNUSED);
int nodeGetCellsFreeMemory(virConnectPtr conn,
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f4b43e0..6b74bb5 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1699,7 +1699,7 @@ done:
static int
remoteNodeGetCPUStats (virConnectPtr conn,
int cpuNum,
- virCPUStatsPtr params, int *nparams,
+ virNodeCPUStatsPtr params, int *nparams,
unsigned int flags)
{
int rv = -1;
@@ -1765,7 +1765,7 @@ done:
static int
remoteNodeGetMemoryStats (virConnectPtr conn,
int cellNum,
- virMemoryStatsPtr params, int *nparams,
+ virNodeMemoryStatsPtr params, int *nparams,
unsigned int flags)
{
int rv = -1;
diff --git a/tools/virsh.c b/tools/virsh.c
index 19db058..43b4bd3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3734,8 +3734,8 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
int i, j;
bool flag_utilization = false;
bool flag_percent = vshCommandOptBool(cmd, "percent");
- int cpuNum = VIR_CPU_STATS_ALL_CPUS;
- virCPUStatsPtr params;
+ int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
+ virNodeCPUStatsPtr params;
int nparams = 0;
bool ret = false;
struct cpu_stats {
@@ -3779,15 +3779,15 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
for (j = 0; j < nparams; j++) {
unsigned long long value = params[j].value;
- if (STREQ(params[j].field, VIR_CPU_STATS_KERNEL)) {
+ if (STREQ(params[j].field, VIR_NODE_CPU_STATS_KERNEL)) {
cpu_stats[i].sys = value;
- } else if (STREQ(params[j].field, VIR_CPU_STATS_USER)) {
+ } else if (STREQ(params[j].field, VIR_NODE_CPU_STATS_USER)) {
cpu_stats[i].user = value;
- } else if (STREQ(params[j].field, VIR_CPU_STATS_IDLE)) {
+ } else if (STREQ(params[j].field, VIR_NODE_CPU_STATS_IDLE)) {
cpu_stats[i].idle = value;
- } else if (STREQ(params[j].field, VIR_CPU_STATS_IOWAIT)) {
+ } else if (STREQ(params[j].field, VIR_NODE_CPU_STATS_IOWAIT)) {
cpu_stats[i].iowait = value;
- } else if (STREQ(params[j].field, VIR_CPU_STATS_UTILIZATION)) {
+ } else if (STREQ(params[j].field, VIR_NODE_CPU_STATS_UTILIZATION)) {
cpu_stats[i].util = value;
flag_utilization = true;
}
@@ -3861,8 +3861,8 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
{
int nparams = 0;
unsigned int i = 0;
- int cellNum = VIR_MEMORY_STATS_ALL_CELLS;
- virMemoryStatsPtr params = NULL;
+ int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
+ virNodeMemoryStatsPtr params = NULL;
bool ret = false;
if (!vshConnectionUsability(ctl, ctl->conn))
--
1.7.0.4
13 years, 6 months
[libvirt] [PATCH] qemu: Fix update device for CURRENT + FORCE flags
by Jiri Denemark
When CURRENT and FORCE flags were used together, UpdateDeviceFlags did
nothing because it failed to transform CURRENT into either LIVE or
CONFIG.
---
src/qemu/qemu_driver.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index da612e7..8596b30 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4789,12 +4789,15 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
virDomainDeviceDefPtr dev = NULL;
bool force = (flags & VIR_DOMAIN_DEVICE_MODIFY_FORCE) != 0;
int ret = -1;
+ unsigned int affect;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG |
(action == QEMU_DEVICE_UPDATE ?
VIR_DOMAIN_DEVICE_MODIFY_FORCE : 0), -1);
+ affect = flags & (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG);
+
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
if (!vm) {
@@ -4809,10 +4812,10 @@ qemuDomainModifyDeviceFlags(virDomainPtr dom, const char *xml,
goto cleanup;
if (virDomainObjIsActive(vm)) {
- if (flags == VIR_DOMAIN_AFFECT_CURRENT)
+ if (affect == VIR_DOMAIN_AFFECT_CURRENT)
flags |= VIR_DOMAIN_AFFECT_LIVE;
} else {
- if (flags == VIR_DOMAIN_AFFECT_CURRENT)
+ if (affect == VIR_DOMAIN_AFFECT_CURRENT)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
/* check consistency between flags and the vm state */
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
--
1.7.5.3
13 years, 6 months
[libvirt] regression in finding boot device
by Laine Stump
I just built a fresh libvirt rpm from the head of git on my Fedora 14
machine and updated all the libvirt packages (I'm not sure what version
had been running previously, but it was at least 0.8.8-4 from
virt-preview, probably something later built from source).
Just prior to the update, I had successfully started up a Fedora 15
guest and stopped it. After the update, I started the F15 guest and got
the following message on the virt-viewer console:
Booting from Hard Disk...
Boot failed: could not read the boot disk.
I downgraded to 0.8.8-4 from virt-preview, and was once again able to
boot the guest. Upgraded again, still broken. Investigated some more,
and I found that if I disable QEMU_CAPS_BOOTINDEX in the new libvirt,
the guest boots with no problem.
(bootindex was showing up as "1" in the log; not knowing anything about
how it worked, I decided to try just changing it to "0". That didn't
work. Switching back to the old method *did* work, though.)
This system is running qemu-kvm-0.14-7.fc14.x86_64.
If you'd like a look at the domain XML, the qemu logs, or access to the
machine, just let me know.
13 years, 6 months
[libvirt] [PATCH] xml: create an RNG file for common types and move some definitions there
by Laine Stump
domain.rng, network.rng, and interface.rng already use a few of the
same types (or in some cases *should* but don't), and an upcoming code
change will have them sharing even more. To prepare for that, this
patch takes those common data type definitions and moves them into
basictypes.rng.
This may break some rule about the need to RNG files to be autonomous
or something, but I saw that storageencryption.rng is used in this
way, so I figured it must not be completely against the law...
---
docs/schemas/basictypes.rng | 130 +++++++++++++++++++++++++++++++++++++++++++
docs/schemas/domain.rng | 86 +---------------------------
docs/schemas/interface.rng | 71 ++++-------------------
docs/schemas/network.rng | 79 +++++++-------------------
4 files changed, 166 insertions(+), 200 deletions(-)
create mode 100644 docs/schemas/basictypes.rng
diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
new file mode 100644
index 0000000..b3267f5
--- /dev/null
+++ b/docs/schemas/basictypes.rng
@@ -0,0 +1,130 @@
+<?xml version="1.0"?>
+<!-- network-related definitions used in multiple grammars -->
+<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+
+ <!-- Our unsignedInt doesn"t allow a leading "+" in its lexical form -->
+ <define name="unsignedInt">
+ <data type="unsignedInt">
+ <param name="pattern">[0-9]+</param>
+ </data>
+ </define>
+
+ <define name="positiveInteger">
+ <data type="positiveInteger">
+ <param name="pattern">[0-9]+</param>
+ </data>
+ </define>
+
+ <define name="uint8range">
+ <choice>
+ <data type="string">
+ <param name="pattern">0x[0-9a-fA-F]{1,2}</param>
+ </data>
+ <data type="int">
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">255</param>
+ </data>
+ </choice>
+ </define>
+ <define name="uint24range">
+ <choice>
+ <data type="string">
+ <param name="pattern">0x[0-9a-fA-F]{1,6}</param>
+ </data>
+ <data type="int">
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">16777215</param>
+ </data>
+ </choice>
+ </define>
+
+ <define name="UUID">
+ <choice>
+ <data type="string">
+ <param name="pattern">[a-fA-F0-9]{32}</param>
+ </data>
+ <data type="string">
+ <param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
+ </data>
+ </choice>
+ </define>
+
+ <!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
+ <define name="macAddr">
+ <data type="string">
+ <param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
+ </data>
+ </define>
+
+ <!-- An ipv4 "dotted quad" address -->
+ <define name="ipv4Addr">
+ <data type="string">
+ <param name="pattern">(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))</param>
+ </data>
+ </define>
+
+ <!-- Based on http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6 -->
+ <define name="ipv6Addr">
+ <data type="string">
+ <!-- To understand this better, take apart the toplevel "|"s -->
+<param name="pattern">(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(([0-9A-Fa-f]{1,4}:){0,5}:(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(::([0-9A-Fa-f]{1,4}:){0,5}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)</param>
+ </data>
+ </define>
+
+ <define name="ipAddr">
+ <choice>
+ <ref name="ipv4Addr"/>
+ <ref name="ipv6Addr"/>
+ </choice>
+ </define>
+
+ <define name="ipv4Prefix">
+ <data type="unsignedInt">
+ <param name="maxInclusive">32</param>
+ </data>
+ </define>
+
+ <define name="ipv6Prefix">
+ <data type="unsignedInt">
+ <param name="maxInclusive">128</param>
+ </data>
+ </define>
+
+ <define name="ipPrefix">
+ <choice>
+ <ref name="ipv4Prefix"/>
+ <ref name="ipv6Prefix"/>
+ </choice>
+ </define>
+
+ <define name="dnsName">
+ <data type="string">
+ <param name="pattern">[a-zA-Z0-9\.\-]+</param>
+ </data>
+ </define>
+
+ <define name="deviceName">
+ <data type="string">
+ <param name="pattern">[a-zA-Z0-9_\.\-\\:/]+</param>
+ </data>
+ </define>
+
+ <define name="filePath">
+ <data type="string">
+ <param name="pattern">[a-zA-Z0-9_\.\+\-\\&"'<>/%]+</param>
+ </data>
+ </define>
+
+ <define name="absFilePath">
+ <data type="string">
+ <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%]+</param>
+ </data>
+ </define>
+
+ <define name="absDirPath">
+ <data type="string">
+ <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%]*</param>
+ </data>
+ </define>
+
+</grammar>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 891662d..5e8fc3c 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -5,6 +5,7 @@
<ref name="domain"/>
</start>
+ <include href='basictypes.rng'/>
<include href='storageencryption.rng'/>
<!--
@@ -714,7 +715,7 @@
<zeroOrMore>
<element name="host">
<attribute name="name">
- <ref name="hostName"/>
+ <ref name="dnsName"/>
</attribute>
<attribute name="port">
<ref name="unsignedInt"/>
@@ -1083,7 +1084,7 @@
<optional>
<element name="mac">
<attribute name="address">
- <ref name="addrMAC"/>
+ <ref name="macAddr"/>
</attribute>
<empty/>
</element>
@@ -1091,7 +1092,7 @@
<optional>
<element name="ip">
<attribute name="address">
- <ref name="addrIP"/>
+ <ref name="ipv4Addr"/>
</attribute>
<empty/>
</element>
@@ -2335,22 +2336,10 @@
<!--
Type library
- Our unsignedInt doesn't allow a leading '+' in its lexical form
A domain name should be made of ascii, numbers, _-+ and is non-empty
- UUID currently allows only the 32 characters strict syntax
memoryKB request at least 4Mbytes though Xen will grow bigger if too low
weight currently is in range [100, 1000]
-->
- <define name="unsignedInt">
- <data type="unsignedInt">
- <param name="pattern">[0-9]+</param>
- </data>
- </define>
- <define name='positiveInteger'>
- <data type='positiveInteger'>
- <param name="pattern">[0-9]+</param>
- </data>
- </define>
<define name="cpuset">
<data type="string">
<param name="pattern">([0-9]+(-[0-9]+)?|\^[0-9]+)(,([0-9]+(-[0-9]+)?|\^[0-9]+))*</param>
@@ -2372,11 +2361,6 @@
<param name="pattern">[0-9]+</param>
</data>
</define>
- <define name="hostName">
- <data type="string">
- <param name="pattern">[a-zA-Z0-9\.\-]+</param>
- </data>
- </define>
<define name="PortNumber">
<data type="short">
<param name="minInclusive">-1</param>
@@ -2410,51 +2394,11 @@
<param name="pattern">[a-zA-Z0-9_\+\-]+</param>
</data>
</define>
- <define name="UUID">
- <choice>
- <data type="string">
- <param name="pattern">[a-fA-F0-9]{32}</param>
- </data>
- <data type="string">
- <param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
- </data>
- </choice>
- </define>
- <define name="filePath">
- <data type="string">
- <param name="pattern">[a-zA-Z0-9_\.\+\-\\&"'<>/%]+</param>
- </data>
- </define>
- <define name="absFilePath">
- <data type="string">
- <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%]+</param>
- </data>
- </define>
- <define name="absDirPath">
- <data type="string">
- <param name="pattern">/[a-zA-Z0-9_\.\+\-\\&"'<>/%]*</param>
- </data>
- </define>
- <define name="deviceName">
- <data type="string">
- <param name="pattern">[a-zA-Z0-9_\.\-\\:/]+</param>
- </data>
- </define>
<define name="bridgeMode">
<data type="string">
<param name="pattern">(vepa|bridge|private|passthrough)</param>
</data>
</define>
- <define name="addrMAC">
- <data type="string">
- <param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
- </data>
- </define>
- <define name="addrIP">
- <data type="string">
- <param name="pattern">([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9]</param>
- </data>
- </define>
<define name="addrIPorName">
<data type="string">
<param name="pattern">(([0-2]?[0-9]?[0-9]\.){3}[0-2]?[0-9]?[0-9])|(([0-9a-fA-F]+|:)+[0-9a-fA-F]+)|([a-zA-Z0-9_\.\+\-]*)</param>
@@ -2530,28 +2474,6 @@
<param name="pattern">[a-zA-Z0-9_\.:]+</param>
</data>
</define>
- <define name="uint8range">
- <choice>
- <data type="string">
- <param name="pattern">0x[0-9a-fA-F]{1,2}</param>
- </data>
- <data type="int">
- <param name="minInclusive">0</param>
- <param name="maxInclusive">255</param>
- </data>
- </choice>
- </define>
- <define name="uint24range">
- <choice>
- <data type="string">
- <param name="pattern">0x[0-9a-fA-F]{1,6}</param>
- </data>
- <data type="int">
- <param name="minInclusive">0</param>
- <param name="maxInclusive">16777215</param>
- </data>
- </choice>
- </define>
<define name="virtualPortProfileID">
<data type="string">
<param name="maxLength">39</param>
diff --git a/docs/schemas/interface.rng b/docs/schemas/interface.rng
index 4dd1bb4..53fa18a 100644
--- a/docs/schemas/interface.rng
+++ b/docs/schemas/interface.rng
@@ -1,3 +1,4 @@
+<?xml version="1.0"?>
<!-- A Relax NG schema for network interfaces -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
xmlns:v="http://netcf.org/xml/version/1.0"
@@ -16,6 +17,7 @@
</choice>
</start>
+ <include href='basictypes.rng'/>
<!--
FIXME: How do we handle VLAN's ? Should they be their own interface
or should we treat them as an option on the base interface ? For
@@ -36,7 +38,7 @@
FIXME: What if device name and MAC don't specify the same NIC ? -->
<optional>
<element name="mac">
- <attribute name="address"><ref name="mac-addr"/></attribute>
+ <attribute name="address"><ref name="macAddr"/></attribute>
</element>
</optional>
<!-- FIXME: Allow (some) ethtool options -->
@@ -75,7 +77,7 @@
<element name="vlan">
<attribute name="tag"><ref name="vlan-id"/></attribute>
<element name="interface">
- <attribute name="name"><ref name="device-name"/></attribute>
+ <attribute name="name"><ref name="deviceName"/></attribute>
</element>
</element>
</define>
@@ -202,7 +204,7 @@
</element>
<element name="arpmon">
<attribute name="interval"><ref name="uint"/></attribute>
- <attribute name="target"><ref name="ipv4-addr"/></attribute>
+ <attribute name="target"><ref name="ipv4Addr"/></attribute>
<optional>
<attribute name="validate">
<choice>
@@ -244,7 +246,7 @@
<!-- Basic attributes for all interface types -->
<define name="name-attr">
<!-- The device name, like eth0 or br2 -->
- <attribute name="name"><ref name="device-name"/></attribute>
+ <attribute name="name"><ref name="deviceName"/></attribute>
</define>
<define name="mtu">
@@ -303,14 +305,14 @@
<ref name="dhcp-element"/>
<group>
<element name="ip">
- <attribute name="address"><ref name="ipv4-addr"/></attribute>
+ <attribute name="address"><ref name="ipv4Addr"/></attribute>
<optional>
- <attribute name="prefix"><ref name="ipv4-prefix"/></attribute>
+ <attribute name="prefix"><ref name="ipv4Prefix"/></attribute>
</optional>
</element>
<optional>
<element name="route">
- <attribute name="gateway"><ref name="ipv4-addr"/></attribute>
+ <attribute name="gateway"><ref name="ipv4Addr"/></attribute>
</element>
</optional>
</group>
@@ -331,15 +333,15 @@
</optional>
<zeroOrMore>
<element name="ip">
- <attribute name="address"><ref name="ipv6-addr"/></attribute>
+ <attribute name="address"><ref name="ipv6Addr"/></attribute>
<optional>
- <attribute name="prefix"><ref name="ipv6-prefix"/></attribute>
+ <attribute name="prefix"><ref name="ipv6Prefix"/></attribute>
</optional>
</element>
</zeroOrMore>
<optional>
<element name="route">
- <attribute name="gateway"><ref name="ipv6-addr"/></attribute>
+ <attribute name="gateway"><ref name="ipv6Addr"/></attribute>
</element>
</optional>
</element>
@@ -417,55 +419,6 @@
</data>
</define>
- <define name='device-name'>
- <data type='string'>
- <param name="pattern">[a-zA-Z0-9_\.\-:/]+</param>
- </data>
- </define>
-
- <define name='UUID'>
- <choice>
- <data type='string'>
- <param name="pattern">[a-fA-F0-9]{32}</param>
- </data>
- <data type='string'>
- <param name="pattern">[a-fA-F0-9]{8}\-([a-fA-F0-9]{4}\-){3}[a-fA-F0-9]{12}</param>
- </data>
- </choice>
- </define>
-
- <define name='mac-addr'>
- <data type='string'>
- <param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
- </data>
- </define>
-
- <define name='ipv4-addr'>
- <data type='string'>
- <param name="pattern">(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))</param>
- </data>
- </define>
-
- <define name='ipv4-prefix'>
- <data type='unsignedInt'>
- <param name="maxInclusive">32</param>
- </data>
- </define>
-
- <!-- Based on http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6 -->
- <define name='ipv6-addr'>
- <data type='string'>
- <!-- To understand this better, take apart the toplevel '|'s -->
- <param name="pattern">(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2}))))|(([0-9A-Fa-f]{1,4}:){0,5}:((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2}))))|(::([0-9A-Fa-f]{1,4}:){0,5}((((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2})))\.){3}(((25[0-5])|(1[0-9]{2})|(2[0-4][0-9])|([0-9]{1,2}))))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)</param>
- </data>
- </define>
-
- <define name='ipv6-prefix'>
- <data type='unsignedInt'>
- <param name="maxInclusive">128</param>
- </data>
- </define>
-
<define name='vlan-id'>
<data type="unsignedInt">
<param name="maxInclusive">4096</param>
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 05f45e5..6d9f06b 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -1,3 +1,4 @@
+<?xml version="1.0"?>
<!-- A Relax NG schema for the libvirt network XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
@@ -5,6 +6,8 @@
<ref name="network"/>
</start>
+ <include href='basictypes.rng'/>
+
<define name="network">
<element name="network">
@@ -18,7 +21,7 @@
<!-- <uuid> element -->
<optional>
- <element name="uuid"><text/></element>
+ <element name="uuid"><ref name="UUID"/></element>
</optional>
<!-- <bridge> element -->
@@ -28,7 +31,7 @@
<element name="bridge">
<optional>
<attribute name="name">
- <text/>
+ <ref name="deviceName"/>
</attribute>
</optional>
@@ -53,7 +56,7 @@
<!-- <mac> element -->
<optional>
<element name="mac">
- <attribute name="address"><ref name="mac-addr"/></attribute>
+ <attribute name="address"><ref name="macAddr"/></attribute>
<empty/>
</element>
</optional>
@@ -65,7 +68,7 @@
<element name="forward">
<optional>
<attribute name="dev">
- <text/>
+ <ref name="deviceName"/>
</attribute>
</optional>
@@ -83,7 +86,7 @@
<!-- <domain> element -->
<optional>
<element name="domain">
- <attribute name="name"><text/></attribute>
+ <attribute name="name"><ref name="dnsName"/></attribute>
</element>
</optional>
@@ -93,15 +96,15 @@
<element name="dns">
<zeroOrMore>
<element name="txt">
- <attribute name="name"><ref name="dns-name"/></attribute>
+ <attribute name="name"><ref name="dnsName"/></attribute>
<attribute name="value"><text/></attribute>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="host">
- <attribute name="ip"><ref name="ipv4-addr"/></attribute>
+ <attribute name="ip"><ref name="ipv4Addr"/></attribute>
<oneOrMore>
- <element name="hostname"><text/></element>
+ <element name="hostname"><ref name="dnsName"/></element>
</oneOrMore>
</element>
</zeroOrMore>
@@ -114,12 +117,12 @@
local to the host. -->
<element name="ip">
<optional>
- <attribute name="address"><ref name="ip-addr"/></attribute>
+ <attribute name="address"><ref name="ipAddr"/></attribute>
</optional>
<optional>
<choice>
- <attribute name="netmask"><ref name="ipv4-addr"/></attribute>
- <attribute name="prefix"><ref name="ip-prefix"/></attribute>
+ <attribute name="netmask"><ref name="ipv4Addr"/></attribute>
+ <attribute name="prefix"><ref name="ipPrefix"/></attribute>
</choice>
</optional>
<optional>
@@ -136,22 +139,22 @@
<element name="dhcp">
<zeroOrMore>
<element name="range">
- <attribute name="start"><ref name="ipv4-addr"/></attribute>
- <attribute name="end"><ref name="ipv4-addr"/></attribute>
+ <attribute name="start"><ref name="ipv4Addr"/></attribute>
+ <attribute name="end"><ref name="ipv4Addr"/></attribute>
</element>
</zeroOrMore>
<zeroOrMore>
<element name="host">
- <attribute name="mac"><ref name="mac-addr"/></attribute>
+ <attribute name="mac"><ref name="macAddr"/></attribute>
<attribute name="name"><text/></attribute>
- <attribute name="ip"><ref name="ipv4-addr"/></attribute>
+ <attribute name="ip"><ref name="ipv4Addr"/></attribute>
</element>
</zeroOrMore>
<optional>
<element name="bootp">
- <attribute name="file"><text/></attribute>
+ <attribute name="file"><ref name="filePath"/></attribute>
<optional>
- <attribute name="server"><text/></attribute>
+ <attribute name="server"><ref name="dnsName"/></attribute>
</optional>
</element>
</optional>
@@ -163,52 +166,10 @@
</element>
</define>
- <!-- An ipv4 "dotted quad" address -->
- <define name='ipv4-addr'>
- <data type='string'>
- <param name="pattern">(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))</param>
- </data>
- </define>
-
- <!-- Based on http://blog.mes-stats.fr/2008/10/09/regex-ipv4-et-ipv6 -->
- <define name='ipv6-addr'>
- <data type='string'>
- <!-- To understand this better, take apart the toplevel '|'s -->
- <param name="pattern">(([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(([0-9A-Fa-f]{1,4}:){0,5}:(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|(::([0-9A-Fa-f]{1,4}:){0,5}(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9])))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:)</param>
- </data>
- </define>
-
- <define name='ip-addr'>
- <choice>
- <ref name='ipv4-addr'/>
- <ref name='ipv6-addr'/>
- </choice>
- </define>
-
- <define name='ip-prefix'>
- <data type='unsignedInt'>
- <param name="maxInclusive">128</param>
- </data>
- </define>
-
<define name='addr-family'>
<data type='string'>
<param name="pattern">(ipv4)|(ipv6)</param>
</data>
</define>
- <!-- a 6 byte MAC address in ASCII-hex format, eg "12:34:56:78:9A:BC" -->
- <define name='mac-addr'>
- <data type='string'>
- <param name="pattern">([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}</param>
- </data>
- </define>
-
- <!-- a valid DNS name -->
- <define name='dns-name'>
- <data type='string'>
- <param name="pattern">([a-zA-Z\-]+)</param>
- </data>
- </define>
-
</grammar>
--
1.7.3.4
13 years, 6 months
[libvirt] [PATCH] daemon: Dynamically create worker threads when some get stuck
by Michal Privoznik
Up to now, we've created new worker threads only during new connection.
This patch monitors worker threads for liveness and dynamically create
new one if all are stuck, waiting for hypervisor to reply. This
situation can happen. All one need to do is send STOP signal to qemu.
The amount of time when we evaluate thread as stuck is defined in
WORKER_TIMEOUT macro.
With this approach we don't need to create new worker thread on incoming
connection. However, as number of active worker threads grows, it might
happen we need to size up the pool of worker threads and hence exceed
the max_worker configuration value.
---
daemon/libvirtd.c | 77 +++++++++++++++++++++++++++++++++++++++++++---------
daemon/libvirtd.h | 4 +++
2 files changed, 67 insertions(+), 14 deletions(-)
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index bcaa37b..df019b3 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1491,19 +1491,6 @@ static int qemudDispatchServer(struct qemud_server *server, struct qemud_socket
server->clients[server->nclients++] = client;
- if (server->nclients > server->nactiveworkers &&
- server->nactiveworkers < server->nworkers) {
- for (i = 0 ; i < server->nworkers ; i++) {
- if (!server->workers[i].hasThread) {
- if (qemudStartWorker(server, &server->workers[i]) < 0)
- return -1;
- server->nactiveworkers++;
- break;
- }
- }
- }
-
-
return 0;
error:
@@ -1629,6 +1616,9 @@ static void *qemudWorker(void *data)
virMutexLock(&server->lock);
worker->processingCall = 0;
+ /* The fact we're here means, this worker is not stuck
+ * and can serve clients. Thus suspend timeout */
+ virEventUpdateTimeout(server->workerTimeout, -1);
virMutexUnlock(&server->lock);
}
}
@@ -1900,8 +1890,12 @@ readmore:
}
/* Move completed message to the end of the dispatch queue */
- if (msg)
+ if (msg) {
qemudClientMessageQueuePush(&client->dx, msg);
+ /* For queued message set timeout. If a worker thread
+ * will serve this, it will also remove this timeout. */
+ virEventUpdateTimeout(server->workerTimeout, WORKER_TIMEOUT);
+ }
client->nrequests++;
/* Possibly need to create another receive buffer */
@@ -2303,6 +2297,53 @@ static void qemudInactiveTimer(int timerid, void *data) {
}
}
+static void qemudWorkerTimeout(int timerid, void *data) {
+ struct qemud_server *server = (struct qemud_server *)data;
+ int i;
+
+ virMutexLock(&server->lock);
+ VIR_DEBUG("Some threads are not responding");
+ for (i = 0; i < server->nclients; i++) {
+ if (server->clients[i]->dx)
+ break;
+ }
+
+ if (i == server->nclients) {
+ /* All clients have been/are being served,
+ * there is no call waiting in the queue */
+ virEventUpdateTimeout(timerid, -1);
+ } else {
+ VIR_DEBUG("Got a queued call. Need to create worker");
+ if (server->nactiveworkers == server->nworkers) {
+ /* We need to size up worker threads pool */
+ if (VIR_REALLOC_N(server->workers, server->nworkers + 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ /* Init new worker structure */
+ memset(&server->workers[server->nworkers], 0,
+ sizeof(struct qemud_worker));
+ server->nworkers++;
+ }
+
+ /* Find free worker and start it */
+ for (i = 0; i < server->nworkers; i++) {
+ if (!server->workers[i].hasThread) {
+ if (qemudStartWorker(server, &server->workers[i]) < 0) {
+ VIR_DEBUG("Could not start new worker");
+ goto cleanup;
+ }
+ server->nactiveworkers++;
+ VIR_DEBUG("created worker %d", i);
+ break;
+ }
+ }
+ }
+
+cleanup:
+ virMutexUnlock(&server->lock);
+}
+
static void qemudFreeClient(struct qemud_client *client) {
while (client->rx) {
struct qemud_client_message *msg
@@ -2346,6 +2387,14 @@ static void *qemudRunLoop(void *opaque) {
return NULL;
}
+ server->workerTimeout = virEventAddTimeout(-1,
+ qemudWorkerTimeout,
+ server, NULL);
+ if (server->workerTimeout < 0) {
+ VIR_ERROR(_("Failed to register worker threads timeout"));
+ return NULL;
+ }
+
if (min_workers > max_workers)
max_workers = min_workers;
diff --git a/daemon/libvirtd.h b/daemon/libvirtd.h
index ea00d5c..1d828be 100644
--- a/daemon/libvirtd.h
+++ b/daemon/libvirtd.h
@@ -271,6 +271,8 @@ struct qemud_worker {
struct qemud_server *server;
};
+#define WORKER_TIMEOUT 3000
+
/* Main server state */
struct qemud_server {
virMutex lock;
@@ -278,6 +280,8 @@ struct qemud_server {
int privileged;
+ int workerTimeout;
+
size_t nworkers;
size_t nactiveworkers;
struct qemud_worker *workers;
--
1.7.5.rc3
13 years, 6 months
[libvirt] [PATCH] nwfiler: Return error message about unresolvable variables
by Stefan Berger
This is in response to bugzilla 664629
https://bugzilla.redhat.com/show_bug.cgi?id=664629
The patch below returns an appropriate error message if the chain of
nwfilters is found to contain unresolvable variables and therefore
cannot be instantiated.
Example: The following XMl added to a domain:
<interface type='bridge'>
<mac address='52:54:00:9f:80:45'/>
<source bridge='virbr0'/>
<model type='virtio'/>
<filterref filter='test'/>
</interface>
that references the following filter
<filter name='test' chain='root'>
<filterref filter='clean-traffic'/>
<filterref filter='allow-dhcp-server'/>
</filter>
now displays upon 'virsh start mydomain'
error: Failed to start domain mydomain
error: internal error Cannot instantiate filter due to unresolvable variable: DHCPSERVER
'DHPCSERVER' is contained in allow-dhcp-server.
Signed-off-by: Stefan Berger <stefanb(a)linux.vnet.ibm.com>
---
src/nwfilter/nwfilter_gentech_driver.c | 84 +++++++++++++++++++++++++++++++--
1 file changed, 80 insertions(+), 4 deletions(-)
Index: libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
===================================================================
--- libvirt-acl.orig/src/nwfilter/nwfilter_gentech_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_gentech_driver.c
@@ -200,6 +200,68 @@ virNWFilterCreateVarHashmap(char *macadd
/**
+ * Convert a virNWFilterHashTable into a string of comma-separated
+ * variable names.
+ */
+struct printString
+{
+ virBuffer buf;
+ const char *separator;
+ bool reportMAC;
+ bool reportIP;
+};
+
+
+static void
+_printString(void *payload ATTRIBUTE_UNUSED, const void *name, void *data)
+{
+ struct printString *ps = data;
+
+ if ((STREQ((char *)name, NWFILTER_STD_VAR_IP ) && !ps->reportIP ) ||
+ (STREQ((char *)name, NWFILTER_STD_VAR_MAC) && !ps->reportMAC))
+ return;
+
+ if (virBufferUse(&ps->buf) && ps->separator)
+ virBufferAdd(&ps->buf, ps->separator, -1);
+
+ virBufferAdd(&ps->buf, name, -1);
+}
+
+/**
+ * virNWFilterPrintVars
+ *
+ * @var: hash table containing variables
+ * @separaptro: separator to use between variable names, i.e., ", "
+ * @reportMAC: whether to report the 'MAC' variable
+ * @reportIP : whether to report the IP variable
+ *
+ * Returns a string of comma separated variable names
+ */
+static char *
+virNWFilterPrintVars(virHashTablePtr vars,
+ const char *separator,
+ bool reportMAC,
+ bool reportIP)
+{
+ struct printString ps = {
+ .buf = VIR_BUFFER_INITIALIZER,
+ .separator = separator,
+ .reportMAC = reportMAC,
+ .reportIP = reportIP,
+ };
+
+ virHashForEach(vars, _printString, &ps);
+
+ if (virBufferError(&ps.buf)) {
+ virBufferFreeAndReset(&ps.buf);
+ virReportOOMError();
+ return NULL;
+ }
+ return virBufferContentAndReset(&ps.buf);
+}
+
+
+/**
* virNWFilterRuleInstantiate:
* @conn: pointer to virConnect object
* @techdriver: the driver to use for instantiation
@@ -575,6 +637,7 @@ virNWFilterInstantiate(virConnectPtr con
virNWFilterRuleInstPtr *insts = NULL;
void **ptrs = NULL;
int instantiate = 1;
+ char *buf;
virNWFilterHashTablePtr missing_vars = virNWFilterHashTableCreate(0);
if (!missing_vars) {
@@ -607,11 +670,9 @@ virNWFilterInstantiate(virConnectPtr con
}
goto err_exit;
}
- rc = 1;
- goto err_exit;
+ goto err_unresolvable_vars;
} else if (virHashSize(missing_vars->hashTable) > 1) {
- rc = 1;
- goto err_exit;
+ goto err_unresolvable_vars;
} else if (!forceWithPendingReq &&
virNWFilterLookupLearnReq(ifindex) != NULL) {
goto err_exit;
@@ -674,6 +735,21 @@ err_exit:
virNWFilterHashTableFree(missing_vars);
return rc;
+
+err_unresolvable_vars:
+
+ buf = virNWFilterPrintVars(missing_vars->hashTable, ", ", false, false);
+ if (buf) {
+ virNWFilterReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Cannot instantiate filter due to unresolvable "
+ "variable%s: %s"),
+ strstr(buf, ", ") ? "s" : "",
+ buf);
+ VIR_FREE(buf);
+ }
+
+ rc = 1;
+ goto err_exit;
}
13 years, 6 months