[libvirt] [PATCH] cygwin: fix abort of virsh on my system
by Stefan Berger
This strange patch fixes aborts of virsh on my system. It seems that the
string returned by xmlSaveUri is owned by the xml library??
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 317125f..a916b86 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -542,6 +542,9 @@ doRemoteOpen (virConnectPtr conn,
}
name = (char *) xmlSaveUri (&tmpuri);
+#ifdef __CYGWIN__
+ name = strdup(name);
+#endif
#ifdef HAVE_XMLURI_QUERY_RAW
VIR_FREE(tmpuri.query_raw);
14 years, 5 months
[libvirt] [PATCH] Fix SCSI disk unplugging
by Wolfgang Mauerer
Detaching disk devices is not only possible for VIR_DOMAIN_DISK_BUS_VIRTIO,
but also for VIR_DOMAIN_DISK_BUS_SCSI, so take care of this possibility.
Additionally, when the new-style device syntax is used, we do not need to
check if the PCI address is valid since we don't need it to do the
hot-unplugging. And while we're at it, drop the "pci" part
in qemudDomainDetachPciDiskDevice() -- it's misleading since we
do not necessarily have to deal with PCI addresses.
Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer(a)siemens.com>
---
src/qemu/qemu_driver.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 704f824..f2b8517 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7862,10 +7862,10 @@ cleanup:
}
-static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
- virDomainObjPtr vm,
- virDomainDeviceDefPtr dev,
- unsigned long long qemuCmdFlags)
+static int qemudDomainDetachDiskDevice(struct qemud_driver *driver,
+ virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev,
+ unsigned long long qemuCmdFlags)
{
int i, ret = -1;
virDomainDiskDefPtr detach = NULL;
@@ -7884,7 +7884,8 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
goto cleanup;
}
- if (!virDomainDeviceAddressIsValid(&detach->info,
+ if (!(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) &&
+ !virDomainDeviceAddressIsValid(&detach->info,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("device cannot be detached without a PCI address"));
@@ -8373,8 +8374,9 @@ static int qemudDomainDetachDevice(virDomainPtr dom,
if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_DISK &&
- dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO) {
- ret = qemudDomainDetachPciDiskDevice(driver, vm, dev, qemuCmdFlags);
+ (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_VIRTIO ||
+ dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_SCSI)) {
+ ret = qemudDomainDetachDiskDevice(driver, vm, dev, qemuCmdFlags);
} else if (dev->type == VIR_DOMAIN_DEVICE_NET) {
ret = qemudDomainDetachNetDevice(driver, vm, dev, qemuCmdFlags);
} else if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
--
1.6.4
14 years, 6 months
[libvirt] [PATCHv2 0/5] build: update gnulib
by Eric Blake
This replaces the first cut at this series:
https://www.redhat.com/archives/libvir-list/2010-April/msg01341.html
Changes since v1:
squash the original 1/5 and 2/5 into one patch
test every stage of the series on a cross-compile to mingw
add new 5/5, and adjust to recent syntax checks available in today's gnulib
[PATCHv2 1/5] build: rely on gnulib's pthread module
[PATCHv2 2/5] build: use gnulib's uname
[PATCHv2 3/5] build: use gnulib's sys/wait.h
[PATCHv2 4/5] build: drop more redundant configure checks
[PATCHv2 5/5] build: update gnulib
Because of the new patch, I'll wait for a re-ACK before pushing; but 1
through 4 are pretty much unchanged from their original ACK.
.gnulib | 2 +-
.x-sc_prohibit_always_true_header_tests | 4 ++++
bootstrap.conf | 3 +++
configure.ac | 22 ++++------------------
src/libvirt.c | 4 +---
src/network/bridge_driver.c | 1 -
src/nodeinfo.c | 12 ++----------
src/openvz/openvz_conf.c | 2 +-
src/openvz/openvz_driver.c | 2 +-
src/phyp/phyp_driver.c | 1 -
src/qemu/qemu_driver.c | 1 -
src/remote/remote_driver.c | 5 +----
src/storage/storage_backend.c | 4 +---
src/uml/uml_driver.c | 1 -
src/util/ebtables.c | 7 ++-----
src/util/hooks.c | 4 +---
src/util/iptables.c | 7 ++-----
src/util/processinfo.c | 6 ++----
src/util/util.c | 4 +---
19 files changed, 27 insertions(+), 65 deletions(-)
14 years, 6 months
Re: [libvirt] [PATCH] cygwin: fix abort of virsh on my system
by Stefan Berger
Stefan Berger/Watson/IBM wrote on 05/06/2010 02:55:31 PM:
> Chris Lalancette <clalance(a)redhat.com> wrote on 05/06/2010 02:28:18 PM:
>
>
> > On 05/06/2010 02:11 PM, Stefan Berger wrote:
> > > This strange patch fixes aborts of virsh on my system. It seems that
the
> > > string returned by xmlSaveUri is owned by the xml library??
> >
> [...]
>
> >
> > So something else might be going on. What version of libxml2
> > are you currently building against?
>
> Cygwin picks up what I have installed in /cydrive/c/GTK/ and there I
> have version 2.6.32.
>
> xmlversion.h:#define LIBXML_DOTTED_VERSION "2.6.32"
>
> The abort occurs upon the VIR_FREE(name).
That was also the problem. Since the includes weren't missing I didn't
have cygwin's libvirt-devel package installed and so it took the wrong
includes...
Stefan
14 years, 6 months
[libvirt] [PATCH] cgroup: Enable memory.use_hierarchy of cgroup for domain
by Ryota Ozaki
Through conversation with Kumar L Srikanth-B22348, I found
that the function of getting memory usage (e.g., virsh dominfo)
doesn't work for lxc with ns subsystem of cgroup enabled.
This is because of features of ns and memory subsystems.
Ns creates child cgroup on every process fork and as a result
processes in a container are not assigned in a cgroup for
domain (e.g., libvirt/lxc/test1/). For example, libvirt_lxc
and init (or somewhat specified in XML) are assigned into
libvirt/lxc/test1/8839/ and libvirt/lxc/test1/8839/8849/,
respectively. On the other hand, memory subsystem accounts
memory usage within a group of processes by default, i.e.,
it does not take any child (and descendent) groups into
account. With the two features, virsh dominfo which just
checks memory usage of a cgroup for domain always returns
zero because the cgroup has no process.
Setting memory.use_hierarchy of a group allows to account
(and limit) memory usage of every descendent groups of the group.
By setting it of a cgroup for domain, we can get proper memory
usage of lxc with ns subsystem enabled. (To be exact, the
setting is required only when memory and ns subsystems are
enabled at the same time, e.g., mount -t cgroup none /cgroup.)
---
src/util/cgroup.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index b8b2eb5..f7d6b41 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -443,7 +443,38 @@ static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
return rc;
}
-static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int create)
+static int virCgroupSetMemoryUseHierarchy(virCgroupPtr group)
+{
+ int rc = 0;
+ unsigned long long value;
+ const char *filename = "memory.use_hierarchy";
+
+ rc = virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ filename, &value);
+ if (rc != 0) {
+ VIR_ERROR("Failed to read %s/%s (%d)", group->path, filename, rc);
+ return rc;
+ }
+
+ /* Setting twice causes error, so if already enabled, skip setting */
+ if (value == 1)
+ return 0;
+
+ VIR_DEBUG("Setting up %s/%s", group->path, filename);
+ rc = virCgroupSetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ filename, 1);
+
+ if (rc != 0) {
+ VIR_ERROR("Failed to set %s/%s (%d)", group->path, filename, rc);
+ }
+
+ return rc;
+}
+
+static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group,
+ int create, int memory_hierarchy)
{
int i;
int rc = 0;
@@ -477,6 +508,20 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int creat
break;
}
}
+ /*
+ * Note that virCgroupSetMemoryUseHierarchy should always be
+ * called prior to creating subcgroups and attaching tasks.
+ */
+ if (memory_hierarchy &&
+ group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mountPoint != NULL &&
+ (i == VIR_CGROUP_CONTROLLER_MEMORY ||
+ STREQ(group->controllers[i].mountPoint, group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mountPoint))) {
+ rc = virCgroupSetMemoryUseHierarchy(group);
+ if (rc != 0) {
+ VIR_FREE(path);
+ break;
+ }
+ }
}
VIR_FREE(path);
@@ -553,7 +598,7 @@ static int virCgroupAppRoot(int privileged,
if (rc != 0)
goto cleanup;
- rc = virCgroupMakeGroup(rootgrp, *group, create);
+ rc = virCgroupMakeGroup(rootgrp, *group, create, 0);
cleanup:
virCgroupFree(&rootgrp);
@@ -653,7 +698,7 @@ int virCgroupForDriver(const char *name,
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(rootgrp, *group, create);
+ rc = virCgroupMakeGroup(rootgrp, *group, create, 0);
if (rc != 0)
virCgroupFree(group);
}
@@ -703,7 +748,17 @@ int virCgroupForDomain(virCgroupPtr driver,
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(driver, *group, create);
+ /*
+ * Create a cgroup with memory.use_hierarchy enabled to
+ * surely account memory usage of lxc with ns subsystem
+ * enabled. (To be exact, memory and ns subsystems are
+ * enabled at the same time.)
+ *
+ * The reason why doing it here, not a upper group, say
+ * a group for driver, is to avoid overhead to track
+ * cumulative usage that we don't need.
+ */
+ rc = virCgroupMakeGroup(driver, *group, create, 1);
if (rc != 0)
virCgroupFree(group);
}
--
1.6.5.2
14 years, 6 months
[libvirt] [PATCH] cgroup: Enable memory.use_hierarchy of cgroup for domain
by Ryota Ozaki
Through conversation with Kumar L Srikanth-B22348, I found
that the function of getting memory usage (e.g., virsh dominfo)
doesn't work for lxc with ns subsystem of cgroup enabled.
This is because of features of ns and memory subsystems.
Ns creates child cgroup on every process fork and as a result
processes in a container are not assigned in a cgroup for
domain (e.g., libvirt/lxc/test1/). For example, libvirt_lxc
and init (or somewhat specified in XML) are assigned into
libvirt/lxc/test1/8839/ and libvirt/lxc/test1/8839/8849/,
respectively. On the other hand, memory subsystem accounts
memory usage within a group of processes by default, i.e.,
it does not take any child (and descendent) groups into
account. With the two features, virsh dominfo which just
checks memory usage of a cgroup for domain always returns
zero because the cgroup has no process.
Setting memory.use_hierarchy of a group allows to account
(and limit) memory usage of every descendent groups of the group.
By setting it of a cgroup for domain, we can get proper memory
usage of lxc with ns subsystem enabled. (To be exact, the
setting is required only when memory and ns subsystems are
enabled at the same time, e.g., mount -t cgroup none /cgroup.)
---
src/util/cgroup.c | 49 +++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index b8b2eb5..93cd6a9 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -443,7 +443,38 @@ static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
return rc;
}
-static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int create)
+static int virCgroupSetMemoryUseHierarchy(virCgroupPtr group)
+{
+ int rc = 0;
+ unsigned long long value;
+ const char *filename = "memory.use_hierarchy";
+
+ rc = virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ filename, &value);
+ if (rc != 0) {
+ VIR_ERROR("Failed to read %s/%s (%d)", group->path, filename, rc);
+ return rc;
+ }
+
+ /* Setting twice causes error, so if already enabled, skip setting */
+ if (value == 1)
+ return 0;
+
+ VIR_DEBUG("Setting up %s/%s", group->path, filename);
+ rc = virCgroupSetValueU64(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ filename, 1);
+
+ if (rc != 0) {
+ VIR_ERROR("Failed to set %s/%s (%d)", group->path, filename, rc);
+ }
+
+ return rc;
+}
+
+static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group,
+ int create, int memory_hierarchy)
{
int i;
int rc = 0;
@@ -477,6 +508,16 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group, int creat
break;
}
}
+ if (memory_hierarchy &&
+ group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mountPoint != NULL &&
+ (i == VIR_CGROUP_CONTROLLER_MEMORY ||
+ STREQ(group->controllers[i].mountPoint, group->controllers[VIR_CGROUP_CONTROLLER_MEMORY].mountPoint))) {
+ rc = virCgroupSetMemoryUseHierarchy(group);
+ if (rc != 0) {
+ VIR_FREE(path);
+ break;
+ }
+ }
}
VIR_FREE(path);
@@ -553,7 +594,7 @@ static int virCgroupAppRoot(int privileged,
if (rc != 0)
goto cleanup;
- rc = virCgroupMakeGroup(rootgrp, *group, create);
+ rc = virCgroupMakeGroup(rootgrp, *group, create, 0);
cleanup:
virCgroupFree(&rootgrp);
@@ -653,7 +694,7 @@ int virCgroupForDriver(const char *name,
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(rootgrp, *group, create);
+ rc = virCgroupMakeGroup(rootgrp, *group, create, 0);
if (rc != 0)
virCgroupFree(group);
}
@@ -703,7 +744,7 @@ int virCgroupForDomain(virCgroupPtr driver,
VIR_FREE(path);
if (rc == 0) {
- rc = virCgroupMakeGroup(driver, *group, create);
+ rc = virCgroupMakeGroup(driver, *group, create, 1);
if (rc != 0)
virCgroupFree(group);
}
--
1.6.5.2
14 years, 6 months
[libvirt] [PATCH] util: fix va_start usage bug
by Eric Blake
Detected by clang. POSIX requires that the second argument to
va_start be the name of the last variable; and in some implementations,
passing *path instead of path would dereference bogus memory instead
of pulling arguments off the stack.
* src/util/util.c (virBuildPathInternal): Use correct argument to
va_start.
---
I think this falls under the trivial rule, as it silences a
compiler warning and is a one-line fix of a real bug, so I pushed it.
src/util/util.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/util/util.c b/src/util/util.c
index 2d32952..c44d012 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2799,7 +2799,7 @@ int virBuildPathInternal(char **path, ...)
va_list ap;
int ret = 0;
- va_start(ap, *path);
+ va_start(ap, path);
path_component = va_arg(ap, char *);
virBufferAdd(&buf, path_component, -1);
--
1.6.6.1
14 years, 6 months
[libvirt] Libvirtd in listen mode.
by Kumar L Srikanth-B22348
Hi,
If I start the libvirtd service using the command "service libvirtd
start", it is not starting in listen mode. I am stopping the libvirtd
service, and then starting in listen mode externally, using the
following command:
"libvirtd -listen".
But, how can I start libvirtd service in listen mode by default (when I
issue the command "service libvirtd start")?
Regards,
Srikanth.
14 years, 6 months
[libvirt] [PATCH] build: silence a clang false positive
by Eric Blake
* src/qemu/qemu_monitor.c (qemuMonitorIOWriteWithFD): Work around
recent clang shortcoming in analysis.
---
False positive encountered with the latest F-13 clang :(
src/qemu/qemu_monitor.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 443d216..abf1338 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1,7 +1,7 @@
/*
* qemu_monitor.c: interaction with QEMU monitor console
*
- * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006-2010 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -374,6 +374,9 @@ qemuMonitorIOWriteWithFD(qemuMonitorPtr mon,
msg.msg_controllen = sizeof(control);
cmsg = CMSG_FIRSTHDR(&msg);
+ /* Some static analyzers, like clang 2.6-0.6.pre2, fail to see
+ that our use of CMSG_FIRSTHDR will not return NULL. */
+ sa_assert(cmsg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
--
1.6.6.1
14 years, 6 months
[libvirt] [PATCH] cgroup: Change virCgroupRemove to remove all child groups at first
by Ryota Ozaki
As same as normal directories, a cgroup cannot be removed if it
contains sub groups. This patch changes virCgroupRemove to remove
all child groups (subdirectories) of a target group before removing
the target group.
The handling is required when we run lxc with ns subsystem of cgroup.
Ns subsystem automatically creates child cgroups on every process
forks, but unfortunately the groups are not removed on process exits,
so we have to remove them by ourselves.
With this patch, such child groups are surely removed at lxc
shutdown, i.e., lxcVmCleanup which calls virCgroupRemove.
---
src/util/cgroup.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index b8b2eb5..531c131 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <libgen.h>
+#include <dirent.h>
#include "internal.h"
#include "util.h"
@@ -561,11 +562,52 @@ cleanup:
}
#endif
+static int virCgroupRemoveRecursively(char *grppath)
+{
+ DIR *grpdir;
+ struct dirent *ent;
+ int rc = 0;
+
+ grpdir = opendir(grppath);
+ if (grpdir == NULL) {
+ VIR_ERROR("Unable to open %s (%d)", grppath, errno);
+ rc = -errno;
+ return rc;
+ }
+
+ while ((ent = readdir(grpdir)) != NULL) {
+ char path[PATH_MAX];
+ int ret;
+
+ if (ent->d_name[0] == '.') continue;
+ if (ent->d_type != DT_DIR) continue;
+
+ ret = snprintf(path, sizeof(path), "%s/%s", grppath, ent->d_name);
+ if (ret < 0)
+ break;
+ rc = virCgroupRemoveRecursively(path);
+ if (rc != 0)
+ break;
+ }
+ DEBUG("Removing cgroup %s", grppath);
+ if (rmdir(grppath) != 0 && errno != ENOENT) {
+ rc = -errno;
+ VIR_ERROR("Unable to remove %s (%d)", grppath, errno);
+ }
+
+ return rc;
+}
+
/**
* virCgroupRemove:
*
* @group: The group to be removed
*
+ * It first removes all child groups recursively
+ * in depth first order and then removes @group
+ * because the presence of the child groups
+ * prevents removing @group.
+ *
* Returns: 0 on success
*/
int virCgroupRemove(virCgroupPtr group)
@@ -585,10 +627,8 @@ int virCgroupRemove(virCgroupPtr group)
&grppath) != 0)
continue;
- DEBUG("Removing cgroup %s", grppath);
- if (rmdir(grppath) != 0 && errno != ENOENT) {
- rc = -errno;
- }
+ DEBUG("Removing cgroup %s and all child cgroups", grppath);
+ rc = virCgroupRemoveRecursively(grppath);
VIR_FREE(grppath);
}
--
1.6.5.2
14 years, 6 months