[libvirt] [PATCH 0/4] support for QEMU vhost-user
by Michele Paolino
This series adds support for the QEMU vhost-user feature to libvirt.
vhost-user enables the communication between a QEMU virtual machine
and other userspace process using the Virtio transport protocol.
It uses a char dev (e.g. Unix socket) for the control plane,
while the data plane based on shared memory.
The XML looks like:
<interface type='vhostuser'>
<source type='unix' path='/tmp/vhost.sock' mode='server'/>
<mac address='52:54:00:3b:83:1a'/>
<model type='virtio'/>
</interface>
Our use case is the deployment of Snabbswitch in an OpenStack/NFV
environment. Snabbswitch uses a Unix socket to implement the
vhost-user control plane, thus we focused on the support for the
type=unix attribute of the <source> element.
To test it with Snabbswitch, it is necessary to apply the
following patches (respectively from Chen Fan and Michele Paolino):
http://www.redhat.com/archives/libvir-list/2014-June/msg01195.html
http://www.redhat.com/archives/libvir-list/2014-June/msg01418.html
It is also possible to directly checkout the Virtual Open Systems'
libvirt repository(branch "vhost-user_support) at the address:
https://github.com/virtualopensystems/libvirt.
This patch is based on the previous work from Luke Gorrie:
http://www.redhat.com/archives/libvir-list/2014-May/msg00934.html
Michele Paolino (4):
vhost-user support: domain configuration
vhost-user support: qemu command-line
vhost-user support: tests and docs
vhost-user support: lxc,xenxs,uml
docs/formatdomain.html.in | 34 +++++++++
docs/schemas/domaincommon.rng | 39 +++++++++++
src/conf/domain_conf.c | 81 ++++++++++++++++++++++
src/conf/domain_conf.h | 10 ++-
src/lxc/lxc_process.c | 1 +
src/qemu/qemu_command.c | 58 ++++++++++++++++
src/uml/uml_conf.c | 5 ++
src/xenxs/xen_sxpr.c | 1 +
.../qemuxml2argv-net-vhostuser.args | 7 ++
.../qemuxml2argv-net-vhostuser.xml | 33 +++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
12 files changed, 269 insertions(+), 2 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
--
1.9.3
10 years, 4 months
[libvirt] [PATCH v2 0/4] Couple of seclabels improvements
by Michal Privoznik
diff to v1:
- rework the 3rd patch
- introduce one more bugfix
Michal Privoznik (4):
virSecurityLabelDef: substitute 'norelabel' with 'relabel'
virSecurityDeviceLabelDef: substitute 'norelabel' with 'relabel'
conf: Always format seclabel's model
conf: Don't allow multiple seclabels for same model
src/conf/domain_conf.c | 67 ++++++++++++----------
src/security/security_apparmor.c | 10 ++--
src/security/security_dac.c | 22 +++----
src/security/security_manager.c | 2 +-
src/security/security_selinux.c | 32 +++++------
src/util/virseclabel.c | 2 +-
src/util/virseclabel.h | 4 +-
.../qemuxml2argv-seclabel-dynamic-none.xml | 28 +++++++++
.../qemuxml2argv-seclabel-multiple.xml | 40 +++++++++++++
tests/qemuxml2argvtest.c | 1 +
tests/qemuxml2xmltest.c | 1 +
11 files changed, 142 insertions(+), 67 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-seclabel-dynamic-none.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-seclabel-multiple.xml
--
1.8.5.5
10 years, 4 months
[libvirt] [PATCH 0/3] storage: Fix operations working with local storage only
by Peter Krempa
Peter Krempa (3):
conf: storage: Add helper to determine whether storage vol is local
storage: wipe: Don't attempt to wipe remote storage
storage: Split out volume upload/download as separate backend function
src/conf/storage_conf.c | 19 +++++++++++++
src/conf/storage_conf.h | 2 ++
src/libvirt_private.syms | 1 +
src/storage/storage_backend.c | 31 ++++++++++++++++++++
src/storage/storage_backend.h | 30 ++++++++++++++++++++
src/storage/storage_backend_disk.c | 2 ++
src/storage/storage_backend_fs.c | 7 +++++
src/storage/storage_backend_iscsi.c | 2 ++
src/storage/storage_backend_logical.c | 2 ++
src/storage/storage_backend_mpath.c | 2 ++
src/storage/storage_backend_scsi.c | 2 ++
src/storage/storage_driver.c | 53 ++++++++++++++---------------------
12 files changed, 121 insertions(+), 32 deletions(-)
--
2.0.0
10 years, 4 months
[libvirt] [PATCH v2] LXC: add support for --config in setmem command
by Chen Hanxiao
In lxc, we could not use setmem command
with --config options.
This patch will add support for this.
Signed-off-by: Chen Hanxiao <chenhanxiao(a)cn.fujitsu.com>
---
v2: use virDomainSetMemoryFlagsEnsureACL
remove redundant domain running check
src/lxc/lxc_driver.c | 48 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 37 insertions(+), 11 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index b47ac5e..93f496b 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -711,18 +711,33 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
return ret;
}
-static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
+static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
+ unsigned int flags)
{
virDomainObjPtr vm;
+ virDomainDefPtr persistentDef = NULL;
+ virCapsPtr caps = NULL;
int ret = -1;
virLXCDomainObjPrivatePtr priv;
+ virLXCDriverPtr driver = dom->conn->privateData;
+ virLXCDriverConfigPtr cfg = NULL;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG, -1);
if (!(vm = lxcDomObjFromDomain(dom)))
goto cleanup;
priv = vm->privateData;
- if (virDomainSetMemoryEnsureACL(dom->conn, vm->def) < 0)
+ if (virDomainSetMemoryFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
+ goto cleanup;
+
+ if (!(caps = virLXCDriverGetCapabilities(driver, false)))
+ goto cleanup;
+
+ if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt, vm, &flags,
+ &persistentDef) < 0)
goto cleanup;
if (newmem > vm->def->mem.max_balloon) {
@@ -731,16 +746,19 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
goto cleanup;
}
- if (!virDomainObjIsActive(vm)) {
- virReportError(VIR_ERR_OPERATION_INVALID,
- "%s", _("Domain is not running"));
- goto cleanup;
- }
+ if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ cfg = virLXCDriverGetConfig(driver);
+ persistentDef->mem.cur_balloon = newmem;
+ if (virDomainSaveConfig(cfg->configDir, persistentDef) < 0)
+ goto cleanup;
+ }
- if (virCgroupSetMemory(priv->cgroup, newmem) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED,
- "%s", _("Failed to set memory for domain"));
- goto cleanup;
+ if (flags & VIR_DOMAIN_AFFECT_LIVE) {
+ if (virCgroupSetMemory(priv->cgroup, newmem) < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("Failed to set memory for domain"));
+ goto cleanup;
+ }
}
ret = 0;
@@ -748,9 +766,16 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
cleanup:
if (vm)
virObjectUnlock(vm);
+ virObjectUnref(caps);
+ virObjectUnref(cfg);
return ret;
}
+static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
+{
+ return lxcDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_AFFECT_LIVE);
+}
+
static int
lxcDomainSetMemoryParameters(virDomainPtr dom,
virTypedParameterPtr params,
@@ -5697,6 +5722,7 @@ static virDriver lxcDriver = {
.domainGetMaxMemory = lxcDomainGetMaxMemory, /* 0.7.2 */
.domainSetMaxMemory = lxcDomainSetMaxMemory, /* 0.7.2 */
.domainSetMemory = lxcDomainSetMemory, /* 0.7.2 */
+ .domainSetMemoryFlags = lxcDomainSetMemoryFlags, /* 1.2.7 */
.domainSetMemoryParameters = lxcDomainSetMemoryParameters, /* 0.8.5 */
.domainGetMemoryParameters = lxcDomainGetMemoryParameters, /* 0.8.5 */
.domainSetBlkioParameters = lxcDomainSetBlkioParameters, /* 0.9.8 */
--
1.9.0
10 years, 4 months
[libvirt] Bug: iohelper drops I/O error messages
by Jason J. Herne
During a recent managed save operation I received the following error
message:
error: operation failed: domain save job: unexpectedly failed.
It turns out that I had run out of disk space. After a brief investigation I
discovered that libvirt_iohelper is exec'ed and is used to handle all
I/O during
a (Qemu) managed save operation. While iohelper appears to be set up to log
error conditions when they occur, for some reason the logging is getting
lost.
I'm hoping someone can help figure out why these errors are getting lost. It
would be nice to present a useful error message to the user when a
managed save
fails because of an I/O error.
I was able to work around this problem with a patch that bypasses iohelper
entirely but I doubt that is really the best thing to do. Does anyone
know why
these error messages are getting suppressed?
10 years, 4 months
[libvirt] [PATCHv5 0/4] Outline of rewriting vbox Driver
by Taowei
Fix some problems in last patch. Includes:
* Re-manage the patches in a better order, move some symbol definitions into the proper patch.
* Make the API in vboxUniformedAPI hierarchical. So when more apis introduced into the
uniformed api, it wouldn't go to a mess.
* Rewrite the vboxDomainSave in a better way.
Taowei (4):
Define vboxUniformedAPI
Implement vboxInitialize and vboxDomainSave
Implement uniformed api for each vbox version
Install vboxUniformedAPI
po/POTFILES.in | 1 +
src/Makefile.am | 4 +-
src/vbox/vbox_common.c | 183 +++++++++++++++
src/vbox/vbox_common.h | 151 ++++++++++++
src/vbox/vbox_driver.c | 22 +-
src/vbox/vbox_tmpl.c | 504 ++++++++++++++++++++++++-----------------
src/vbox/vbox_uniformed_api.h | 211 +++++++++++++++++
7 files changed, 868 insertions(+), 208 deletions(-)
create mode 100644 src/vbox/vbox_common.c
create mode 100644 src/vbox/vbox_common.h
create mode 100644 src/vbox/vbox_uniformed_api.h
--
1.7.9.5
10 years, 4 months
[libvirt] [PATCH V2] storagevol: add nocow to vol xml
by Chunyan Liu
Add 'nocow' to storage volume xml so that user can have an option
to set NOCOW flag to the newly created volume. It's useful on btrfs
file system to enhance performance.
Btrfs has low performance when hosting VM images, even more when the guest
in those VM are also using btrfs as file system. One way to mitigate this
bad performance is to turn off COW attributes on VM files. Generally, there
are two ways to turn off NOCOW on btrfs: a) by mounting fs with nodatacow,
then all newly created files will be NOCOW. b) per file. Add the NOCOW file
attribute. It could only be done to empty or new files.
This patch tries the second way, according to 'nocow' option, it could set
NOCOW flag per file:
for raw file images, handle 'nocow' in libvirt code; for non-raw file images,
pass 'nocow=on' option to qemu-img, and let qemu-img to handle that (requires
qemu-img version >= 2.1).
Signed-off-by: Chunyan Liu <cyliu(a)suse.com>
---
Changes:
- now qemu-img can handle 'nocow=on' option, just pass 'nocow=on' to
qemu-img for non-raw file images. No need to handle all file type
in libvirt code.
Pervious version is here:
http://www.redhat.com/archives/libvir-list/2013-December/msg01257.html
---
docs/formatstorage.html.in | 7 +++++++
docs/schemas/storagevol.rng | 5 +++++
src/conf/storage_conf.c | 3 +++
src/storage/storage_backend.c | 22 ++++++++++++++++++++++
src/util/virstoragefile.h | 1 +
5 files changed, 38 insertions(+)
diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 1cd82b4..e8862bf 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -385,6 +385,7 @@
<label>virt_image_t</label>
</permissions>
<compat>1.1</compat>
+ <nocow/>
<features>
<lazy_refcounts/>
</features>
@@ -424,6 +425,12 @@
1.1 is used. If omitted, qemu-img default is used.
<span class="since">Since 1.1.0</span>
</dd>
+ <dt><code>nocow</code></dt>
+ <dd>Turn off COW of the newly created volume. So far, this is only valid
+ to a file image in btrfs file system. It will improve performance when
+ the file image is used in VM. To create non-raw file images, it
+ requires QEMU version since 2.1. <span class="since">Since 1.2.6</span>
+ </dd>
<dt><code>features</code></dt>
<dd>Format-specific features. Only used for <code>qcow2</code> now.
Valid sub-elements are:
diff --git a/docs/schemas/storagevol.rng b/docs/schemas/storagevol.rng
index 3798476..1b2d4cc 100644
--- a/docs/schemas/storagevol.rng
+++ b/docs/schemas/storagevol.rng
@@ -138,6 +138,11 @@
<ref name='compat'/>
</optional>
<optional>
+ <element name='nocow'>
+ <empty/>
+ </element>
+ </optional>
+ <optional>
<ref name='fileFormatFeatures'/>
</optional>
</interleave>
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 9ac5975..77ea23e 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1285,6 +1285,9 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
virStringFreeList(version);
}
+ if (virXPathNode("./target/nocow", ctxt))
+ ret->target.nocow = true;
+
if (options->featureFromString && virXPathNode("./target/features", ctxt)) {
if ((n = virXPathNodeSet("./target/features/*", ctxt, &nodes)) < 0)
goto error;
diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index e83a108..80347de 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -37,6 +37,9 @@
#ifdef __linux__
# include <sys/ioctl.h>
# include <linux/fs.h>
+# ifndef FS_NOCOW_FL
+# define FS_NOCOW_FL 0x00800000 /* Do not cow file */
+# endif
#endif
#if WITH_SELINUX
@@ -452,6 +455,21 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
goto cleanup;
}
+ if (vol->target.nocow) {
+#ifdef __linux__
+ int attr;
+
+ /* Set NOCOW flag. This is an optimisation for btrfs.
+ * The FS_IOC_SETFLAGS ioctl return value will be ignored since any
+ * failure of this operation should not block the left work.
+ */
+ if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
+ attr |= FS_NOCOW_FL;
+ ioctl(fd, FS_IOC_SETFLAGS, &attr);
+ }
+#endif
+ }
+
if ((ret = createRawFile(fd, vol, inputvol)) < 0)
/* createRawFile already reported the exact error. */
ret = -1;
@@ -717,6 +735,7 @@ virStorageBackendCreateQemuImgOpts(char **opts,
bool preallocate,
int format,
const char *compat,
+ bool nocow,
virBitmapPtr features)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -729,6 +748,8 @@ virStorageBackendCreateQemuImgOpts(char **opts,
virBufferAddLit(&buf, "encryption=on,");
if (preallocate)
virBufferAddLit(&buf, "preallocation=metadata,");
+ if (nocow)
+ virBufferAddLit(&buf, "nocow=on,");
if (compat)
virBufferAsprintf(&buf, "compat=%s,", compat);
@@ -948,6 +969,7 @@ virStorageBackendCreateQemuImgCmd(virConnectPtr conn,
do_encryption, preallocate,
vol->target.format,
compat,
+ vol->target.nocow,
vol->target.features) < 0) {
virCommandFree(cmd);
return NULL;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 4f7357b..baaa42a 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -247,6 +247,7 @@ struct _virStorageSource {
* pool-specific enum for storage volumes */
virBitmapPtr features;
char *compat;
+ bool nocow;
virStoragePermsPtr perms;
virStorageTimestampsPtr timestamps;
--
1.8.4.5
10 years, 4 months
[libvirt] [PATCH] build: package .pc files for mingw64
by Eric Blake
Commit 65d8c92a fixed the mingw spec file for 32-bit builds,
but forgot to make the adjustment for 64-bit builds:
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/eblake/rpmbuild/BUILDROOT/mingw-libvirt-1.2.7-1.fc20.eblake1404944503.x86_64
error: Installed (but unpackaged) file(s) found:
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/libvirt-lxc.pc
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig/libvirt-qemu.pc
* mingw-libvirt.spec.in (%files): List missing .pc files.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule, since I detected it via
./autobuild.sh. Also backporting to v1.2.6-maint.
mingw-libvirt.spec.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mingw-libvirt.spec.in b/mingw-libvirt.spec.in
index a555f9c..a1e58cb 100644
--- a/mingw-libvirt.spec.in
+++ b/mingw-libvirt.spec.in
@@ -258,6 +258,8 @@ rm -rf $RPM_BUILD_ROOT%{mingw64_libexecdir}/libvirt-guests.sh
%{mingw64_libdir}/libvirt.dll.a
%{mingw64_libdir}/pkgconfig/libvirt.pc
+%{mingw64_libdir}/pkgconfig/libvirt-qemu.pc
+%{mingw64_libdir}/pkgconfig/libvirt-lxc.pc
%{mingw64_libdir}/libvirt-lxc.dll.a
%{mingw64_libdir}/libvirt-qemu.dll.a
--
1.9.3
10 years, 4 months
[libvirt] [PATCH] build: fix gnulib build for mingw
by Eric Blake
Pavel flagged a build regression under mingw, and traced it to a
recent flaw in gnulib for working around nl_langinfo. This picks
up the fix.
* gnulib: Update to latest, for mingw build fixes.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
Pushing under the build-breaker rule
* .gnulib 9d5efe7...2d28074 (2):
> nl_langinfo: fix build under mingw
> mountlist: do not classify a bind-mounted dir entry as "dummy"
.gnulib | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gnulib b/.gnulib
index 9d5efe7..2d28074 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 9d5efe7d61e1d96a6d7c97ffa4d21c5e33e9bd30
+Subproject commit 2d280742a9e30088aa169f53353765d5daafe4c0
--
1.9.3
10 years, 4 months
[libvirt] [PATCH v3] libxl: add discard support to libxl_device_disk
by Olaf Hering
Translate libvirt discard settings into libxl-4.5 discard settings.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
v3:
passing discard= with old libxl is now a fatal error
v2:
add cast to switch variable to let compiler check if the code handles
all enum values
src/libxl/libxl_conf.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 8eeaf82..538cfa4 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -715,6 +715,35 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
return -1;
}
+static int
+libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
+{
+ if (!x_disk->readwrite)
+ return 0;
+#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
+ switch ((enum virDomainDiskDiscard)discard) {
+ case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
+ case VIR_DOMAIN_DISK_DISCARD_LAST:
+ break;
+ case VIR_DOMAIN_DISK_DISCARD_UNMAP:
+ libxl_defbool_set(&x_disk->discard_enable, true);
+ break;
+ case VIR_DOMAIN_DISK_DISCARD_IGNORE:
+ libxl_defbool_set(&x_disk->discard_enable, false);
+ break;
+ }
+ return 0;
+#else
+ if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
+ return 0;
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("This version of libxenlight does not support "
+ "disk 'discard' option passing"));
+ return -1;
+#endif
+}
+
+
int
libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
{
@@ -829,6 +858,8 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
x_disk->removable = 1;
x_disk->readwrite = !l_disk->readonly;
x_disk->is_cdrom = l_disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
+ if (libxlDiskSetDiscard(x_disk, l_disk->discard) < 0)
+ return -1;
/* An empty CDROM must have the empty format, otherwise libxl fails. */
if (x_disk->is_cdrom && !x_disk->pdev_path)
x_disk->format = LIBXL_DISK_FORMAT_EMPTY;
10 years, 4 months