[libvirt] [PATCH] qemu: capabilities detection for 0.15 through 1.1
by Doug Goldstein
With the introduction of the new capabilities storage relying on QMP we
lost some insight into features available between 0.15 and 1.1. We use
QMP on these versions but only when we go to start the actual guest
rather than for querying up front. The issue is help scraping isn't an
exact science while QMP is an exact science. The issue with the existing
approach of checking QMP on startup is that if the command is really not
there, then we never clear the bit.
An example of this being a problem in on Ubuntu 12.04 LTS where the
default qemu-kvm package does not include SPICE support but -help claims
that it does (because -help always advertises SPICE support). So the
user does not get to see our helpful message when they attempt to start
up a SPICE based domain without having SPICE support.
---
Really hoping a Ubuntu 12.04 user or Ubuntu developer can test this out and
see if this remedies the issue. There's a long list of issues opened on
Launchpad with this bug. I believe where this fix really remedies
things for people is when they're using -vga std instead of -vga qxl. Due to
the fact that qxl will have a spicevmc device that just won't work so they'll
at least get notification that way. -vga std will result in no message and
the domain not working.
---
src/qemu/qemu_capabilities.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 271273c..37b50c1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1871,6 +1871,21 @@ qemuCapsProbeQMPCommands(qemuCapsPtr caps,
if ((ncommands = qemuMonitorGetCommands(mon, &commands)) < 0)
return -1;
+ /* We want to clear these capabilities out so we can properly
+ * detect them. Otherwise if they're already set and we don't
+ * detect them, the bit won't clear.
+ */
+ qemuCapsClear(caps, QEMU_CAPS_WAKEUP);
+ qemuCapsClear(caps, QEMU_CAPS_TRANSACTION);
+ qemuCapsClear(caps, QEMU_CAPS_BLOCKJOB_SYNC);
+ qemuCapsClear(caps, QEMU_CAPS_BLOCKJOB_ASYNC);
+ qemuCapsClear(caps, QEMU_CAPS_DUMP_GUEST_MEMORY);
+ qemuCapsClear(caps, QEMU_CAPS_SPICE);
+ qemuCapsClear(caps, QEMU_CAPS_KVM);
+ qemuCapsClear(caps, QEMU_CAPS_VNC);
+ qemuCapsClear(caps, QEMU_CAPS_BLOCK_COMMIT);
+ qemuCapsClear(caps, QEMU_CAPS_DRIVE_MIRROR);
+
for (i = 0 ; i < ncommands ; i++) {
char *name = commands[i];
if (STREQ(name, "system_wakeup"))
@@ -1909,6 +1924,13 @@ qemuCapsProbeQMPEvents(qemuCapsPtr caps,
int nevents;
size_t i;
+ /* We want to clear these capabilities out so we can properly
+ * detect them. Otherwise if they're already set and we don't
+ * detect them, the bit won't clear.
+ */
+ qemuCapsClear(caps, QEMU_CAPS_BALLOON_EVENT);
+ qemuCapsClear(caps, QEMU_CAPS_SEAMLESS_MIGRATION);
+
if ((nevents = qemuMonitorGetEvents(mon, &events)) < 0)
return -1;
--
1.7.8.6
12 years
[libvirt] [PATCH] qemu: QMP capabilities support starts with 1.2
by Doug Goldstein
Per the code comment in qemuCapsInitQMPBasic() and Eric, we
should only use QMP for capabilities probing starting with 1.2 and
newer.
---
src/qemu/qemu_capabilities.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 271273c..64c0bea 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -2314,7 +2314,7 @@ qemuCapsInitQMP(qemuCapsPtr caps,
VIR_DEBUG("Got version %d.%d.%d (%s)",
major, minor, micro, NULLSTR(package));
- if (!(major >= 1 || (major == 1 && minor >= 1))) {
+ if (!(major >= 1 || (major == 1 && minor >= 2))) {
VIR_DEBUG("Not new enough for QMP capabilities detection");
ret = 0;
goto cleanup;
--
1.7.8.6
12 years
[libvirt] [RFC: PATCH] nodeinfo: support kernels that lack socket information
by Eric Blake
On RHEL 5, I was getting a segfault trying to start libvirtd,
because we were failing virNodeParseSocket but not checking
for errors, and then calling CPU_SET(-1, &sock_map) as a result.
But if you don't have a topology/physical_package_id file,
then you can just assume that the cpu belongs to socket 0.
* src/nodeinfo.c (virNodeGetCpuValue): Change bool into
default_value.
(virNodeParseSocket, virNodeParseNode): Update callers.
---
I'm still testing this, but wanted to get eyes on it now as I think
it belongs in 1.0.0 if it passes my testing. Having libvirtd dump
core on RHEL 5 is not nice. I'm not quite sure when the regression
was introduced, but it was caused by our refactoring of code to
parse different sysfs files.
src/nodeinfo.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 35c5f96..ccf0682 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -79,13 +79,14 @@ static int linuxNodeGetMemoryStats(FILE *meminfo,
int *nparams);
/* Return the positive decimal contents of the given
- * DIR/cpu%u/FILE, or -1 on error. If MISSING_OK and the
- * file could not be found, return 1 instead of an error; this is
- * because some machines cannot hot-unplug cpu0, or because
- * hot-unplugging is disabled. */
+ * DIR/cpu%u/FILE, or -1 on error. If DEFAULT_VALUE is non-negative
+ * and the file could not be found, return that instead of an error;
+ * this is useful for machines that cannot hot-unplug cpu0, or where
+ * hot-unplugging is disabled, or where the kernel is too old
+ * to support NUMA cells, etc. */
static int
virNodeGetCpuValue(const char *dir, unsigned int cpu, const char *file,
- bool missing_ok)
+ int default_value)
{
char *path;
FILE *pathfp;
@@ -100,8 +101,8 @@ virNodeGetCpuValue(const char *dir, unsigned int cpu, const char *file,
pathfp = fopen(path, "r");
if (pathfp == NULL) {
- if (missing_ok && errno == ENOENT)
- value = 1;
+ if (default_value >= 0 && errno == ENOENT)
+ value = default_value;
else
virReportSystemError(errno, _("cannot open %s"), path);
goto cleanup;
@@ -174,7 +175,7 @@ static int
virNodeParseSocket(const char *dir, unsigned int cpu)
{
int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id",
- false);
+ 0);
# if defined(__powerpc__) || \
defined(__powerpc64__) || \
defined(__s390__) || \
@@ -236,7 +237,7 @@ virNodeParseNode(const char *node, int *sockets, int *cores, int *threads)
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
- if ((online = virNodeGetCpuValue(node, cpu, "online", true)) < 0)
+ if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
goto cleanup;
if (!online)
@@ -275,7 +276,7 @@ virNodeParseNode(const char *node, int *sockets, int *cores, int *threads)
if (sscanf(cpudirent->d_name, "cpu%u", &cpu) != 1)
continue;
- if ((online = virNodeGetCpuValue(node, cpu, "online", true)) < 0)
+ if ((online = virNodeGetCpuValue(node, cpu, "online", 1)) < 0)
goto cleanup;
if (!online)
@@ -297,7 +298,7 @@ virNodeParseNode(const char *node, int *sockets, int *cores, int *threads)
/* logical cpu is equivalent to a core on s390 */
core = cpu;
# else
- core = virNodeGetCpuValue(node, cpu, "topology/core_id", false);
+ core = virNodeGetCpuValue(node, cpu, "topology/core_id", -1);
# endif
CPU_SET(core, &core_maps[sock]);
--
1.7.11.7
12 years
Re: [libvirt] [virt-devel] This patch removes the mknod capability from Linux Containers.
by Eric Blake
[originally posted to the wrong list]
On 11/01/2012 12:57 PM, Daniel J Walsh wrote:
>
> 0001-Linux-Containers-are-not-allowed-to-create-device-no.patch
>
>
>>From 3913ef4148728430cc9df79b84d5ec44130f4ac8 Mon Sep 17 00:00:00 2001
> From: rhatdan <dwalsh(a)redhat.com>
I'll adjust the author attribution to match other patches of yours (we
generally prefer 'git shortlog' to list full names).
> Date: Thu, 1 Nov 2012 14:54:39 -0400
> Subject: [PATCH] Linux Containers are not allowed to create device nodes.
> This needs to be done before the container starts. Turning
> off the mknod capabilty is noticed by systemd, which will
s/capabilty/capability/
> no longer attempt to create device nodes.
Missing a blank line, so 'git log' tries to treat this as a really long
subject line.
>
> This eliminates SELinux AVC messages and ugly failure messages in the journal.
> ---
> src/lxc/lxc_container.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 2789c17..8faa664 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -1717,6 +1717,7 @@ static int lxcContainerDropCapabilities(bool keepReboot ATTRIBUTE_UNUSED)
> CAPNG_INHERITABLE | CAPNG_BOUNDING_SET,
> CAP_SYS_MODULE, /* No kernel module loading */
> CAP_SYS_TIME, /* No changing the clock */
> + CAP_MKNOD, /* No creating device nodes */
> CAP_AUDIT_CONTROL, /* No messing with auditing status */
> CAP_MAC_ADMIN, /* No messing with LSM config */
> keepReboot ? -1 : CAP_SYS_BOOT, /* No use of reboot */
Makes sense to me. ACK; I'll clean it up and push in time for 1.0.0.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
12 years
[libvirt] [PATCH 0/2] qemu: Fix incorrect qemuDomainGetBlockIoTune() results
by Stefan Hajnoczi
The qemuDomainGetBlockIoTune() function was returning incorrect results as I
discovered on Fedora Virt Test Day:
https://fedoraproject.org/wiki/QA:Testcase_Virtualization_IO_Throttling
The problem is that I/O limits can be set but I only see zeroes when displaying
them with "virsh blkdeviotune <domain> <device>" on a domain with two disks.
First, we're comparing guest device names ("virtio-blk-0") instead of host
device names ("drive-virtio-blk-0"). Second, the JSON monitor code has
inverted string compare logic so we were skipping the device we were looking
for.
These patches make "virsh blkdeviotune" report correct results.
Stefan Hajnoczi (2):
qemu: Keep QEMU host drive prefix in BlkIoTune
qemu: Fix device name comparison in
qemuMonitorJSONBlockIoThrottleInfo()
src/qemu/qemu_monitor_json.c | 5 +----
src/qemu/qemu_monitor_text.c | 3 ---
2 files changed, 1 insertion(+), 7 deletions(-)
--
1.7.12.1
12 years
[libvirt] [PATCH 00/20] Support for external checkpoints
by Peter Krempa
This set consists of multiple parts:
The first 4 patches are a rebase of Eric's series to add
external checkpoint support to the XML. I posted them as
I had some conflicts to solve when rebasing them lately.
Patches 5-10 are a re-send of my previously posted series to
add ability to create external checkpoints. These are only
rebased and I did _not_ apply review feedback to them.
Patches 11-20 are new and consist of a few cleanups
and refactors to implement needed functionality to revert an
external snapshot. There are three new features:
1) creation of offline external snapshots
2) deletion of external snapshots (with a few limitations)
3) reverting of external snapshots
When this series will be closer to being "pushable" I'll post
another cleanup that will split out all snapshot related
code in qemu into a separate file as it's a mess right now.
Eric Blake (4):
snapshot: new XML for external system checkpoint
snapshot: improve disk align checking
snapshot: populate new XML info for qemu snapshots
snapshot: merge pre-snapshot checks
Peter Krempa (16):
qemu: Split out code to save domain memory to allow reuse
snapshot: Add flag to enable creating checkpoints in paused state
snapshot: qemu: Add async job type for snapshots
snapshot: qemu: Rename qemuDomainSnapshotCreateActive
snapshot: qemu: Add support for external checkpoints
snapshot: qemu: Remove restrictions preventing external snapshots
qemu: snapshot: Clean up snapshot retrieval to use the new helper
qemu: Split out guts of qemuDomainSaveImageStartVM() to allow reuse
snapshot: qemu: Add flag VIR_DOMAIN_SNAPSHOT_REVERT_STOPPED
snapshot: qemu: Add support for external inactive snapshots
conf: Fix private symbols exported by files in conf
conf: Add helper to determine if snapshot is external
snapshot: qemu: Add detail option for PMSUSPENDED event.
snapshot: qemu: Fix detection of external snapshots when deleting
snapshot: qemu: Add support for external snapshot deletion.
snapshot: qemu: Implement reverting of external snapshots
docs/formatsnapshot.html.in | 11 +
docs/schemas/domainsnapshot.rng | 23 +
examples/domain-events/events-c/event-test.c | 3 +
include/libvirt/libvirt.h.in | 7 +
src/conf/snapshot_conf.c | 102 +-
src/conf/snapshot_conf.h | 6 +
src/libvirt.c | 9 +-
src/libvirt_private.syms | 48 +-
src/qemu/qemu_domain.c | 125 ++-
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_driver.c | 1111 ++++++++++++++------
src/qemu/qemu_process.c | 19 +
tests/domainsnapshotxml2xmlin/external_vm.xml | 10 +
tests/domainsnapshotxml2xmlin/noparent.xml | 9 +
tests/domainsnapshotxml2xmlout/all_parameters.xml | 1 +
tests/domainsnapshotxml2xmlout/disk_snapshot.xml | 1 +
tests/domainsnapshotxml2xmlout/external_vm.xml | 43 +
tests/domainsnapshotxml2xmlout/full_domain.xml | 1 +
tests/domainsnapshotxml2xmlout/metadata.xml | 1 +
tests/domainsnapshotxml2xmlout/noparent.xml | 1 +
.../noparent_nodescription.xml | 1 +
.../noparent_nodescription_noactive.xml | 1 +
tests/domainsnapshotxml2xmltest.c | 1 +
tools/virsh-domain-monitor.c | 2 +
tools/virsh-snapshot.c | 9 +
tools/virsh.pod | 21 +-
26 files changed, 1207 insertions(+), 360 deletions(-)
create mode 100644 tests/domainsnapshotxml2xmlin/external_vm.xml
create mode 100644 tests/domainsnapshotxml2xmlin/noparent.xml
create mode 100644 tests/domainsnapshotxml2xmlout/external_vm.xml
--
1.7.12.4
12 years
[libvirt] [PATCH] nodeinfo: enable nodeGetCPUCount for older kernels
by Viktor Mihajlovski
Since /sys/devices/system/cpu/present is not available on
older kernels like on RHEL 5.x nodeGetCPUCount will
fail there. The fallback implemented is to scan for
/sys/devices/system/cpu/cpuNN entries.
Signed-off-by: Viktor Mihajlovski <mihajlov(a)linux.vnet.ibm.com>
---
src/nodeinfo.c | 33 ++++++++++++++++++++++++++++-----
1 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 35c5f96..181630f 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -953,11 +953,34 @@ int
nodeGetCPUCount(void)
{
#ifdef __linux__
- /* XXX should we also work on older kernels, like RHEL5, that lack
- * cpu/present and cpu/online files? Those kernels also lack cpu
- * hotplugging, so it would be a matter of finding the largest
- * cpu/cpuNN directory, and returning NN + 1 */
- return linuxParseCPUmax(SYSFS_SYSTEM_PATH "/cpu/present");
+ /* to support older kernels, like RHEL5, that lack
+ * cpu/present we fall back to count cpu/cpuNN
+ * entries.
+ */
+ char *cpupath = NULL;
+ int i = 0;
+
+ if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/present")) {
+ i = linuxParseCPUmax(SYSFS_SYSTEM_PATH "/cpu/present");
+ } else if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/cpu0")) {
+ do {
+ i++;
+ VIR_FREE(cpupath);
+ if (virAsprintf(&cpupath, "%s/cpu/cpu%d",
+ SYSFS_SYSTEM_PATH, i) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ } while (virFileExists(cpupath));
+ } else {
+ /* no cpu/cpu0: we give up */
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
+ _("host cpu counting not supported on this node"));
+ return -1;
+ }
+
+ VIR_FREE(cpupath);
+ return i;
#else
virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("host cpu counting not implemented on this platform"));
--
1.7.0.4
12 years
[libvirt] [PATCH] net-update docs: s/domain/network/
by Michal Privoznik
A leftover from copy paste.
---
tools/virsh-network.c | 6 +++---
tools/virsh.pod | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 6005e5b..fd9d563 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -755,9 +755,9 @@ static const vshCmdOptDef opts_network_update[] = {
N_("name of file containing xml (or, if it starts with '<', the complete "
"xml element itself) to add/modify, or to be matched for search")},
{"parent-index", VSH_OT_INT, 0, N_("which parent object to search through")},
- {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
- {"live", VSH_OT_BOOL, 0, N_("affect running domain")},
- {"current", VSH_OT_BOOL, 0, N_("affect current domain")},
+ {"config", VSH_OT_BOOL, 0, N_("affect next network startup")},
+ {"live", VSH_OT_BOOL, 0, N_("affect running network")},
+ {"current", VSH_OT_BOOL, 0, N_("affect current state of network")},
{NULL, 0, 0, NULL}
};
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 07d6a67..38e787a 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2062,9 +2062,9 @@ the network; if a parent-index isn't provided, the "most appropriate"
<dhcp> element), but if I<--parent-index> is given, that particular
instance of <ip> will get the modification.
-If I<--live> is specified, affect a running guest.
-If I<--config> is specified, affect the next boot of a persistent guest.
-If I<--current> is specified, affect the current guest state.
+If I<--live> is specified, affect a running network.
+If I<--config> is specified, affect the next startup of a persistent network.
+If I<--current> is specified, affect the current network state.
Both I<--live> and I<--config> flags may be given, but I<--current> is
exclusive. Not specifying any flag is the same as specifying I<--current>.
--
1.7.8.6
12 years
[libvirt] [PATCH v3] iohelper: fsync() at the end
by Michal Privoznik
Currently, when we are doing (managed) save, we insert the
iohelper between the qemu and OS. The pipe is created, the
writing end is passed to qemu and the reading end to the
iohelper. It reads data and write them into given file. However,
with write() being asynchronous data may still be in OS
caches and hence in some (corner) cases, all migration data
may have been read and written (not physically though). So
qemu will report success, as well as iohelper. However, with
some non local filesystems, where ENOSPACE is polled every X
time units, we may get into situation where all operations
succeeded but data hasn't reached the disk. And in fact will
never do. Therefore we ought sync caches to make sure data
has reached the block device on remote host.
---
src/util/iohelper.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index c6542ed..860e14a 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -179,6 +179,12 @@ runIO(const char *path, int fd, int oflags, unsigned long long length)
}
}
+ /* Ensure all data is written */
+ if (fdatasync(fdout) < 0) {
+ virReportSystemError(errno, _("unable to fsync %s"), fdoutname);
+ goto cleanup;
+ }
+
ret = 0;
cleanup:
--
1.7.8.6
12 years
[libvirt] [PATCHv2 0/3] Use virNodeGetCPUMap where appropriate
by Viktor Mihajlovski
This series concludes the introduction of the virNodeGetCPUMap API
by replacing calls to virNodeGetInfo used only for the purpose
of computing the maximum number of node CPUs (which has the potential
to yield the incorrect number).
Most prominently, with patch 3/3 the output of virsh vcpuinfo will
now be correct for domains on hosts with offline CPUs
V2 Changes:
Rework based on Eric's feedback:
- Use nodeGetCPUCount instead of nodeGetCPUMap
- Avoid code bloat by computing node CPU count in a helper function
Viktor Mihajlovski (3):
qemu, lxc: Change host CPU detection logic.
python: Use virNodeGetCPUMap where possible
virsh: Use virNodeGetCPUMap if possible
python/libvirt-override.c | 87 ++++++++++++++++++++++++++++-------------------
src/lxc/lxc_controller.c | 8 ++---
src/qemu/qemu_driver.c | 14 +++-----
src/qemu/qemu_process.c | 8 ++---
tools/virsh-domain.c | 32 ++++++++++++-----
5 files changed, 86 insertions(+), 63 deletions(-)
--
1.7.12.4
12 years