[libvirt] [PATCH 00/13] Support use of systemd-machined for cgroups
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
This is a patch series which adds support for using systemd-machined
for creating cgroups. The first 12 patches are all really just cleanups
and refactoring. The actual systemd code is the last patch, but at time
of posting it doesn't quite work properly. Given the freeze, I'd like
to get the first 12 patches merged, while I iron out the remaining
problems with the last patch.
Daniel P. Berrange (13):
Fix handling of DBus errors emitted by the bus itself
Add logic for handling systemd-machined non-existance
Add a virCgroupNewDetect API for finding cgroup placement
Add API for checking if a cgroup is valid for a domain
Auto-detect existing cgroup placement
Remove obsolete cgroups creation apis
Create + setup cgroups atomically for QEMU process
Create + setup cgroups atomically for LXC process
New cgroups API for atomically creating machine cgroups
Convert QEMU driver to use virCgroupNewMachine
Convert LXC driver to use virCgroupNewMachine
Protection against doing bad stuff to the root group
Enable support for systemd-machined in cgroups creation
src/libvirt_private.syms | 5 +-
src/lxc/lxc_cgroup.c | 82 +++-------
src/lxc/lxc_cgroup.h | 2 +-
src/lxc/lxc_controller.c | 19 +--
src/lxc/lxc_process.c | 52 +++++--
src/qemu/qemu_cgroup.c | 114 ++++++++------
src/qemu/qemu_cgroup.h | 5 +-
src/qemu/qemu_process.c | 41 +++--
src/util/vircgroup.c | 388 +++++++++++++++++++++++++++++------------------
src/util/vircgroup.h | 32 ++--
src/util/virdbus.c | 5 +-
src/util/virsystemd.c | 19 ++-
tests/vircgrouptest.c | 112 --------------
tests/virsystemdmock.c | 14 +-
tests/virsystemdtest.c | 63 +++++---
15 files changed, 496 insertions(+), 457 deletions(-)
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH v5 0/5] Support CHAP authentication for iscsi pool
by John Ferlan
This is a reworking and reposting of the authentication patches originally
posted as part of my v3 reworking of Osier's original patches, see:
https://www.redhat.com/archives/libvir-list/2013-July/msg00894.html
Patch 7/7 was noted to be incorrect since the authentication was in the
wrong place in the backend driver, see v3:
https://www.redhat.com/archives/libvir-list/2013-July/msg00901.html
and followups from my v2 posting:
https://www.redhat.com/archives/libvir-list/2013-July/msg00910.html
NOTE:
Patch 4 (https://www.redhat.com/archives/libvir-list/2013-July/msg00960.html)
was scrapped.
Adjustments from previous patches
1. Using the same logic as Direct iSCSI, add the pool authentication info
from the iSCSI pool to virDomainDiskDef's during qemuTranslateDiskSourcePool
2. Refactor the secret fetching code into one function for easier use
3. Refactor the volume building code into one function for easier use. This
is where the magic to add the auth information to the disk occurs and now
that it's part of the disk definition from the pool it will just 'be there'
4. Restore original intent to use startPool callback in order to authenticate
the pool. Added a check for NULL connection. This just stops autostarting
pools from getting authentication. This still needs to be fixed/resolved,
but there just wasn't time in this release for that.
5. Split the rbd authentication code into it's own patch rather than being
part of the iscsi patch 4.
John Ferlan (5):
qemu: Add source pool auth info to virDomainDiskDef for iSCSI
qemu: Create a common qemuGetSecretString
qemu_common: Create qemuBuildVolumeString() to process storage pool
storage: Support "chap" authentication for iscsi pool
Adjust 'ceph' authentication secret usage for rbd pool.
src/qemu/qemu_command.c | 265 ++++++++++++++++++++----------------
src/qemu/qemu_conf.c | 55 ++++++++
src/storage/storage_backend_iscsi.c | 111 ++++++++++++++-
src/storage/storage_backend_rbd.c | 21 ++-
4 files changed, 329 insertions(+), 123 deletions(-)
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH] python: virConnect: fix destructor
by Sandro Bonazzola
Fixed virConnect destructor checking for attribute
existance before trying to use it.
Avoids:
Exception AttributeError: AttributeError("virConnect instance has no
attribute 'domainEventCallbacks'",) in <bound method virConnect.__del__
of <libvirt.virConnect instance at 0x4280f38>> ignored
However, something still doesn't work:
Exception TypeError: TypeError("'NoneType' object is not callable",)
in <bound method virConnect.__del__ of <libvirt.virConnect object at 0x37576d0>> ignored
Signed-off-by: Sandro Bonazzola <sbonazzo(a)redhat.com>
---
python/libvirt-override-virConnect.py | 32 +++++++++++++++++---------------
1 file changed, 17 insertions(+), 15 deletions(-)
diff --git a/python/libvirt-override-virConnect.py b/python/libvirt-override-virConnect.py
index 5495b70..28d6d41 100644
--- a/python/libvirt-override-virConnect.py
+++ b/python/libvirt-override-virConnect.py
@@ -1,11 +1,12 @@
def __del__(self):
- try:
- for cb,opaque in self.domainEventCallbacks.items():
- del self.domainEventCallbacks[cb]
- del self.domainEventCallbacks
- libvirtmod.virConnectDomainEventDeregister(self._o, self)
- except AttributeError:
- pass
+ if hasattr(self, 'domainEventCallbacks'):
+ try:
+ for cb,opaque in self.domainEventCallbacks.items():
+ del self.domainEventCallbacks[cb]
+ del self.domainEventCallbacks
+ libvirtmod.virConnectDomainEventDeregister(self._o, self)
+ except AttributeError:
+ pass
if self._o != None:
libvirtmod.virConnectClose(self._o)
@@ -14,14 +15,15 @@
def domainEventDeregister(self, cb):
"""Removes a Domain Event Callback. De-registering for a
domain callback will disable delivery of this event type """
- try:
- del self.domainEventCallbacks[cb]
- if len(self.domainEventCallbacks) == 0:
- del self.domainEventCallbacks
- ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
- if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
- except AttributeError:
- pass
+ if hasattr(self, 'domainEventCallbacks'):
+ try:
+ del self.domainEventCallbacks[cb]
+ if len(self.domainEventCallbacks) == 0:
+ del self.domainEventCallbacks
+ ret = libvirtmod.virConnectDomainEventDeregister(self._o, self)
+ if ret == -1: raise libvirtError ('virConnectDomainEventDeregister() failed', conn=self)
+ except AttributeError:
+ pass
def domainEventRegister(self, cb, opaque):
"""Adds a Domain Event Callback. Registering for a domain
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH] virLXCMonitorClose: Unlock domain while closing monitor
by Michal Privoznik
There's a race in lxc driver causing a deadlock. If a domain is
destroyed immediately after started, the deadlock can occur. When domain
is started, the even loop tries to connect to the monitor. If the
connecting succeeds, virLXCProcessMonitorInitNotify() is called with
@mon->client locked. The first thing that callee does, is
virObjectLock(vm). So the order of locking is: 1) @mon->client, 2) @vm.
However, if there's another thread executing virDomainDestroy on the
very same domain, the first thing done here is locking the @vm. Then,
the corresponding libvirt_lxc process is killed and monitor is closed
via calling virLXCMonitorClose(). This callee tries to lock @mon->client
too. So the order is reversed to the first case. This situation results
in deadlock and unresponsive libvirtd (since the eventloop is involved).
The proper solution is to unlock the @vm in virLXCMonitorClose prior
entering virNetClientClose(). See the backtrace as follows:
Thread 25 (Thread 0x7f1b7c9b8700 (LWP 16312)):
0 0x00007f1b80539714 in __lll_lock_wait () from /lib64/libpthread.so.0
1 0x00007f1b8053516c in _L_lock_516 () from /lib64/libpthread.so.0
2 0x00007f1b80534fbb in pthread_mutex_lock () from /lib64/libpthread.so.0
3 0x00007f1b82a637cf in virMutexLock (m=0x7f1b3c0038d0) at util/virthreadpthread.c:85
4 0x00007f1b82a4ccf2 in virObjectLock (anyobj=0x7f1b3c0038c0) at util/virobject.c:320
5 0x00007f1b82b861f6 in virNetClientCloseInternal (client=0x7f1b3c0038c0, reason=3) at rpc/virnetclient.c:696
6 0x00007f1b82b862f5 in virNetClientClose (client=0x7f1b3c0038c0) at rpc/virnetclient.c:721
7 0x00007f1b6ee12500 in virLXCMonitorClose (mon=0x7f1b3c007210) at lxc/lxc_monitor.c:216
8 0x00007f1b6ee129f0 in virLXCProcessCleanup (driver=0x7f1b68100240, vm=0x7f1b680ceb70, reason=VIR_DOMAIN_SHUTOFF_DESTROYED) at lxc/lxc_process.c:174
9 0x00007f1b6ee14106 in virLXCProcessStop (driver=0x7f1b68100240, vm=0x7f1b680ceb70, reason=VIR_DOMAIN_SHUTOFF_DESTROYED) at lxc/lxc_process.c:710
10 0x00007f1b6ee1aa36 in lxcDomainDestroyFlags (dom=0x7f1b5c002560, flags=0) at lxc/lxc_driver.c:1291
11 0x00007f1b6ee1ab1a in lxcDomainDestroy (dom=0x7f1b5c002560) at lxc/lxc_driver.c:1321
12 0x00007f1b82b05be5 in virDomainDestroy (domain=0x7f1b5c002560) at libvirt.c:2303
13 0x00007f1b835a7e85 in remoteDispatchDomainDestroy (server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0, rerr=0x7f1b7c9b7c30, args=0x7f1b5c004a50) at remote_dispatch.h:3143
14 0x00007f1b835a7d78 in remoteDispatchDomainDestroyHelper (server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0, rerr=0x7f1b7c9b7c30, args=0x7f1b5c004a50, ret=0x7f1b5c0029e0) at remote_dispatch.h:3121
15 0x00007f1b82b93704 in virNetServerProgramDispatchCall (prog=0x7f1b8573af90, server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0) at rpc/virnetserverprogram.c:435
16 0x00007f1b82b93263 in virNetServerProgramDispatch (prog=0x7f1b8573af90, server=0x7f1b857419d0, client=0x7f1b8574ae40, msg=0x7f1b8574acf0) at rpc/virnetserverprogram.c:305
17 0x00007f1b82b8c0f6 in virNetServerProcessMsg (srv=0x7f1b857419d0, client=0x7f1b8574ae40, prog=0x7f1b8573af90, msg=0x7f1b8574acf0) at rpc/virnetserver.c:163
18 0x00007f1b82b8c1da in virNetServerHandleJob (jobOpaque=0x7f1b8574dca0, opaque=0x7f1b857419d0) at rpc/virnetserver.c:184
19 0x00007f1b82a64158 in virThreadPoolWorker (opaque=0x7f1b8573cb10) at util/virthreadpool.c:144
20 0x00007f1b82a63ae5 in virThreadHelper (data=0x7f1b8574b9f0) at util/virthreadpthread.c:161
21 0x00007f1b80532f4a in start_thread () from /lib64/libpthread.so.0
22 0x00007f1b7fc4f20d in clone () from /lib64/libc.so.6
Thread 1 (Thread 0x7f1b83546740 (LWP 16297)):
0 0x00007f1b80539714 in __lll_lock_wait () from /lib64/libpthread.so.0
1 0x00007f1b8053516c in _L_lock_516 () from /lib64/libpthread.so.0
2 0x00007f1b80534fbb in pthread_mutex_lock () from /lib64/libpthread.so.0
3 0x00007f1b82a637cf in virMutexLock (m=0x7f1b680ceb80) at util/virthreadpthread.c:85
4 0x00007f1b82a4ccf2 in virObjectLock (anyobj=0x7f1b680ceb70) at util/virobject.c:320
5 0x00007f1b6ee13bd7 in virLXCProcessMonitorInitNotify (mon=0x7f1b3c007210, initpid=4832, vm=0x7f1b680ceb70) at lxc/lxc_process.c:601
6 0x00007f1b6ee11fd3 in virLXCMonitorHandleEventInit (prog=0x7f1b3c001f10, client=0x7f1b3c0038c0, evdata=0x7f1b8574a7d0, opaque=0x7f1b3c007210) at lxc/lxc_monitor.c:109
7 0x00007f1b82b8a196 in virNetClientProgramDispatch (prog=0x7f1b3c001f10, client=0x7f1b3c0038c0, msg=0x7f1b3c003928) at rpc/virnetclientprogram.c:259
8 0x00007f1b82b87030 in virNetClientCallDispatchMessage (client=0x7f1b3c0038c0) at rpc/virnetclient.c:1019
9 0x00007f1b82b876bb in virNetClientCallDispatch (client=0x7f1b3c0038c0) at rpc/virnetclient.c:1140
10 0x00007f1b82b87d41 in virNetClientIOHandleInput (client=0x7f1b3c0038c0) at rpc/virnetclient.c:1312
11 0x00007f1b82b88f51 in virNetClientIncomingEvent (sock=0x7f1b3c0044e0, events=1, opaque=0x7f1b3c0038c0) at rpc/virnetclient.c:1832
12 0x00007f1b82b9e1c8 in virNetSocketEventHandle (watch=3321, fd=54, events=1, opaque=0x7f1b3c0044e0) at rpc/virnetsocket.c:1695
13 0x00007f1b82a272cf in virEventPollDispatchHandles (nfds=21, fds=0x7f1b8574ded0) at util/vireventpoll.c:498
14 0x00007f1b82a27af2 in virEventPollRunOnce () at util/vireventpoll.c:645
15 0x00007f1b82a25a61 in virEventRunDefaultImpl () at util/virevent.c:273
16 0x00007f1b82b8e97e in virNetServerRun (srv=0x7f1b857419d0) at rpc/virnetserver.c:1097
17 0x00007f1b8359db6b in main (argc=2, argv=0x7ffff98dbaa8) at libvirtd.c:1512
---
src/lxc/lxc_monitor.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/lxc/lxc_monitor.c b/src/lxc/lxc_monitor.c
index 999039b..07e9301 100644
--- a/src/lxc/lxc_monitor.c
+++ b/src/lxc/lxc_monitor.c
@@ -205,6 +205,9 @@ static void virLXCMonitorDispose(void *opaque)
void virLXCMonitorClose(virLXCMonitorPtr mon)
{
+ virDomainObjPtr vm;
+ virNetClientPtr client;
+
VIR_DEBUG("mon=%p", mon);
if (mon->client) {
/* When manually closing the monitor, we don't
@@ -212,9 +215,18 @@ void virLXCMonitorClose(virLXCMonitorPtr mon)
* the caller is not re-entrant safe
*/
VIR_DEBUG("Clear EOF callback mon=%p", mon);
- mon->cb.eofNotify = NULL;
- virNetClientClose(mon->client);
- virObjectUnref(mon->client);
+ vm = mon->vm;
+ client = mon->client;
mon->client = NULL;
+ mon->cb.eofNotify = NULL;
+
+ virObjectRef(vm);
+ virObjectUnlock(vm);
+
+ virNetClientClose(client);
+ virObjectUnref(client);
+
+ virObjectLock(vm);
+ virObjectUnref(vm);
}
}
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH V4] add console support in libxl
by Bamvor Jian Zhang
this patch introduce the console api in libxl driver for both pv and
hvm guest. and import and update the libxlMakeChrdevStr function
which was deleted in commit dfa1e1dd.
Signed-off-by: Bamvor Jian Zhang <bjzhang(a)suse.com>
---
Changes since V3:
implicity forbit dev_name pass to libxl driver due to only one
console supported by libxl.
Changes since V2:
1), forbid parallel configure because libxl do not support it
2), only support one serial on libxl driver.
3), also remove console code in libxl driver, AFAICS serial is enough for
connecting to libxl console.
Changes since V1:
1), add virDomainOpenConsoleEnsureACL
3), remove virReportOOMErrorFull when virAsprintf fail.
4), change size_t for non-nagetive number in libxlDomainOpenConsole
size_t i;
size_t num = 0;
5), fix for make check
(1), replace virAsprintf with VIR_STRDUP in two places
(2), delete space.
src/libxl/libxl_conf.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++
src/libxl/libxl_conf.h | 3 ++
src/libxl/libxl_driver.c | 94 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 197 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4a0fba9..539d537 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -331,6 +331,90 @@ error:
}
static int
+libxlMakeChrdevStr(virDomainChrDefPtr def, char **buf)
+{
+ const char *type = virDomainChrTypeToString(def->source.type);
+ int ret;
+
+ if (!type) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("unexpected chr device type"));
+ return -1;
+ }
+
+ switch (def->source.type) {
+ case VIR_DOMAIN_CHR_TYPE_NULL:
+ case VIR_DOMAIN_CHR_TYPE_STDIO:
+ case VIR_DOMAIN_CHR_TYPE_VC:
+ case VIR_DOMAIN_CHR_TYPE_PTY:
+ if (VIR_STRDUP(*buf, type) < 0)
+ return -1;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_FILE:
+ case VIR_DOMAIN_CHR_TYPE_PIPE:
+ if (virAsprintf(buf, "%s:%s", type,
+ def->source.data.file.path) < 0)
+ return -1;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_DEV:
+ if (VIR_STRDUP(*buf, def->source.data.file.path) < 0)
+ return -1;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_UDP: {
+ const char *connectHost = def->source.data.udp.connectHost;
+ const char *bindHost = def->source.data.udp.bindHost;
+ const char *bindService = def->source.data.udp.bindService;
+
+ if (connectHost == NULL)
+ connectHost = "";
+ if (bindHost == NULL)
+ bindHost = "";
+ if (bindService == NULL)
+ bindService = "0";
+
+ ret = virAsprintf(buf, "udp:%s:%s@%s:%s",
+ connectHost,
+ def->source.data.udp.connectService,
+ bindHost,
+ bindService);
+ if (ret < 0)
+ return -1;
+ break;
+
+ }
+ case VIR_DOMAIN_CHR_TYPE_TCP:
+ if (def->source.data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET)
+ ret = virAsprintf(buf, "telnet:%s:%s%s",
+ def->source.data.tcp.host,
+ def->source.data.tcp.service,
+ def->source.data.tcp.listen ? ",server,nowait" : "");
+ else
+ ret = virAsprintf(buf, "tcp:%s:%s%s",
+ def->source.data.tcp.host,
+ def->source.data.tcp.service,
+ def->source.data.tcp.listen ? ",server,nowait" : "");
+
+ if (ret < 0)
+ return -1;
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_UNIX:
+ ret = virAsprintf(buf, "unix:%s%s",
+ def->source.data.nix.path,
+ def->source.data.nix.listen ? ",server,nowait" : "");
+ if (ret < 0)
+ return -1;
+ break;
+
+ }
+
+ return 0;
+}
+
+static int
libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
{
libxl_domain_build_info *b_info = &d_config->b_info;
@@ -403,6 +487,22 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
if (VIR_STRDUP(b_info->u.hvm.boot, bootorder) < 0)
goto error;
+ if (def->nserials) {
+ if (def->nserials > 1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Only one serial is supported by libxl"));
+ goto error;
+ }
+ if (libxlMakeChrdevStr(def->serials[0], &b_info->u.hvm.serial) < 0)
+ goto error;
+ }
+
+ if (def->nparallels) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s", _("Parallel is not supported"));
+ goto error;
+ }
+
/*
* The following comment and calculation were taken directly from
* libxenlight's internal function libxl_get_required_shadow_memory():
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 2b4a281..861d689 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -34,6 +34,7 @@
# include "configmake.h"
# include "virportallocator.h"
# include "virobject.h"
+# include "virchrdev.h"
# define LIBXL_VNC_PORT_MIN 5900
@@ -94,6 +95,8 @@ struct _libxlDomainObjPrivate {
/* per domain libxl ctx */
libxl_ctx *ctx;
+ /* console */
+ virChrdevsPtr devs;
libxl_evgen_domain_death *deathW;
/* list of libxl timeout registrations */
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 358d387..9299484 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -417,6 +417,9 @@ libxlDomainObjPrivateAlloc(void)
libxl_osevent_register_hooks(priv->ctx, &libxl_event_callbacks, priv);
+ if (!(priv->devs = virChrdevAlloc()))
+ return NULL;
+
return priv;
}
@@ -429,6 +432,7 @@ libxlDomainObjPrivateDispose(void *obj)
libxl_evdisable_domain_death(priv->ctx, priv->deathW);
libxl_ctx_free(priv->ctx);
+ virChrdevFree(priv->devs);
}
static void
@@ -4493,6 +4497,95 @@ cleanup:
return ret;
}
+
+static int
+libxlDomainOpenConsole(virDomainPtr dom,
+ const char *dev_name,
+ virStreamPtr st,
+ unsigned int flags)
+{
+ libxlDriverPrivatePtr driver = dom->conn->privateData;
+ virDomainObjPtr vm = NULL;
+ int ret = -1;
+ virDomainChrDefPtr chr = NULL;
+ libxlDomainObjPrivatePtr priv;
+ char *console = NULL;
+
+ virCheckFlags(VIR_DOMAIN_CONSOLE_SAFE |
+ VIR_DOMAIN_CONSOLE_FORCE, -1);
+
+ if (dev_name) {
+ /* XXX support device aliases in future */
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("Named device aliases are not supported"));
+ goto cleanup;
+ }
+
+ libxlDriverLock(driver);
+ vm = virDomainObjListFindByUUID(driver->domains, dom->uuid);
+ libxlDriverUnlock(driver);
+ if (!vm) {
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+ virUUIDFormat(dom->uuid, uuidstr);
+ virReportError(VIR_ERR_NO_DOMAIN,
+ _("No domain with matching uuid '%s'"), uuidstr);
+ goto cleanup;
+ }
+
+ if (virDomainOpenConsoleEnsureACL(dom->conn, vm->def) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(vm)) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ "%s", _("domain is not running"));
+ goto cleanup;
+ }
+
+ priv = vm->privateData;
+
+ if (vm->def->nserials)
+ chr = vm->def->serials[0];
+
+ if (!chr) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot find character device %s"),
+ NULLSTR(dev_name));
+ goto cleanup;
+ }
+
+ if (chr->source.type != VIR_DOMAIN_CHR_TYPE_PTY) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("character device %s is not using a PTY"),
+ NULLSTR(dev_name));
+ goto cleanup;
+ }
+
+ ret = libxl_primary_console_get_tty(priv->ctx, vm->def->id, &console);
+ if (ret)
+ goto cleanup;
+
+ if (VIR_STRDUP(chr->source.data.file.path, console) < 0)
+ goto cleanup;
+
+ /* handle mutually exclusive access to console devices */
+ ret = virChrdevOpen(priv->devs,
+ &chr->source,
+ st,
+ (flags & VIR_DOMAIN_CONSOLE_FORCE) != 0);
+
+ if (ret == 1) {
+ virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+ _("Active console session exists for this domain"));
+ ret = -1;
+ }
+
+cleanup:
+ VIR_FREE(console);
+ if (vm)
+ virObjectUnlock(vm);
+ return ret;
+}
+
static int
libxlDomainSetSchedulerParameters(virDomainPtr dom, virTypedParameterPtr params,
int nparams)
@@ -4875,6 +4968,7 @@ static virDriver libxlDriver = {
.domainManagedSave = libxlDomainManagedSave, /* 0.9.2 */
.domainHasManagedSaveImage = libxlDomainHasManagedSaveImage, /* 0.9.2 */
.domainManagedSaveRemove = libxlDomainManagedSaveRemove, /* 0.9.2 */
+ .domainOpenConsole = libxlDomainOpenConsole, /* 1.1.1 */
.domainIsActive = libxlDomainIsActive, /* 0.9.0 */
.domainIsPersistent = libxlDomainIsPersistent, /* 0.9.0 */
.domainIsUpdated = libxlDomainIsUpdated, /* 0.9.0 */
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH] libxl: Correctly initialize vcpu bitmap
by Stefan Bader
This fixes the basic setup but there is likely more to do if things
like manual CPU hirarchy (nodes, cores, threads) to be working.
Cross-posting to xen-devel to make sure I am doing things correctly.
-Stefan
>From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001
From: Stefan Bader <stefan.bader(a)canonical.com>
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap
The avai_vcpu bitmap has to be allocated before it can be used (using
the maximum allowed value for that). Then for each available VCPU the
bit in the mask has to be set (libxl_bitmap_set takes a bit position
as an argument, not the number of bits to set).
Without this, I would always only get one VCPU for guests created
through libvirt/libxl.
Signed-off-by: Stefan Bader <stefan.bader(a)canonical.com>
---
src/libxl/libxl_conf.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4a0fba9..7592dd2 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -331,7 +331,8 @@ error:
}
static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+ libxl_domain_config *d_config)
{
libxl_domain_build_info *b_info = &d_config->b_info;
int hvm = STREQ(def->os.type, "hvm");
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
else
libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
b_info->max_vcpus = def->maxvcpus;
- libxl_bitmap_set((&b_info->avail_vcpus), def->vcpus);
+ if (libxl_cpu_bitmap_alloc(driver->ctx, &b_info->avail_vcpus,
+ def->maxvcpus))
+ goto error;
+ libxl_bitmap_set_none(&b_info->avail_vcpus);
+ for (i = 0; i < def->vcpus; i++)
+ libxl_bitmap_set((&b_info->avail_vcpus), i);
+
if (def->clock.ntimers > 0 &&
def->clock.timers[0]->name == VIR_DOMAIN_TIMER_NAME_TSC) {
switch (def->clock.timers[0]->mode) {
@@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
if (libxlMakeDomCreateInfo(driver, def, &d_config->c_info) < 0)
return -1;
- if (libxlMakeDomBuildInfo(def, d_config) < 0) {
+ if (libxlMakeDomBuildInfo(driver, def, d_config) < 0) {
return -1;
}
--
1.7.9.5
11 years, 4 months
[libvirt] [PATCH] Fix link_addr detection
by Roman Bogorodskiy
link_addr detection in configure always reports that
link_addr is missing because it uses link_addr(NULL, NULL) in
AC_LINK_IFELSE check with limited set of headers that doesn't
define NULL.
Fix by replacing 'NULL' with just '0'.
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 27531a1..cc9942a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2401,7 +2401,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM(
#include <net/if_dl.h>
]],
[[
- link_addr(NULL, NULL)]])],
+ link_addr(0, 0)]])],
[AC_DEFINE([HAVE_DECL_LINK_ADDR],
[1],
[whether link_addr is available])])
--
1.7.11.5
11 years, 4 months
[libvirt] [PATCH] Add new virAuth symbols to private.syms
by Ján Tomko
Otherwise libvirtd fails to load the lockd plugin.
---
src/libvirt_private.syms | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5a5d112..526010f 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1095,8 +1095,11 @@ virAuditSend;
# util/virauth.h
virAuthGetConfigFilePath;
+virAuthGetConfigFilePathURI;
virAuthGetPassword;
+virAuthGetPasswordPath;
virAuthGetUsername;
+virAuthGetUsernamePath;
# util/virauthconfig.h
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH] Add a colon after 'internal error'
by Ján Tomko
As we do for other errors with an extra string.
---
src/util/virerror.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virerror.c b/src/util/virerror.c
index b92c6d1..ca25678 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -730,7 +730,7 @@ virErrorMsg(virErrorNumber error, const char *info)
return NULL;
case VIR_ERR_INTERNAL_ERROR:
if (info != NULL)
- errmsg = _("internal error %s");
+ errmsg = _("internal error: %s");
else
errmsg = _("internal error");
break;
--
1.8.1.5
11 years, 4 months