[PATCH] qemu_tpm: Do async IO when starting swtpm emulator
by Michal Privoznik
When vTPM is secured via virSecret libvirt passes the secret
value via an FD when swtpm is started (arguments --key and
--migration-key). The writing of the secret into the FDs is
handled via virCommand, specifically qemu_tpm calls
virCommandSetSendBuffer()) and then virCommandRunAsync() spawns a
thread to handle writing into the FD via
virCommandDoAsyncIOHelper. But the thread is not created unless
VIR_EXEC_ASYNC_IO flag is set, which it isn't. In order to fix
it, virCommandDoAsyncIO() must be called.
The credit goes to Marc-André Lureau
<marcandre.lureau(a)redhat.com> who has done all the debugging and
proposed fix in the bugzilla.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2064115
Fixes: a9c500d2b50c5c041a1bb6ae9724402cf1cec8fe
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_tpm.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
index 50f9caabf3..56bccee128 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -899,6 +899,7 @@ qemuTPMEmulatorStart(virQEMUDriver *driver,
if (!(pidfile = qemuTPMEmulatorPidFileBuildPath(cfg->swtpmStateDir, shortName)))
return -1;
+ virCommandDoAsyncIO(cmd);
virCommandDaemonize(cmd);
virCommandSetPidFile(cmd, pidfile);
virCommandSetErrorFD(cmd, &errfd);
--
2.34.1
2 years, 8 months
[PATCH 0/7] qemu: Add qemu-namespace XML to override device properties (-set replacement)
by Peter Krempa
The use of '-set' via the qemu argument passthrough broke when we
switched to using JSON with -device.
Provide a replacement using the qemu namespace XML elements.
Peter Krempa (7):
qemuDomainDefNamespaceFormatXML*: Convert to virXMLFormatElement
docs: drvqemu: Document overriding of device properties
qemu: domain: Add XML namespace code for overriding device config
conf: Introduce VIR_DOMAIN_TAINT_CUSTOM_DEVICE and use it in qemu
qemuBuildDeviceCommandlineFromJSON: Pass 'virDomainDef' into the
function
qemu: command: Override device definition according to the namespace
config
NEWS: Mention the qemu device property override feature
NEWS.rst | 7 +
docs/drvqemu.rst | 52 ++++
docs/schemas/domaincommon.rng | 32 +++
src/conf/domain_conf.c | 2 +
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 133 ++++++----
src/qemu/qemu_domain.c | 241 ++++++++++++++++--
src/qemu/qemu_domain.h | 33 +++
.../qemu-ns.x86_64-4.0.0.args | 2 +-
.../qemu-ns.x86_64-latest.args | 2 +-
tests/qemuxml2argvdata/qemu-ns.xml | 12 +
.../qemu-ns.x86_64-latest.xml | 12 +
12 files changed, 457 insertions(+), 72 deletions(-)
--
2.35.1
2 years, 8 months
[libvirt PATCH] schemas: move out of docs, fix no-docs build
by root
From: Claudio Fontana <cfontana(a)suse.de>
schemas are used for more than just documentation,
virsh edit fails if schemas are not available.
Therefore, fix the no-docs build by moving schemas
to the top source directory.
Signed-off-by: Claudio Fontana <cfontana(a)suse.de>
---
docs/meson.build | 2 --
meson.build | 2 ++
{docs/schemas => schemas}/basictypes.rng | 0
{docs/schemas => schemas}/capability.rng | 0
{docs/schemas => schemas}/cpu.rng | 0
{docs/schemas => schemas}/cputypes.rng | 0
{docs/schemas => schemas}/domain.rng | 0
{docs/schemas => schemas}/domainbackup.rng | 0
{docs/schemas => schemas}/domaincaps.rng | 0
{docs/schemas => schemas}/domaincheckpoint.rng | 0
{docs/schemas => schemas}/domaincommon.rng | 0
{docs/schemas => schemas}/domainsnapshot.rng | 0
{docs/schemas => schemas}/interface.rng | 0
{docs/schemas => schemas}/meson.build | 0
{docs/schemas => schemas}/network.rng | 0
{docs/schemas => schemas}/networkcommon.rng | 0
{docs/schemas => schemas}/networkport.rng | 0
{docs/schemas => schemas}/nodedev.rng | 0
{docs/schemas => schemas}/nwfilter.rng | 0
{docs/schemas => schemas}/nwfilter_params.rng | 0
{docs/schemas => schemas}/nwfilterbinding.rng | 0
{docs/schemas => schemas}/secret.rng | 0
{docs/schemas => schemas}/storagecommon.rng | 0
{docs/schemas => schemas}/storagepool.rng | 0
{docs/schemas => schemas}/storagepoolcaps.rng | 0
{docs/schemas => schemas}/storagevol.rng | 0
26 files changed, 2 insertions(+), 2 deletions(-)
rename {docs/schemas => schemas}/basictypes.rng (100%)
rename {docs/schemas => schemas}/capability.rng (100%)
rename {docs/schemas => schemas}/cpu.rng (100%)
rename {docs/schemas => schemas}/cputypes.rng (100%)
rename {docs/schemas => schemas}/domain.rng (100%)
rename {docs/schemas => schemas}/domainbackup.rng (100%)
rename {docs/schemas => schemas}/domaincaps.rng (100%)
rename {docs/schemas => schemas}/domaincheckpoint.rng (100%)
rename {docs/schemas => schemas}/domaincommon.rng (100%)
rename {docs/schemas => schemas}/domainsnapshot.rng (100%)
rename {docs/schemas => schemas}/interface.rng (100%)
rename {docs/schemas => schemas}/meson.build (100%)
rename {docs/schemas => schemas}/network.rng (100%)
rename {docs/schemas => schemas}/networkcommon.rng (100%)
rename {docs/schemas => schemas}/networkport.rng (100%)
rename {docs/schemas => schemas}/nodedev.rng (100%)
rename {docs/schemas => schemas}/nwfilter.rng (100%)
rename {docs/schemas => schemas}/nwfilter_params.rng (100%)
rename {docs/schemas => schemas}/nwfilterbinding.rng (100%)
rename {docs/schemas => schemas}/secret.rng (100%)
rename {docs/schemas => schemas}/storagecommon.rng (100%)
rename {docs/schemas => schemas}/storagepool.rng (100%)
rename {docs/schemas => schemas}/storagepoolcaps.rng (100%)
rename {docs/schemas => schemas}/storagevol.rng (100%)
diff --git a/docs/meson.build b/docs/meson.build
index 868267b764..7aebe08047 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -334,8 +334,6 @@ subdir('js')
subdir('kbase')
subdir('logos')
subdir('manpages')
-subdir('schemas')
-
foreach file : docs_assets
# This hack enables us to view the web pages
diff --git a/meson.build b/meson.build
index f6259e59a4..bea1b8e0ea 100644
--- a/meson.build
+++ b/meson.build
@@ -2125,6 +2125,8 @@ if gen_docs
subdir('docs')
endif
+subdir('schemas')
+
subdir('build-aux')
diff --git a/docs/schemas/basictypes.rng b/schemas/basictypes.rng
similarity index 100%
rename from docs/schemas/basictypes.rng
rename to schemas/basictypes.rng
diff --git a/docs/schemas/capability.rng b/schemas/capability.rng
similarity index 100%
rename from docs/schemas/capability.rng
rename to schemas/capability.rng
diff --git a/docs/schemas/cpu.rng b/schemas/cpu.rng
similarity index 100%
rename from docs/schemas/cpu.rng
rename to schemas/cpu.rng
diff --git a/docs/schemas/cputypes.rng b/schemas/cputypes.rng
similarity index 100%
rename from docs/schemas/cputypes.rng
rename to schemas/cputypes.rng
diff --git a/docs/schemas/domain.rng b/schemas/domain.rng
similarity index 100%
rename from docs/schemas/domain.rng
rename to schemas/domain.rng
diff --git a/docs/schemas/domainbackup.rng b/schemas/domainbackup.rng
similarity index 100%
rename from docs/schemas/domainbackup.rng
rename to schemas/domainbackup.rng
diff --git a/docs/schemas/domaincaps.rng b/schemas/domaincaps.rng
similarity index 100%
rename from docs/schemas/domaincaps.rng
rename to schemas/domaincaps.rng
diff --git a/docs/schemas/domaincheckpoint.rng b/schemas/domaincheckpoint.rng
similarity index 100%
rename from docs/schemas/domaincheckpoint.rng
rename to schemas/domaincheckpoint.rng
diff --git a/docs/schemas/domaincommon.rng b/schemas/domaincommon.rng
similarity index 100%
rename from docs/schemas/domaincommon.rng
rename to schemas/domaincommon.rng
diff --git a/docs/schemas/domainsnapshot.rng b/schemas/domainsnapshot.rng
similarity index 100%
rename from docs/schemas/domainsnapshot.rng
rename to schemas/domainsnapshot.rng
diff --git a/docs/schemas/interface.rng b/schemas/interface.rng
similarity index 100%
rename from docs/schemas/interface.rng
rename to schemas/interface.rng
diff --git a/docs/schemas/meson.build b/schemas/meson.build
similarity index 100%
rename from docs/schemas/meson.build
rename to schemas/meson.build
diff --git a/docs/schemas/network.rng b/schemas/network.rng
similarity index 100%
rename from docs/schemas/network.rng
rename to schemas/network.rng
diff --git a/docs/schemas/networkcommon.rng b/schemas/networkcommon.rng
similarity index 100%
rename from docs/schemas/networkcommon.rng
rename to schemas/networkcommon.rng
diff --git a/docs/schemas/networkport.rng b/schemas/networkport.rng
similarity index 100%
rename from docs/schemas/networkport.rng
rename to schemas/networkport.rng
diff --git a/docs/schemas/nodedev.rng b/schemas/nodedev.rng
similarity index 100%
rename from docs/schemas/nodedev.rng
rename to schemas/nodedev.rng
diff --git a/docs/schemas/nwfilter.rng b/schemas/nwfilter.rng
similarity index 100%
rename from docs/schemas/nwfilter.rng
rename to schemas/nwfilter.rng
diff --git a/docs/schemas/nwfilter_params.rng b/schemas/nwfilter_params.rng
similarity index 100%
rename from docs/schemas/nwfilter_params.rng
rename to schemas/nwfilter_params.rng
diff --git a/docs/schemas/nwfilterbinding.rng b/schemas/nwfilterbinding.rng
similarity index 100%
rename from docs/schemas/nwfilterbinding.rng
rename to schemas/nwfilterbinding.rng
diff --git a/docs/schemas/secret.rng b/schemas/secret.rng
similarity index 100%
rename from docs/schemas/secret.rng
rename to schemas/secret.rng
diff --git a/docs/schemas/storagecommon.rng b/schemas/storagecommon.rng
similarity index 100%
rename from docs/schemas/storagecommon.rng
rename to schemas/storagecommon.rng
diff --git a/docs/schemas/storagepool.rng b/schemas/storagepool.rng
similarity index 100%
rename from docs/schemas/storagepool.rng
rename to schemas/storagepool.rng
diff --git a/docs/schemas/storagepoolcaps.rng b/schemas/storagepoolcaps.rng
similarity index 100%
rename from docs/schemas/storagepoolcaps.rng
rename to schemas/storagepoolcaps.rng
diff --git a/docs/schemas/storagevol.rng b/schemas/storagevol.rng
similarity index 100%
rename from docs/schemas/storagevol.rng
rename to schemas/storagevol.rng
--
2.35.1
2 years, 8 months
Plans for the next release
by Jiri Denemark
We are getting close to the next release of libvirt. To aim for the
April Fools' release on Apr 01 I suggest entering the freeze on Monday
Mar 28 and tagging RC2 on Wednesday Mar 30.
I hope this works for everyone.
Jirka
2 years, 8 months
[PATCH RFC 0/1] s390x CPU Model Feature Deprecation
by Collin Walling
The s390x architecture has a growing list of features that will no longer
be supported on future hardware releases. This introduces an issue with
migration such that guests, running on models with these features enabled,
will be rejected outright by machines that do not support these features.
A current example is the CSSKE feature that has been deprecated for some time.
It has been publicly announced that gen15 will be the last release to
support this feature, however we have postponed this to gen16a. A possible
solution to remedy this would be to create a new QEMU QMP Response that allows
users to query for deprecated/unsupported features.
This presents two parts of the puzzle: how to report deprecated features to
a user (libvirt) and how should libvirt handle this information.
First, let's discuss the latter. The patch presented alongside this cover letter
attempts to solve the migration issue by hard-coding the CSSKE feature to be
disabled for all s390x CPU models. This is done by simply appending the CSSKE
feature with the disabled policy to the host-model.
libvirt pseudo:
if arch is s390x
set CSSKE to disabled for host-model
This will be recorded under the host-model as (observable via domcapabilities):
<mode name='host-model' supported='yes'>
<model fallback='forbid'>z13.2-base</model>
<feature policy='require' name='aen'/>
<feature policy='require' name='aefsi'/>
<feature policy='require' name='diag318'/>
...
<feature policy='disable' name='csske'/>
...
Obviously a hard-coded path is not a desired approach and requires a
constant update whenever newer features are listed for deprecation.
The patch is presented to instead spin up the discussion as to where
it is appropriate to record these deprecated features (e.g. should these
be reported under the host-model? or added to the guest CPU definition
prior to start up? etc). There is one issue observed by this change to
the host-model, denoted directly below.
A change in the host-model XML affects the hypervisor-cpu-comparison
command, which uses the libvirt-recorded host-model XML. Issuing
comparison on a machine that still supports CSSKE (but with it flagged
as disabled in the host-model XML) with an equal or older CPU model
that does *not* present CSSKE as disabled in the XML will be reported
as incompatible. The response should report "identical" or "superset"
because technically the hardware still supports the feature.
A possible solution is to modify the hypervisor-cpu-comparison command
to query the host-model via expansion to get the proper hypervisor CPU
model as opposed to using libvirt's modified definition.
Secondly, let's discuss the how to report the deprecated features. Namely,
an introduction of a new QEMU QMP response.
This would be a long-term approach that allows a user to query a list of
deprecated features for a particular architecture. A list will be kept
within QEMU that contains all deprecated CPU features. This allows the
retention of CPU model definitions within QEMU. Libvirt may query this
list and update the host-model definition to disable the features reported
by QEMU.
QEMU QMP Response example:
{ "execute": "query-cpu-model-deprecated-features" }
{ "return": { "props": { "name": "csske", "name": "feat_a", "name": "feat_b" }}}
libvirt pseudo:
if query_deprecated_features is supported
list = query_deprecated_features()
for each feat in list
set feat to disabled for host-model
Then, any new features that are flagged for deprecated in the future may
simply be added to this "deprecated features" list in QEMU alongside a
new CPU definition.
Please let me know your thoughts on these approaches. All input is welcome.
Thanks.
Collin Walling (1):
qemu: capabilities: disable csske for host cpu
src/qemu/qemu_capabilities.c | 10 ++++++++++
tests/domaincapsdata/qemu_2.11.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_2.12.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_2.8.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_2.9.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_3.0.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 +
8 files changed, 17 insertions(+)
--
2.31.1
2 years, 8 months
[libvirt RFC v2] virfile: set pipe size in virFileWrapperFdNew to improve throughput
by root
From: Claudio Fontana <cfontana(a)suse.de>
virsh save is very slow with a default pipe size, so set a larger one.
This change improves throughput by ~400% on fast nvme or ramdisk,
for the current only user of virFileWrapperFdNew: the qemu driver.
Best value currently measured is 1MB, which happens to be also
the kernel default for the pipe-max-size.
We do not try to use a pipe buffer larger than what the setting
of /proc/sys/fs/pipe-max-size currently allows.
Signed-off-by: Claudio Fontana <cfontana(a)suse.de>
---
src/util/virfile.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
see v1 at
https://listman.redhat.com/archives/libvir-list/2022-March/229252.html
Changes v1 -> v2:
* removed VIR_FILE_WRAPPER_BIG_PIPE, made the new pipe resizing
unconditional (Michal)
* moved code to separate functions (Michal)
* removed ternary op, disliked in libvirt (Michal)
* added #ifdef __linux__ (Ani Sinha)
* try smallest value between currently best measured value (1MB)
and the pipe-max-size setting. If pipe-max-size cannot be read,
try kernel default max (1MB). (Daniel)
diff --git a/src/util/virfile.c b/src/util/virfile.c
index a04f888e06..13bdd42c68 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -201,6 +201,71 @@ struct _virFileWrapperFd {
};
#ifndef WIN32
+
+#ifdef __linux__
+/**
+ * virFileWrapperGetBestPipeSize:
+ *
+ * get the best pipe size to use with virFileWrapper.
+ *
+ * We first check the maximum we are allowed by the system pipe-max-size,
+ * and then use the minimum between that and our tested best value.
+ * This is because a request beyond pipe-max-size may fail with EPERM.
+ * If we are unable to read pipe-max-size, use the kernel default (1MB).
+ *
+ * Return value is the pipe size to use.
+ */
+
+static int virFileWrapperGetBestPipeSize(void)
+{
+ const char path[] = "/proc/sys/fs/pipe-max-size";
+ int best_sz = 1024 * 1024; /* good virsh save results with this size */
+ int max_sz;
+
+ if (virFileReadValueInt(&max_sz, path) < 0) {
+ max_sz = 1024 * 1024; /* this is the kernel default pipe-max-size */
+ VIR_WARN("failed to read %s, trying default %d", path, max_sz);
+ } else if (max_sz > best_sz) {
+ max_sz = best_sz;
+ }
+ return max_sz;
+}
+
+/**
+ * virFileWrapperSetPipeSize:
+ * @fd: the fd of the pipe
+ *
+ * Set best pipe size on the passed file descriptor for bulk transfers of data.
+ *
+ * default pipe size (usually 64K) is generally not suited for large transfers
+ * to fast devices. This has been measured to improve virsh save by 400%
+ * in ideal conditions.
+ *
+ * Return value is 0 on success, -1 and errno set on error.
+ * OS note: only for linux, on other OS this is a no-op.
+ */
+static int
+virFileWrapperSetPipeSize(int fd)
+{
+ int pipe_sz = virFileWrapperGetBestPipeSize();
+ int rv = fcntl(fd, F_SETPIPE_SZ, pipe_sz);
+
+ if (rv < 0) {
+ VIR_ERROR(_("failed to set pipe size to %d (errno=%d)"), pipe_sz, errno);
+ return -1;
+ }
+ VIR_INFO("fd %d pipe size adjusted to %d", fd, rv);
+ return 0;
+}
+
+#else /* !__linux__ */
+static int virFileWrapperSetPipeSize(int fd)
+{
+ return 0;
+}
+#endif /* !__linux__ */
+
+
/**
* virFileWrapperFdNew:
* @fd: pointer to fd to wrap
@@ -282,6 +347,10 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned int flags)
ret->cmd = virCommandNewArgList(iohelper_path, name, NULL);
+ if (virFileWrapperSetPipeSize(pipefd[!output]) < 0) {
+ virReportError(VIR_ERR_SYSTEM_ERROR, "%s", _("unable to set pipe size, data transfer might be slow"));
+ }
+
if (output) {
virCommandSetInputFD(ret->cmd, pipefd[0]);
virCommandSetOutputFD(ret->cmd, fd);
--
2.35.1
2 years, 8 months
[PATCH] domain_conf: include checks against dom->os.type and dom->virtType
by Jamm02
All the checks against dom->os.type and dom->virtType in
virDomainInputDefParseXML shifted to
virDomainInputDefValidate function
Signed-off-by: Jamm02 <codeguy.moteen(a)gmail.com>
---
src/conf/domain_conf.c | 49 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e0dfc9e45f..b237fd9ab1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11837,6 +11837,55 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt,
return NULL;
}
+static virDomainInputDef *
+virDomainInputDefValidate(const virDomainDef *dom,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt)
+{
+ VIR_XPATH_NODE_AUTORESTORE(ctxt)
+ virDomainInputDef *def;
+ g_autofree char *bus = NULL;
+
+ def = g_new0(virDomainInputDef, 1);
+
+ ctxt->node = node;
+ bus = virXMLPropString(node, "bus");
+
+ if (bus) {
+ if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown input bus type '%s'"), bus);
+ goto error;
+ }
+
+ } else {
+ if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+ if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
+ (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_PS2;
+ } else if (ARCH_IS_S390(dom->os.arch) ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_VIRTIO;
+ } else if (def->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_NONE;
+ } else {
+ def->bus = VIR_DOMAIN_INPUT_BUS_USB;
+ }
+ } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ dom->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_XEN;
+ } else {
+ if ((dom->virtType == VIR_DOMAIN_VIRT_VZ ||
+ dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
+ def->bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
+ }
+ }
+
+ error:
+ virDomainInputDefFree(def);
+ return NULL;
+}
/* Parse the XML definition for an input device */
static virDomainInputDef *
virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
--
2.35.1
2 years, 8 months
[PATCH] domain_conf: include checks against dom->os.type and dom->virtType
by Jamm02
All the checks against dom->os.type and dom->virtType in
virDomainInputDefParseXML shifted to
virDomainInputDefValidate function
Signed-off-by: Jamm02 <codeguy.moteen(a)gmail.com>
---
src/conf/domain_conf.c | 49 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e0dfc9e45f..b237fd9ab1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11837,6 +11837,55 @@ virDomainPanicDefParseXML(virDomainXMLOption *xmlopt,
return NULL;
}
+static virDomainInputDef *
+virDomainInputDefValidate(const virDomainDef *dom,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt)
+{
+ VIR_XPATH_NODE_AUTORESTORE(ctxt)
+ virDomainInputDef *def;
+ g_autofree char *bus = NULL;
+
+ def = g_new0(virDomainInputDef, 1);
+
+ ctxt->node = node;
+ bus = virXMLPropString(node, "bus");
+
+ if (bus) {
+ if ((def->bus = virDomainInputBusTypeFromString(bus)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown input bus type '%s'"), bus);
+ goto error;
+ }
+
+ } else {
+ if (dom->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+ if ((def->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_KBD) &&
+ (ARCH_IS_X86(dom->os.arch) || dom->os.arch == VIR_ARCH_NONE)) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_PS2;
+ } else if (ARCH_IS_S390(dom->os.arch) ||
+ def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_VIRTIO;
+ } else if (def->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_NONE;
+ } else {
+ def->bus = VIR_DOMAIN_INPUT_BUS_USB;
+ }
+ } else if (dom->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ dom->os.type == VIR_DOMAIN_OSTYPE_XENPVH) {
+ def->bus = VIR_DOMAIN_INPUT_BUS_XEN;
+ } else {
+ if ((dom->virtType == VIR_DOMAIN_VIRT_VZ ||
+ dom->virtType == VIR_DOMAIN_VIRT_PARALLELS))
+ def->bus = VIR_DOMAIN_INPUT_BUS_PARALLELS;
+ }
+ }
+
+ error:
+ virDomainInputDefFree(def);
+ return NULL;
+}
/* Parse the XML definition for an input device */
static virDomainInputDef *
virDomainInputDefParseXML(virDomainXMLOption *xmlopt,
--
2.35.1
2 years, 8 months
[PATCH] virNWFilterLockIface: Preserve correct lock ordering
by Michal Privoznik
In the not so distant past, the lock ordering in
virNWFilterLockIface() was as follows: global mutex ifaceMapLock
was acquired, then internal representation of given interface was
looked up in a hash table (or created brand new if none was
found), the global lock was released and the lock of the
interface was acquired.
But this was mistakenly changed as the function was rewritten to
use automatic mutexes, because now the global lock is held
throughout the whole run of the function and thus the interface
specific lock is acquired with the global lock held. This results
in a deadlock.
Fixes: dd8150c48dcf94e8d3b0481be08eeef822b98b02
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/nwfilter/nwfilter_learnipaddr.c | 49 +++++++++++++++--------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 2c85972012..ec2d337188 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -143,37 +143,40 @@ static bool threadsTerminate;
int
virNWFilterLockIface(const char *ifname)
{
- VIR_LOCK_GUARD lock = virLockGuardLock(&ifaceMapLock);
- virNWFilterIfaceLock *ifaceLock = virHashLookup(ifaceLockMap, ifname);
+ virNWFilterIfaceLock *ifaceLock = NULL;
- if (!ifaceLock) {
- ifaceLock = g_new0(virNWFilterIfaceLock, 1);
+ VIR_WITH_MUTEX_LOCK_GUARD(&ifaceMapLock) {
+ ifaceLock = virHashLookup(ifaceLockMap, ifname);
- if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("mutex initialization failed"));
- g_free(ifaceLock);
- return -1;
- }
+ if (!ifaceLock) {
+ ifaceLock = g_new0(virNWFilterIfaceLock, 1);
- if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("interface name %s does not fit into buffer"),
- ifaceLock->ifname);
- g_free(ifaceLock);
- return -1;
- }
+ if (virMutexInitRecursive(&ifaceLock->lock) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("mutex initialization failed"));
+ g_free(ifaceLock);
+ return -1;
+ }
+
+ if (virStrcpyStatic(ifaceLock->ifname, ifname) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("interface name %s does not fit into buffer"),
+ ifaceLock->ifname);
+ g_free(ifaceLock);
+ return -1;
+ }
+
+ while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
+ g_free(ifaceLock);
+ return -1;
+ }
- while (virHashAddEntry(ifaceLockMap, ifname, ifaceLock)) {
- g_free(ifaceLock);
- return -1;
+ ifaceLock->refctr = 0;
}
- ifaceLock->refctr = 0;
+ ifaceLock->refctr++;
}
- ifaceLock->refctr++;
-
virMutexLock(&ifaceLock->lock);
return 0;
--
2.34.1
2 years, 8 months
[libvirt PATCH v2 00/17] qemu: Implement virtio-iommu support
by Andrea Bolognani
The first patch adds replies files and as such has been
aggressively snipped to deal with mailing list message size limits.
Grab the unabriged version with
$ git fetch https://gitlab.com/abologna/libvirt.git virtio-iommu
The QEMU side of the feature has now been merged, so this can finally
go in as well.
I have retained the R-bs for most patches, but there are a few that
have been changed enough to warrant another look before I push them.
Changes from [v1]:
* rebase on top of master;
* generate -device argument as JSON.
[v1] https://listman.redhat.com/archives/libvir-list/2021-October/223977.html
Andrea Bolognani (17):
tests: Add capabilities for QEMU 7.0.0 on aarch64
conf: Introduce VIR_PCI_CONNECT_INTEGRATED
qemu: Tweak some code
qemu: Introduce QEMU_CAPS_DEVICE_VIRTIO_IOMMU_PCI
qemu: Introduce QEMU_CAPS_VIRTIO_IOMMU_BOOT_BYPASS
conf: Introduce virtio model for <iommu>
tests: Add test cases for virtio-iommu
qemu: Validate machine type used with virtio-iommu
qemu: Validate capabilities for virtio-iommu
qemu: Validate use of ACPI with virtio-iommu
conf: Add virDomainDeviceInfo to virDomainIOMMUDef
qemu: Assign PCI address to virtio-iommu
qemu: Validate address type for virtio-iommu
tests: Add test for virtio-iommu address
qemu: Generate command line for virtio-iommu
docs: Document virtio-iommu
news: Document virtio-iommu
NEWS.rst | 4 +
docs/formatdomain.rst | 5 +-
docs/schemas/domaincommon.rng | 64 +-
src/conf/domain_addr.c | 17 +
src/conf/domain_addr.h | 26 +-
src/conf/domain_conf.c | 38 +-
src/conf/domain_conf.h | 2 +
src/qemu/qemu_capabilities.c | 10 +
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 30 +-
src/qemu/qemu_domain_address.c | 33 +-
src/qemu/qemu_validate.c | 32 +
.../qemu_7.0.0-virt.aarch64.xml | 193 +
tests/domaincapsdata/qemu_7.0.0.aarch64.xml | 187 +
.../caps_5.0.0.aarch64.replies | 71 +-
.../caps_5.0.0.aarch64.xml | 1 +
.../caps_5.0.0.ppc64.replies | 59 +-
.../qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 +
.../caps_5.0.0.riscv64.replies | 55 +-
.../caps_5.0.0.riscv64.xml | 1 +
.../caps_5.0.0.x86_64.replies | 71 +-
.../caps_5.0.0.x86_64.xml | 1 +
.../caps_5.1.0.x86_64.replies | 71 +-
.../caps_5.1.0.x86_64.xml | 1 +
.../caps_5.2.0.aarch64.replies | 71 +-
.../caps_5.2.0.aarch64.xml | 1 +
.../caps_5.2.0.ppc64.replies | 59 +-
.../qemucapabilitiesdata/caps_5.2.0.ppc64.xml | 1 +
.../caps_5.2.0.riscv64.replies | 55 +-
.../caps_5.2.0.riscv64.xml | 1 +
.../caps_5.2.0.s390x.replies | 59 +-
.../qemucapabilitiesdata/caps_5.2.0.s390x.xml | 1 +
.../caps_5.2.0.x86_64.replies | 71 +-
.../caps_5.2.0.x86_64.xml | 1 +
.../caps_6.0.0.aarch64.replies | 71 +-
.../caps_6.0.0.aarch64.xml | 1 +
.../caps_6.0.0.s390x.replies | 59 +-
.../qemucapabilitiesdata/caps_6.0.0.s390x.xml | 1 +
.../caps_6.0.0.x86_64.replies | 71 +-
.../caps_6.0.0.x86_64.xml | 1 +
.../caps_6.1.0.x86_64.replies | 71 +-
.../caps_6.1.0.x86_64.xml | 1 +
.../caps_6.2.0.aarch64.replies | 71 +-
.../caps_6.2.0.aarch64.xml | 1 +
.../caps_6.2.0.ppc64.replies | 59 +-
.../qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 +
.../caps_6.2.0.x86_64.replies | 71 +-
.../caps_6.2.0.x86_64.xml | 1 +
...h64.replies => caps_7.0.0.aarch64.replies} | 8112 ++++++++++++-----
...2.0.aarch64.xml => caps_7.0.0.aarch64.xml} | 34 +-
.../caps_7.0.0.ppc64.replies | 59 +-
.../qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 +
.../caps_7.0.0.x86_64.replies | 275 +-
.../caps_7.0.0.x86_64.xml | 2 +
...fault-cpu-kvm-virt-4.2.aarch64-latest.args | 6 +-
...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 6 +-
.../aarch64-tpm.aarch64-latest.args | 2 +-
.../aarch64-virt-graphics.aarch64-latest.args | 36 +-
.../aarch64-virt-headless.aarch64-latest.args | 28 +-
...ult-video-type-aarch64.aarch64-latest.args | 6 +-
.../disk-arm-virtio-sd.aarch64-latest.args | 2 +-
...e-expander-bus-aarch64.aarch64-latest.args | 2 +-
... virtio-iommu-aarch64.aarch64-latest.args} | 17 +-
.../qemuxml2argvdata/virtio-iommu-aarch64.xml | 20 +
...mmu-invalid-address-type.x86_64-latest.err | 1 +
.../virtio-iommu-invalid-address-type.xml | 20 +
...io-iommu-invalid-address.x86_64-latest.err | 1 +
.../virtio-iommu-invalid-address.xml | 20 +
.../virtio-iommu-no-acpi.x86_64-latest.err | 1 +
.../qemuxml2argvdata/virtio-iommu-no-acpi.xml | 15 +
...rtio-iommu-wrong-machine.x86_64-latest.err | 1 +
.../virtio-iommu-wrong-machine.xml | 18 +
.../virtio-iommu-x86_64.x86_64-6.1.0.err | 1 +
.../virtio-iommu-x86_64.x86_64-latest.args | 32 +
.../qemuxml2argvdata/virtio-iommu-x86_64.xml | 18 +
tests/qemuxml2argvtest.c | 7 +
.../virtio-iommu-aarch64.aarch64-latest.xml | 34 +
.../virtio-iommu-x86_64.x86_64-latest.xml | 36 +
tests/qemuxml2xmltest.c | 2 +
79 files changed, 7862 insertions(+), 2728 deletions(-)
create mode 100644 tests/domaincapsdata/qemu_7.0.0-virt.aarch64.xml
create mode 100644 tests/domaincapsdata/qemu_7.0.0.aarch64.xml
copy tests/qemucapabilitiesdata/{caps_6.2.0.aarch64.replies => caps_7.0.0.aarch64.replies} (87%)
copy tests/qemucapabilitiesdata/{caps_6.2.0.aarch64.xml => caps_7.0.0.aarch64.xml} (96%)
copy tests/qemuxml2argvdata/{aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args => virtio-iommu-aarch64.aarch64-latest.args} (55%)
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-aarch64.xml
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-invalid-address-type.x86_64-latest.err
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-invalid-address-type.xml
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-invalid-address.x86_64-latest.err
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-invalid-address.xml
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-no-acpi.x86_64-latest.err
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-no-acpi.xml
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-wrong-machine.x86_64-latest.err
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-wrong-machine.xml
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-6.1.0.err
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-x86_64.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/virtio-iommu-x86_64.xml
create mode 100644 tests/qemuxml2xmloutdata/virtio-iommu-aarch64.aarch64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/virtio-iommu-x86_64.x86_64-latest.xml
--
2.35.1
2 years, 8 months