[PATCH] docs: minor fix in launchSecurity
by Boris Fiuczynski
Correcting XML element.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
docs/formatdomain.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index d4f30bb8af..69e02e0135 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -8201,7 +8201,7 @@ Note: DEA/TDEA is synonymous with DES/TDES.
Launch Security
---------------
-Specifying ``<launchSecurity type='s390-pv'\>`` in a s390 domain prepares
+Specifying ``<launchSecurity type='s390-pv'/>`` in a s390 domain prepares
the guest to run in protected virtualization secure mode, also known as
IBM Secure Execution. For more required host and guest preparation steps, see
`Protected Virtualization on s390 <kbase/s390_protected_virt.html>`__
--
2.33.1
2 years, 10 months
[libvirt PATCH v2 0/3] ci: Check spelling
by Tim Wiederhake
This is a wrapper for codespell [1], a spell checker for source code.
Codespell does not compare words to a dictionary, but rather works by
checking words against a list of common typos, making it produce fewer
false positives than other solutions.
The script in this patch works around the lack of per-directory ignore
lists and some oddities regarding capitalization in ignore lists.
[1] (https://github.com/codespell-project/codespell/)
V1: https://listman.redhat.com/archives/libvir-list/2021-October/msg00015.html
The wrapper script changed since it was Reviewed-by: Ján, hence I did not mark
patch #2 as already reviewed.
Regards,
Tim
Tim Wiederhake (3):
scripts: Check spelling
ci: Add spell checking
Fix some typos
.gitlab-ci.yml | 12 +++
scripts/check-spelling.py | 119 ++++++++++++++++++++++++++++++
src/qemu/qemu_cgroup.c | 2 +-
tests/qemucapabilitiesnumbering.c | 2 +-
tests/qemucapabilitiestest.c | 4 +-
5 files changed, 135 insertions(+), 4 deletions(-)
create mode 100755 scripts/check-spelling.py
--
2.31.1
2 years, 10 months
[PATCH v2] report error when virProcessGetStatInfo() is unable to parse data
by Ani Sinha
Currently virProcessGetStatInfo() always returns success and only logs error
when it is unable to parse the data. Make this function actually report the
error and return a negative value in this error scenario.
Fix the callers so that they do not override the error generated.
Signed-off-by: Ani Sinha <ani(a)anisinha.ca>
---
src/ch/ch_driver.c | 2 --
src/qemu/qemu_driver.c | 7 +------
src/util/virprocess.c | 6 +++++-
3 files changed, 6 insertions(+), 9 deletions(-)
changelog:
v2: fixed the callers
diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c
index 53e0872207..3cbc668489 100644
--- a/src/ch/ch_driver.c
+++ b/src/ch/ch_driver.c
@@ -1073,8 +1073,6 @@ chDomainHelperGetVcpus(virDomainObj *vm,
if (virProcessGetStatInfo(&vcpuinfo->cpuTime,
&vcpuinfo->cpu, NULL,
vm->pid, vcpupid) < 0) {
- virReportSystemError(errno, "%s",
- _("cannot get vCPU placement & pCPU time"));
return -1;
}
}
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4974450333..015ffb2ce7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1359,8 +1359,6 @@ qemuDomainHelperGetVcpus(virDomainObj *vm,
if (virProcessGetStatInfo(&vcpuinfo->cpuTime,
&vcpuinfo->cpu, NULL,
vm->pid, vcpupid) < 0) {
- virReportSystemError(errno, "%s",
- _("cannot get vCPU placement & pCPU time"));
return -1;
}
}
@@ -2521,8 +2519,6 @@ qemuDomainGetInfo(virDomainPtr dom,
if (virDomainObjIsActive(vm)) {
if (virProcessGetStatInfo(&(info->cpuTime), NULL, NULL,
vm->pid, 0) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("cannot read cputime for domain"));
goto cleanup;
}
}
@@ -10530,8 +10526,7 @@ qemuDomainMemoryStatsInternal(virQEMUDriver *driver,
}
if (virProcessGetStatInfo(NULL, NULL, &rss, vm->pid, 0) < 0) {
- virReportError(VIR_ERR_OPERATION_FAILED, "%s",
- _("cannot get RSS for domain"));
+ return -1;
} else {
stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_RSS;
stats[ret].val = rss;
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index c74bd16fe6..b9f498d5d8 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1783,7 +1783,11 @@ virProcessGetStatInfo(unsigned long long *cpuTime,
virStrToLong_ullp(proc_stat[VIR_PROCESS_STAT_STIME], NULL, 10, &systime) < 0 ||
virStrToLong_l(proc_stat[VIR_PROCESS_STAT_RSS], NULL, 10, &rss) < 0 ||
virStrToLong_i(proc_stat[VIR_PROCESS_STAT_PROCESSOR], NULL, 10, &cpu) < 0) {
- VIR_WARN("cannot parse process status data");
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot parse process status data for pid '%d/%d'"),
+ (int) pid, (int) tid);
+
+ return -1;
}
/* We got jiffies
--
2.25.1
2 years, 10 months
[libvirt PATCH v5 00/20] qemu: Introduce hvf domain type for Hypervisor.framework
by Andrea Bolognani
In order to hopefully address [libvirt#147] at long last, I've picked
up Roman's patches from 2018 and attempted to forward-port them.
More specifically, I've used the [roolebo/hvf-domain] branch as a
starting point, since it seems to contain a few improvements over
[v2] and was just easier to pick up.
The code is mostly his own, so I've retained the existing authorship
information, but I've dropped Reviewed-by tags for commits that have
been modified in non-trivial ways. I've applied very minimal style
tweaks along the way, but overall I've tried to modify the existing
patches as little as possible.
I've added a few changes of my own, which I've marked as "fixup!"
when I felt that they should be squashed into the previous patch
rather than existing as separate commits.
The new test cases, such as they are, pass, and no regressions to KVM
support appear to have been introduced in the process. I don't
currently have access to a machine running macOS, so I can't verify
that it's actually possible to start a hardware-accelerated VM by
myself, but a user has confirmed on the GitLab issue that the new
feature works.
Changes from [v4]:
* fixed an issue that prevented machine types from being probed
correctly, effectively making the entire thing non functional;
* only report HVF support as available when the guest architecture
and the host architecture match.
Changes from [v3]:
* reintroduced the patch that was missing in the initial version
of the forward-port;
* converted the documentation to reStructuredText and trimmed it
significantly;
* reworked virQEMUCapsAccelStr() based on Dan's suggestions;
* reworked macOS support in the test suite based on Dan's
suggestions;
* fixed a few minor issues found while doing the above.
Changes from [v2]:
* rebased on top of master;
* added a couple of simple test cases.
Useful links:
* GitLab: [abologna/hvf]
* CI: [pipeline]
[libvirt#147] https://gitlab.com/libvirt/libvirt/-/issues/147
[roolebo/hvf-domain] https://github.com/roolebo/libvirt/tree/hvf-domain
[abologna/hvf] https://gitlab.com/abologna/libvirt/-/commits/hvf
[pipeline] https://gitlab.com/abologna/libvirt/-/pipelines/443320533
[v4] https://listman.redhat.com/archives/libvir-list/2022-January/msg00280.html
[v3] https://listman.redhat.com/archives/libvir-list/2022-January/msg00131.html
[v2] https://listman.redhat.com/archives/libvir-list/2018-November/msg00802.html
Andrea Bolognani (7):
qemu: Only probe KVM on Linux
fixup! qemu: Fix / improve virQEMUCapsProbeHVF()
tests: Introduce testQemuHostOS
tests: Add macOS support to testutilsqemu
tests: Add macOS support to qemuxml2*test
tests: Add HVF test cases
fixup! NEWS: Mention Apple Silicon support for HVF
Roman Bolshakov (13):
qemu: Add KVM CPUs into cache only if KVM is present
conf: Add hvf domain type
qemu: Define hvf capability
qemu: Query hvf capability on macOS
qemu: Expose hvf domain type if hvf is supported
qemu: Introduce virQEMUCapsAccelStr
qemu: Introduce virQEMUCapsTypeIsAccelerated
qemu: Introduce virQEMUCapsHaveAccel
qemu: Correct CPU capabilities probing for hvf
docs: Add hvf on QEMU driver page
docs: Note hvf support for domain elements
docs: Add support page for libvirt on macOS
news: Mention hvf domain type
NEWS.rst | 6 +
docs/docs.html.in | 3 +
docs/drvqemu.rst | 48 +++++-
docs/formatdomain.rst | 22 +--
docs/index.html.in | 4 +-
docs/macos.rst | 44 ++++++
docs/meson.build | 1 +
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 1 +
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 147 ++++++++++++++++--
src/qemu/qemu_capabilities.h | 3 +
src/qemu/qemu_command.c | 4 +
src/qemu/qemu_process.c | 10 +-
.../hvf-aarch64-virt-headless.args | 48 ++++++
.../hvf-aarch64-virt-headless.xml | 45 ++++++
.../hvf-x86_64-q35-headless.args | 47 ++++++
.../hvf-x86_64-q35-headless.x86_64-latest.err | 1 +
.../hvf-x86_64-q35-headless.xml | 44 ++++++
tests/qemuxml2argvtest.c | 43 ++++-
.../hvf-aarch64-virt-headless.xml | 94 +++++++++++
.../hvf-x86_64-q35-headless.xml | 97 ++++++++++++
tests/qemuxml2xmltest.c | 43 ++++-
tests/testutilsqemu.c | 146 +++++++++++++----
tests/testutilsqemu.h | 10 ++
25 files changed, 849 insertions(+), 64 deletions(-)
create mode 100644 docs/macos.rst
create mode 100644 tests/qemuxml2argvdata/hvf-aarch64-virt-headless.args
create mode 100644 tests/qemuxml2argvdata/hvf-aarch64-virt-headless.xml
create mode 100644 tests/qemuxml2argvdata/hvf-x86_64-q35-headless.args
create mode 100644 tests/qemuxml2argvdata/hvf-x86_64-q35-headless.x86_64-latest.err
create mode 100644 tests/qemuxml2argvdata/hvf-x86_64-q35-headless.xml
create mode 100644 tests/qemuxml2xmloutdata/hvf-aarch64-virt-headless.xml
create mode 100644 tests/qemuxml2xmloutdata/hvf-x86_64-q35-headless.xml
--
2.31.1
2 years, 10 months
[PATCH] docs: Add man page for libvirt-guests
by Jim Fehlig
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
docs/manpages/index.rst | 1 +
docs/manpages/libvirt-guests.rst | 146 +++++++++++++++++++++++++++++++
docs/manpages/meson.build | 1 +
tools/libvirt-guests.service.in | 2 +-
4 files changed, 149 insertions(+), 1 deletion(-)
diff --git a/docs/manpages/index.rst b/docs/manpages/index.rst
index fb4a36d46a..b2717bc9f2 100644
--- a/docs/manpages/index.rst
+++ b/docs/manpages/index.rst
@@ -41,6 +41,7 @@ Tools
* `virt-admin(1) <virt-admin.html>`__ - daemon administration interface
* `virsh(1) <virsh.html>`__ - management user interface
* `virt-qemu-run(1) <virt-qemu-run.html>`__ - run standalone QEMU instances
+* `libvirt-guests(8) <libvirt-guests.html>`__ - Suspend/Resume running libvirt guests
Key codes
=========
diff --git a/docs/manpages/libvirt-guests.rst b/docs/manpages/libvirt-guests.rst
new file mode 100644
index 0000000000..9dc7ed3473
--- /dev/null
+++ b/docs/manpages/libvirt-guests.rst
@@ -0,0 +1,146 @@
+==============
+libvirt-guests
+==============
+
+-------------------------------------
+suspend/resume running libvirt guests
+-------------------------------------
+
+:Manual section: 8
+:Manual group: Virtualization Support
+
+.. contents::
+
+SYNOPSIS
+========
+
+``libvirt-guests`` *COMMAND*
+
+
+DESCRIPTION
+===========
+
+``libvirt-guests`` is a service that can be used to coordinate guest and host
+lifecyle actions. By default, ``libvirt-guests`` will suspend running guests
+when the host shuts down, and restore them to their pre-shutdown state when
+the host reboots.
+
+``libvirt-guests`` is typically under control of systemd. When
+``libvirt-guests.service`` is enabled, systemd will call ``libvirt-guests``
+with the ``start`` *command* when the host boots. Conversely, systemd will call
+``libvirt-guests`` with the ``stop`` *command* when the host shuts down.
+
+``libvirt-guests`` can be used directly. In addition to the ``start`` and
+``stop`` *commands*, it also supports ``status``, ``restart``, ``condrestart``,
+``try-restart``, ``reload``, ``force-reload``, ``gueststatus``, and
+``shutdown`` *commands*.
+
+
+ENVIRONMENT
+===========
+
+The following environment variables can be used to alter the behavior of
+``libvirt-guests``
+
+- URIS=default
+
+ URIs to check for running guests
+
+- ON_BOOT=start
+
+ Action taken on host boot
+
+ * start
+
+ All guests which were running on shutdown are started on boot regardless
+ of their autostart settings
+
+ * ignore
+
+ ``libvirt-guests`` won't start any guest on boot, however, guests marked
+ as autostart will still be automatically started by libvirtd
+
+- START_DELAY=0
+
+ Number of seconds to wait between each guest start. Set to 0 to allow parallel
+ startup.
+
+- ON_SHUTDOWN=suspend
+
+ Action taken on host shutdown
+
+ * suspend
+
+ All running guests are suspended using virsh managedsave
+
+ * shutdown
+
+ All running guests are asked to shutdown. Please be careful with this
+ settings since there is no way to distinguish between a guest which is
+ stuck or ignores shutdown requests and a guest which just needs a long
+ time to shutdown. When setting ON_SHUTDOWN=shutdown, you must also set
+ SHUTDOWN_TIMEOUT to a value suitable for your guests.
+
+- PARALLEL_SHUTDOWN=0
+
+ Number of guests will be shutdown concurrently, taking effect when
+ "ON_SHUTDOWN" is set to "shutdown". If Set to 0, guests will be shutdown one
+ after another. Number of guests on shutdown at any time will not exceed number
+ set in this variable.
+
+- SHUTDOWN_TIMEOUT=300
+
+ Number of seconds we're willing to wait for a guest to shut down. If parallel
+ shutdown is enabled, this timeout applies as a timeout for shutting down all
+ guests on a single URI defined in the variable URIS. If this is 0, then there
+ is no time out (use with caution, as guests might not respond to a shutdown
+ request). The default value is 300 seconds (5 minutes).
+
+- BYPASS_CACHE=0
+
+ If non-zero, try to bypass the file system cache when saving and
+ restoring guests, even though this may give slower operation for
+ some file systems.
+
+ - SYNC_TIME=1
+
+ If non-zero, try to sync guest time on domain resume. Be aware, that
+ this requires guest agent with support for time synchronization
+ running in the guest. By default, this functionality is turned off.
+
+
+BUGS
+====
+
+Please report all bugs you discover. This should be done via either:
+
+#. the mailing list
+
+ `https://libvirt.org/contact.html <https://libvirt.org/contact.html>`_
+
+#. the bug tracker
+
+ `https://libvirt.org/bugs.html <https://libvirt.org/bugs.html>`_
+
+Alternatively, you may report bugs to your software distributor / vendor.
+
+
+AUTHORS
+=======
+
+Please refer to the AUTHORS file distributed with libvirt.
+
+
+LICENSE
+=======
+
+``libvirt-guests`` is distributed under the terms of the GNU LGPL v2.1+.
+This is free software; see the source for copying conditions. There
+is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE
+
+
+SEE ALSO
+========
+
+libvirtd(8), `https://libvirt.org/ <https://libvirt.org/>`_
diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build
index 6763d19af8..2c84011aa7 100644
--- a/docs/manpages/meson.build
+++ b/docs/manpages/meson.build
@@ -39,6 +39,7 @@ docs_man_files = [
{ 'name': 'virtvboxd', 'section': '8', 'install': conf.has('WITH_VBOX') },
{ 'name': 'virtvzd', 'section': '8', 'install': conf.has('WITH_VZ') },
{ 'name': 'virtxend', 'section': '8', 'install': conf.has('WITH_LIBXL') },
+ { 'name': 'libvirt-guests', 'section': '8', 'install': true },
]
foreach name : keycode_list
diff --git a/tools/libvirt-guests.service.in b/tools/libvirt-guests.service.in
index 10c664016a..1a9b233e11 100644
--- a/tools/libvirt-guests.service.in
+++ b/tools/libvirt-guests.service.in
@@ -6,7 +6,7 @@ After=network.target
After=time-sync.target
After=libvirtd.service
After=virt-guest-shutdown.target
-Documentation=man:libvirtd(8)
+Documentation=man:libvirt-guests(8)
Documentation=https://libvirt.org
[Service]
--
2.34.1
2 years, 10 months
[PATCH v1] virdnsmasq: fix runtime search for executable
by Olaf Hering
dnsmasq is an optional binary which does not neccessary exist during build.
Signed-off-by: Olaf Hering <olaf(a)aepfle.de>
---
src/util/virdnsmasq.c | 28 +++++++++++++++++++++++-----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index f2f606913f..06d192c99d 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -729,8 +729,26 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool force)
return ret;
}
+static char *
+dnsmasqGetBinaryPath(void)
+{
+ static const char binary[] = DNSMASQ;
+ char *binary_path;
+
+ if (g_path_is_absolute(binary))
+ return g_strdup(binary);
+
+ binary_path = virFindFileInPath(binary);
+ if (!binary_path) {
+ virReportSystemError(ENOENT, _("Cannot find '%s' in path"), binary);
+ binary_path = g_strdup(binary);
+ }
+
+ return binary_path;
+}
+
static dnsmasqCaps *
-dnsmasqCapsNewEmpty(const char *binaryPath)
+dnsmasqCapsNewEmpty(void)
{
dnsmasqCaps *caps;
@@ -739,14 +757,14 @@ dnsmasqCapsNewEmpty(const char *binaryPath)
if (!(caps = virObjectNew(dnsmasqCapsClass)))
return NULL;
caps->flags = virBitmapNew(DNSMASQ_CAPS_LAST);
- caps->binaryPath = g_strdup(binaryPath ? binaryPath : DNSMASQ);
+ caps->binaryPath = dnsmasqGetBinaryPath();
return caps;
}
dnsmasqCaps *
dnsmasqCapsNewFromBuffer(const char *buf)
{
- dnsmasqCaps *caps = dnsmasqCapsNewEmpty(DNSMASQ);
+ dnsmasqCaps *caps = dnsmasqCapsNewEmpty();
if (!caps)
return NULL;
@@ -761,7 +779,7 @@ dnsmasqCapsNewFromBuffer(const char *buf)
dnsmasqCaps *
dnsmasqCapsNewFromBinary(void)
{
- dnsmasqCaps *caps = dnsmasqCapsNewEmpty(DNSMASQ);
+ dnsmasqCaps *caps = dnsmasqCapsNewEmpty();
if (!caps)
return NULL;
@@ -776,7 +794,7 @@ dnsmasqCapsNewFromBinary(void)
const char *
dnsmasqCapsGetBinaryPath(dnsmasqCaps *caps)
{
- return caps ? caps->binaryPath : DNSMASQ;
+ return caps ? caps->binaryPath : dnsmasqGetBinaryPath();
}
unsigned long
2 years, 10 months
[PATCH] virsh-network: Don't check for virshXXXTypeFromString() >= VIR_XXX_LAST
by Michal Privoznik
They way our VIR_ENUM_IMPL() and virXXXTypeFromString() work is
that for any string that's not recognized a negative one is
returned. And, since VIR_XXX_LAST is passed to VIR_ENUM_IMPL() we
can be sure that all enum members are covered. Therefore, there
is no way that virXXXTypeFromString() can return a value that's
bigger or equal to VIR_XXX_LAST.
I've noticed two places where such comparison was made, both in
cmdNetworkUpdate(). Drop them.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-network.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 5f574be78c..b2daf31d6b 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -984,7 +984,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
command = VIR_NETWORK_UPDATE_COMMAND_ADD_LAST;
} else {
command = virshNetworkUpdateCommandTypeFromString(commandStr);
- if (command <= 0 || command >= VIR_NETWORK_UPDATE_COMMAND_LAST) {
+ if (command <= 0) {
vshError(ctl, _("unrecognized command name '%s'"), commandStr);
goto cleanup;
}
@@ -994,7 +994,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
section = virshNetworkSectionTypeFromString(sectionStr);
- if (section <= 0 || section >= VIR_NETWORK_SECTION_LAST) {
+ if (section <= 0) {
vshError(ctl, _("unrecognized section name '%s'"), sectionStr);
goto cleanup;
}
--
2.34.1
2 years, 10 months
[libvirt PATCH] meson: Fix yajl workaround
by Andrea Bolognani
Recent versions of Meson report
WARNING: pkgconfig variable 'cflags' not defined for dependency yajl.
which makes sense, because "cflags" is not one of the variables
reported by
$ pkg-config --print-variables yajl
and
$ pkg-config --variable=cflags yajl
doesn't work either.
Use "includedir", which is a proper pkg-config variable,
instead.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
meson.build | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/meson.build b/meson.build
index ec7dcffac4..214a3f05eb 100644
--- a/meson.build
+++ b/meson.build
@@ -1356,17 +1356,18 @@ if yajl_dep.found()
#
# [1] https://github.com/Homebrew/homebrew-core/pull/74516
if host_machine.system() != 'linux'
- cflags = yajl_dep.get_pkgconfig_variable('cflags')
- if cflags.contains('include/yajl')
+ includedir = yajl_dep.get_pkgconfig_variable('includedir')
+ if includedir.contains('include/yajl')
rc = run_command(
'python3', '-c',
'print("@0@".replace("@1@", "@2@"))'.format(
- cflags, 'include/yajl', 'include',
+ includedir, 'include/yajl', 'include',
),
check: true,
)
+ includedir = rc.stdout().strip()
yajl_dep = declare_dependency(
- compile_args: rc.stdout().strip().split(),
+ compile_args: [ '-I' + includedir ],
dependencies: [ yajl_dep ],
)
endif
--
2.31.1
2 years, 10 months
[PATCH v3 00/12] Add riscv kvm accel support
by Yifei Jiang
This series adds both riscv32 and riscv64 kvm support, and implements
migration based on riscv.
Because of RISC-V KVM has been merged into the Linux master, so this
series are changed from RFC to patch.
Several steps to use this:
1. Build emulation
$ ./configure --target-list=riscv64-softmmu
$ make -j$(nproc)
2. Build kernel
3. Build QEMU VM
Cross built in riscv toolchain.
$ PKG_CONFIG_LIBDIR=<toolchain pkgconfig path>
$ export PKG_CONFIG_SYSROOT_DIR=<toolchain sysroot path>
$ ./configure --target-list=riscv64-softmmu --enable-kvm \
--cross-prefix=riscv64-linux-gnu- --disable-libiscsi --disable-glusterfs \
--disable-libusb --disable-usb-redir --audio-drv-list= --disable-opengl \
--disable-libxml2
$ make -j$(nproc)
4. Start emulation
$ ./qemu-system-riscv64 -M virt -m 4096M -cpu rv64,x-h=true -nographic \
-name guest=riscv-hyp,debug-threads=on \
-smp 4 \
-bios ./fw_jump.bin \
-kernel ./Image \
-drive file=./hyp.img,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-append "root=/dev/vda rw console=ttyS0 earlycon=sbi"
5. Start kvm-acceled QEMU VM in emulation
$ ./qemu-system-riscv64 -M virt,accel=kvm -m 1024M -cpu host -nographic \
-name guest=riscv-guset \
-smp 2 \
-bios none \
-kernel ./Image \
-drive file=./guest.img,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-append "root=/dev/vda rw console=ttyS0 earlycon=sbi"
Changes since patch v2
- Create a macro for get and put timer csr.
- Remove M-mode PLIC contexts when kvm is enabled.
- Add get timer frequency.
- Move cpu_host_load to vmstate_kvmtimer.
Changes since patch v1
- Rebase on recent commit a216e7cf119c91ffdf5931834a1a030ebea40d70
- Sync-up headers with Linux-5.16-rc4.
- Fixbug in kvm_arch_init_vcpu.
- Create a macro for get and put regs csr.
- Start kernel directly when kvm_enabled.
- Use riscv_cpu_set_irq to inject KVM interrupts.
- Use the Semihosting Console API for RISC-V kvm handle sbi.
- Update vmstate_riscv_cpu version id.
Placing kvm_timer into a subsection.
Changes since RFC v6
- Rebase on recent commit 8627edfb3f1fca24a96a0954148885c3241c10f8
- Sync-up headers with Linux-5.16-rc1
Changes since RFC v5
- Rebase on QEMU v6.1.0-rc1 and kvm-riscv linux v19.
- Move kvm interrupt setting to riscv_cpu_update_mip().
- Replace __u64 with uint64_t.
Changes since RFC v4
- Rebase on QEMU v6.0.0-rc2 and kvm-riscv linux v17.
- Remove time scaling support as software solution is incomplete.
Because it will cause unacceptable performance degradation. and
We will post a better solution.
- Revise according to Alistair's review comments.
- Remove compile time XLEN checks in kvm_riscv_reg_id
- Surround TYPE_RISCV_CPU_HOST definition by CONFIG_KVM and share
it between RV32 and RV64.
- Add kvm-stub.c for reduce unnecessary compilation checks.
- Add riscv_setup_direct_kernel() to direct boot kernel for KVM.
Changes since RFC v3
- Rebase on QEMU v5.2.0-rc2 and kvm-riscv linux v15.
- Add time scaling support(New patches 13, 14 and 15).
- Fix the bug that guest vm can't reboot.
Changes since RFC v2
- Fix checkpatch error at target/riscv/sbi_ecall_interface.h.
- Add riscv migration support.
Changes since RFC v1
- Add separate SBI ecall interface header.
- Add riscv32 kvm accel support.
Yifei Jiang (12):
update-linux-headers: Add asm-riscv/kvm.h
target/riscv: Add target/riscv/kvm.c to place the public kvm interface
target/riscv: Implement function kvm_arch_init_vcpu
target/riscv: Implement kvm_arch_get_registers
target/riscv: Implement kvm_arch_put_registers
target/riscv: Support start kernel directly by KVM
target/riscv: Support setting external interrupt by KVM
target/riscv: Handle KVM_EXIT_RISCV_SBI exit
target/riscv: Add host cpu type
target/riscv: Add kvm_riscv_get/put_regs_timer
target/riscv: Implement virtual time adjusting with vm state changing
target/riscv: Support virtual time context synchronization
hw/intc/sifive_plic.c | 8 +-
hw/riscv/boot.c | 16 +-
hw/riscv/virt.c | 87 +++--
include/hw/riscv/boot.h | 1 +
linux-headers/asm-riscv/kvm.h | 128 +++++++
meson.build | 2 +
target/riscv/cpu.c | 29 +-
target/riscv/cpu.h | 11 +
target/riscv/kvm-stub.c | 30 ++
target/riscv/kvm.c | 533 +++++++++++++++++++++++++++++
target/riscv/kvm_riscv.h | 25 ++
target/riscv/machine.c | 30 ++
target/riscv/meson.build | 1 +
target/riscv/sbi_ecall_interface.h | 72 ++++
14 files changed, 944 insertions(+), 29 deletions(-)
create mode 100644 linux-headers/asm-riscv/kvm.h
create mode 100644 target/riscv/kvm-stub.c
create mode 100644 target/riscv/kvm.c
create mode 100644 target/riscv/kvm_riscv.h
create mode 100644 target/riscv/sbi_ecall_interface.h
--
2.19.1
2 years, 10 months