[libvirt] PATCH: Fix cleanup of transient VMs
by Daniel P. Berrange
If a transient VM quit unexpectedly it would never be cleaned up, resulting
in a guest that's impossible to remove
Daniel
commit 7781032c3d870f5c9dacfc02baecc151689d9c57
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Fri Jul 31 14:38:46 2009 +0100
Fix removal of transient VMs when LXC aborts
* src/lxc_driver.c: Remove transient VM after monitor triggered
shutdown
diff --git a/src/lxc_driver.c b/src/lxc_driver.c
index f37fc5d..d62c2d7 100644
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -774,6 +774,10 @@ static void lxcMonitorEvent(int watch,
VIR_DOMAIN_EVENT_STOPPED,
VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN);
}
+ if (!vm->persistent) {
+ virDomainRemoveInactive(&driver->domains, vm);
+ vm = NULL;
+ }
cleanup:
if (vm)
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 3 months
[libvirt] PATCH: Fix startup of LXC vms without cgroups
by Daniel P. Berrange
If cgroups was not mounted at all, LXC would fail to start any VM, since
we missed an error code check
Daniel
commit 8713c7e8111e73879f8380b920995ff3d1f3f9e9
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Fri Jul 31 14:37:25 2009 +0100
Don't try to activate cgroups if not present for LXC
* src/lxc_controller.c: Don't throw error in LXC startup if
the cgroups driver mount isn't available. Improve error
logging for resource setup
diff --git a/src/lxc_controller.c b/src/lxc_controller.c
index 9ad48a7..8d11238 100644
--- a/src/lxc_controller.c
+++ b/src/lxc_controller.c
@@ -84,25 +84,38 @@ static int lxcSetContainerResources(virDomainDefPtr def)
rc = virCgroupForDriver("lxc", &driver, 1, 0);
if (rc != 0) {
- lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
- _("Unable to get cgroup for driver"));
+ /* Skip all if no driver cgroup is configured */
+ if (rc == -ENXIO || rc == -ENOENT)
+ return 0;
+
+ virReportSystemError(NULL, -rc, "%s",
+ _("Unable to get cgroup for driver"));
return rc;
}
rc = virCgroupForDomain(driver, def->name, &cgroup, 1);
if (rc != 0) {
- lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Unable to create cgroup for domain %s"), def->name);
+ virReportSystemError(NULL, -rc,
+ _("Unable to create cgroup for domain %s"),
+ def->name);
goto cleanup;
}
rc = virCgroupSetMemory(cgroup, def->maxmem);
- if (rc != 0)
- goto out;
+ if (rc != 0) {
+ virReportSystemError(NULL, -rc,
+ _("Unable to set memory limit for domain %s"),
+ def->name);
+ goto cleanup;
+ }
rc = virCgroupDenyAllDevices(cgroup);
- if (rc != 0)
- goto out;
+ if (rc != 0) {
+ virReportSystemError(NULL, -rc,
+ _("Unable to deny devices for domain %s"),
+ def->name);
+ goto cleanup;
+ }
for (i = 0; devices[i].type != 0; i++) {
struct cgroup_device_policy *dev = &devices[i];
@@ -110,19 +123,27 @@ static int lxcSetContainerResources(virDomainDefPtr def)
dev->type,
dev->major,
dev->minor);
- if (rc != 0)
- goto out;
+ if (rc != 0) {
+ virReportSystemError(NULL, -rc,
+ _("Unable to allow device %c:%d:%d for domain %s"),
+ dev->type, dev->major, dev->minor, def->name);
+ goto cleanup;
+ }
}
rc = virCgroupAllowDeviceMajor(cgroup, 'c', LXC_DEV_MAJ_PTY);
- if (rc != 0)
- goto out;
+ if (rc != 0) {
+ virReportSystemError(NULL, -rc,
+ _("Unable to allow PYT devices for domain %s"),
+ def->name);
+ goto cleanup;
+ }
rc = virCgroupAddTask(cgroup, getpid());
-out:
if (rc != 0) {
- virReportSystemError(NULL, -rc, "%s",
- _("Failed to set lxc resources"));
+ virReportSystemError(NULL, -rc,
+ _("Unable to add task %d to cgroup for domain %s"),
+ getpid(), def->name);
}
cleanup:
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 3 months
[libvirt] [PATCH] Refresh /etc/xen if inotify wasn't initialized
by Cole Robinson
If libvirt was built against inotify, but an API user isn't using domain
events (virsh, virt-manager), the xen xm driver doesn't poll /etc/xen
for new config files. This means that domains created or deleted on
other libvirt connections aren't reflected in the original connection
(but they will show up for all newly opened connections). This causes
newly created VMs to disappear from virt-manager < 0.8.0 once they are
shutdown, since VMs were installed on a separate connection.
The attached patch refreshes /etc/xen in all cases, unless inotify was
successfully initialized (user is using domain events).
Thanks,
Cole
15 years, 3 months
[libvirt] [PATCH] Allow libvirtd to RPC to external libvirtd.
by Chris Lalancette
Allow the daemon itself to make RPCs to an external libvirtd, but only if
the URI is fully specified. While this isn't used at the moment, it will
be for the tunnelled migration support in the future.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/remote_internal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/remote_internal.c b/src/remote_internal.c
index ad0cbf0..ff4fb6c 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -997,7 +997,7 @@ remoteOpen (virConnectPtr conn,
int ret, rflags = 0;
const char *autostart = getenv("LIBVIRT_AUTOSTART");
- if (inside_daemon)
+ if (inside_daemon && (!conn->uri || (conn->uri && !conn->uri->server)))
return VIR_DRV_OPEN_DECLINED;
if (!(priv = remoteAllocPrivateData(conn)))
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] rng comment fixes
by Aron Griffis
---
docs/schemas/capability.rng | 3 +--
docs/schemas/nodedev.rng | 4 ----
docs/schemas/storagepool.rng | 3 +--
docs/schemas/storagevol.rng | 3 +--
4 files changed, 3 insertions(+), 10 deletions(-)
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 775bbdb..1e3c5f3 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -1,7 +1,6 @@
-<!-- A Relax NG schema for the libvirt node device XML format -->
+<!-- A Relax NG schema for the libvirt capabilities XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <!-- We handle only document defining a domain -->
<start>
<ref name='capabilities'/>
</start>
diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 78bd6a8..7060274 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -1,14 +1,10 @@
<!-- A Relax NG schema for the libvirt node device XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <!-- We handle only document defining a domain -->
<start>
<ref name='device'/>
</start>
- <!--
- We handle only document defining a domain
- -->
<define name='device'>
<element name="device">
<!-- The name of the network, used to refer to it through the API
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index e152e19..d225f97 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -1,7 +1,6 @@
-<!-- A Relax NG schema for the libvirt node device XML format -->
+<!-- A Relax NG schema for the libvirt storage pool XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <!-- We handle only document defining a domain -->
<start>
<ref name='pool'/>
</start>
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 7dc7876..5b0b038 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -1,7 +1,6 @@
-<!-- A Relax NG schema for the libvirt node device XML format -->
+<!-- A Relax NG schema for the libvirt storage volume XML format -->
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
- <!-- We handle only document defining a domain -->
<start>
<ref name='vol'/>
</start>
15 years, 3 months
[libvirt] openvzGetType() leaks memory
by Matthias Bolte
All other drivers return a static string from their getType() function
(conforming with the API documentation), but the OpenVZ driver does
strdup() a string, generating a leak:
static const char *openvzGetType(virConnectPtr conn ATTRIBUTE_UNUSED) {
return strdup("OpenVZ");
}
Matthias
15 years, 3 months
[libvirt] [PATCH] Fix latent buffer overflow in qemudOpenMonitorUnix.
by Chris Lalancette
Fix a possible latent bug in qemudOpenMonitorUnix(). If the pathname
to the monitor is very long (i.e. >= UNIX_MAX_PATH), then strncpy will
*not* place a final \0 on the string (see "man strncpy").
NULL terminate the buffer to ensure we don't run off the end.
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 9fcc07a..4f173b7 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -910,6 +910,7 @@ qemudOpenMonitorUnix(virConnectPtr conn,
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, monitor, sizeof(addr.sun_path));
+ NUL_TERMINATE(addr.sun_path);
do {
ret = connect(monfd, (struct sockaddr *) &addr, sizeof(addr));
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Remove a stray semicolon in qemudDomainMigratePrepare2.
by Chris Lalancette
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu_driver.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 83cbcf3..5f4b28b 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -6274,7 +6274,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
char migrateFrom [64];
const char *p;
virDomainEventPtr event = NULL;
- int ret = -1;;
+ int ret = -1;
int internalret;
*uri_out = NULL;
--
1.6.0.6
15 years, 3 months
[libvirt] [PATCH] Workaround for broken GCC in Debian Etch
by Maximilian Wilhelm
Hi again!
I missed one patch for working around a GCC bug in Debian Etch
regarding limit definitions.
Sorry for the unstripped git-format-patch outputs, I just realised
this after pressing send :(
(This seems to be not my day :))
Ciao
Max
--
Gib Dein Bestes. Dann übertriff Dich selbst!
15 years, 3 months