[libvirt] [PATCH] qemu_migration: Check ABI stability against MIGRATABLE xml
by Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=994364
If user provides domain XML in migration we check if it doesn't break
ABI via virDomainDefCheckABIStability(). However, if the provided XML
was generated via virDomainGetXMLDesc(..., VIR_DOMAIN_XML_MIGRATABLE)
it is missing some devices, e.g. 'pci-root' controller. Hence, the ABI
stability check fails even though it is stable.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_migration.c | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3a1aab7..65a09b4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1970,6 +1970,8 @@ static char
virCapsPtr caps = NULL;
unsigned int cookieFlags = QEMU_MIGRATION_COOKIE_LOCKSTATE;
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
+ virDomainDefPtr migratableDef = NULL;
+ char *migratableDefStr = NULL;
VIR_DEBUG("driver=%p, vm=%p, xmlin=%s, dname=%s,"
" cookieout=%p, cookieoutlen=%p, flags=%lx",
@@ -2039,7 +2041,17 @@ static char
VIR_DOMAIN_XML_INACTIVE)))
goto cleanup;
- if (!virDomainDefCheckABIStability(vm->def, def))
+ migratableDefStr = qemuDomainDefFormatLive(driver, vm->def, false, true);
+ if (!migratableDefStr)
+ goto cleanup;
+
+ if (!(migratableDef = virDomainDefParseString(migratableDefStr, caps,
+ driver->xmlopt,
+ QEMU_EXPECTED_VIRT_TYPES,
+ VIR_DOMAIN_XML_INACTIVE)))
+ goto cleanup;
+
+ if (!virDomainDefCheckABIStability(migratableDef, def))
goto cleanup;
rv = qemuDomainDefFormatLive(driver, def, false, true);
@@ -2051,6 +2063,8 @@ cleanup:
qemuMigrationCookieFree(mig);
virObjectUnref(caps);
virDomainDefFree(def);
+ virDomainDefFree(migratableDef);
+ VIR_FREE(migratableDefStr);
return rv;
}
@@ -2179,6 +2193,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
const char *listenAddr = NULL;
char *migrateFrom = NULL;
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
+ virDomainDefPtr migratableDef = NULL;
+ char *migratableDefStr = NULL;
if (virTimeMillisNow(&now) < 0)
return -1;
@@ -2213,18 +2229,16 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
/* Let migration hook filter domain XML */
if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) {
- char *xml;
int hookret;
- if (!(xml = qemuDomainDefFormatXML(driver, *def,
- VIR_DOMAIN_XML_SECURE |
- VIR_DOMAIN_XML_MIGRATABLE)))
+ if (!(migratableDefStr = qemuDomainDefFormatXML(driver, *def,
+ VIR_DOMAIN_XML_SECURE |
+ VIR_DOMAIN_XML_MIGRATABLE)))
goto cleanup;
hookret = virHookCall(VIR_HOOK_DRIVER_QEMU, (*def)->name,
VIR_HOOK_QEMU_OP_MIGRATE, VIR_HOOK_SUBOP_BEGIN,
- NULL, xml, &xmlout);
- VIR_FREE(xml);
+ NULL, migratableDefStr, &xmlout);
if (hookret < 0) {
goto cleanup;
@@ -2242,7 +2256,16 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
if (!newdef)
goto cleanup;
- if (!virDomainDefCheckABIStability(*def, newdef)) {
+ migratableDef = virDomainDefParseString(migratableDefStr, caps,
+ driver->xmlopt,
+ QEMU_EXPECTED_VIRT_TYPES,
+ VIR_DOMAIN_XML_INACTIVE);
+ if (!migratableDef) {
+ virDomainDefFree(newdef);
+ goto cleanup;
+ }
+
+ if (!virDomainDefCheckABIStability(migratableDef, newdef)) {
virDomainDefFree(newdef);
goto cleanup;
}
@@ -2429,6 +2452,8 @@ cleanup:
qemuDomainEventQueue(driver, event);
qemuMigrationCookieFree(mig);
virObjectUnref(caps);
+ virDomainDefFree(migratableDef);
+ VIR_FREE(migratableDefStr);
return ret;
stop:
--
1.8.1.5
11 years, 1 month
[libvirt] [PATCH]docs: exit if failed to generate html
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
If xhtml1 dtd not install, some html will not be generated.
If we 'make install', it will succeed and
message "missing XHTML1 DTD" will be hide inside a large
amount of logs.
So exit when this occurs.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
docs/Makefile.am | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 9de3406..82c3ed8 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -223,7 +223,7 @@ internals/%.html.tmp: internals/%.html.in subsite.xsl page.xsl sitemap.html.in
SGML_CATALOG_FILES='$(XML_CATALOG_FILE)' \
$(XMLLINT) --catalogs --nonet --format --valid $< > $(srcdir)/$@ \
|| { rm $(srcdir)/$@ && exit 1; }; \
- else echo "missing XHTML1 DTD" ; fi ; fi
+ else echo "missing XHTML1 DTD" ; exit 1; fi ; fi
%.php.tmp: %.php.in site.xsl page.xsl sitemap.html.in
@if [ -x $(XSLTPROC) ] ; then \
@@ -249,7 +249,7 @@ html/index.html: libvirt-api.xml newapi.xsl page.xsl sitemap.html.in
> /dev/null ; then \
SGML_CATALOG_FILES='$(XML_CATALOG_FILE)' \
$(XMLLINT) --catalogs --nonet --valid --noout $(srcdir)/html/*.html ; \
- else echo "missing XHTML1 DTD" ; fi ; fi
+ else echo "missing XHTML1 DTD" ; exit 1; fi ; fi
$(addprefix $(srcdir)/,$(devhelphtml)): $(srcdir)/libvirt-api.xml $(devhelpxsl)
$(AM_V_GEN)if [ -x $(XSLTPROC) ] ; then \
--
1.8.2.1
11 years, 1 month
[libvirt] [PATCHv3] LXC: Fix handling of RAM filesystem size units
by Ján Tomko
Since 76b644c when the support for RAM filesystems was introduced,
libvirt accepted the following XML:
<source usage='1024' unit='KiB'/>
This was parsed correctly and internally stored in bytes, but it
was formatted as (with an extra 's'):
<source usage='1024' units='KiB'/>
When read again, this was treated as if the units were missing,
meaning libvirt was unable to parse its own XML correctly.
The usage attribute was documented as being in KiB, but it was not
scaled if the unit was missing. Transient domains still worked,
because this was balanced by an extra 'k' in the mount options.
This patch:
Changes the parser to use 'units' instead of 'unit', as the latter
was never documented (fixing persistent domains).
Removes the extra 'k' from the tmpfs mount options, which is needed
because now we parse our own XML correctly.
Changes the default input unit to KiB to match documentation, fixing:
https://bugzilla.redhat.com/show_bug.cgi?id=1015689
---
v1: https://www.redhat.com/archives/libvir-list/2013-October/msg00361.html
v2: keeps the output unit KiB
changes the default input unit to KiB
accepts 'units' as well as 'unit' in input XML
v3: drop 'unit' completely as it was never documented
docs/formatdomain.html.in | 6 +++--
docs/schemas/domaincommon.rng | 2 +-
src/conf/domain_conf.c | 9 ++++---
src/lxc/lxc_container.c | 2 +-
tests/domainschematest | 2 +-
tests/lxcxml2xmldata/lxc-filesystem-ram.xml | 33 ++++++++++++++++++++++++++
tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml | 33 ++++++++++++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
8 files changed, 78 insertions(+), 10 deletions(-)
create mode 100644 tests/lxcxml2xmldata/lxc-filesystem-ram.xml
create mode 100644 tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3689399..8f74487 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2213,7 +2213,8 @@
<dd>
An in-memory filesystem, using memory from the host OS.
The source element has a single attribute <code>usage</code>
- which gives the memory usage limit in kibibytes. Only used
+ which gives the memory usage limit in KiB, unless units
+ are specified by the <code>units</code> attribute. Only used
by LXC driver.
<span class="since"> (since 0.9.13)</span></dd>
<dt><code>type='bind'</code></dt>
@@ -2279,7 +2280,8 @@
<code>name</code> attribute must be used with
<code>type='template'</code>, and the <code>dir</code> attribute must
be used with <code>type='mount'</code>. The <code>usage</code> attribute
- is used with <code>type='ram'</code> to set the memory limit in KB.
+ is used with <code>type='ram'</code> to set the memory limit in KiB,
+ unless units are specified by the <code>units</code> attribute.
</dd>
<dt><code>target</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5c5301d..10b017f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1732,7 +1732,7 @@
<ref name="unsignedLong"/>
</attribute>
<optional>
- <attribute name='unit'>
+ <attribute name='units'>
<ref name='unit'/>
</attribute>
</optional>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0d63845..e3737bc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5916,7 +5916,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
char *accessmode = NULL;
char *wrpolicy = NULL;
char *usage = NULL;
- char *unit = NULL;
+ char *units = NULL;
ctxt->node = node;
@@ -5972,7 +5972,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
source = virXMLPropString(cur, "name");
else if (def->type == VIR_DOMAIN_FS_TYPE_RAM) {
usage = virXMLPropString(cur, "usage");
- unit = virXMLPropString(cur, "unit");
+ units = virXMLPropString(cur, "units");
}
} else if (!target &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
@@ -6042,8 +6042,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
usage);
goto error;
}
- if (unit &&
- virScaleInteger(&def->usage, unit,
+ if (virScaleInteger(&def->usage, units,
1024, ULLONG_MAX) < 0)
goto error;
}
@@ -6065,7 +6064,7 @@ cleanup:
VIR_FREE(accessmode);
VIR_FREE(wrpolicy);
VIR_FREE(usage);
- VIR_FREE(unit);
+ VIR_FREE(units);
VIR_FREE(format);
return def;
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index b1f429c..7c722cc 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1428,7 +1428,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
VIR_DEBUG("usage=%lld sec=%s", fs->usage, sec_mount_options);
if (virAsprintf(&data,
- "size=%lldk%s", fs->usage, sec_mount_options) < 0)
+ "size=%lld%s", fs->usage, sec_mount_options) < 0)
goto cleanup;
if (virFileMakePath(fs->dst) < 0) {
diff --git a/tests/domainschematest b/tests/domainschematest
index 0e360ca..9ebf0b9 100755
--- a/tests/domainschematest
+++ b/tests/domainschematest
@@ -7,7 +7,7 @@
DIRS=""
DIRS="$DIRS domainschemadata qemuxml2argvdata sexpr2xmldata"
DIRS="$DIRS xmconfigdata xml2sexprdata qemuxml2xmloutdata "
-DIRS="$DIRS lxcxml2xmldata"
+DIRS="$DIRS lxcxml2xmldata lxcxml2xmloutdata"
SCHEMA="domain.rng"
check_schema "$DIRS" "$SCHEMA"
diff --git a/tests/lxcxml2xmldata/lxc-filesystem-ram.xml b/tests/lxcxml2xmldata/lxc-filesystem-ram.xml
new file mode 100644
index 0000000..002fde6
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-filesystem-ram.xml
@@ -0,0 +1,33 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/sh</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='ram'>
+ <source usage='1048576'/>
+ <target dir='/mnt/mississippi'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1048576' units='bytes'/>
+ <target dir='/mnt/antananarivo'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1024' units='KiB'/>
+ <target dir='/mnt/ouagadougou'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml b/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
new file mode 100644
index 0000000..d2369a2
--- /dev/null
+++ b/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
@@ -0,0 +1,33 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/sh</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1048576' units='KiB'/>
+ <target dir='/mnt/mississippi'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1024' units='KiB'/>
+ <target dir='/mnt/antananarivo'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1024' units='KiB'/>
+ <target dir='/mnt/ouagadougou'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 5846ab0..1692e4b 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -136,6 +136,7 @@ mymain(void)
DO_TEST("systemd");
DO_TEST("hostdev");
DO_TEST("disk-formats");
+ DO_TEST_DIFFERENT("filesystem-ram");
virObjectUnref(caps);
virObjectUnref(xmlopt);
--
1.8.1.5
11 years, 1 month
[libvirt] [PATCH]cgroup: fix a comment typo in vircgroup.c
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
s/shoule/should
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
src/util/vircgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index e99caf5..91b8704 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2431,7 +2431,7 @@ virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
int
virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period)
{
- /* The cfs_period shoule be greater or equal than 1ms, and less or equal
+ /* The cfs_period should be greater or equal than 1ms, and less or equal
* than 1s.
*/
if (cfs_period < 1000 || cfs_period > 1000000) {
--
1.8.2.1
11 years, 1 month
[libvirt] [PATCH] storage_backend: Fix issue with allocation of 0 length volume
by John Ferlan
Commit id '532fef36' added a call to fallocate() and some error
handling based on whether or not the function existed. This new
call resulted in libvirt-cim/cimtest failures when attempting to
create a volume with "0" (zero) allocation value. The failure is
logged as:
Oct 9 07:51:33 localhost libvirtd[8030]: cannot allocate 0 bytes in
file '/var/lib/libvirt/images/cimtest-vol.img': Invalid argument
This can also be seen with virsh vol-create-as:
error: Failed to create vol test
error: cannot allocate 0 bytes in file '/home/vm-images/test': Invalid
argument
error: Failed to create vol test
error: cannot allocate 0 bytes in file '/home/vm-images/test': Invalid
argument
It turns out fallocate() will return EINVAL when the incoming 'len'
(or allocation) value is 0 (or less).
---
src/storage/storage_backend.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 662af32..d0580f9 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -332,19 +332,22 @@ createRawFile(int fd, virStorageVolDefPtr vol,
/* Avoid issues with older kernel's <linux/fs.h> namespace pollution. */
#if HAVE_FALLOCATE - 0
/* Try to preallocate all requested disk space, but fall back to
- * other methods if this fails with ENOSYS or EOPNOTSUPP.
+ * other methods if this fails with ENOSYS or EOPNOTSUPP. If allocation
+ * is 0 (or less than 0), then fallocate will fail with EINVAL.
* NOTE: do not use posix_fallocate; posix_fallocate falls back
* to writing zeroes block by block in case fallocate isn't
* available, and since we're going to copy data from another
* file it doesn't make sense to write the file twice. */
- if (fallocate(fd, 0, 0, vol->allocation) == 0) {
- need_alloc = 0;
- } else if (errno != ENOSYS && errno != EOPNOTSUPP) {
- ret = -errno;
- virReportSystemError(errno,
- _("cannot allocate %llu bytes in file '%s'"),
- vol->allocation, vol->target.path);
- goto cleanup;
+ if (vol->allocation) {
+ if (fallocate(fd, 0, 0, vol->allocation) == 0) {
+ need_alloc = 0;
+ } else if (errno != ENOSYS && errno != EOPNOTSUPP) {
+ ret = -errno;
+ virReportSystemError(errno,
+ _("cannot allocate %llu bytes in file '%s'"),
+ vol->allocation, vol->target.path);
+ goto cleanup;
+ }
}
#endif
--
1.8.3.1
11 years, 1 month
[libvirt] [PATCHv2] LXC: Fix handling of RAM filesystem size units
by Ján Tomko
Since 76b644c when the support for RAM filesystems was introduced,
libvirt accepted the following XML:
<source usage='1024' unit='KiB'/>
This was parsed correctly and internally stored in bytes, but it
was formatted as (with an extra 's'):
<source usage='1024' units='KiB'/>
When read again, this was treated as if the units were missing,
meaning libvirt was unable to parse its own XML correctly.
The usage attribute was documented as being in KiB, but it was not
scaled if the unit was missing. Transient domains still worked,
because this was balanced by an extra 'k' in the mount options.
This patch:
Outputs the units via the 'unit' attribute (fixing persistent domains),
but accepts both 'unit' and 'units' (for compatibility with older
libvirt and libvirt-sandbox).
Removes the extra 'k' from the tmpfs mount options, which is needed
because now we parse our own XML correctly.
Changes the default unit to KiB to match documentation, fixing:
https://bugzilla.redhat.com/show_bug.cgi?id=1015689
---
v1: https://www.redhat.com/archives/libvir-list/2013-October/msg00361.html
v2: keeps the output unit KiB
changes the default input unit to KiB
accepts 'units' as well as 'unit' in input XML
docs/formatdomain.html.in | 6 ++--
docs/schemas/domaincommon.rng | 5 ++++
src/conf/domain_conf.c | 12 ++++++--
src/lxc/lxc_container.c | 2 +-
tests/domainschematest | 2 +-
tests/lxcxml2xmldata/lxc-filesystem-ram.xml | 41 ++++++++++++++++++++++++++
tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml | 41 ++++++++++++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
8 files changed, 103 insertions(+), 7 deletions(-)
create mode 100644 tests/lxcxml2xmldata/lxc-filesystem-ram.xml
create mode 100644 tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3689399..dfd11bf 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2213,7 +2213,8 @@
<dd>
An in-memory filesystem, using memory from the host OS.
The source element has a single attribute <code>usage</code>
- which gives the memory usage limit in kibibytes. Only used
+ which gives the memory usage limit in KiB, unless units
+ are specified by the <code>unit</code> attribute. Only used
by LXC driver.
<span class="since"> (since 0.9.13)</span></dd>
<dt><code>type='bind'</code></dt>
@@ -2279,7 +2280,8 @@
<code>name</code> attribute must be used with
<code>type='template'</code>, and the <code>dir</code> attribute must
be used with <code>type='mount'</code>. The <code>usage</code> attribute
- is used with <code>type='ram'</code> to set the memory limit in KB.
+ is used with <code>type='ram'</code> to set the memory limit KiB, unless
+ units are specified by the <code>unit</code> attribute.
</dd>
<dt><code>target</code></dt>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5c5301d..582d4c3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1736,6 +1736,11 @@
<ref name='unit'/>
</attribute>
</optional>
+ <optional>
+ <attribute name='units'>
+ <ref name='unit'/>
+ </attribute>
+ </optional>
<empty/>
</element>
</interleave>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0d63845..0870047 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5917,6 +5917,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
char *wrpolicy = NULL;
char *usage = NULL;
char *unit = NULL;
+ char *units = NULL;
ctxt->node = node;
@@ -5973,6 +5974,7 @@ virDomainFSDefParseXML(xmlNodePtr node,
else if (def->type == VIR_DOMAIN_FS_TYPE_RAM) {
usage = virXMLPropString(cur, "usage");
unit = virXMLPropString(cur, "unit");
+ units = virXMLPropString(cur, "units");
}
} else if (!target &&
xmlStrEqual(cur->name, BAD_CAST "target")) {
@@ -6042,8 +6044,11 @@ virDomainFSDefParseXML(xmlNodePtr node,
usage);
goto error;
}
- if (unit &&
- virScaleInteger(&def->usage, unit,
+ /* Older libvirt only parsed 'unit' here, despite
+ * printing it in the 'units' attribute.
+ *
+ * The default was bytes when 'unit' wasn't present */
+ if (virScaleInteger(&def->usage, units ? units : unit,
1024, ULLONG_MAX) < 0)
goto error;
}
@@ -6066,6 +6071,7 @@ cleanup:
VIR_FREE(wrpolicy);
VIR_FREE(usage);
VIR_FREE(unit);
+ VIR_FREE(units);
VIR_FREE(format);
return def;
@@ -14764,7 +14770,7 @@ virDomainFSDefFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_FS_TYPE_RAM:
- virBufferAsprintf(buf, " <source usage='%lld' units='KiB'/>\n",
+ virBufferAsprintf(buf, " <source usage='%lld' unit='KiB'/>\n",
def->usage / 1024);
break;
}
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index b1f429c..7c722cc 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1428,7 +1428,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
VIR_DEBUG("usage=%lld sec=%s", fs->usage, sec_mount_options);
if (virAsprintf(&data,
- "size=%lldk%s", fs->usage, sec_mount_options) < 0)
+ "size=%lld%s", fs->usage, sec_mount_options) < 0)
goto cleanup;
if (virFileMakePath(fs->dst) < 0) {
diff --git a/tests/domainschematest b/tests/domainschematest
index 0e360ca..9ebf0b9 100755
--- a/tests/domainschematest
+++ b/tests/domainschematest
@@ -7,7 +7,7 @@
DIRS=""
DIRS="$DIRS domainschemadata qemuxml2argvdata sexpr2xmldata"
DIRS="$DIRS xmconfigdata xml2sexprdata qemuxml2xmloutdata "
-DIRS="$DIRS lxcxml2xmldata"
+DIRS="$DIRS lxcxml2xmldata lxcxml2xmloutdata"
SCHEMA="domain.rng"
check_schema "$DIRS" "$SCHEMA"
diff --git a/tests/lxcxml2xmldata/lxc-filesystem-ram.xml b/tests/lxcxml2xmldata/lxc-filesystem-ram.xml
new file mode 100644
index 0000000..4b2abb5
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-filesystem-ram.xml
@@ -0,0 +1,41 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/sh</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='ram'>
+ <source usage='1048576'/>
+ <target dir='/mnt/mississippi'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1048576' unit='bytes'/>
+ <target dir='/mnt/titicaca'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1024' unit='KiB'/>
+ <target dir='/mnt/orinoco'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1048576' units='bytes'/>
+ <target dir='/mnt/antananarivo'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1024' units='KiB'/>
+ <target dir='/mnt/ouagadougou'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml b/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
new file mode 100644
index 0000000..65d07dd
--- /dev/null
+++ b/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
@@ -0,0 +1,41 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/sh</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1048576' unit='KiB'/>
+ <target dir='/mnt/mississippi'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1024' unit='KiB'/>
+ <target dir='/mnt/titicaca'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1024' unit='KiB'/>
+ <target dir='/mnt/orinoco'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1024' unit='KiB'/>
+ <target dir='/mnt/antananarivo'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1024' unit='KiB'/>
+ <target dir='/mnt/ouagadougou'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 5846ab0..1692e4b 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -136,6 +136,7 @@ mymain(void)
DO_TEST("systemd");
DO_TEST("hostdev");
DO_TEST("disk-formats");
+ DO_TEST_DIFFERENT("filesystem-ram");
virObjectUnref(caps);
virObjectUnref(xmlopt);
--
1.8.1.5
11 years, 1 month
[libvirt] [PATCH 0/3] qemu:Allow users specify -incoming listen address
by Michal Privoznik
However, if user provides a wrong address, the libvirtd dies horribly:
Core was generated by `/home/zippy/tmp/libvirt.git/daemon/.libs/libvirtd --listen'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f5c3859a7fc in qemuProcessHandleMonitorEOF (mon=0x7f5c24001870, vm=0x7f5c24001fa0, opaque=0x7f5c300c8600) at qemu/qemu_process.c:300
300 if (priv->beingDestroyed) {
(gdb) p priv
$1 = (qemuDomainObjPrivatePtr) 0x0
(gdb) p vm
$2 = (virDomainObjPtr) 0x7f5c24001fa0
This is supposed to be fixed by my patch:
https://www.redhat.com/archives/libvir-list/2013-October/msg00347.html
Michal Privoznik (3):
Migration: Introduce VIR_MIGRATE_PARAM_LISTEN_ADDRESS
qemu: Implement support for VIR_MIGRATE_PARAM_LISTEN_ADDRESS
qemu_conf: Introduce "listen_address"
include/libvirt/libvirt.h.in | 10 ++++
src/qemu/libvirtd_qemu.aug | 3 ++
src/qemu/qemu.conf | 6 +++
src/qemu/qemu_conf.c | 2 +
src/qemu/qemu_conf.h | 2 +
src/qemu/qemu_driver.c | 33 +++++++++----
src/qemu/qemu_migration.c | 98 +++++++++++++++++++++++++++-----------
src/qemu/qemu_migration.h | 13 +++--
src/qemu/test_libvirtd_qemu.aug.in | 1 +
tools/virsh-domain.c | 11 +++++
tools/virsh.pod | 10 +++-
11 files changed, 146 insertions(+), 43 deletions(-)
--
1.8.1.5
11 years, 1 month
[libvirt] [PATCH] LXC: Fix the output units of ram filesystem size
by Ján Tomko
Commit 76b644c added support for adding RAM filesystems to LXC
domains, with a syntax of:
<source usage='10' unit='MiB'/>
where default unit would be KiB per documentation, however the
XML parser treated sizes without units as bytes.
When formatting the XML, this was divided by 1024, but the KiB units
were put inside the 'units' attribute, as opposed to the 'unit'
attribute the parser looks for.
The code generating the mount options assumed the size in the domain
definition to be in KiB, despite it being parsed as B. This worked
as long as exaclty one re-format of the XML happened (for domains that
were just created).
Change the XML output to bytes and fix the documentation.
https://bugzilla.redhat.com/show_bug.cgi?id=1015689
---
docs/formatdomain.html.in | 5 ++--
src/conf/domain_conf.c | 4 ++--
src/lxc/lxc_container.c | 2 +-
tests/lxcxml2xmldata/lxc-filesystem-ram.xml | 33 ++++++++++++++++++++++++++
tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml | 33 ++++++++++++++++++++++++++
tests/lxcxml2xmltest.c | 1 +
6 files changed, 73 insertions(+), 5 deletions(-)
create mode 100644 tests/lxcxml2xmldata/lxc-filesystem-ram.xml
create mode 100644 tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 3689399..bfe0ae4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2213,7 +2213,8 @@
<dd>
An in-memory filesystem, using memory from the host OS.
The source element has a single attribute <code>usage</code>
- which gives the memory usage limit in kibibytes. Only used
+ which gives the memory usage limit in bytes, unless units
+ are specified by the attribute <code>unit</code>. Only used
by LXC driver.
<span class="since"> (since 0.9.13)</span></dd>
<dt><code>type='bind'</code></dt>
@@ -2279,7 +2280,7 @@
<code>name</code> attribute must be used with
<code>type='template'</code>, and the <code>dir</code> attribute must
be used with <code>type='mount'</code>. The <code>usage</code> attribute
- is used with <code>type='ram'</code> to set the memory limit in KB.
+ is used with <code>type='ram'</code> to set the memory limit in bytes.
</dd>
<dt><code>target</code></dt>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0d63845..2c67966 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14764,8 +14764,8 @@ virDomainFSDefFormat(virBufferPtr buf,
break;
case VIR_DOMAIN_FS_TYPE_RAM:
- virBufferAsprintf(buf, " <source usage='%lld' units='KiB'/>\n",
- def->usage / 1024);
+ virBufferAsprintf(buf, " <source usage='%lld' unit='B'/>\n",
+ def->usage);
break;
}
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index b1f429c..7c722cc 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1428,7 +1428,7 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
VIR_DEBUG("usage=%lld sec=%s", fs->usage, sec_mount_options);
if (virAsprintf(&data,
- "size=%lldk%s", fs->usage, sec_mount_options) < 0)
+ "size=%lld%s", fs->usage, sec_mount_options) < 0)
goto cleanup;
if (virFileMakePath(fs->dst) < 0) {
diff --git a/tests/lxcxml2xmldata/lxc-filesystem-ram.xml b/tests/lxcxml2xmldata/lxc-filesystem-ram.xml
new file mode 100644
index 0000000..404429b
--- /dev/null
+++ b/tests/lxcxml2xmldata/lxc-filesystem-ram.xml
@@ -0,0 +1,33 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/sh</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='ram'>
+ <source usage='1048576'/>
+ <target dir='/mnt/mississippi'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1048576' unit='b'/>
+ <target dir='/mnt/titicaca'/>
+ </filesystem>
+ <filesystem type='ram'>
+ <source usage='1024' unit='KiB'/>
+ <target dir='/mnt/orinoco'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml b/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
new file mode 100644
index 0000000..431b8cb
--- /dev/null
+++ b/tests/lxcxml2xmloutdata/lxc-filesystem-ram.xml
@@ -0,0 +1,33 @@
+<domain type='lxc'>
+ <name>demo</name>
+ <uuid>8369f1ac-7e46-e869-4ca5-759d51478066</uuid>
+ <memory unit='KiB'>500000</memory>
+ <currentMemory unit='KiB'>500000</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64'>exe</type>
+ <init>/bin/sh</init>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/libexec/libvirt_lxc</emulator>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1048576' unit='B'/>
+ <target dir='/mnt/mississippi'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1048576' unit='B'/>
+ <target dir='/mnt/titicaca'/>
+ </filesystem>
+ <filesystem type='ram' accessmode='passthrough'>
+ <source usage='1048576' unit='B'/>
+ <target dir='/mnt/orinoco'/>
+ </filesystem>
+ <console type='pty'>
+ <target type='lxc' port='0'/>
+ </console>
+ </devices>
+</domain>
diff --git a/tests/lxcxml2xmltest.c b/tests/lxcxml2xmltest.c
index 5846ab0..1692e4b 100644
--- a/tests/lxcxml2xmltest.c
+++ b/tests/lxcxml2xmltest.c
@@ -136,6 +136,7 @@ mymain(void)
DO_TEST("systemd");
DO_TEST("hostdev");
DO_TEST("disk-formats");
+ DO_TEST_DIFFERENT("filesystem-ram");
virObjectUnref(caps);
virObjectUnref(xmlopt);
--
1.8.1.5
11 years, 1 month
[libvirt] [PATCH] storage: Use bool instead of int
by Ján Tomko
Commit 532fef3 added two-state 'need_alloc' and exposed
'want_sparse' which also only has two states.
Change their type from int to bool.
---
src/storage/storage_backend.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 662af32..4eec0f3 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -129,7 +129,7 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol,
int fd,
unsigned long long *total,
- int want_sparse)
+ bool want_sparse)
{
int inputfd = -1;
int amtread = -1;
@@ -270,7 +270,7 @@ virStorageBackendCreateBlockFrom(virConnectPtr conn ATTRIBUTE_UNUSED,
if (inputvol) {
int res = virStorageBackendCopyToFD(vol, inputvol,
- fd, &remain, 0);
+ fd, &remain, false);
if (res < 0)
goto cleanup;
}
@@ -315,7 +315,7 @@ static int
createRawFile(int fd, virStorageVolDefPtr vol,
virStorageVolDefPtr inputvol)
{
- int need_alloc = 1;
+ bool need_alloc = true;
int ret = 0;
unsigned long long remain;
@@ -338,7 +338,7 @@ createRawFile(int fd, virStorageVolDefPtr vol,
* available, and since we're going to copy data from another
* file it doesn't make sense to write the file twice. */
if (fallocate(fd, 0, 0, vol->allocation) == 0) {
- need_alloc = 0;
+ need_alloc = false;
} else if (errno != ENOSYS && errno != EOPNOTSUPP) {
ret = -errno;
virReportSystemError(errno,
@@ -354,8 +354,8 @@ createRawFile(int fd, virStorageVolDefPtr vol,
/* allow zero blocks to be skipped if we've requested sparse
* allocation (allocation < capacity) or we have already
* been able to allocate the required space. */
- int want_sparse = (need_alloc == 0) ||
- (vol->allocation < inputvol->capacity);
+ bool want_sparse = !need_alloc ||
+ (vol->allocation < inputvol->capacity);
ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse);
if (ret < 0) {
--
1.8.1.5
11 years, 1 month
[libvirt] [PATCH 0/2] change the minimum blkio weight according to kernel version
by Chen Hanxiao
From: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
Since 2.6.39, kernel changed the minimum weight of device blkio.
We need to follow them according to different kernel version.
Chen Hanxiao (2):
[libvirt][PATCH]cgroup: introduce kernel version check function for
cgroup
[libvirt][PATCH]blkio: change the minimum weight according to kernel
version
src/util/vircgroup.c | 76 ++++++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 65 insertions(+), 11 deletions(-)
--
1.8.2.1
11 years, 1 month