[libvirt] [PATCH] util: Improve error reporting from absolutePathFromBaseFile helper
by Peter Krempa
There are multiple reasons canonicalize_file_name() used in
absolutePathFromBaseFile helper can fail. This patch enhances error
reporting from that helper.
---
src/util/storage_file.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index e0b4178..f4c2943 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -530,22 +530,36 @@ qedGetBackingStore(char **res,
static char *
absolutePathFromBaseFile(const char *base_file, const char *path)
{
- char *res;
- char *tmp;
- size_t d_len = dir_len (base_file);
+ char *res = NULL;
+ char *tmp = NULL;
+ size_t d_len = dir_len(base_file);
/* If path is already absolute, or if dirname(base_file) is ".",
just return a copy of path. */
- if (*path == '/' || d_len == 0)
- return canonicalize_file_name(path);
+ if (*path == '/' || d_len == 0) {
+ if (!(res = canonicalize_file_name(path)))
+ virReportSystemError(errno,
+ _("Can't canonicalize path '%s'"), path);
+
+ goto cleanup;
+ }
/* Ensure that the following cast-to-int is valid. */
- if (d_len > INT_MAX)
- return NULL;
+ if (d_len > INT_MAX) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Directory name too long: '%s'", base_file);
+ goto cleanup;
+ }
- if (virAsprintf(&tmp, "%.*s/%s", (int) d_len, base_file, path) < 0)
- return NULL;
- res = canonicalize_file_name(tmp);
+ if (virAsprintf(&tmp, "%.*s/%s", (int) d_len, base_file, path) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (!(res = canonicalize_file_name(tmp)))
+ virReportSystemError(errno, _("Can't canonicalize path '%s'"), path);
+
+cleanup:
VIR_FREE(tmp);
return res;
}
@@ -713,7 +727,6 @@ virStorageFileGetMetadataFromBuf(int format,
meta->backingStoreRaw = meta->backingStore;
meta->backingStore = absolutePathFromBaseFile(path, backing);
if (meta->backingStore == NULL) {
- virReportOOMError();
VIR_FREE(backing);
return -1;
}
--
1.7.12.4
12 years
[libvirt] [Libvirt] Support for HyperV Server 2012?
by Mark Ashton
Hi All,
According to libvirt.org "The libvirt Microsoft Hyper-V driver can
manage Hyper-V 2008 R2.".
I have verified this after enabling HyperV in libvirt, building libvirt
(+openwsman) and performing some management against a server running
Hyper-V 2008 R2.
What is the current level of support for Microsoft Hyper-V Server 2012?
Are there plans to support Microsoft Hyper-V Server 2012 in a future
release? If so, when is this likely to happen?
Thanks in advance!
Kind Regards,
Mark
12 years
[libvirt] [PATCH 0/2] Make non-KVM machines work with QMP probing
by Martin Kletzander
This "series wannabe" fixes a problem with SW emulated machines not
being able to be run with upstream qemu (no qemu-kvm + QMP probing).
Libvirt currently sets QEMU_CAPS_KVM based on the fact that QEMU knows
about 'query-kvm' QMP command. This not necessarily means that
'-no-kvm' option needs to be supplied in order to disable KVM and that
consequently leads to a non-startable domain when qemu doesn't know
about the option.
In order to fix this issue only with QMP, I thought about two
possibilities, so... The first patch represents what's identical for
both possibilities, whether the second one can be chosen from [2/2 v1]
and [2/2 v2] (I didn't come up with better naming, sorry).
Martin Kletzander (2):
qemu: Enhance QMP detection of KVM state
qemu: Fix SW emulated machines
src/qemu/qemu_capabilities.c | 33 +++++++++++++++++++++++++++++-
src/qemu/qemu_command.c | 6 ++++--
src/qemu/qemu_monitor.c | 23 +++++++++++++++++++++
src/qemu/qemu_monitor.h | 4 ++++
src/qemu/qemu_monitor_json.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 5 +++++
6 files changed, 116 insertions(+), 3 deletions(-)
--
1.7.12.4
12 years
[libvirt] [PATCH] bugfix: ip6tables rule removal
by Gene Czarcinski
Three FORWARD chain rules are added and two INPUT chain rules
are added when a network is started but only the FORWARD chain
rules are removed when the network is destroyed.
---
src/network/bridge_driver.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f814f6f..3dbf009 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1578,6 +1578,8 @@ networkRemoveGeneralIp6tablesRules(struct network_driver *driver,
if (!virNetworkDefGetIpByIndex(network->def, AF_INET6, 0))
return;
+ iptablesRemoveUdpInput(driver->iptables, AF_INET6, network->def->bridge, 53);
+ iptablesRemoveTcpInput(driver->iptables, AF_INET6, network->def->bridge, 53);
iptablesRemoveForwardAllowCross(driver->iptables, AF_INET6, network->def->bridge);
iptablesRemoveForwardRejectIn(driver->iptables, AF_INET6, network->def->bridge);
iptablesRemoveForwardRejectOut(driver->iptables, AF_INET6, network->def->bridge);
--
1.7.11.7
12 years
[libvirt] [PATCH] maint: log xml during volume creation
by Eric Blake
I noticed this while answering a list question about Java bindings
of volume creation.
* src/libvirt.c (virStorageVolCreateXML)
(virStorageVolCreateXMLFrom): Use consistent spelling of xmlDesc,
and log the argument.
---
Pushing under the trivial rule.
src/libvirt.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index 8e01443..2a01b80 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -13298,7 +13298,7 @@ virStorageVolGetKey(virStorageVolPtr vol)
/**
* virStorageVolCreateXML:
* @pool: pointer to storage pool
- * @xmldesc: description of volume to create
+ * @xmlDesc: description of volume to create
* @flags: extra flags; not used yet, so callers should always pass 0
*
* Create a storage volume within a pool based
@@ -13309,10 +13309,10 @@ virStorageVolGetKey(virStorageVolPtr vol)
*/
virStorageVolPtr
virStorageVolCreateXML(virStoragePoolPtr pool,
- const char *xmldesc,
+ const char *xmlDesc,
unsigned int flags)
{
- VIR_DEBUG("pool=%p, flags=%x", pool, flags);
+ VIR_DEBUG("pool=%p, xmlDesc=%s, flags=%x", pool, xmlDesc, flags);
virResetLastError();
@@ -13322,7 +13322,7 @@ virStorageVolCreateXML(virStoragePoolPtr pool,
return NULL;
}
- virCheckNonNullArgGoto(xmldesc, error);
+ virCheckNonNullArgGoto(xmlDesc, error);
if (pool->conn->flags & VIR_CONNECT_RO) {
virLibConnError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
@@ -13331,7 +13331,7 @@ virStorageVolCreateXML(virStoragePoolPtr pool,
if (pool->conn->storageDriver && pool->conn->storageDriver->volCreateXML) {
virStorageVolPtr ret;
- ret = pool->conn->storageDriver->volCreateXML (pool, xmldesc, flags);
+ ret = pool->conn->storageDriver->volCreateXML (pool, xmlDesc, flags);
if (!ret)
goto error;
return ret;
@@ -13348,7 +13348,7 @@ error:
/**
* virStorageVolCreateXMLFrom:
* @pool: pointer to parent pool for the new volume
- * @xmldesc: description of volume to create
+ * @xmlDesc: description of volume to create
* @clonevol: storage volume to use as input
* @flags: extra flags; not used yet, so callers should always pass 0
*
@@ -13361,11 +13361,12 @@ error:
*/
virStorageVolPtr
virStorageVolCreateXMLFrom(virStoragePoolPtr pool,
- const char *xmldesc,
+ const char *xmlDesc,
virStorageVolPtr clonevol,
unsigned int flags)
{
- VIR_DEBUG("pool=%p, flags=%x, clonevol=%p", pool, flags, clonevol);
+ VIR_DEBUG("pool=%p, xmlDesc=%s, clonevol=%p, flags=%x",
+ pool, xmlDesc, clonevol, flags);
virResetLastError();
@@ -13380,7 +13381,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto error;
}
- virCheckNonNullArgGoto(xmldesc, error);
+ virCheckNonNullArgGoto(xmlDesc, error);
if (pool->conn->flags & VIR_CONNECT_RO ||
clonevol->conn->flags & VIR_CONNECT_RO) {
@@ -13391,7 +13392,7 @@ virStorageVolCreateXMLFrom(virStoragePoolPtr pool,
if (pool->conn->storageDriver &&
pool->conn->storageDriver->volCreateXMLFrom) {
virStorageVolPtr ret;
- ret = pool->conn->storageDriver->volCreateXMLFrom (pool, xmldesc,
+ ret = pool->conn->storageDriver->volCreateXMLFrom (pool, xmlDesc,
clonevol, flags);
if (!ret)
goto error;
--
1.7.11.7
12 years
[libvirt] [PATCH] Create temporary dir for socket
by Guido Günther
to avoid ENAMETOOLONG:
https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=amd64&ver=1.0...
---
tests/qemumonitortestutils.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 7133c99..1369cb7 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -424,9 +424,23 @@ static qemuMonitorCallbacks qemuCallbacks = {
qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
{
qemuMonitorTestPtr test;
- const char *path = abs_builddir "/qemumonitorjsontest.sock";
virDomainChrSourceDef src;
+ char *tmpdir = NULL, *path = NULL;
+ char template[] = "/tmp/libvirt_XXXXXX";
+
+ tmpdir = mkdtemp(template);
+ if (tmpdir == NULL) {
+ virReportSystemError(errno, "%s",
+ "Failed to create temporary directory");
+ goto error;
+ }
+
+ if (virAsprintf(&path, "%s/qemumonitorjsontest.sock", tmpdir) < 0) {
+ virReportOOMError();
+ goto error;
+ }
+
memset(&src, 0, sizeof(src));
src.type = VIR_DOMAIN_CHR_TYPE_UNIX;
src.data.nix.path = (char *)path;
@@ -494,11 +508,15 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
test->running = true;
virMutexUnlock(&test->lock);
+cleanup:
+ if (tmpdir)
+ rmdir(tmpdir);
+ VIR_FREE(path);
return test;
error:
qemuMonitorTestFree(test);
- return NULL;
+ goto cleanup;
}
qemuMonitorPtr qemuMonitorTestGetMonitor(qemuMonitorTestPtr test)
--
1.7.10.4
12 years
[libvirt] [PATCH] util: do a better job of matching up pids with their binaries
by Laine Stump
This patch resolves: https://bugzilla.redhat.com/show_bug.cgi?id=871201
If libvirt is restarted after updating the dnsmasq or radvd packages,
a subsequent "virsh net-destroy" will fail to kill the dnsmasq/radvd
process.
The problem is that when libvirtd restarts, it re-reads the dnsmasq
and radvd pidfiles, then does a sanity check on each pid it finds,
including checking that the symbolic link in /proc/$pid/exe actually
points to the same file as the path used by libvirt to execute the
binary in the first place. If this fails, libvirt assumes that the
process is no longer alive.
But if the original binary has been replaced, the link in /proc is set
to "$binarypath (deleted)" (it literally has the string " (deleted)"
appended to the link text stored in the filesystem), so even if a new
binary exists in the same location, attempts to resolve the link will
fail.
In the end, not only is the old dnsmasq/radvd not terminated when the
network is stopped, but a new dnsmasq can't be started when the
network is later restarted (because the original process is still
listening on the ports that the new process wants).
The solution is, when the initial "use stat to check for identical
inodes" check for identity between /proc/$pid/exe and $binpath fails,
to check /proc/$pid/exe for a link ending with " (deleted)" and if so,
truncate that part of the link and compare what's left with the
original binarypath.
A twist to this problem is that on systems with "merged" /sbin and
/usr/sbin (i.e. /sbin is really just a symlink to /usr/sbin; Fedora
17+ is an example of this), libvirt may have started the process using
one path, but /proc/$pid/exe lists a different path (indeed, on F17
this is the case - libvirtd uses /sbin/dnsmasq, but /proc/$pid/exe
shows "/usr/sbin/dnsmasq"). The further bit of code to resolve this is
to call virFileResolveAllLinks() on both the original binarypath and
on the truncated link we read from /proc/$pid/exe, and compare the
results.
The resulting code still succeeds in all the same cases it did before,
but also succeeds if the binary was deleted or replaced after it was
started.
---
src/util/virpidfile.c | 92 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 73 insertions(+), 19 deletions(-)
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index c2a087d..cb8a992 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -35,6 +35,7 @@
#include "logging.h"
#include "virterror_internal.h"
#include "c-ctype.h"
+#include "areadlink.h"
#define VIR_FROM_THIS VIR_FROM_NONE
@@ -203,38 +204,91 @@ int virPidFileRead(const char *dir,
*/
int virPidFileReadPathIfAlive(const char *path,
pid_t *pid,
- const char *binpath)
+ const char *binPath)
{
- int rc;
- char *procpath = NULL;
+ int ret, retPid;
+ bool isLink;
+ char *procPath = NULL;
+ char *procLink = NULL;
+ size_t procLinkLen;
+ char *resolvedBinPath = NULL;
+ char *resolvedProcLink = NULL;
+ const char deletedText[] = " (deleted)";
+ size_t deletedTextLen = strlen(deletedText);
+
- rc = virPidFileReadPath(path, pid);
- if (rc < 0)
- return rc;
+ /* only set this at the very end on success */
+ *pid = -1;
+
+ if ((ret = virPidFileReadPath(path, &retPid)) < 0)
+ goto cleanup;
#ifndef WIN32
/* Check that it's still alive. Safe to skip this sanity check on
* mingw, which lacks kill(). */
- if (kill(*pid, 0) < 0) {
- *pid = -1;
- return 0;
+ if (kill(retPid, 0) < 0) {
+ ret = 0;
+ retPid = -1;
+ goto cleanup;
}
#endif
- if (binpath) {
- if (virAsprintf(&procpath, "/proc/%lld/exe", (long long)*pid) < 0) {
- *pid = -1;
- return -1;
- }
+ if (!binPath) {
+ /* we only knew the pid, and that pid is alive, so we can
+ * return it.
+ */
+ ret = 0;
+ goto cleanup;
+ }
+
+ if (virAsprintf(&procPath, "/proc/%lld/exe", (long long)retPid) < 0) {
+ ret = -ENOMEM;
+ goto cleanup;
+ }
- if (virFileIsLink(procpath) &&
- virFileLinkPointsTo(procpath, binpath) == 0)
- *pid = -1;
+ if ((ret = virFileIsLink(procPath)) < 0)
+ goto cleanup;
+ isLink = ret;
- VIR_FREE(procpath);
+ if (isLink && virFileLinkPointsTo(procPath, binPath)) {
+ /* the link in /proc/$pid/exe is a symlink to a file
+ * that has the same inode as the file at binpath.
+ */
+ ret = 0;
+ goto cleanup;
}
- return 0;
+ /* Even if virFileLinkPointsTo returns a mismatch, it could be
+ * that the binary was deleted/replaced after it was executed. In
+ * that case the link in /proc/$pid/exe will contain
+ * "$procpath (deleted)". Read that link, remove the " (deleted)"
+ * part, and see if it has the same canonicalized name as binpath.
+ */
+ if (!(procLink = areadlink(procPath))) {
+ ret = -errno;
+ goto cleanup;
+ }
+ procLinkLen = strlen(procLink);
+ if (procLinkLen > deletedTextLen)
+ procLink[procLinkLen - deletedTextLen] = 0;
+
+ if ((ret = virFileResolveAllLinks(binPath, &resolvedBinPath)) < 0)
+ goto cleanup;
+ if ((ret = virFileResolveAllLinks(procLink, &resolvedProcLink)) < 0)
+ goto cleanup;
+
+ ret = STREQ(resolvedBinPath, resolvedProcLink) ? 0 : -1;
+
+cleanup:
+ VIR_FREE(procPath);
+ VIR_FREE(procLink);
+ VIR_FREE(resolvedProcLink);
+ VIR_FREE(resolvedBinPath);
+
+ /* return the originally set pid of -1 unless we proclaim success */
+ if (ret == 0)
+ *pid = retPid;
+ return ret;
}
--
1.7.11.7
12 years
[libvirt] [PATCH] cpu: Fix definition of flag smap
by Peter Krempa
A mild case of dyslexia caused that commit
012f9b19ef3812884e207dc431571502de4cebce specifies wrong mask for the
smap cpu feature flag. This patch fixes that mistake.
---
The flags definition file in qemu can be accessed at:
http://git.qemu.org/?p=qemu.git;a=blob;f=target-i386/cpu.c;h=f3708e63b765...
---
src/cpu/cpu_map.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index d059e20..f0a1f04 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -270,7 +270,7 @@
<cpuid function='0x00000007' ebx='0x00000080'/>
</feature>
<feature name='smap'>
- <cpuid function='0x00000007' ebx='0x00080000'/>
+ <cpuid function='0x00000007' ebx='0x00100000'/>
</feature>
<!-- models -->
--
1.7.12.4
12 years
[libvirt] [jbrooks@redhat.com: [Users] oVirt at LinuxCon Europe Next Week]
by Dave Allan
FYI, there's a bunch of oVirt related stuff going on at LinuxCon next
week.
----- Forwarded message from Jason Brooks <jbrooks(a)redhat.com> -----
Date: Mon, 29 Oct 2012 14:11:29 -0700
From: Jason Brooks <jbrooks(a)redhat.com>
To: oVirt Mailing List <users(a)ovirt.org>, announce(a)ovirt.org
Subject: [Users] oVirt at LinuxCon Europe Next Week
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1
LinuxCon Europe 2012 is taking place next week in Barcelona, Spain,
alongside a cluster of related workshops and summits, several of which
will focus on the oVirt Project.
If you are planning on attending LinuxCon Europe next week, it should
provide a great opportunity to connect with other oVirt community
members in attendance. If you know others outside the community who
plan to be at LinuxCon Europe, and who may be interested in learning
more about oVirt, please pass along this information.
On Monday November 5, from 10:30am to 7:00pm, and continuing on
Tuesday from 10:30am to 4:30pm, there will be a Technology Showcase
with booths from LinuxCon Europe exhibitors. The oVirt Project will be
in booth #22, on the ground floor of the Hotel Fira Palace.
On Tuesday November 6, the oVirt Project's own Itamar Heim, from Red
Hat, will giving the talk, "Introduction to the oVirt Virtualization
Management Platform," from 2:15 pm to 3:10pm, at the Hotel Fira
Palace, in the Verdi room, as part of the CloudOpen Summit.
On Wednesday November 7, the oVirt Workshop will kick off at 9am in
the L'ARIA Restaurant, before covering an introduction to oVirt,
architecture and roadmap presentations, and deep dives into oVirt
networking and storage, leading up to a Hands-On Install & Play Lab
from 3:30pm to 6:00pm.
Also on Wednesday, at the KVM Forum, there will be an oVirt Demo from
5:30pm to 6:00pm in the Ambar room.
On Thursday November 8, the oVirt Workshop resumes at 9:00am in the
Rubi room, with a full day of sessions devoted to oVirt integration
topics.
Also on Thursday, at 11:15am, Red Hat's Vijay Bellur will be giving a
talk on "Integrating GlusterFS, oVirt and KVM" as part of the Gluster
Workshop, in the Vivaldi room.
On Friday November 9, the oVirt Workshop will begin its final day with
a brief keynote in the Ambar room, before proceeding with a day of
developer-focused topics back in the Rubi room.
For details on the oVirt Workshop agenda, see the schedule at
http://events.linuxfoundation.org/events/kvm-forum/schedule.
For information about LinuxCon Europe 2012, see event site at
http://events.linuxfoundation.org/events/linuxcon-europe.
_______________________________________________
Users mailing list
Users(a)ovirt.org
http://lists.ovirt.org/mailman/listinfo/users
----- End forwarded message -----
12 years
[libvirt] [PATCH] nodeinfotest: Delete NUL bytes from test data
by Peter Krempa
The test data contained extra \0 bytes after newlines probably due to a
kernel off-by-one bug.
---
Pushed under the trivial rule.
---
tests/nodeinfodata/linux-test3/node/possible | Bin 5 -> 4 bytes
tests/nodeinfodata/linux-test4/node/possible | Bin 5 -> 4 bytes
tests/nodeinfodata/linux-test6/node/online | Bin 3 -> 2 bytes
tests/nodeinfodata/linux-test6/node/possible | Bin 3 -> 2 bytes
4 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/tests/nodeinfodata/linux-test3/node/possible b/tests/nodeinfodata/linux-test3/node/possible
index 21408fdea85537c7277785de368c5cef105e30ed..74fc2fb6b048c39d90b0c17de3824095162634f8 100644
GIT binary patch
literal 4
LcmXreHRl2V0mA^F
literal 5
McmXreHRoag00LqFp8x;=
diff --git a/tests/nodeinfodata/linux-test4/node/possible b/tests/nodeinfodata/linux-test4/node/possible
index 138b411f24a5cecb7a254a97b9584b276c805be2..8b0fab869c1d36fcc3c0dc686412f10644aef53a 100644
GIT binary patch
literal 4
LcmXreHRJ*S0k;5|
literal 5
McmXreHRNId00K||nE(I)
diff --git a/tests/nodeinfodata/linux-test6/node/online b/tests/nodeinfodata/linux-test6/node/online
index c1da2e294b3f3646e368cc0056986632de06e2cc..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 100644
GIT binary patch
literal 2
JcmXru0ssJP06PEx
literal 3
KcmXruVgLXDrvN(u
diff --git a/tests/nodeinfodata/linux-test6/node/possible b/tests/nodeinfodata/linux-test6/node/possible
index c1da2e294b3f3646e368cc0056986632de06e2cc..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 100644
GIT binary patch
literal 2
JcmXru0ssJP06PEx
literal 3
KcmXruVgLXDrvN(u
--
1.7.12.4
12 years