Synchronization with qemu-kvm-5.2.0-10.el8

This commit is contained in:
Miroslav Rezanina 2021-03-08 12:28:11 +01:00
parent cd9fb661b4
commit bf6207fc0a
52 changed files with 5789 additions and 4 deletions

View File

@ -0,0 +1,125 @@
From 23d161ad92d783275ad56f3acb663f7a21b809f4 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Mon, 8 Feb 2021 22:56:59 -0300
Subject: [PATCH 01/54] block/nbd: only detach existing iochannel from
aio_context
RH-Author: Eric Blake <eblake@redhat.com>
Message-id: <20210208225701.110110-2-eblake@redhat.com>
Patchwork-id: 101005
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v4 1/3] block/nbd: only detach existing iochannel from aio_context
Bugzilla: 1887883
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
From: Roman Kagan <rvkagan@yandex-team.ru>
When the reconnect in NBD client is in progress, the iochannel used for
NBD connection doesn't exist. Therefore an attempt to detach it from
the aio_context of the parent BlockDriverState results in a NULL pointer
dereference.
The problem is triggerable, in particular, when an outgoing migration is
about to finish, and stopping the dataplane tries to move the
BlockDriverState from the iothread aio_context to the main loop. If the
NBD connection is lost before this point, and the NBD client has entered
the reconnect procedure, QEMU crashes:
#0 qemu_aio_coroutine_enter (ctx=0x5618056c7580, co=0x0)
at /build/qemu-6MF7tq/qemu-5.0.1/util/qemu-coroutine.c:109
#1 0x00005618034b1b68 in nbd_client_attach_aio_context_bh (
opaque=0x561805ed4c00) at /build/qemu-6MF7tq/qemu-5.0.1/block/nbd.c:164
#2 0x000056180353116b in aio_wait_bh (opaque=0x7f60e1e63700)
at /build/qemu-6MF7tq/qemu-5.0.1/util/aio-wait.c:55
#3 0x0000561803530633 in aio_bh_call (bh=0x7f60d40a7e80)
at /build/qemu-6MF7tq/qemu-5.0.1/util/async.c:136
#4 aio_bh_poll (ctx=ctx@entry=0x5618056c7580)
at /build/qemu-6MF7tq/qemu-5.0.1/util/async.c:164
#5 0x0000561803533e5a in aio_poll (ctx=ctx@entry=0x5618056c7580,
blocking=blocking@entry=true)
at /build/qemu-6MF7tq/qemu-5.0.1/util/aio-posix.c:650
#6 0x000056180353128d in aio_wait_bh_oneshot (ctx=0x5618056c7580,
cb=<optimized out>, opaque=<optimized out>)
at /build/qemu-6MF7tq/qemu-5.0.1/util/aio-wait.c:71
#7 0x000056180345c50a in bdrv_attach_aio_context (new_context=0x5618056c7580,
bs=0x561805ed4c00) at /build/qemu-6MF7tq/qemu-5.0.1/block.c:6172
#8 bdrv_set_aio_context_ignore (bs=bs@entry=0x561805ed4c00,
new_context=new_context@entry=0x5618056c7580,
ignore=ignore@entry=0x7f60e1e63780)
at /build/qemu-6MF7tq/qemu-5.0.1/block.c:6237
#9 0x000056180345c969 in bdrv_child_try_set_aio_context (
bs=bs@entry=0x561805ed4c00, ctx=0x5618056c7580,
ignore_child=<optimized out>, errp=<optimized out>)
at /build/qemu-6MF7tq/qemu-5.0.1/block.c:6332
#10 0x00005618034957db in blk_do_set_aio_context (blk=0x56180695b3f0,
new_context=0x5618056c7580, update_root_node=update_root_node@entry=true,
errp=errp@entry=0x0)
at /build/qemu-6MF7tq/qemu-5.0.1/block/block-backend.c:1989
#11 0x00005618034980bd in blk_set_aio_context (blk=<optimized out>,
new_context=<optimized out>, errp=errp@entry=0x0)
at /build/qemu-6MF7tq/qemu-5.0.1/block/block-backend.c:2010
#12 0x0000561803197953 in virtio_blk_data_plane_stop (vdev=<optimized out>)
at /build/qemu-6MF7tq/qemu-5.0.1/hw/block/dataplane/virtio-blk.c:292
#13 0x00005618033d67bf in virtio_bus_stop_ioeventfd (bus=0x5618056d9f08)
at /build/qemu-6MF7tq/qemu-5.0.1/hw/virtio/virtio-bus.c:245
#14 0x00005618031c9b2e in virtio_vmstate_change (opaque=0x5618056d9f90,
running=0, state=<optimized out>)
at /build/qemu-6MF7tq/qemu-5.0.1/hw/virtio/virtio.c:3220
#15 0x0000561803208bfd in vm_state_notify (running=running@entry=0,
state=state@entry=RUN_STATE_FINISH_MIGRATE)
at /build/qemu-6MF7tq/qemu-5.0.1/softmmu/vl.c:1275
#16 0x0000561803155c02 in do_vm_stop (state=RUN_STATE_FINISH_MIGRATE,
send_stop=<optimized out>) at /build/qemu-6MF7tq/qemu-5.0.1/cpus.c:1032
#17 0x00005618033e3765 in migration_completion (s=0x5618056e6960)
at /build/qemu-6MF7tq/qemu-5.0.1/migration/migration.c:2914
#18 migration_iteration_run (s=0x5618056e6960)
at /build/qemu-6MF7tq/qemu-5.0.1/migration/migration.c:3275
#19 migration_thread (opaque=opaque@entry=0x5618056e6960)
at /build/qemu-6MF7tq/qemu-5.0.1/migration/migration.c:3439
#20 0x0000561803536ad6 in qemu_thread_start (args=<optimized out>)
at /build/qemu-6MF7tq/qemu-5.0.1/util/qemu-thread-posix.c:519
#21 0x00007f61085d06ba in start_thread ()
from /lib/x86_64-linux-gnu/libpthread.so.0
#22 0x00007f610830641d in sysctl () from /lib/x86_64-linux-gnu/libc.so.6
#23 0x0000000000000000 in ?? ()
Fix it by checking that the iochannel is non-null before trying to
detach it from the aio_context. If it is null, no detaching is needed,
and it will get reattached in the proper aio_context once the connection
is reestablished.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210129073859.683063-2-rvkagan@yandex-team.ru>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 3b5e4db6734d30e551101c0941b2a6140862ba40)
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
block/nbd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/block/nbd.c b/block/nbd.c
index 42536702b6..ed7b6df10b 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -234,7 +234,14 @@ static void nbd_client_detach_aio_context(BlockDriverState *bs)
/* Timer is deleted in nbd_client_co_drain_begin() */
assert(!s->reconnect_delay_timer);
- qio_channel_detach_aio_context(QIO_CHANNEL(s->ioc));
+ /*
+ * If reconnect is in progress we may have no ->ioc. It will be
+ * re-instantiated in the proper aio context once the connection is
+ * reestablished.
+ */
+ if (s->ioc) {
+ qio_channel_detach_aio_context(QIO_CHANNEL(s->ioc));
+ }
}
static void nbd_client_attach_aio_context_bh(void *opaque)
--
2.27.0

View File

@ -0,0 +1,124 @@
From ed5dbeb52152217fc7fe9023327dbacfac8b2322 Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Mon, 8 Feb 2021 22:57:00 -0300
Subject: [PATCH 02/54] block/nbd: only enter connection coroutine if it's
present
RH-Author: Eric Blake <eblake@redhat.com>
Message-id: <20210208225701.110110-3-eblake@redhat.com>
Patchwork-id: 101008
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v4 2/3] block/nbd: only enter connection coroutine if it's present
Bugzilla: 1887883
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
From: Roman Kagan <rvkagan@yandex-team.ru>
When an NBD block driver state is moved from one aio_context to another
(e.g. when doing a drain in a migration thread),
nbd_client_attach_aio_context_bh is executed that enters the connection
coroutine.
However, the assumption that ->connection_co is always present here
appears incorrect: the connection may have encountered an error other
than -EIO in the underlying transport, and thus may have decided to quit
rather than keep trying to reconnect, and therefore it may have
terminated the connection coroutine. As a result an attempt to reassign
the client in this state (NBD_CLIENT_QUIT) to a different aio_context
leads to a null pointer dereference:
#0 qio_channel_detach_aio_context (ioc=0x0)
at /build/qemu-gYtjVn/qemu-5.0.1/io/channel.c:452
#1 0x0000562a242824b3 in bdrv_detach_aio_context (bs=0x562a268d6a00)
at /build/qemu-gYtjVn/qemu-5.0.1/block.c:6151
#2 bdrv_set_aio_context_ignore (bs=bs@entry=0x562a268d6a00,
new_context=new_context@entry=0x562a260c9580,
ignore=ignore@entry=0x7feeadc9b780)
at /build/qemu-gYtjVn/qemu-5.0.1/block.c:6230
#3 0x0000562a24282969 in bdrv_child_try_set_aio_context
(bs=bs@entry=0x562a268d6a00, ctx=0x562a260c9580,
ignore_child=<optimized out>, errp=<optimized out>)
at /build/qemu-gYtjVn/qemu-5.0.1/block.c:6332
#4 0x0000562a242bb7db in blk_do_set_aio_context (blk=0x562a2735d0d0,
new_context=0x562a260c9580,
update_root_node=update_root_node@entry=true, errp=errp@entry=0x0)
at /build/qemu-gYtjVn/qemu-5.0.1/block/block-backend.c:1989
#5 0x0000562a242be0bd in blk_set_aio_context (blk=<optimized out>,
new_context=<optimized out>, errp=errp@entry=0x0)
at /build/qemu-gYtjVn/qemu-5.0.1/block/block-backend.c:2010
#6 0x0000562a23fbd953 in virtio_blk_data_plane_stop (vdev=<optimized
out>)
at /build/qemu-gYtjVn/qemu-5.0.1/hw/block/dataplane/virtio-blk.c:292
#7 0x0000562a241fc7bf in virtio_bus_stop_ioeventfd (bus=0x562a260dbf08)
at /build/qemu-gYtjVn/qemu-5.0.1/hw/virtio/virtio-bus.c:245
#8 0x0000562a23fefb2e in virtio_vmstate_change (opaque=0x562a260dbf90,
running=0, state=<optimized out>)
at /build/qemu-gYtjVn/qemu-5.0.1/hw/virtio/virtio.c:3220
#9 0x0000562a2402ebfd in vm_state_notify (running=running@entry=0,
state=state@entry=RUN_STATE_FINISH_MIGRATE)
at /build/qemu-gYtjVn/qemu-5.0.1/softmmu/vl.c:1275
#10 0x0000562a23f7bc02 in do_vm_stop (state=RUN_STATE_FINISH_MIGRATE,
send_stop=<optimized out>)
at /build/qemu-gYtjVn/qemu-5.0.1/cpus.c:1032
#11 0x0000562a24209765 in migration_completion (s=0x562a260e83a0)
at /build/qemu-gYtjVn/qemu-5.0.1/migration/migration.c:2914
#12 migration_iteration_run (s=0x562a260e83a0)
at /build/qemu-gYtjVn/qemu-5.0.1/migration/migration.c:3275
#13 migration_thread (opaque=opaque@entry=0x562a260e83a0)
at /build/qemu-gYtjVn/qemu-5.0.1/migration/migration.c:3439
#14 0x0000562a2435ca96 in qemu_thread_start (args=<optimized out>)
at /build/qemu-gYtjVn/qemu-5.0.1/util/qemu-thread-posix.c:519
#15 0x00007feed31466ba in start_thread (arg=0x7feeadc9c700)
at pthread_create.c:333
#16 0x00007feed2e7c41d in __GI___sysctl (name=0x0, nlen=608471908,
oldval=0x562a2452b138, oldlenp=0x0, newval=0x562a2452c5e0
<__func__.28102>, newlen=0)
at ../sysdeps/unix/sysv/linux/sysctl.c:30
#17 0x0000000000000000 in ?? ()
Fix it by checking that the connection coroutine is non-null before
trying to enter it. If it is null, no entering is needed, as the
connection is probably going down anyway.
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210129073859.683063-3-rvkagan@yandex-team.ru>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit ddde5ee769fcc84b96f879d7b94f35268f69ca3b)
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
block/nbd.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index ed7b6df10b..1bdba9fc49 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -249,13 +249,15 @@ static void nbd_client_attach_aio_context_bh(void *opaque)
BlockDriverState *bs = opaque;
BDRVNBDState *s = (BDRVNBDState *)bs->opaque;
- /*
- * The node is still drained, so we know the coroutine has yielded in
- * nbd_read_eof(), the only place where bs->in_flight can reach 0, or it is
- * entered for the first time. Both places are safe for entering the
- * coroutine.
- */
- qemu_aio_coroutine_enter(bs->aio_context, s->connection_co);
+ if (s->connection_co) {
+ /*
+ * The node is still drained, so we know the coroutine has yielded in
+ * nbd_read_eof(), the only place where bs->in_flight can reach 0, or
+ * it is entered for the first time. Both places are safe for entering
+ * the coroutine.
+ */
+ qemu_aio_coroutine_enter(bs->aio_context, s->connection_co);
+ }
bdrv_dec_in_flight(bs);
}
--
2.27.0

View File

@ -0,0 +1,39 @@
From 5aadfd88a3438cee837d2e7e96fa0801d885d119 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Fri, 19 Feb 2021 16:14:09 -0500
Subject: [PATCH 18/54] default-configs: Enable vhost-user-blk
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20210219161409.53788-2-kwolf@redhat.com>
Patchwork-id: 101166
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/1] default-configs: Enable vhost-user-blk
Bugzilla: 1930033
RH-Acked-by: Thomas Huth <thuth@redhat.com>
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
Now that we have qemu-storage-daemon with a vhost-user-blk export,
we want to be able to use that in guests. So enable vhost-user-blk in
our build configuration.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
default-configs/devices/x86_64-rh-devices.mak | 1 +
1 file changed, 1 insertion(+)
diff --git a/default-configs/devices/x86_64-rh-devices.mak b/default-configs/devices/x86_64-rh-devices.mak
index e80877d4e2..993e2c1d2f 100644
--- a/default-configs/devices/x86_64-rh-devices.mak
+++ b/default-configs/devices/x86_64-rh-devices.mak
@@ -87,6 +87,7 @@ CONFIG_VGA=y
CONFIG_VGA_CIRRUS=y
CONFIG_VGA_PCI=y
CONFIG_VHOST_USER=y
+CONFIG_VHOST_USER_BLK=y
CONFIG_VIRTIO_PCI=y
CONFIG_VIRTIO_VGA=y
CONFIG_VMMOUSE=y
--
2.27.0

View File

@ -0,0 +1,50 @@
From b3dbe8179b0f73d09bb90cbf92e991a187ef3534 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 16 Feb 2021 16:19:41 -0500
Subject: [PATCH 15/54] docs: Add qemu-storage-daemon(1) manpage to meson.build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20210216161943.126728-4-kwolf@redhat.com>
Patchwork-id: 101104
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 3/5] docs: Add qemu-storage-daemon(1) manpage to meson.build
Bugzilla: 1901323
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
From: Peter Maydell <peter.maydell@linaro.org>
In commit 1982e1602d15 we added a new qemu-storage-daemon(1) manpage.
At the moment new manpages have to be listed both in the conf.py for
Sphinx and also in docs/meson.build for Meson. We forgot the second
of those -- correct the omission.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Message-id: 20210108161416.21129-2-peter.maydell@linaro.org
(cherry picked from commit fa56cf7e86f99d5557a4fb730e375777b89d8b50)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
docs/meson.build | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/meson.build b/docs/meson.build
index 71641b4fe0..fae9849b79 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -62,6 +62,7 @@ if build_docs
'qemu-img.1': (have_tools ? 'man1' : ''),
'qemu-nbd.8': (have_tools ? 'man8' : ''),
'qemu-pr-helper.8': (have_tools ? 'man8' : ''),
+ 'qemu-storage-daemon.1': (have_tools ? 'man1' : ''),
'qemu-trace-stap.1': (config_host.has_key('CONFIG_TRACE_SYSTEMTAP') ? 'man1' : ''),
'virtfs-proxy-helper.1': (have_virtfs_proxy_helper ? 'man1' : ''),
'virtiofsd.1': (have_virtiofsd ? 'man1' : ''),
--
2.27.0

View File

@ -0,0 +1,218 @@
From f3831252e618e420ea24e53dbdee8eb51e8cad3e Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 16 Feb 2021 16:19:40 -0500
Subject: [PATCH 14/54] docs: add qemu-storage-daemon(1) man page
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20210216161943.126728-3-kwolf@redhat.com>
Patchwork-id: 101102
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 2/5] docs: add qemu-storage-daemon(1) man page
Bugzilla: 1901323
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
From: Stefan Hajnoczi <stefanha@redhat.com>
Document the qemu-storage-daemon tool. Most of the command-line options
are identical to their QEMU counterparts. Perhaps Sphinx hxtool
integration could be extended to extract documentation for individual
command-line options so they can be shared. For now the
qemu-storage-daemon simply refers to the qemu(1) man page where the
command-line options are identical.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20201209103802.350848-3-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 1982e1602d15313cd82f225e821c37733ece3404)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
docs/tools/conf.py | 2 +
docs/tools/index.rst | 1 +
docs/tools/qemu-storage-daemon.rst | 148 +++++++++++++++++++++++++++++
3 files changed, 151 insertions(+)
create mode 100644 docs/tools/qemu-storage-daemon.rst
diff --git a/docs/tools/conf.py b/docs/tools/conf.py
index 4760d36ff2..7072d99324 100644
--- a/docs/tools/conf.py
+++ b/docs/tools/conf.py
@@ -20,6 +20,8 @@ html_theme_options['description'] = \
man_pages = [
('qemu-img', 'qemu-img', u'QEMU disk image utility',
['Fabrice Bellard'], 1),
+ ('qemu-storage-daemon', 'qemu-storage-daemon', u'QEMU storage daemon',
+ [], 1),
('qemu-nbd', 'qemu-nbd', u'QEMU Disk Network Block Device Server',
['Anthony Liguori <anthony@codemonkey.ws>'], 8),
('qemu-pr-helper', 'qemu-pr-helper', 'QEMU persistent reservation helper',
diff --git a/docs/tools/index.rst b/docs/tools/index.rst
index b99f86c7c6..3a5829c17a 100644
--- a/docs/tools/index.rst
+++ b/docs/tools/index.rst
@@ -11,6 +11,7 @@ Contents:
:maxdepth: 2
qemu-img
+ qemu-storage-daemon
qemu-nbd
qemu-pr-helper
qemu-trace-stap
diff --git a/docs/tools/qemu-storage-daemon.rst b/docs/tools/qemu-storage-daemon.rst
new file mode 100644
index 0000000000..f63627eaf6
--- /dev/null
+++ b/docs/tools/qemu-storage-daemon.rst
@@ -0,0 +1,148 @@
+QEMU Storage Daemon
+===================
+
+Synopsis
+--------
+
+**qemu-storage-daemon** [options]
+
+Description
+-----------
+
+qemu-storage-daemon provides disk image functionality from QEMU, qemu-img, and
+qemu-nbd in a long-running process controlled via QMP commands without running
+a virtual machine. It can export disk images, run block job operations, and
+perform other disk-related operations. The daemon is controlled via a QMP
+monitor and initial configuration from the command-line.
+
+The daemon offers the following subset of QEMU features:
+
+* Block nodes
+* Block jobs
+* Block exports
+* Throttle groups
+* Character devices
+* Crypto and secrets
+* QMP
+* IOThreads
+
+Commands can be sent over a QEMU Monitor Protocol (QMP) connection. See the
+:manpage:`qemu-storage-daemon-qmp-ref(7)` manual page for a description of the
+commands.
+
+The daemon runs until it is stopped using the ``quit`` QMP command or
+SIGINT/SIGHUP/SIGTERM.
+
+**Warning:** Never modify images in use by a running virtual machine or any
+other process; this may destroy the image. Also, be aware that querying an
+image that is being modified by another process may encounter inconsistent
+state.
+
+Options
+-------
+
+.. program:: qemu-storage-daemon
+
+Standard options:
+
+.. option:: -h, --help
+
+ Display help and exit
+
+.. option:: -V, --version
+
+ Display version information and exit
+
+.. option:: -T, --trace [[enable=]PATTERN][,events=FILE][,file=FILE]
+
+ .. include:: ../qemu-option-trace.rst.inc
+
+.. option:: --blockdev BLOCKDEVDEF
+
+ is a block node definition. See the :manpage:`qemu(1)` manual page for a
+ description of block node properties and the :manpage:`qemu-block-drivers(7)`
+ manual page for a description of driver-specific parameters.
+
+.. option:: --chardev CHARDEVDEF
+
+ is a character device definition. See the :manpage:`qemu(1)` manual page for
+ a description of character device properties. A common character device
+ definition configures a UNIX domain socket::
+
+ --chardev socket,id=char1,path=/tmp/qmp.sock,server,nowait
+
+.. option:: --export [type=]nbd,id=<id>,node-name=<node-name>[,name=<export-name>][,writable=on|off][,bitmap=<name>]
+ --export [type=]vhost-user-blk,id=<id>,node-name=<node-name>,addr.type=unix,addr.path=<socket-path>[,writable=on|off][,logical-block-size=<block-size>][,num-queues=<num-queues>]
+ --export [type=]vhost-user-blk,id=<id>,node-name=<node-name>,addr.type=fd,addr.str=<fd>[,writable=on|off][,logical-block-size=<block-size>][,num-queues=<num-queues>]
+
+ is a block export definition. ``node-name`` is the block node that should be
+ exported. ``writable`` determines whether or not the export allows write
+ requests for modifying data (the default is off).
+
+ The ``nbd`` export type requires ``--nbd-server`` (see below). ``name`` is
+ the NBD export name. ``bitmap`` is the name of a dirty bitmap reachable from
+ the block node, so the NBD client can use NBD_OPT_SET_META_CONTEXT with the
+ metadata context name "qemu:dirty-bitmap:BITMAP" to inspect the bitmap.
+
+ The ``vhost-user-blk`` export type takes a vhost-user socket address on which
+ it accept incoming connections. Both
+ ``addr.type=unix,addr.path=<socket-path>`` for UNIX domain sockets and
+ ``addr.type=fd,addr.str=<fd>`` for file descriptor passing are supported.
+ ``logical-block-size`` sets the logical block size in bytes (the default is
+ 512). ``num-queues`` sets the number of virtqueues (the default is 1).
+
+.. option:: --monitor MONITORDEF
+
+ is a QMP monitor definition. See the :manpage:`qemu(1)` manual page for
+ a description of QMP monitor properties. A common QMP monitor definition
+ configures a monitor on character device ``char1``::
+
+ --monitor chardev=char1
+
+.. option:: --nbd-server addr.type=inet,addr.host=<host>,addr.port=<port>[,tls-creds=<id>][,tls-authz=<id>][,max-connections=<n>]
+ --nbd-server addr.type=unix,addr.path=<path>[,tls-creds=<id>][,tls-authz=<id>][,max-connections=<n>]
+
+ is a server for NBD exports. Both TCP and UNIX domain sockets are supported.
+ TLS encryption can be configured using ``--object`` tls-creds-* and authz-*
+ secrets (see below).
+
+ To configure an NBD server on UNIX domain socket path ``/tmp/nbd.sock``::
+
+ --nbd-server addr.type=unix,addr.path=/tmp/nbd.sock
+
+.. option:: --object help
+ --object <type>,help
+ --object <type>[,<property>=<value>...]
+
+ is a QEMU user creatable object definition. List object types with ``help``.
+ List object properties with ``<type>,help``. See the :manpage:`qemu(1)`
+ manual page for a description of the object properties.
+
+Examples
+--------
+Launch the daemon with QMP monitor socket ``qmp.sock`` so clients can execute
+QMP commands::
+
+ $ qemu-storage-daemon \
+ --chardev socket,path=qmp.sock,server,nowait,id=char1 \
+ --monitor chardev=char1
+
+Export raw image file ``disk.img`` over NBD UNIX domain socket ``nbd.sock``::
+
+ $ qemu-storage-daemon \
+ --blockdev driver=file,node-name=disk,filename=disk.img \
+ --nbd-server addr.type=unix,addr.path=nbd.sock \
+ --export type=nbd,id=export,node-name=disk,writable=on
+
+Export a qcow2 image file ``disk.qcow2`` as a vhosts-user-blk device over UNIX
+domain socket ``vhost-user-blk.sock``::
+
+ $ qemu-storage-daemon \
+ --blockdev driver=file,node-name=file,filename=disk.qcow2 \
+ --blockdev driver=qcow2,node-name=qcow2,file=file \
+ --export type=vhost-user-blk,id=export,addr.type=unix,addr.path=vhost-user-blk.sock,node-name=qcow2
+
+See also
+--------
+
+:manpage:`qemu(1)`, :manpage:`qemu-block-drivers(7)`, :manpage:`qemu-storage-daemon-qmp-ref(7)`
--
2.27.0

View File

@ -0,0 +1,111 @@
From 5425716387734e0a782ac633021cd85eb4d4b914 Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 16 Feb 2021 16:19:39 -0500
Subject: [PATCH 13/54] docs: generate qemu-storage-daemon-qmp-ref(7) man page
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20210216161943.126728-2-kwolf@redhat.com>
Patchwork-id: 101101
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/5] docs: generate qemu-storage-daemon-qmp-ref(7) man page
Bugzilla: 1901323
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
From: Stefan Hajnoczi <stefanha@redhat.com>
Although individual qemu-storage-daemon QMP commands are identical to
QEMU QMP commands, qemu-storage-daemon only supports a subset of QEMU's
QMP commands. Generate a manual page of just the commands supported by
qemu-storage-daemon so that users know exactly what is available in
qemu-storage-daemon.
Add an h1 heading in storage-daemon/qapi/qapi-schema.json so that
block-core.json is at the h2 heading level.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20201209103802.350848-2-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 23c02ace3508dba5f781ed9ecfde400e462f3a37)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
docs/interop/conf.py | 2 ++
docs/interop/index.rst | 1 +
docs/interop/qemu-storage-daemon-qmp-ref.rst | 13 +++++++++++++
docs/meson.build | 1 +
storage-daemon/qapi/qapi-schema.json | 3 +++
5 files changed, 20 insertions(+)
create mode 100644 docs/interop/qemu-storage-daemon-qmp-ref.rst
diff --git a/docs/interop/conf.py b/docs/interop/conf.py
index 2634ca3410..f4370aaa13 100644
--- a/docs/interop/conf.py
+++ b/docs/interop/conf.py
@@ -23,4 +23,6 @@ man_pages = [
[], 7),
('qemu-qmp-ref', 'qemu-qmp-ref', 'QEMU QMP Reference Manual',
[], 7),
+ ('qemu-storage-daemon-qmp-ref', 'qemu-storage-daemon-qmp-ref',
+ 'QEMU Storage Daemon QMP Reference Manual', [], 7),
]
diff --git a/docs/interop/index.rst b/docs/interop/index.rst
index cd78d679d8..95d56495f6 100644
--- a/docs/interop/index.rst
+++ b/docs/interop/index.rst
@@ -20,6 +20,7 @@ Contents:
qemu-ga
qemu-ga-ref
qemu-qmp-ref
+ qemu-storage-daemon-qmp-ref
vhost-user
vhost-user-gpu
vhost-vdpa
diff --git a/docs/interop/qemu-storage-daemon-qmp-ref.rst b/docs/interop/qemu-storage-daemon-qmp-ref.rst
new file mode 100644
index 0000000000..caf9dad23a
--- /dev/null
+++ b/docs/interop/qemu-storage-daemon-qmp-ref.rst
@@ -0,0 +1,13 @@
+QEMU Storage Daemon QMP Reference Manual
+========================================
+
+..
+ TODO: the old Texinfo manual used to note that this manual
+ is GPL-v2-or-later. We should make that reader-visible
+ both here and in our Sphinx manuals more generally.
+
+..
+ TODO: display the QEMU version, both here and in our Sphinx manuals
+ more generally.
+
+.. qapi-doc:: storage-daemon/qapi/qapi-schema.json
diff --git a/docs/meson.build b/docs/meson.build
index bb8fe4c9e4..71641b4fe0 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -56,6 +56,7 @@ if build_docs
'qemu-ga.8': (have_tools ? 'man8' : ''),
'qemu-ga-ref.7': 'man7',
'qemu-qmp-ref.7': 'man7',
+ 'qemu-storage-daemon-qmp-ref.7': (have_tools ? 'man7' : ''),
},
'tools': {
'qemu-img.1': (have_tools ? 'man1' : ''),
diff --git a/storage-daemon/qapi/qapi-schema.json b/storage-daemon/qapi/qapi-schema.json
index c6ad5ae1e3..28117c3aac 100644
--- a/storage-daemon/qapi/qapi-schema.json
+++ b/storage-daemon/qapi/qapi-schema.json
@@ -15,6 +15,9 @@
{ 'include': '../../qapi/pragma.json' }
+##
+# = Block devices
+##
{ 'include': '../../qapi/block-core.json' }
{ 'include': '../../qapi/block-export.json' }
{ 'include': '../../qapi/char.json' }
--
2.27.0

View File

@ -0,0 +1,121 @@
From 4f94bc7cc479dba60fba841608b3da74b940a26d Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:44 -0500
Subject: [PATCH 47/54] failover: Caller of this two functions already have
primary_dev
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-25-lvivier@redhat.com>
Patchwork-id: 101246
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 24/27] failover: Caller of this two functions already have primary_dev
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Pass it as an argument.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-26-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 0e9a65c5b168b993b845ec2acb2568328c2353da)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 746ed3fb71..b37e9cd1d9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3093,17 +3093,17 @@ void virtio_net_set_netclient_name(VirtIONet *n, const char *name,
n->netclient_type = g_strdup(type);
}
-static bool failover_unplug_primary(VirtIONet *n)
+static bool failover_unplug_primary(VirtIONet *n, DeviceState *dev)
{
HotplugHandler *hotplug_ctrl;
PCIDevice *pci_dev;
Error *err = NULL;
- hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
+ hotplug_ctrl = qdev_get_hotplug_handler(dev);
if (hotplug_ctrl) {
- pci_dev = PCI_DEVICE(n->primary_dev);
+ pci_dev = PCI_DEVICE(dev);
pci_dev->partially_hotplugged = true;
- hotplug_handler_unplug_request(hotplug_ctrl, n->primary_dev, &err);
+ hotplug_handler_unplug_request(hotplug_ctrl, dev, &err);
if (err) {
error_report_err(err);
return false;
@@ -3114,30 +3114,31 @@ static bool failover_unplug_primary(VirtIONet *n)
return true;
}
-static bool failover_replug_primary(VirtIONet *n, Error **errp)
+static bool failover_replug_primary(VirtIONet *n, DeviceState *dev,
+ Error **errp)
{
Error *err = NULL;
HotplugHandler *hotplug_ctrl;
- PCIDevice *pdev = PCI_DEVICE(n->primary_dev);
+ PCIDevice *pdev = PCI_DEVICE(dev);
BusState *primary_bus;
if (!pdev->partially_hotplugged) {
return true;
}
- primary_bus = n->primary_dev->parent_bus;
+ primary_bus = dev->parent_bus;
if (!primary_bus) {
error_setg(errp, "virtio_net: couldn't find primary bus");
return false;
}
- qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort);
+ qdev_set_parent_bus(dev, primary_bus, &error_abort);
qatomic_set(&n->failover_primary_hidden, false);
- hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
+ hotplug_ctrl = qdev_get_hotplug_handler(dev);
if (hotplug_ctrl) {
- hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err);
+ hotplug_handler_pre_plug(hotplug_ctrl, dev, &err);
if (err) {
goto out;
}
- hotplug_handler_plug(hotplug_ctrl, n->primary_dev, &err);
+ hotplug_handler_plug(hotplug_ctrl, dev, &err);
}
out:
@@ -3161,7 +3162,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
}
if (migration_in_setup(s) && !should_be_hidden) {
- if (failover_unplug_primary(n)) {
+ if (failover_unplug_primary(n, n->primary_dev)) {
vmstate_unregister(VMSTATE_IF(n->primary_dev),
qdev_get_vmsd(n->primary_dev),
n->primary_dev);
@@ -3172,7 +3173,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
}
} else if (migration_has_failed(s)) {
/* We already unplugged the device let's plug it back */
- if (!failover_replug_primary(n, &err)) {
+ if (!failover_replug_primary(n, n->primary_dev, &err)) {
if (err) {
error_report_err(err);
}
--
2.27.0

View File

@ -0,0 +1,52 @@
From 03ad2d1426775c5c993f59512932c4bbf62206c1 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:25 -0500
Subject: [PATCH 28/54] failover: Remove external partially_hotplugged property
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-6-lvivier@redhat.com>
Patchwork-id: 101251
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 05/27] failover: Remove external partially_hotplugged property
Bugzilla: 1819991
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
It was only set "once", and with the wrong value. As far as I can see,
libvirt still don't use it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-7-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 594d308b9314b446ed2ccc42de7b4d57ba1b7118)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 3f658d6246..6ca85627d8 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3135,10 +3135,6 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
}
qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort);
qatomic_set(&n->primary_should_be_hidden, false);
- if (!qemu_opt_set_bool(n->primary_device_opts,
- "partially_hotplugged", true, errp)) {
- return false;
- }
hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
if (hotplug_ctrl) {
hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err);
--
2.27.0

View File

@ -0,0 +1,60 @@
From e9380df03375e871de088ad5aee8fd19d6ad3794 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:32 -0500
Subject: [PATCH 35/54] failover: Remove memory leak
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-13-lvivier@redhat.com>
Patchwork-id: 101261
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 12/27] failover: Remove memory leak
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Two things, at this point:
* n->primary_device_id has to be set, otherwise
virtio_net_find_primary don't work. So we have a leak here.
* it has to be exactly the same that prim_dev->id because what
qdev_find_recursive() does is just compare this two values.
So remove the unneeded assignment and leaky bits.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-14-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 7b3dc2f8c0b817bbe78ba347130b3c99fe2c4470)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 6e5a56a230..70fa372c08 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -854,9 +854,7 @@ static DeviceState *virtio_connect_failover_devices(VirtIONet *n, Error **errp)
Error *err = NULL;
prim_dev = virtio_net_find_primary(n, &err);
- if (prim_dev) {
- n->primary_device_id = g_strdup(prim_dev->id);
- } else {
+ if (!prim_dev) {
error_propagate(errp, err);
}
--
2.27.0

View File

@ -0,0 +1,158 @@
From 52dce3568320900c79e34eb2093058e5c3f60aa9 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:46 -0500
Subject: [PATCH 49/54] failover: Remove primary_dev member
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-27-lvivier@redhat.com>
Patchwork-id: 101250
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 26/27] failover: Remove primary_dev member
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Only three uses remained, and we can remove them on that case.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-28-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 21e8709b29cd981c74565e75276ed476c954cbbf)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 55 +++++++++++++++-------------------
include/hw/virtio/virtio-net.h | 1 -
2 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9203d81780..044ac95f6f 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -832,13 +832,31 @@ static char *failover_find_primary_device_id(VirtIONet *n)
return fid.id;
}
+/**
+ * Find the primary device for this failover virtio-net
+ *
+ * @n: VirtIONet device
+ * @errp: returns an error if this function fails
+ */
+static DeviceState *failover_find_primary_device(VirtIONet *n)
+{
+ char *id = failover_find_primary_device_id(n);
+
+ if (!id) {
+ return NULL;
+ }
+
+ return qdev_find_recursive(sysbus_get_default(), id);
+}
+
static void failover_add_primary(VirtIONet *n, Error **errp)
{
Error *err = NULL;
QemuOpts *opts;
char *id;
+ DeviceState *dev = failover_find_primary_device(n);
- if (n->primary_dev) {
+ if (dev) {
return;
}
@@ -848,7 +866,7 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
}
opts = qemu_opts_find(qemu_find_opts("device"), id);
if (opts) {
- n->primary_dev = qdev_device_add(opts, &err);
+ dev = qdev_device_add(opts, &err);
if (err) {
qemu_opts_del(opts);
}
@@ -861,23 +879,6 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
error_propagate(errp, err);
}
-/**
- * Find the primary device for this failover virtio-net
- *
- * @n: VirtIONet device
- * @errp: returns an error if this function fails
- */
-static DeviceState *failover_find_primary_device(VirtIONet *n)
-{
- char *id = failover_find_primary_device_id(n);
-
- if (!id) {
- return NULL;
- }
-
- return qdev_find_recursive(sysbus_get_default(), id);
-}
-
static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -933,19 +934,9 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
qatomic_set(&n->failover_primary_hidden, false);
failover_add_primary(n, &err);
if (err) {
- n->primary_dev = failover_find_primary_device(n);
- failover_add_primary(n, &err);
- if (err) {
- goto out_err;
- }
+ warn_report_err(err);
}
}
- return;
-
-out_err:
- if (err) {
- warn_report_err(err);
- }
}
static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
@@ -3420,13 +3411,15 @@ static int virtio_net_pre_save(void *opaque)
static bool primary_unplug_pending(void *opaque)
{
DeviceState *dev = opaque;
+ DeviceState *primary;
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIONet *n = VIRTIO_NET(vdev);
if (!virtio_vdev_has_feature(vdev, VIRTIO_NET_F_STANDBY)) {
return false;
}
- return n->primary_dev ? n->primary_dev->pending_deleted_event : false;
+ primary = failover_find_primary_device(n);
+ return primary ? primary->pending_deleted_event : false;
}
static bool dev_unplug_pending(void *opaque)
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index efef64e02f..7e96d193aa 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -202,7 +202,6 @@ struct VirtIONet {
AnnounceTimer announce_timer;
bool needs_vnet_hdr_swap;
bool mtu_bypass_backend;
- DeviceState *primary_dev;
/* primary failover device is hidden*/
bool failover_primary_hidden;
bool failover;
--
2.27.0

View File

@ -0,0 +1,96 @@
From 277c3c13377cc7f41d4121fdce918df3005fc063 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:31 -0500
Subject: [PATCH 34/54] failover: Remove primary_device_dict
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-12-lvivier@redhat.com>
Patchwork-id: 101262
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 11/27] failover: Remove primary_device_dict
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
It was only used once. And we have there opts->id, so no need for it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-13-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 9673a88e97d1eb428872bd261dbf56a0f3c2fd71)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 17 ++++-------------
include/hw/virtio/virtio-net.h | 1 -
2 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 953d5c2bc8..6e5a56a230 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3186,28 +3186,21 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
if (!device_opts) {
return -1;
}
- n->primary_device_dict = qemu_opts_to_qdict(device_opts,
- n->primary_device_dict);
standby_id = qemu_opt_get(device_opts, "failover_pair_id");
if (g_strcmp0(standby_id, n->netclient_name) == 0) {
match_found = true;
} else {
match_found = false;
hide = false;
- n->primary_device_dict = NULL;
goto out;
}
/* failover_primary_hidden is set during feature negotiation */
hide = qatomic_read(&n->failover_primary_hidden);
-
- if (n->primary_device_dict) {
- g_free(n->primary_device_id);
- n->primary_device_id = g_strdup(qdict_get_try_str(
- n->primary_device_dict, "id"));
- if (!n->primary_device_id) {
- warn_report("primary_device_id not set");
- }
+ g_free(n->primary_device_id);
+ n->primary_device_id = g_strdup(device_opts->id);
+ if (!n->primary_device_id) {
+ warn_report("primary_device_id not set");
}
out:
@@ -3396,8 +3389,6 @@ static void virtio_net_device_unrealize(DeviceState *dev)
if (n->failover) {
device_listener_unregister(&n->primary_listener);
g_free(n->primary_device_id);
- qobject_unref(n->primary_device_dict);
- n->primary_device_dict = NULL;
}
max_queues = n->multiqueue ? n->max_queues : 1;
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index a055f39dd6..fe353d8299 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -202,7 +202,6 @@ struct VirtIONet {
AnnounceTimer announce_timer;
bool needs_vnet_hdr_swap;
bool mtu_bypass_backend;
- QDict *primary_device_dict;
DeviceState *primary_dev;
char *primary_device_id;
/* primary failover device is hidden*/
--
2.27.0

View File

@ -0,0 +1,110 @@
From ec36f213983c0ea89fe8db8b44d1105df0bd3dc2 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:29 -0500
Subject: [PATCH 32/54] failover: Remove primary_device_opts
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-10-lvivier@redhat.com>
Patchwork-id: 101259
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 09/27] failover: Remove primary_device_opts
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
It was really only used once, in failover_add_primary(). Just search
for it on global opts when it is needed.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-11-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 19e49bc2e984bd065719fc3595f35368b3ae87cd)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 21 +++++----------------
include/hw/virtio/virtio-net.h | 1 -
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index e334f05352..2a99b0e0f6 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -791,17 +791,17 @@ static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n)
static void failover_add_primary(VirtIONet *n, Error **errp)
{
Error *err = NULL;
+ QemuOpts *opts;
if (n->primary_dev) {
return;
}
- n->primary_device_opts = qemu_opts_find(qemu_find_opts("device"),
- n->primary_device_id);
- if (n->primary_device_opts) {
- n->primary_dev = qdev_device_add(n->primary_device_opts, &err);
+ opts = qemu_opts_find(qemu_find_opts("device"), n->primary_device_id);
+ if (opts) {
+ n->primary_dev = qdev_device_add(opts, &err);
if (err) {
- qemu_opts_del(n->primary_device_opts);
+ qemu_opts_del(opts);
}
} else {
error_setg(errp, "Primary device not found");
@@ -856,7 +856,6 @@ static DeviceState *virtio_connect_failover_devices(VirtIONet *n, Error **errp)
prim_dev = virtio_net_find_primary(n, &err);
if (prim_dev) {
n->primary_device_id = g_strdup(prim_dev->id);
- n->primary_device_opts = prim_dev->opts;
} else {
error_propagate(errp, err);
}
@@ -3113,14 +3112,6 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
if (!pdev->partially_hotplugged) {
return true;
}
- if (!n->primary_device_opts) {
- n->primary_device_opts = qemu_opts_from_qdict(qemu_find_opts("device"),
- n->primary_device_dict,
- errp);
- if (!n->primary_device_opts) {
- return false;
- }
- }
primary_bus = n->primary_dev->parent_bus;
if (!primary_bus) {
error_setg(errp, "virtio_net: couldn't find primary bus");
@@ -3211,8 +3202,6 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
goto out;
}
- n->primary_device_opts = device_opts;
-
/* failover_primary_hidden is set during feature negotiation */
hide = qatomic_read(&n->failover_primary_hidden);
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index ca68be759f..7159e6c0a0 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -202,7 +202,6 @@ struct VirtIONet {
AnnounceTimer announce_timer;
bool needs_vnet_hdr_swap;
bool mtu_bypass_backend;
- QemuOpts *primary_device_opts;
QDict *primary_device_dict;
DeviceState *primary_dev;
char *primary_device_id;
--
2.27.0

View File

@ -0,0 +1,68 @@
From 69ba4fc743b29e9e3f595c1e96596204abc1aa0e Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:24 -0500
Subject: [PATCH 27/54] failover: Remove unused parameter
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-5-lvivier@redhat.com>
Patchwork-id: 101243
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 04/27] failover: Remove unused parameter
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-6-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 82ceb65799855efb0db965a6ef86d81ae1c8bcd7)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 786d313330..3f658d6246 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -855,9 +855,7 @@ static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp)
return dev;
}
-static DeviceState *virtio_connect_failover_devices(VirtIONet *n,
- DeviceState *dev,
- Error **errp)
+static DeviceState *virtio_connect_failover_devices(VirtIONet *n, Error **errp)
{
DeviceState *prim_dev = NULL;
Error *err = NULL;
@@ -928,7 +926,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
qatomic_set(&n->primary_should_be_hidden, false);
failover_add_primary(n, &err);
if (err) {
- n->primary_dev = virtio_connect_failover_devices(n, n->qdev, &err);
+ n->primary_dev = virtio_connect_failover_devices(n, &err);
if (err) {
goto out_err;
}
@@ -3164,7 +3162,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
should_be_hidden = qatomic_read(&n->primary_should_be_hidden);
if (!n->primary_dev) {
- n->primary_dev = virtio_connect_failover_devices(n, n->qdev, &err);
+ n->primary_dev = virtio_connect_failover_devices(n, &err);
if (!n->primary_dev) {
return;
}
--
2.27.0

View File

@ -0,0 +1,113 @@
From 6d228bc32fa1e6c9619dc99dc10bfa3a9116bbf0 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:27 -0500
Subject: [PATCH 30/54] failover: Rename bool to failover_primary_hidden
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-8-lvivier@redhat.com>
Patchwork-id: 101260
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 07/27] failover: Rename bool to failover_primary_hidden
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
You should not use passive naming variables.
And once there, be able to search for them.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-9-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit e2bde83e23d3cfc1d90911c74500fd2e3b0b04fa)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 14 +++++++-------
include/hw/virtio/virtio-net.h | 3 ++-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 3e82108d42..c221671852 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -916,7 +916,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
if (virtio_has_feature(features, VIRTIO_NET_F_STANDBY)) {
qapi_event_send_failover_negotiated(n->netclient_name);
- qatomic_set(&n->primary_should_be_hidden, false);
+ qatomic_set(&n->failover_primary_hidden, false);
failover_add_primary(n, &err);
if (err) {
n->primary_dev = virtio_connect_failover_devices(n, &err);
@@ -3127,7 +3127,7 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
return false;
}
qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort);
- qatomic_set(&n->primary_should_be_hidden, false);
+ qatomic_set(&n->failover_primary_hidden, false);
hotplug_ctrl = qdev_get_hotplug_handler(n->primary_dev);
if (hotplug_ctrl) {
hotplug_handler_pre_plug(hotplug_ctrl, n->primary_dev, &err);
@@ -3148,7 +3148,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
bool should_be_hidden;
Error *err = NULL;
- should_be_hidden = qatomic_read(&n->primary_should_be_hidden);
+ should_be_hidden = qatomic_read(&n->failover_primary_hidden);
if (!n->primary_dev) {
n->primary_dev = virtio_connect_failover_devices(n, &err);
@@ -3163,7 +3163,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
qdev_get_vmsd(n->primary_dev),
n->primary_dev);
qapi_event_send_unplug_primary(n->primary_device_id);
- qatomic_set(&n->primary_should_be_hidden, true);
+ qatomic_set(&n->failover_primary_hidden, true);
} else {
warn_report("couldn't unplug primary device");
}
@@ -3213,8 +3213,8 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
n->primary_device_opts = device_opts;
- /* primary_should_be_hidden is set during feature negotiation */
- hide = qatomic_read(&n->primary_should_be_hidden);
+ /* failover_primary_hidden is set during feature negotiation */
+ hide = qatomic_read(&n->failover_primary_hidden);
if (n->primary_device_dict) {
g_free(n->primary_device_id);
@@ -3271,7 +3271,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
if (n->failover) {
n->primary_listener.should_be_hidden =
virtio_net_primary_should_be_hidden;
- qatomic_set(&n->primary_should_be_hidden, true);
+ qatomic_set(&n->failover_primary_hidden, true);
device_listener_register(&n->primary_listener);
n->migration_state.notify = virtio_net_migration_state_notifier;
add_migration_state_change_notifier(&n->migration_state);
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index c8da637d40..ca68be759f 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -207,7 +207,8 @@ struct VirtIONet {
DeviceState *primary_dev;
char *primary_device_id;
char *standby_id;
- bool primary_should_be_hidden;
+ /* primary failover device is hidden*/
+ bool failover_primary_hidden;
bool failover;
DeviceListener primary_listener;
Notifier migration_state;
--
2.27.0

View File

@ -0,0 +1,127 @@
From 1fbde79ae60990ff0439f3f3bb060f7d723e4910 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:35 -0500
Subject: [PATCH 38/54] failover: Rename function to hide_device()
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-16-lvivier@redhat.com>
Patchwork-id: 101264
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 15/27] failover: Rename function to hide_device()
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
You should not use pasive.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-17-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit b91ad981b867e15171234efc3f2ab4074d377cef)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/core/qdev.c | 4 ++--
hw/net/virtio-net.c | 7 +++----
include/hw/qdev-core.h | 28 +++++++++++++++-------------
3 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 8f4b8f3cc1..cbdff0b6c6 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -217,8 +217,8 @@ bool qdev_should_hide_device(QemuOpts *opts)
DeviceListener *listener;
QTAILQ_FOREACH(listener, &device_listeners, link) {
- if (listener->should_be_hidden) {
- if (listener->should_be_hidden(listener, opts)) {
+ if (listener->hide_device) {
+ if (listener->hide_device(listener, opts)) {
return true;
}
}
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9f12d33da0..747614ff2a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3161,8 +3161,8 @@ static void virtio_net_migration_state_notifier(Notifier *notifier, void *data)
virtio_net_handle_migration_primary(n, s);
}
-static bool virtio_net_primary_should_be_hidden(DeviceListener *listener,
- QemuOpts *device_opts)
+static bool failover_hide_primary_device(DeviceListener *listener,
+ QemuOpts *device_opts)
{
VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
bool hide;
@@ -3220,8 +3220,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
}
if (n->failover) {
- n->primary_listener.should_be_hidden =
- virtio_net_primary_should_be_hidden;
+ n->primary_listener.hide_device = failover_hide_primary_device;
qatomic_set(&n->failover_primary_hidden, true);
device_listener_register(&n->primary_listener);
n->migration_state.notify = virtio_net_migration_state_notifier;
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 250f4edef6..6ac86db44e 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -81,16 +81,17 @@ typedef void (*BusUnrealize)(BusState *bus);
* </note>
*
* # Hiding a device #
- * To hide a device, a DeviceListener function should_be_hidden() needs to
+ * To hide a device, a DeviceListener function hide_device() needs to
* be registered.
- * It can be used to defer adding a device and therefore hide it from the
- * guest. The handler registering to this DeviceListener can save the QOpts
- * passed to it for re-using it later and must return that it wants the device
- * to be/remain hidden or not. When the handler function decides the device
- * shall not be hidden it will be added in qdev_device_add() and
- * realized as any other device. Otherwise qdev_device_add() will return early
- * without adding the device. The guest will not see a "hidden" device
- * until it was marked don't hide and qdev_device_add called again.
+ * It can be used to defer adding a device and therefore hide it from
+ * the guest. The handler registering to this DeviceListener can save
+ * the QOpts passed to it for re-using it later. It must return if it
+ * wants the device to be hidden or visible. When the handler function
+ * decides the device shall be visible it will be added with
+ * qdev_device_add() and realized as any other device. Otherwise
+ * qdev_device_add() will return early without adding the device. The
+ * guest will not see a "hidden" device until it was marked visible
+ * and qdev_device_add called again.
*
*/
struct DeviceClass {
@@ -196,11 +197,12 @@ struct DeviceListener {
void (*realize)(DeviceListener *listener, DeviceState *dev);
void (*unrealize)(DeviceListener *listener, DeviceState *dev);
/*
- * This callback is called upon init of the DeviceState and allows to
- * inform qdev that a device should be hidden, depending on the device
- * opts, for example, to hide a standby device.
+ * This callback is called upon init of the DeviceState and
+ * informs qdev if a device should be visible or hidden. We can
+ * hide a failover device depending for example on the device
+ * opts.
*/
- bool (*should_be_hidden)(DeviceListener *listener, QemuOpts *device_opts);
+ bool (*hide_device)(DeviceListener *listener, QemuOpts *device_opts);
QTAILQ_ENTRY(DeviceListener) link;
};
--
2.27.0

View File

@ -0,0 +1,77 @@
From e1ea7c178c1762dca02e2c85f57ccfad1063c753 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:37 -0500
Subject: [PATCH 40/54] failover: Rename to failover_find_primary_device()
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-18-lvivier@redhat.com>
Patchwork-id: 101263
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 17/27] failover: Rename to failover_find_primary_device()
Bugzilla: 1819991
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
This commit:
* Rename them to failover_find_primary_devices() so
- it starts with failover_
- it don't connect anything, just find the primary device
* Create documentation for the function
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-19-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 85d3b93196e43c4493c118aa9e3a82fe657636b5)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index c6200b924e..ff82f1017d 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -826,7 +826,13 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
return ret;
}
-static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp)
+/**
+ * Find the primary device for this failover virtio-net
+ *
+ * @n: VirtIONet device
+ * @errp: returns an error if this function fails
+ */
+static DeviceState *failover_find_primary_device(VirtIONet *n, Error **errp)
{
Error *err = NULL;
@@ -891,7 +897,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
qatomic_set(&n->failover_primary_hidden, false);
failover_add_primary(n, &err);
if (err) {
- n->primary_dev = virtio_net_find_primary(n, &err);
+ n->primary_dev = failover_find_primary_device(n, &err);
if (err) {
goto out_err;
}
@@ -3115,7 +3121,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
should_be_hidden = qatomic_read(&n->failover_primary_hidden);
if (!n->primary_dev) {
- n->primary_dev = virtio_net_find_primary(n, &err);
+ n->primary_dev = failover_find_primary_device(n, &err);
if (!n->primary_dev) {
return;
}
--
2.27.0

View File

@ -0,0 +1,49 @@
From be9147ddedc35a458b976a71fd947634ab71bb44 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:22 -0500
Subject: [PATCH 25/54] failover: Use always atomics for
primary_should_be_hidden
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-3-lvivier@redhat.com>
Patchwork-id: 101247
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 02/27] failover: Use always atomics for primary_should_be_hidden
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-4-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 587f2fcb93eddf69736e00731a2da018a0e0a726)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1011a524bf..a0fa63e7cb 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3136,7 +3136,7 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
return false;
}
qdev_set_parent_bus(n->primary_dev, n->primary_bus, &error_abort);
- n->primary_should_be_hidden = false;
+ qatomic_set(&n->primary_should_be_hidden, false);
if (!qemu_opt_set_bool(n->primary_device_opts,
"partially_hotplugged", true, errp)) {
return false;
--
2.27.0

View File

@ -0,0 +1,128 @@
From 845e4811506c58b8f1f4cfcb183994f1d0f4d66b Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:43 -0500
Subject: [PATCH 46/54] failover: We don't need to cache primary_device_id
anymore
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-24-lvivier@redhat.com>
Patchwork-id: 101258
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 23/27] failover: We don't need to cache primary_device_id anymore
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-25-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 3abad4a221e050d43fa8540677b285057642baaf)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 20 ++++++++++----------
include/hw/virtio/virtio-net.h | 1 -
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2c502c13fd..746ed3fb71 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -824,6 +824,7 @@ static char *failover_find_primary_device_id(VirtIONet *n)
Error *err = NULL;
FailoverId fid;
+ fid.n = n;
if (!qemu_opts_foreach(qemu_find_opts("device"),
failover_set_primary, &fid, &err)) {
return NULL;
@@ -835,12 +836,17 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
{
Error *err = NULL;
QemuOpts *opts;
+ char *id;
if (n->primary_dev) {
return;
}
- opts = qemu_opts_find(qemu_find_opts("device"), n->primary_device_id);
+ id = failover_find_primary_device_id(n);
+ if (!id) {
+ return;
+ }
+ opts = qemu_opts_find(qemu_find_opts("device"), id);
if (opts) {
n->primary_dev = qdev_device_add(opts, &err);
if (err) {
@@ -868,9 +874,8 @@ static DeviceState *failover_find_primary_device(VirtIONet *n)
if (!id) {
return NULL;
}
- n->primary_device_id = g_strdup(id);
- return qdev_find_recursive(sysbus_get_default(), n->primary_device_id);
+ return qdev_find_recursive(sysbus_get_default(), id);
}
static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
@@ -3160,7 +3165,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
vmstate_unregister(VMSTATE_IF(n->primary_dev),
qdev_get_vmsd(n->primary_dev),
n->primary_dev);
- qapi_event_send_unplug_primary(n->primary_device_id);
+ qapi_event_send_unplug_primary(n->primary_dev->id);
qatomic_set(&n->failover_primary_hidden, true);
} else {
warn_report("couldn't unplug primary device");
@@ -3186,7 +3191,6 @@ static bool failover_hide_primary_device(DeviceListener *listener,
QemuOpts *device_opts)
{
VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
- bool hide;
const char *standby_id;
if (!device_opts) {
@@ -3198,10 +3202,7 @@ static bool failover_hide_primary_device(DeviceListener *listener,
}
/* failover_primary_hidden is set during feature negotiation */
- hide = qatomic_read(&n->failover_primary_hidden);
- g_free(n->primary_device_id);
- n->primary_device_id = g_strdup(device_opts->id);
- return hide;
+ return qatomic_read(&n->failover_primary_hidden);
}
static void virtio_net_device_realize(DeviceState *dev, Error **errp)
@@ -3378,7 +3379,6 @@ static void virtio_net_device_unrealize(DeviceState *dev)
if (n->failover) {
device_listener_unregister(&n->primary_listener);
- g_free(n->primary_device_id);
}
max_queues = n->multiqueue ? n->max_queues : 1;
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index fe353d8299..efef64e02f 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -203,7 +203,6 @@ struct VirtIONet {
bool needs_vnet_hdr_swap;
bool mtu_bypass_backend;
DeviceState *primary_dev;
- char *primary_device_id;
/* primary failover device is hidden*/
bool failover_primary_hidden;
bool failover;
--
2.27.0

View File

@ -0,0 +1,171 @@
From 619e58f19e3e20c4144eb1259ce2f338d09176c1 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:21 -0500
Subject: [PATCH 24/54] failover: fix indentantion
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-2-lvivier@redhat.com>
Patchwork-id: 101240
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 01/27] failover: fix indentantion
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Once there, remove not needed cast.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-3-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 1c775d65d4bff3a5a9876e398b2e689bc45aa1f7)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 33 +++++++++++++++------------------
softmmu/qdev-monitor.c | 4 ++--
2 files changed, 17 insertions(+), 20 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9179013ac4..1011a524bf 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -797,7 +797,7 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
}
n->primary_device_opts = qemu_opts_find(qemu_find_opts("device"),
- n->primary_device_id);
+ n->primary_device_id);
if (n->primary_device_opts) {
n->primary_dev = qdev_device_add(n->primary_device_opts, &err);
if (err) {
@@ -814,9 +814,9 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
} else {
error_setg(errp, "Primary device not found");
error_append_hint(errp, "Virtio-net failover will not work. Make "
- "sure primary device has parameter"
- " failover_pair_id=<virtio-net-id>\n");
-}
+ "sure primary device has parameter"
+ " failover_pair_id=<virtio-net-id>\n");
+ }
error_propagate(errp, err);
}
@@ -824,7 +824,6 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
{
VirtIONet *n = opaque;
int ret = 0;
-
const char *standby_id = qemu_opt_get(opts, "failover_pair_id");
if (standby_id != NULL && (g_strcmp0(standby_id, n->netclient_name) == 0)) {
@@ -841,14 +840,14 @@ static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp)
Error *err = NULL;
if (qemu_opts_foreach(qemu_find_opts("device"),
- is_my_primary, n, &err)) {
+ is_my_primary, n, &err)) {
if (err) {
error_propagate(errp, err);
return NULL;
}
if (n->primary_device_id) {
dev = qdev_find_recursive(sysbus_get_default(),
- n->primary_device_id);
+ n->primary_device_id);
} else {
error_setg(errp, "Primary device id not found");
return NULL;
@@ -857,8 +856,6 @@ static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp)
return dev;
}
-
-
static DeviceState *virtio_connect_failover_devices(VirtIONet *n,
DeviceState *dev,
Error **errp)
@@ -3126,9 +3123,9 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
return true;
}
if (!n->primary_device_opts) {
- n->primary_device_opts = qemu_opts_from_qdict(
- qemu_find_opts("device"),
- n->primary_device_dict, errp);
+ n->primary_device_opts = qemu_opts_from_qdict(qemu_find_opts("device"),
+ n->primary_device_dict,
+ errp);
if (!n->primary_device_opts) {
return false;
}
@@ -3176,8 +3173,8 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
if (migration_in_setup(s) && !should_be_hidden) {
if (failover_unplug_primary(n)) {
vmstate_unregister(VMSTATE_IF(n->primary_dev),
- qdev_get_vmsd(n->primary_dev),
- n->primary_dev);
+ qdev_get_vmsd(n->primary_dev),
+ n->primary_dev);
qapi_event_send_unplug_primary(n->primary_device_id);
qatomic_set(&n->primary_should_be_hidden, true);
} else {
@@ -3201,7 +3198,7 @@ static void virtio_net_migration_state_notifier(Notifier *notifier, void *data)
}
static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
- QemuOpts *device_opts)
+ QemuOpts *device_opts)
{
VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
bool match_found = false;
@@ -3211,11 +3208,11 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
return -1;
}
n->primary_device_dict = qemu_opts_to_qdict(device_opts,
- n->primary_device_dict);
+ n->primary_device_dict);
if (n->primary_device_dict) {
g_free(n->standby_id);
n->standby_id = g_strdup(qdict_get_try_str(n->primary_device_dict,
- "failover_pair_id"));
+ "failover_pair_id"));
}
if (g_strcmp0(n->standby_id, n->netclient_name) == 0) {
match_found = true;
@@ -3235,7 +3232,7 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
if (n->primary_device_dict) {
g_free(n->primary_device_id);
n->primary_device_id = g_strdup(qdict_get_try_str(
- n->primary_device_dict, "id"));
+ n->primary_device_dict, "id"));
if (!n->primary_device_id) {
warn_report("primary_device_id not set");
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index bf79d0bbcd..a25f5d612c 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -573,10 +573,10 @@ void qdev_set_id(DeviceState *dev, const char *id)
}
static int is_failover_device(void *opaque, const char *name, const char *value,
- Error **errp)
+ Error **errp)
{
if (strcmp(name, "failover_pair_id") == 0) {
- QemuOpts *opts = (QemuOpts *)opaque;
+ QemuOpts *opts = opaque;
if (qdev_should_hide_device(opts)) {
return 1;
--
2.27.0

View File

@ -0,0 +1,48 @@
From 97b7137652441a3d458f3d9f7bc326047de185c3 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:28 -0500
Subject: [PATCH 31/54] failover: g_strcmp0() knows how to handle NULL
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-9-lvivier@redhat.com>
Patchwork-id: 101249
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 08/27] failover: g_strcmp0() knows how to handle NULL
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-10-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 518eda9fda49da910d47f5baf66a1c0d1d30cebd)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index c221671852..e334f05352 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -818,7 +818,7 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
int ret = 0;
const char *standby_id = qemu_opt_get(opts, "failover_pair_id");
- if (standby_id != NULL && (g_strcmp0(standby_id, n->netclient_name) == 0)) {
+ if (g_strcmp0(standby_id, n->netclient_name) == 0) {
n->primary_device_id = g_strdup(opts->id);
ret = 1;
}
--
2.27.0

View File

@ -0,0 +1,68 @@
From 06c77533c61f65886bf0a9236d8f13085b2f3e51 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:40 -0500
Subject: [PATCH 43/54] failover: make sure that id always exist
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-21-lvivier@redhat.com>
Patchwork-id: 101257
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 20/27] failover: make sure that id always exist
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
We check that it exist at device creation time, so we don't have to
check anywhere else.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-22-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit fec037c1e2da0a7ea54eabce65cc14d461fdc5eb)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 3 ---
softmmu/qdev-monitor.c | 4 ++++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index ff82f1017d..c708c03cf6 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3173,9 +3173,6 @@ static bool failover_hide_primary_device(DeviceListener *listener,
hide = qatomic_read(&n->failover_primary_hidden);
g_free(n->primary_device_id);
n->primary_device_id = g_strdup(device_opts->id);
- if (!n->primary_device_id) {
- warn_report("primary_device_id not set");
- }
return hide;
}
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 0e10f0466f..301089eaea 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -613,6 +613,10 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
}
if (qemu_opt_get(opts, "failover_pair_id")) {
+ if (!opts->id) {
+ error_setg(errp, "Device with failover_pair_id don't have id");
+ return NULL;
+ }
if (qdev_should_hide_device(opts)) {
if (bus && !qbus_is_hotpluggable(bus)) {
error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
--
2.27.0

View File

@ -0,0 +1,87 @@
From 0c0190ed0d933a6900230427c374e4b93faab73b Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:23 -0500
Subject: [PATCH 26/54] failover: primary bus is only used once, and where it
is set
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-4-lvivier@redhat.com>
Patchwork-id: 101245
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 03/27] failover: primary bus is only used once, and where it is set
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Just remove the struct member.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-5-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 78274682b79d48e8de76c817c67c3cfbb76dc2ee)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 8 ++++----
include/hw/virtio/virtio-net.h | 1 -
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index a0fa63e7cb..786d313330 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -804,7 +804,6 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
qemu_opts_del(n->primary_device_opts);
}
if (n->primary_dev) {
- n->primary_bus = n->primary_dev->parent_bus;
if (err) {
qdev_unplug(n->primary_dev, &err);
qdev_set_id(n->primary_dev, "");
@@ -3118,6 +3117,7 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
Error *err = NULL;
HotplugHandler *hotplug_ctrl;
PCIDevice *pdev = PCI_DEVICE(n->primary_dev);
+ BusState *primary_bus;
if (!pdev->partially_hotplugged) {
return true;
@@ -3130,12 +3130,12 @@ static bool failover_replug_primary(VirtIONet *n, Error **errp)
return false;
}
}
- n->primary_bus = n->primary_dev->parent_bus;
- if (!n->primary_bus) {
+ primary_bus = n->primary_dev->parent_bus;
+ if (!primary_bus) {
error_setg(errp, "virtio_net: couldn't find primary bus");
return false;
}
- qdev_set_parent_bus(n->primary_dev, n->primary_bus, &error_abort);
+ qdev_set_parent_bus(n->primary_dev, primary_bus, &error_abort);
qatomic_set(&n->primary_should_be_hidden, false);
if (!qemu_opt_set_bool(n->primary_device_opts,
"partially_hotplugged", true, errp)) {
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index f4852ac27b..c8da637d40 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -205,7 +205,6 @@ struct VirtIONet {
QemuOpts *primary_device_opts;
QDict *primary_device_dict;
DeviceState *primary_dev;
- BusState *primary_bus;
char *primary_device_id;
char *standby_id;
bool primary_should_be_hidden;
--
2.27.0

View File

@ -0,0 +1,55 @@
From 63f2415d2cee7bcf24e7f3dc515c5155731071e6 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:26 -0500
Subject: [PATCH 29/54] failover: qdev_device_add() returns err or dev set
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-7-lvivier@redhat.com>
Patchwork-id: 101252
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 06/27] failover: qdev_device_add() returns err or dev set
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Never both.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-8-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 3d1c7a9782d19052505aabc8f2c134ccd6f3f3fb)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 6ca85627d8..3e82108d42 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -803,13 +803,6 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
if (err) {
qemu_opts_del(n->primary_device_opts);
}
- if (n->primary_dev) {
- if (err) {
- qdev_unplug(n->primary_dev, &err);
- qdev_set_id(n->primary_dev, "");
-
- }
- }
} else {
error_setg(errp, "Primary device not found");
error_append_hint(errp, "Virtio-net failover will not work. Make "
--
2.27.0

View File

@ -0,0 +1,72 @@
From 96883a1a05766ac6c1a2a064f40aab6c0bd54861 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:41 -0500
Subject: [PATCH 44/54] failover: remove failover_find_primary_device() error
parameter
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-22-lvivier@redhat.com>
Patchwork-id: 101265
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 21/27] failover: remove failover_find_primary_device() error parameter
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
It can never give one error.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-23-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 0a0a27d66bcb275e5b984d8758880a7eff75464e)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index c708c03cf6..b994796734 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -832,7 +832,7 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
* @n: VirtIONet device
* @errp: returns an error if this function fails
*/
-static DeviceState *failover_find_primary_device(VirtIONet *n, Error **errp)
+static DeviceState *failover_find_primary_device(VirtIONet *n)
{
Error *err = NULL;
@@ -897,10 +897,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
qatomic_set(&n->failover_primary_hidden, false);
failover_add_primary(n, &err);
if (err) {
- n->primary_dev = failover_find_primary_device(n, &err);
- if (err) {
- goto out_err;
- }
+ n->primary_dev = failover_find_primary_device(n);
failover_add_primary(n, &err);
if (err) {
goto out_err;
@@ -3121,7 +3118,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
should_be_hidden = qatomic_read(&n->failover_primary_hidden);
if (!n->primary_dev) {
- n->primary_dev = failover_find_primary_device(n, &err);
+ n->primary_dev = failover_find_primary_device(n);
if (!n->primary_dev) {
return;
}
--
2.27.0

View File

@ -0,0 +1,89 @@
From cead8b9c03911360666ac3bb56d7b1db068ade36 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:30 -0500
Subject: [PATCH 33/54] failover: remove standby_id variable
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-11-lvivier@redhat.com>
Patchwork-id: 101248
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 10/27] failover: remove standby_id variable
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
We can calculate it, and we only use it once anyways.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-12-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 4f0303aed87f83715055e558176046a8a3d9b987)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 11 +++--------
include/hw/virtio/virtio-net.h | 1 -
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2a99b0e0f6..953d5c2bc8 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3181,23 +3181,19 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
bool match_found = false;
bool hide = false;
+ const char *standby_id;
if (!device_opts) {
return -1;
}
n->primary_device_dict = qemu_opts_to_qdict(device_opts,
n->primary_device_dict);
- if (n->primary_device_dict) {
- g_free(n->standby_id);
- n->standby_id = g_strdup(qdict_get_try_str(n->primary_device_dict,
- "failover_pair_id"));
- }
- if (g_strcmp0(n->standby_id, n->netclient_name) == 0) {
+ standby_id = qemu_opt_get(device_opts, "failover_pair_id");
+ if (g_strcmp0(standby_id, n->netclient_name) == 0) {
match_found = true;
} else {
match_found = false;
hide = false;
- g_free(n->standby_id);
n->primary_device_dict = NULL;
goto out;
}
@@ -3400,7 +3396,6 @@ static void virtio_net_device_unrealize(DeviceState *dev)
if (n->failover) {
device_listener_unregister(&n->primary_listener);
g_free(n->primary_device_id);
- g_free(n->standby_id);
qobject_unref(n->primary_device_dict);
n->primary_device_dict = NULL;
}
diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
index 7159e6c0a0..a055f39dd6 100644
--- a/include/hw/virtio/virtio-net.h
+++ b/include/hw/virtio/virtio-net.h
@@ -205,7 +205,6 @@ struct VirtIONet {
QDict *primary_device_dict;
DeviceState *primary_dev;
char *primary_device_id;
- char *standby_id;
/* primary failover device is hidden*/
bool failover_primary_hidden;
bool failover;
--
2.27.0

View File

@ -0,0 +1,144 @@
From 8dadc3183e8e75e47b5f5e39823b9eaf950cf4fe Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:34 -0500
Subject: [PATCH 37/54] failover: should_be_hidden() should take a bool
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-15-lvivier@redhat.com>
Patchwork-id: 101241
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 14/27] failover: should_be_hidden() should take a bool
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
We didn't use at all the -1 value, and we don't really care. It was
only used for the cases when this is not the device that we are
searching for. And in that case we should not hide the device.
Once there, simplify virtio-Snet_primary_should_be_hidden.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-16-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 89631fed27bd76b0292d8b2a78291ea96185c87d)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/core/qdev.c | 19 +++++--------------
hw/net/virtio-net.c | 27 +++++++--------------------
include/hw/qdev-core.h | 2 +-
3 files changed, 13 insertions(+), 35 deletions(-)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 262bca716f..8f4b8f3cc1 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -214,26 +214,17 @@ void device_listener_unregister(DeviceListener *listener)
bool qdev_should_hide_device(QemuOpts *opts)
{
- int rc = -1;
DeviceListener *listener;
QTAILQ_FOREACH(listener, &device_listeners, link) {
- if (listener->should_be_hidden) {
- /*
- * should_be_hidden_will return
- * 1 if device matches opts and it should be hidden
- * 0 if device matches opts and should not be hidden
- * -1 if device doesn't match ops
- */
- rc = listener->should_be_hidden(listener, opts);
- }
-
- if (rc > 0) {
- break;
+ if (listener->should_be_hidden) {
+ if (listener->should_be_hidden(listener, opts)) {
+ return true;
+ }
}
}
- return rc > 0;
+ return false;
}
void qdev_set_legacy_instance_id(DeviceState *dev, int alias_id,
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 881907d1bd..9f12d33da0 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3161,24 +3161,19 @@ static void virtio_net_migration_state_notifier(Notifier *notifier, void *data)
virtio_net_handle_migration_primary(n, s);
}
-static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
- QemuOpts *device_opts)
+static bool virtio_net_primary_should_be_hidden(DeviceListener *listener,
+ QemuOpts *device_opts)
{
VirtIONet *n = container_of(listener, VirtIONet, primary_listener);
- bool match_found = false;
- bool hide = false;
+ bool hide;
const char *standby_id;
if (!device_opts) {
- return -1;
+ return false;
}
standby_id = qemu_opt_get(device_opts, "failover_pair_id");
- if (g_strcmp0(standby_id, n->netclient_name) == 0) {
- match_found = true;
- } else {
- match_found = false;
- hide = false;
- goto out;
+ if (g_strcmp0(standby_id, n->netclient_name) != 0) {
+ return false;
}
/* failover_primary_hidden is set during feature negotiation */
@@ -3188,15 +3183,7 @@ static int virtio_net_primary_should_be_hidden(DeviceListener *listener,
if (!n->primary_device_id) {
warn_report("primary_device_id not set");
}
-
-out:
- if (match_found && hide) {
- return 1;
- } else if (match_found && !hide) {
- return 0;
- } else {
- return -1;
- }
+ return hide;
}
static void virtio_net_device_realize(DeviceState *dev, Error **errp)
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 5e737195b5..250f4edef6 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -200,7 +200,7 @@ struct DeviceListener {
* inform qdev that a device should be hidden, depending on the device
* opts, for example, to hide a standby device.
*/
- int (*should_be_hidden)(DeviceListener *listener, QemuOpts *device_opts);
+ bool (*should_be_hidden)(DeviceListener *listener, QemuOpts *device_opts);
QTAILQ_ENTRY(DeviceListener) link;
};
--
2.27.0

View File

@ -0,0 +1,86 @@
From cf70ee739171e208243b5b06a57d2517df8c3d91 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:45 -0500
Subject: [PATCH 48/54] failover: simplify failover_unplug_primary
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-26-lvivier@redhat.com>
Patchwork-id: 101242
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 25/27] failover: simplify failover_unplug_primary
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
We can calculate device just once.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-27-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 07a5d816d50f5f876d5fcd43724a6ff17cf59a4f)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b37e9cd1d9..9203d81780 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -3146,34 +3146,29 @@ out:
return !err;
}
-static void virtio_net_handle_migration_primary(VirtIONet *n,
- MigrationState *s)
+static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationState *s)
{
bool should_be_hidden;
Error *err = NULL;
+ DeviceState *dev = failover_find_primary_device(n);
- should_be_hidden = qatomic_read(&n->failover_primary_hidden);
-
- if (!n->primary_dev) {
- n->primary_dev = failover_find_primary_device(n);
- if (!n->primary_dev) {
- return;
- }
+ if (!dev) {
+ return;
}
+ should_be_hidden = qatomic_read(&n->failover_primary_hidden);
+
if (migration_in_setup(s) && !should_be_hidden) {
- if (failover_unplug_primary(n, n->primary_dev)) {
- vmstate_unregister(VMSTATE_IF(n->primary_dev),
- qdev_get_vmsd(n->primary_dev),
- n->primary_dev);
- qapi_event_send_unplug_primary(n->primary_dev->id);
+ if (failover_unplug_primary(n, dev)) {
+ vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev);
+ qapi_event_send_unplug_primary(dev->id);
qatomic_set(&n->failover_primary_hidden, true);
} else {
warn_report("couldn't unplug primary device");
}
} else if (migration_has_failed(s)) {
/* We already unplugged the device let's plug it back */
- if (!failover_replug_primary(n, n->primary_dev, &err)) {
+ if (!failover_replug_primary(n, dev, &err)) {
if (err) {
error_report_err(err);
}
--
2.27.0

View File

@ -0,0 +1,70 @@
From 27a1972d1a5961a8218d5a52fba16b67816635fe Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:38 -0500
Subject: [PATCH 41/54] failover: simplify qdev_device_add() failover case
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-19-lvivier@redhat.com>
Patchwork-id: 101255
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 18/27] failover: simplify qdev_device_add() failover case
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
Just put allthe logic inside the same if.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-20-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 5f2ef3b0d032797b6bad9449dfece3a8111a8529)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
softmmu/qdev-monitor.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index a25f5d612c..12b7540f17 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -600,7 +600,6 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
const char *driver, *path;
DeviceState *dev = NULL;
BusState *bus = NULL;
- bool hide;
driver = qemu_opt_get(opts, "driver");
if (!driver) {
@@ -634,14 +633,16 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
return NULL;
}
}
- hide = should_hide_device(opts);
- if ((hide || qdev_hotplug) && bus && !qbus_is_hotpluggable(bus)) {
- error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+ if (should_hide_device(opts)) {
+ if (bus && !qbus_is_hotpluggable(bus)) {
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+ }
return NULL;
}
- if (hide) {
+ if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
return NULL;
}
--
2.27.0

View File

@ -0,0 +1,89 @@
From 7822f8042e26cca6c1307e26c6f08d5f99636d90 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:39 -0500
Subject: [PATCH 42/54] failover: simplify qdev_device_add()
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-20-lvivier@redhat.com>
Patchwork-id: 101256
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 19/27] failover: simplify qdev_device_add()
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
We don't need to walk the opts by hand. qmp_opt_get() already does
that. And then we can remove the functions that did that walk.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-21-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 2e28095369f4eab516852fd49dde17c3bfd782f9)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
softmmu/qdev-monitor.c | 32 ++++++--------------------------
1 file changed, 6 insertions(+), 26 deletions(-)
diff --git a/softmmu/qdev-monitor.c b/softmmu/qdev-monitor.c
index 12b7540f17..0e10f0466f 100644
--- a/softmmu/qdev-monitor.c
+++ b/softmmu/qdev-monitor.c
@@ -572,28 +572,6 @@ void qdev_set_id(DeviceState *dev, const char *id)
}
}
-static int is_failover_device(void *opaque, const char *name, const char *value,
- Error **errp)
-{
- if (strcmp(name, "failover_pair_id") == 0) {
- QemuOpts *opts = opaque;
-
- if (qdev_should_hide_device(opts)) {
- return 1;
- }
- }
-
- return 0;
-}
-
-static bool should_hide_device(QemuOpts *opts)
-{
- if (qemu_opt_foreach(opts, is_failover_device, opts, NULL) == 0) {
- return false;
- }
- return true;
-}
-
DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
{
DeviceClass *dc;
@@ -634,11 +612,13 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
}
}
- if (should_hide_device(opts)) {
- if (bus && !qbus_is_hotpluggable(bus)) {
- error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+ if (qemu_opt_get(opts, "failover_pair_id")) {
+ if (qdev_should_hide_device(opts)) {
+ if (bus && !qbus_is_hotpluggable(bus)) {
+ error_setg(errp, QERR_BUS_NO_HOTPLUG, bus->name);
+ }
+ return NULL;
}
- return NULL;
}
if (qdev_hotplug && bus && !qbus_is_hotpluggable(bus)) {
--
2.27.0

View File

@ -0,0 +1,70 @@
From 24bd4b43c3f59c9c28f924da8ef7a9dacc0f2f52 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:33 -0500
Subject: [PATCH 36/54] failover: simplify virtio_net_find_primary()
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-14-lvivier@redhat.com>
Patchwork-id: 101253
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 13/27] failover: simplify virtio_net_find_primary()
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
a - is_my_primary() never sets one error
b - If we return 1, primary_device_id is always set
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-15-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 7cf05b7ed8e84e89b873701e3dfcd56aa81b2d13)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 70fa372c08..881907d1bd 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -828,24 +828,12 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp)
{
- DeviceState *dev = NULL;
Error *err = NULL;
- if (qemu_opts_foreach(qemu_find_opts("device"),
- is_my_primary, n, &err)) {
- if (err) {
- error_propagate(errp, err);
- return NULL;
- }
- if (n->primary_device_id) {
- dev = qdev_find_recursive(sysbus_get_default(),
- n->primary_device_id);
- } else {
- error_setg(errp, "Primary device id not found");
- return NULL;
- }
+ if (!qemu_opts_foreach(qemu_find_opts("device"), is_my_primary, n, &err)) {
+ return NULL;
}
- return dev;
+ return qdev_find_recursive(sysbus_get_default(), n->primary_device_id);
}
static DeviceState *virtio_connect_failover_devices(VirtIONet *n, Error **errp)
--
2.27.0

View File

@ -0,0 +1,128 @@
From 2e3e87787776632d521ec5f08758973d42fc208e Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:42 -0500
Subject: [PATCH 45/54] failover: split failover_find_primary_device_id()
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-23-lvivier@redhat.com>
Patchwork-id: 101244
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 22/27] failover: split failover_find_primary_device_id()
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
So we can calculate the device id when we need it.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-24-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit f5e1847ba50a8d1adf66c0cf312e53c162e52487)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 63 +++++++++++++++++++++++++++++++++------------
1 file changed, 47 insertions(+), 16 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b994796734..2c502c13fd 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -788,6 +788,49 @@ static inline uint64_t virtio_net_supported_guest_offloads(VirtIONet *n)
return virtio_net_guest_offloads_by_features(vdev->guest_features);
}
+typedef struct {
+ VirtIONet *n;
+ char *id;
+} FailoverId;
+
+/**
+ * Set the id of the failover primary device
+ *
+ * @opaque: FailoverId to setup
+ * @opts: opts for device we are handling
+ * @errp: returns an error if this function fails
+ */
+static int failover_set_primary(void *opaque, QemuOpts *opts, Error **errp)
+{
+ FailoverId *fid = opaque;
+ const char *standby_id = qemu_opt_get(opts, "failover_pair_id");
+
+ if (g_strcmp0(standby_id, fid->n->netclient_name) == 0) {
+ fid->id = g_strdup(opts->id);
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * Find the primary device id for this failover virtio-net
+ *
+ * @n: VirtIONet device
+ * @errp: returns an error if this function fails
+ */
+static char *failover_find_primary_device_id(VirtIONet *n)
+{
+ Error *err = NULL;
+ FailoverId fid;
+
+ if (!qemu_opts_foreach(qemu_find_opts("device"),
+ failover_set_primary, &fid, &err)) {
+ return NULL;
+ }
+ return fid.id;
+}
+
static void failover_add_primary(VirtIONet *n, Error **errp)
{
Error *err = NULL;
@@ -812,20 +855,6 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
error_propagate(errp, err);
}
-static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
-{
- VirtIONet *n = opaque;
- int ret = 0;
- const char *standby_id = qemu_opt_get(opts, "failover_pair_id");
-
- if (g_strcmp0(standby_id, n->netclient_name) == 0) {
- n->primary_device_id = g_strdup(opts->id);
- ret = 1;
- }
-
- return ret;
-}
-
/**
* Find the primary device for this failover virtio-net
*
@@ -834,11 +863,13 @@ static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
*/
static DeviceState *failover_find_primary_device(VirtIONet *n)
{
- Error *err = NULL;
+ char *id = failover_find_primary_device_id(n);
- if (!qemu_opts_foreach(qemu_find_opts("device"), is_my_primary, n, &err)) {
+ if (!id) {
return NULL;
}
+ n->primary_device_id = g_strdup(id);
+
return qdev_find_recursive(sysbus_get_default(), n->primary_device_id);
}
--
2.27.0

View File

@ -0,0 +1,80 @@
From 385df1f898e08c9cf0c90e543978cc68ee0c1097 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:36 -0500
Subject: [PATCH 39/54] failover: virtio_net_connect_failover_devices() does
nothing
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-17-lvivier@redhat.com>
Patchwork-id: 101254
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 16/27] failover: virtio_net_connect_failover_devices() does nothing
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
From: Juan Quintela <quintela@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
It just calls virtio_net_find_primary(), so just update the callers.
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-Id: <20201118083748.1328-18-quintela@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 0763db4f2df3a92336d78e8b68a665f7d1a1bc66)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 747614ff2a..c6200b924e 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -836,19 +836,6 @@ static DeviceState *virtio_net_find_primary(VirtIONet *n, Error **errp)
return qdev_find_recursive(sysbus_get_default(), n->primary_device_id);
}
-static DeviceState *virtio_connect_failover_devices(VirtIONet *n, Error **errp)
-{
- DeviceState *prim_dev = NULL;
- Error *err = NULL;
-
- prim_dev = virtio_net_find_primary(n, &err);
- if (!prim_dev) {
- error_propagate(errp, err);
- }
-
- return prim_dev;
-}
-
static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
{
VirtIONet *n = VIRTIO_NET(vdev);
@@ -904,7 +891,7 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features)
qatomic_set(&n->failover_primary_hidden, false);
failover_add_primary(n, &err);
if (err) {
- n->primary_dev = virtio_connect_failover_devices(n, &err);
+ n->primary_dev = virtio_net_find_primary(n, &err);
if (err) {
goto out_err;
}
@@ -3128,7 +3115,7 @@ static void virtio_net_handle_migration_primary(VirtIONet *n,
should_be_hidden = qatomic_read(&n->failover_primary_hidden);
if (!n->primary_dev) {
- n->primary_dev = virtio_connect_failover_devices(n, &err);
+ n->primary_dev = virtio_net_find_primary(n, &err);
if (!n->primary_dev) {
return;
}
--
2.27.0

View File

@ -0,0 +1,213 @@
From 78375038a68fee2e7b182b4f191d5ba53fbdcd72 Mon Sep 17 00:00:00 2001
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Date: Tue, 23 Feb 2021 15:18:11 -0500
Subject: [PATCH 52/54] i386: Add the support for AMD EPYC 3rd generation
processors
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-id: <20210223151811.27968-3-dgilbert@redhat.com>
Patchwork-id: 101198
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 2/2] i386: Add the support for AMD EPYC 3rd generation processors
Bugzilla: 1926785
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Peter Xu <peterx@redhat.com>
From: Babu Moger <babu.moger@amd.com>
Adds the support for AMD 3rd generation processors. The model
display for the new processor will be EPYC-Milan.
Adds the following new feature bits on top of the feature bits from
the first and second generation EPYC models.
pcid : Process context identifiers support
ibrs : Indirect Branch Restricted Speculation
ssbd : Speculative Store Bypass Disable
erms : Enhanced REP MOVSB/STOSB support
fsrm : Fast Short REP MOVSB support
invpcid : Invalidate processor context ID
pku : Protection keys support
svme-addr-chk : SVM instructions address check for #GP handling
Depends on the following kernel commits:
14c2bf81fcd2 ("KVM: SVM: Fix #GP handling for doubly-nested virtualization")
3b9c723ed7cf ("KVM: SVM: Add support for SVM instruction address check change")
4aa2691dcbd3 ("8ce1c461188799d863398dd2865d KVM: x86: Factor out x86 instruction emulation with decoding")
4407a797e941 ("KVM: SVM: Enable INVPCID feature on AMD")
9715092f8d7e ("KVM: X86: Move handling of INVPCID types to x86")
3f3393b3ce38 ("KVM: X86: Rename and move the function vmx_handle_memory_failure to x86.c")
830bd71f2c06 ("KVM: SVM: Remove set_cr_intercept, clr_cr_intercept and is_cr_intercept")
4c44e8d6c193 ("KVM: SVM: Add new intercept word in vmcb_control_area")
c62e2e94b9d4 ("KVM: SVM: Modify 64 bit intercept field to two 32 bit vectors")
9780d51dc2af ("KVM: SVM: Modify intercept_exceptions to generic intercepts")
30abaa88382c ("KVM: SVM: Change intercept_dr to generic intercepts")
03bfeeb988a9 ("KVM: SVM: Change intercept_cr to generic intercepts")
c45ad7229d13 ("KVM: SVM: Introduce vmcb_(set_intercept/clr_intercept/_is_intercept)")
a90c1ed9f11d ("(pcid) KVM: nSVM: Remove unused field")
fa44b82eb831 ("KVM: x86: Move MPK feature detection to common code")
38f3e775e9c2 ("x86/Kconfig: Update config and kernel doc for MPK feature on AMD")
37486135d3a7 ("KVM: x86: Fix pkru save/restore when guest CR4.PKE=0, move it to x86.c")
Signed-off-by: Babu Moger <babu.moger@amd.com>
Message-Id: <161290460478.11352.8933244555799318236.stgit@bmoger-ubuntu>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
(cherry picked from commit 623972ceae091b31331ae4a1dc94fe5cbb891937)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
target/i386/cpu.c | 107 +++++++++++++++++++++++++++++++++++++++++++++-
target/i386/cpu.h | 4 ++
2 files changed, 110 insertions(+), 1 deletion(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 372cba2942..523a97c0fb 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1029,7 +1029,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
"clzero", NULL, "xsaveerptr", NULL,
NULL, NULL, NULL, NULL,
NULL, "wbnoinvd", NULL, NULL,
- "ibpb", NULL, NULL, "amd-stibp",
+ "ibpb", NULL, "ibrs", "amd-stibp",
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
"amd-ssbd", "virt-ssbd", "amd-no-ssb", NULL,
@@ -1769,6 +1769,56 @@ static CPUCaches epyc_rome_cache_info = {
},
};
+static CPUCaches epyc_milan_cache_info = {
+ .l1d_cache = &(CPUCacheInfo) {
+ .type = DATA_CACHE,
+ .level = 1,
+ .size = 32 * KiB,
+ .line_size = 64,
+ .associativity = 8,
+ .partitions = 1,
+ .sets = 64,
+ .lines_per_tag = 1,
+ .self_init = 1,
+ .no_invd_sharing = true,
+ },
+ .l1i_cache = &(CPUCacheInfo) {
+ .type = INSTRUCTION_CACHE,
+ .level = 1,
+ .size = 32 * KiB,
+ .line_size = 64,
+ .associativity = 8,
+ .partitions = 1,
+ .sets = 64,
+ .lines_per_tag = 1,
+ .self_init = 1,
+ .no_invd_sharing = true,
+ },
+ .l2_cache = &(CPUCacheInfo) {
+ .type = UNIFIED_CACHE,
+ .level = 2,
+ .size = 512 * KiB,
+ .line_size = 64,
+ .associativity = 8,
+ .partitions = 1,
+ .sets = 1024,
+ .lines_per_tag = 1,
+ },
+ .l3_cache = &(CPUCacheInfo) {
+ .type = UNIFIED_CACHE,
+ .level = 3,
+ .size = 32 * MiB,
+ .line_size = 64,
+ .associativity = 16,
+ .partitions = 1,
+ .sets = 32768,
+ .lines_per_tag = 1,
+ .self_init = true,
+ .inclusive = true,
+ .complex_indexing = true,
+ },
+};
+
/* The following VMX features are not supported by KVM and are left out in the
* CPU definitions:
*
@@ -4101,6 +4151,61 @@ static X86CPUDefinition builtin_x86_defs[] = {
.model_id = "AMD EPYC-Rome Processor",
.cache_info = &epyc_rome_cache_info,
},
+ {
+ .name = "EPYC-Milan",
+ .level = 0xd,
+ .vendor = CPUID_VENDOR_AMD,
+ .family = 25,
+ .model = 1,
+ .stepping = 1,
+ .features[FEAT_1_EDX] =
+ CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX | CPUID_CLFLUSH |
+ CPUID_PSE36 | CPUID_PAT | CPUID_CMOV | CPUID_MCA | CPUID_PGE |
+ CPUID_MTRR | CPUID_SEP | CPUID_APIC | CPUID_CX8 | CPUID_MCE |
+ CPUID_PAE | CPUID_MSR | CPUID_TSC | CPUID_PSE | CPUID_DE |
+ CPUID_VME | CPUID_FP87,
+ .features[FEAT_1_ECX] =
+ CPUID_EXT_RDRAND | CPUID_EXT_F16C | CPUID_EXT_AVX |
+ CPUID_EXT_XSAVE | CPUID_EXT_AES | CPUID_EXT_POPCNT |
+ CPUID_EXT_MOVBE | CPUID_EXT_SSE42 | CPUID_EXT_SSE41 |
+ CPUID_EXT_CX16 | CPUID_EXT_FMA | CPUID_EXT_SSSE3 |
+ CPUID_EXT_MONITOR | CPUID_EXT_PCLMULQDQ | CPUID_EXT_SSE3 |
+ CPUID_EXT_PCID,
+ .features[FEAT_8000_0001_EDX] =
+ CPUID_EXT2_LM | CPUID_EXT2_RDTSCP | CPUID_EXT2_PDPE1GB |
+ CPUID_EXT2_FFXSR | CPUID_EXT2_MMXEXT | CPUID_EXT2_NX |
+ CPUID_EXT2_SYSCALL,
+ .features[FEAT_8000_0001_ECX] =
+ CPUID_EXT3_OSVW | CPUID_EXT3_3DNOWPREFETCH |
+ CPUID_EXT3_MISALIGNSSE | CPUID_EXT3_SSE4A | CPUID_EXT3_ABM |
+ CPUID_EXT3_CR8LEG | CPUID_EXT3_SVM | CPUID_EXT3_LAHF_LM |
+ CPUID_EXT3_TOPOEXT | CPUID_EXT3_PERFCORE,
+ .features[FEAT_8000_0008_EBX] =
+ CPUID_8000_0008_EBX_CLZERO | CPUID_8000_0008_EBX_XSAVEERPTR |
+ CPUID_8000_0008_EBX_WBNOINVD | CPUID_8000_0008_EBX_IBPB |
+ CPUID_8000_0008_EBX_IBRS | CPUID_8000_0008_EBX_STIBP |
+ CPUID_8000_0008_EBX_AMD_SSBD,
+ .features[FEAT_7_0_EBX] =
+ CPUID_7_0_EBX_FSGSBASE | CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_AVX2 |
+ CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_RDSEED |
+ CPUID_7_0_EBX_ADX | CPUID_7_0_EBX_SMAP | CPUID_7_0_EBX_CLFLUSHOPT |
+ CPUID_7_0_EBX_SHA_NI | CPUID_7_0_EBX_CLWB | CPUID_7_0_EBX_ERMS |
+ CPUID_7_0_EBX_INVPCID,
+ .features[FEAT_7_0_ECX] =
+ CPUID_7_0_ECX_UMIP | CPUID_7_0_ECX_RDPID | CPUID_7_0_ECX_PKU,
+ .features[FEAT_7_0_EDX] =
+ CPUID_7_0_EDX_FSRM,
+ .features[FEAT_XSAVE] =
+ CPUID_XSAVE_XSAVEOPT | CPUID_XSAVE_XSAVEC |
+ CPUID_XSAVE_XGETBV1 | CPUID_XSAVE_XSAVES,
+ .features[FEAT_6_EAX] =
+ CPUID_6_EAX_ARAT,
+ .features[FEAT_SVM] =
+ CPUID_SVM_NPT | CPUID_SVM_NRIPSAVE | CPUID_SVM_SVME_ADDR_CHK,
+ .xlevel = 0x8000001E,
+ .model_id = "AMD EPYC-Milan Processor",
+ .cache_info = &epyc_milan_cache_info,
+ },
};
/* KVM-specific features that are automatically added/removed
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 4fdb552f93..92ca64a21b 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -811,8 +811,12 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
#define CPUID_8000_0008_EBX_WBNOINVD (1U << 9)
/* Indirect Branch Prediction Barrier */
#define CPUID_8000_0008_EBX_IBPB (1U << 12)
+/* Indirect Branch Restricted Speculation */
+#define CPUID_8000_0008_EBX_IBRS (1U << 14)
/* Single Thread Indirect Branch Predictors */
#define CPUID_8000_0008_EBX_STIBP (1U << 15)
+/* Speculative Store Bypass Disable */
+#define CPUID_8000_0008_EBX_AMD_SSBD (1U << 24)
#define CPUID_XSAVE_XSAVEOPT (1U << 0)
#define CPUID_XSAVE_XSAVEC (1U << 1)
--
2.27.0

View File

@ -0,0 +1,167 @@
From 039775f93548382ec1b98f5a6004c3eee02fbd28 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 22 Feb 2021 13:35:05 -0500
Subject: [PATCH 22/54] migration: dirty-bitmap: Allow control of bitmap
persistence
RH-Author: Peter Krempa <pkrempa@redhat.com>
Message-id: <aab968e05bbfb581697573b8e42768af502f46db.1614000630.git.pkrempa@redhat.com>
Patchwork-id: 101171
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 2/3] migration: dirty-bitmap: Allow control of bitmap persistence
Bugzilla: 1930757
RH-Acked-by: John Snow <jsnow@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Eric Blake <eblake@redhat.com>
Bitmap's source persistence is transported over the migration stream and
the destination mirrors it. In some cases the destination might want to
persist bitmaps which are not persistent on the source (e.g. the result
of merging bitmaps from a number of layers on the source when migrating
into a squashed image) but currently it would need to create another set
of persistent bitmaps and merge them.
This patch adds a 'transform' property to the alias map which allows
overriding the persistence of migrated bitmaps both on the source and
destination sides.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Message-Id: <b20afb675917b86f6359ac3591166ac6d4233573.1613150869.git.pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: grammar tweaks, drop dead conditional]
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 6e9f21a2aa8a78bc9a512a836a40c79fe50dd2b4)
https://bugzilla.redhat.com/show_bug.cgi?id=1930757
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
migration/block-dirty-bitmap.c | 29 ++++++++++++++++++++++++++---
qapi/migration.json | 19 ++++++++++++++++++-
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index b39c13ce4e..975093610a 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -150,6 +150,7 @@ typedef struct DBMLoadState {
BdrvDirtyBitmap *bitmap;
bool before_vm_start_handled; /* set in dirty_bitmap_mig_before_vm_start */
+ BitmapMigrationBitmapAlias *bmap_inner;
/*
* cancelled
@@ -529,6 +530,7 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
}
FOR_EACH_DIRTY_BITMAP(bs, bitmap) {
+ BitmapMigrationBitmapAliasTransform *bitmap_transform = NULL;
bitmap_name = bdrv_dirty_bitmap_name(bitmap);
if (!bitmap_name) {
continue;
@@ -549,6 +551,9 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
}
bitmap_alias = bmap_inner->alias;
+ if (bmap_inner->has_transform) {
+ bitmap_transform = bmap_inner->transform;
+ }
} else {
if (strlen(bitmap_name) > UINT8_MAX) {
error_report("Cannot migrate bitmap '%s' on node '%s': "
@@ -574,8 +579,15 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
if (bdrv_dirty_bitmap_enabled(bitmap)) {
dbms->flags |= DIRTY_BITMAP_MIG_START_FLAG_ENABLED;
}
- if (bdrv_dirty_bitmap_get_persistence(bitmap)) {
- dbms->flags |= DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT;
+ if (bitmap_transform &&
+ bitmap_transform->has_persistent) {
+ if (bitmap_transform->persistent) {
+ dbms->flags |= DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT;
+ }
+ } else {
+ if (bdrv_dirty_bitmap_get_persistence(bitmap)) {
+ dbms->flags |= DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT;
+ }
}
QSIMPLEQ_INSERT_TAIL(&s->dbms_list, dbms, entry);
@@ -783,6 +795,7 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoadState *s)
uint32_t granularity = qemu_get_be32(f);
uint8_t flags = qemu_get_byte(f);
LoadBitmapState *b;
+ bool persistent;
if (s->cancelled) {
return 0;
@@ -807,7 +820,15 @@ static int dirty_bitmap_load_start(QEMUFile *f, DBMLoadState *s)
return -EINVAL;
}
- if (flags & DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT) {
+ if (s->bmap_inner &&
+ s->bmap_inner->has_transform &&
+ s->bmap_inner->transform->has_persistent) {
+ persistent = s->bmap_inner->transform->persistent;
+ } else {
+ persistent = flags & DIRTY_BITMAP_MIG_START_FLAG_PERSISTENT;
+ }
+
+ if (persistent) {
bdrv_dirty_bitmap_set_persistence(s->bitmap, true);
}
@@ -1091,6 +1112,8 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s,
} else {
bitmap_name = bmap_inner->name;
}
+
+ s->bmap_inner = bmap_inner;
}
if (!s->cancelled) {
diff --git a/qapi/migration.json b/qapi/migration.json
index 3c75820527..19b796ab47 100644
--- a/qapi/migration.json
+++ b/qapi/migration.json
@@ -525,6 +525,19 @@
'data': [ 'none', 'zlib',
{ 'name': 'zstd', 'if': 'defined(CONFIG_ZSTD)' } ] }
+##
+# @BitmapMigrationBitmapAliasTransform:
+#
+# @persistent: If present, the bitmap will be made persistent
+# or transient depending on this parameter.
+#
+# Since: 6.0
+##
+{ 'struct': 'BitmapMigrationBitmapAliasTransform',
+ 'data': {
+ '*persistent': 'bool'
+ } }
+
##
# @BitmapMigrationBitmapAlias:
#
@@ -533,12 +546,16 @@
# @alias: An alias name for migration (for example the bitmap name on
# the opposite site).
#
+# @transform: Allows the modification of the migrated bitmap.
+# (since 6.0)
+#
# Since: 5.2
##
{ 'struct': 'BitmapMigrationBitmapAlias',
'data': {
'name': 'str',
- 'alias': 'str'
+ 'alias': 'str',
+ '*transform': 'BitmapMigrationBitmapAliasTransform'
} }
##
--
2.27.0

View File

@ -0,0 +1,143 @@
From e49b317a80df94b769c01c2ae488a369921088d2 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 22 Feb 2021 13:35:04 -0500
Subject: [PATCH 21/54] migration: dirty-bitmap: Use struct for alias map inner
members
RH-Author: Peter Krempa <pkrempa@redhat.com>
Message-id: <943503323f3f97d576715d09736376cf07d6efab.1614000630.git.pkrempa@redhat.com>
Patchwork-id: 101170
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/3] migration: dirty-bitmap: Use struct for alias map inner members
Bugzilla: 1930757
RH-Acked-by: John Snow <jsnow@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Eric Blake <eblake@redhat.com>
Currently the alias mapping hash stores just strings of the target
objects internally. In further patches we'll be adding another member
which will need to be stored in the map so pass a copy of the whole
BitmapMigrationBitmapAlias QAPI struct into the map.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Message-Id: <fc5f27e1fe16cb75e08a248c2d938de3997b9bfb.1613150869.git.pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: adjust long lines]
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 0d1e450c7b3117ee635a00c81d9a92666ebc7ffa)
https://bugzilla.redhat.com/show_bug.cgi?id=1930757
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
migration/block-dirty-bitmap.c | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
index c61d382be8..b39c13ce4e 100644
--- a/migration/block-dirty-bitmap.c
+++ b/migration/block-dirty-bitmap.c
@@ -75,6 +75,8 @@
#include "qemu/id.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-migration.h"
+#include "qapi/qapi-visit-migration.h"
+#include "qapi/clone-visitor.h"
#include "trace.h"
#define CHUNK_SIZE (1 << 10)
@@ -224,6 +226,7 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
AliasMapInnerNode *amin;
GHashTable *bitmaps_map;
const char *node_map_from, *node_map_to;
+ GDestroyNotify gdn;
if (!id_wellformed(bmna->alias)) {
error_setg(errp, "The node alias '%s' is not well-formed",
@@ -263,8 +266,9 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
node_map_to = bmna->node_name;
}
- bitmaps_map = g_hash_table_new_full(g_str_hash, g_str_equal,
- g_free, g_free);
+ gdn = (GDestroyNotify) qapi_free_BitmapMigrationBitmapAlias;
+ bitmaps_map = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
+ gdn);
amin = g_new(AliasMapInnerNode, 1);
*amin = (AliasMapInnerNode){
@@ -276,7 +280,7 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
for (bmbal = bmna->bitmaps; bmbal; bmbal = bmbal->next) {
const BitmapMigrationBitmapAlias *bmba = bmbal->value;
- const char *bmap_map_from, *bmap_map_to;
+ const char *bmap_map_from;
if (strlen(bmba->alias) > UINT8_MAX) {
error_setg(errp,
@@ -293,7 +297,6 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
if (name_to_alias) {
bmap_map_from = bmba->name;
- bmap_map_to = bmba->alias;
if (g_hash_table_contains(bitmaps_map, bmba->name)) {
error_setg(errp, "The bitmap '%s'/'%s' is mapped twice",
@@ -302,7 +305,6 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
}
} else {
bmap_map_from = bmba->alias;
- bmap_map_to = bmba->name;
if (g_hash_table_contains(bitmaps_map, bmba->alias)) {
error_setg(errp, "The bitmap alias '%s'/'%s' is used twice",
@@ -311,8 +313,8 @@ static GHashTable *construct_alias_map(const BitmapMigrationNodeAliasList *bbm,
}
}
- g_hash_table_insert(bitmaps_map,
- g_strdup(bmap_map_from), g_strdup(bmap_map_to));
+ g_hash_table_insert(bitmaps_map, g_strdup(bmap_map_from),
+ QAPI_CLONE(BitmapMigrationBitmapAlias, bmba));
}
}
@@ -538,11 +540,15 @@ static int add_bitmaps_to_list(DBMSaveState *s, BlockDriverState *bs,
}
if (bitmap_aliases) {
- bitmap_alias = g_hash_table_lookup(bitmap_aliases, bitmap_name);
- if (!bitmap_alias) {
+ BitmapMigrationBitmapAlias *bmap_inner;
+
+ bmap_inner = g_hash_table_lookup(bitmap_aliases, bitmap_name);
+ if (!bmap_inner) {
/* Skip bitmaps with no alias */
continue;
}
+
+ bitmap_alias = bmap_inner->alias;
} else {
if (strlen(bitmap_name) > UINT8_MAX) {
error_report("Cannot migrate bitmap '%s' on node '%s': "
@@ -1074,13 +1080,16 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s,
bitmap_name = s->bitmap_alias;
if (!s->cancelled && bitmap_alias_map) {
- bitmap_name = g_hash_table_lookup(bitmap_alias_map,
- s->bitmap_alias);
- if (!bitmap_name) {
+ BitmapMigrationBitmapAlias *bmap_inner;
+
+ bmap_inner = g_hash_table_lookup(bitmap_alias_map, s->bitmap_alias);
+ if (!bmap_inner) {
error_report("Error: Unknown bitmap alias '%s' on node "
"'%s' (alias '%s')", s->bitmap_alias,
s->bs->node_name, s->node_alias);
cancel_incoming_locked(s);
+ } else {
+ bitmap_name = bmap_inner->name;
}
}
--
2.27.0

View File

@ -0,0 +1,72 @@
From 7b7974468656d2ceba6a7f6dba2b35dfe28a5d1f Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Mon, 8 Feb 2021 22:57:01 -0300
Subject: [PATCH 03/54] nbd: make nbd_read* return -EIO on error
RH-Author: Eric Blake <eblake@redhat.com>
Message-id: <20210208225701.110110-4-eblake@redhat.com>
Patchwork-id: 101007
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v4 3/3] nbd: make nbd_read* return -EIO on error
Bugzilla: 1887883
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
From: Roman Kagan <rvkagan@yandex-team.ru>
NBD reconnect logic considers the error code from the functions that
read NBD messages to tell if reconnect should be attempted or not: it is
attempted on -EIO, otherwise the client transitions to NBD_CLIENT_QUIT
state (see nbd_channel_error). This error code is propagated from the
primitives like nbd_read.
The problem, however, is that nbd_read itself turns every error into -1
rather than -EIO. As a result, if the NBD server happens to die while
sending the message, the client in QEMU receives less data than it
expects, considers it as a fatal error, and wouldn't attempt
reestablishing the connection.
Fix it by turning every negative return from qio_channel_read_all into
-EIO returned from nbd_read. Apparently that was the original behavior,
but got broken later. Also adjust nbd_readXX to follow.
Fixes: e6798f06a6 ("nbd: generalize usage of nbd_read")
Signed-off-by: Roman Kagan <rvkagan@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210129073859.683063-4-rvkagan@yandex-team.ru>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 5082fc82a6bc3fc06a04be47d39777c7cff61e5b)
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
include/block/nbd.h | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 4a52a43ef5..5f34d23bb0 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -364,7 +364,7 @@ static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,
if (desc) {
error_prepend(errp, "Failed to read %s: ", desc);
}
- return -1;
+ return ret;
}
return 0;
@@ -375,8 +375,9 @@ static inline int nbd_read##bits(QIOChannel *ioc, \
uint##bits##_t *val, \
const char *desc, Error **errp) \
{ \
- if (nbd_read(ioc, val, sizeof(*val), desc, errp) < 0) { \
- return -1; \
+ int ret = nbd_read(ioc, val, sizeof(*val), desc, errp); \
+ if (ret < 0) { \
+ return ret; \
} \
*val = be##bits##_to_cpu(*val); \
return 0; \
--
2.27.0

View File

@ -0,0 +1,137 @@
From aee681700e512679981e39928d8709eb226a4a6d Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Wed, 10 Feb 2021 17:04:45 -0300
Subject: [PATCH 10/54] pci: add romsize property
RH-Author: Peter Xu <peterx@redhat.com>
Message-id: <20210210170445.128304-3-peterx@redhat.com>
Patchwork-id: 101041
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 2/2] pci: add romsize property
Bugzilla: 1917830
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
This property can be useful for distros to set up known-good ROM sizes for
migration purposes. The VM will fail to start if the ROM is too large,
and migration compatibility will not be broken if the ROM is too small.
Note that even though romsize is a uint32_t, it has to be between 1
(because empty ROM files are not accepted, and romsize must be greater
than the file) and 2^31 (because values above are not powers of two and
are rejected).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Message-Id: <20201218182736.1634344-1-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210203131828.156467-3-pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 08b1df8ff463e72b0875538fb991d5393047606c)
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
hw/pci/pci.c | 19 +++++++++++++++++--
hw/xen/xen_pt_load_rom.c | 14 ++++++++++++--
include/hw/pci/pci.h | 1 +
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index e4caad33c5..9619b8d068 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -67,6 +67,7 @@ static void pcibus_reset(BusState *qbus);
static Property pci_props[] = {
DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
+ DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, -1),
DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1),
DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present,
QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false),
@@ -2106,6 +2107,11 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp)
bool is_default_rom;
uint16_t class_id;
+ if (pci_dev->romsize != -1 && !is_power_of_2(pci_dev->romsize)) {
+ error_setg(errp, "ROM size %u is not a power of two", pci_dev->romsize);
+ return;
+ }
+
/* initialize cap_present for pci_is_express() and pci_config_size(),
* Note that hybrid PCIs are not set automatically and need to manage
* QEMU_PCI_CAP_EXPRESS manually */
@@ -2371,7 +2377,16 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
g_free(path);
return;
}
- size = pow2ceil(size);
+ if (pdev->romsize != -1) {
+ if (size > pdev->romsize) {
+ error_setg(errp, "romfile \"%s\" (%u bytes) is too large for ROM size %u",
+ pdev->romfile, (uint32_t)size, pdev->romsize);
+ g_free(path);
+ return;
+ }
+ } else {
+ pdev->romsize = pow2ceil(size);
+ }
vmsd = qdev_get_vmsd(DEVICE(pdev));
@@ -2381,7 +2396,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
snprintf(name, sizeof(name), "%s.rom", object_get_typename(OBJECT(pdev)));
}
pdev->has_rom = true;
- memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, size, &error_fatal);
+ memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, pdev->romsize, &error_fatal);
ptr = memory_region_get_ram_ptr(&pdev->rom);
if (load_image_size(path, ptr, size) < 0) {
error_setg(errp, "failed to load romfile \"%s\"", pdev->romfile);
diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c
index a50a80837e..03422a8a71 100644
--- a/hw/xen/xen_pt_load_rom.c
+++ b/hw/xen/xen_pt_load_rom.c
@@ -53,10 +53,20 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev,
}
fseek(fp, 0, SEEK_SET);
+ if (dev->romsize != -1) {
+ if (st.st_size > dev->romsize) {
+ error_report("ROM BAR \"%s\" (%ld bytes) is too large for ROM size %u",
+ rom_file, (long) st.st_size, dev->romsize);
+ goto close_rom;
+ }
+ } else {
+ dev->romsize = st.st_size;
+ }
+
snprintf(name, sizeof(name), "%s.rom", object_get_typename(owner));
- memory_region_init_ram(&dev->rom, owner, name, st.st_size, &error_abort);
+ memory_region_init_ram(&dev->rom, owner, name, dev->romsize, &error_abort);
ptr = memory_region_get_ram_ptr(&dev->rom);
- memset(ptr, 0xff, st.st_size);
+ memset(ptr, 0xff, dev->romsize);
if (!fread(ptr, 1, st.st_size, fp)) {
error_report("pci-assign: Cannot read from host %s", rom_file);
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 72ce649eee..75a6b15757 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -343,6 +343,7 @@ struct PCIDevice {
/* Location of option rom */
char *romfile;
+ uint32_t romsize;
bool has_rom;
MemoryRegion rom;
uint32_t rom_bar;
--
2.27.0

View File

@ -0,0 +1,89 @@
From a6e34aa76d86319d15355fd55fa6d12eb49a816f Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Wed, 10 Feb 2021 17:04:44 -0300
Subject: [PATCH 09/54] pci: reject too large ROMs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Peter Xu <peterx@redhat.com>
Message-id: <20210210170445.128304-2-peterx@redhat.com>
Patchwork-id: 101039
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/2] pci: reject too large ROMs
Bugzilla: 1917830
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
From: Paolo Bonzini <pbonzini@redhat.com>
get_image_size() returns an int64_t, which pci_add_option_rom() assigns
to an "int" without any range checking. A 32-bit BAR could be up to
2 GiB in size, so reject anything above it. In order to accomodate
a rounded-up size of 2 GiB, change pci_patch_ids's size argument
to unsigned.
Conflicts:
hw/pci/pci.c: missing 2c65db5e58d ("vl: extract softmmu/datadir.c") so
there's no "#include <qemu/datadir.h>" yet
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210203131828.156467-2-pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: David Edmondson <david.edmondson@oracle.com>
(cherry picked from commit 7c16b5bbb6c0f797945327d17e4be60f25a4427d)
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
hw/pci/pci.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 0131d9d02c..e4caad33c5 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -24,6 +24,7 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
+#include "qemu/units.h"
#include "hw/irq.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_bridge.h"
@@ -2256,7 +2257,7 @@ static uint8_t pci_find_capability_at_offset(PCIDevice *pdev, uint8_t offset)
/* Patch the PCI vendor and device ids in a PCI rom image if necessary.
This is needed for an option rom which is used for more than one device. */
-static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size)
+static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, uint32_t size)
{
uint16_t vendor_id;
uint16_t device_id;
@@ -2314,7 +2315,7 @@ static void pci_patch_ids(PCIDevice *pdev, uint8_t *ptr, int size)
static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
Error **errp)
{
- int size;
+ int64_t size;
char *path;
void *ptr;
char name[32];
@@ -2364,6 +2365,11 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom,
error_setg(errp, "romfile \"%s\" is empty", pdev->romfile);
g_free(path);
return;
+ } else if (size > 2 * GiB) {
+ error_setg(errp, "romfile \"%s\" too large (size cannot exceed 2 GiB)",
+ pdev->romfile);
+ g_free(path);
+ return;
}
size = pow2ceil(size);
--
2.27.0

View File

@ -0,0 +1,146 @@
From 20eb8dc4f6679e3325e1f1f434b17e2dc6a60eee Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 21:42:47 -0500
Subject: [PATCH 20/54] pcie: don't set link state active if the slot is empty
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225214247.1336554-1-lvivier@redhat.com>
Patchwork-id: 101211
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH] pcie: don't set link state active if the slot is empty
Bugzilla: 1917654
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
BZ: https://bugzilla.redhat.com/1917654
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=35163495
When the pcie slot is initialized, by default PCI_EXP_LNKSTA_DLLLA
(Data Link Layer Link Active) is set in PCI_EXP_LNKSTA
(Link Status) without checking if the slot is empty or not.
This is confusing for the kernel because as it sees the link is up
it tries to read the vendor ID and fails:
(From https://bugzilla.kernel.org/show_bug.cgi?id=211691)
[ 1.661105] pcieport 0000:00:02.2: pciehp: Slot Capabilities : 0x0002007b
[ 1.661115] pcieport 0000:00:02.2: pciehp: Slot Status : 0x0010
[ 1.661123] pcieport 0000:00:02.2: pciehp: Slot Control : 0x07c0
[ 1.661138] pcieport 0000:00:02.2: pciehp: Slot #0 AttnBtn+ PwrCtrl+ MRL- AttnInd+ PwrInd+ HotPlug+ Surprise+ Interlock+ NoCompl- IbPresDis- LLActRep+
[ 1.662581] pcieport 0000:00:02.2: pciehp: pciehp_get_power_status: SLOTCTRL 6c value read 7c0
[ 1.662597] pcieport 0000:00:02.2: pciehp: pciehp_check_link_active: lnk_status = 2204
[ 1.662703] pcieport 0000:00:02.2: pciehp: pending interrupts 0x0010 from Slot Status
[ 1.662706] pcieport 0000:00:02.2: pciehp: pcie_enable_notification: SLOTCTRL 6c write cmd 1031
[ 1.662730] pcieport 0000:00:02.2: pciehp: pciehp_check_link_active: lnk_status = 2204
[ 1.662748] pcieport 0000:00:02.2: pciehp: pciehp_check_link_active: lnk_status = 2204
[ 1.662750] pcieport 0000:00:02.2: pciehp: Slot(0-2): Link Up
[ 2.896132] pcieport 0000:00:02.2: pciehp: pciehp_check_link_status: lnk_status = 2204
[ 2.896135] pcieport 0000:00:02.2: pciehp: Slot(0-2): No device found
[ 2.896900] pcieport 0000:00:02.2: pciehp: pending interrupts 0x0010 from Slot Status
[ 2.896903] pcieport 0000:00:02.2: pciehp: pciehp_power_off_slot: SLOTCTRL 6c write cmd 400
[ 3.656901] pcieport 0000:00:02.2: pciehp: pending interrupts 0x0009 from Slot Status
This is really a problem with virtio-net failover that hotplugs a VFIO
card during the boot process. The kernel can shutdown the slot while
QEMU is hotplugging it, and this likely ends by an automatic unplug of
the card. At the end of the boot sequence the card has disappeared.
To fix that, don't set the "Link Active" state in the init function, but
rely on the plug function to do it, as the mechanism has already been
introduced by 2f2b18f60bf1.
Fixes: 2f2b18f60bf1 ("pcie: set link state inactive/active after hot unplug/plug")
Cc: zhengxiang9@huawei.com
Fixes: 3d67447fe7c2 ("pcie: Fill PCIESlot link fields to support higher speeds and widths")
Cc: alex.williamson@redhat.com
Fixes: b2101eae63ea ("pcie: Set the "link active" in the link status register")
Cc: benh@kernel.crashing.org
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20210212135250.2738750-5-lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit df72184ec15829053b3bb5a0d5801773b6d9ec25)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/pci/pcie.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index d4010cf8f3..a733e2fb87 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -75,11 +75,6 @@ pcie_cap_v1_fill(PCIDevice *dev, uint8_t port, uint8_t type, uint8_t version)
QEMU_PCI_EXP_LNKSTA_NLW(QEMU_PCI_EXP_LNK_X1) |
QEMU_PCI_EXP_LNKSTA_CLS(QEMU_PCI_EXP_LNK_2_5GT));
- if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
- pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
- PCI_EXP_LNKSTA_DLLLA);
- }
-
/* We changed link status bits over time, and changing them across
* migrations is generally fine as hardware changes them too.
* Let's not bother checking.
@@ -125,8 +120,7 @@ static void pcie_cap_fill_slot_lnk(PCIDevice *dev)
*/
pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKCAP,
PCI_EXP_LNKCAP_DLLLARC);
- pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
- PCI_EXP_LNKSTA_DLLLA);
+ /* the PCI_EXP_LNKSTA_DLLLA will be set in the hotplug function */
/*
* Target Link Speed defaults to the highest link speed supported by
@@ -427,6 +421,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
PCIDevice *pci_dev = PCI_DEVICE(dev);
+ uint32_t lnkcap = pci_get_long(exp_cap + PCI_EXP_LNKCAP);
/* Don't send event when device is enabled during qemu machine creation:
* it is present on boot, no hotplug event is necessary. We do send an
@@ -434,7 +429,8 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
if (!dev->hotplugged) {
pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_PDS);
- if (pci_dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+ if (pci_dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA ||
+ (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) {
pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
PCI_EXP_LNKSTA_DLLLA);
}
@@ -448,7 +444,8 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
if (pci_get_function_0(pci_dev)) {
pci_word_test_and_set_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_PDS);
- if (pci_dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+ if (pci_dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA ||
+ (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) {
pci_word_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA,
PCI_EXP_LNKSTA_DLLLA);
}
@@ -640,6 +637,7 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
uint32_t pos = dev->exp.exp_cap;
uint8_t *exp_cap = dev->config + pos;
uint16_t sltsta = pci_get_word(exp_cap + PCI_EXP_SLTSTA);
+ uint32_t lnkcap = pci_get_long(exp_cap + PCI_EXP_LNKCAP);
if (ranges_overlap(addr, len, pos + PCI_EXP_SLTSTA, 2)) {
/*
@@ -695,7 +693,8 @@ void pcie_cap_slot_write_config(PCIDevice *dev,
pci_word_test_and_clear_mask(exp_cap + PCI_EXP_SLTSTA,
PCI_EXP_SLTSTA_PDS);
- if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA) {
+ if (dev->cap_present & QEMU_PCIE_LNKSTA_DLLLA ||
+ (lnkcap & PCI_EXP_LNKCAP_DLLLARC)) {
pci_word_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA,
PCI_EXP_LNKSTA_DLLLA);
}
--
2.27.0

View File

@ -0,0 +1,154 @@
From b76dbfedc47366039a08f68de82792b9c70a6be9 Mon Sep 17 00:00:00 2001
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 22 Feb 2021 13:35:06 -0500
Subject: [PATCH 23/54] qemu-iotests: 300: Add test case for modifying
persistence of bitmap
RH-Author: Peter Krempa <pkrempa@redhat.com>
Message-id: <a63403a45bdb082d5bd339f5161dd177d8374f74.1614000630.git.pkrempa@redhat.com>
Patchwork-id: 101172
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 3/3] qemu-iotests: 300: Add test case for modifying persistence of bitmap
Bugzilla: 1930757
RH-Acked-by: John Snow <jsnow@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
RH-Acked-by: Eric Blake <eblake@redhat.com>
Verify that the modification of the bitmap persistence over migration
which is controlled via BitmapMigrationBitmapAliasTransform works
properly.
Based on TestCrossAliasMigration
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Message-Id: <d9c8e9827e9b6001b2dd1b92e64aab858e6d2a86.1613150869.git.pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: Adjust test for explicit read_zeroes=False]
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit ca4bfec41d56a1154da89b105048b3462361d0f0)
https://bugzilla.redhat.com/show_bug.cgi?id=1930757
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
tests/qemu-iotests/300 | 93 ++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/300.out | 4 +-
2 files changed, 95 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/300 b/tests/qemu-iotests/300
index 5b75121b84..b25d8b04c0 100755
--- a/tests/qemu-iotests/300
+++ b/tests/qemu-iotests/300
@@ -588,6 +588,99 @@ class TestCrossAliasMigration(TestDirtyBitmapMigration):
self.verify_dest_has_all_bitmaps()
self.verify_dest_error(None)
+class TestAliasTransformMigration(TestDirtyBitmapMigration):
+ """
+ Tests the 'transform' option which modifies bitmap persistence on migration.
+ """
+
+ src_node_name = 'node-a'
+ dst_node_name = 'node-b'
+ src_bmap_name = 'bmap-a'
+ dst_bmap_name = 'bmap-b'
+
+ def setUp(self) -> None:
+ TestDirtyBitmapMigration.setUp(self)
+
+ # Now create another block device and let both have two bitmaps each
+ result = self.vm_a.qmp('blockdev-add',
+ node_name='node-b', driver='null-co',
+ read_zeroes=False)
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm_b.qmp('blockdev-add',
+ node_name='node-a', driver='null-co',
+ read_zeroes=False)
+ self.assert_qmp(result, 'return', {})
+
+ bmaps_to_add = (('node-a', 'bmap-b'),
+ ('node-b', 'bmap-a'),
+ ('node-b', 'bmap-b'))
+
+ for (node, bmap) in bmaps_to_add:
+ result = self.vm_a.qmp('block-dirty-bitmap-add',
+ node=node, name=bmap)
+ self.assert_qmp(result, 'return', {})
+
+ @staticmethod
+ def transform_mapping() -> BlockBitmapMapping:
+ return [
+ {
+ 'node-name': 'node-a',
+ 'alias': 'node-a',
+ 'bitmaps': [
+ {
+ 'name': 'bmap-a',
+ 'alias': 'bmap-a',
+ 'transform':
+ {
+ 'persistent': True
+ }
+ },
+ {
+ 'name': 'bmap-b',
+ 'alias': 'bmap-b'
+ }
+ ]
+ },
+ {
+ 'node-name': 'node-b',
+ 'alias': 'node-b',
+ 'bitmaps': [
+ {
+ 'name': 'bmap-a',
+ 'alias': 'bmap-a'
+ },
+ {
+ 'name': 'bmap-b',
+ 'alias': 'bmap-b'
+ }
+ ]
+ }
+ ]
+
+ def verify_dest_bitmap_state(self) -> None:
+ bitmaps = self.vm_b.query_bitmaps()
+
+ for node in bitmaps:
+ bitmaps[node] = sorted(((bmap['name'], bmap['persistent']) for bmap in bitmaps[node]))
+
+ self.assertEqual(bitmaps,
+ {'node-a': [('bmap-a', True), ('bmap-b', False)],
+ 'node-b': [('bmap-a', False), ('bmap-b', False)]})
+
+ def test_transform_on_src(self) -> None:
+ self.set_mapping(self.vm_a, self.transform_mapping())
+
+ self.migrate()
+ self.verify_dest_bitmap_state()
+ self.verify_dest_error(None)
+
+ def test_transform_on_dst(self) -> None:
+ self.set_mapping(self.vm_b, self.transform_mapping())
+
+ self.migrate()
+ self.verify_dest_bitmap_state()
+ self.verify_dest_error(None)
if __name__ == '__main__':
iotests.main(supported_protocols=['file'])
diff --git a/tests/qemu-iotests/300.out b/tests/qemu-iotests/300.out
index cafb8161f7..12e9ab7d57 100644
--- a/tests/qemu-iotests/300.out
+++ b/tests/qemu-iotests/300.out
@@ -1,5 +1,5 @@
-.....................................
+.......................................
----------------------------------------------------------------------
-Ran 37 tests
+Ran 39 tests
OK
--
2.27.0

View File

@ -0,0 +1,96 @@
From 1107799dade18adccfca5097341b6dfb4977e69e Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Mon, 22 Feb 2021 21:34:55 -0500
Subject: [PATCH 19/54] qemu-nbd: Use SOMAXCONN for socket listen() backlog
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Eric Blake <eblake@redhat.com>
Message-id: <20210222213455.320104-2-eblake@redhat.com>
Patchwork-id: 101192
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/1] qemu-nbd: Use SOMAXCONN for socket listen() backlog
Bugzilla: 1925345
RH-Acked-by: Richard Jones <rjones@redhat.com>
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
Our default of a backlog of 1 connection is rather puny; it gets in
the way when we are explicitly allowing multiple clients (such as
qemu-nbd -e N [--shared], or nbd-server-start with its default
"max-connections":0 for unlimited), but is even a problem when we
stick to qemu-nbd's default of only 1 active client but use -t
[--persistent] where a second client can start using the server once
the first finishes. While the effects are less noticeable on TCP
sockets (since the client can poll() to learn when the server is ready
again), it is definitely observable on Unix sockets, where on Linux, a
client will fail with EAGAIN and no recourse but to sleep an arbitrary
amount of time before retrying if the server backlog is already full.
Since QMP nbd-server-start is always persistent, it now always
requests a backlog of SOMAXCONN; meanwhile, qemu-nbd will request
SOMAXCONN if persistent, otherwise its backlog should be based on the
expected number of clients.
See https://bugzilla.redhat.com/1925045 for a demonstration of where
our low backlog prevents libnbd from connecting as many parallel
clients as it wants.
Reported-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
CC: qemu-stable@nongnu.org
Message-Id: <20210209152759.209074-2-eblake@redhat.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 582d4210eb2f2ab5baac328fe4b479cd86da1647)
Signed-off-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
blockdev-nbd.c | 7 ++++++-
qemu-nbd.c | 10 +++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index d8443d235b..b264620b98 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -134,7 +134,12 @@ void nbd_server_start(SocketAddress *addr, const char *tls_creds,
qio_net_listener_set_name(nbd_server->listener,
"nbd-listener");
- if (qio_net_listener_open_sync(nbd_server->listener, addr, 1, errp) < 0) {
+ /*
+ * Because this server is persistent, a backlog of SOMAXCONN is
+ * better than trying to size it to max_connections.
+ */
+ if (qio_net_listener_open_sync(nbd_server->listener, addr, SOMAXCONN,
+ errp) < 0) {
goto error;
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 1d337b7504..ce1dc43d69 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -970,8 +970,16 @@ int main(int argc, char **argv)
server = qio_net_listener_new();
if (socket_activation == 0) {
+ int backlog;
+
+ if (persistent) {
+ backlog = SOMAXCONN;
+ } else {
+ backlog = MIN(shared, SOMAXCONN);
+ }
saddr = nbd_build_socket_address(sockpath, bindto, port);
- if (qio_net_listener_open_sync(server, saddr, 1, &local_err) < 0) {
+ if (qio_net_listener_open_sync(server, saddr, backlog,
+ &local_err) < 0) {
object_unref(OBJECT(server));
error_report_err(local_err);
exit(EXIT_FAILURE);
--
2.27.0

View File

@ -0,0 +1,49 @@
From 6707057bc09cef526579bddb54ef7d4c3a7883ad Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 16 Feb 2021 16:19:42 -0500
Subject: [PATCH 16/54] qemu-storage-daemon: Enable object-add
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <20210216161943.126728-5-kwolf@redhat.com>
Patchwork-id: 101103
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 4/5] qemu-storage-daemon: Enable object-add
Bugzilla: 1901323
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
As we don't have a fully QAPIfied version of object-add yet and it still
has 'gen': false in the schema, it needs to be registered explicitly in
init_qmp_commands() to be available for users.
Fixes: 2af282ec51a27116d0402cab237b8970800f870c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210204072137.19663-1-kwolf@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 15d40e9204eb3d89577187f117a1dde2237bdc4d)
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
storage-daemon/qemu-storage-daemon.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index d8d172cc60..9021a46b3a 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -144,6 +144,8 @@ static void init_qmp_commands(void)
qmp_init_marshal(&qmp_commands);
qmp_register_command(&qmp_commands, "query-qmp-schema",
qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG);
+ qmp_register_command(&qmp_commands, "object-add", qmp_object_add,
+ QCO_NO_OPTIONS);
QTAILQ_INIT(&qmp_cap_negotiation_commands);
qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
--
2.27.0

View File

@ -0,0 +1,135 @@
From 1b6e1cc1f3d8033620bc0c04670d252180bd2c36 Mon Sep 17 00:00:00 2001
From: Peter Xu <peterx@redhat.com>
Date: Wed, 10 Feb 2021 17:10:34 -0300
Subject: [PATCH 11/54] redhat: Add some devices for exporting upstream machine
types
RH-Author: Peter Xu <peterx@redhat.com>
Message-id: <20210210171034.129116-2-peterx@redhat.com>
Patchwork-id: 101043
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/1] redhat: Add some devices for exporting upstream machine types
Bugzilla: 1917826
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Both "isa-parallel" and "hpet" will be required for the to-be-exported upstream
x86 machine types, so add them back into config.
Since HPET was disabled for rhel machine types previously, we need to
explicitly do that for RHEL now after we add HPET back.
Meanwhile, add blockers for the two devices so that they can never be created
on RHEL machine types. That should keep the old behavior for RHEL-AV.
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
default-configs/devices/x86_64-softmmu.mak | 6 ++++++
default-configs/devices/x86_64-upstream-devices.mak | 4 ++++
hw/char/parallel.c | 9 +++++++++
hw/i386/pc_piix.c | 2 +-
hw/i386/pc_q35.c | 2 +-
hw/timer/hpet.c | 8 ++++++++
6 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 default-configs/devices/x86_64-upstream-devices.mak
diff --git a/default-configs/devices/x86_64-softmmu.mak b/default-configs/devices/x86_64-softmmu.mak
index b5de7e5279..e57bcff7d9 100644
--- a/default-configs/devices/x86_64-softmmu.mak
+++ b/default-configs/devices/x86_64-softmmu.mak
@@ -3,3 +3,9 @@
#include i386-softmmu.mak
include x86_64-rh-devices.mak
+
+#
+# RHEL: this is for the limited upstream machine type support, so to export
+# some more devices than what RHEL machines have.
+#
+include x86_64-upstream-devices.mak
diff --git a/default-configs/devices/x86_64-upstream-devices.mak b/default-configs/devices/x86_64-upstream-devices.mak
new file mode 100644
index 0000000000..2cd20f54d2
--- /dev/null
+++ b/default-configs/devices/x86_64-upstream-devices.mak
@@ -0,0 +1,4 @@
+# We need "isa-parallel"
+CONFIG_PARALLEL=y
+# We need "hpet"
+CONFIG_HPET=y
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index 8b418abf71..6b3696a237 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -29,6 +29,7 @@
#include "chardev/char-parallel.h"
#include "chardev/char-fe.h"
#include "hw/acpi/aml-build.h"
+#include "hw/boards.h"
#include "hw/irq.h"
#include "hw/isa/isa.h"
#include "hw/qdev-properties.h"
@@ -533,6 +534,14 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp)
int base;
uint8_t dummy;
+ /* Restricted for Red Hat Enterprise Linux */
+ MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+ if (strstr(mc->name, "rhel")) {
+ error_setg(errp, "Device %s is not supported with machine type %s",
+ object_get_typename(OBJECT(dev)), mc->name);
+ return;
+ }
+
if (!qemu_chr_fe_backend_connected(&s->chr)) {
error_setg(errp, "Can't create parallel device, empty char device");
return;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1b1cc18ae0..6e1f1ba082 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -1018,7 +1018,7 @@ static void pc_machine_rhel7_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
m->family = "pc_piix_Y";
- m->default_machine_opts = "firmware=bios-256k.bin";
+ m->default_machine_opts = "firmware=bios-256k.bin,hpet=off";
pcmc->default_nic_model = "e1000";
m->default_display = "std";
m->no_parallel = 1;
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 72854192a9..a8c0496c9f 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -580,7 +580,7 @@ static void pc_q35_machine_rhel_options(MachineClass *m)
pcmc->default_nic_model = "e1000e";
m->family = "pc_q35_Z";
m->units_per_default_bus = 1;
- m->default_machine_opts = "firmware=bios-256k.bin";
+ m->default_machine_opts = "firmware=bios-256k.bin,hpet=off";
m->default_display = "std";
m->no_floppy = 1;
m->no_parallel = 1;
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 9520471be2..202e032524 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -733,6 +733,14 @@ static void hpet_realize(DeviceState *dev, Error **errp)
int i;
HPETTimer *timer;
+ /* Restricted for Red Hat Enterprise Linux */
+ MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
+ if (strstr(mc->name, "rhel")) {
+ error_setg(errp, "Device %s is not supported with machine type %s",
+ object_get_typename(OBJECT(dev)), mc->name);
+ return;
+ }
+
if (!s->intcap) {
warn_report("Hpet's intcap not initialized");
}
--
2.27.0

View File

@ -0,0 +1,205 @@
From 2cb473c2e1cd671da4458b58a0f760f4f1c36cbc Mon Sep 17 00:00:00 2001
From: Greg Kurz <gkurz@redhat.com>
Date: Wed, 10 Feb 2021 16:54:03 -0300
Subject: [PATCH 08/54] spapr: Adjust firmware path of PCI devices
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: Greg Kurz <gkurz@redhat.com>
Message-id: <20210210165403.469213-2-gkurz@redhat.com>
Patchwork-id: 101036
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/1] spapr: Adjust firmware path of PCI devices
Bugzilla: 1920941
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
RH-Acked-by: David Gibson <dgibson@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
From: Greg Kurz <groug@kaod.org>
It is currently not possible to perform a strict boot from USB storage:
$ qemu-system-ppc64 -accel kvm -nodefaults -nographic -serial stdio \
-boot strict=on \
-device qemu-xhci \
-device usb-storage,drive=disk,bootindex=0 \
-blockdev driver=file,node-name=disk,filename=fedora-ppc64le.qcow2
SLOF **********************************************************************
QEMU Starting
Build Date = Jul 17 2020 11:15:24
FW Version = git-e18ddad8516ff2cf
Press "s" to enter Open Firmware.
Populating /vdevice methods
Populating /vdevice/vty@71000000
Populating /vdevice/nvram@71000001
Populating /pci@800000020000000
00 0000 (D) : 1b36 000d serial bus [ usb-xhci ]
No NVRAM common partition, re-initializing...
Scanning USB
XHCI: Initializing
USB Storage
SCSI: Looking for devices
101000000000000 DISK : "QEMU QEMU HARDDISK 2.5+"
Using default console: /vdevice/vty@71000000
Welcome to Open Firmware
Copyright (c) 2004, 2017 IBM Corporation All rights reserved.
This program and the accompanying materials are made available
under the terms of the BSD License available at
http://www.opensource.org/licenses/bsd-license.php
Trying to load: from: /pci@800000020000000/usb@0/storage@1/disk@101000000000000 ...
E3405: No such device
E3407: Load failed
Type 'boot' and press return to continue booting the system.
Type 'reset-all' and press return to reboot the system.
Ready!
0 >
The device tree handed over by QEMU to SLOF indeed contains:
qemu,boot-list =
"/pci@800000020000000/usb@0/storage@1/disk@101000000000000 HALT";
but the device node is named usb-xhci@0, not usb@0.
This happens because the firmware names of PCI devices returned
by get_boot_devices_list() come from pcibus_get_fw_dev_path(),
while the sPAPR PHB code uses a different naming scheme for
device nodes. This inconsistency has always been there but it was
hidden for a long time because SLOF used to rename USB device
nodes, until this commit, merged in QEMU 4.2.0 :
commit 85164ad4ed9960cac842fa4cc067c6b6699b0994
Author: Alexey Kardashevskiy <aik@ozlabs.ru>
Date: Wed Sep 11 16:24:32 2019 +1000
pseries: Update SLOF firmware image
This fixes USB host bus adapter name in the device tree to match QEMU's
one.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Fortunately, sPAPR implements the firmware path provider interface.
This provides a way to override the default firmware paths.
Just factor out the sPAPR PHB naming logic from spapr_dt_pci_device()
to a helper, and use it in the sPAPR firmware path provider hook.
Fixes: 85164ad4ed99 ("pseries: Update SLOF firmware image")
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210122170157.246374-1-groug@kaod.org>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
(cherry picked from commit 040bdafce12f750816d879442014df2999a995c4)
Signed-off-by: Greg Kurz <gkurz@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
hw/ppc/spapr.c | 5 +++++
hw/ppc/spapr_pci.c | 33 ++++++++++++++++++---------------
include/hw/pci-host/spapr.h | 2 ++
3 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index a67df8cb26..c6a97e7964 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3057,6 +3057,7 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
SCSIDevice *d = CAST(SCSIDevice, dev, TYPE_SCSI_DEVICE);
SpaprPhbState *phb = CAST(SpaprPhbState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE);
VHostSCSICommon *vsc = CAST(VHostSCSICommon, dev, TYPE_VHOST_SCSI_COMMON);
+ PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE);
if (d) {
void *spapr = CAST(void, bus->parent, "spapr-vscsi");
@@ -3130,6 +3131,10 @@ static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus,
return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn));
}
+ if (pcidev) {
+ return spapr_pci_fw_dev_name(pcidev);
+ }
+
return NULL;
}
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 88ce87f130..e78e917af1 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1334,15 +1334,29 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCIBus *bus,
return offset;
}
+char *spapr_pci_fw_dev_name(PCIDevice *dev)
+{
+ const gchar *basename;
+ int slot = PCI_SLOT(dev->devfn);
+ int func = PCI_FUNC(dev->devfn);
+ uint32_t ccode = pci_default_read_config(dev, PCI_CLASS_PROG, 3);
+
+ basename = dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0xff,
+ ccode & 0xff);
+
+ if (func != 0) {
+ return g_strdup_printf("%s@%x,%x", basename, slot, func);
+ } else {
+ return g_strdup_printf("%s@%x", basename, slot);
+ }
+}
+
/* create OF node for pci device and required OF DT properties */
static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev,
void *fdt, int parent_offset)
{
int offset;
- const gchar *basename;
- gchar *nodename;
- int slot = PCI_SLOT(dev->devfn);
- int func = PCI_FUNC(dev->devfn);
+ g_autofree gchar *nodename = spapr_pci_fw_dev_name(dev);
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
ResourceProps rp;
SpaprDrc *drc = drc_from_dev(sphb, dev);
@@ -1359,19 +1373,8 @@ static int spapr_dt_pci_device(SpaprPhbState *sphb, PCIDevice *dev,
uint32_t pci_status = pci_default_read_config(dev, PCI_STATUS, 2);
gchar *loc_code;
- basename = dt_name_from_class((ccode >> 16) & 0xff, (ccode >> 8) & 0xff,
- ccode & 0xff);
-
- if (func != 0) {
- nodename = g_strdup_printf("%s@%x,%x", basename, slot, func);
- } else {
- nodename = g_strdup_printf("%s@%x", basename, slot);
- }
-
_FDT(offset = fdt_add_subnode(fdt, parent_offset, nodename));
- g_free(nodename);
-
/* in accordance with PAPR+ v2.7 13.6.3, Table 181 */
_FDT(fdt_setprop_cell(fdt, offset, "vendor-id", vendor_id));
_FDT(fdt_setprop_cell(fdt, offset, "device-id", device_id));
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index bd014823a9..5b03a7b0eb 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -210,4 +210,6 @@ static inline unsigned spapr_phb_windows_supported(SpaprPhbState *sphb)
return sphb->ddw_enabled ? SPAPR_PCI_DMA_MAX_WINDOWS : 1;
}
+char *spapr_pci_fw_dev_name(PCIDevice *dev);
+
#endif /* PCI_HOST_SPAPR_H */
--
2.27.0

View File

@ -0,0 +1,75 @@
From 9142072649d593acbd118e71f5d257bd9996ab36 Mon Sep 17 00:00:00 2001
From: eperezma <eperezma@redhat.com>
Date: Fri, 19 Feb 2021 08:49:50 -0300
Subject: [PATCH 12/54] vhost: Check for valid vdev in
vhost_backend_handle_iotlb_msg
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
RH-Author: eperezma <eperezma@redhat.com>
Message-id: <20210219084950.2159701-1-eperezma@redhat.com>
Patchwork-id: 101110
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH] vhost: Check for valid vdev in vhost_backend_handle_iotlb_msg
Bugzilla: 1880299
RH-Acked-by: Peter Xu <peterx@redhat.com>
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1880299
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=35031170
Not checking this can lead to invalid dev->vdev member access in
vhost_device_iotlb_miss if backend issue an iotlb message in a bad
timing, either maliciously or by a bug.
Reproduced rebooting a guest with testpmd in txonly forward mode.
#0 0x0000559ffff94394 in vhost_device_iotlb_miss (
dev=dev@entry=0x55a0012f6680, iova=10245279744, write=1)
at ../hw/virtio/vhost.c:1013
#1 0x0000559ffff9ac31 in vhost_backend_handle_iotlb_msg (
imsg=0x7ffddcfd32c0, dev=0x55a0012f6680)
at ../hw/virtio/vhost-backend.c:411
#2 vhost_backend_handle_iotlb_msg (dev=dev@entry=0x55a0012f6680,
imsg=imsg@entry=0x7ffddcfd32c0)
at ../hw/virtio/vhost-backend.c:404
#3 0x0000559fffeded7b in slave_read (opaque=0x55a0012f6680)
at ../hw/virtio/vhost-user.c:1464
#4 0x000055a0000c541b in aio_dispatch_handler (
ctx=ctx@entry=0x55a0010a2120, node=0x55a0012d9e00)
at ../util/aio-posix.c:329
Fixes: 020e571b8b ("vhost: rework IOTLB messaging")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20210129090728.831208-1-eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 4d1ccc17f40f73313e13c84914f70ec3d40ac738)
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
hw/virtio/vhost-backend.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 222bbcc62d..31b33bde37 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -406,6 +406,11 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
{
int ret = 0;
+ if (unlikely(!dev->vdev)) {
+ error_report("Unexpected IOTLB message when virtio device is stopped");
+ return -EINVAL;
+ }
+
switch (imsg->type) {
case VHOST_IOTLB_MISS:
ret = vhost_device_iotlb_miss(dev, imsg->iova,
--
2.27.0

View File

@ -0,0 +1,87 @@
From 4a1b30af56f99b9fe7ecdd47aa9691fed5d3a0c3 Mon Sep 17 00:00:00 2001
From: Stefano Garzarella <sgarzare@redhat.com>
Date: Tue, 9 Feb 2021 17:15:33 -0300
Subject: [PATCH 04/54] virtio: move 'use-disabled-flag' property to
hw_compat_4_2
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
Message-id: <20210209171533.133268-2-sgarzare@redhat.com>
Patchwork-id: 101012
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/1] virtio: move 'use-disabled-flag' property to hw_compat_4_2
Bugzilla: 1907255
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Commit 9d7bd0826f introduced a new 'use-disabled-flag' property
set to true by default.
To allow the migration, we set this property to false in the hw_compat,
but in the wrong place (hw_compat_4_1).
Since commit 9d7bd0826f was released with QEMU 5.0, we move
'use-disabled-flag' property to hw_compat_4_2, so 4.2 machine types
will have the pre-patch behavior and the migration can work.
The issue was discovered with vhost-vsock device and 4.2 machine
type without running any kernel in the VM:
$ qemu-4.2 -M pc-q35-4.2,accel=kvm \
-device vhost-vsock-pci,guest-cid=4 \
-monitor stdio -incoming tcp:0:3333
$ qemu-5.2 -M pc-q35-4.2,accel=kvm \
-device vhost-vsock-pci,guest-cid=3 \
-monitor stdio
(qemu) migrate -d tcp:0:3333
# qemu-4.2 output
qemu-system-x86_64: Failed to load virtio-vhost_vsock:virtio
qemu-system-x86_64: error while loading state for instance 0x0 of device '0000:00:03.0/virtio-vhost_vsock'
qemu-system-x86_64: load of migration failed: No such file or directory
Reported-by: Jing Zhao <jinzhao@redhat.com>
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1907255
Fixes: 9d7bd0826f ("virtio-pci: disable vring processing when bus-mastering is disabled")
Cc: mdroth@linux.vnet.ibm.com
CC: qemu-stable@nongnu.org
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20210108171252.209502-1-sgarzare@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit c126b4c57e0164549de606ca35d1512762051083)
[sgarzare: add 'use-disabled-flag' property to hw_compat_rhel_8_2]
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
hw/core/machine.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 68495b9411..92398966a4 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -77,6 +77,8 @@ GlobalProperty hw_compat_rhel_8_2[] = {
{ "qxl-vga", "revision", "4" },
/* hw_compat_rhel_8_2 from hw_compat_4_2 */
{ "fw_cfg", "acpi-mr-restore", "false" },
+ /* hw_compat_rhel_8_2 from hw_compat_4_2 */
+ { "virtio-device", "use-disabled-flag", "false" },
/* hw_compat_rhel_8_2 from hw_compat_5_0 */
{ "pci-host-bridge", "x-config-reg-migration-enabled", "off" },
/* hw_compat_rhel_8_2 from hw_compat_5_0 */
@@ -298,12 +300,12 @@ GlobalProperty hw_compat_4_2[] = {
{ "qxl", "revision", "4" },
{ "qxl-vga", "revision", "4" },
{ "fw_cfg", "acpi-mr-restore", "false" },
+ { "virtio-device", "use-disabled-flag", "false" },
};
const size_t hw_compat_4_2_len = G_N_ELEMENTS(hw_compat_4_2);
GlobalProperty hw_compat_4_1[] = {
{ "virtio-pci", "x-pcie-flr-init", "off" },
- { "virtio-device", "use-disabled-flag", "false" },
};
const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1);
--
2.27.0

View File

@ -0,0 +1,66 @@
From d66b778c2f888507dedc3e4111006215dd394b95 Mon Sep 17 00:00:00 2001
From: Laurent Vivier <lvivier@redhat.com>
Date: Thu, 25 Feb 2021 23:14:47 -0500
Subject: [PATCH 50/54] virtio-net: add missing object_unref()
RH-Author: Laurent Vivier <lvivier@redhat.com>
Message-id: <20210225231447.2187738-28-lvivier@redhat.com>
Patchwork-id: 101266
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH v2 27/27] virtio-net: add missing object_unref()
Bugzilla: 1819991
RH-Acked-by: Juan Quintela <quintela@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
BZ: https://bugzilla.redhat.com/1819991
BRANCH: rhel-av-8.4.0
UPSTREAM: Merged
failover_add_primary() calls qdev_device_add() and doesn't unref
the device. Because of that, when the device is unplugged a reference
is remaining and prevents the cleanup of the object.
This prevents to be able to plugin back the failover primary device,
with errors like:
(qemu) device_add vfio-pci,host=0000:41:00.0,id=hostdev0,bus=root.3,failover_pair_id=net0
(qemu) device_del hostdev0
We can check with "info qtree" and "info pci" that the device has been removed, and then:
(qemu) device_add vfio-pci,host=0000:41:00.0,id=hostdev1,bus=root.3,failover_pair_id=net0
Error: vfio 0000:41:00.0: device is already attached
(qemu) device_add vfio-pci,host=0000:41:00.0,id=hostdev0,bus=root.3,failover_pair_id=net0
qemu-kvm: Duplicate ID 'hostdev0' for device
Fixes: 21e8709b29cd ("failover: Remove primary_dev member")
Cc: quintela@redhat.com
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Message-Id: <20210212135250.2738750-3-lvivier@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
(cherry picked from commit 00e7b1299599384dfdda2a2a4570a0fb2d69eb6b)
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
hw/net/virtio-net.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 044ac95f6f..7faaa829b6 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -869,6 +869,8 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
dev = qdev_device_add(opts, &err);
if (err) {
qemu_opts_del(opts);
+ } else {
+ object_unref(OBJECT(dev));
}
} else {
error_setg(errp, "Primary device not found");
--
2.27.0

View File

@ -0,0 +1,157 @@
From 745a04765f21dad1991be89e23dd97a0543d3fce Mon Sep 17 00:00:00 2001
From: Stefan Hajnoczi <stefanha@redhat.com>
Date: Wed, 10 Feb 2021 11:15:16 -0300
Subject: [PATCH 05/54] virtiofsd: extract lo_do_open() from lo_open()
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: <20210210111518.228148-2-stefanha@redhat.com>
Patchwork-id: 101032
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/3] virtiofsd: extract lo_do_open() from lo_open()
Bugzilla: 1920740
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Both lo_open() and lo_create() have similar code to open a file. Extract
a common lo_do_open() function from lo_open() that will be used by
lo_create() in a later commit.
Since lo_do_open() does not otherwise need fuse_req_t req, convert
lo_add_fd_mapping() to use struct lo_data *lo instead.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210204150208.367837-2-stefanha@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
(cherry picked from commit 8afaaee976965b7fb90ec225a51d60f35c5f173c)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
tools/virtiofsd/passthrough_ll.c | 73 ++++++++++++++++++++------------
1 file changed, 46 insertions(+), 27 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 97485b22b4..218e20e9d7 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -471,17 +471,17 @@ static void lo_map_remove(struct lo_map *map, size_t key)
}
/* Assumes lo->mutex is held */
-static ssize_t lo_add_fd_mapping(fuse_req_t req, int fd)
+static ssize_t lo_add_fd_mapping(struct lo_data *lo, int fd)
{
struct lo_map_elem *elem;
- elem = lo_map_alloc_elem(&lo_data(req)->fd_map);
+ elem = lo_map_alloc_elem(&lo->fd_map);
if (!elem) {
return -1;
}
elem->fd = fd;
- return elem - lo_data(req)->fd_map.elems;
+ return elem - lo->fd_map.elems;
}
/* Assumes lo->mutex is held */
@@ -1661,6 +1661,38 @@ static void update_open_flags(int writeback, int allow_direct_io,
}
}
+static int lo_do_open(struct lo_data *lo, struct lo_inode *inode,
+ struct fuse_file_info *fi)
+{
+ char buf[64];
+ ssize_t fh;
+ int fd;
+
+ update_open_flags(lo->writeback, lo->allow_direct_io, fi);
+
+ sprintf(buf, "%i", inode->fd);
+ fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
+ if (fd == -1) {
+ return errno;
+ }
+
+ pthread_mutex_lock(&lo->mutex);
+ fh = lo_add_fd_mapping(lo, fd);
+ pthread_mutex_unlock(&lo->mutex);
+ if (fh == -1) {
+ close(fd);
+ return ENOMEM;
+ }
+
+ fi->fh = fh;
+ if (lo->cache == CACHE_NONE) {
+ fi->direct_io = 1;
+ } else if (lo->cache == CACHE_ALWAYS) {
+ fi->keep_cache = 1;
+ }
+ return 0;
+}
+
static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
mode_t mode, struct fuse_file_info *fi)
{
@@ -1701,7 +1733,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
ssize_t fh;
pthread_mutex_lock(&lo->mutex);
- fh = lo_add_fd_mapping(req, fd);
+ fh = lo_add_fd_mapping(lo, fd);
pthread_mutex_unlock(&lo->mutex);
if (fh == -1) {
close(fd);
@@ -1892,38 +1924,25 @@ static void lo_fsyncdir(fuse_req_t req, fuse_ino_t ino, int datasync,
static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
{
- int fd;
- ssize_t fh;
- char buf[64];
struct lo_data *lo = lo_data(req);
+ struct lo_inode *inode = lo_inode(req, ino);
+ int err;
fuse_log(FUSE_LOG_DEBUG, "lo_open(ino=%" PRIu64 ", flags=%d)\n", ino,
fi->flags);
- update_open_flags(lo->writeback, lo->allow_direct_io, fi);
-
- sprintf(buf, "%i", lo_fd(req, ino));
- fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
- if (fd == -1) {
- return (void)fuse_reply_err(req, errno);
- }
-
- pthread_mutex_lock(&lo->mutex);
- fh = lo_add_fd_mapping(req, fd);
- pthread_mutex_unlock(&lo->mutex);
- if (fh == -1) {
- close(fd);
- fuse_reply_err(req, ENOMEM);
+ if (!inode) {
+ fuse_reply_err(req, EBADF);
return;
}
- fi->fh = fh;
- if (lo->cache == CACHE_NONE) {
- fi->direct_io = 1;
- } else if (lo->cache == CACHE_ALWAYS) {
- fi->keep_cache = 1;
+ err = lo_do_open(lo, inode, fi);
+ lo_inode_put(lo, &inode);
+ if (err) {
+ fuse_reply_err(req, err);
+ } else {
+ fuse_reply_open(req, fi);
}
- fuse_reply_open(req, fi);
}
static void lo_release(fuse_req_t req, fuse_ino_t ino,
--
2.27.0

View File

@ -0,0 +1,121 @@
From 24833a2db44e39ec7652779a0fa2e70983b9cb4e Mon Sep 17 00:00:00 2001
From: Stefan Hajnoczi <stefanha@redhat.com>
Date: Wed, 10 Feb 2021 11:15:17 -0300
Subject: [PATCH 06/54] virtiofsd: optionally return inode pointer from
lo_do_lookup()
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: <20210210111518.228148-3-stefanha@redhat.com>
Patchwork-id: 101033
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 2/3] virtiofsd: optionally return inode pointer from lo_do_lookup()
Bugzilla: 1920740
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
lo_do_lookup() finds an existing inode or allocates a new one. It
increments nlookup so that the inode stays alive until the client
releases it.
Existing callers don't need the struct lo_inode so the function doesn't
return it. Extend the function to optionally return the inode. The next
commit will need it.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Message-Id: <20210204150208.367837-3-stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
(cherry picked from commit 22d2ece71e533310da31f2857ebc4a00d91968b3)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
tools/virtiofsd/passthrough_ll.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 218e20e9d7..2bd050b620 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -843,11 +843,13 @@ static int do_statx(struct lo_data *lo, int dirfd, const char *pathname,
}
/*
- * Increments nlookup and caller must release refcount using
- * lo_inode_put(&parent).
+ * Increments nlookup on the inode on success. unref_inode_lolocked() must be
+ * called eventually to decrement nlookup again. If inodep is non-NULL, the
+ * inode pointer is stored and the caller must call lo_inode_put().
*/
static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
- struct fuse_entry_param *e)
+ struct fuse_entry_param *e,
+ struct lo_inode **inodep)
{
int newfd;
int res;
@@ -857,6 +859,10 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
struct lo_inode *inode = NULL;
struct lo_inode *dir = lo_inode(req, parent);
+ if (inodep) {
+ *inodep = NULL;
+ }
+
/*
* name_to_handle_at() and open_by_handle_at() can reach here with fuse
* mount point in guest, but we don't have its inode info in the
@@ -924,7 +930,14 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
pthread_mutex_unlock(&lo->mutex);
}
e->ino = inode->fuse_ino;
- lo_inode_put(lo, &inode);
+
+ /* Transfer ownership of inode pointer to caller or drop it */
+ if (inodep) {
+ *inodep = inode;
+ } else {
+ lo_inode_put(lo, &inode);
+ }
+
lo_inode_put(lo, &dir);
fuse_log(FUSE_LOG_DEBUG, " %lli/%s -> %lli\n", (unsigned long long)parent,
@@ -959,7 +972,7 @@ static void lo_lookup(fuse_req_t req, fuse_ino_t parent, const char *name)
return;
}
- err = lo_do_lookup(req, parent, name, &e);
+ err = lo_do_lookup(req, parent, name, &e, NULL);
if (err) {
fuse_reply_err(req, err);
} else {
@@ -1067,7 +1080,7 @@ static void lo_mknod_symlink(fuse_req_t req, fuse_ino_t parent,
goto out;
}
- saverr = lo_do_lookup(req, parent, name, &e);
+ saverr = lo_do_lookup(req, parent, name, &e, NULL);
if (saverr) {
goto out;
}
@@ -1544,7 +1557,7 @@ static void lo_do_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
if (plus) {
if (!is_dot_or_dotdot(name)) {
- err = lo_do_lookup(req, ino, name, &e);
+ err = lo_do_lookup(req, ino, name, &e, NULL);
if (err) {
goto error;
}
@@ -1742,7 +1755,7 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
}
fi->fh = fh;
- err = lo_do_lookup(req, parent, name, &e);
+ err = lo_do_lookup(req, parent, name, &e, NULL);
}
if (lo->cache == CACHE_NONE) {
fi->direct_io = 1;
--
2.27.0

View File

@ -0,0 +1,311 @@
From 8cc13bdaa45cca3ef907cad9697683390aff2545 Mon Sep 17 00:00:00 2001
From: Stefan Hajnoczi <stefanha@redhat.com>
Date: Wed, 10 Feb 2021 11:15:18 -0300
Subject: [PATCH 07/54] virtiofsd: prevent opening of special files
(CVE-2020-35517)
RH-Author: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: <20210210111518.228148-4-stefanha@redhat.com>
Patchwork-id: 101034
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 3/3] virtiofsd: prevent opening of special files (CVE-2020-35517)
Bugzilla: 1920740
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Greg Kurz <gkurz@redhat.com>
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
A well-behaved FUSE client does not attempt to open special files with
FUSE_OPEN because they are handled on the client side (e.g. device nodes
are handled by client-side device drivers).
The check to prevent virtiofsd from opening special files is missing in
a few cases, most notably FUSE_OPEN. A malicious client can cause
virtiofsd to open a device node, potentially allowing the guest to
escape. This can be exploited by a modified guest device driver. It is
not exploitable from guest userspace since the guest kernel will handle
special files inside the guest instead of sending FUSE requests.
This patch fixes this issue by introducing the lo_inode_open() function
to check the file type before opening it. This is a short-term solution
because it does not prevent a compromised virtiofsd process from opening
device nodes on the host.
Restructure lo_create() to try O_CREAT | O_EXCL first. Note that O_CREAT
| O_EXCL does not follow symlinks, so O_NOFOLLOW masking is not
necessary here. If the file exists and the user did not specify O_EXCL,
open it via lo_do_open().
Reported-by: Alex Xu <alex@alxu.ca>
Fixes: CVE-2020-35517
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210204150208.367837-4-stefanha@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
(cherry picked from commit a3fdbbc7f271bff7d53d0501b29d910ece0b3789)
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
---
tools/virtiofsd/passthrough_ll.c | 144 ++++++++++++++++++++-----------
1 file changed, 92 insertions(+), 52 deletions(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 2bd050b620..03c5e0d13c 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -567,6 +567,38 @@ static int lo_fd(fuse_req_t req, fuse_ino_t ino)
return fd;
}
+/*
+ * Open a file descriptor for an inode. Returns -EBADF if the inode is not a
+ * regular file or a directory.
+ *
+ * Use this helper function instead of raw openat(2) to prevent security issues
+ * when a malicious client opens special files such as block device nodes.
+ * Symlink inodes are also rejected since symlinks must already have been
+ * traversed on the client side.
+ */
+static int lo_inode_open(struct lo_data *lo, struct lo_inode *inode,
+ int open_flags)
+{
+ g_autofree char *fd_str = g_strdup_printf("%d", inode->fd);
+ int fd;
+
+ if (!S_ISREG(inode->filetype) && !S_ISDIR(inode->filetype)) {
+ return -EBADF;
+ }
+
+ /*
+ * The file is a symlink so O_NOFOLLOW must be ignored. We checked earlier
+ * that the inode is not a special file but if an external process races
+ * with us then symlinks are traversed here. It is not possible to escape
+ * the shared directory since it is mounted as "/" though.
+ */
+ fd = openat(lo->proc_self_fd, fd_str, open_flags & ~O_NOFOLLOW);
+ if (fd < 0) {
+ return -errno;
+ }
+ return fd;
+}
+
static void lo_init(void *userdata, struct fuse_conn_info *conn)
{
struct lo_data *lo = (struct lo_data *)userdata;
@@ -696,9 +728,9 @@ static void lo_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
if (fi) {
truncfd = fd;
} else {
- sprintf(procname, "%i", ifd);
- truncfd = openat(lo->proc_self_fd, procname, O_RDWR);
+ truncfd = lo_inode_open(lo, inode, O_RDWR);
if (truncfd < 0) {
+ errno = -truncfd;
goto out_err;
}
}
@@ -860,7 +892,7 @@ static int lo_do_lookup(fuse_req_t req, fuse_ino_t parent, const char *name,
struct lo_inode *dir = lo_inode(req, parent);
if (inodep) {
- *inodep = NULL;
+ *inodep = NULL; /* in case there is an error */
}
/*
@@ -1674,19 +1706,26 @@ static void update_open_flags(int writeback, int allow_direct_io,
}
}
+/*
+ * Open a regular file, set up an fd mapping, and fill out the struct
+ * fuse_file_info for it. If existing_fd is not negative, use that fd instead
+ * opening a new one. Takes ownership of existing_fd.
+ *
+ * Returns 0 on success or a positive errno.
+ */
static int lo_do_open(struct lo_data *lo, struct lo_inode *inode,
- struct fuse_file_info *fi)
+ int existing_fd, struct fuse_file_info *fi)
{
- char buf[64];
ssize_t fh;
- int fd;
+ int fd = existing_fd;
update_open_flags(lo->writeback, lo->allow_direct_io, fi);
- sprintf(buf, "%i", inode->fd);
- fd = openat(lo->proc_self_fd, buf, fi->flags & ~O_NOFOLLOW);
- if (fd == -1) {
- return errno;
+ if (fd < 0) {
+ fd = lo_inode_open(lo, inode, fi->flags);
+ if (fd < 0) {
+ return -fd;
+ }
}
pthread_mutex_lock(&lo->mutex);
@@ -1709,9 +1748,10 @@ static int lo_do_open(struct lo_data *lo, struct lo_inode *inode,
static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
mode_t mode, struct fuse_file_info *fi)
{
- int fd;
+ int fd = -1;
struct lo_data *lo = lo_data(req);
struct lo_inode *parent_inode;
+ struct lo_inode *inode = NULL;
struct fuse_entry_param e;
int err;
struct lo_cred old = {};
@@ -1737,36 +1777,38 @@ static void lo_create(fuse_req_t req, fuse_ino_t parent, const char *name,
update_open_flags(lo->writeback, lo->allow_direct_io, fi);
- fd = openat(parent_inode->fd, name, (fi->flags | O_CREAT) & ~O_NOFOLLOW,
- mode);
+ /* Try to create a new file but don't open existing files */
+ fd = openat(parent_inode->fd, name, fi->flags | O_CREAT | O_EXCL, mode);
err = fd == -1 ? errno : 0;
- lo_restore_cred(&old);
- if (!err) {
- ssize_t fh;
+ lo_restore_cred(&old);
- pthread_mutex_lock(&lo->mutex);
- fh = lo_add_fd_mapping(lo, fd);
- pthread_mutex_unlock(&lo->mutex);
- if (fh == -1) {
- close(fd);
- err = ENOMEM;
- goto out;
- }
+ /* Ignore the error if file exists and O_EXCL was not given */
+ if (err && (err != EEXIST || (fi->flags & O_EXCL))) {
+ goto out;
+ }
- fi->fh = fh;
- err = lo_do_lookup(req, parent, name, &e, NULL);
+ err = lo_do_lookup(req, parent, name, &e, &inode);
+ if (err) {
+ goto out;
}
- if (lo->cache == CACHE_NONE) {
- fi->direct_io = 1;
- } else if (lo->cache == CACHE_ALWAYS) {
- fi->keep_cache = 1;
+
+ err = lo_do_open(lo, inode, fd, fi);
+ fd = -1; /* lo_do_open() takes ownership of fd */
+ if (err) {
+ /* Undo lo_do_lookup() nlookup ref */
+ unref_inode_lolocked(lo, inode, 1);
}
out:
+ lo_inode_put(lo, &inode);
lo_inode_put(lo, &parent_inode);
if (err) {
+ if (fd >= 0) {
+ close(fd);
+ }
+
fuse_reply_err(req, err);
} else {
fuse_reply_create(req, &e, fi);
@@ -1780,7 +1822,6 @@ static struct lo_inode_plock *lookup_create_plock_ctx(struct lo_data *lo,
pid_t pid, int *err)
{
struct lo_inode_plock *plock;
- char procname[64];
int fd;
plock =
@@ -1797,12 +1838,10 @@ static struct lo_inode_plock *lookup_create_plock_ctx(struct lo_data *lo,
}
/* Open another instance of file which can be used for ofd locks. */
- sprintf(procname, "%i", inode->fd);
-
/* TODO: What if file is not writable? */
- fd = openat(lo->proc_self_fd, procname, O_RDWR);
- if (fd == -1) {
- *err = errno;
+ fd = lo_inode_open(lo, inode, O_RDWR);
+ if (fd < 0) {
+ *err = -fd;
free(plock);
return NULL;
}
@@ -1949,7 +1988,7 @@ static void lo_open(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
return;
}
- err = lo_do_open(lo, inode, fi);
+ err = lo_do_open(lo, inode, -1, fi);
lo_inode_put(lo, &inode);
if (err) {
fuse_reply_err(req, err);
@@ -2005,39 +2044,40 @@ static void lo_flush(fuse_req_t req, fuse_ino_t ino, struct fuse_file_info *fi)
static void lo_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
struct fuse_file_info *fi)
{
+ struct lo_inode *inode = lo_inode(req, ino);
+ struct lo_data *lo = lo_data(req);
int res;
int fd;
- char *buf;
fuse_log(FUSE_LOG_DEBUG, "lo_fsync(ino=%" PRIu64 ", fi=0x%p)\n", ino,
(void *)fi);
- if (!fi) {
- struct lo_data *lo = lo_data(req);
-
- res = asprintf(&buf, "%i", lo_fd(req, ino));
- if (res == -1) {
- return (void)fuse_reply_err(req, errno);
- }
+ if (!inode) {
+ fuse_reply_err(req, EBADF);
+ return;
+ }
- fd = openat(lo->proc_self_fd, buf, O_RDWR);
- free(buf);
- if (fd == -1) {
- return (void)fuse_reply_err(req, errno);
+ if (!fi) {
+ fd = lo_inode_open(lo, inode, O_RDWR);
+ if (fd < 0) {
+ res = -fd;
+ goto out;
}
} else {
fd = lo_fi_fd(req, fi);
}
if (datasync) {
- res = fdatasync(fd);
+ res = fdatasync(fd) == -1 ? errno : 0;
} else {
- res = fsync(fd);
+ res = fsync(fd) == -1 ? errno : 0;
}
if (!fi) {
close(fd);
}
- fuse_reply_err(req, res == -1 ? errno : 0);
+out:
+ lo_inode_put(lo, &inode);
+ fuse_reply_err(req, res);
}
static void lo_read(fuse_req_t req, fuse_ino_t ino, size_t size, off_t offset,
--
2.27.0

View File

@ -0,0 +1,91 @@
From ed5fe7ae48c263ff69602b55361806f896ed12fb Mon Sep 17 00:00:00 2001
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Date: Tue, 23 Feb 2021 15:18:10 -0500
Subject: [PATCH 51/54] x86/cpu: Populate SVM CPUID feature bits
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-id: <20210223151811.27968-2-dgilbert@redhat.com>
Patchwork-id: 101197
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH 1/2] x86/cpu: Populate SVM CPUID feature bits
Bugzilla: 1926785
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
RH-Acked-by: Peter Xu <peterx@redhat.com>
From: Wei Huang <wei.huang2@amd.com>
Newer AMD CPUs will add CPUID_0x8000000A_EDX[28] bit, which indicates
that SVM instructions (VMRUN/VMSAVE/VMLOAD) will trigger #VMEXIT before
CPU checking their EAX against reserved memory regions. This change will
allow the hypervisor to avoid intercepting #GP and emulating SVM
instructions. KVM turns on this CPUID bit for nested VMs. In order to
support it, let us populate this bit, along with other SVM feature bits,
in FEAT_SVM.
Signed-off-by: Wei Huang <wei.huang2@amd.com>
Message-Id: <20210126202456.589932-1-wei.huang2@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 5447089c2b3b084b51670af36fc86ee3979e04be)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
target/i386/cpu.c | 6 +++---
target/i386/cpu.h | 24 ++++++++++++++----------
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index f944b41573..372cba2942 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -922,11 +922,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
"npt", "lbrv", "svm-lock", "nrip-save",
"tsc-scale", "vmcb-clean", "flushbyasid", "decodeassists",
NULL, NULL, "pause-filter", NULL,
- "pfthreshold", NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
+ "pfthreshold", "avic", NULL, "v-vmsave-vmload",
+ "vgif", NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
+ "svme-addr-chk", NULL, NULL, NULL,
},
.cpuid = { .eax = 0x8000000A, .reg = R_EDX, },
.tcg_features = TCG_SVM_FEATURES,
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index a3db7e3c6c..4fdb552f93 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -672,16 +672,20 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS];
#define CPUID_EXT3_PERFCORE (1U << 23)
#define CPUID_EXT3_PERFNB (1U << 24)
-#define CPUID_SVM_NPT (1U << 0)
-#define CPUID_SVM_LBRV (1U << 1)
-#define CPUID_SVM_SVMLOCK (1U << 2)
-#define CPUID_SVM_NRIPSAVE (1U << 3)
-#define CPUID_SVM_TSCSCALE (1U << 4)
-#define CPUID_SVM_VMCBCLEAN (1U << 5)
-#define CPUID_SVM_FLUSHASID (1U << 6)
-#define CPUID_SVM_DECODEASSIST (1U << 7)
-#define CPUID_SVM_PAUSEFILTER (1U << 10)
-#define CPUID_SVM_PFTHRESHOLD (1U << 12)
+#define CPUID_SVM_NPT (1U << 0)
+#define CPUID_SVM_LBRV (1U << 1)
+#define CPUID_SVM_SVMLOCK (1U << 2)
+#define CPUID_SVM_NRIPSAVE (1U << 3)
+#define CPUID_SVM_TSCSCALE (1U << 4)
+#define CPUID_SVM_VMCBCLEAN (1U << 5)
+#define CPUID_SVM_FLUSHASID (1U << 6)
+#define CPUID_SVM_DECODEASSIST (1U << 7)
+#define CPUID_SVM_PAUSEFILTER (1U << 10)
+#define CPUID_SVM_PFTHRESHOLD (1U << 12)
+#define CPUID_SVM_AVIC (1U << 13)
+#define CPUID_SVM_V_VMSAVE_VMLOAD (1U << 15)
+#define CPUID_SVM_VGIF (1U << 16)
+#define CPUID_SVM_SVME_ADDR_CHK (1U << 28)
/* Support RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */
#define CPUID_7_0_EBX_FSGSBASE (1U << 0)
--
2.27.0

View File

@ -64,7 +64,7 @@ Requires: %{name}-block-ssh = %{epoch}:%{version}-%{release}
Summary: QEMU is a machine emulator and virtualizer
Name: qemu-kvm
Version: 5.2.0
Release: 7%{?dist}
Release: 10%{?dist}
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
Epoch: 15
License: GPLv2 and GPLv2+ and CC-BY
@ -182,6 +182,108 @@ Patch71: kvm-storage-daemon-Call-bdrv_close_all-on-exit.patch
# For bz#1918966 - [incremental_backup] qemu aborts if guest reboot during backup when using virtio-blk: "aio_co_schedule: Co-routine was already scheduled in 'aio_co_schedule'"
# For bz#1918968 - [incremental_backup] qemu deadlock after poweroff in guest during backup in nbd_export_close_all()
Patch72: kvm-block-move-blk_exp_close_all-to-qemu_cleanup.patch
# For bz#1887883 - qemu blocks client progress with various NBD actions
Patch73: kvm-block-nbd-only-detach-existing-iochannel-from-aio_co.patch
# For bz#1887883 - qemu blocks client progress with various NBD actions
Patch74: kvm-block-nbd-only-enter-connection-coroutine-if-it-s-pr.patch
# For bz#1887883 - qemu blocks client progress with various NBD actions
Patch75: kvm-nbd-make-nbd_read-return-EIO-on-error.patch
# For bz#1907255 - Migrate failed with vhost-vsock-pci from RHEL-AV 8.3.1 to RHEL-AV 8.2.1
Patch76: kvm-virtio-move-use-disabled-flag-property-to-hw_compat_.patch
# For bz#1920740 - CVE-2020-35517 virt:8.4/qemu-kvm: QEMU: virtiofsd: potential privileged host device access from guest [rhel-av-8.4.0]
Patch77: kvm-virtiofsd-extract-lo_do_open-from-lo_open.patch
# For bz#1920740 - CVE-2020-35517 virt:8.4/qemu-kvm: QEMU: virtiofsd: potential privileged host device access from guest [rhel-av-8.4.0]
Patch78: kvm-virtiofsd-optionally-return-inode-pointer-from-lo_do.patch
# For bz#1920740 - CVE-2020-35517 virt:8.4/qemu-kvm: QEMU: virtiofsd: potential privileged host device access from guest [rhel-av-8.4.0]
Patch79: kvm-virtiofsd-prevent-opening-of-special-files-CVE-2020-.patch
# For bz#1920941 - [ppc64le] [AV]--disk cdimage.iso,bus=usb fails to boot
Patch80: kvm-spapr-Adjust-firmware-path-of-PCI-devices.patch
# For bz#1917830 - Add romsize property to qemu-kvm
Patch81: kvm-pci-reject-too-large-ROMs.patch
# For bz#1917830 - Add romsize property to qemu-kvm
Patch82: kvm-pci-add-romsize-property.patch
# For bz#1917826 - Add extra device support to qemu-kvm, but not to rhel machine types
Patch83: kvm-redhat-Add-some-devices-for-exporting-upstream-machi.patch
# For bz#1880299 - vhost-user mq connection fails to restart after kill host testpmd which acts as vhost-user client
Patch84: kvm-vhost-Check-for-valid-vdev-in-vhost_backend_handle_i.patch
# For bz#1901323 - QSD (QEMU Storage Daemon): basic support - TechPreview
Patch85: kvm-docs-generate-qemu-storage-daemon-qmp-ref-7-man-page.patch
# For bz#1901323 - QSD (QEMU Storage Daemon): basic support - TechPreview
Patch86: kvm-docs-add-qemu-storage-daemon-1-man-page.patch
# For bz#1901323 - QSD (QEMU Storage Daemon): basic support - TechPreview
Patch87: kvm-docs-Add-qemu-storage-daemon-1-manpage-to-meson.buil.patch
# For bz#1901323 - QSD (QEMU Storage Daemon): basic support - TechPreview
Patch88: kvm-qemu-storage-daemon-Enable-object-add.patch
# For bz#1930033 - enable vhost-user-blk device [TechPreview]
Patch90: kvm-default-configs-Enable-vhost-user-blk.patch
# For bz#1925345 - qemu-nbd needs larger backlog for Unix socket listen()
Patch91: kvm-qemu-nbd-Use-SOMAXCONN-for-socket-listen-backlog.patch
# For bz#1917654 - [failover vf migration][RHEL84 vm] After start a vm with a failover vf + a failover virtio net device, the failvoer vf do not exist in the vm
Patch92: kvm-pcie-don-t-set-link-state-active-if-the-slot-is-empt.patch
# For bz#1930757 - Allow control of block-dirty-bitmap persistence via 'block-bitmap-mapping'
Patch93: kvm-migration-dirty-bitmap-Use-struct-for-alias-map-inne.patch
# For bz#1930757 - Allow control of block-dirty-bitmap persistence via 'block-bitmap-mapping'
Patch94: kvm-migration-dirty-bitmap-Allow-control-of-bitmap-persi.patch
# For bz#1930757 - Allow control of block-dirty-bitmap persistence via 'block-bitmap-mapping'
Patch95: kvm-qemu-iotests-300-Add-test-case-for-modifying-persist.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch96: kvm-failover-fix-indentantion.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch97: kvm-failover-Use-always-atomics-for-primary_should_be_hi.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch98: kvm-failover-primary-bus-is-only-used-once-and-where-it-.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch99: kvm-failover-Remove-unused-parameter.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch100: kvm-failover-Remove-external-partially_hotplugged-proper.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch101: kvm-failover-qdev_device_add-returns-err-or-dev-set.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch102: kvm-failover-Rename-bool-to-failover_primary_hidden.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch103: kvm-failover-g_strcmp0-knows-how-to-handle-NULL.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch104: kvm-failover-Remove-primary_device_opts.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch105: kvm-failover-remove-standby_id-variable.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch106: kvm-failover-Remove-primary_device_dict.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch107: kvm-failover-Remove-memory-leak.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch108: kvm-failover-simplify-virtio_net_find_primary.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch109: kvm-failover-should_be_hidden-should-take-a-bool.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch110: kvm-failover-Rename-function-to-hide_device.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch111: kvm-failover-virtio_net_connect_failover_devices-does-no.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch112: kvm-failover-Rename-to-failover_find_primary_device.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch113: kvm-failover-simplify-qdev_device_add-failover-case.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch114: kvm-failover-simplify-qdev_device_add.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch115: kvm-failover-make-sure-that-id-always-exist.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch116: kvm-failover-remove-failover_find_primary_device-error-p.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch117: kvm-failover-split-failover_find_primary_device_id.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch118: kvm-failover-We-don-t-need-to-cache-primary_device_id-an.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch119: kvm-failover-Caller-of-this-two-functions-already-have-p.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch120: kvm-failover-simplify-failover_unplug_primary.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch121: kvm-failover-Remove-primary_dev-member.patch
# For bz#1819991 - Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug
Patch122: kvm-virtio-net-add-missing-object_unref.patch
# For bz#1926785 - [RFE] AMD Milan - Add KVM/support for EPYC-Milan CPU Model - Fast Train
Patch123: kvm-x86-cpu-Populate-SVM-CPUID-feature-bits.patch
# For bz#1926785 - [RFE] AMD Milan - Add KVM/support for EPYC-Milan CPU Model - Fast Train
Patch124: kvm-i386-Add-the-support-for-AMD-EPYC-3rd-generation-pro.patch
BuildRequires: wget
BuildRequires: rpm-build
@ -1045,9 +1147,6 @@ rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}/QEMU,cgthree.bin
rm -rf ${RPM_BUILD_ROOT}%{_bindir}/ivshmem-client
rm -rf ${RPM_BUILD_ROOT}%{_bindir}/ivshmem-server
# Remove qemu-storage-daemon
rm -rf ${RPM_BUILD_ROOT}%{_bindir}/qemu-storage-daemon
# Remove efi roms
rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}/efi*.rom
@ -1333,8 +1432,11 @@ sh %{_sysconfdir}/sysconfig/modules/kvm.modules &> /dev/null || :
%{_bindir}/qemu-img
%{_bindir}/qemu-io
%{_bindir}/qemu-nbd
%{_bindir}/qemu-storage-daemon
%{_mandir}/man1/qemu-img.1*
%{_mandir}/man8/qemu-nbd.8*
%{_mandir}/man1/qemu-storage-daemon.1*
%{_mandir}/man7/qemu-storage-daemon-qmp-ref.7*
%files -n qemu-guest-agent
%defattr(-,root,root,-)
@ -1371,6 +1473,92 @@ sh %{_sysconfdir}/sysconfig/modules/kvm.modules &> /dev/null || :
%changelog
* Wed Mar 03 2021 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 5.2.0-10.el8
- kvm-migration-dirty-bitmap-Use-struct-for-alias-map-inne.patch [bz#1930757]
- kvm-migration-dirty-bitmap-Allow-control-of-bitmap-persi.patch [bz#1930757]
- kvm-qemu-iotests-300-Add-test-case-for-modifying-persist.patch [bz#1930757]
- kvm-failover-fix-indentantion.patch [bz#1819991]
- kvm-failover-Use-always-atomics-for-primary_should_be_hi.patch [bz#1819991]
- kvm-failover-primary-bus-is-only-used-once-and-where-it-.patch [bz#1819991]
- kvm-failover-Remove-unused-parameter.patch [bz#1819991]
- kvm-failover-Remove-external-partially_hotplugged-proper.patch [bz#1819991]
- kvm-failover-qdev_device_add-returns-err-or-dev-set.patch [bz#1819991]
- kvm-failover-Rename-bool-to-failover_primary_hidden.patch [bz#1819991]
- kvm-failover-g_strcmp0-knows-how-to-handle-NULL.patch [bz#1819991]
- kvm-failover-Remove-primary_device_opts.patch [bz#1819991]
- kvm-failover-remove-standby_id-variable.patch [bz#1819991]
- kvm-failover-Remove-primary_device_dict.patch [bz#1819991]
- kvm-failover-Remove-memory-leak.patch [bz#1819991]
- kvm-failover-simplify-virtio_net_find_primary.patch [bz#1819991]
- kvm-failover-should_be_hidden-should-take-a-bool.patch [bz#1819991]
- kvm-failover-Rename-function-to-hide_device.patch [bz#1819991]
- kvm-failover-virtio_net_connect_failover_devices-does-no.patch [bz#1819991]
- kvm-failover-Rename-to-failover_find_primary_device.patch [bz#1819991]
- kvm-failover-simplify-qdev_device_add-failover-case.patch [bz#1819991]
- kvm-failover-simplify-qdev_device_add.patch [bz#1819991]
- kvm-failover-make-sure-that-id-always-exist.patch [bz#1819991]
- kvm-failover-remove-failover_find_primary_device-error-p.patch [bz#1819991]
- kvm-failover-split-failover_find_primary_device_id.patch [bz#1819991]
- kvm-failover-We-don-t-need-to-cache-primary_device_id-an.patch [bz#1819991]
- kvm-failover-Caller-of-this-two-functions-already-have-p.patch [bz#1819991]
- kvm-failover-simplify-failover_unplug_primary.patch [bz#1819991]
- kvm-failover-Remove-primary_dev-member.patch [bz#1819991]
- kvm-virtio-net-add-missing-object_unref.patch [bz#1819991]
- kvm-x86-cpu-Populate-SVM-CPUID-feature-bits.patch [bz#1926785]
- kvm-i386-Add-the-support-for-AMD-EPYC-3rd-generation-pro.patch [bz#1926785]
- Resolves: bz#1930757
(Allow control of block-dirty-bitmap persistence via 'block-bitmap-mapping')
- Resolves: bz#1819991
(Hostdev type interface with net failover enabled exists in domain xml and doesn't reattach to host after hot-unplug)
- Resolves: bz#1926785
([RFE] AMD Milan - Add KVM/support for EPYC-Milan CPU Model - Fast Train)
* Mon Mar 01 2021 Danilo Cesar Lemes de Paula <ddepaula@redhat.com> - 5.2.0-9.el8
- kvm-docs-generate-qemu-storage-daemon-qmp-ref-7-man-page.patch [bz#1901323]
- kvm-docs-add-qemu-storage-daemon-1-man-page.patch [bz#1901323]
- kvm-docs-Add-qemu-storage-daemon-1-manpage-to-meson.buil.patch [bz#1901323]
- kvm-qemu-storage-daemon-Enable-object-add.patch [bz#1901323]
- kvm-spec-Package-qemu-storage-daemon.patch [bz#1901323]
- kvm-default-configs-Enable-vhost-user-blk.patch [bz#1930033]
- kvm-qemu-nbd-Use-SOMAXCONN-for-socket-listen-backlog.patch [bz#1925345]
- kvm-pcie-don-t-set-link-state-active-if-the-slot-is-empt.patch [bz#1917654]
- Resolves: bz#1901323
(QSD (QEMU Storage Daemon): basic support - TechPreview)
- Resolves: bz#1930033
(enable vhost-user-blk device)
- Resolves: bz#1925345
(qemu-nbd needs larger backlog for Unix socket listen())
- Resolves: bz#1917654
([failover vf migration][RHEL84 vm] After start a vm with a failover vf + a failover virtio net device, the failvoer vf do not exist in the vm)
* Fri Feb 19 2021 Eduardo Lima (Etrunko) <elima@redhat.com> - 5.2.0-8.el8
- kvm-block-nbd-only-detach-existing-iochannel-from-aio_co.patch [bz#1887883]
- kvm-block-nbd-only-enter-connection-coroutine-if-it-s-pr.patch [bz#1887883]
- kvm-nbd-make-nbd_read-return-EIO-on-error.patch [bz#1887883]
- kvm-virtio-move-use-disabled-flag-property-to-hw_compat_.patch [bz#1907255]
- kvm-virtiofsd-extract-lo_do_open-from-lo_open.patch [bz#1920740]
- kvm-virtiofsd-optionally-return-inode-pointer-from-lo_do.patch [bz#1920740]
- kvm-virtiofsd-prevent-opening-of-special-files-CVE-2020-.patch [bz#1920740]
- kvm-spapr-Adjust-firmware-path-of-PCI-devices.patch [bz#1920941]
- kvm-pci-reject-too-large-ROMs.patch [bz#1917830]
- kvm-pci-add-romsize-property.patch [bz#1917830]
- kvm-redhat-Add-some-devices-for-exporting-upstream-machi.patch [bz#1917826]
- kvm-vhost-Check-for-valid-vdev-in-vhost_backend_handle_i.patch [bz#1880299]
- Resolves: bz#1887883
(qemu blocks client progress with various NBD actions)
- Resolves: bz#1907255
(Migrate failed with vhost-vsock-pci from RHEL-AV 8.3.1 to RHEL-AV 8.2.1)
- Resolves: bz#1920740
(CVE-2020-35517 virt:8.4/qemu-kvm: QEMU: virtiofsd: potential privileged host device access from guest [rhel-av-8.4.0])
- Resolves: bz#1920941
([ppc64le] [AV]--disk cdimage.iso,bus=usb fails to boot)
- Resolves: bz#1917830
(Add romsize property to qemu-kvm)
- Resolves: bz#1917826
(Add extra device support to qemu-kvm, but not to rhel machine types)
- Resolves: bz#1880299
(vhost-user mq connection fails to restart after kill host testpmd which acts as vhost-user client)
* Fri Feb 12 2021 Eduardo Lima (Etrunko) <elima@redhat.com> - 5.2.0-7.el8
- kvm-virtio-Add-corresponding-memory_listener_unregister-.patch [bz#1903521]
- kvm-block-Honor-blk_set_aio_context-context-requirements.patch [bz#1918966 bz#1918968]