[libvirt] [PATCH] virFork: placate static analyzers: ignore pthread_sigmask return value
by Jim Meyering
Since we check all other uses of pthread_sigmask, be consistent
and clear: mark that we're deliberately ignoring this one.
>From 0cb4b2ffa51bb8c73243876221bff6d7edecd9cf Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 19 Feb 2010 18:40:14 +0100
Subject: [PATCH] virFork: placate static analyzers: ignore pthread_sigmask return value
* src/util/util.c: Include "ignore-value.h".
(virFork): We really do want to ignore pthread_sigmask failure.
---
src/util/util.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 624e570..cf7bba5 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -69,6 +69,7 @@
#include "virterror_internal.h"
#include "logging.h"
#include "event.h"
+#include "ignore-value.h"
#include "buf.h"
#include "util.h"
#include "memory.h"
@@ -344,7 +345,7 @@ int virFork(pid_t *pid) {
if (*pid < 0) {
/* attempt to restore signal mask, but ignore failure, to
avoid obscuring the fork failure */
- pthread_sigmask(SIG_SETMASK, &oldmask, NULL);
+ ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
virReportSystemError(saved_errno,
"%s", _("cannot fork child process"));
goto cleanup;
--
1.7.0.233.g05e1a
14 years, 10 months
[libvirt] [PATCH] virBufferVSprintf: do not omit va_end(argptr) call
by Jim Meyering
Just realized I didn't post a version of this without
the gnulib diff that Eric pointed out, so here you go:
>From 4501145dd3529dc510e6cb52025a71dd0b111b4d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 18 Feb 2010 21:25:01 +0100
Subject: [PATCH] virBufferVSprintf: do not omit va_end(argptr) call
* src/util/buf.c (virBufferVSprintf): Do not omit va_end(argptr).
Improved-by: Daniel Veillard.
---
src/util/buf.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/util/buf.c b/src/util/buf.c
index cc0a087..fc1217b 100644
--- a/src/util/buf.c
+++ b/src/util/buf.c
@@ -245,12 +245,15 @@ virBufferVSprintf(const virBufferPtr buf, const char *format, ...)
va_end(locarg);
grow_size = (count > 1000) ? count : 1000;
- if (virBufferGrow(buf, grow_size) < 0)
+ if (virBufferGrow(buf, grow_size) < 0) {
+ va_end(argptr);
return;
+ }
size = buf->size - buf->use - 1;
va_copy(locarg, argptr);
}
+ va_end(argptr);
va_end(locarg);
buf->use += count;
buf->content[buf->use] = '\0';
--
1.7.0.233.g05e1a
14 years, 10 months
[libvirt] [PATCH] xend_internal.c: don't dereference NULL for unexpected input
by Jim Meyering
My recent xend_internal.c change introduced a bug.
"val" could be NULL just before the STREQ comparisons.
Here's a fix:
>From 5cc834ab30a444cc35ddc9317379f4be3b5cf4c5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 19 Feb 2010 17:45:41 +0100
Subject: [PATCH] xend_internal.c: don't dereference NULL for unexpected input
* src/xen/xend_internal.c (xenDaemonDomainSetAutostart): Avoid a NULL
dereference upon non-SEXPR_VALUE'd on_xend_start. This bug was
introduced by commit 37ce5600c0bb1aed9e2f2888922388de4340ebd3.
---
src/xen/xend_internal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 1f8b106..9d95291 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -4411,7 +4411,7 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
if (autonode) {
const char *val = (autonode->u.s.car->kind == SEXPR_VALUE
? autonode->u.s.car->u.value : NULL);
- if (!STREQ(val, "ignore") && !STREQ(val, "start")) {
+ if (!val || (!STREQ(val, "ignore") && !STREQ(val, "start"))) {
virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
"%s", _("unexpected value from on_xend_start"));
goto error;
--
1.7.0.233.g05e1a
14 years, 10 months
[libvirt] [PATCH 0/2] rework virFileCreate into virFileOperation w/hook function
by Laine Stump
(This patchset requires that the virFork() patchset I send a couple
hours ago be applied first, otherwise it will fail to apply).
virFileCreate just didn't have what it takes to get the job done. It
turns out that there are other things that must be done to files as the
qemu (or whatever) user, so this patchset adds a hook function that
gets called during the child process. That solves a problem I found
with creating raw storage volumes on root-squash NFS, and will also be
used for an upcoming domain-save-on-root-squash-nfs patch.
I'm now beginning to think that virFileCreate/virFileOperation is just
too narrow in scope, and it's getting too many options. Possibly it
will be better to just make a simpler virCallasUID() function that
gets a pointer to a function to execute in the child process as an
argument and does nothing but fork/setuid/call the function. That
function would then contain *all* of the file operations,
including creating/opening/closing the file. But that's too large of a
change to contemplate so soon before a release, and this functionality
is necessary for two important bug fixes (mentioned above), so...
14 years, 10 months
[libvirt] [PATCH v2] remote: Print ssh stderr on connection failure
by Cole Robinson
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/remote/remote_driver.c | 38 +++++++++++++++++++++++++++++++++++---
1 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 13534ce..8914c39 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -154,6 +154,7 @@ struct private_data {
virMutex lock;
int sock; /* Socket. */
+ int errfd; /* File handle connected to remote stderr */
int watch; /* File handle watch */
pid_t pid; /* PID of tunnel process */
int uses_tls; /* TLS enabled on socket? */
@@ -783,6 +784,7 @@ doRemoteOpen (virConnectPtr conn,
case trans_ext: {
pid_t pid;
int sv[2];
+ int errfd[2];
/* Fork off the external process. Use socketpair to create a private
* (unnamed) Unix domain socket to the child process so we don't have
@@ -794,14 +796,22 @@ doRemoteOpen (virConnectPtr conn,
goto failed;
}
+ if (pipe(errfd) == -1) {
+ virReportSystemError(errno, "%s",
+ _("unable to create socket pair"));
+ goto failed;
+ }
+
if (virExec((const char**)cmd_argv, NULL, NULL,
- &pid, sv[1], &(sv[1]), NULL,
+ &pid, sv[1], &(sv[1]), &(errfd[1]),
VIR_EXEC_CLEAR_CAPS) < 0)
goto failed;
/* Parent continues here. */
close (sv[1]);
+ close (errfd[1]);
priv->sock = sv[0];
+ priv->errfd = errfd[0];
priv->pid = pid;
/* Do not set 'is_secure' flag since we can't guarentee
@@ -827,6 +837,12 @@ doRemoteOpen (virConnectPtr conn,
goto failed;
}
+ if ((priv->errfd != -1) && virSetNonBlock(priv->errfd) < 0) {
+ virReportSystemError(errno, "%s",
+ _("unable to make socket non-blocking"));
+ goto failed;
+ }
+
if (pipe(wakeupFD) < 0) {
virReportSystemError(errno, "%s",
_("unable to make pipe"));
@@ -939,6 +955,9 @@ doRemoteOpen (virConnectPtr conn,
failed:
/* Close the socket if we failed. */
+ if (priv->errfd >= 0)
+ close(priv->errfd);
+
if (priv->sock >= 0) {
if (priv->uses_tls && priv->session) {
gnutls_bye (priv->session, GNUTLS_SHUT_RDWR);
@@ -986,6 +1005,7 @@ remoteAllocPrivateData(virConnectPtr conn)
priv->localUses = 1;
priv->watch = -1;
priv->sock = -1;
+ priv->errfd = -1;
return priv;
}
@@ -1408,6 +1428,7 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
sasl_dispose (&priv->saslconn);
#endif
close (priv->sock);
+ close (priv->errfd);
#ifndef WIN32
if (priv->pid > 0) {
@@ -7785,12 +7806,23 @@ remoteIOReadBuffer(virConnectPtr conn,
if (errno == EWOULDBLOCK)
return 0;
+ char errout[1024] = "\0";
+ if (priv->errfd != -1) {
+ saferead(priv->errfd, errout, sizeof(errout));
+ }
+
virReportSystemError(errno,
- "%s", _("cannot recv data"));
+ _("cannot recv data: %s"), errout);
+
} else {
+ char errout[1024] = "\0";
+ if (priv->errfd != -1) {
+ saferead(priv->errfd, errout, sizeof(errout));
+ }
+
errorf (in_open ? NULL : conn,
VIR_ERR_SYSTEM_ERROR,
- "%s", _("server closed connection"));
+ _("server closed connection: %s"), errout);
}
return -1;
}
--
1.6.5.2
14 years, 10 months
[libvirt] [PATCH v2] qemu: Check for IA64 kvm
by Cole Robinson
From: Dustin Xiong <x_k_123(a)hotmail.com>
ACPI feature bit dropped: I asked internally if the -no-acpi option
had any meaning for IA64, and was told 'probably not'.
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/qemu/qemu_conf.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 79bd1e8..f02db9c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -394,6 +394,7 @@ static const struct qemu_arch_info const arch_info_hvm[] = {
{ "mipsel", 32, NULL, "qemu-system-mipsel", NULL, NULL, 0 },
{ "sparc", 32, NULL, "qemu-system-sparc", NULL, NULL, 0 },
{ "ppc", 32, NULL, "qemu-system-ppc", NULL, NULL, 0 },
+ { "itanium", 64, NULL, "qemu-system-ia64", NULL, NULL, 0 },
};
static const struct qemu_arch_info const arch_info_xen[] = {
--
1.6.5.2
14 years, 10 months
[libvirt] [ PATCH ] fix multiple veth problem for OpenVZ
by Yuji NISHIDA
Dear all
This is to fix multiple veth problem.
NETIF setting was overwritten after first CT because any CT could not be found by character name.
---
src/openvz/openvz_conf.c | 38 ++++++++++++++++++++++++++++++++++++++
src/openvz/openvz_conf.h | 1 +
src/openvz/openvz_driver.c | 2 +-
3 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index 43bbaf2..9fb9f7e 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -948,3 +948,41 @@ static int openvzAssignUUIDs(void)
VIR_FREE(conf_dir);
return 0;
}
+
+
+/*
+ * Return CTID from name
+ *
+ */
+
+int openvzGetVEID(char *name) {
+
+ char cmd[64];
+ int veid;
+ FILE *fp;
+
+ strcpy( cmd, VZLIST );
+ strcat( cmd, " " );
+ strcat( cmd, name );
+ strcat( cmd, " -ovpsid -H" );
+
+ if ((fp = popen(cmd, "r")) == NULL) {
+ openvzError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("popen failed"));
+ return -1;
+ }
+
+ if (fscanf(fp, "%d\n", &veid ) != 1) {
+ if (feof(fp))
+ return -1;
+
+ openvzError(NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Failed to parse vzlist output"));
+ goto cleanup;
+ }
+
+ return veid;
+
+ cleanup:
+ fclose(fp);
+ return -1;
+}
diff --git a/src/openvz/openvz_conf.h b/src/openvz/openvz_conf.h
index 00e18b4..518c267 100644
--- a/src/openvz/openvz_conf.h
+++ b/src/openvz/openvz_conf.h
@@ -66,5 +66,6 @@ void openvzFreeDriver(struct openvz_driver *driver);
int strtoI(const char *str);
int openvzSetDefinedUUID(int vpsid, unsigned char *uuid);
unsigned int openvzGetNodeCPUs(void);
+int openvzGetVEID(char *name);
#endif /* OPENVZ_CONF_H */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 196fd8c..879b5d0 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -667,7 +667,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *dev_name_ve;
- int veid = strtoI(vpsid);
+ int veid = openvzGetVEID(vpsid);
//--netif_add ifname[,mac,host_ifname,host_mac]
ADD_ARG_LIT("--netif_add") ;
--
1.5.2.2
-----
Yuji Nishida
nishidy(a)nict.go.jp
14 years, 10 months
[libvirt] [PATCH] Make an error message in PCI util code clearer.
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/util/pci.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/pci.c b/src/util/pci.c
index aa8344e..83ed461 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -540,7 +540,7 @@ pciTrySecondaryBusReset(pciDevice *dev,
*/
if (pciRead(dev, 0, config_space, PCI_CONF_LEN) < 0) {
pciReportError(VIR_ERR_NO_SUPPORT,
- _("Failed to save PCI config space for %s"),
+ _("Failed to read PCI config space for %s"),
dev->name);
goto out;
}
@@ -586,7 +586,7 @@ pciTryPowerManagementReset(pciDevice *dev)
/* Save and restore the device's config space. */
if (pciRead(dev, 0, &config_space[0], PCI_CONF_LEN) < 0) {
pciReportError(VIR_ERR_NO_SUPPORT,
- _("Failed to save PCI config space for %s"),
+ _("Failed to read PCI config space for %s"),
dev->name);
return -1;
}
--
1.6.6
14 years, 10 months
[libvirt] [PATCH] [FIX] macvtap mac_filter support
by Stefan Berger
Previous posting had an unused variable in the compile case of --without-macvtap.
This patch adds the mac_filter support to the macvtap device.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
14 years, 10 months
[libvirt] [PATCH 1/4] qemu: Make Set*Mem commands hotplug only
by Cole Robinson
SetMem and SetMaxMem are hotplug only APIs, any persistent config
changes are supposed to go via XML definition. The original implementation
of these calls were incorrect and had the nasty side effect of making
a psuedo persistent change that would be lost after libvirtd restart
(I didn't know any better).
Fix these APIs to rightly reject non running domains.
---
src/qemu/qemu_driver.c | 54 ++++++++++++++++++++++++++++-------------------
1 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a2be1a3..56a450c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3625,14 +3625,21 @@ static int qemudDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax) {
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if (newmax < vm->def->memory) {
- qemuReportError(VIR_ERR_INVALID_ARG,
- "%s", _("cannot set max memory lower than current memory"));
- goto cleanup;;
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("cannot set max memory lower than current memory"));
+ goto cleanup;
}
- vm->def->maxmem = newmax;
- ret = 0;
+ /* There isn't any way to change this value for a running qemu guest */
+ qemuReportError(VIR_ERR_NO_SUPPORT,
+ "%s", _("cannot set max memory of an active domain"));
cleanup:
if (vm)
@@ -3643,8 +3650,9 @@ cleanup:
static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
struct qemud_driver *driver = dom->conn->privateData;
+ qemuDomainObjPrivatePtr priv;
virDomainObjPtr vm;
- int ret = -1;
+ int ret = -1, r;
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -3657,6 +3665,12 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
goto cleanup;
}
+ if (!virDomainObjIsActive(vm)) {
+ qemuReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
if (newmem > vm->def->maxmem) {
qemuReportError(VIR_ERR_INVALID_ARG,
"%s", _("cannot set memory higher than max memory"));
@@ -3666,25 +3680,21 @@ static int qemudDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
if (qemuDomainObjBeginJob(vm) < 0)
goto cleanup;
- if (virDomainObjIsActive(vm)) {
- qemuDomainObjPrivatePtr priv = vm->privateData;
- qemuDomainObjEnterMonitor(vm);
- int r = qemuMonitorSetBalloon(priv->mon, newmem);
- qemuDomainObjExitMonitor(vm);
- if (r < 0)
- goto endjob;
+ priv = vm->privateData;
+ qemuDomainObjEnterMonitor(vm);
+ r = qemuMonitorSetBalloon(priv->mon, newmem);
+ qemuDomainObjExitMonitor(vm);
+ if (r < 0)
+ goto endjob;
- /* Lack of balloon support is a fatal error */
- if (r == 0) {
- qemuReportError(VIR_ERR_NO_SUPPORT,
- "%s", _("cannot set memory of an active domain"));
- goto endjob;
- }
- } else {
- vm->def->memory = newmem;
+ /* Lack of balloon support is a fatal error */
+ if (r == 0) {
+ qemuReportError(VIR_ERR_NO_SUPPORT,
+ "%s", _("cannot set memory of an active domain"));
+ goto endjob;
}
- ret = 0;
+ ret = 0;
endjob:
if (qemuDomainObjEndJob(vm) == 0)
vm = NULL;
--
1.6.5.2
14 years, 10 months