[libvirt] [PATCH] cpumap: optimize for clients that don't need online count
by Eric Blake
It turns out that calling virNodeGetCPUMap(conn, NULL, NULL, 0)
is both useful, and with Viktor's patches, common enough to
optimize. Since this interface hasn't been released yet, we
can change the RPC call.
* src/nodeinfo.c (nodeGetCPUMap): Avoid bitmap when not needed.
* src/remote/remote_protocol.x (remote_node_get_cpu_map_args):
Supply two separate flags for needed arguments.
* src/remote/remote_driver.c (remoteNodeGetCPUMap): Update
caller.
* daemon/remote.c (remoteDispatchNodeGetCPUMap): Likewise.
* src/remote_protocol-structs: Regenerate.
---
This has to be applied before 1.0.0 if we want it; otherwise the
change to RPC wire protocol will render this patch an ABI break.
I thought of one alternative, that wouldn't change the RPC size,
but still would be a difference. That would be using the old
need_results int as a bitmap of which of the two arguments are
needed, instead of just a 1 or 0. But even that is risky enough
that it should get in before we commit to this interface.
daemon/remote.c | 8 ++++----
src/nodeinfo.c | 3 +++
src/remote/remote_driver.c | 3 ++-
src/remote/remote_protocol.x | 3 ++-
src/remote_protocol-structs | 3 ++-
5 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 7a9df60..340d07d 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4578,7 +4578,7 @@ remoteDispatchNodeGetCPUMap(virNetServerPtr server ATTRIBUTE_UNUSED,
remote_node_get_cpu_map_ret *ret)
{
unsigned char *cpumap = NULL;
- unsigned int online;
+ unsigned int online = 0;
unsigned int flags;
int cpunum;
int rv = -1;
@@ -4592,13 +4592,13 @@ remoteDispatchNodeGetCPUMap(virNetServerPtr server ATTRIBUTE_UNUSED,
flags = args->flags;
- cpunum = virNodeGetCPUMap(priv->conn, args->need_results ? &cpumap : NULL,
- &online, flags);
+ cpunum = virNodeGetCPUMap(priv->conn, args->need_map ? &cpumap : NULL,
+ args->need_online ? &online : NULL, flags);
if (cpunum < 0)
goto cleanup;
/* 'serialize' return cpumap */
- if (args->need_results) {
+ if (args->need_map) {
ret->cpumap.cpumap_len = VIR_CPU_MAPLEN(cpunum);
ret->cpumap.cpumap_val = (char *) cpumap;
cpumap = NULL;
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 35c5f96..3348ae7 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -1277,6 +1277,9 @@ nodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
virCheckFlags(0, -1);
+ if (!cpumap && !online)
+ return nodeGetCPUCount();
+
if (!(cpus = nodeGetCPUBitmap(&maxpresent)))
goto cleanup;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 71218f0..5eca0fa 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -5793,7 +5793,8 @@ remoteNodeGetCPUMap(virConnectPtr conn,
remoteDriverLock(priv);
- args.need_results = !!cpumap;
+ args.need_map = !!cpumap;
+ args.need_online = !!online;
args.flags = flags;
memset (&ret, 0, sizeof(ret));
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 765ffcd..d6ac3c1 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2671,7 +2671,8 @@ struct remote_node_get_memory_parameters_ret {
};
struct remote_node_get_cpu_map_args {
- int need_results;
+ int need_map;
+ int need_online;
unsigned int flags;
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 567864a..6fe7213 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2127,7 +2127,8 @@ struct remote_node_get_memory_parameters_ret {
int nparams;
};
struct remote_node_get_cpu_map_args {
- int need_results;
+ int need_map;
+ int need_online;
u_int flags;
};
struct remote_node_get_cpu_map_ret {
--
1.7.11.7
12 years, 6 months
[libvirt] dnsmasq-248 (CentOS/RHEL) compatibility
by Gene Czarcinski
There are currently three significant libvirt patches I am involved with:
1. Change so that dnsmasq parameters are in a conf file instead of on
the command line.
2. A small patch to add dnsmasq parameter interface=
3. A significant patch to add DHCPv6 support to libvirt.
A concern has been raised about the compatibility of my patches with
dnsmasq-2.48 which is the version on CentOS 6 and RHEL 6. While
something like libvirt-1.0.0 is not officially supported, there is a
strong desire not to get in the way of individuals back-porting it.
Plan A: Install CentOS 6.3 into a virtual guest. Apparently, the
current virt-manager has some problems running CentOS 6.3. Since I was
here to drain a swap, I decided not to go after this alligator.
Plan B: Get a the src.rpm for dnsmasq-2.48 from CentOS and build it on
Fedora 17. Then, using a Fedora 17 virtual guest, downgrade install
dnsmasq-2.48 on it.
I then took four of my virtual dnsmasq conf-files than I use, slightly
modify them to use interface=eth2 and common pid, hostsfile, addnhosts,
and leases files. I then fed each of these configuration files to
dnsmasq-2.48. Everything worked except for the one which had an IPv6
dhcp-range specified. That was not surprising dnsmasq-2.48 only
supports IPv6 for dns.
If someone has some additional tests they would like run, please say so.
My recommendation: Incorporate my patches [when I finish the DHCPv6 one
and resubmit the others]. Add (somewhere?) a warning to backporters
that they will need to update their dnsmasq packages to actually do
DHCPv6 but otherwise, earlier versions such as dnsmasq-2.48 will be
compatible.
Comments? Suggestions?
Gene
12 years, 6 months
[libvirt] [PATCH] logging: Do not redefine mkostemp on uclibc
by Jiri Denemark
An obsolete version of the patch that fixed building on systems with
uclibc (4dbd6e96) was accidentally pushed as part of the release commit
(2b435c15). Since this obsolete patch made syntax-check, commit 30b398d5
was pushed to fix that issue. But the real fix is to actually remove the
offending code.
This patch reverts commit 30b398d5 and the relevant part of 2b435c15.
---
cfg.mk | 2 --
src/util/logging.c | 5 -----
2 files changed, 7 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 963f642..cda04e4 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -817,5 +817,3 @@ exclude_file_name_regexp--sc_unmarked_diagnostics = \
^(docs/apibuild.py|tests/virt-aa-helper-test)$$
exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
-
-exclude_file_name_regexp--sc_prohibit_mkstemp = ^src/util/logging\.c$$
diff --git a/src/util/logging.c b/src/util/logging.c
index 27bd74c..dd43842 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -58,11 +58,6 @@
#define VIR_FROM_THIS VIR_FROM_NONE
-#ifdef __UCLIBC__
-/* uclibc does not implement mkostemp GNU extention */
-# define mkostemp(x,y) mkstemp(x)
-#endif
-
VIR_ENUM_DECL(virLogSource)
VIR_ENUM_IMPL(virLogSource, VIR_LOG_FROM_LAST,
"file",
--
1.7.12.4
12 years, 6 months
[libvirt] Proposed: optionally enable dnsmasq logging
by Gene Czarcinski
Note: the solutions listed below will all work with dnsmasq-2.48.
Sometimes it is very difficult to determine what a dnsmasq problem is
when it does not work as expected. Dnsmasq has to options for logging:
log-quiries and log-dhcp. Either or both can be enabled. By default,
neither is enabled.
1. Add an option or options to libvirtd.conf which will enable the
logging on all started dnsmasq processes. While this is doable, it will
also produce a great deal of syslog mesages if more than one dnsmasq
process is running.
2. Add an option to libvirtd.conf which will enable the solutions given
below. By default, it will not be enabled.
3. Add dnsmasq parameter conf-dir= to specify a directory (under the
same directory as the leases file) where the administrator/user can add
a file which contains log-queries and/or log-dhcp.
4. Add the dnsmasq parameter conf-file= to specify an additional
configuration file. This would be under the same directory as the
leases file and have a name of something like: <network_name>.conf-2.
If the file already existed, nothing would be done. If the file did not
exist, a zero-length file would be created.
Currently, I favor ether 4 or the combination of 4 and 2.
Note: dnsmasq would only read this secondary configuration file when it
is started or restarted.
Comments? Suggestions? Whatever?
Gene
12 years, 6 months
[libvirt] [PATCH 0/2] Add lock in libxl
by Bamvor Jian Zhang
These two patches implement a lock for long-running
job(save, dump and migration) and normal job which will
return in short time but maybe affect the state of virtual
machine.
With these patches, the normal job could not execute while
the long-ruuning job or other normal job is running.
In order to tracking these job, job type for normal job and
long-ruuning job(will be called as async job in code) is
defined.
The abort job is called while user want to cancel such async
job. Note that there is no cancellation function for async
job in xenlight stack. So, abort function just block the
cancellation of user.
Update compare to v1:
1, remove migration relative job functions from lock patch.
2, update comments according to upstream's comments.
Bamvor Jian Zhang (2):
Introduce a lock for libxl long-running api
Add lock for libxl api
src/libxl/libxl_conf.h | 56 +++++
src/libxl/libxl_driver.c | 638 ++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 633 insertions(+), 61 deletions(-)
--
1.7.12
12 years, 6 months
[libvirt] Coverity on libvirt-1.0.0 release
by Alex Jia
Hi all,
This is a Coverity report on libvirt-1.0.0 release, for details, please check attachment.
Analysis summary report:
------------------------
Files analyzed : 294
Total LoC input to cov-analyze : 391588
Functions analyzed : 9762
Paths analyzed : 1146758
Time taken by Coverity analysis : 00:20:58
Defect occurrences found : 304 Total
5 ATOMICITY
53 BAD_SIZEOF
7 CHECKED_RETURN
1 CONSTANT_EXPRESSION_RESULT
7 DEADCODE
19 FORWARD_NULL
2 LOCK
1 MISSING_BREAK
8 NEGATIVE_RETURNS
1 NO_EFFECT
7 NULL_RETURNS
2 OVERRUN_STATIC
122 RESOURCE_LEAK
1 RETURN_LOCAL
17 REVERSE_INULL
2 SIZEOF_MISMATCH
1 STRING_NULL
1 STRING_OVERFLOW
4 TAINTED_SCALAR
25 TOCTOU
9 UNINIT
1 UNREACHABLE
8 UNUSED_VALUE
--
Regards,
Alex
12 years, 6 months
[libvirt] [PATCH] logging.c: Properly indent and ignore one syntax-check rule
by Michal Privoznik
With our fix of mkostemp (pushed as 2b435c15) we define a macro
to compile with uclibc. However, this definition is conditional
and thus needs to be properly indented. Moreover, with this definition
sc_prohibit_mkstemp syntax-check rule keeps yelling:
src/util/logging.c:63:# define mkostemp(x,y) mkstemp(x)
maint.mk: use mkostemp with O_CLOEXEC instead of mkstemp
Therefore we should ignore this file for this rule.
---
Pushed under build-breaker rule.
cfg.mk | 2 ++
src/util/logging.c | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index cda04e4..963f642 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -817,3 +817,5 @@ exclude_file_name_regexp--sc_unmarked_diagnostics = \
^(docs/apibuild.py|tests/virt-aa-helper-test)$$
exclude_file_name_regexp--sc_size_of_brackets = cfg.mk
+
+exclude_file_name_regexp--sc_prohibit_mkstemp = ^src/util/logging\.c$$
diff --git a/src/util/logging.c b/src/util/logging.c
index c0b2f0b..27bd74c 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -60,7 +60,7 @@
#ifdef __UCLIBC__
/* uclibc does not implement mkostemp GNU extention */
-#define mkostemp(x,y) mkstemp(x)
+# define mkostemp(x,y) mkstemp(x)
#endif
VIR_ENUM_DECL(virLogSource)
--
1.7.8.6
12 years, 6 months
[libvirt] [PATCH 0/2] Add lock in libxl
by Bamvor Jian Zhang
These two patches implement a lock for long-running
job(save, dump and migration) and normal job which will
return in short time but maybe affect the state of virtual
machine.
With these patches, the normal job could not execute while
the long-ruuning job or other normal job is running.
In order to tracking these job, job type for normal job and
long-ruuning job(will be called as async job in code) is
defined.
The abort job is called while user want to cancel such async
job. Note that there is no cancellation function for async
job in xenlight stack. So, abort function just block the
cancellation of user.
Bamvor Jian Zhang (2):
Introduce a lock for libxl long-running api
Add lock for libxl api
src/libxl/libxl_conf.h | 58 +++++
src/libxl/libxl_driver.c | 665 ++++++++++++++++++++++++++++++++++++++++++-----
2 files changed, 662 insertions(+), 61 deletions(-)
--
1.7.12
12 years, 6 months
[libvirt] [PATCH] qemu: use default machine type if missing it in qemu command line
by Guannan Ren
BZ:https://bugzilla.redhat.com/show_bug.cgi?id=871273
when using virsh qemu-attach to attach an existing qemu process,
if it misses the -M option in qemu command line, libvirtd crashed
because the NULL value of def->os.machine in later use.
Example:
/usr/libexec/qemu-kvm -name foo \
-cdrom /var/lib/libvirt/images/boot.img \
-monitor unix:/tmp/demo,server,nowait \
error: End of file while reading data: Input/output error
error: Failed to reconnect to the hypervisor
This patch tries to set default machine type if the value of
def->os.machine is still NULL after qemu command line parsing.
---
src/qemu/qemu_command.c | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fe99f5d..0b6d2f8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8768,6 +8768,17 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
}
}
+ if (!def->os.machine) {
+ const char *defaultMachine =
+ virCapabilitiesDefaultGuestMachine(caps,
+ def->os.type,
+ def->os.arch,
+ virDomainVirtTypeToString(def->virtType));
+ if (defaultMachine != NULL)
+ if (!(def->os.machine = strdup(defaultMachine)))
+ goto no_memory;
+ }
+
if (!nographics && def->ngraphics == 0) {
virDomainGraphicsDefPtr sdl;
const char *display = qemuFindEnv(progenv, "DISPLAY");
--
1.7.1
12 years, 6 months