[libvirt PATCH] meson: add -Wformat explicitly
by Pavel Hrdina
If someone runs `meson setup --buildtype plain` meson ignores
warning_level=2 that is in our meson.build file. The implication is
that Meson will not automatically add -Wall which enables -Wformat.
This breaks building libvirt from git with the buildtype set to plain.
There is an issue reported [1] to not ignore warning_level silently
and the change to ignore it was done by upstream commit [2].
[1] <https://github.com/mesonbuild/meson/issues/7399>
[2] <https://github.com/mesonbuild/meson/commit/8ee1c9a07a3a35e3ed262fbc358fd8...>
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
meson.build | 1 +
1 file changed, 1 insertion(+)
diff --git a/meson.build b/meson.build
index e193166a9b..4e99b5ba39 100644
--- a/meson.build
+++ b/meson.build
@@ -257,6 +257,7 @@ cc_flags += [
'-Wempty-body',
'-Wendif-labels',
'-Wexpansion-to-defined',
+ '-Wformat',
'-Wformat-contains-nul',
'-Wformat-extra-args',
'-Wformat-nonliteral',
--
2.26.2
4 years, 2 months
[PATCH] nss: Finish renaming of HAVE_BSD_NSS macro
by Michal Privoznik
When switching to meson, some of HAVE_* macros were renamed to
WITH_ because they did not reflect whether the build platform has
or doesn't have something, but whether we are building with some
functionality turned on or off. This is the case with
HAVE_BSD_NSS macro too. As a result, the NSS plugin built on BSD
did not expose nss_module_register() function which made the
plugin unusable:
https://www.redhat.com/archives/libvir-list/2020-September/msg00000.html
Fixes: c74268705557a6781788ba011492c15df2e3df11
Reported-by: Roman Bogorodskiy <bogorodskiy(a)gmail.com>
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/nss/libvirt_nss.c | 6 +++---
tools/nss/libvirt_nss.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 3b89f72742..6331c65131 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -37,7 +37,7 @@
#include <time.h>
-#if defined(HAVE_BSD_NSS)
+#if defined(WITH_BSD_NSS)
# include <nsswitch.h>
#endif
@@ -451,7 +451,7 @@ NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
}
#endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
-#if defined(HAVE_BSD_NSS)
+#if defined(WITH_BSD_NSS)
NSS_METHOD_PROTOTYPE(_nss_compat_getaddrinfo);
NSS_METHOD_PROTOTYPE(_nss_compat_gethostbyname2_r);
@@ -598,4 +598,4 @@ nss_module_register(const char *name __attribute__((unused)),
*unregister = NULL;
return methods;
}
-#endif /* HAVE_BSD_NSS */
+#endif /* WITH_BSD_NSS */
diff --git a/tools/nss/libvirt_nss.h b/tools/nss/libvirt_nss.h
index 95ebafdc71..121b9e8722 100644
--- a/tools/nss/libvirt_nss.h
+++ b/tools/nss/libvirt_nss.h
@@ -84,8 +84,8 @@ NSS_NAME(gethostbyname4)(const char *name, struct gaih_addrtuple **pat,
int *herrnop, int32_t *ttlp);
#endif /* HAVE_STRUCT_GAIH_ADDRTUPLE */
-#if defined(HAVE_BSD_NSS)
+#if defined(WITH_BSD_NSS)
ns_mtab*
nss_module_register(const char *name, unsigned int *size,
nss_module_unregister_fn *unregister);
-#endif /* HAVE_BSD_NSS */
+#endif /* WITH_BSD_NSS */
--
2.26.2
4 years, 2 months
[PATCH] NVRAM: check NVRAM file size and recover from template
by Hao Wang
From: Hao Wang <wanghao232(a)huawei.com>
Subject: [PATCH] NVRAM: check NVRAM file size and recover from template
A corrupted nvram file (e.g. caused by last unsuccessful creation due to
insufficient memory) can lead to boot or migration failure.
Check the size of the existed nvram file when qemuPrepareNVRAM, and re-create
if the existed one is unhealthy.
Signed-off-by: Hao Wang <wanghao232(a)huawei.com>
---
src/qemu/qemu_process.c | 54 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 126fabf5ef..42060bb36c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4376,6 +4376,48 @@ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
}
+static bool
+qemuIsNvramFileHealthy(virQEMUDriverConfigPtr cfg,
+ virDomainLoaderDefPtr loader)
+{
+ const char *masterNvramPath;
+ off_t nvramSize;
+ off_t masterSize;
+
+ masterNvramPath = loader->templt;
+ if (!loader->templt) {
+ size_t i;
+ for (i = 0; i < cfg->nfirmwares; i++) {
+ if (STREQ(cfg->firmwares[i]->name, loader->path)) {
+ masterNvramPath = cfg->firmwares[i]->nvram;
+ break;
+ }
+ }
+ }
+
+ if (!masterNvramPath) {
+ VIR_WARN("no nvram template is found; assume the nvram file is healthy");
+ return true;
+ }
+
+ if ((nvramSize = virFileLength(loader->nvram, -1)) < 0 ||
+ (masterSize = virFileLength(masterNvramPath, -1)) < 0) {
+ virReportSystemError(errno,
+ _("unable to get the size of '%s' or '%s'"),
+ loader->nvram, masterNvramPath);
+ return false;
+ }
+
+ if (nvramSize != masterSize) {
+ VIR_WARN("the size(%zd) of the nvram file is not equal to that of the template %s",
+ nvramSize, masterNvramPath);
+ return false;
+ }
+
+ return true;
+}
+
+
static int
qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
virDomainObjPtr vm)
@@ -4388,9 +4430,19 @@ qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg,
const char *master_nvram_path;
ssize_t r;
- if (!loader || !loader->nvram || virFileExists(loader->nvram))
+ if (!loader || !loader->nvram)
return 0;
+ if (virFileExists(loader->nvram)) {
+ if (qemuIsNvramFileHealthy(cfg, loader))
+ return 0;
+
+ ignore_value(virFileRemove(loader->nvram, -1, -1));
+ VIR_WARN("the nvram file %s exists but may be corrupted! "
+ "Remove it and try to copy a new one from template.",
+ loader->nvram);
+ }
+
master_nvram_path = loader->templt;
if (!loader->templt) {
size_t i;
--
2.23.0
4 years, 2 months
[GSoC PATCH 3/9] Jailhouse driver: Implementation of ConnectGetType
by Prakhar Bansal
---
src/jailhouse/jailhouse_driver.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/jailhouse/jailhouse_driver.c b/src/jailhouse/jailhouse_driver.c
index ac9da4c85d..75bf41fc11 100644
--- a/src/jailhouse/jailhouse_driver.c
+++ b/src/jailhouse/jailhouse_driver.c
@@ -32,8 +32,10 @@
#include "viralloc.h"
#include "virfile.h"
#include "virlog.h"
+#include "virutil.h"
#include "vircommand.h"
#include "virpidfile.h"
+#include "access/viraccessapicheck.h"
#define VIR_FROM_THIS VIR_FROM_JAILHOUSE
@@ -241,16 +243,19 @@ jailhouseStateInitialize(bool privileged G_GNUC_UNUSED,
static const char *
jailhouseConnectGetType(virConnectPtr conn)
{
- UNUSED(conn);
- return NULL;
+ if (virConnectGetTypeEnsureACL(conn) < 0)
+ return NULL;
+ return "JAILHOUSE";
}
static char *
jailhouseConnectGetHostname(virConnectPtr conn)
{
- UNUSED(conn);
- return NULL;
+ if (virConnectGetHostnameEnsureACL(conn) < 0)
+ return NULL;
+
+ return virGetHostname();
}
static int
@@ -263,7 +268,7 @@ jailhouseNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info)
static int
jailhouseConnectListAllDomains(virConnectPtr conn,
- virDomainPtr ** domain, unsigned int flags)
+ virDomainPtr **domain, unsigned int flags)
{
UNUSED(conn);
UNUSED(domain);
@@ -300,7 +305,6 @@ jailhouseDomainCreate(virDomainPtr domain)
{
UNUSED(domain);
return -1;
-
}
static int
@@ -350,18 +354,18 @@ static virHypervisorDriver jailhouseHypervisorDriver = {
.connectOpen = jailhouseConnectOpen, /* 6.3.0 */
.connectClose = jailhouseConnectClose, /* 6.3.0 */
.connectListAllDomains = jailhouseConnectListAllDomains, /* 6.3.0 */
- .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
- .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
- .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
- .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
- .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
.connectGetType = jailhouseConnectGetType, /* 6.3.0 */
.connectGetHostname = jailhouseConnectGetHostname, /* 6.3.0 */
- .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
+ .domainCreate = jailhouseDomainCreate, /* 6.3.0 */
.domainShutdown = jailhouseDomainShutdown, /* 6.3.0 */
.domainDestroy = jailhouseDomainDestroy, /* 6.3.0 */
.domainGetInfo = jailhouseDomainGetInfo, /* 6.3.0 */
.domainGetState = jailhouseDomainGetState, /* 6.3.0 */
+ .domainLookupByID = jailhouseDomainLookupByID, /* 6.3.0 */
+ .domainLookupByUUID = jailhouseDomainLookupByUUID, /* 6.3.0 */
+ .domainLookupByName = jailhouseDomainLookupByName, /* 6.3.0 */
+ .domainGetXMLDesc = jailhouseDomainGetXMLDesc, /* 6.3.0 */
+ .nodeGetInfo = jailhouseNodeGetInfo, /* 6.3.0 */
};
--
2.17.1
4 years, 2 months
[PATCH libvirt-dbus 0/2] Introduce libivirt-dbus systemd unit
by Katerina Koukiou
For distributions that are using systemd introduce a
libvirt-dbus.service and have 'libvirt' group as supplementary
group for the spawned libvirt-dbus process. This will allow ubuntu
users (SocketMode is 0660 in newer ubuntu), to use system connection
without extra configuration.
Katerina Koukiou (2):
meson: generate systemd unit file for libvirt-dbus
systemd: use SupplementaryGroups=libvirt so that ubuntu users can use
the system connection
data/system/libvirt-dbus.service.in | 22 ++++++++++++++++
data/system/meson.build | 30 +++++++++++++++++-----
data/system/org.libvirt-systemd.service.in | 5 ++++
libvirt-dbus.spec.in | 4 ++-
meson.build | 12 +++++++++
meson_options.txt | 1 +
6 files changed, 67 insertions(+), 7 deletions(-)
create mode 100644 data/system/libvirt-dbus.service.in
create mode 100644 data/system/org.libvirt-systemd.service.in
--
2.26.2
4 years, 2 months
Symbol missing in nss_libvirt.so
by Roman Bogorodskiy
Hi,
I noticed that the FreeBSD version of the nss plugin misses the
'nss_module_register' symbol (which makes the plugin fail to register).
$ build/tools/nss/libnss_libvirt_impl.a
libvirt_nss.c.o:
0000000000000000 r .L.str
0000000000000020 r .L.str.1
0000000000000028 r .L.str.2
U __error
U __h_errno
U __stack_chk_fail
U __stack_chk_guard
0000000000000750 T _nss_libvirt_gethostbyname2_r
0000000000000040 T _nss_libvirt_gethostbyname3_r
0000000000000000 T _nss_libvirt_gethostbyname_r
U asprintf
U closedir
U findLeases
U free
0000000000000780 t leaseAddressSorter
U memcpy
U opendir
U qsort
U readdir
U realloc
U strcmp
U strlen
U time
libvirt_nss_leases.c.o:
0000000000000000 r .L.str
000000000000000c r .L.str.1
0000000000000017 r .L.str.2
0000000000000023 r .L.str.3
U __stack_chk_fail
U __stack_chk_guard
U close
0000000000000000 T findLeases
00000000000006e0 t findLeasesParserEndArray
0000000000000400 t findLeasesParserEndMap
0000000000000260 t findLeasesParserInteger
00000000000003c0 t findLeasesParserMapKey
00000000000006c0 t findLeasesParserStartArray
0000000000000380 t findLeasesParserStartMap
00000000000002b0 t findLeasesParserString
U free
U freeaddrinfo
U getaddrinfo
U memcpy
U open
U read
U realloc
U strcmp
U strndup
U yajl_alloc
U yajl_complete_parse
U yajl_free
U yajl_free_error
U yajl_get_error
U yajl_parse
$ nm build/tools/nss/96b7fa1@@nss_libvirt_impl(a)sta/libvirt_nss.c.o
0000000000000000 r .L.str
0000000000000020 r .L.str.1
0000000000000028 r .L.str.2
U __error
U __h_errno
U __stack_chk_fail
U __stack_chk_guard
0000000000000750 T _nss_libvirt_gethostbyname2_r
0000000000000040 T _nss_libvirt_gethostbyname3_r
0000000000000000 T _nss_libvirt_gethostbyname_r
U asprintf
U closedir
U findLeases
U free
0000000000000780 t leaseAddressSorter
U memcpy
U opendir
U qsort
U readdir
U realloc
U strcmp
U strlen
U time
$ nm build/tools/nss/nss_libvirt.so.1
0000000000004098 d _DYNAMIC
w _Jv_RegisterClasses
0000000000004018 d __CTOR_END__
0000000000004010 d __CTOR_LIST__
0000000000004028 d __DTOR_END__
0000000000004020 d __DTOR_LIST__
0000000000004030 d __JCR_LIST__
0000000000004030 d __JCR_LIST__
w __cxa_finalize
0000000000002df0 t __do_global_ctors_aux
0000000000001ee0 t __do_global_dtors_aux
0000000000005358 d __dso_handle
U __error
U __h_errno
U __stack_chk_fail
U __stack_chk_guard
0000000000002e2c t _fini
0000000000002e1c t _init
00000000000026b0 t _nss_libvirt_gethostbyname2_r
0000000000001fa0 t _nss_libvirt_gethostbyname3_r
0000000000001f60 t _nss_libvirt_gethostbyname_r
U asprintf
U close
U closedir
00000000000026f0 t findLeases
0000000000002dd0 t findLeasesParserEndArray
0000000000002af0 t findLeasesParserEndMap
0000000000002950 t findLeasesParserInteger
0000000000002ab0 t findLeasesParserMapKey
0000000000002db0 t findLeasesParserStartArray
0000000000002a70 t findLeasesParserStartMap
00000000000029a0 t findLeasesParserString
U free
U freeaddrinfo
U getaddrinfo
00000000000026e0 t leaseAddressSorter
U memcpy
U open
U opendir
U qsort
U read
U readdir
U realloc
0000000000001f30 t register_classes
U strcmp
U strlen
U strndup
U time
U yajl_alloc
U yajl_complete_parse
U yajl_free
U yajl_free_error
U yajl_get_error
U yajl_parse
WITH_BSD_NSS value is properly set:
$ grep WITH_BSD_NSS build/meson-config.h
#define WITH_BSD_NSS 1
$
Related build commands:
[526/1087] ccache cc -Itools/nss/96b7fa1@@nss_libvirt_impl@sta
-Itools/nss -I../tools/nss -Iinclude -I../include -Isrc -I../src
-Isrc/util -I../src/util -I. -I.. -I/usr/local/include/libxml2
-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include
-I/usr/local/include -Xclang -fcolor-diagnostics -pipe
-D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -O2 -g
-Werror -fno-common -W
<skip the rest of -W flags>
-fexceptions -fasynchronous-unwind-tables -fstack-protector-strong -Wdouble-promotion -Wno-unused-function -fPIC -pthread -DLIBVIRT_NSS -MD -MQ 'tools/nss/96b7fa1@@nss_libvirt_impl(a)sta/libvirt_nss.c.o' -MF 'tools/nss/96b7fa1@@nss_libvirt_impl(a)sta/libvirt_nss.c.o.d' -o 'tools/nss/96b7fa1@@nss_libvirt_impl(a)sta/libvirt_nss.c.o' -c ../tools/nss/libvirt_nss.c
[540/1087] cc -o tools/nss/nss_libvirt.so.1 -Wl,--as-needed -Wl,--allow-shlib-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,nss_libvirt.so.1 -Wl,--whole-archive tools/nss/libnss_libvirt_impl.a -Wl,--no-whole-archive -lkvm -lutil -Wl,--version-script=/usr/home/novel/code/libvirt/tools/nss/libvirt_nss_bsd.syms -Wl,-export-dynamic -Wl,-z,relro -Wl,-z,now -Wl,--no-copy-dt-needed-entries -Wl,-z,defs /usr/local/lib/libxml2.so /usr/local/lib/libglib-2.0.so /usr/local/lib/libintl.so /usr/local/lib/libgobject-2.0.so /usr/local/lib/libgio-2.0.so /usr/local/lib/libyajl.so -Wl,--end-group
[541/1087] cc -o tools/virt-admin 'tools/f9d35d4@@virt-admin(a)exe/virt-admin.c.o' 'tools/f9d35d4@@virt-admin(a)exe/virt-admin-completer.c.o' -Wl,--as-needed -Wl,--no-undefined -pie -Wl,--start-group -lkvm -lutil src/libvirt-admin.so.0.6007.0 tools/libvirt_shell.a src/libvirt.so.0.6007.0 -Wl,-z,relro -Wl,-z,now -Wl,--no-copy-dt-needed-entries -Wl,-z,defs /usr/local/lib/libxml2.so /usr/local/lib/libglib-2.0.so /usr/local/lib/libintl.so /usr/local/lib/libgobject-2.0.so /usr/local/lib/libgio-2.0.so /usr/local/lib/libreadline.so -Wl,--end-group -Wl,-z,relro -Wl,-z,now -Wl,--no-copy-dt-needed-entries -Wl,-z,defs '-Wl,-rpath,$ORIGIN/../src:$ORIGIN/' -Wl,-rpath-link,/usr/home/novel/code/libvirt/build/src -Wl,-rpath-link,/usr/home/novel/code/libvirt/build/tools
[542/1087] cc -o tools/nss/nss_libvirt_guest.so.1 -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,nss_libvirt_guest.so.1 -Wl,--whole-archive tools/nss/libnss_libvirt_guest_impl.a -Wl,--no-whole-archive -lkvm -lutil -Wl,--version-script=/usr/home/novel/code/libvirt/tools/nss/libvirt_nss_bsd.syms -Wl,-export-dynamic -Wl,-z,relro -Wl,-z,now -Wl,--no-copy-dt-needed-entries -Wl,-z,defs /usr/local/lib/libxml2.so /usr/local/lib/libglib-2.0.so /usr/local/lib/libintl.so /usr/local/lib/libgobject-2.0.so /usr/local/lib/libgio-2.0.so /usr/local/lib/libyajl.so -Wl,--end-group
Any pointers how to debug that?
Roman Bogorodskiy
4 years, 2 months
[PATCH] qemu_validate: Only allow none address for watchdog ib700
by Han Han
Since QEMU 1.5.3, the ib700 watchdog device has no options for address,
and not address in device tree:
$ /usr/libexec/qemu-kvm -version
QEMU emulator version 1.5.3 (qemu-kvm-1.5.3-175.el7), Copyright (c) 2003-2008 Fabrice Bellard
$ /usr/libexec/qemu-kvm -device ib700,\?
$ virsh qemu-monitor-command seabios --hmp info qtree|grep ib700 -A 2
dev: ib700, id "watchdog0"
dev: isa-serial, id "serial0"
index = 0
So only allow it to use none address.
https://bugzilla.redhat.com/show_bug.cgi?id=1509908
Signed-off-by: Han Han <hhan(a)redhat.com>
---
src/qemu/qemu_validate.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 488f258d00..0e5ca81ab4 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1637,8 +1637,7 @@ qemuValidateDomainWatchdogDef(const virDomainWatchdogDef *dev,
break;
case VIR_DOMAIN_WATCHDOG_MODEL_IB700:
- if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
- dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) {
+ if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("%s model of watchdog can go only on ISA bus"),
virDomainWatchdogModelTypeToString(dev->model));
--
2.27.0
4 years, 2 months
Release of libvirt-6.7.0
by Jiri Denemark
The 6.7.0 release of both libvirt and libvirt-python is tagged and
signed tarballs and source RPMs are available at
https://libvirt.org/sources/
https://libvirt.org/sources/python/
Thanks everybody who helped with this release by sending patches,
reviewing, testing, or providing any other feedback. Your work is
greatly appreciated.
* Packaging changes
* Libvirt switch to Meson build system
Libvirt abandoned autotools and switched to Meson build system.
* New features
* qemu: Add support for initiator IQN configuration for iSCSI hostdevs
Similarly to iSCSI ``<disk>`` users can use an ``<initiator>`` element
inside ``<hostdev>`` with the same format to configure the ``IQN`` value
used by the qemu initiator when connecting to an iSCSI target.
* xen: Add support for device model command-line passthrough
Xen supports passing arbitrary arguments to the QEMU device model using
the ``device_model_args`` setting in xl.cfg(5). The libvirt xen driver now
supports this using ``<xen:commandline/>`` XML extensions.
* shmem: Add support for shmem-{plain, doorbell} ``role`` option
The ``role`` attribute controls how the domain behaves on migration. With
``role=master``, the guest will copy the shared memory on migration to
the destination host. With ``role=peer``, the migration is disabled.
* bhyve: Sound device support
This feature allows to configure guest sound device using
the ``<sound>`` element, and map it to the host sound device using
the ``<audio>`` element.
* Improvements
* Allow sparse streams for block devices
Sparse streams (e.g. ``virsh vol-download --sparse`` or ``virsh vol-upload
--sparse``) now handle if one of the stream ends is a block device.
* Remove NVDIMM auto-alignment for pSeries Guests
This feature was introduced in libvirt v6.2.0 as part of the overall
NVDIMM support for pSeries guests. The idea was to relieve the user
from knowing ppc64 alignment details, but the end result is that we
ended up with inconsistencies between domain XML and actual NVDIMM
size the guest is using. To promote consistency between domain XML
and the guest, unaligned NVDIMM sizes for pSeries guests will now be
forbidden and no size auto-alignment will be made. Instead, libvirt will
suggest an aligned round up size for the user.
* Bug fixes
* virdevmapper: Deal with kernels without DM support
In the previous release libvirt dropped libdevmapper in favor of its own
implementation. However, it failed to deal correctly with kernels that
either don't have device mapper enabled or where the dm-mod module is not
loaded yet. This is now fixed.
* resctrl: Use exclusive lock for /sys/fs/resctrl
When two or more domains were attempted to start at once, due to a bug in
implementation, resctrl was not locked properly and thus threads did not
mutually exclude with each other resulting in not setting requested
limitations.
* mdev: Fix daemon crash when reattaching mdevs on assignment conflict
If there's a list of mdevs to be assigned to a domain, but one of them (NOT
the first) is already assigned to a different domain then libvirtd would
crash. This is now fixed.
* Fix logic in setting COW flag on btrfs
When COW is not explicitly requested to be disabled or enabled, then
libvirt should do nothing on non-BTRFS file systems.
* Avoid crash due to race in glib event loop code
Libvirt switched to glib event loop in 6.1.0 but it was also tickling a bug
in glib code leading to the daemon crash. Libvirt way of calling glib was
changed so the daemon crashes no more.
* virdevmapper: Handle kernel without device-mapper support
In the previous release, Libvirt dropped libdevmapper in favor of its own
implementation. But the implementation did not handle kernels without
device-mapper support. This is now fixed.
* remove autogenerated macvtap names from migration XML
Autogenerated macvtap device names were being left in the
migration XML, which could result in libvirt erroneously deleting
the macvtap device of a different guest in the aftermath of
failing to restart the guest on the destination host. Removing the
autogenerated names avoids this.
Enjoy.
Jirka
4 years, 2 months
[GSoC] Take migration in Salt virt module to the next level
by Radostin Stoyanov
Hello again libvirt community!
This summer, I once again worked on a GSoC project with libvirt. This
time, the goal of my project was to improve the libvirt integration with
SaltStack and, in particular, the support for VM migration.
SaltStack is an incredibly valuable tool that helps with automation and
infrastructure management. This is accomplished with master/minion
topology where a master acts as a central control bus for the clients
(minions), and the minions connect back to the master. The Salt virt
module provides support for core cloud operations such as VM lifecycle
management, including VM migration, by allowing minions to connect with
libvirt virtualization host.
The Salt virt.migrate interface allows users to migrate a VM from one
host to another. However, the implementation of this function used to be
based on the virsh command-line tool (instead of the libvirt Python API
bindings), which had resulted in an increased code complexity (e.g.,
string concatenation, invoking Popen.subprocess, etc) and had a limited
number of migration options exposed to users.
My project was roughly separated into three phases. The aim of the first
phase was to improve the test coverage of the virt module by increasing
the number of integration tests (i.e., before applying any major code
changes). However, SaltStack is designed to run on different platforms,
and it has been extended over the years to support many applications and
tools. Consequently, the SaltStack test suite has grown in complexity
and number of dependencies as well. As a result, not all of them (e.g.,
libvirt and qemu) are available in the Jenkins CI environment. In
addition, our goal was to only be able to effectively test VM lifecycle
management features (start, destroy, list, etc.) but also to test VM
migration. To achieve this we packaged libvirt, qemu, and all required
SaltStack minion dependencies in a container image that allows us to
spawn multiple virtualization host instances on a single machine (with
low virtualization overhead).
In the second phase of the project, now with a test environment in
place, we were able to refactor the virt.migrate implementation to
utilize the Python bindings of libvirt and add support for additional
migration options (described in the “What's new?” section below).
The third phase was primarily focused on refining the set patches,
resolving merge conflicts with upstream changes or other related PRs.
One of the major challenges was to revisit the set of tests to make them
compatible with pytest as well to collaborate with the SaltStack
community to ensure that all proposed changes will be easy to maintain
in the future.
Contributions
============
Although the development work was done in several iterations, with code
reviews on regular basis, the final result was consolidated in a single
GitHub pull request: https://github.com/saltstack/salt/pull/57947
What’s new?
===========
https://docs.saltstack.com/en/master/ref/modules/all/salt.modules.virt.ht...
The virt.migrate interface of SaltStack has been extended to support
target URI format:
$ salt src virt.migrate guest qemu+ssh://dst/system
$ salt src virt.migrate guest qemu+tcp://dst/system
$ salt src virt.migrate guest qemu+tls://dst/system
with preserved backward compatibility:
$ salt src virt.migrate guest dst
$ salt src virt.migrate guest dst True
Support for the following migration options was introduced:
Disable live migration
$ salt src virt.migrate guest qemu+ssh://dst/system live=False
Leave the migrated VM transient on destination host
$ salt src virt.migrate guest qemu+ssh://dst/system persistent=False
Leave the domain defined on the source host
$ salt src virt.migrate guest qemu+ssh://dst/system undefinesource=False
Offline migration
$ salt src virt.migrate guest qemu+ssh://dst/system offline=False
Set maximum bandwidth (in MiB/s)
$ salt src virt.migrate guest qemu+tls://dst/system max_bandwidth=10
Set maximum tolerable downtime for live-migration (i.e. a number of
milliseconds the VM is allowed to be down at the end of live migration)
$ salt src virt.migrate guest qemu+tls://dst/system max_downtime=100
Set a number of parallel network connections for live migration
$ salt src virt.migrate guest qemu+tls://dst/system parallel_connections=10
Live migration with enabled compression
$ salt src virt.migrate guest qemu+tls://dst/system \
compressed=True \
comp_methods=mt \
comp_mt_level=5 \
comp_mt_threads=4 \
comp_mt_dthreads=4
$ salt src virt.migrate guest qemu+tls://dst/system \
compressed=True \
comp_methods=xbzrle \
comp_xbzrle_cache=1024
Migrate non-shared storage
(Full disk copy)
$ salt src virt.migrate guest qemu+tls://dst/system copy_storage=all
(Incremental copy)
$ salt src virt.migrate guest qemu+tls://dst/system copy_storage=inc
Using post-copy migration
$ salt src virt.migrate guest qemu+tls://dst/system postcopy=True
$ salt src virt.migrate_start_postcopy guest
Using post-copy migration with bandwidth limit (MiB/s)
$ salt src virt.migrate guest qemu+tls://dst/system \
postcopy=True \
postcopy_bandwidth=1
$ salt src virt.migrate_start_postcopy guest
Acknowledgments
===============
I would like to sincerely thank all those who provided me with their
time, assistance, and guidance during the course of this project, for
which I am enormously grateful.
I would like to thank Cedric Bosdonnat (cbosdo), Pedro Algarvio
(s0undt3ch), Wayne Werner (waynew), Charles McMarrow (cmcmarrow) and
Daniel Wozniak (dwoz) who offered a huge amount of support, expertise,
guidance and code reviews.
I would also like to thank Michal Privoznik (mprivozn), Martin
Kletzander (mkletzan) and the rest of the libvirt and SaltStack
communities who have been extremely supportive.
Best wishes,
Radostin
4 years, 2 months