[libvirt] [PATCH] i386: Resolve CPU models to v1 by default
by Eduardo Habkost
When using `query-cpu-definitions` using `-machine none`,
QEMU is resolving all CPU models to their latest versions. The
actual CPU model version being used by another machine type (e.g.
`pc-q35-4.0`) might be different.
In theory, this was OK because the correct CPU model
version is returned when using the correct `-machine` argument.
Except that in practice, this breaks libvirt expectations:
libvirt always use `-machine none` when checking if a CPU model
is runnable, because runnability is not expected to be affected
when the machine type is changed.
For example, when running on a Haswell host without TSX,
Haswell-v4 is runnable, but Haswell-v1 is not. On those hosts,
`query-cpu-definitions` says Haswell is runnable if using
`-machine none`, but Haswell is actually not runnable using any
of the `pc-*` machine types (because they resolve Haswell to
Haswell-v1). In other words, we're breaking the "runnability
guarantee" we promised to not break for a few releases (see
qemu-deprecated.texi).
To address this issue, change the default CPU model version to v1
on all machine types, so we make `query-cpu-definitions` output
when using `-machine none` match the results when using `pc-*`.
This will change in the future (the plan is to always return the
latest CPU model version if using `-machine none`), but only
after giving libvirt the opportunity to adapt.
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1779078
Signed-off-by: Eduardo Habkost <ehabkost(a)redhat.com>
---
I don't think this should block QEMU 4.2.0 from being tagged.
The bug is present since 4.1.0, so we can fix it in 4.1.2 and/or
4.2.1.
---
qemu-deprecated.texi | 8 ++++++++
target/i386/cpu.c | 8 +++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 4b4b7425ac..b42d8b3c5f 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -374,6 +374,14 @@ guarantees must resolve the CPU model aliases using te
``alias-of'' field returned by the ``query-cpu-definitions'' QMP
command.
+While those guarantees are kept, the return value of
+``query-cpu-definitions'' will have existing CPU model aliases
+point to a version that doesn't break runnability guarantees
+(specifically, version 1 of those CPU models). In future QEMU
+versions, aliases will point to newer CPU model versions
+depending on the machine type, so management software must
+resolve CPU model aliases before starting a virtual machine.
+
@node Recently removed features
@appendix Recently removed features
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 69f518a21a..54e7f18a09 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3924,7 +3924,13 @@ static PropValue tcg_default_props[] = {
};
-X86CPUVersion default_cpu_version = CPU_VERSION_LATEST;
+/*
+ * We resolve CPU model aliases using -v1 when using "-machine
+ * none", but this is just for compatibility while libvirt isn't
+ * adapted to resolve CPU model versions before creating VMs.
+ * See "Runnability guarantee of CPU models" at * qemu-deprecated.texi.
+ */
+X86CPUVersion default_cpu_version = 1;
void x86_cpu_set_default_version(X86CPUVersion version)
{
--
2.23.0
5 years
Re: [libvirt] [PATCH v3] qga: fence guest-set-time if hwclock not available
by Philippe Mathieu-Daudé
On 12/5/19 2:12 PM, Cornelia Huck wrote:
> On Thu, 5 Dec 2019 14:05:19 +0100
> Philippe Mathieu-Daudé <philmd(a)redhat.com> wrote:
>
>> Hi Cornelia,
>>
>> On 12/5/19 12:53 PM, Cornelia Huck wrote:
>>> The Posix implementation of guest-set-time invokes hwclock to
>>> set/retrieve the time to/from the hardware clock. If hwclock
>>> is not available, the user is currently informed that "hwclock
>>> failed to set hardware clock to system time", which is quite
>>> misleading. This may happen e.g. on s390x, which has a different
>>> timekeeping concept anyway.
>>>
>>> Let's check for the availability of the hwclock command and
>>> return QERR_UNSUPPORTED for guest-set-time if it is not available.
>>>
>>> Reviewed-by: Laszlo Ersek <lersek(a)redhat.com>
>>> Reviewed-by: Daniel P. Berrangé <berrange(a)redhat.com>
>>> Reviewed-by: Michael Roth <mdroth(a)linux.vnet.ibm.com>
>>> Signed-off-by: Cornelia Huck <cohuck(a)redhat.com>
>>> ---
>>>
>>> v2->v3:
>>> - added 'static' keyword to hwclock_path
>>>
>>> Not sure what tree this is going through; if there's no better place,
>>> I can also take this through the s390 tree.
>>
>> s390 or trivial trees seems appropriate.
>>
>>>
>>> ---
>>> qga/commands-posix.c | 13 ++++++++++++-
>>> 1 file changed, 12 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/qga/commands-posix.c b/qga/commands-posix.c
>>> index 1c1a165daed8..0be301a4ea77 100644
>>> --- a/qga/commands-posix.c
>>> +++ b/qga/commands-posix.c
>>> @@ -156,6 +156,17 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
>>> pid_t pid;
>>> Error *local_err = NULL;
>>> struct timeval tv;
>>> + static const char hwclock_path[] = "/sbin/hwclock";
>>> + static int hwclock_available = -1;
>>> +
>>> + if (hwclock_available < 0) {
>>> + hwclock_available = (access(hwclock_path, X_OK) == 0);
>>> + }
>>> +
>>> + if (!hwclock_available) {
>>> + error_setg(errp, QERR_UNSUPPORTED);
>>
>> In include/qapi/qmp/qerror.h we have:
>>
>> /*
>> * These macros will go away, please don't use in new code, and do not
>> * add new ones!
>> */
>
> Sigh, it is really hard to keep track here :( I just copied from other
> callers in this file...
>
>>
>> Maybe we can replace it by "this feature is not supported on this
>> architecture"? (or without 'on this architecture').
>
> This is not really architecture specific, you'd get this on any setup
> that does not have /sbin/hwclock.
>
> Q: Is libvirt doing anything with such an error message from QEMU? Do
> we have the freedom to say e.g "guest-set-time is not supported" or so?
> Or is it beneficial to print the same error message for any unsupported
> feature?
Cc'ing Markus who added the command and libvir-list.
Using "guest-set-time is not supported" or "this command is not supported":
Reviewed-by: Philippe Mathieu-Daudé <philmd(a)redhat.com>
>>> + return;
>>> + }
>>>
>>> /* If user has passed a time, validate and set it. */
>>> if (has_time) {
>>> @@ -195,7 +206,7 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
>>>
>>> /* Use '/sbin/hwclock -w' to set RTC from the system time,
>>> * or '/sbin/hwclock -s' to set the system time from RTC. */
>>> - execle("/sbin/hwclock", "hwclock", has_time ? "-w" : "-s",
>>> + execle(hwclock_path, "hwclock", has_time ? "-w" : "-s",
>>> NULL, environ);
>>> _exit(EXIT_FAILURE);
>>> } else if (pid < 0) {
>>>
>>
>
5 years
[libvirt] [PATCH 0/2] qemu: Refactor qemuDomainAbortJob
by Peter Krempa
Review of my incremental backup series prompted for refactor of
qemuDomainAbortJob
Peter Krempa (2):
qemu: driver: Split out cancellation of migration from
qemuDomainAbortJob
qemu: Convert aborting of a domain job to a switch statement
src/qemu/qemu_driver.c | 90 +++++++++++++++++++++++++++++-------------
1 file changed, 63 insertions(+), 27 deletions(-)
--
2.23.0
5 years
[libvirt] [PATCH] docs: document some recent news items
by Daniel P. Berrangé
Document xz compression improvements, docutils build requirements,
and dropped python 2 support.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
docs/news.xml | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml
index 43aa96f497..63d57a85ac 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -44,11 +44,48 @@
<libvirt>
<release version="v6.0.0" date="unreleased">
<section title="New features">
+ <change>
+ <summary>
+ docs: the python docutils toolset is now required
+ </summary>
+ <description>
+ The use of rst2html has been introduced for the
+ website build process since docs are now being
+ written in the RST as an alternative to HTML.
+ </description>
+ </change>
</section>
<section title="Improvements">
+ <change>
+ <summary>
+ qemu: xz save image compression is faster
+ </summary>
+ <description>
+ When using the xz format to compressed virtual
+ machine saved state images, the "-3" compression
+ level preset is now used. This results in slightly
+ larger files, but with a massively reduced time
+ to compress. The xz format offers the best compression
+ level for saved state images, albeit still with the
+ slowest running time. For the fastest possible
+ running time, at cost of the larest compressed size,
+ lzop should be used.
+ </description>
+ </change>
</section>
<section title="Bug fixes">
</section>
+ <section title="Removed features">
+ <change>
+ <summary>
+ support for python2 is removed
+ </summary>
+ <description>
+ Libvirt is no longer able to be built using the
+ Python 2 binary. Python 3 must be used instead.
+ </description>
+ </change>
+ </section>
</release>
<release version="v5.10.0" date="2019-12-02">
<section title="New features">
--
2.21.0
5 years
[libvirt] [PATCH v2] qemuProcessStop: Remove image metadata only when allowed
by Michal Privoznik
In v5.9.0-370-g8fa0374c5b I've tried to fix a bug by removing
some stale XATTRs in qemuProcessStop(). However, I forgot to
do nothing when the VIR_QEMU_PROCESS_STOP_NO_RELABEL flag was
specified.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_process.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 75ee3893c6..5e178b3c6c 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7648,13 +7648,15 @@ void qemuProcessStop(virQEMUDriverPtr driver,
/* Do this explicitly after vm->pid is reset so that security drivers don't
* try to enter the domain's namespace which is non-existent by now as qemu
* is no longer running. */
- for (i = 0; i < def->ndisks; i++) {
- virDomainDiskDefPtr disk = def->disks[i];
+ if (!(flags & VIR_QEMU_PROCESS_STOP_NO_RELABEL)) {
+ for (i = 0; i < def->ndisks; i++) {
+ virDomainDiskDefPtr disk = def->disks[i];
- if (disk->mirror)
- qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->mirror);
+ if (disk->mirror)
+ qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->mirror);
- qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src);
+ qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src);
+ }
}
/* clear all private data entries which are no longer needed */
--
2.23.0
5 years
[libvirt] [PATCH] qemuProcessStop: Remove image metadata only when allowed
by Michal Privoznik
In v5.9.0-370-g8fa0374c5b I've tried to fix a bug by removing
some stale XATTRs in qemuProcessStop(). However, I forgot to
do nothing when the VIR_QEMU_PROCESS_STOP_NO_RELABEL flag was
specified. 🤦
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_process.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 75ee3893c6..df19977bb3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7648,13 +7648,15 @@ void qemuProcessStop(virQEMUDriverPtr driver,
/* Do this explicitly after vm->pid is reset so that security drivers don't
* try to enter the domain's namespace which is non-existent by now as qemu
* is no longer running. */
- for (i = 0; i < def->ndisks; i++) {
- virDomainDiskDefPtr disk = def->disks[i];
+ if ((flags & VIR_QEMU_PROCESS_STOP_NO_RELABEL)) {
+ for (i = 0; i < def->ndisks; i++) {
+ virDomainDiskDefPtr disk = def->disks[i];
- if (disk->mirror)
- qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->mirror);
+ if (disk->mirror)
+ qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->mirror);
- qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src);
+ qemuBlockRemoveImageMetadata(driver, vm, disk->dst, disk->src);
+ }
}
/* clear all private data entries which are no longer needed */
--
2.23.0
5 years
[libvirt] [PATCH] add lock priv->lock protection in remoteClientCloseFunc()
by LanceLiu
sometimes, virsh console session may closed by virsh console existed session(when virsh console client
exit) and new virsh console --force session simutaneously. So in one thread(Job worker), it calls
daemonStreamEvent() and referencing stream, and in another thread(main thread), virNetServerClientClose()
was called, and the callback remoteClientCloseFunc() was called, without protect by priv->lock in
remoteClientCloseFunc(), it may lead to daemonStreamEvent reference stream released by remoteClientCloseFunc(),
and also need change virNetServerClientClose() to be virNetServerClientImmediateClose() in daemonStreamEvent(),
or it lead to libvirt daemon deadlock by double lock priv->lock in daemonStreamEvent()
---
src/remote/remote_daemon_dispatch.c | 2 ++
src/remote/remote_daemon_stream.c | 14 +++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index f369ffb..b0982b7 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1724,7 +1724,9 @@ static void remoteClientCloseFunc(virNetServerClientPtr client)
{
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
+ virMutexLock(&priv->lock);
daemonRemoveAllClientStreams(priv->streams);
+ virMutexUnlock(&priv->lock);
remoteClientFreePrivateCallbacks(priv);
}
diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_stream.c
index 73e4d7b..6a84fdf 100644
--- a/src/remote/remote_daemon_stream.c
+++ b/src/remote/remote_daemon_stream.c
@@ -141,7 +141,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
(events & VIR_STREAM_EVENT_WRITABLE)) {
if (daemonStreamHandleWrite(client, stream) < 0) {
daemonRemoveClientStream(client, stream);
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
}
@@ -151,7 +151,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
events = events & ~(VIR_STREAM_EVENT_READABLE);
if (daemonStreamHandleRead(client, stream) < 0) {
daemonRemoveClientStream(client, stream);
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
/* If we detected EOF during read processing,
@@ -176,7 +176,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
if (daemonStreamHandleFinish(client, stream, msg) < 0) {
virNetMessageFree(msg);
daemonRemoveClientStream(client, stream);
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
break;
@@ -186,7 +186,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
if (daemonStreamHandleAbort(client, stream, msg) < 0) {
virNetMessageFree(msg);
daemonRemoveClientStream(client, stream);
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
break;
@@ -205,7 +205,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
stream->recvEOF = true;
if (!(msg = virNetMessageNew(false))) {
daemonRemoveClientStream(client, stream);
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
msg->cb = daemonStreamMessageFinished;
@@ -219,7 +219,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
"", 0) < 0) {
virNetMessageFree(msg);
daemonRemoveClientStream(client, stream);
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
}
@@ -262,7 +262,7 @@ daemonStreamEvent(virStreamPtr st, int events, void *opaque)
}
daemonRemoveClientStream(client, stream);
if (ret < 0)
- virNetServerClientClose(client);
+ virNetServerClientImmediateClose(client);
goto cleanup;
}
--
1.8.3.1
5 years
[libvirt] [python PATCH] Fix RPM deps for centos 7
by Daniel P. Berrangé
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
libvirt-python.spec.in | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libvirt-python.spec.in b/libvirt-python.spec.in
index 1e92f3c..33d2775 100644
--- a/libvirt-python.spec.in
+++ b/libvirt-python.spec.in
@@ -21,8 +21,13 @@ Url: http://libvirt.org
License: LGPLv2+
BuildRequires: libvirt-devel == %{version}
BuildRequires: python3-devel
+%if 0%{?rhel} == 7
+BuildRequires: python36-nose
+BuildRequires: python36-lxml
+%else
BuildRequires: python3-nose
BuildRequires: python3-lxml
+%endif
BuildRequires: gcc
# Don't want provides for python shared objects
--
2.23.0
5 years
[libvirt] [jenkins-ci PATCH] lcitool: Add 'install=' to the extra_arg
by Fabiano Fidêncio
Add "install=" unconditionally to the extra_arg parameter passed to
virt-install. It's needed as the virt-install present on CentOS CI host
does not use the correct kernel URL argument when installing OpenSUSE.
This does not cause issues on other installations as the other distros
will just ignore the argument passed.
Signed-off-by: Fabiano Fidêncio <fidencio(a)redhat.com>
---
I've verified this solution works on a CentOS 7 host. I've verified this
solution doesn't cause regressions on a Fedora 31 host.
---
guests/lcitool | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/guests/lcitool b/guests/lcitool
index 0e27796..c7f949d 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -542,8 +542,13 @@ class Application:
# but we need to point anaconda in the right direction through
# the 'ks' kernel parameter. We can use 'ks' unconditionally
# for simplicity's sake, because distributions that don't use
- # kickstart for unattended installation will simply ignore it
- extra_arg = "console=ttyS0 ks=file:/{}".format(install_config)
+ # kickstart for unattended installation will simply ignore it.
+ # Similarly to how we can use 'ks' unconditionally, we also can
+ # do the same with 'install' argument, needed to workaround a
+ # a bug on virt-install as it does not use the correct kernel
+ # URL argument when installing an OpenSUSE guest.
+ extra_arg = ("console=ttyS0 ks=file:/{} install={}".
+ format(install_config, facts["install_url"]))
virt_install = distutils.spawn.find_executable("virt-install")
if virt_install is None:
--
2.23.0
5 years