[libvirt] [PATCH] interface: fix udev backend use after free
by Doug Goldstein
udevIfaceListAllInterface() used the udev_device after it had its ref
count decremented which results in a use after free issue.
---
src/interface/interface_backend_udev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 92c35d9..2c41bde 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -359,7 +359,6 @@ udevIfaceListAllInterfaces(virConnectPtr conn,
name = udev_device_get_sysname(dev);
macaddr = udev_device_get_sysattr_value(dev, "address");
status = STREQ(udev_device_get_sysattr_value(dev, "operstate"), "up");
- udev_device_unref(dev);
/* Filter the results */
if (status && (flags & VIR_CONNECT_LIST_INTERFACES_ACTIVE))
@@ -375,6 +374,7 @@ udevIfaceListAllInterfaces(virConnectPtr conn,
}
count++;
}
+ udev_device_unref(dev);
}
/* Drop our refcounts */
--
1.7.12.4
11 years, 9 months
[libvirt] [PATCH] Add autogenerated lxc_protocol.[ch] to gitignore
by Doug Goldstein
/src/lxc/lxc_protocol.[ch] is autogenerated so add it to .gitignore
---
.gitignore | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitignore b/.gitignore
index 23fdc91..16ac708 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
/COPYING
/ChangeLog
/GNUmakefile
+/HACKING
/INSTALL
/NEWS
/aclocal.m4
@@ -121,6 +122,7 @@
/src/lxc/lxc_monitor_dispatch.h
/src/lxc/lxc_monitor_protocol.c
/src/lxc/lxc_monitor_protocol.h
+/src/lxc/lxc_protocol.[ch]
/src/lxc/test_libvirtd_lxc.aug
/src/qemu/test_libvirtd_qemu.aug
/src/remote/*_client_bodies.h
--
1.7.12.4
11 years, 9 months
[libvirt] [PATCH 0/5] Clean up after recent Coverity scan
by John Ferlan
This is the last round of cleanup with a few Coverity errors from the
tests trees and a couple that just showed up in my recent scans within
security and virsh. The commandtest still has Valgrind errors, but errors
are not new to this change.
After this round of Coverity changes, the only remaining Coverity warnings
reported are within the gnulib tree. A few have been there all along within
vasnprintf.c, while others are new with the recent gnulib update (regexec.c,
regex_internal.c, and regcomp.c).
Once these are submitted I will have a baseline from which I can make
periodic comparisons. Since Coverity will sometimes "find" issues unrelated
to recent changes, using git bisect to point the fickle finger of fate at
a recent submission may not be possible.
John Ferlan (5):
drivermodule: Ignore coverity warning about leaked_storage
commandtest: Resolve some coverity resource leaks
vircommand: Remove unnecessary sa_assert
virsh: Resolve possible NULL dereference
security: Remove unnecessary checks for mgr == NULL
src/security/security_dac.c | 6 ------
src/security/security_selinux.c | 6 ------
src/util/vircommand.c | 3 ---
tests/commandtest.c | 17 ++++++++++++-----
tests/virdrivermoduletest.c | 2 ++
tools/virsh.c | 4 ++--
6 files changed, 16 insertions(+), 22 deletions(-)
--
1.7.11.7
11 years, 9 months
[libvirt] [PATCH 0/2] Restore DAC labels
by Michal Privoznik
If libvirt is doing labeling on a domain startup, the original
owner of files is not remembered. So later, when the domain is
shutting down and re-labelling is done, we have no other option,
just to fall back to 0:0. These patches are solving this issue
for DAC driver. I am sending them just to know if the path I wen
through is right so I don't bother with selinux if it is not.
Michal Privoznik (2):
conf: Add oldlabel field to virSecurityDeviceLabelDef
security driver: Remember the original DAC label
src/conf/domain_conf.c | 20 ++-
src/conf/domain_conf.h | 1 +
src/security/security_dac.c | 340 +++++++++++++++++++++++++++++++-------------
3 files changed, 260 insertions(+), 101 deletions(-)
--
1.8.0.2
11 years, 9 months
[libvirt] libvirt compilation error, libvirt.so: undefined reference to `xmlParseFile'
by nasb@ruedesrancy.org
Hi,
I'm currently trying to compile libvirt 1.0.2 on my custom
x86_64/uClibc environnement. Configuration goes well (./configure
--prefix=/usr --without-pyton), but during make I get the following
error message :
CCLD libvirtd
/lslbuild/svn/trunk/packages/virtualization/libvirt/libvirt-1.0.2/src/.libs/libvirt.so:
undefined reference to `xmlParseFile'
collect2: error: ld returned 1 exit status
Looks like a -lxml2 flag missing, but configure found the correct flags
according to the Makefile which contains :
LIBXML_CFLAGS = -I/usr/include/libxml2
LIBXML_LIBS = -lxml2
Does anyone have an idea on what's going wrong? What other informations
should I provide?
Thanks,
--
Eric LECAT
11 years, 9 months
[libvirt] Plan for the next release
by Daniel Veillard
February is short, but we are already at more then 180 commits
since 1.0.2 release, and well we ought to fix the python bindings
problems of 1.0.2 in an official release, so I think this makes
sense to push a new release at the end of the month.
I suggest to enter freeze in a week, targetting a 1.0.3 release
on the 28th or March 1st,
Daniel
--
Daniel Veillard | Open Source and Standards, Red Hat
veillard(a)redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | virtualization library http://libvirt.org/
11 years, 9 months
[libvirt] How to catch libvirtd logs
by harryxiyou
Hi all,
I start a VM with command "virsh create hlfs.xml", which fork a child
process. But i am not sure how to catch this child process's logs?
Could anyone give me some suggestions? Thanks in advance.
--
Thanks
Harry Wei
11 years, 9 months
[libvirt] [PATCH] Add support for <option> tag in network config
by Pieter Hollants
This patch adds support for a new <option>-Tag in the <dhcp> block of network configs,
based on a subset of the fifth proposal by Laine Stump in the mailing list discussion at
https://www.redhat.com/archives/libvir-list/2012-November/msg01054.html. Any such defined
option will result in a dhcp-option=<number>,"<value>" statement in the generated dnsmasq
configuration file.
Currently, DHCP options can be specified by number only and there is no whitelisting or
blacklisting of option numbers, which should probably be added.
Signed-off-by: Pieter Hollants <pieter(a)hollants.com>
---
AUTHORS.in | 1 +
docs/schemas/network.rng | 6 +++
docs/schemas/networkcommon.rng | 6 +++
src/conf/network_conf.c | 54 +++++++++++++++++++++
src/conf/network_conf.h | 10 ++++
src/network/bridge_driver.c | 10 ++++
tests/networkxml2xmlin/netboot-network.xml | 1 +
tests/networkxml2xmlin/netboot-proxy-network.xml | 1 +
tests/networkxml2xmlout/netboot-network.xml | 1 +
tests/networkxml2xmlout/netboot-proxy-network.xml | 1 +
10 Dateien geändert, 91 Zeilen hinzugefügt(+)
diff --git a/AUTHORS.in b/AUTHORS.in
index 39fe68d..074185e 100644
--- a/AUTHORS.in
+++ b/AUTHORS.in
@@ -74,6 +74,7 @@ Michel Ponceau <michel.ponceau(a)bull.net>
Nobuhiro Itou <fj0873gn(a)aa.jp.fujitsu.com>
Pete Vetere <pvetere(a)redhat.com>
Philippe Berthault <philippe.berthault(a)Bull.net>
+Pieter Hollants <pieter(a)hollants.com>
Saori Fukuta <fukuta.saori(a)jp.fujitsu.com>
Shigeki Sakamoto <fj0588di(a)aa.jp.fujitsu.com>
Shuveb Hussain <shuveb(a)binarykarma.com>
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index 09d7c73..a2ce1c9 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -293,6 +293,12 @@
</optional>
</element>
</optional>
+ <zeroOrMore>
+ <element name="option">
+ <attribute name="number"><ref name="unsignedByte"/></attribute>
+ <attribute name="value"><text/></attribute>
+ </element>
+ </zeroOrMore>
</element>
</optional>
</element>
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
index 51ff759..3510928 100644
--- a/docs/schemas/networkcommon.rng
+++ b/docs/schemas/networkcommon.rng
@@ -173,6 +173,12 @@
</data>
</define>
+ <define name='unsignedByte'>
+ <data type='integer'>
+ <param name="minInclusive">0</param>
+ <param name="maxInclusive">255</param>
+ </data>
+ </define>
<define name='unsignedShort'>
<data type='integer'>
<param name="minInclusive">0</param>
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 3604ff7..9d84c7e 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -777,6 +777,45 @@ cleanup:
}
static int
+virNetworkDHCPOptionDefParseXML(const char *networkName,
+ xmlNodePtr node,
+ virNetworkDHCPOptionDefPtr option)
+{
+ char *number = NULL;
+ int ret = -1;
+
+ if (!(number = virXMLPropString(node, "number"))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Option definition in IPv4 network '%s' "
+ "must have number attribute"),
+ networkName);
+ goto cleanup;
+ }
+ if (number &&
+ virStrToLong_ui(number, NULL, 10, &option->number) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Cannot parse <option> 'number' attribute"));
+ goto cleanup;
+ }
+ /* TODO: either whitelist numbers or blacklist numbers already occupied
+ * by other XML statements (eg. submask) */
+ if (!(option->value = virXMLPropString(node, "value"))) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Option definition in IPv4 network '%s' "
+ "must have value attribute"),
+ networkName);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(number);
+ return ret;
+}
+
+
+static int
virNetworkDHCPDefParseXML(const char *networkName,
xmlNodePtr node,
virNetworkIpDefPtr def)
@@ -837,6 +876,17 @@ virNetworkDHCPDefParseXML(const char *networkName,
def->bootfile = file;
def->bootserver = inaddr;
VIR_FREE(server);
+ } else if (cur->type == XML_ELEMENT_NODE &&
+ xmlStrEqual(cur->name, BAD_CAST "option")) {
+ if (VIR_REALLOC_N(def->options, def->noptions + 1) < 0) {
+ virReportOOMError();
+ return -1;
+ }
+ if (virNetworkDHCPOptionDefParseXML(networkName, cur,
+ &def->options[def->noptions])) {
+ return -1;
+ }
+ def->noptions++;
}
cur = cur->next;
@@ -2045,6 +2095,10 @@ virNetworkIpDefFormat(virBufferPtr buf,
virBufferAddLit(buf, "/>\n");
}
+ for (ii = 0 ; ii < def->noptions ; ii++) {
+ virBufferAsprintf(buf, "<option number='%u' value='%s' />\n",
+ def->options[ii].number, def->options[ii].value);
+ }
virBufferAdjustIndent(buf, -2);
virBufferAddLit(buf, "</dhcp>\n");
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 4c634ed..14f852a 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -77,6 +77,13 @@ struct _virNetworkDHCPHostDef {
virSocketAddr ip;
};
+typedef struct _virNetworkDHCPOptionDef virNetworkDHCPOptionDef;
+typedef virNetworkDHCPOptionDef *virNetworkDHCPOptionDefPtr;
+struct _virNetworkDHCPOptionDef {
+ unsigned int number;
+ char *value;
+};
+
typedef struct _virNetworkDNSTxtDef virNetworkDNSTxtDef;
typedef virNetworkDNSTxtDef *virNetworkDNSTxtDefPtr;
struct _virNetworkDNSTxtDef {
@@ -139,6 +146,9 @@ struct _virNetworkIpDef {
char *tftproot;
char *bootfile;
virSocketAddr bootserver;
+
+ size_t noptions; /* Zero or more additional dhcp options */
+ virNetworkDHCPOptionDefPtr options;
};
typedef struct _virNetworkForwardIfDef virNetworkForwardIfDef;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c834f83..c7c0a9e 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -926,6 +926,15 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
virBufferAsprintf(&configbuf, "dhcp-boot=%s\n", ipdef->bootfile);
}
}
+
+ /* Any additional DHCP options? */
+ if (ipdef->noptions > 0) {
+ for (r = 0 ; r < ipdef->noptions ; r++) {
+ virBufferAsprintf(&configbuf, "dhcp-option=%u,\"%s\"\n",
+ ipdef->options[r].number,
+ ipdef->options[r].value);
+ }
+ }
}
ipdef = (ipdef == ipv6def) ? NULL : ipv6def;
}
@@ -959,6 +968,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
virBufferAsprintf(&configbuf, "addn-hosts=%s\n",
dctx->addnhostsfile->path);
+
/* Are we doing RA instead of radvd? */
if (DNSMASQ_RA_SUPPORT(caps)) {
if (ipv6def)
diff --git a/tests/networkxml2xmlin/netboot-network.xml b/tests/networkxml2xmlin/netboot-network.xml
index ed75663..4de8976 100644
--- a/tests/networkxml2xmlin/netboot-network.xml
+++ b/tests/networkxml2xmlin/netboot-network.xml
@@ -9,6 +9,7 @@
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
<bootp file="pxeboot.img" />
+ <option number="252" value="\n" />
</dhcp>
</ip>
</network>
diff --git a/tests/networkxml2xmlin/netboot-proxy-network.xml b/tests/networkxml2xmlin/netboot-proxy-network.xml
index ecb6738..4c5c480 100644
--- a/tests/networkxml2xmlin/netboot-proxy-network.xml
+++ b/tests/networkxml2xmlin/netboot-proxy-network.xml
@@ -8,6 +8,7 @@
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
<bootp file="pxeboot.img" server="10.20.30.40" />
+ <option number="252" value="\n" />
</dhcp>
</ip>
</network>
diff --git a/tests/networkxml2xmlout/netboot-network.xml b/tests/networkxml2xmlout/netboot-network.xml
index b8a4d99..c3ea95a 100644
--- a/tests/networkxml2xmlout/netboot-network.xml
+++ b/tests/networkxml2xmlout/netboot-network.xml
@@ -9,6 +9,7 @@
<dhcp>
<range start='192.168.122.2' end='192.168.122.254' />
<bootp file='pxeboot.img' />
+ <option number='252' value='\n' />
</dhcp>
</ip>
</network>
diff --git a/tests/networkxml2xmlout/netboot-proxy-network.xml b/tests/networkxml2xmlout/netboot-proxy-network.xml
index e11c50b..f5f2c0d 100644
--- a/tests/networkxml2xmlout/netboot-proxy-network.xml
+++ b/tests/networkxml2xmlout/netboot-proxy-network.xml
@@ -8,6 +8,7 @@
<dhcp>
<range start='192.168.122.2' end='192.168.122.254' />
<bootp file='pxeboot.img' server='10.20.30.40' />
+ <option number='252' value='\n' />
</dhcp>
</ip>
</network>
--
1.7.10.4
11 years, 9 months
[libvirt] [PATCH] build: fix vircommand build on mingw
by Eric Blake
CC libvirt_util_la-vircommand.lo
../../src/util/vircommand.c:2358:1: error: 'virCommandHandshakeChild' defined but not used [-Werror=unused-function]
* src/util/vircommand.c (virCommandHandshakeChild): Hoist earlier,
so that win32 build doesn't hit an unused forward declaration.
---
Pushing under the build-breaker rule.
src/util/vircommand.c | 98 +++++++++++++++++++++++++--------------------------
1 file changed, 48 insertions(+), 50 deletions(-)
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 5837fee..ee1b510 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -118,8 +118,6 @@ struct _virCommand {
#endif
};
-static int virCommandHandshakeChild(virCommandPtr cmd);
-
/*
* virCommandFDIsSet:
* @fd: FD to test
@@ -332,6 +330,54 @@ prepareStdFd(int fd, int std)
return 0;
}
+/* virCommandHandshakeChild:
+ *
+ * child side of handshake - called by child process in virExec() to
+ * indicate to parent that the child process has successfully
+ * completed its pre-exec initialization.
+ */
+static int
+virCommandHandshakeChild(virCommandPtr cmd)
+{
+ char c = '1';
+ int rv;
+
+ if (!cmd->handshake)
+ return true;
+
+ VIR_DEBUG("Notifying parent for handshake start on %d",
+ cmd->handshakeWait[1]);
+ if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
+ virReportSystemError(errno, "%s",
+ _("Unable to notify parent process"));
+ return -1;
+ }
+
+ VIR_DEBUG("Waiting on parent for handshake complete on %d",
+ cmd->handshakeNotify[0]);
+ if ((rv = saferead(cmd->handshakeNotify[0], &c,
+ sizeof(c))) != sizeof(c)) {
+ if (rv < 0)
+ virReportSystemError(errno, "%s",
+ _("Unable to wait on parent process"));
+ else
+ virReportSystemError(EIO, "%s",
+ _("libvirtd quit during handshake"));
+ return -1;
+ }
+ if (c != '1') {
+ virReportSystemError(EINVAL,
+ _("Unexpected confirm code '%c' from parent"),
+ c);
+ return -1;
+ }
+ VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
+ VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
+
+ VIR_DEBUG("Handshake with parent is done");
+ return 0;
+}
+
/*
* virExec:
* @cmd virCommandPtr containing all information about the program to
@@ -2348,54 +2394,6 @@ void virCommandRequireHandshake(virCommandPtr cmd)
cmd->handshake = true;
}
-/* virCommandHandshakeChild:
- *
- * child side of handshake - called by child process in virExec() to
- * indicate to parent that the child process has successfully
- * completed its pre-exec initialization.
- */
-static int
-virCommandHandshakeChild(virCommandPtr cmd)
-{
- char c = '1';
- int rv;
-
- if (!cmd->handshake)
- return true;
-
- VIR_DEBUG("Notifying parent for handshake start on %d",
- cmd->handshakeWait[1]);
- if (safewrite(cmd->handshakeWait[1], &c, sizeof(c)) != sizeof(c)) {
- virReportSystemError(errno, "%s",
- _("Unable to notify parent process"));
- return -1;
- }
-
- VIR_DEBUG("Waiting on parent for handshake complete on %d",
- cmd->handshakeNotify[0]);
- if ((rv = saferead(cmd->handshakeNotify[0], &c,
- sizeof(c))) != sizeof(c)) {
- if (rv < 0)
- virReportSystemError(errno, "%s",
- _("Unable to wait on parent process"));
- else
- virReportSystemError(EIO, "%s",
- _("libvirtd quit during handshake"));
- return -1;
- }
- if (c != '1') {
- virReportSystemError(EINVAL,
- _("Unexpected confirm code '%c' from parent"),
- c);
- return -1;
- }
- VIR_FORCE_CLOSE(cmd->handshakeWait[1]);
- VIR_FORCE_CLOSE(cmd->handshakeNotify[0]);
-
- VIR_DEBUG("Handshake with parent is done");
- return 0;
-}
-
/**
* virCommandHandshakeWait:
* @cmd: command to wait on
--
1.8.1.2
11 years, 9 months
[libvirt] [PATCH] conf: Generate agent socket path if missing
by Michal Privoznik
It's not desired to force users imagine path for a socket they
are not even supposed to connect to. On the other hand, we
already have a release where the qemu agent socket path is
exposed to XML, so we cannot silently drop it from there.
The new path is generated in form:
$LOCALSTATEDIR/lib/libvirt/qemu/$domain.agent
---
This makes the qemu agent to be generated at domain startup phase.
So until that, we generate XML without any path, e.g.:
<channel type='unix'>
<source mode='connect'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='1'/>
</channel>
The other possibility is to generate path during XML parse phase, however this
expose something we are lacking for years - callbacks to fill in default values
for not configured ones. The aim so to make libvirt accept this snippet as
valid qemu agent config:
<channel type='unix'>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
src/conf/domain_conf.c | 37 ++++++++++++++++++++-----------------
src/qemu/qemu_process.c | 30 ++++++++++++++++++++++++++++--
2 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7a2b012..6245fec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6038,7 +6038,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDefPtr def,
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
- if (path == NULL) {
+ /* path is not required in special case of qemu guest agent */
+ if (path == NULL &&
+ chr_def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO &&
+ STRNEQ(chr_def->target.name, "org.qemu.guest_agent.0")) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing source path attribute for char device"));
goto error;
@@ -6135,7 +6138,6 @@ virDomainChrDefParseXML(virCapsPtr caps,
char *type = NULL;
const char *nodeName;
virDomainChrDefPtr def;
- int remaining;
bool seenTarget = false;
if (!(def = virDomainChrDefNew()))
@@ -6159,29 +6161,28 @@ virDomainChrDefParseXML(virCapsPtr caps,
}
cur = node->children;
- remaining = virDomainChrSourceDefParseXML(&def->source, cur, flags,
- def, ctxt,
- vmSeclabels, nvmSeclabels);
- if (remaining < 0)
- goto error;
- if (remaining) {
- while (cur != NULL) {
- if (cur->type == XML_ELEMENT_NODE) {
- if (xmlStrEqual(cur->name, BAD_CAST "target")) {
- seenTarget = true;
- if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) {
- goto error;
- }
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ if (xmlStrEqual(cur->name, BAD_CAST "target")) {
+ seenTarget = true;
+ if (virDomainChrDefParseTargetXML(caps, vmdef, def, cur) < 0) {
+ goto error;
}
+ break;
}
- cur = cur->next;
}
+ cur = cur->next;
}
if (!seenTarget &&
((def->targetType = virDomainChrDefaultTargetType(caps, vmdef, def->deviceType)) < 0))
goto cleanup;
+ if (virDomainChrSourceDefParseXML(&def->source, node->children,
+ flags, def, ctxt,
+ vmSeclabels, nvmSeclabels) < 0)
+ goto error;
+
if (def->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
if (def->targetType != VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -13307,10 +13308,12 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
+
virBufferAsprintf(buf, " <source mode='%s'",
def->data.nix.listen ? "bind" : "connect");
- virBufferEscapeString(buf, " path='%s'/>\n",
+ virBufferEscapeString(buf, " path='%s'",
def->data.nix.path);
+ virBufferAddLit(buf, "/>\n");
break;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4251c34..90f072d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2788,6 +2788,31 @@ qemuProcessPrepareMonitorChr(virQEMUDriverConfigPtr cfg,
return 0;
}
+static int
+qemuProcessPrepareAgentChr(virQEMUDriverConfigPtr cfg,
+ virDomainObjPtr vm)
+{
+ virDomainChrSourceDefPtr config = qemuFindAgentConfig(vm->def);
+ virDomainChrSourceDefPtr newConfing = qemuFindAgentConfig(vm->newDef);
+
+ if (!config)
+ return 0;
+
+ /* if user hasn't supplied any agent socket path, generate one,
+ * and store it in inactive config as well */
+ if ((config->type == VIR_DOMAIN_CHR_TYPE_UNIX) &&
+ !config->data.nix.path) {
+ if ((virAsprintf(&config->data.nix.path, "%s/%s.agent",
+ cfg->libDir, vm->def->name) < 0) ||
+ !(newConfing->data.nix.path = strdup(config->data.nix.path))) {
+ virReportOOMError();
+ return -1;
+ }
+ newConfing->data.nix.listen = config->data.nix.listen = true;
+ }
+
+ return 0;
+}
/*
* Precondition: vm must be locked, and a job must be active.
@@ -3772,8 +3797,9 @@ int qemuProcessStart(virConnectPtr conn,
goto cleanup;
}
- VIR_DEBUG("Preparing monitor state");
- if (qemuProcessPrepareMonitorChr(cfg, priv->monConfig, vm->def->name) < 0)
+ VIR_DEBUG("Preparing monitor and agent state");
+ if ((qemuProcessPrepareMonitorChr(cfg, priv->monConfig, vm->def->name) < 0) ||
+ (qemuProcessPrepareAgentChr(cfg, vm) < 0))
goto cleanup;
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MONITOR_JSON))
--
1.8.0.2
11 years, 9 months