Compare commits
204 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f6883e0fb | |||
| 6ed21f35ce | |||
| fd4b7c7eda | |||
| a7685ecb49 | |||
| 4987454f4d | |||
| 7d54a9531e | |||
| ec17372ebc | |||
| 64e6ea2c74 | |||
| 4877a48e58 | |||
| 9862314ee5 | |||
| 5e3f148cab | |||
| 8fa149f902 | |||
| cc9cfaa90d | |||
| 2c2e71c0ce | |||
| 96b1b18b42 | |||
| f7763bfd17 | |||
| 404e58cb18 | |||
| cd3767e3b9 | |||
| f1867a5ecc | |||
| b5548f62cb | |||
| 52f3bedee7 | |||
| f87237919c | |||
| e8969fb913 | |||
| 74d46bc7dd | |||
| 4b6ea94306 | |||
| 963754bc8c | |||
| 7b5483236c | |||
| 438006407c | |||
| 76c8282ee2 | |||
| f463598b24 | |||
| f4e752a385 | |||
| c37cb21dea | |||
| e0bfc1f8aa | |||
| 544ad4a787 | |||
| 8f163760ed | |||
| 565427cf89 | |||
| e10da2f6d4 | |||
| aa386576d5 | |||
| c73c129b48 | |||
| afe729ac3c | |||
| b6038bae4f | |||
| e6d9787587 | |||
| 44699dc495 | |||
| 991d719dde | |||
| 96a520b555 | |||
| e31df5e9de | |||
| 6763b267b9 | |||
| 24e91208a4 | |||
| 15dec999e7 | |||
| d6b0635d3d | |||
| 336a93264e | |||
| 6398d1cff5 | |||
| 6926ed26ea | |||
| 6253f97a2d | |||
| 37ddbd0eac | |||
| 95fe7c8df2 | |||
| 79ae809020 | |||
| f19e302ba9 | |||
| e9c1d3f4b0 | |||
| 0f577d932b | |||
| 21a02c2e90 | |||
| 4e460d5f09 | |||
| f9de2f6bc6 | |||
| 2daa1b7814 | |||
| f99eeb8567 | |||
| 7069f75cb8 | |||
| 2cac7dac46 | |||
| 913c3c6554 | |||
| a5a4c0c89b | |||
| 8c8aca2fab | |||
| daf8e124ca | |||
| 38c4b724fe | |||
| 4d00487275 | |||
| a6831c26c1 | |||
| c363c7ebdb | |||
| 18ee6daf8a | |||
| 459eb426c3 | |||
| a0d670d2bf | |||
| d7b41212c1 | |||
| 2e1539eba4 | |||
| ee9521d87c | |||
| 8d8fc08bac | |||
| e79d304c79 | |||
| db03f03fd9 | |||
| 957403ebec | |||
| 6c32e1aaeb | |||
| 362e335c0b | |||
| ed6c49f874 | |||
| 47fcec5405 | |||
| d7239a45b6 | |||
| f13fb18c58 | |||
| d29644418d | |||
| ed9e426b26 | |||
| 659febf9ff | |||
| fca1fccfad | |||
| f713d63bab | |||
| 5a45e466cf | |||
| 742b24eb23 | |||
| 03369d2383 | |||
| 2605d662e0 | |||
| e8394ab5b5 | |||
| 8ad156a5c2 | |||
| f2d6fb6239 | |||
| e3a592c38d | |||
| 7e99819dda | |||
| a160d7f98d | |||
| 36cab842e8 | |||
| 7b7b86e327 | |||
| f4bfe638b6 | |||
| 0e9d242f05 | |||
| e24467a8c2 | |||
| b39c370a76 | |||
| 62e4e7cde2 | |||
| f822179f97 | |||
| 47e7e1e548 | |||
| e73b75314b | |||
| 8193a55b4a | |||
| 6036708fa2 | |||
| 4717aa0b6d | |||
| 97ae25ea7d | |||
| 6470ed033b | |||
| b550f9c1d5 | |||
| ee0273ffc3 | |||
| 50fce74b00 | |||
| e29f71d1c9 | |||
| 427ed20801 | |||
| d23e6c285b | |||
| 2c139b45d8 | |||
| 762435e3b7 | |||
| 6383d6b056 | |||
| 3712441ea6 | |||
| 9d0bc882fa | |||
| 90dddf3d3d | |||
| 86abd54d02 | |||
| 4ab5ad5425 | |||
| f9c1b758c3 | |||
| 38cf1bd5ba | |||
| aeda455930 | |||
| 288291b795 | |||
| 7c2073faca | |||
| 5b528ba717 | |||
| 4f731a7250 | |||
| f1ac0031f5 | |||
| e45b9c9030 | |||
| 3cf75c269d | |||
| 585033f372 | |||
| 897506e66a | |||
| e4bf8ffa42 | |||
| 20367a58a6 | |||
| aa037364ed | |||
| c034c1a3b2 | |||
| da05e02884 | |||
| e1b7b518ac | |||
| 581b5f5022 | |||
| c476c8b683 | |||
| b93eafc59f | |||
| 2105d62ca8 | |||
| 743adffffe | |||
| 11e3b51c0d | |||
| 66df925739 | |||
| b20a5c6d3b | |||
| 7f58f3aa54 | |||
| 6577b14441 | |||
| 2e7812764f | |||
| 854b878580 | |||
| 89c28e4013 | |||
| db269c2d21 | |||
| 98e4f7ee9f | |||
| 0c4afc5ee9 | |||
| 593255292e | |||
| ccafc8ecb4 | |||
| a38fb9cbc1 | |||
| 6359121866 | |||
| b20d669e88 | |||
| a3e1cc37ed | |||
| a6eca3382d | |||
| c6c5072e90 | |||
| 705fd20a0e | |||
| e0e9927d93 | |||
| bae7a0fb84 | |||
| 36aee593bc | |||
| dc0cb0e91a | |||
| 84d66312fe | |||
| 4f644ce267 | |||
| cdd5b3d62d | |||
| 53f63aa62d | |||
| 748df35c5f | |||
| a6e23d00fa | |||
| c6d11b43c9 | |||
| 83091ff0dd | |||
| 4465a63872 | |||
| 3f397d9786 | |||
| 750aec5507 | |||
| d7c1d3bbc0 | |||
| fa0f21c263 | |||
| afdaf5d354 | |||
| 26bba5aea9 | |||
| 1a4185bdcc | |||
| 6a73119e65 | |||
| 1e2f9fce0a | |||
| f5edf79c95 | |||
| b59e64bf44 | |||
| a09fc2658a | |||
| a008fcf27e |
@@ -3,5 +3,3 @@
|
||||
i686
|
||||
x86_64
|
||||
libvirt-*.tar.gz
|
||||
libvirt-0.6.0.tar.gz
|
||||
libvirt-0.6.1.tar.gz
|
||||
@@ -0,0 +1,27 @@
|
||||
From 37865f1dead1fac2ee34af48f96d19d686296e04 Mon Sep 17 00:00:00 2001
|
||||
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||
Date: Thu, 13 Sep 2012 14:37:22 +0100
|
||||
Subject: [PATCH] Use 'qemu-system-i386' as binary instead of 'qemu'.
|
||||
|
||||
---
|
||||
src/qemu/qemu_capabilities.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
||||
index af3b0b2..179b3d2 100644
|
||||
--- a/src/qemu/qemu_capabilities.c
|
||||
+++ b/src/qemu/qemu_capabilities.c
|
||||
@@ -244,8 +244,8 @@ static const struct qemu_feature_flags const arch_info_x86_64_flags [] = {
|
||||
|
||||
/* The archicture tables for supported QEMU archs */
|
||||
static const struct qemu_arch_info const arch_info_hvm[] = {
|
||||
- { "i686", 32, NULL, "qemu",
|
||||
- "qemu-system-x86_64", arch_info_i686_flags, 4 },
|
||||
+ { "i686", 32, NULL, "qemu-system-i386",
|
||||
+ NULL, arch_info_i686_flags, 4 },
|
||||
{ "x86_64", 64, NULL, "qemu-system-x86_64",
|
||||
NULL, arch_info_x86_64_flags, 2 },
|
||||
{ "arm", 32, NULL, "qemu-system-arm", NULL, NULL, 0 },
|
||||
--
|
||||
1.7.11.4
|
||||
|
||||
@@ -4,7 +4,7 @@ NAME := libvirt
|
||||
SPECFILE = $(firstword $(wildcard *.spec))
|
||||
|
||||
define find-makefile-common
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(find-makefile-common))
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
From: Daniel P. Berrange <berrange@redhat.com>
|
||||
Date: Mon, 16 Mar 2009 10:35:21 +0000 (+0000)
|
||||
Subject: Fix dispatch of FD events when one or more handles are marked deleted
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=10baf3deb8588f5902b6f2eb362fb408707e3d95
|
||||
|
||||
Fix dispatch of FD events when one or more handles are marked deleted
|
||||
---
|
||||
|
||||
diff --git a/qemud/event.c b/qemud/event.c
|
||||
index c9ea563..0887008 100644
|
||||
--- a/qemud/event.c
|
||||
+++ b/qemud/event.c
|
||||
@@ -409,25 +409,26 @@ static int virEventDispatchTimeouts(void) {
|
||||
* Returns 0 upon success, -1 if an error occurred
|
||||
*/
|
||||
static int virEventDispatchHandles(int nfds, struct pollfd *fds) {
|
||||
- int i;
|
||||
+ int i, n;
|
||||
|
||||
- for (i = 0 ; i < nfds ; i++) {
|
||||
+ for (i = 0, n = 0 ; i < eventLoop.handlesCount && n < nfds ; i++) {
|
||||
if (eventLoop.handles[i].deleted) {
|
||||
EVENT_DEBUG("Skip deleted %d", eventLoop.handles[i].fd);
|
||||
continue;
|
||||
}
|
||||
|
||||
- if (fds[i].revents) {
|
||||
+ if (fds[n].revents) {
|
||||
virEventHandleCallback cb = eventLoop.handles[i].cb;
|
||||
void *opaque = eventLoop.handles[i].opaque;
|
||||
- int hEvents = virPollEventToEventHandleType(fds[i].revents);
|
||||
- EVENT_DEBUG("Dispatch %d %d %p", fds[i].fd,
|
||||
- fds[i].revents, eventLoop.handles[i].opaque);
|
||||
+ int hEvents = virPollEventToEventHandleType(fds[n].revents);
|
||||
+ EVENT_DEBUG("Dispatch %d %d %p", fds[n].fd,
|
||||
+ fds[n].revents, eventLoop.handles[i].opaque);
|
||||
virEventUnlock();
|
||||
(cb)(eventLoop.handles[i].watch,
|
||||
- fds[i].fd, hEvents, opaque);
|
||||
+ fds[n].fd, hEvents, opaque);
|
||||
virEventLock();
|
||||
}
|
||||
+ n++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1,78 +0,0 @@
|
||||
From: Daniel Veillard <veillard@redhat.com>
|
||||
Date: Mon, 16 Mar 2009 10:41:37 +0000 (+0000)
|
||||
Subject: Avoid some potential FILE * leaks
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=39429bab2d55807698d9aed0112200ae532799b8
|
||||
|
||||
Avoid some potential FILE * leaks
|
||||
* qemud/qemud.c src/cgroup.c src/uml_driver.c src/util.c: close
|
||||
some potential FILE * leaks
|
||||
Daniel
|
||||
---
|
||||
|
||||
diff --git a/qemud/qemud.c b/qemud/qemud.c
|
||||
index fd315fc..4f04355 100644
|
||||
--- a/qemud/qemud.c
|
||||
+++ b/qemud/qemud.c
|
||||
@@ -488,7 +488,7 @@ static int qemudWritePidFile(const char *pidFile) {
|
||||
if (fprintf(fh, "%lu\n", (unsigned long)getpid()) < 0) {
|
||||
VIR_ERROR(_("Failed to write to pid file '%s' : %s"),
|
||||
pidFile, virStrerror(errno, ebuf, sizeof ebuf));
|
||||
- close(fd);
|
||||
+ fclose(fh);
|
||||
return -1;
|
||||
}
|
||||
|
||||
diff --git a/src/cgroup.c b/src/cgroup.c
|
||||
index 5af44bd..d1d44a2 100644
|
||||
--- a/src/cgroup.c
|
||||
+++ b/src/cgroup.c
|
||||
@@ -57,7 +57,7 @@ void virCgroupFree(virCgroupPtr *group)
|
||||
|
||||
static virCgroupPtr virCgroupGetMount(const char *controller)
|
||||
{
|
||||
- FILE *mounts;
|
||||
+ FILE *mounts = NULL;
|
||||
struct mntent entry;
|
||||
char buf[CGROUP_MAX_VAL];
|
||||
virCgroupPtr root = NULL;
|
||||
@@ -90,6 +90,8 @@ static virCgroupPtr virCgroupGetMount(const char *controller)
|
||||
|
||||
return root;
|
||||
err:
|
||||
+ if (mounts != NULL)
|
||||
+ fclose(mounts);
|
||||
virCgroupFree(&root);
|
||||
|
||||
return NULL;
|
||||
diff --git a/src/uml_driver.c b/src/uml_driver.c
|
||||
index 1dc7ccd..f7400f9 100644
|
||||
--- a/src/uml_driver.c
|
||||
+++ b/src/uml_driver.c
|
||||
@@ -547,6 +547,7 @@ reopen:
|
||||
|
||||
if (fscanf(file, "%d", &vm->pid) != 1) {
|
||||
errno = EINVAL;
|
||||
+ fclose(file);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -1040,6 +1041,7 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, int pid) {
|
||||
|
||||
if (fscanf(pidinfo, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %llu %llu", &usertime, &systime) != 2) {
|
||||
umlDebug("not enough arg");
|
||||
+ fclose(pidinfo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
diff --git a/src/util.c b/src/util.c
|
||||
index 9b74757..66ad9a4 100644
|
||||
--- a/src/util.c
|
||||
+++ b/src/util.c
|
||||
@@ -1058,6 +1058,7 @@ int virFileReadPid(const char *dir,
|
||||
|
||||
if (fscanf(file, "%d", pid) != 1) {
|
||||
rc = EINVAL;
|
||||
+ fclose(file);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
Index: src/remote_internal.c
|
||||
===================================================================
|
||||
RCS file: /data/cvs/libxen/src/remote_internal.c,v
|
||||
retrieving revision 1.141
|
||||
diff -u -u -p -r1.141 remote_internal.c
|
||||
--- src/remote_internal.c 3 Mar 2009 19:33:34 -0000 1.141
|
||||
+++ src/remote_internal.c 16 Mar 2009 16:57:17 -0000
|
||||
@@ -332,7 +332,7 @@ doRemoteOpen (virConnectPtr conn,
|
||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||
int flags)
|
||||
{
|
||||
- int wakeupFD[2];
|
||||
+ int wakeupFD[2] = { -1, -1 };
|
||||
char *transport_str = NULL;
|
||||
|
||||
if (conn->uri) {
|
||||
@@ -885,6 +885,11 @@ doRemoteOpen (virConnectPtr conn,
|
||||
#endif
|
||||
}
|
||||
|
||||
+ if (wakeupFD[0] >= 0) {
|
||||
+ close(wakeupFD[0]);
|
||||
+ close(wakeupFD[1]);
|
||||
+ }
|
||||
+
|
||||
VIR_FREE(priv->hostname);
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -1350,6 +1355,11 @@ doRemoteClose (virConnectPtr conn, struc
|
||||
} while (reap != -1 && reap != priv->pid);
|
||||
}
|
||||
#endif
|
||||
+ if (priv->wakeupReadFD >= 0) {
|
||||
+ close(priv->wakeupReadFD);
|
||||
+ close(priv->wakeupSendFD);
|
||||
+ }
|
||||
+
|
||||
|
||||
/* Free hostname copy */
|
||||
free (priv->hostname);
|
||||
@@ -1,22 +0,0 @@
|
||||
From: Daniel P. Berrange <berrange@redhat.com>
|
||||
Date: Mon, 16 Mar 2009 10:33:01 +0000 (+0000)
|
||||
Subject: Fix handling of cpumaps arg to virDomainGetVcpus RPC dispatcher
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=2d75d954f52a740470f85ceece4eb995d79968ca
|
||||
|
||||
Fix handling of cpumaps arg to virDomainGetVcpus RPC dispatcher
|
||||
---
|
||||
|
||||
diff --git a/qemud/remote.c b/qemud/remote.c
|
||||
index 8eaa7d6..44a274a 100644
|
||||
--- a/qemud/remote.c
|
||||
+++ b/qemud/remote.c
|
||||
@@ -1475,7 +1475,8 @@ remoteDispatchDomainGetVcpus (struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
/* Allocate buffers to take the results. */
|
||||
if (VIR_ALLOC_N(info, args->maxinfo) < 0)
|
||||
goto oom;
|
||||
- if (VIR_ALLOC_N(cpumaps, args->maxinfo) < 0)
|
||||
+ if (args->maplen > 0 &&
|
||||
+ VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0)
|
||||
goto oom;
|
||||
|
||||
info_len = virDomainGetVcpus (dom,
|
||||
@@ -1,188 +0,0 @@
|
||||
From: Daniel Veillard <veillard@redhat.com>
|
||||
Date: Thu, 12 Mar 2009 20:15:32 +0000 (+0000)
|
||||
Subject: * src/storage_conf.c: fix storage pool mode parsing, and refactoring
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=bc962f5d7c6e2c2cfc233ea6deea95dba2b7c6eb
|
||||
|
||||
* src/storage_conf.c: fix storage pool mode parsing, and refactoring
|
||||
patch by Ryota Ozaki
|
||||
Daniel
|
||||
---
|
||||
|
||||
diff --git a/src/storage_conf.c b/src/storage_conf.c
|
||||
index 9c13e07..1c9a4e5 100644
|
||||
--- a/src/storage_conf.c
|
||||
+++ b/src/storage_conf.c
|
||||
@@ -371,15 +371,33 @@ virStoragePoolDefParseAuthChap(virConnectPtr conn,
|
||||
|
||||
|
||||
static int
|
||||
-virStoragePoolDefParsePerms(virConnectPtr conn,
|
||||
- xmlXPathContextPtr ctxt,
|
||||
- virStoragePermsPtr perms) {
|
||||
+virStorageDefParsePerms(virConnectPtr conn,
|
||||
+ xmlXPathContextPtr ctxt,
|
||||
+ virStoragePermsPtr perms,
|
||||
+ const char *permxpath,
|
||||
+ int defaultmode) {
|
||||
char *mode;
|
||||
long v;
|
||||
+ int ret = -1;
|
||||
+ xmlNodePtr relnode;
|
||||
+ xmlNodePtr node;
|
||||
|
||||
- mode = virXPathString(conn, "string(/pool/permissions/mode)", ctxt);
|
||||
+ node = virXPathNode(conn, permxpath, ctxt);
|
||||
+ if (node == NULL) {
|
||||
+ /* Set default values if there is not <permissions> element */
|
||||
+ perms->mode = defaultmode;
|
||||
+ perms->uid = getuid();
|
||||
+ perms->gid = getgid();
|
||||
+ perms->label = NULL;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ relnode = ctxt->node;
|
||||
+ ctxt->node = node;
|
||||
+
|
||||
+ mode = virXPathString(conn, "string(./mode)", ctxt);
|
||||
if (!mode) {
|
||||
- perms->mode = 0700;
|
||||
+ perms->mode = defaultmode;
|
||||
} else {
|
||||
char *end = NULL;
|
||||
perms->mode = strtol(mode, &end, 8);
|
||||
@@ -387,36 +405,39 @@ virStoragePoolDefParsePerms(virConnectPtr conn,
|
||||
if (*end || perms->mode < 0 || perms->mode > 0777) {
|
||||
virStorageReportError(conn, VIR_ERR_XML_ERROR,
|
||||
"%s", _("malformed octal mode"));
|
||||
- return -1;
|
||||
+ goto error;
|
||||
}
|
||||
}
|
||||
|
||||
- if (virXPathNode(conn, "/pool/permissions/owner", ctxt) == NULL) {
|
||||
+ if (virXPathNode(conn, "./owner", ctxt) == NULL) {
|
||||
perms->uid = getuid();
|
||||
} else {
|
||||
- if (virXPathLong(conn, "number(/pool/permissions/owner)", ctxt, &v) < 0) {
|
||||
+ if (virXPathLong(conn, "number(./owner)", ctxt, &v) < 0) {
|
||||
virStorageReportError(conn, VIR_ERR_XML_ERROR,
|
||||
"%s", _("malformed owner element"));
|
||||
- return -1;
|
||||
+ goto error;
|
||||
}
|
||||
perms->uid = (int)v;
|
||||
}
|
||||
|
||||
- if (virXPathNode(conn, "/pool/permissions/group", ctxt) == NULL) {
|
||||
+ if (virXPathNode(conn, "./group", ctxt) == NULL) {
|
||||
perms->gid = getgid();
|
||||
} else {
|
||||
- if (virXPathLong(conn, "number(/pool/permissions/group)", ctxt, &v) < 0) {
|
||||
+ if (virXPathLong(conn, "number(./group)", ctxt, &v) < 0) {
|
||||
virStorageReportError(conn, VIR_ERR_XML_ERROR,
|
||||
"%s", _("malformed group element"));
|
||||
- return -1;
|
||||
+ goto error;
|
||||
}
|
||||
perms->gid = (int)v;
|
||||
}
|
||||
|
||||
/* NB, we're ignoring missing labels here - they'll simply inherit */
|
||||
- perms->label = virXPathString(conn, "string(/pool/permissions/label)", ctxt);
|
||||
+ perms->label = virXPathString(conn, "string(./label)", ctxt);
|
||||
|
||||
- return 0;
|
||||
+ ret = 0;
|
||||
+error:
|
||||
+ ctxt->node = relnode;
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +600,8 @@ virStoragePoolDefParseDoc(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- if (virStoragePoolDefParsePerms(conn, ctxt, &ret->target.perms) < 0)
|
||||
+ if (virStorageDefParsePerms(conn, ctxt, &ret->target.perms,
|
||||
+ "/pool/target/permissions", 0700) < 0)
|
||||
goto cleanup;
|
||||
|
||||
return ret;
|
||||
@@ -801,55 +823,6 @@ virStoragePoolDefFormat(virConnectPtr conn,
|
||||
|
||||
|
||||
static int
|
||||
-virStorageVolDefParsePerms(virConnectPtr conn,
|
||||
- xmlXPathContextPtr ctxt,
|
||||
- virStoragePermsPtr perms) {
|
||||
- char *mode;
|
||||
- long v;
|
||||
-
|
||||
- mode = virXPathString(conn, "string(/volume/permissions/mode)", ctxt);
|
||||
- if (!mode) {
|
||||
- perms->mode = 0600;
|
||||
- } else {
|
||||
- char *end = NULL;
|
||||
- perms->mode = strtol(mode, &end, 8);
|
||||
- VIR_FREE(mode);
|
||||
- if (*end || perms->mode < 0 || perms->mode > 0777) {
|
||||
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
|
||||
- "%s", _("malformed octal mode"));
|
||||
- return -1;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (virXPathNode(conn, "/volume/permissions/owner", ctxt) == NULL) {
|
||||
- perms->uid = getuid();
|
||||
- } else {
|
||||
- if (virXPathLong(conn, "number(/volume/permissions/owner)", ctxt, &v) < 0) {
|
||||
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
|
||||
- "%s", _("missing owner element"));
|
||||
- return -1;
|
||||
- }
|
||||
- perms->uid = (int)v;
|
||||
- }
|
||||
- if (virXPathNode(conn, "/volume/permissions/group", ctxt) == NULL) {
|
||||
- perms->gid = getgid();
|
||||
- } else {
|
||||
- if (virXPathLong(conn, "number(/volume/permissions/group)", ctxt, &v) < 0) {
|
||||
- virStorageReportError(conn, VIR_ERR_XML_ERROR,
|
||||
- "%s", _("missing group element"));
|
||||
- return -1;
|
||||
- }
|
||||
- perms->gid = (int)v;
|
||||
- }
|
||||
-
|
||||
- /* NB, we're ignoring missing labels here - they'll simply inherit */
|
||||
- perms->label = virXPathString(conn, "string(/volume/permissions/label)", ctxt);
|
||||
-
|
||||
- return 0;
|
||||
-}
|
||||
-
|
||||
-
|
||||
-static int
|
||||
virStorageSize(virConnectPtr conn,
|
||||
const char *unit,
|
||||
const char *val,
|
||||
@@ -997,7 +970,8 @@ virStorageVolDefParseDoc(virConnectPtr conn,
|
||||
VIR_FREE(format);
|
||||
}
|
||||
|
||||
- if (virStorageVolDefParsePerms(conn, ctxt, &ret->target.perms) < 0)
|
||||
+ if (virStorageDefParsePerms(conn, ctxt, &ret->target.perms,
|
||||
+ "/volume/target/permissions", 0600) < 0)
|
||||
goto cleanup;
|
||||
|
||||
|
||||
@@ -1019,7 +993,8 @@ virStorageVolDefParseDoc(virConnectPtr conn,
|
||||
VIR_FREE(format);
|
||||
}
|
||||
|
||||
- if (virStorageVolDefParsePerms(conn, ctxt, &ret->backingStore.perms) < 0)
|
||||
+ if (virStorageDefParsePerms(conn, ctxt, &ret->backingStore.perms,
|
||||
+ "/volume/backingStore/permissions", 0600) < 0)
|
||||
goto cleanup;
|
||||
|
||||
return ret;
|
||||
@@ -1,20 +0,0 @@
|
||||
From: Daniel P. Berrange <berrange@redhat.com>
|
||||
Date: Mon, 16 Mar 2009 10:31:38 +0000 (+0000)
|
||||
Subject: Don't free storage volume in cleanup path, since it may still be referenced
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=d8f08ca049b6d3bc7a5124a3957e967539ad080d
|
||||
|
||||
Don't free storage volume in cleanup path, since it may still be referenced
|
||||
---
|
||||
|
||||
diff --git a/src/storage_driver.c b/src/storage_driver.c
|
||||
index f1320c5..b261843 100644
|
||||
--- a/src/storage_driver.c
|
||||
+++ b/src/storage_driver.c
|
||||
@@ -1296,7 +1296,6 @@ storageVolumeDelete(virStorageVolPtr obj,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
- virStorageVolDefFree(vol);
|
||||
if (pool)
|
||||
virStoragePoolObjUnlock(pool);
|
||||
return ret;
|
||||
@@ -1,36 +0,0 @@
|
||||
From: Daniel P. Berrange <berrange@redhat.com>
|
||||
Date: Mon, 16 Mar 2009 11:44:46 +0000 (+0000)
|
||||
Subject: Avoid deadlock setting vcpus in QEMU driver
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=4d7ecd146ce4de847256ae0887963719f214f62f
|
||||
|
||||
Avoid deadlock setting vcpus in QEMU driver
|
||||
---
|
||||
|
||||
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
|
||||
index dad7098..51442d6 100644
|
||||
--- a/src/qemu_driver.c
|
||||
+++ b/src/qemu_driver.c
|
||||
@@ -2725,6 +2725,7 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
||||
virDomainObjPtr vm;
|
||||
int max;
|
||||
int ret = -1;
|
||||
+ const char *type;
|
||||
|
||||
qemuDriverLock(driver);
|
||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||
@@ -2745,7 +2746,14 @@ static int qemudDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- if ((max = qemudDomainGetMaxVcpus(dom)) < 0) {
|
||||
+ if (!(type = virDomainVirtTypeToString(vm->def->virtType))) {
|
||||
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR,
|
||||
+ _("unknown virt type in domain definition '%d'"),
|
||||
+ vm->def->virtType);
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ if ((max = qemudGetMaxVCPUs(dom->conn, type)) < 0) {
|
||||
qemudReportError(dom->conn, dom, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("could not determine max vcpus for the domain"));
|
||||
goto cleanup;
|
||||
@@ -1,277 +0,0 @@
|
||||
diff -r 961d4b1ca1d3 qemud/libvirtd_qemu.aug
|
||||
--- a/qemud/libvirtd_qemu.aug Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/qemud/libvirtd_qemu.aug Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -27,6 +27,8 @@ module Libvirtd_qemu =
|
||||
| str_entry "vnc_tls_x509_cert_dir"
|
||||
| bool_entry "vnc_tls_x509_verify"
|
||||
| str_entry "vnc_password"
|
||||
+ | bool_entry "vnc_sasl"
|
||||
+ | str_entry "vnc_sasl_dir"
|
||||
|
||||
(* Each enty in the config is one of the following three ... *)
|
||||
let entry = vnc_entry
|
||||
diff -r 961d4b1ca1d3 qemud/test_libvirtd_qemu.aug
|
||||
--- a/qemud/test_libvirtd_qemu.aug Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/qemud/test_libvirtd_qemu.aug Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -60,6 +60,25 @@ vnc_tls_x509_verify = 1
|
||||
# example here before you set this
|
||||
#
|
||||
vnc_password = \"XYZ12345\"
|
||||
+
|
||||
+
|
||||
+# Enable use of SASL encryption on the VNC server. This requires
|
||||
+# a VNC client which supports the SASL protocol extension.
|
||||
+# Examples include vinagre, virt-viewer and virt-manager
|
||||
+# itself. UltraVNC, RealVNC, TightVNC do not support this
|
||||
+#
|
||||
+# It is necessary to configure /etc/sasl2/qemu.conf to choose
|
||||
+# the desired SASL plugin (eg, GSSPI for Kerberos)
|
||||
+#
|
||||
+vnc_sasl = 1
|
||||
+
|
||||
+
|
||||
+# The default SASL configuration file is located in /etc/sasl2/
|
||||
+# When running libvirtd unprivileged, it may be desirable to
|
||||
+# override the configs in this location. Set this parameter to
|
||||
+# point to the directory, and create a qemu.conf in that location
|
||||
+#
|
||||
+vnc_sasl_dir = \"/some/directory/sasl2\"
|
||||
"
|
||||
|
||||
test Libvirtd_qemu.lns get conf =
|
||||
@@ -123,3 +142,22 @@ vnc_password = \"XYZ12345\"
|
||||
{ "#comment" = "example here before you set this" }
|
||||
{ "#comment" = "" }
|
||||
{ "vnc_password" = "XYZ12345" }
|
||||
+{ "#empty" }
|
||||
+{ "#empty" }
|
||||
+{ "#comment" = "Enable use of SASL encryption on the VNC server. This requires" }
|
||||
+{ "#comment" = "a VNC client which supports the SASL protocol extension." }
|
||||
+{ "#comment" = "Examples include vinagre, virt-viewer and virt-manager" }
|
||||
+{ "#comment" = "itself. UltraVNC, RealVNC, TightVNC do not support this" }
|
||||
+{ "#comment" = "" }
|
||||
+{ "#comment" = "It is necessary to configure /etc/sasl2/qemu.conf to choose" }
|
||||
+{ "#comment" = "the desired SASL plugin (eg, GSSPI for Kerberos)" }
|
||||
+{ "#comment" = "" }
|
||||
+{ "vnc_sasl" = "1" }
|
||||
+{ "#empty" }
|
||||
+{ "#empty" }
|
||||
+{ "#comment" = "The default SASL configuration file is located in /etc/sasl2/" }
|
||||
+{ "#comment" = "When running libvirtd unprivileged, it may be desirable to" }
|
||||
+{ "#comment" = "override the configs in this location. Set this parameter to" }
|
||||
+{ "#comment" = "point to the directory, and create a qemu.conf in that location" }
|
||||
+{ "#comment" = "" }
|
||||
+{ "vnc_sasl_dir" = "/some/directory/sasl2" }
|
||||
diff -r 961d4b1ca1d3 src/qemu.conf
|
||||
--- a/src/qemu.conf Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/src/qemu.conf Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -60,6 +60,27 @@
|
||||
# vnc_password = "XYZ12345"
|
||||
|
||||
|
||||
+# Enable use of SASL encryption on the VNC server. This requires
|
||||
+# a VNC client which supports the SASL protocol extension.
|
||||
+# Examples include vinagre, virt-viewer and virt-manager
|
||||
+# itself. UltraVNC, RealVNC, TightVNC do not support this
|
||||
+#
|
||||
+# It is necessary to configure /etc/sasl2/qemu.conf to choose
|
||||
+# the desired SASL plugin (eg, GSSPI for Kerberos)
|
||||
+#
|
||||
+# vnc_sasl = 1
|
||||
+
|
||||
+
|
||||
+# The default SASL configuration file is located in /etc/sasl2/
|
||||
+# When running libvirtd unprivileged, it may be desirable to
|
||||
+# override the configs in this location. Set this parameter to
|
||||
+# point to the directory, and create a qemu.conf in that location
|
||||
+#
|
||||
+# vnc_sasl_dir = "/some/directory/sasl2"
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
# The default security driver is SELinux. If SELinux is disabled
|
||||
# on the host, then the security driver will automatically disable
|
||||
# itself. If you wish to disable QEMU SELinux security driver while
|
||||
diff -r 961d4b1ca1d3 src/qemu_conf.c
|
||||
--- a/src/qemu_conf.c Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/src/qemu_conf.c Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -161,6 +161,21 @@ int qemudLoadDriverConfig(struct qemud_d
|
||||
}
|
||||
}
|
||||
|
||||
+ p = virConfGetValue (conf, "vnc_sasl");
|
||||
+ CHECK_TYPE ("vnc_sasl", VIR_CONF_LONG);
|
||||
+ if (p) driver->vncSASL = p->l;
|
||||
+
|
||||
+ p = virConfGetValue (conf, "vnc_sasl_dir");
|
||||
+ CHECK_TYPE ("vnc_sasl_dir", VIR_CONF_STRING);
|
||||
+ if (p && p->str) {
|
||||
+ VIR_FREE(driver->vncSASLdir);
|
||||
+ if (!(driver->vncSASLdir = strdup(p->str))) {
|
||||
+ virReportOOMError(NULL);
|
||||
+ virConfFree(conf);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
virConfFree (conf);
|
||||
return 0;
|
||||
}
|
||||
@@ -838,15 +853,20 @@ int qemudBuildCommandLine(virConnectPtr
|
||||
goto no_memory; \
|
||||
} while (0)
|
||||
|
||||
+#define ADD_ENV_PAIR(envname, val) \
|
||||
+ do { \
|
||||
+ char *envval; \
|
||||
+ ADD_ENV_SPACE; \
|
||||
+ if (virAsprintf(&envval, "%s=%s", envname, val) < 0) \
|
||||
+ goto no_memory; \
|
||||
+ qenv[qenvc++] = envval; \
|
||||
+ } while (0)
|
||||
+
|
||||
#define ADD_ENV_COPY(envname) \
|
||||
do { \
|
||||
char *val = getenv(envname); \
|
||||
- char *envval; \
|
||||
- ADD_ENV_SPACE; \
|
||||
if (val != NULL) { \
|
||||
- if (virAsprintf(&envval, "%s=%s", envname, val) < 0) \
|
||||
- goto no_memory; \
|
||||
- qenv[qenvc++] = envval; \
|
||||
+ ADD_ENV_PAIR(envname, val); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -1295,6 +1315,15 @@ int qemudBuildCommandLine(virConnectPtr
|
||||
driver->vncTLSx509certdir);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ if (driver->vncSASL) {
|
||||
+ virBufferAddLit(&opt, ",sasl");
|
||||
+
|
||||
+ if (driver->vncSASLdir)
|
||||
+ ADD_ENV_PAIR("SASL_CONF_DIR", driver->vncSASLdir);
|
||||
+
|
||||
+ /* TODO: Support ACLs later */
|
||||
+ }
|
||||
} else {
|
||||
virBufferVSprintf(&opt, "%d",
|
||||
vm->def->graphics->data.vnc.port - 5900);
|
||||
diff -r 961d4b1ca1d3 src/qemu_conf.h
|
||||
--- a/src/qemu_conf.h Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/src/qemu_conf.h Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -73,9 +73,11 @@ struct qemud_driver {
|
||||
char *stateDir;
|
||||
unsigned int vncTLS : 1;
|
||||
unsigned int vncTLSx509verify : 1;
|
||||
+ unsigned int vncSASL : 1;
|
||||
char *vncTLSx509certdir;
|
||||
char *vncListen;
|
||||
char *vncPassword;
|
||||
+ char *vncSASLdir;
|
||||
|
||||
virCapsPtr caps;
|
||||
|
||||
diff -r 961d4b1ca1d3 src/qemu_driver.c
|
||||
--- a/src/qemu_driver.c Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/src/qemu_driver.c Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -620,6 +620,7 @@ qemudShutdown(void) {
|
||||
VIR_FREE(qemu_driver->vncTLSx509certdir);
|
||||
VIR_FREE(qemu_driver->vncListen);
|
||||
VIR_FREE(qemu_driver->vncPassword);
|
||||
+ VIR_FREE(qemu_driver->vncSASLdir);
|
||||
|
||||
/* Free domain callback list */
|
||||
virDomainEventCallbackListFree(qemu_driver->domainEventCallbacks);
|
||||
diff -r 961d4b1ca1d3 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.args Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -0,0 +1,1 @@
|
||||
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test SASL_CONF_DIR=/root/.sasl2 /usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3,sasl
|
||||
diff -r 961d4b1ca1d3 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-sasl.xml Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -0,0 +1,24 @@
|
||||
+<domain type='qemu'>
|
||||
+ <name>QEMUGuest1</name>
|
||||
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
+ <memory>219200</memory>
|
||||
+ <currentMemory>219200</currentMemory>
|
||||
+ <vcpu>1</vcpu>
|
||||
+ <os>
|
||||
+ <type arch='i686' machine='pc'>hvm</type>
|
||||
+ <boot dev='hd'/>
|
||||
+ </os>
|
||||
+ <clock offset='utc'/>
|
||||
+ <on_poweroff>destroy</on_poweroff>
|
||||
+ <on_reboot>restart</on_reboot>
|
||||
+ <on_crash>destroy</on_crash>
|
||||
+ <devices>
|
||||
+ <emulator>/usr/bin/qemu</emulator>
|
||||
+ <disk type='block' device='disk'>
|
||||
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
+ <target dev='hda' bus='ide'/>
|
||||
+ </disk>
|
||||
+ <input type='mouse' bus='ps2'/>
|
||||
+ <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'/>
|
||||
+ </devices>
|
||||
+</domain>
|
||||
diff -r 961d4b1ca1d3 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.args Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -0,0 +1,1 @@
|
||||
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test SASL_CONF_DIR=/root/.sasl2 /usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor pty -pidfile /nowhere/QEMUGuest1.pid -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3,tls,x509verify=/etc/pki/tls/qemu,sasl
|
||||
diff -r 961d4b1ca1d3 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml
|
||||
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
||||
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-tls.xml Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -0,0 +1,24 @@
|
||||
+<domain type='qemu'>
|
||||
+ <name>QEMUGuest1</name>
|
||||
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
+ <memory>219200</memory>
|
||||
+ <currentMemory>219200</currentMemory>
|
||||
+ <vcpu>1</vcpu>
|
||||
+ <os>
|
||||
+ <type arch='i686' machine='pc'>hvm</type>
|
||||
+ <boot dev='hd'/>
|
||||
+ </os>
|
||||
+ <clock offset='utc'/>
|
||||
+ <on_poweroff>destroy</on_poweroff>
|
||||
+ <on_reboot>restart</on_reboot>
|
||||
+ <on_crash>destroy</on_crash>
|
||||
+ <devices>
|
||||
+ <emulator>/usr/bin/qemu</emulator>
|
||||
+ <disk type='block' device='disk'>
|
||||
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
||||
+ <target dev='hda' bus='ide'/>
|
||||
+ </disk>
|
||||
+ <input type='mouse' bus='ps2'/>
|
||||
+ <graphics type='vnc' port='5903' autoport='no' listen='127.0.0.1'/>
|
||||
+ </devices>
|
||||
+</domain>
|
||||
diff -r 961d4b1ca1d3 tests/qemuxml2argvtest.c
|
||||
--- a/tests/qemuxml2argvtest.c Wed Mar 04 13:17:44 2009 +0000
|
||||
+++ b/tests/qemuxml2argvtest.c Thu Mar 05 14:22:50 2009 +0000
|
||||
@@ -213,6 +213,19 @@ mymain(int argc, char **argv)
|
||||
QEMUD_CMD_FLAG_DRIVE_CACHE_V2);
|
||||
DO_TEST("disk-usb", 0);
|
||||
DO_TEST("graphics-vnc", 0);
|
||||
+
|
||||
+ driver.vncSASL = 1;
|
||||
+ driver.vncSASLdir = strdup("/root/.sasl2");
|
||||
+ DO_TEST("graphics-vnc-sasl", 0);
|
||||
+ driver.vncTLS = 1;
|
||||
+ driver.vncTLSx509verify = 1;
|
||||
+ driver.vncTLSx509certdir = strdup("/etc/pki/tls/qemu");
|
||||
+ DO_TEST("graphics-vnc-tls", 0);
|
||||
+ driver.vncSASL = driver.vncTLSx509verify = driver.vncTLS = 0;
|
||||
+ free(driver.vncSASLdir);
|
||||
+ free(driver.vncTLSx509certdir);
|
||||
+ driver.vncSASLdir = driver.vncTLSx509certdir = NULL;
|
||||
+
|
||||
DO_TEST("graphics-sdl", 0);
|
||||
DO_TEST("graphics-sdl-fullscreen", 0);
|
||||
DO_TEST("input-usbmouse", 0);
|
||||
@@ -1,29 +0,0 @@
|
||||
Index: src/xs_internal.c
|
||||
===================================================================
|
||||
RCS file: /data/cvs/libxen/src/xs_internal.c,v
|
||||
retrieving revision 1.88
|
||||
diff -u -u -r1.88 xs_internal.c
|
||||
--- src/xs_internal.c 5 Feb 2009 18:14:00 -0000 1.88
|
||||
+++ src/xs_internal.c 11 Mar 2009 13:23:17 -0000
|
||||
@@ -1215,7 +1215,7 @@
|
||||
static void
|
||||
xenStoreWatchEvent(int watch ATTRIBUTE_UNUSED,
|
||||
int fd ATTRIBUTE_UNUSED,
|
||||
- int events ATTRIBUTE_UNUSED,
|
||||
+ int events,
|
||||
void *data)
|
||||
{
|
||||
char **event;
|
||||
@@ -1226,8 +1226,12 @@
|
||||
|
||||
virConnectPtr conn = data;
|
||||
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
|
||||
+
|
||||
if(!priv) return;
|
||||
|
||||
+ /* only set a watch on read and write events */
|
||||
+ if (events & (VIR_EVENT_HANDLE_ERROR | VIR_EVENT_HANDLE_HANGUP)) return;
|
||||
+
|
||||
xenUnifiedLock(priv);
|
||||
|
||||
if(!priv->xshandle)
|
||||
@@ -1,26 +0,0 @@
|
||||
From: Daniel P. Berrange <berrange@redhat.com>
|
||||
Date: Tue, 10 Mar 2009 10:32:24 +0000 (+0000)
|
||||
Subject: Fix Xen block detach with newer Xend (Cole RobinSon / Tomohiro Takahashi)
|
||||
X-Git-Url: http://git.et.redhat.com/?p=libvirt.git;a=commitdiff_plain;h=33813a932d58c17441203d0e581eba91369a71e0
|
||||
|
||||
Fix Xen block detach with newer Xend (Cole RobinSon / Tomohiro Takahashi)
|
||||
---
|
||||
|
||||
diff --git a/src/xend_internal.c b/src/xend_internal.c
|
||||
index f9f2cb3..772f3f4 100644
|
||||
--- a/src/xend_internal.c
|
||||
+++ b/src/xend_internal.c
|
||||
@@ -5566,7 +5566,12 @@ virDomainXMLDevID(virDomainPtr domain,
|
||||
char *xref;
|
||||
|
||||
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
|
||||
- strcpy(class, "vbd");
|
||||
+ if (dev->data.disk->driverName &&
|
||||
+ STREQ(dev->data.disk->driverName, "tap"))
|
||||
+ strcpy(class, "tap");
|
||||
+ else
|
||||
+ strcpy(class, "vbd");
|
||||
+
|
||||
if (dev->data.disk->dst == NULL)
|
||||
return -1;
|
||||
xenUnifiedLock(priv);
|
||||
@@ -1,24 +0,0 @@
|
||||
Index: src/xend_internal.c
|
||||
===================================================================
|
||||
RCS file: /data/cvs/libxen/src/xend_internal.c,v
|
||||
retrieving revision 1.251
|
||||
diff -u -r1.251 xend_internal.c
|
||||
--- src/xend_internal.c 13 Feb 2009 18:23:23 -0000 1.251
|
||||
+++ src/xend_internal.c 10 Mar 2009 10:00:28 -0000
|
||||
@@ -904,7 +904,15 @@
|
||||
count++;
|
||||
}
|
||||
|
||||
- if (VIR_ALLOC_N(ptr, count + 1 + extra) < 0)
|
||||
+ /*
|
||||
+ * We can'tuse the normal allocation routines as we are mixing
|
||||
+ * an array of char * at the beginning followed by an array of char
|
||||
+ * ret points to the NULL terminated array of char *
|
||||
+ * ptr points to the current string after that array but in the same
|
||||
+ * allocated block
|
||||
+ */
|
||||
+ if (virAlloc((void *)&ptr,
|
||||
+ (count + 1) * sizeof(char *) + extra * sizeof(char)) < 0)
|
||||
goto error;
|
||||
|
||||
ret = (char **) ptr;
|
||||
@@ -0,0 +1,225 @@
|
||||
Return-Path: alexl@redhat.com
|
||||
Received: from zmta04.collab.prod.int.phx2.redhat.com (LHLO
|
||||
zmta04.collab.prod.int.phx2.redhat.com) (10.5.81.11) by
|
||||
zmail20.collab.prod.int.phx2.redhat.com with LMTP; Tue, 9 Oct 2012 11:26:38
|
||||
-0400 (EDT)
|
||||
Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
|
||||
by zmta04.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id D4096D0927
|
||||
for <alexl@mail.corp.redhat.com>; Tue, 9 Oct 2012 11:26:38 -0400 (EDT)
|
||||
Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1])
|
||||
by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q99FQV93016417;
|
||||
Tue, 9 Oct 2012 11:26:33 -0400
|
||||
From: Alexander Larsson <alexl@redhat.com>
|
||||
To: libvir-list@redhat.com
|
||||
Cc: Alexander Larsson <alexl@redhat.com>
|
||||
Subject: [PATCH 1/2] virdbus: Add virDBusGetSessionBus helper
|
||||
Date: Tue, 9 Oct 2012 17:26:28 +0200
|
||||
Message-Id: <1349796389-6122-2-git-send-email-alexl@redhat.com>
|
||||
In-Reply-To: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
References: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
|
||||
|
||||
This splits out some common code from virDBusGetSystemBus and
|
||||
uses it to implement a new virDBusGetSessionBus helper.
|
||||
---
|
||||
src/libvirt_private.syms | 1 +
|
||||
src/util/virdbus.c | 84 ++++++++++++++++++++++++++++++++++++------------
|
||||
src/util/virdbus.h | 1 +
|
||||
3 files changed, 66 insertions(+), 20 deletions(-)
|
||||
|
||||
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
||||
index a8c81e7..88f1b2f 100644
|
||||
--- a/src/libvirt_private.syms
|
||||
+++ b/src/libvirt_private.syms
|
||||
@@ -1310,6 +1310,7 @@ virConsoleOpen;
|
||||
|
||||
# virdbus.h
|
||||
virDBusGetSystemBus;
|
||||
+virDBusGetSessionBus;
|
||||
|
||||
|
||||
# virdomainlist.h
|
||||
diff --git a/src/util/virdbus.c b/src/util/virdbus.c
|
||||
index 4acce12..2dc7265 100644
|
||||
--- a/src/util/virdbus.c
|
||||
+++ b/src/util/virdbus.c
|
||||
@@ -32,40 +32,49 @@
|
||||
#ifdef HAVE_DBUS
|
||||
|
||||
static DBusConnection *systembus = NULL;
|
||||
-static virOnceControl once = VIR_ONCE_CONTROL_INITIALIZER;
|
||||
-static DBusError dbuserr;
|
||||
+static DBusConnection *sessionbus = NULL;
|
||||
+static virOnceControl systemonce = VIR_ONCE_CONTROL_INITIALIZER;
|
||||
+static virOnceControl sessiononce = VIR_ONCE_CONTROL_INITIALIZER;
|
||||
+static DBusError systemdbuserr;
|
||||
+static DBusError sessiondbuserr;
|
||||
|
||||
static dbus_bool_t virDBusAddWatch(DBusWatch *watch, void *data);
|
||||
static void virDBusRemoveWatch(DBusWatch *watch, void *data);
|
||||
static void virDBusToggleWatch(DBusWatch *watch, void *data);
|
||||
|
||||
-static void virDBusSystemBusInit(void)
|
||||
+static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr)
|
||||
{
|
||||
+ DBusConnection *bus;
|
||||
+
|
||||
/* Allocate and initialize a new HAL context */
|
||||
dbus_connection_set_change_sigpipe(FALSE);
|
||||
dbus_threads_init_default();
|
||||
|
||||
- dbus_error_init(&dbuserr);
|
||||
- if (!(systembus = dbus_bus_get(DBUS_BUS_SYSTEM, &dbuserr)))
|
||||
- return;
|
||||
+ dbus_error_init(dbuserr);
|
||||
+ if (!(bus = dbus_bus_get(type, dbuserr)))
|
||||
+ return NULL;
|
||||
|
||||
- dbus_connection_set_exit_on_disconnect(systembus, FALSE);
|
||||
+ dbus_connection_set_exit_on_disconnect(bus, FALSE);
|
||||
|
||||
/* Register dbus watch callbacks */
|
||||
- if (!dbus_connection_set_watch_functions(systembus,
|
||||
+ if (!dbus_connection_set_watch_functions(bus,
|
||||
virDBusAddWatch,
|
||||
virDBusRemoveWatch,
|
||||
virDBusToggleWatch,
|
||||
- NULL, NULL)) {
|
||||
- systembus = NULL;
|
||||
- return;
|
||||
+ bus, NULL)) {
|
||||
+ return NULL;
|
||||
}
|
||||
+ return bus;
|
||||
}
|
||||
|
||||
+static void virDBusSystemBusInit(void)
|
||||
+{
|
||||
+ systembus = virDBusBusInit (DBUS_BUS_SYSTEM, &systemdbuserr);
|
||||
+}
|
||||
|
||||
DBusConnection *virDBusGetSystemBus(void)
|
||||
{
|
||||
- if (virOnce(&once, virDBusSystemBusInit) < 0) {
|
||||
+ if (virOnce(&systemonce, virDBusSystemBusInit) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Unable to run one time DBus initializer"));
|
||||
return NULL;
|
||||
@@ -74,7 +83,7 @@ DBusConnection *virDBusGetSystemBus(void)
|
||||
if (!systembus) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to get DBus system bus connection: %s"),
|
||||
- dbuserr.message ? dbuserr.message : "watch setup failed");
|
||||
+ systemdbuserr.message ? systemdbuserr.message : "watch setup failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -82,13 +91,45 @@ DBusConnection *virDBusGetSystemBus(void)
|
||||
}
|
||||
|
||||
|
||||
+static void virDBusSessionBusInit(void)
|
||||
+{
|
||||
+ sessionbus = virDBusBusInit (DBUS_BUS_SESSION, &sessiondbuserr);
|
||||
+}
|
||||
+
|
||||
+DBusConnection *virDBusGetSessionBus(void)
|
||||
+{
|
||||
+ if (virOnce(&sessiononce, virDBusSessionBusInit) < 0) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
+ _("Unable to run one time DBus initializer"));
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if (!sessionbus) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
+ _("Unable to get DBus session bus connection: %s"),
|
||||
+ sessiondbuserr.message ? sessiondbuserr.message : "watch setup failed");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ return sessionbus;
|
||||
+}
|
||||
+
|
||||
+struct virDBusWatch
|
||||
+{
|
||||
+ int watch;
|
||||
+ DBusConnection *bus;
|
||||
+};
|
||||
+
|
||||
static void virDBusWatchCallback(int fdatch ATTRIBUTE_UNUSED,
|
||||
int fd ATTRIBUTE_UNUSED,
|
||||
int events, void *opaque)
|
||||
{
|
||||
DBusWatch *watch = opaque;
|
||||
+ struct virDBusWatch *info;
|
||||
int dbus_flags = 0;
|
||||
|
||||
+ info = dbus_watch_get_data(watch);
|
||||
+
|
||||
if (events & VIR_EVENT_HANDLE_READABLE)
|
||||
dbus_flags |= DBUS_WATCH_READABLE;
|
||||
if (events & VIR_EVENT_HANDLE_WRITABLE)
|
||||
@@ -100,7 +141,7 @@ static void virDBusWatchCallback(int fdatch ATTRIBUTE_UNUSED,
|
||||
|
||||
(void)dbus_watch_handle(watch, dbus_flags);
|
||||
|
||||
- while (dbus_connection_dispatch(systembus) == DBUS_DISPATCH_DATA_REMAINS)
|
||||
+ while (dbus_connection_dispatch(info->bus) == DBUS_DISPATCH_DATA_REMAINS)
|
||||
/* keep dispatching while data remains */;
|
||||
}
|
||||
|
||||
@@ -120,18 +161,13 @@ static int virDBusTranslateWatchFlags(int dbus_flags)
|
||||
}
|
||||
|
||||
|
||||
-struct virDBusWatch
|
||||
-{
|
||||
- int watch;
|
||||
-};
|
||||
-
|
||||
static void virDBusWatchFree(void *data) {
|
||||
struct virDBusWatch *info = data;
|
||||
VIR_FREE(info);
|
||||
}
|
||||
|
||||
static dbus_bool_t virDBusAddWatch(DBusWatch *watch,
|
||||
- void *data ATTRIBUTE_UNUSED)
|
||||
+ void *data)
|
||||
{
|
||||
int flags = 0;
|
||||
int fd;
|
||||
@@ -148,6 +184,7 @@ static dbus_bool_t virDBusAddWatch(DBusWatch *watch,
|
||||
# else
|
||||
fd = dbus_watch_get_fd(watch);
|
||||
# endif
|
||||
+ info->bus = (DBusConnection *)data;
|
||||
info->watch = virEventAddHandle(fd, flags,
|
||||
virDBusWatchCallback,
|
||||
watch, NULL);
|
||||
@@ -194,4 +231,11 @@ DBusConnection *virDBusGetSystemBus(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+DBusConnection *virDBusGetSessionBus(void)
|
||||
+{
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
+ "%s", _("DBus support not compiled into this binary"));
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
#endif /* ! HAVE_DBUS */
|
||||
diff --git a/src/util/virdbus.h b/src/util/virdbus.h
|
||||
index 27dca00..e443fbe 100644
|
||||
--- a/src/util/virdbus.h
|
||||
+++ b/src/util/virdbus.h
|
||||
@@ -30,5 +30,6 @@
|
||||
# include "internal.h"
|
||||
|
||||
DBusConnection *virDBusGetSystemBus(void);
|
||||
+DBusConnection *virDBusGetSessionBus(void);
|
||||
|
||||
#endif /* __VIR_DBUS_H__ */
|
||||
--
|
||||
1.7.12.1
|
||||
|
||||
@@ -0,0 +1,303 @@
|
||||
Return-Path: alexl@redhat.com
|
||||
Received: from zmta06.collab.prod.int.phx2.redhat.com (LHLO
|
||||
zmta06.collab.prod.int.phx2.redhat.com) (10.5.81.13) by
|
||||
zmail20.collab.prod.int.phx2.redhat.com with LMTP; Tue, 9 Oct 2012 11:26:39
|
||||
-0400 (EDT)
|
||||
Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
|
||||
by zmta06.collab.prod.int.phx2.redhat.com (Postfix) with ESMTP id D4A8516044F
|
||||
for <alexl@mail.corp.redhat.com>; Tue, 9 Oct 2012 11:26:39 -0400 (EDT)
|
||||
Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1])
|
||||
by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q99FQV94016417;
|
||||
Tue, 9 Oct 2012 11:26:34 -0400
|
||||
From: Alexander Larsson <alexl@redhat.com>
|
||||
To: libvir-list@redhat.com
|
||||
Cc: Alexander Larsson <alexl@redhat.com>
|
||||
Subject: [PATCH 2/2] Shut down session libvirtd cleanly
|
||||
Date: Tue, 9 Oct 2012 17:26:29 +0200
|
||||
Message-Id: <1349796389-6122-3-git-send-email-alexl@redhat.com>
|
||||
In-Reply-To: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
References: <1349796389-6122-1-git-send-email-alexl@redhat.com>
|
||||
X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
|
||||
|
||||
When the session dies or when the system is going to be shut down
|
||||
we save all active VMs and exit libvirtd.
|
||||
|
||||
Additionally whenever there is an active domain we hold a
|
||||
shutdown inhibitor to avoid shutting down before all the
|
||||
VMs are saved.
|
||||
---
|
||||
daemon/libvirtd.c | 244 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 244 insertions(+)
|
||||
|
||||
diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
|
||||
index b49acc5..c3bf2ce 100644
|
||||
--- a/daemon/libvirtd.c
|
||||
+++ b/daemon/libvirtd.c
|
||||
@@ -98,6 +98,11 @@
|
||||
|
||||
#include "configmake.h"
|
||||
|
||||
+#ifdef HAVE_DBUS
|
||||
+# include <dbus/dbus.h>
|
||||
+# include "virdbus.h"
|
||||
+#endif
|
||||
+
|
||||
#if HAVE_SASL
|
||||
virNetSASLContextPtr saslCtxt = NULL;
|
||||
#endif
|
||||
@@ -769,6 +774,212 @@ static int daemonSetupSignals(virNetServerPtr srv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_DBUS
|
||||
+
|
||||
+static DBusConnection *sessionBus;
|
||||
+static DBusConnection *systemBus;
|
||||
+static virConnectPtr sessionConnection;
|
||||
+static int numActiveDomains;
|
||||
+static bool hasInhibit;
|
||||
+static bool callingInhibit;
|
||||
+static int inhibitFd = -1;
|
||||
+
|
||||
+static void runSaveAllDomains(void *opaque)
|
||||
+{
|
||||
+ virNetServerPtr srv = opaque;
|
||||
+ int numDomains, i;
|
||||
+ int state;
|
||||
+ virDomainPtr *domains = NULL;
|
||||
+ unsigned int *flags = NULL;
|
||||
+
|
||||
+ numDomains = virConnectListAllDomains(sessionConnection, &domains, VIR_CONNECT_LIST_DOMAINS_ACTIVE);
|
||||
+ if (numDomains < 0)
|
||||
+ goto cleanup;
|
||||
+
|
||||
+ if (VIR_ALLOC_N(flags, numDomains) < 0) {
|
||||
+ virReportOOMError();
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ /* First we pause all VMs to make them stop dirtying
|
||||
+ pages, etc. We remember if any VMs were paused so
|
||||
+ we can restore that on resume. */
|
||||
+ for (i = 0 ; i < numDomains ; i++) {
|
||||
+ flags[i] = VIR_DOMAIN_SAVE_RUNNING;
|
||||
+ if (virDomainGetState (domains[i], &state, NULL, 0) == 0) {
|
||||
+ if (state == VIR_DOMAIN_PAUSED) {
|
||||
+ flags[i] = VIR_DOMAIN_SAVE_PAUSED;
|
||||
+ }
|
||||
+ }
|
||||
+ virDomainSuspend (domains[i]);
|
||||
+ }
|
||||
+
|
||||
+ /* Then we save the VMs to disk */
|
||||
+ for (i = 0 ; i < numDomains ; i++)
|
||||
+ virDomainManagedSave (domains[i], flags[i]);
|
||||
+
|
||||
+ VIR_FREE (domains);
|
||||
+ VIR_FREE (flags);
|
||||
+
|
||||
+ cleanup:
|
||||
+ if (domains != NULL) {
|
||||
+ for (i = 0 ; i < numDomains ; i++)
|
||||
+ virDomainFree (domains[i]);
|
||||
+ VIR_FREE (domains);
|
||||
+ }
|
||||
+ if (flags != NULL)
|
||||
+ VIR_FREE (flags);
|
||||
+
|
||||
+ /* We don't need any shutdown inhibit lock anymore now */
|
||||
+ if (inhibitFd != -1) {
|
||||
+ if (VIR_CLOSE (inhibitFd) < 0)
|
||||
+ virReportSystemError(errno, "%s", _("failed to close file"));
|
||||
+ inhibitFd = -1;
|
||||
+ }
|
||||
+
|
||||
+ /* Exit libvirtd cleanly */
|
||||
+ virNetServerQuit (srv);
|
||||
+}
|
||||
+
|
||||
+/* We do this in a thread to not block the main loop */
|
||||
+static void saveAllDomains(virNetServerPtr srv)
|
||||
+{
|
||||
+ virThread thr;
|
||||
+ virObjectRef(srv);
|
||||
+ if (virThreadCreate(&thr, false, runSaveAllDomains, srv) < 0) {
|
||||
+ virObjectUnref(srv);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void gotInhibitReply (DBusPendingCall *pending,
|
||||
+ void *opaque ATTRIBUTE_UNUSED)
|
||||
+{
|
||||
+ DBusMessage *reply;
|
||||
+ int fd;
|
||||
+
|
||||
+ callingInhibit = false;
|
||||
+
|
||||
+ reply = dbus_pending_call_steal_reply (pending);
|
||||
+ if (reply == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ if (dbus_message_get_args (reply, NULL,
|
||||
+ DBUS_TYPE_UNIX_FD, &fd,
|
||||
+ DBUS_TYPE_INVALID)) {
|
||||
+ if (hasInhibit)
|
||||
+ inhibitFd = fd;
|
||||
+ else {
|
||||
+ /* We stopped the last VM since we made the inhibit call */
|
||||
+ if (VIR_CLOSE (fd) < 0) {
|
||||
+ virReportSystemError(errno, "%s", _("failed to close file"));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ dbus_message_unref (reply);
|
||||
+}
|
||||
+
|
||||
+/* As per: http://www.freedesktop.org/wiki/Software/systemd/inhibit */
|
||||
+static void callInhibit(const char *what,
|
||||
+ const char *who,
|
||||
+ const char *why,
|
||||
+ const char *mode)
|
||||
+{
|
||||
+ DBusMessage *message;
|
||||
+ DBusPendingCall *pendingReply;
|
||||
+
|
||||
+ if (systemBus == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ /* Only one outstanding call at a time */
|
||||
+ if (callingInhibit)
|
||||
+ return;
|
||||
+
|
||||
+ message = dbus_message_new_method_call ("org.freedesktop.login1",
|
||||
+ "/org/freedesktop/login1",
|
||||
+ "org.freedesktop.login1.Manager",
|
||||
+ "Inhibit");
|
||||
+ if (message == NULL)
|
||||
+ return;
|
||||
+
|
||||
+ dbus_message_append_args (message,
|
||||
+ DBUS_TYPE_STRING, &what,
|
||||
+ DBUS_TYPE_STRING, &who,
|
||||
+ DBUS_TYPE_STRING, &why,
|
||||
+ DBUS_TYPE_STRING, &mode,
|
||||
+ DBUS_TYPE_INVALID);
|
||||
+
|
||||
+ pendingReply = NULL;
|
||||
+ if (dbus_connection_send_with_reply (systemBus, message,
|
||||
+ &pendingReply,
|
||||
+ 25*1000)) {
|
||||
+ dbus_pending_call_set_notify (pendingReply,
|
||||
+ gotInhibitReply,
|
||||
+ NULL, NULL);
|
||||
+ callingInhibit = true;
|
||||
+ }
|
||||
+ dbus_message_unref (message);
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void numActiveDomainsChanged(void)
|
||||
+{
|
||||
+ if (numActiveDomains > 0 && !hasInhibit) {
|
||||
+ callInhibit("shutdown", _("Libvirt"), _("Virtual machines need to be saved"), "delay");
|
||||
+ hasInhibit = true;
|
||||
+ } else if (numActiveDomains == 0 && hasInhibit) {
|
||||
+ if (inhibitFd != -1) {
|
||||
+ if (VIR_CLOSE (inhibitFd) < 0) {
|
||||
+ virReportSystemError(errno, "%s", _("failed to close file"));
|
||||
+ }
|
||||
+ inhibitFd = -1;
|
||||
+ }
|
||||
+ hasInhibit = false;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int lifecycleEventCallback(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
+ virDomainPtr dom ATTRIBUTE_UNUSED,
|
||||
+ int event,
|
||||
+ int detail ATTRIBUTE_UNUSED,
|
||||
+ void *opaque ATTRIBUTE_UNUSED)
|
||||
+{
|
||||
+ if (event == VIR_DOMAIN_EVENT_STOPPED)
|
||||
+ numActiveDomains--;
|
||||
+ else if (event == VIR_DOMAIN_EVENT_STARTED)
|
||||
+ numActiveDomains++;
|
||||
+
|
||||
+ numActiveDomainsChanged();
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static DBusHandlerResult handleSessionMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
|
||||
+ DBusMessage *message,
|
||||
+ void *userData)
|
||||
+{
|
||||
+ virNetServerPtr srv = userData;
|
||||
+
|
||||
+ if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
|
||||
+ saveAllDomains (srv);
|
||||
+ }
|
||||
+
|
||||
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static DBusHandlerResult handleSystemMessageFunc(DBusConnection *connection ATTRIBUTE_UNUSED,
|
||||
+ DBusMessage *message,
|
||||
+ void *userData)
|
||||
+{
|
||||
+ virNetServerPtr srv = userData;
|
||||
+
|
||||
+ if (dbus_message_is_signal(message, "org.freedesktop.login1.Manager", "PrepareForShutdown")) {
|
||||
+ saveAllDomains (srv);
|
||||
+ }
|
||||
+
|
||||
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
static void daemonRunStateInit(void *opaque)
|
||||
{
|
||||
virNetServerPtr srv = opaque;
|
||||
@@ -785,6 +996,39 @@ static void daemonRunStateInit(void *opaque)
|
||||
return;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_DBUS
|
||||
+ /* Tie the non-priviledged libvirtd to the session/shutdown lifecycle */
|
||||
+ if (!virNetServerIsPrivileged(srv)) {
|
||||
+
|
||||
+ sessionBus = virDBusGetSessionBus ();
|
||||
+ if (sessionBus != NULL) {
|
||||
+ dbus_connection_add_filter(sessionBus,
|
||||
+ handleSessionMessageFunc, srv, NULL);
|
||||
+ }
|
||||
+
|
||||
+ systemBus = virDBusGetSystemBus ();
|
||||
+ if (systemBus != NULL) {
|
||||
+ dbus_connection_add_filter(systemBus,
|
||||
+ handleSystemMessageFunc, srv, NULL);
|
||||
+ dbus_bus_add_match(systemBus,
|
||||
+ "type='signal',sender='org.freedesktop.login1', interface='org.freedesktop.login1.Manager'",
|
||||
+ NULL);
|
||||
+ }
|
||||
+
|
||||
+ sessionConnection = virConnectOpen("qemu:///session");
|
||||
+ if (sessionConnection != NULL) {
|
||||
+ numActiveDomains = virConnectNumOfDomains(sessionConnection);
|
||||
+ virConnectDomainEventRegisterAny(sessionConnection,
|
||||
+ NULL,
|
||||
+ VIR_DOMAIN_EVENT_ID_LIFECYCLE,
|
||||
+ VIR_DOMAIN_EVENT_CALLBACK (lifecycleEventCallback),
|
||||
+ NULL, NULL);
|
||||
+ numActiveDomainsChanged();
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
/* Only now accept clients from network */
|
||||
virNetServerUpdateServices(srv, true);
|
||||
virObjectUnref(srv);
|
||||
--
|
||||
1.7.12.1
|
||||
|
||||
+2278
-353
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user