[libvirt] [PATCH]virsh: fix a typo in virsh-domain
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
s/it's/its
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
tools/virsh-domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6d241db..9017cac 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -3036,7 +3036,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
&ctxt)))
goto error;
- /* tokenize the string from user and save it's parts into an array */
+ /* tokenize the string from user and save its parts into an array */
if (vol_string &&
(nvol_list = vshStringToArray(vol_string, &vol_list)) < 0)
goto error;
--
1.8.2.1
11 years, 2 months
[libvirt] [PATCH] build: use the gnulib version of the .m4 files when present
by Giuseppe Scrivano
prevent aclocal to prefer .m4 files under m4/ to the version provided
by gnulib.
I have noticed this after './configure --help' gave me two different
versions of "--enable-threads". This was caused by aclocal that
preferred the version of lock.m4 provided by autopoint instead of
using the newer version distributed with gnulib.
Signed-off-by: Giuseppe Scrivano <gscrivan(a)redhat.com>
---
bootstrap.conf | 5 -----
1 file changed, 5 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 68c4a89..e7353e2 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -191,11 +191,6 @@ gnulib_tool_option_extras="\
"
local_gl_dir=gnulib/local
-# Convince bootstrap to use multiple m4 directories.
-: ${ACLOCAL=aclocal}
-ACLOCAL="$ACLOCAL -I m4"
-export ACLOCAL
-
# Build prerequisites
# Note that some of these programs are only required for 'make dist' to
# succeed from a fresh git checkout; not all of these programs are
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] storage: document existing pools
by Eric Blake
We forgot to document several pool types. Furthermore, the
RNG grammar did not allow arbitrary interleaving, which makes
it harder than necessary to create a new pool from XML.
* docs/formatstorage.html.in: Add docs for scsi, mpath, rbd, and
sheepdog.
* docs/schemas/storagepool.rng: Allow interleaving.
* tests/storagepoolxml2xmlin/pool-sheepdog.xml: Test interleave.
* tests/storagepoolxml2xmlin/pool-iscsi-auth.xml: Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
docs/formatstorage.html.in | 44 +--
docs/schemas/storagepool.rng | 356 ++++++++++++++-----------
tests/storagepoolxml2xmlin/pool-iscsi-auth.xml | 12 +-
tests/storagepoolxml2xmlin/pool-sheepdog.xml | 6 +-
4 files changed, 238 insertions(+), 180 deletions(-)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 3300d67..6f79b0c 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -18,9 +18,12 @@
The top level tag for a storage pool document is 'pool'. It has
a single attribute <code>type</code>, which is one of <code>dir</code>,
<code>fs</code>, <code>netfs</code>, <code>disk</code>,
- <code>iscsi</code>, <code>logical</code>. This corresponds to the
+ <code>iscsi</code>, <code>logical</code>, <code>scsi</code>
+ (all <span class="since">since 0.4.1</span>), <code>mpath</code>
+ (<span class="since">since 0.7.1</span>), <code>rbd</code>
+ (<span class="since">since 0.9.13</span>), or <code>sheepdog</code>
+ (<span class="since">since 0.10.0</span>). This corresponds to the
storage backend drivers listed further along in this document.
- The storage pool XML format is available <span class="since">since 0.4.1</span>
</p>
<h3><a name="StoragePoolFirst">General metadata</a></h3>
@@ -64,7 +67,8 @@
<p>
A single <code>source</code> element is contained within the top level
<code>pool</code> element. This tag is used to describe the source of
- the storage pool. It can contain the following child elements:
+ the storage pool. The set of child elements that it will contain
+ depend on the pool type, but come from the following child elements:
</p>
<pre>
@@ -89,17 +93,18 @@
<dl>
<dt><code>device</code></dt>
- <dd>Provides the source for pools backed by physical devices.
+ <dd>Provides the source for pools backed by physical devices
+ (fs, logical, disk, iscsi).
May be repeated multiple times depending on backend driver. Contains
a single attribute <code>path</code> which is the fully qualified
path to the block device node. <span class="since">Since 0.4.1</span></dd>
- <dt><code>directory</code></dt>
- <dd>Provides the source for pools backed by directories. May
+ <dt><code>dir</code></dt>
+ <dd>Provides the source for pools backed by directories (dir). May
only occur once. Contains a single attribute <code>path</code>
which is the fully qualified path to the backing directory.
<span class="since">Since 0.4.1</span></dd>
<dt><code>adapter</code></dt>
- <dd>Provides the source for pools backed by SCSI adapters. May
+ <dd>Provides the source for pools backed by SCSI adapters (scsi). May
only occur once. Attribute <code>name</code> is the SCSI adapter
name (ex. "scsi_host1". NB, although a name such as "host1" is
still supported for backwards compatibility, it is not recommended).
@@ -120,7 +125,8 @@
<span class="since">Since 0.6.2</span></dd>
<dt><code>host</code></dt>
<dd>Provides the source for pools backed by storage from a
- remote server. Will be used in combination with a <code>directory</code>
+ remote server (netfs, iscsi, rbd, sheepdog). Will be
+ used in combination with a <code>directory</code>
or <code>device</code> element. Contains an attribute <code>name</code>
which is the hostname or IP address of the server. May optionally
contain a <code>port</code> attribute for the protocol specific
@@ -128,18 +134,19 @@
<dt><code>auth</code></dt>
<dd>If present, the <code>auth</code> element provides the
authentication credentials needed to access the source by the
- setting of the <code>type</code> attribute. The <code>type</code>
- must be either "chap" or "ceph". Additionally a mandatory attribute
+ setting of the <code>type</code> attribute (iscsi,
+ rbd). The <code>type</code>
+ must be either "chap" or "ceph". Use "ceph" for
+ Ceph RBD (Rados Block Device) network sources and use "iscsi" for CHAP
+ (Challenge-Handshake Authentication Protocol) iSCSI
+ targets. Additionally a mandatory attribute
<code>username</code> identifies the username to use during
authentication as well as a sub-element <code>secret</code> with
a mandatory attribute <code>type</code>, to tie back to a
<a href="formatsecret.html">libvirt secret object</a> that
holds the actual password or other credentials. The domain XML
intentionally does not expose the password, only the reference
- to the object that manages the password. The secret element
- <code>type</code> must be either "ceph" or "iscsi". Use "ceph" for
- Ceph RBD (Rados Block Device) network sources and use "iscsi" for CHAP
- (Challenge-Handshake Authentication Protocol) iSCSI targets.
+ to the object that manages the password.
The <code>secret</code> element requires either a <code>uuid</code>
attribute with the UUID of the secret object or a <code>usage</code>
attribute matching the key that was specified in the
@@ -148,11 +155,12 @@
</dd>
<dt><code>name</code></dt>
<dd>Provides the source for pools backed by storage from a
- named element (e.g., a logical volume group name).
+ named element (logical, rbd, sheepdog).
Contains a string identifier.
<span class="since">Since 0.4.5</span></dd>
<dt><code>format</code></dt>
- <dd>Provides information about the format of the pool. This
+ <dd>Provides information about the format of the pool (fs,
+ netfs, disk, logical). This
contains a single attribute <code>type</code> whose value is
backend specific. This is typically used to indicate filesystem
type, or network filesystem type, or partition table type, or
@@ -174,7 +182,9 @@
<p>
A single <code>target</code> element is contained within the top level
- <code>pool</code> element. This tag is used to describe the mapping of
+ <code>pool</code> element for some types of pools (dir, fs,
+ netfs, logical, disk, iscsi, scsi, mpath). This tag is used to
+ describe the mapping of
the storage pool into the host filesystem. It can contain the following
child elements:
</p>
diff --git a/docs/schemas/storagepool.rng b/docs/schemas/storagepool.rng
index a4ef5af..66d3c22 100644
--- a/docs/schemas/storagepool.rng
+++ b/docs/schemas/storagepool.rng
@@ -29,192 +29,224 @@
<attribute name='type'>
<value>dir</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcedir'/>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcedir'/>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='poolfs'>
<attribute name='type'>
<value>fs</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcefs'/>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcefs'/>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='poolnetfs'>
<attribute name='type'>
<value>netfs</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcenetfs'/>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcenetfs'/>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='poollogical'>
<attribute name='type'>
<value>logical</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcelogical'/>
- <ref name='targetlogical'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcelogical'/>
+ <ref name='targetlogical'/>
+ </interleave>
</define>
<define name='pooldisk'>
<attribute name='type'>
<value>disk</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcedisk'/>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcedisk'/>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='pooliscsi'>
<attribute name='type'>
<value>iscsi</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourceiscsi'/>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourceiscsi'/>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='poolscsi'>
<attribute name='type'>
<value>scsi</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcescsi'/>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcescsi'/>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='poolmpath'>
<attribute name='type'>
<value>mpath</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <optional>
- <ref name='sourcempath'/>
- </optional>
- <ref name='target'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <optional>
+ <ref name='sourcempath'/>
+ </optional>
+ <ref name='target'/>
+ </interleave>
</define>
<define name='poolrbd'>
<attribute name='type'>
<value>rbd</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcerbd'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcerbd'/>
+ </interleave>
</define>
<define name='poolsheepdog'>
<attribute name='type'>
<value>sheepdog</value>
</attribute>
- <ref name='commonmetadata'/>
- <ref name='sizing'/>
- <ref name='sourcesheepdog'/>
+ <interleave>
+ <ref name='commonmetadata'/>
+ <ref name='sizing'/>
+ <ref name='sourcesheepdog'/>
+ </interleave>
</define>
<define name='sourceinfovendor'>
- <optional>
- <element name='vendor'>
- <attribute name='name'>
- <text/>
- </attribute>
- </element>
- </optional>
- <optional>
- <element name='product'>
- <attribute name='name'>
- <text/>
- </attribute>
- </element>
- </optional>
+ <interleave>
+ <optional>
+ <element name='vendor'>
+ <attribute name='name'>
+ <text/>
+ </attribute>
+ </element>
+ </optional>
+ <optional>
+ <element name='product'>
+ <attribute name='name'>
+ <text/>
+ </attribute>
+ </element>
+ </optional>
+ </interleave>
</define>
<define name='commonmetadata'>
- <element name='name'>
- <ref name='genericName'/>
- </element>
- <optional>
- <element name='uuid'>
- <ref name='UUID'/>
+ <interleave>
+ <element name='name'>
+ <ref name='genericName'/>
</element>
- </optional>
+ <optional>
+ <element name='uuid'>
+ <ref name='UUID'/>
+ </element>
+ </optional>
+ </interleave>
</define>
<define name='sizing'>
- <optional>
- <element name='capacity'>
- <ref name='scaledInteger'/>
- </element>
- </optional>
- <optional>
- <element name='allocation'>
- <ref name='scaledInteger'/>
- </element>
- </optional>
- <optional>
- <element name='available'>
- <ref name='scaledInteger'/>
- </element>
- </optional>
+ <interleave>
+ <optional>
+ <element name='capacity'>
+ <ref name='scaledInteger'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='allocation'>
+ <ref name='scaledInteger'/>
+ </element>
+ </optional>
+ <optional>
+ <element name='available'>
+ <ref name='scaledInteger'/>
+ </element>
+ </optional>
+ </interleave>
</define>
<define name='permissions'>
<optional>
<element name='permissions'>
- <element name='mode'>
- <ref name='octalMode'/>
- </element>
- <element name='owner'>
- <choice>
- <ref name='unsignedInt'/>
- <value>-1</value>
- </choice>
- </element>
- <element name='group'>
- <choice>
- <ref name='unsignedInt'/>
- <value>-1</value>
- </choice>
- </element>
- <optional>
- <element name='label'>
- <text/>
- </element>
- </optional>
+ <interleave>
+ <element name='mode'>
+ <ref name='octalMode'/>
+ </element>
+ <element name='owner'>
+ <choice>
+ <ref name='unsignedInt'/>
+ <value>-1</value>
+ </choice>
+ </element>
+ <element name='group'>
+ <choice>
+ <ref name='unsignedInt'/>
+ <value>-1</value>
+ </choice>
+ </element>
+ <optional>
+ <element name='label'>
+ <text/>
+ </element>
+ </optional>
+ </interleave>
</element>
</optional>
</define>
<define name='target'>
<element name='target'>
- <element name='path'>
- <ref name='absFilePath'/>
- </element>
- <ref name='permissions'/>
+ <interleave>
+ <element name='path'>
+ <ref name='absFilePath'/>
+ </element>
+ <ref name='permissions'/>
+ </interleave>
</element>
</define>
<define name='targetlogical'>
<element name='target'>
- <optional>
- <element name='path'>
- <ref name='absFilePath'/>
- </element>
- </optional>
- <ref name='permissions'/>
+ <interleave>
+ <optional>
+ <element name='path'>
+ <ref name='absFilePath'/>
+ </element>
+ </optional>
+ <ref name='permissions'/>
+ </interleave>
</element>
</define>
@@ -413,74 +445,86 @@
<define name='sourcefs'>
<element name='source'>
- <ref name='sourceinfodev'/>
- <ref name='sourcefmtfs'/>
- <optional>
- <ref name='sourceinfovendor'/>
- </optional>
+ <interleave>
+ <ref name='sourceinfodev'/>
+ <ref name='sourcefmtfs'/>
+ <optional>
+ <ref name='sourceinfovendor'/>
+ </optional>
+ </interleave>
</element>
</define>
<define name='sourcenetfs'>
<element name='source'>
- <ref name='sourceinfohost'/>
- <ref name='sourceinfodir'/>
- <ref name='sourcefmtnetfs'/>
- <optional>
- <ref name='sourceinfovendor'/>
- </optional>
+ <interleave>
+ <ref name='sourceinfohost'/>
+ <ref name='sourceinfodir'/>
+ <ref name='sourcefmtnetfs'/>
+ <optional>
+ <ref name='sourceinfovendor'/>
+ </optional>
+ </interleave>
</element>
</define>
<define name='sourcelogical'>
<element name='source'>
- <oneOrMore>
+ <interleave>
+ <oneOrMore>
+ <optional>
+ <ref name='sourceinfoname'/>
+ </optional>
+ <optional>
+ <ref name='sourceinfodev'/>
+ </optional>
+ </oneOrMore>
+ <ref name='sourcefmtlogical'/>
<optional>
- <ref name='sourceinfoname'/>
- </optional>
- <optional>
- <ref name='sourceinfodev'/>
+ <ref name='sourceinfovendor'/>
</optional>
- </oneOrMore>
- <ref name='sourcefmtlogical'/>
- <optional>
- <ref name='sourceinfovendor'/>
- </optional>
+ </interleave>
</element>
</define>
<define name='sourcedisk'>
<element name='source'>
- <ref name='sourceinfodev'/>
- <ref name='sourcefmtdisk'/>
- <optional>
- <ref name='sourceinfovendor'/>
- </optional>
+ <interleave>
+ <ref name='sourceinfodev'/>
+ <ref name='sourcefmtdisk'/>
+ <optional>
+ <ref name='sourceinfovendor'/>
+ </optional>
+ </interleave>
</element>
</define>
<define name='sourceiscsi'>
<element name='source'>
- <ref name='sourceinfohost'/>
- <ref name='sourceinfodev'/>
- <optional>
- <ref name='initiatorinfo'/>
- </optional>
- <optional>
- <ref name='sourceinfoauth'/>
- </optional>
- <optional>
- <ref name='sourceinfovendor'/>
- </optional>
+ <interleave>
+ <ref name='sourceinfohost'/>
+ <ref name='sourceinfodev'/>
+ <optional>
+ <ref name='initiatorinfo'/>
+ </optional>
+ <optional>
+ <ref name='sourceinfoauth'/>
+ </optional>
+ <optional>
+ <ref name='sourceinfovendor'/>
+ </optional>
+ </interleave>
</element>
</define>
<define name='sourcescsi'>
<element name='source'>
- <ref name='sourceinfoadapter'/>
- <optional>
- <ref name='sourceinfovendor'/>
- </optional>
+ <interleave>
+ <ref name='sourceinfoadapter'/>
+ <optional>
+ <ref name='sourceinfovendor'/>
+ </optional>
+ </interleave>
</element>
</define>
@@ -492,18 +536,22 @@
<define name='sourcerbd'>
<element name='source'>
- <ref name='sourceinfoname'/>
- <ref name='sourceinfohost'/>
- <optional>
- <ref name='sourceinfoauth'/>
- </optional>
+ <interleave>
+ <ref name='sourceinfoname'/>
+ <ref name='sourceinfohost'/>
+ <optional>
+ <ref name='sourceinfoauth'/>
+ </optional>
+ </interleave>
</element>
</define>
<define name='sourcesheepdog'>
<element name='source'>
- <ref name='sourceinfohost'/>
- <ref name='sourceinfoname'/>
+ <interleave>
+ <ref name='sourceinfohost'/>
+ <ref name='sourceinfoname'/>
+ </interleave>
</element>
</define>
diff --git a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
index c81eb60..5e5d336 100644
--- a/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
+++ b/tests/storagepoolxml2xmlin/pool-iscsi-auth.xml
@@ -1,19 +1,19 @@
<pool type='iscsi'>
- <name>virtimages</name>
- <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
<source>
- <host name="iscsi.example.com"/>
- <device path="demo-target"/>
<auth type='chap' username='admin'>
<secret uuid='2ec115d7-3a88-3ceb-bc12-0ac909a6fd87'/>
</auth>
+ <device path="demo-target"/>
+ <host name="iscsi.example.com"/>
</source>
+ <uuid>e9392370-2917-565e-692b-d057f46512d6</uuid>
<target>
- <path>/dev/disk/by-path</path>
<permissions>
- <mode>0700</mode>
<owner>0</owner>
+ <mode>0700</mode>
<group>0</group>
</permissions>
+ <path>/dev/disk/by-path</path>
</target>
+ <name>virtimages</name>
</pool>
diff --git a/tests/storagepoolxml2xmlin/pool-sheepdog.xml b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
index 1287047..49b6baf 100644
--- a/tests/storagepoolxml2xmlin/pool-sheepdog.xml
+++ b/tests/storagepoolxml2xmlin/pool-sheepdog.xml
@@ -1,8 +1,8 @@
<pool type='sheepdog'>
- <name>sheepdog</name>
- <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
<source>
- <host name='localhost' port='7000'/>
<name>sheepdog</name>
+ <host name='localhost' port='7000'/>
</source>
+ <uuid>65fcba04-5b13-bd93-cff3-52ce48e11ad7</uuid>
+ <name>sheepdog</name>
</pool>
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH] remote-driver: Fix 'leav' typo in comment
by Christophe Fergeau
---
Pushed under the trivial rule.
src/remote/remote_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 96ccb99..87ef5a9 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3721,7 +3721,7 @@ static int remoteAuthCredSASL2Vir(int vircred)
*
* Build up the SASL callback structure. We register one callback for
* each credential type that the libvirt client indicated they support.
- * We explicitly leav the callback function pointer at NULL though,
+ * We explicitly leave the callback function pointer at NULL though,
* because we don't actually want to get SASL callbacks triggered.
* Instead, we want the start/step functions to return SASL_INTERACT.
* This lets us give the libvirt client a list of all required
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH v2] rpc: Correct the wrong payload size checking
by Osier Yang
<...>
/* Size of message length field. Not counted in VIR_NET_MESSAGE_MAX
* and VIR_NET_MESSAGE_INITIAL.
*/
const VIR_NET_MESSAGE_LEN_MAX = 4;
</...>
However, msg->bufferLength includes the length word. The wrong checking
was introduced by commit e914dcfd.
* src/rpc/virnetmessage.c:
- Correct the checking in virNetMessageEncodePayloadRaw
- Use a new variable to track the new payload length in
virNetMessageEncodePayloadRaw
---
src/rpc/virnetmessage.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index 8f4e4bc..d60366b 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -346,15 +346,16 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
/* Try to encode the payload. If the buffer is too small increase it. */
while (!(*filter)(&xdr, data)) {
- if ((msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4 > VIR_NET_MESSAGE_MAX) {
+ unsigned int newlen = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4;
+
+ if (newlen > VIR_NET_MESSAGE_MAX) {
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
goto error;
}
xdr_destroy(&xdr);
- msg->bufferLength = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4 +
- VIR_NET_MESSAGE_LEN_MAX;
+ msg->bufferLength = newlen + VIR_NET_MESSAGE_LEN_MAX;
if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
goto error;
@@ -426,10 +427,15 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
/* If the message buffer is too small for the payload increase it accordingly. */
if ((msg->bufferLength - msg->bufferOffset) < len) {
- if ((msg->bufferOffset + len) > VIR_NET_MESSAGE_MAX) {
+ if ((msg->bufferOffset + len) >
+ (VIR_NET_MESSAGE_MAX + VIR_NET_MESSAGE_LEN_MAX)) {
virReportError(VIR_ERR_RPC,
- _("Stream data too long to send (%zu bytes needed, %zu bytes available)"),
- len, (VIR_NET_MESSAGE_MAX - msg->bufferOffset));
+ _("Stream data too long to send "
+ "(%zu bytes needed, %zu bytes available)"),
+ len,
+ VIR_NET_MESSAGE_MAX +
+ VIR_NET_MESSAGE_LEN_MAX -
+ msg->bufferOffset);
return -1;
}
--
1.8.1.4
11 years, 2 months
[libvirt] [PATCH] qemu: Fix the wrong logic of building cmd line for volume type disk
by Osier Yang
It builds a "libiscsi" uri if the volume type is "file" and
"disk->auth.username" is specified, but I even see no reason to
build the "libiscsi" uri for a "file" type volume, and the logic
to check whether "disk->auth.username" is specified is also beyond
understanding.
It produces unexpected result like below:
Disk config (pool is of 'fs' type):
<disk type='volume' device='disk'>
<driver name='qemu' type='raw'/>
<auth username='myuser'>
</auth>
<source pool='default' volume='f18.img'/>
<target dev='sda' bus='scsi'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
% virsh start f18
error: Failed to start domain f18
error: internal error: iscsi accepts only one host
---
src/qemu/qemu_command.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index abb62e9..9b6a27d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3806,13 +3806,7 @@ qemuBuildVolumeString(virConnectPtr conn,
}
break;
case VIR_STORAGE_VOL_FILE:
- if (disk->auth.username) {
- if (qemuBuildISCSIString(conn, disk, opt) < 0)
- goto cleanup;
- virBufferAddChar(opt, ',');
- } else {
- virBufferEscape(opt, ',', ",", "file=%s,", disk->src);
- }
+ virBufferEscape(opt, ',', ",", "file=%s,", disk->src);
break;
case VIR_STORAGE_VOL_NETWORK:
/* Keep the compiler quite, qemuTranslateDiskSourcePool already
--
1.8.1.4
11 years, 2 months
[libvirt] [PATCH v2] Introduce new OOM testing support
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
The previous OOM testing support would re-run the entire "main"
method each iteration, failing a different malloc each time.
When a test suite has 'n' allocations, the number of repeats
requires is (n * (n + 1) ) / 2. This gets very large, very
quickly.
This new OOM testing support instead integrates at the
virtTestRun level, so each individual test case gets repeated,
instead of the entire test suite. This means the values of
'n' are orders of magnitude smaller.
The simple usage is
$ VIR_TEST_OOM=1 ./qemuxml2argvtest
...
29) QEMU XML-2-ARGV clock-utc ... OK
Test OOM for nalloc=36 .................................... OK
30) QEMU XML-2-ARGV clock-localtime ... OK
Test OOM for nalloc=36 .................................... OK
31) QEMU XML-2-ARGV clock-france ... OK
Test OOM for nalloc=38 ...................................... OK
...
the second lines reports how many mallocs have to be failed, and thus
how many repeats of the test will be run.
If it crashes, then running under valgrind will often show the problem
$ VIR_TEST_OOM=1 ../run valgrind ./qemuxml2argvtest
When debugging problems it is also helpful to select an individual
test case
$ VIR_TEST_RANGE=30 VIR_TEST_OOM=1 ../run valgrind ./qemuxml2argvtest
When things get really tricky, it is possible to request that just
specific allocs are failed. eg to fail allocs 5 -> 12, use
$ VIR_TEST_RANGE=30 VIR_TEST_OOM=1:5-12 ../run valgrind ./qemuxml2argvtest
In the worse case, you might want to know the stack trace of the
alloc which was failed then VIR_TEST_OOM_TRACE can be set. If it
is set to 1 then it will only print if it thinks a mistake happened.
This is often not reliable, so setting it to 2 will make it print
the stack trace for every alloc that is failed.
$ VIR_TEST_OOM_TRACE=2 VIR_TEST_RANGE=30 VIR_TEST_OOM=1:5-5 ../run valgrind ./qemuxml2argvtest
30) QEMU XML-2-ARGV clock-localtime ... OK
Test OOM for nalloc=36 !virAllocN
/home/berrange/src/virt/libvirt/src/util/viralloc.c:180
virHashCreateFull
/home/berrange/src/virt/libvirt/src/util/virhash.c:144
virDomainDefParseXML
/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:11745
virDomainDefParseNode
/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12646
virDomainDefParse
/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12590
testCompareXMLToArgvFiles
/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:106
virtTestRun
/home/berrange/src/virt/libvirt/tests/testutils.c:250
mymain
/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:418 (discriminator 2)
virtTestMain
/home/berrange/src/virt/libvirt/tests/testutils.c:750
??
??:0
_start
??:?
FAILED
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
docs/internals/oomtesting.html.in | 213 ++++++++++++++++++++++++++++++++++++++
docs/sitemap.html.in | 4 +
tests/qemuargv2xmltest.c | 14 +--
tests/qemuxml2argvtest.c | 12 ++-
tests/qemuxmlnstest.c | 18 ++--
tests/testutils.c | 195 +++++++++++++++++++++++++++++++++-
tests/testutils.h | 2 +
7 files changed, 437 insertions(+), 21 deletions(-)
create mode 100644 docs/internals/oomtesting.html.in
diff --git a/docs/internals/oomtesting.html.in b/docs/internals/oomtesting.html.in
new file mode 100644
index 0000000..652aff6
--- /dev/null
+++ b/docs/internals/oomtesting.html.in
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <body>
+ <h1>Out of memory testing</h1>
+
+ <ul id="toc"></ul>
+
+
+ <p>
+ This page describes how to use the test suite todo out of memory
+ testing.
+ </p>
+
+ <h2>Building with OOM testing</h2>
+
+ <p>
+ Since OOM testing requires hooking into the malloc APIs, it is
+ not enabled by default. The flag <code>--enable-test-oom</code>
+ must be given to <code>configure</code>. When this is done the
+ libvirt allocation APIs will have some hooks enabled.
+ </p>
+
+ <pre>
+$ ./configure --enable-test-oom
+</pre>
+
+
+ <h2><a name="basicoom">Basic OOM testing support</a></h2>
+
+ <p>
+ The first step in validating OOM usage is to run a test suite
+ with full OOM testing enabled. This is done by setting the
+ <code>VIR_TEST_OOM=1</code> environment variable. The way this
+ works is that it runs the test once normally to "prime" any
+ static memory allocations. Then it runs it once more counting
+ the total number of memory allocations. Then it runs it in a
+ loop failing a different memory allocation each time. For every
+ memory allocation failure triggered, it expects the test case
+ to return an error. OOM testing is quite slow requiring each
+ test case to be executed O(n) times, where 'n' is the total
+ number of memory allocations. This results in a total number
+ of memory allocations of '(n * (n + 1) ) / 2'
+ </p>
+
+ <pre>
+$ VIR_TEST_OOM=1 ./qemuxml2argvtest
+ 1) QEMU XML-2-ARGV minimal ... OK
+ Test OOM for nalloc=42 .......................................... OK
+ 2) QEMU XML-2-ARGV minimal-s390 ... OK
+ Test OOM for nalloc=28 ............................ OK
+ 3) QEMU XML-2-ARGV machine-aliases1 ... OK
+ Test OOM for nalloc=38 ...................................... OK
+ 4) QEMU XML-2-ARGV machine-aliases2 ... OK
+ Test OOM for nalloc=38 ...................................... OK
+ 5) QEMU XML-2-ARGV machine-core-on ... OK
+ Test OOM for nalloc=37 ..................................... OK
+...snip...
+</pre>
+
+ <p>
+ In this output, the first line shows the normal execution and
+ the test number, and the second line shows the total number
+ of memory allocations from that test case.
+ </p>
+
+ <h3><a name="valgrind">Tracking failures with valgrind</a></h3>
+
+ <p>
+ The test suite should obviously *not* crash during OOM testing.
+ If it does crash, then to assist in tracking down the problem
+ it is worth using valgrind and only running a single test case.
+ For example, supposing test case 5 crashed. Then re-run the
+ test with
+ </p>
+
+ <pre>
+$ VIR_TEST_OOM=1 VIR_TEST_RANGE=5 ../run valgrind ./qemuxml2argvtest
+...snip...
+ 5) QEMU XML-2-ARGV machine-core-on ... OK
+ Test OOM for nalloc=37 ..................................... OK
+...snip...
+ </pre>
+
+ <p>
+ Valgrind should report the cause of the crash - for example a
+ double free or use of uninitialized memory or NULL pointer
+ access.
+ </p>
+
+ <h3><a name="stacktraces">Tracking failures with stack traces</a></h3>
+
+ <p>
+ With some really difficult bugs valgrind is not sufficient to
+ identify the cause. In this case, it is useful to identify the
+ precise allocation which was failed, to allow the code path
+ to the error to be traced. The <code>VIR_TEST_OOM</code>
+ env variable can be given a range of memory allocations to
+ test. So if a test case has 150 allocations, it can be told
+ to only test allocation numbers 7-10. The <code>VIR_TEST_OOM_TRACE</code>
+ variable can be used to print out stack traces.
+ </p>
+
+ <pre>
+$ VIR_TEST_OOM_TRACE=2 VIR_TEST_OOM=1:7-10 VIR_TEST_RANGE=5 \
+ ../run valgrind ./qemuxml2argvtest
+ 5) QEMU XML-2-ARGV machine-core-on ... OK
+ Test OOM for nalloc=37 !virAllocN
+/home/berrange/src/virt/libvirt/src/util/viralloc.c:180
+virDomainDefParseXML
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:11786 (discriminator 1)
+virDomainDefParseNode
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12677
+virDomainDefParse
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12621
+testCompareXMLToArgvFiles
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:107
+virtTestRun
+/home/berrange/src/virt/libvirt/tests/testutils.c:266
+mymain
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:388 (discriminator 2)
+virtTestMain
+/home/berrange/src/virt/libvirt/tests/testutils.c:791
+__libc_start_main
+??:?
+_start
+??:?
+!virAlloc
+/home/berrange/src/virt/libvirt/src/util/viralloc.c:133
+virDomainDiskDefParseXML
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:4790
+virDomainDefParseXML
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:11797
+virDomainDefParseNode
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12677
+virDomainDefParse
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12621
+testCompareXMLToArgvFiles
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:107
+virtTestRun
+/home/berrange/src/virt/libvirt/tests/testutils.c:266
+mymain
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:388 (discriminator 2)
+virtTestMain
+/home/berrange/src/virt/libvirt/tests/testutils.c:791
+__libc_start_main
+??:?
+_start
+??:?
+!virAllocN
+/home/berrange/src/virt/libvirt/src/util/viralloc.c:180
+virXPathNodeSet
+/home/berrange/src/virt/libvirt/src/util/virxml.c:609
+virDomainDefParseXML
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:11805
+virDomainDefParseNode
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12677
+virDomainDefParse
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12621
+testCompareXMLToArgvFiles
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:107
+virtTestRun
+/home/berrange/src/virt/libvirt/tests/testutils.c:266
+mymain
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:388 (discriminator 2)
+virtTestMain
+/home/berrange/src/virt/libvirt/tests/testutils.c:791
+__libc_start_main
+??:?
+_start
+??:?
+!virAllocN
+/home/berrange/src/virt/libvirt/src/util/viralloc.c:180
+virDomainDefParseXML
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:11808 (discriminator 1)
+virDomainDefParseNode
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12677
+virDomainDefParse
+/home/berrange/src/virt/libvirt/src/conf/domain_conf.c:12621
+testCompareXMLToArgvFiles
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:107
+virtTestRun
+/home/berrange/src/virt/libvirt/tests/testutils.c:266
+mymain
+/home/berrange/src/virt/libvirt/tests/qemuxml2argvtest.c:388 (discriminator 2)
+virtTestMain
+/home/berrange/src/virt/libvirt/tests/testutils.c:791
+__libc_start_main
+??:?
+_start
+??:?
+ </pre>
+
+ <h3><a name="noncrash">Non-crash related problems</a></h3>
+
+ <p>
+ Not all memory allocation bugs result in code crashing. Sometimes
+ the code will be silently ignoring the allocation failure, resulting
+ in incorrect data being produced. For example the XML parser may
+ mistakenly treat an allocation failure as indicating that an XML
+ attribute was not set in the input document. It is hard to identify
+ these problems from the test suite automatically. For this, the
+ test suites should be run with <code>VIR_TEST_DEBUG=1</code> set
+ and then stderr analysed for any unexpected data. For example,
+ the XML conversion may show an embedded "(null)" literal, or the
+ test suite might complain about missing elements / attributes
+ in the actual vs expected data. These are all signs of bugs in
+ OOM handling. In the future the OOM tests will be enhanced to
+ validate that an error VIR_ERR_NO_MEMORY is returned for each
+ allocation failed, rather than some other error.
+ </p>
+ </body>
+</html>
diff --git a/docs/sitemap.html.in b/docs/sitemap.html.in
index d821a9e..d885f02 100644
--- a/docs/sitemap.html.in
+++ b/docs/sitemap.html.in
@@ -338,6 +338,10 @@
<a href="internals/locking.html">Lock managers</a>
<span>Use lock managers to protect disk content</span>
</li>
+ <li>
+ <a href="internals/oomtesting.html">Out of memory testing</a>
+ <span>Simulating OOM conditions in the test suite</span>
+ </li>
</ul>
</li>
<li>
diff --git a/tests/qemuargv2xmltest.c b/tests/qemuargv2xmltest.c
index 6dd8bb0..92fc89a 100644
--- a/tests/qemuargv2xmltest.c
+++ b/tests/qemuargv2xmltest.c
@@ -42,7 +42,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
char *cmd = NULL;
int ret = -1;
virDomainDefPtr vmdef = NULL;
- char *log;
if (virtTestLoadFile(cmdfile, &cmd) < 0)
goto fail;
@@ -53,13 +52,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
cmd, NULL, NULL, NULL)))
goto fail;
- if ((log = virtTestLogContentAndReset()) == NULL)
- goto fail;
- if ((*log != '\0') != expect_warning) {
+ if (!virtTestOOMActive()) {
+ char *log;
+ if ((log = virtTestLogContentAndReset()) == NULL)
+ goto fail;
+ if ((*log != '\0') != expect_warning) {
+ VIR_FREE(log);
+ goto fail;
+ }
VIR_FREE(log);
- goto fail;
}
- VIR_FREE(log);
if (!(actualxml = virDomainDefFormat(vmdef, 0)))
goto fail;
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 060acf2..83ddbad 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -107,7 +107,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
QEMU_EXPECTED_VIRT_TYPES,
VIR_DOMAIN_XML_INACTIVE))) {
- if (flags & FLAG_EXPECT_PARSE_ERROR)
+ if (!virtTestOOMActive() &&
+ (flags & FLAG_EXPECT_PARSE_ERROR))
goto ok;
goto out;
}
@@ -170,7 +171,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
migrateFrom, migrateFd, NULL,
VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,
&testCallbacks))) {
- if (flags & FLAG_EXPECT_FAILURE) {
+ if (!virtTestOOMActive() &&
+ (flags & FLAG_EXPECT_FAILURE)) {
ret = 0;
if (virTestGetDebug() > 1)
fprintf(stderr, "Got expected error: %s\n",
@@ -184,7 +186,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
goto out;
}
- if (!!virGetLastError() != !!(flags & FLAG_EXPECT_ERROR)) {
+ if (!virtTestOOMActive() &&
+ (!!virGetLastError() != !!(flags & FLAG_EXPECT_ERROR))) {
if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
fprintf(stderr, "\n%s", log);
goto out;
@@ -205,7 +208,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
}
ok:
- if (flags & FLAG_EXPECT_ERROR) {
+ if (!virtTestOOMActive() &&
+ (flags & FLAG_EXPECT_ERROR)) {
/* need to suppress the errors */
virResetLastError();
}
diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c
index 2cc15d1..38c98bd 100644
--- a/tests/qemuxmlnstest.c
+++ b/tests/qemuxmlnstest.c
@@ -117,15 +117,17 @@ static int testCompareXMLToArgvFiles(const char *xml,
&testCallbacks)))
goto fail;
- if (!!virGetLastError() != expectError) {
- if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
- fprintf(stderr, "\n%s", log);
- goto fail;
- }
+ if (!virtTestOOMActive()) {
+ if (!!virGetLastError() != expectError) {
+ if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
+ fprintf(stderr, "\n%s", log);
+ goto fail;
+ }
- if (expectError) {
- /* need to suppress the errors */
- virResetLastError();
+ if (expectError) {
+ /* need to suppress the errors */
+ virResetLastError();
+ }
}
if (!(actualargv = virCommandToString(cmd)))
diff --git a/tests/testutils.c b/tests/testutils.c
index 5d634b4..bc1e34e 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -47,6 +47,13 @@
#include "virprocess.h"
#include "virstring.h"
+#ifdef TEST_OOM
+# ifdef TEST_OOM_TRACE
+#include <dlfcn.h>
+#include <execinfo.h>
+# endif
+#endif
+
#ifdef HAVE_PATHS_H
# include <paths.h>
#endif
@@ -64,6 +71,18 @@ static unsigned int testDebug = -1;
static unsigned int testVerbose = -1;
static unsigned int testExpensive = -1;
+#ifdef TEST_OOM
+static unsigned int testOOM = 0;
+static unsigned int testOOMStart = -1;
+static unsigned int testOOMEnd = -1;
+static unsigned int testOOMTrace = 0;
+# ifdef TEST_OOM_TRACE
+void *testAllocStack[30];
+int ntestAllocStack;
+# endif
+#endif
+static bool testOOMActive = false;
+
static size_t testCounter = 0;
static size_t testStart = 0;
static size_t testEnd = 0;
@@ -71,6 +90,19 @@ static size_t testEnd = 0;
char *progname;
char *abs_srcdir;
+bool virtTestOOMActive(void)
+{
+ return testOOMActive;
+}
+
+#ifdef TEST_OOM_TRACE
+static void virTestAllocHook(int nalloc ATTRIBUTE_UNUSED,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ ntestAllocStack = backtrace(testAllocStack, ARRAY_CARDINALITY(testAllocStack));
+}
+#endif
+
void virtTestResult(const char *name, int ret, const char *msg, ...)
{
va_list vargs;
@@ -109,6 +141,35 @@ void virtTestResult(const char *name, int ret, const char *msg, ...)
va_end(vargs);
}
+#ifdef TEST_OOM_TRACE
+static void
+virTestShowTrace(void)
+{
+ size_t j;
+ for (j = 2; j < ntestAllocStack; j++) {
+ Dl_info info;
+ char *cmd;
+
+ dladdr(testAllocStack[j], &info);
+ if (info.dli_fname &&
+ strstr(info.dli_fname, ".so")) {
+ if (virAsprintf(&cmd, "addr2line -f -e %s %p",
+ info.dli_fname,
+ ((void*)((unsigned long long)testAllocStack[j]
+ - (unsigned long long)info.dli_fbase))) < 0)
+ continue;
+ } else {
+ if (virAsprintf(&cmd, "addr2line -f -e %s %p",
+ (char*)(info.dli_fname ? info.dli_fname : "<unknown>"),
+ testAllocStack[j]) < 0)
+ continue;
+ }
+ ignore_value(system(cmd));
+ VIR_FREE(cmd);
+ }
+}
+#endif
+
/*
* Runs test
*
@@ -155,7 +216,7 @@ virtTestRun(const char *title,
!((testCounter-1) % 40)) {
fprintf(stderr, " %-3zu\n", (testCounter-1));
fprintf(stderr, " ");
- }
+ }
if (ret == 0)
fprintf(stderr, ".");
else if (ret == EXIT_AM_SKIP)
@@ -164,6 +225,77 @@ virtTestRun(const char *title,
fprintf(stderr, "!");
}
+#ifdef TEST_OOM
+ if (testOOM && ret != EXIT_AM_SKIP) {
+ int nalloc;
+ int oomret;
+ int start, end;
+ size_t i;
+ virResetLastError();
+ virAllocTestInit();
+# ifdef TEST_OOM_TRACE
+ virAllocTestHook(virTestAllocHook, NULL);
+# endif
+ oomret = body(data);
+ nalloc = virAllocTestCount();
+ fprintf(stderr, " Test OOM for nalloc=%d ", nalloc);
+ if (testOOMStart == -1 ||
+ testOOMEnd == -1) {
+ start = 0;
+ end = nalloc;
+ } else {
+ start = testOOMStart;
+ end = testOOMEnd + 1;
+ }
+ testOOMActive = true;
+ for (i = start; i < end; i++) {
+ bool missingFail = false;
+# ifdef TEST_OOM_TRACE
+ memset(testAllocStack, 0, ARRAY_CARDINALITY(testAllocStack));
+ ntestAllocStack = 0;
+# endif
+ virAllocTestOOM(i + 1, 1);
+ oomret = body(data);
+
+ /* fprintf() disabled because XML parsing APIs don't allow
+ * distinguish between element / attribute not present
+ * in the XML (which is non-fatal), vs OOM / malformed
+ * which should be fatal. Thus error reporting for
+ * optionally present XML is mostly broken.
+ */
+ if (oomret == 0) {
+ missingFail = true;
+# if 0
+ fprintf(stderr, " alloc %zu failed but no err status\n", i + 1);
+# endif
+ } else {
+ virErrorPtr lerr = virGetLastError();
+ if (!lerr) {
+# if 0
+ fprintf(stderr, " alloc %zu failed but no error report\n", i + 1);
+# endif
+ missingFail = true;
+ }
+ }
+ if ((missingFail && testOOMTrace) || (testOOMTrace > 1)) {
+ fprintf(stderr, "%s", "!");
+# ifdef TEST_OOM_TRACE
+ virTestShowTrace();
+# endif
+ ret = -1;
+ } else {
+ fprintf(stderr, "%s", ".");
+ }
+ }
+ testOOMActive = false;
+ if (ret == 0)
+ fprintf(stderr, " OK\n");
+ else
+ fprintf(stderr, " FAILED\n");
+ virAllocTestInit();
+ }
+#endif /* TEST_OOM */
+
return ret;
}
@@ -192,7 +324,6 @@ virtTestLoadFile(const char *file, char **buf)
tmplen = buflen = st.st_size + 1;
if (VIR_ALLOC_N(*buf, buflen) < 0) {
- fprintf(stderr, "%s: larger than available memory (> %d)\n", file, buflen);
VIR_FORCE_FCLOSE(fp);
return -1;
}
@@ -468,7 +599,8 @@ virtTestLogOutput(virLogSource source ATTRIBUTE_UNUSED,
{
struct virtTestLogData *log = data;
virCheckFlags(VIR_LOG_STACK_TRACE,);
- virBufferAsprintf(&log->buf, "%s: %s", timestamp, str);
+ if (!testOOMActive)
+ virBufferAsprintf(&log->buf, "%s: %s", timestamp, str);
}
static void
@@ -537,6 +669,9 @@ int virtTestMain(int argc,
int ret;
bool abs_srcdir_cleanup = false;
char *testRange = NULL;
+#ifdef TEST_OOM
+ char *oomstr;
+#endif
abs_srcdir = getenv("abs_srcdir");
if (!abs_srcdir) {
@@ -597,6 +732,60 @@ int virtTestMain(int argc,
}
}
+#ifdef TEST_OOM
+ if ((oomstr = getenv("VIR_TEST_OOM")) != NULL) {
+ char *next;
+ if (testDebug == -1)
+ testDebug = 1;
+ testOOM = 1;
+ if (oomstr[0] != '\0' &&
+ oomstr[1] == ':') {
+ if (virStrToLong_ui(oomstr + 2, &next, 10, &testOOMStart) < 0) {
+ fprintf(stderr, "Cannot parse range %s\n", oomstr);
+ return EXIT_FAILURE;
+ }
+ if (*next == '\0') {
+ testOOMEnd = testOOMStart;
+ } else {
+ if (*next != '-') {
+ fprintf(stderr, "Cannot parse range %s\n", oomstr);
+ return EXIT_FAILURE;
+ }
+ if (virStrToLong_ui(next+1, NULL, 10, &testOOMEnd) < 0) {
+ fprintf(stderr, "Cannot parse range %s\n", oomstr);
+ return EXIT_FAILURE;
+ }
+ }
+ } else {
+ testOOMStart = -1;
+ testOOMEnd = -1;
+ }
+ }
+
+# ifdef TEST_OOM_TRACE
+ if ((oomstr = getenv("VIR_TEST_OOM_TRACE")) != NULL) {
+ if (virStrToLong_ui(oomstr, NULL, 10, &testOOMTrace) < 0) {
+ fprintf(stderr, "Cannot parse oom trace %s\n", oomstr);
+ return EXIT_FAILURE;
+ }
+ }
+# else
+ if (getenv("VIR_TEST_OOM_TRACE")) {
+ fprintf(stderr, "%s", "OOM test tracing not enabled in this build\n");
+ return EXIT_FAILURE;
+ }
+# endif
+#else /* TEST_OOM */
+ if (getenv("VIR_TEST_OOM")) {
+ fprintf(stderr, "%s", "OOM testing not enabled in this build\n");
+ return EXIT_FAILURE;
+ }
+ if (getenv("VIR_TEST_OOM_TRACE")) {
+ fprintf(stderr, "%s", "OOM test tracing not enabled in this build\n");
+ return EXIT_FAILURE;
+ }
+#endif /* TEST_OOM */
+
ret = (func)();
if (abs_srcdir_cleanup)
diff --git a/tests/testutils.h b/tests/testutils.h
index 478b53c..e6f494d 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -40,6 +40,8 @@
extern char *progname;
extern char *abs_srcdir;
+bool virtTestOOMActive(void);
+
void virtTestResult(const char *name, int ret, const char *msg, ...)
ATTRIBUTE_FMT_PRINTF(3,4);
int virtTestRun(const char *title,
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCH 0/6] Try to fix selinux/securityfs mount handling in LXC
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
This series tries to address the problem of LXC containers failing
to start because 'securityfs' is not compiled in. In doing this some
general cleanup was performed on the LXC mount code.
Daniel P. Berrange (6):
Add virFileIsMountPoint function
Remove unused 'opts' field from LXC basic mounts struct
Remove pointless 'srcpath' variable in lxcContainerMountBasicFS
Remove duplicate entries in lxcBasicMounts array
Add flag to lxcBasicMounts to control use in user namespaces
Skip any files which are not mounted on the host
src/libvirt_private.syms | 1 +
src/lxc/lxc_container.c | 86 +++++++++++++++++++++++++++++-------------------
src/util/virfile.c | 58 ++++++++++++++++++++++++++++++++
src/util/virfile.h | 2 ++
4 files changed, 113 insertions(+), 34 deletions(-)
--
1.8.3.1
11 years, 2 months
[libvirt] [PATCHv2 00/23] Better approach to add the "pvticketlocks" feature
by Peter Krempa
This version resolves conflicts with Eric's const correctnes series.
The paravirtual spinlock feature was introduced recently into the qemu and
linux code base. To test it you need the most recent -rc version of the linux
kernel and the git version of qemu.
As the requirements to activate this feature in the guest are really volatile
(kernel support, qemu support .. .) I decided to improve the original version
so that it detects if the feature was actually enabled in the guest. This
avoids possible problems with breaking guest ABI when migrating between two
hosts with different kernels. Additionally we may start enforcin other features
too.
This patchset is partialy based on Jiri's work on getting actual cpu definition
from a running qemu.
Jiri Denemark (8):
cpu: Add support for loading and storing CPU data
cpu: x86: Rename struct cpuX86cpuid as virCPUx86CPUID
cpu: x86: Rename struct cpuX86Data as virCPUx86Data
cpu: x86: Rename x86DataFree() as virCPUx86DataFree()
cpu: x86: Rename x86MakeCPUData as virCPUx86MakeData
cpu: x86: Rename x86DataAddCpuid as virCPUx86DataAddCPUID
cpu: Export few x86-specific APIs
qemu: Add monitor APIs to fetch CPUID data from QEMU
Peter Krempa (15):
schema: Rename option to make it reusable
conf: Clean up few error messages
qemu: command: Fix macro indentation
cpu: x86: Rename data_iterator and DATA_ITERATOR_INIT
cpu: x86: Fix return types of x86cpuidMatch and x86cpuidMatchMasked
cpu: x86: Fix function header formatting and whitespace
cpu: x86: Use whitespace to clarify context and use consistent labels
cpu: x86: Clean up error messages in x86VendorLoad()
qemu: Clean up check of maximum cpu count supported by a machine type
cpu_x86: Refactor storage of CPUID data to add support for KVM
features
cpu: x86: Parse the CPU feature map only once
cpu: x86: Add internal CPUID features support and KVM feature bits
conf: Refactor storing and usage of feature flags
qemu: Add support for paravirtual spinlocks in the guest
qemu: process: Validate specific CPUID flags of a guest
docs/formatdomain.html.in | 7 +
docs/schemas/domaincommon.rng | 18 +-
src/conf/domain_conf.c | 200 ++++--
src/conf/domain_conf.h | 3 +-
src/cpu/cpu.c | 41 ++
src/cpu/cpu.h | 16 +-
src/cpu/cpu_x86.c | 699 ++++++++++++---------
src/cpu/cpu_x86.h | 9 +
src/cpu/cpu_x86_data.h | 26 +-
src/libvirt_private.syms | 8 +
src/libxl/libxl_conf.c | 9 +-
src/lxc/lxc_container.c | 6 +-
src/qemu/qemu_command.c | 31 +-
src/qemu/qemu_monitor.c | 21 +
src/qemu/qemu_monitor.h | 3 +
src/qemu/qemu_monitor_json.c | 107 ++++
src/qemu/qemu_monitor_json.h | 3 +
src/qemu/qemu_process.c | 50 +-
src/vbox/vbox_tmpl.c | 45 +-
src/xenapi/xenapi_driver.c | 10 +-
src/xenapi/xenapi_utils.c | 22 +-
src/xenxs/xen_sxpr.c | 20 +-
src/xenxs/xen_xm.c | 30 +-
tests/Makefile.am | 1 +
.../qemumonitorjson-getcpu-empty.data | 2 +
.../qemumonitorjson-getcpu-empty.json | 46 ++
.../qemumonitorjson-getcpu-filtered.data | 4 +
.../qemumonitorjson-getcpu-filtered.json | 46 ++
.../qemumonitorjson-getcpu-full.data | 5 +
.../qemumonitorjson-getcpu-full.json | 46 ++
.../qemumonitorjson-getcpu-host.data | 6 +
.../qemumonitorjson-getcpu-host.json | 45 ++
tests/qemumonitorjsontest.c | 76 +++
.../qemuxml2argv-pv-spinlock-disabled.args | 5 +
.../qemuxml2argv-pv-spinlock-disabled.xml | 26 +
.../qemuxml2argv-pv-spinlock-enabled.args | 5 +
.../qemuxml2argv-pv-spinlock-enabled.xml | 26 +
tests/qemuxml2argvtest.c | 2 +
tests/qemuxml2xmltest.c | 2 +
39 files changed, 1279 insertions(+), 448 deletions(-)
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-empty.data
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-empty.json
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-filtered.data
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-filtered.json
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.data
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-full.json
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.data
create mode 100644 tests/qemumonitorjsondata/qemumonitorjson-getcpu-host.json
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pv-spinlock-disabled.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pv-spinlock-disabled.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pv-spinlock-enabled.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pv-spinlock-enabled.xml
--
1.8.3.2
11 years, 2 months
[libvirt] [PATCH] virprocess: make virProcessGetStartTime work on Mac OS X
by Ryota Ozaki
This patch addresses the following warning output by libvirtd:
warning : virProcessGetStartTime:843 : Process start time of
pid XXXXX not available on this platform
For Mac OS X, we can use similar instructions to FreeBSD
to get the start time of a process. The difference between them
is struct kinfo_proc; kinfo_proc.ki_start is the start time
of a process for FreeBSD while kinfo_proc.kp_proc.p_starttime
for Mac OS X.
Note that this patch works for Lion and Mountain Lion, however,
doesn't work for Snow Leopard for some reason;
sysctlnametomib("kern.proc.pid", ...) fails on Snow Leopard with
the following error:
error : virProcessGetStartTime:822 : Unable to get MIB of
kern.proc.pid: No such file or directory
This is unexpected. man 3 sysctl of Snow Leopard says it
should work...
Anyway libvirtd is able to launch on Snow Leopard regardless of
the error.
Signed-off-by: Ryota Ozaki <ozaki.ryota(a)gmail.com>
---
src/util/virprocess.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 9fc3207..5a0ed0d 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -32,7 +32,7 @@
#endif
#include <sched.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__APPLE__)
# include <sys/param.h>
# include <sys/sysctl.h>
# include <sys/user.h>
@@ -809,7 +809,7 @@ cleanup:
VIR_FREE(buf);
return ret;
}
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__APPLE__)
int virProcessGetStartTime(pid_t pid,
unsigned long long *timestamp)
{
@@ -817,7 +817,12 @@ int virProcessGetStartTime(pid_t pid,
int mib[4];
size_t len = 4;
- sysctlnametomib("kern.proc.pid", mib, &len);
+ /* FIXME: It doesn't work on Snow Leopard for some reason */
+ if (sysctlnametomib("kern.proc.pid", mib, &len) < 0) {
+ virReportSystemError(errno, "%s",
+ _("Unable to get MIB of kern.proc.pid"));
+ return -1;
+ }
len = sizeof(struct kinfo_proc);
mib[3] = pid;
@@ -828,7 +833,11 @@ int virProcessGetStartTime(pid_t pid,
return -1;
}
+# if defined(__FreeBSD__)
*timestamp = (unsigned long long)p.ki_start.tv_sec;
+# else
+ *timestamp = (unsigned long long)p.kp_proc.p_starttime.tv_sec;
+# endif
return 0;
--
1.8.4
11 years, 2 months