[PATCH] qemuxmlconftest: Add test cases for broken and missing XML files
by Peter Krempa
Add test cases for few edge cases which excercise the XML reporting from
libxml2 in anticipation of upcoming changes of behaviour.
'virschematest' must skip parsing of the broken file altogether so this
patch adds infrastructure to allow that.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
This patch is meant as an addendum to my review of:
[PATCH] util: open XML files before calling libxml2
.../broken-xml-invalid.x86_64-latest.err | 3 +++
tests/qemuxmlconfdata/broken-xml-invalid.xml | 1 +
.../nonexistent-file.x86_64-latest.err | 1 +
tests/qemuxmlconftest.c | 8 +++++++-
tests/testutilsqemu.h | 1 +
tests/virschematest.c | 11 +++++++++++
6 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err
create mode 100644 tests/qemuxmlconfdata/broken-xml-invalid.xml
create mode 100644 tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err
diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err
new file mode 100644
index 0000000000..601f547cc6
--- /dev/null
+++ b/tests/qemuxmlconfdata/broken-xml-invalid.x86_64-latest.err
@@ -0,0 +1,3 @@
+/home/pipo/libvirt/tests/qemuxmlconfdata/broken-xml-invalid.xml:2: Couldn't find end of Start Tag dom line 1
+(null)
+^
diff --git a/tests/qemuxmlconfdata/broken-xml-invalid.xml b/tests/qemuxmlconfdata/broken-xml-invalid.xml
new file mode 100644
index 0000000000..9903e61ead
--- /dev/null
+++ b/tests/qemuxmlconfdata/broken-xml-invalid.xml
@@ -0,0 +1 @@
+<dom
diff --git a/tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err b/tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err
new file mode 100644
index 0000000000..59e92917f9
--- /dev/null
+++ b/tests/qemuxmlconfdata/nonexistent-file.x86_64-latest.err
@@ -0,0 +1 @@
+XML error: failed to parse xml document '/home/pipo/libvirt/tests/qemuxmlconfdata/nonexistent-file.xml'
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 8aa8efea13..9e6d40fe33 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -372,6 +372,7 @@ testCheckExclusiveFlags(int flags)
FLAG_REAL_CAPS |
FLAG_SLIRP_HELPER |
FLAG_ALLOW_DUPLICATE_OUTPUT |
+ FLAG_ALLOW_MISSING_INPUT |
0, -1);
return 0;
@@ -671,7 +672,8 @@ testQemuConfXMLCommon(testQemuInfo *info,
if (qemuTestCapsCacheInsert(driver.qemuCapsCache, info->qemuCaps) < 0)
goto cleanup;
- if (!virFileExists(info->infile)) {
+ if (!(info->flags & FLAG_ALLOW_MISSING_INPUT) &&
+ !virFileExists(info->infile)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"Input file '%s' not found", info->infile);
goto cleanup;
@@ -1233,6 +1235,10 @@ mymain(void)
g_unsetenv("PIPEWIRE_REMOTE");
g_unsetenv("PIPEWIRE_RUNTIME_DIR");
+ DO_TEST_CAPS_ARCH_LATEST_FULL("nonexistent-file", "x86_64",
+ ARG_FLAGS, FLAG_EXPECT_PARSE_ERROR | FLAG_ALLOW_MISSING_INPUT);
+ DO_TEST_CAPS_LATEST_PARSE_ERROR("broken-xml-invalid");
+
DO_TEST_CAPS_LATEST("x86_64-pc-minimal");
DO_TEST_CAPS_LATEST_ABI_UPDATE("x86_64-pc-minimal");
DO_TEST_CAPS_LATEST("x86_64-q35-minimal");
diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h
index a5806f244b..90632031ff 100644
--- a/tests/testutilsqemu.h
+++ b/tests/testutilsqemu.h
@@ -61,6 +61,7 @@ typedef enum {
FLAG_REAL_CAPS = 1 << 2,
FLAG_SLIRP_HELPER = 1 << 3,
FLAG_ALLOW_DUPLICATE_OUTPUT = 1 << 4, /* allow multiple tests with the same output file */
+ FLAG_ALLOW_MISSING_INPUT = 1 << 5,
} testQemuInfoFlags;
struct testQemuConf {
diff --git a/tests/virschematest.c b/tests/virschematest.c
index 9b6649a6cf..b4113619e2 100644
--- a/tests/virschematest.c
+++ b/tests/virschematest.c
@@ -36,6 +36,7 @@ struct testSchemaEntry {
const char **exceptions; /* optional NULL terminated list of filenames inside
directory where the expected validation result is
inverted */
+ const char **skip; /* list of files to skip altogether */
const char *dirRegex;
const char *file;
};
@@ -131,6 +132,10 @@ testSchemaDir(const char *schema,
!g_regex_match(filter, ent->d_name, 0, NULL))
continue;
+ if (entry->skip &&
+ g_strv_contains(entry->skip, ent->d_name))
+ continue;
+
if (entry->exceptions)
exception = g_strv_contains(entry->exceptions, ent->d_name);
@@ -237,10 +242,16 @@ static const char *exceptions_qemuxmlconfdata[] = {
NULL
};
+/* skip tests with completely broken XML */
+static const char *skip_qemuxmlconfdata[] = {
+ "broken-xml-invalid.xml"
+};
+
static const struct testSchemaEntry schemaDomain[] = {
{ .dir = "tests/domainschemadata" },
{ .dir = "tests/qemuxmlconfdata",
.exceptions = exceptions_qemuxmlconfdata,
+ .skip = skip_qemuxmlconfdata,
},
{ .dir = "tests/xmconfigdata" },
{ .dir = "tests/lxcxml2xmldata" },
--
2.45.2
8 months, 1 week
[PATCH 0/3] Intel-IOMMU: Add dma-translation switch
by Sandesh Patel
Since Qemu commit 8646d9c (Support IR-only mode without DMA translation) version 7.1.0,
Qemu support dma-translation attribute for Intel IOMMU. This patch adds a new attribute
dma_translation to configure this.
Sandesh Patel (3):
Conf: add dma_translation attribute to iommu
qemu: format dma-translation on intel-iommu command line
tests: add test for intel-iommu dma-translation attribute
docs/formatdomain.rst | 7 ++++
src/conf/domain_conf.c | 15 ++++++++
src/conf/domain_conf.h | 1 +
src/conf/schemas/domaincommon.rng | 5 +++
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 1 +
src/qemu/qemu_validate.c | 6 +++
.../caps_7.1.0_x86_64.xml | 1 +
.../caps_7.2.0_x86_64+hvf.xml | 1 +
.../caps_7.2.0_x86_64.xml | 1 +
.../caps_8.0.0_x86_64.xml | 1 +
.../caps_8.1.0_x86_64.xml | 1 +
.../caps_8.2.0_x86_64.xml | 1 +
.../caps_9.0.0_x86_64.xml | 1 +
.../caps_9.1.0_x86_64.xml | 1 +
.../migration-out-nbd-bitmaps-in.xml | 1 +
...l-iommu-dma-translation.x86_64-latest.args | 34 +++++++++++++++++
...el-iommu-dma-translation.x86_64-latest.xml | 1 +
.../intel-iommu-dma-translation.xml | 37 +++++++++++++++++++
tests/qemuxmlconftest.c | 1 +
21 files changed, 120 insertions(+)
create mode 100644 tests/qemuxmlconfdata/intel-iommu-dma-translation.x86_64-latest.args
create mode 120000 tests/qemuxmlconfdata/intel-iommu-dma-translation.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/intel-iommu-dma-translation.xml
--
2.22.3
8 months, 1 week
[PATCH 0/3] tests: qemu: Update test cases and bump 9.1 caps dump
by Peter Krempa
Peter Krempa (3):
qemuxmlconftest: Add test for old-style NUMA memory specification
qemuxmlconftest: Don't use soon-to-be-removed machine types
qemucapabilitiesdata: Update data for qemu-9.1 dev cycle on x86_64
.../caps_9.1.0_x86_64.replies | 3796 +++++++++--------
.../caps_9.1.0_x86_64.xml | 162 +-
.../controller-usb-order.x86_64-latest.args | 2 +-
.../controller-usb-order.x86_64-latest.xml | 2 +-
.../qemuxmlconfdata/controller-usb-order.xml | 2 +-
...pu-numa-memory-oldstyle.x86_64-latest.args | 34 +
...cpu-numa-memory-oldstyle.x86_64-latest.xml | 36 +
.../cpu-numa-memory-oldstyle.xml | 27 +
...rbd-encryption-layering.x86_64-latest.args | 2 +-
...-rbd-encryption-layering.x86_64-latest.xml | 2 +-
.../disk-network-rbd-encryption-layering.xml | 2 +-
...rbd-encryption-luks-any.x86_64-latest.args | 2 +-
...-rbd-encryption-luks-any.x86_64-latest.xml | 2 +-
.../disk-network-rbd-encryption-luks-any.xml | 2 +-
...-network-rbd-encryption.x86_64-latest.args | 2 +-
...k-network-rbd-encryption.x86_64-latest.xml | 2 +-
.../disk-network-rbd-encryption.xml | 2 +-
tests/qemuxmlconfdata/luks-disk-invalid.xml | 2 +-
.../luks-disks-source.x86_64-latest.args | 2 +-
.../luks-disks-source.x86_64-latest.xml | 2 +-
tests/qemuxmlconfdata/luks-disks-source.xml | 2 +-
.../luks-disks.x86_64-latest.args | 2 +-
tests/qemuxmlconfdata/luks-disks.xml | 2 +-
...memory-default-hugepage.x86_64-latest.args | 2 +-
.../memfd-memory-default-hugepage.xml | 2 +-
.../memfd-memory-numa.x86_64-latest.args | 2 +-
tests/qemuxmlconfdata/memfd-memory-numa.xml | 2 +-
...vcpus-topology-mismatch.x86_64-latest.args | 8 +-
...avcpus-topology-mismatch.x86_64-latest.xml | 2 +-
.../numavcpus-topology-mismatch.xml | 2 +-
tests/qemuxmlconftest.c | 1 +
31 files changed, 2241 insertions(+), 1871 deletions(-)
create mode 100644 tests/qemuxmlconfdata/cpu-numa-memory-oldstyle.x86_64-latest.args
create mode 100644 tests/qemuxmlconfdata/cpu-numa-memory-oldstyle.x86_64-latest.xml
create mode 100644 tests/qemuxmlconfdata/cpu-numa-memory-oldstyle.xml
--
2.45.2
8 months, 1 week
[PATCH 2/2] qemu: Introduce the ability to disable the built-in PS/2 controller
by Kamil Szczęk
A while back QEMU introduced a new machine option for disabling the
i8042 PS/2 controller (commit 4ccd5fe22feb95137d325f422016a6473)
which up until then was a built-in device included by all PC machine
type descendants unconditionally. This new option allowed users to
disable emulation of this controller, thus removing the default PS/2
peripherals. The rationale for why somebody might want to disable
PS/2 peripherals is explained in the aforementioned commit.
This introduces a new 'ps2' feature which, when disabled, results in
no implicit PS/2 bus input devices being automatically added to the
domain and addition of the 'i8042=off' machine option to the QEMU
command-line.
A notable side effect of disabling the i8042 controller in QEMU is that
the vmport device won't be created. For this reason we will not allow
setting the vmport feature if the ps2 feature is explicitly disabled.
Signed-off-by: Kamil Szczęk <kamil(a)szczek.dev>
---
docs/formatdomain.rst | 5 +++++
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 1 +
src/conf/domain_validate.c | 23 +++++++++++++++++++++++
src/conf/schemas/domaincommon.rng | 5 +++++
src/qemu/qemu_capabilities.c | 21 +++++++++++++++++++++
src/qemu/qemu_capabilities.h | 4 ++++
src/qemu/qemu_command.c | 5 +++++
src/qemu/qemu_domain.c | 3 ++-
src/qemu/qemu_validate.c | 23 +++++++++++++++++++++++
10 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index c56b739b23..3300a57393 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -2262,6 +2262,11 @@ are:
exceptions when enabled (``on``). If the attribute is not defined, the
hypervisor default will be used.
:since:`Since 10.4.0` (QEMU/KVM and ARM virt guests only)
+``ps2``
+ Depending on the ``state`` attribute (values ``on``, ``off``) enable or
+ disable the emulation of a PS/2 controller used by ``ps2`` bus input devices.
+ If the attribute is not defined, the hypervisor default will be used.
+ :since:`Since 10.7.0` (QEMU only)
Time keeping
------------
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 86b563fbfb..19d14eb13d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -185,6 +185,7 @@ VIR_ENUM_IMPL(virDomainFeature,
"tcg",
"async-teardown",
"ras",
+ "ps2",
);
VIR_ENUM_IMPL(virDomainCapabilitiesPolicy,
@@ -17015,7 +17016,8 @@ virDomainFeaturesDefParse(virDomainDef *def,
case VIR_DOMAIN_FEATURE_HTM:
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
- case VIR_DOMAIN_FEATURE_RAS: {
+ case VIR_DOMAIN_FEATURE_RAS:
+ case VIR_DOMAIN_FEATURE_PS2: {
virTristateSwitch state;
if (virXMLPropTristateSwitch(nodes[i], "state",
@@ -20879,6 +20881,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
case VIR_DOMAIN_FEATURE_RAS:
+ case VIR_DOMAIN_FEATURE_PS2:
if (src->features[i] != dst->features[i]) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of feature '%1$s' differs: source: '%2$s', destination: '%3$s'"),
@@ -27670,6 +27673,7 @@ virDomainDefFormatFeatures(virBuffer *buf,
case VIR_DOMAIN_FEATURE_NESTED_HV:
case VIR_DOMAIN_FEATURE_CCF_ASSIST:
case VIR_DOMAIN_FEATURE_RAS:
+ case VIR_DOMAIN_FEATURE_PS2:
switch ((virTristateSwitch) def->features[i]) {
case VIR_TRISTATE_SWITCH_LAST:
case VIR_TRISTATE_SWITCH_ABSENT:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95ddf5470e..5b9ed67232 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2181,6 +2181,7 @@ typedef enum {
VIR_DOMAIN_FEATURE_TCG,
VIR_DOMAIN_FEATURE_ASYNC_TEARDOWN,
VIR_DOMAIN_FEATURE_RAS,
+ VIR_DOMAIN_FEATURE_PS2,
VIR_DOMAIN_FEATURE_LAST
} virDomainFeature;
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 39b8d67928..56f1092841 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -2744,6 +2744,29 @@ virDomainInputDefValidate(const virDomainInputDef *input,
return -1;
}
+ switch ((virDomainInputBus) input->bus) {
+ case VIR_DOMAIN_INPUT_BUS_PS2:
+ if (def->features[VIR_DOMAIN_FEATURE_PS2] == VIR_TRISTATE_SWITCH_OFF) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ps2 bus inputs require the ps2 feature not to be disabled"));
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_INPUT_BUS_DEFAULT:
+ case VIR_DOMAIN_INPUT_BUS_USB:
+ case VIR_DOMAIN_INPUT_BUS_XEN:
+ case VIR_DOMAIN_INPUT_BUS_PARALLELS:
+ case VIR_DOMAIN_INPUT_BUS_VIRTIO:
+ case VIR_DOMAIN_INPUT_BUS_NONE:
+ break;
+
+ case VIR_DOMAIN_INPUT_BUS_LAST:
+ default:
+ virReportEnumRangeError(virDomainInputBus, input->bus);
+ return -1;
+ }
+
return 0;
}
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 7d58dce465..9b6dddae81 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -6912,6 +6912,11 @@
<ref name="featurestate"/>
</element>
</optional>
+ <optional>
+ <element name="ps2">
+ <ref name="featurestate"/>
+ </element>
+ </optional>
</interleave>
</element>
</optional>
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 19a057d94d..4c135b2558 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -713,6 +713,7 @@ VIR_ENUM_IMPL(virQEMUCaps,
"sev-snp-guest", /* QEMU_CAPS_SEV_SNP_GUEST */
"netdev.user", /* QEMU_CAPS_NETDEV_USER */
"acpi-erst", /* QEMU_CAPS_DEVICE_ACPI_ERST */
+ "machine-i8042-opt", /* QEMU_CAPS_MACHINE_I8042_OPT */
);
@@ -1748,6 +1749,10 @@ static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsVirt[] = {
{ "ras", QEMU_CAPS_MACHINE_VIRT_RAS },
};
+static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsPC[] = {
+ { "i8042", QEMU_CAPS_MACHINE_I8042_OPT },
+};
+
static struct virQEMUCapsStringFlags virQEMUCapsMachinePropsGeneric[] = {
{ "confidential-guest-support", QEMU_CAPS_MACHINE_CONFIDENTAL_GUEST_SUPPORT },
};
@@ -1759,6 +1764,9 @@ static virQEMUCapsObjectTypeProps virQEMUCapsMachineProps[] = {
{ "virt", virQEMUCapsMachinePropsVirt,
G_N_ELEMENTS(virQEMUCapsMachinePropsVirt),
-1 },
+ { "pc", virQEMUCapsMachinePropsPC,
+ G_N_ELEMENTS(virQEMUCapsMachinePropsPC),
+ -1 },
{ "none", virQEMUCapsMachinePropsGeneric,
G_N_ELEMENTS(virQEMUCapsMachinePropsGeneric),
-1 },
@@ -6026,6 +6034,19 @@ virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps,
STREQ(def->os.machine, "isapc");
}
+bool
+virQEMUCapsSupportsI8042Toggle(virQEMUCaps *qemuCaps,
+ const virDomainDef *def)
+{
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_I8042_OPT))
+ return false;
+
+ return qemuDomainIsI440FX(def) ||
+ qemuDomainIsQ35(def) ||
+ qemuDomainIsXenFV(def) ||
+ STREQ(def->os.machine, "isapc");
+}
+
/*
* The preferred machine to use if none is listed explicitly
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index d77a4bf4d9..d21cbfbce4 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -692,6 +692,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
QEMU_CAPS_SEV_SNP_GUEST, /* -object sev-snp-guest */
QEMU_CAPS_NETDEV_USER, /* -netdev user */
QEMU_CAPS_DEVICE_ACPI_ERST, /* -device acpi-erst */
+ QEMU_CAPS_MACHINE_I8042_OPT, /* -machine xxx,i8042=on/off */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
@@ -720,6 +721,9 @@ bool virQEMUCapsSupportsVmport(virQEMUCaps *qemuCaps,
bool virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps,
const virDomainDef *def);
+bool virQEMUCapsSupportsI8042Toggle(virQEMUCaps *qemuCaps,
+ const virDomainDef *def);
+
const char *virQEMUCapsGetBinary(virQEMUCaps *qemuCaps);
virArch virQEMUCapsGetArch(virQEMUCaps *qemuCaps);
unsigned int virQEMUCapsGetVersion(virQEMUCaps *qemuCaps);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f15e6bda1e..53fbf49e20 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6887,6 +6887,11 @@ qemuAppendDomainFeaturesMachineParam(virBuffer *buf,
virBufferAsprintf(buf, ",ras=%s", str);
}
+ if (def->features[VIR_DOMAIN_FEATURE_PS2] != VIR_TRISTATE_SWITCH_ABSENT) {
+ const char *str = virTristateSwitchTypeToString(def->features[VIR_DOMAIN_FEATURE_PS2]);
+ virBufferAsprintf(buf, ",i8042=%s", str);
+ }
+
return 0;
}
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 56f09699db..66b0caac24 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3926,7 +3926,8 @@ static int
qemuDomainDefAddImplicitInputDevice(virDomainDef *def,
virQEMUCaps *qemuCaps)
{
- if (virQEMUCapsSupportsI8042(qemuCaps, def)) {
+ if (virQEMUCapsSupportsI8042(qemuCaps, def) &&
+ def->features[VIR_DOMAIN_FEATURE_PS2] != VIR_TRISTATE_SWITCH_OFF) {
if (virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_BUS_PS2) < 0)
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 7730344c52..2007d040fe 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -143,6 +143,13 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
_("vmport is not available with this QEMU binary"));
return -1;
}
+
+ if (def->features[i] == VIR_TRISTATE_SWITCH_ON &&
+ def->features[VIR_DOMAIN_FEATURE_PS2] == VIR_TRISTATE_SWITCH_OFF) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("vmport feature requires the ps2 feature not to be disabled"));
+ return -1;
+ }
break;
case VIR_DOMAIN_FEATURE_VMCOREINFO:
@@ -242,6 +249,22 @@ qemuValidateDomainDefFeatures(const virDomainDef *def,
}
break;
+ case VIR_DOMAIN_FEATURE_PS2:
+ if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
+ !virQEMUCapsSupportsI8042(qemuCaps, def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ps2 feature is not available with this QEMU binary"));
+ return -1;
+ }
+
+ if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
+ !virQEMUCapsSupportsI8042Toggle(qemuCaps, def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("ps2 feature state cannot be controlled with this QEMU binary"));
+ return -1;
+ }
+ break;
+
case VIR_DOMAIN_FEATURE_SMM:
case VIR_DOMAIN_FEATURE_KVM:
case VIR_DOMAIN_FEATURE_XEN:
--
2.45.0
8 months, 1 week
[PATCH 1/2] qemu: Improve PS/2 controller detection
by Kamil Szczęk
Up until now, we've assumed that all x86 machines have a PS/2
controller built-in. This assumption was correct until QEMU v4.2
introduced a new x86-based machine type - microvm.
Due to this assumption, a pair of unnecessary PS/2 inputs are implicitly
added to all microvm domains. This patch fixes that by whitelisting
machine types which are known to include the i8042 PS/2 controller.
Signed-off-by: Kamil Szczęk <kamil(a)szczek.dev>
---
src/qemu/qemu_capabilities.c | 20 ++++++++++++++++++++
src/qemu/qemu_capabilities.h | 3 +++
src/qemu/qemu_domain.c | 28 +++++++++++++++++++++++++---
src/qemu/qemu_domain.h | 1 +
src/qemu/qemu_validate.c | 3 +--
5 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 29dfe8d35a..19a057d94d 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1359,6 +1359,13 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
{ "vhost-user-vga", QEMU_CAPS_DEVICE_VHOST_USER_VGA },
{ "ramfb", QEMU_CAPS_DEVICE_RAMFB },
{ "max-arm-cpu", QEMU_CAPS_ARM_MAX_CPU },
+ /*
+ * The i8042 controller is a built-in device and is not user-creatable.
+ * However, since not all machine types include this controller, you should
+ * avoid checking for this capability directly.
+ *
+ * Prefer using virQEMUCapsSupportsI8042() instead.
+ */
{ "i8042", QEMU_CAPS_DEVICE_I8042 },
{ "rng-builtin", QEMU_CAPS_OBJECT_RNG_BUILTIN },
{ "tpm-spapr", QEMU_CAPS_DEVICE_TPM_SPAPR },
@@ -6006,6 +6013,19 @@ virQEMUCapsSupportsVmport(virQEMUCaps *qemuCaps,
STREQ(def->os.machine, "isapc");
}
+bool
+virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps,
+ const virDomainDef *def)
+{
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_I8042))
+ return false;
+
+ return qemuDomainIsI440FX(def) ||
+ qemuDomainIsQ35(def) ||
+ qemuDomainIsXenFV(def) ||
+ STREQ(def->os.machine, "isapc");
+}
+
/*
* The preferred machine to use if none is listed explicitly
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 51d951771d..d77a4bf4d9 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -717,6 +717,9 @@ void virQEMUCapsInitProcessCapsInterlock(virQEMUCaps *qemuCaps);
bool virQEMUCapsSupportsVmport(virQEMUCaps *qemuCaps,
const virDomainDef *def);
+bool virQEMUCapsSupportsI8042(virQEMUCaps *qemuCaps,
+ const virDomainDef *def);
+
const char *virQEMUCapsGetBinary(virQEMUCaps *qemuCaps);
virArch virQEMUCapsGetArch(virQEMUCaps *qemuCaps);
unsigned int virQEMUCapsGetVersion(virQEMUCaps *qemuCaps);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 198ab99aef..56f09699db 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3923,9 +3923,10 @@ virXMLNamespace virQEMUDriverDomainXMLNamespace = {
static int
-qemuDomainDefAddImplicitInputDevice(virDomainDef *def)
+qemuDomainDefAddImplicitInputDevice(virDomainDef *def,
+ virQEMUCaps *qemuCaps)
{
- if (ARCH_IS_X86(def->os.arch)) {
+ if (virQEMUCapsSupportsI8042(qemuCaps, def)) {
if (virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_BUS_PS2) < 0)
@@ -4164,7 +4165,7 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
bool addITCOWatchdog = false;
/* add implicit input devices */
- if (qemuDomainDefAddImplicitInputDevice(def) < 0)
+ if (qemuDomainDefAddImplicitInputDevice(def, qemuCaps) < 0)
return -1;
/* Add implicit PCI root controller if the machine has one */
@@ -9126,6 +9127,21 @@ qemuDomainMachineIsMipsMalta(const char *machine,
return false;
}
+static bool
+qemuDomainMachineIsXenFV(const char *machine,
+ const virArch arch)
+{
+ if (!ARCH_IS_X86(arch))
+ return false;
+
+ if (STREQ(machine, "xenfv") ||
+ STRPREFIX(machine, "xenfv-")) {
+ return true;
+ }
+
+ return false;
+}
+
/* You should normally avoid this function and use
* qemuDomainHasBuiltinIDE() instead. */
@@ -9212,6 +9228,12 @@ qemuDomainIsLoongArchVirt(const virDomainDef *def)
return qemuDomainMachineIsLoongArchVirt(def->os.machine, def->os.arch);
}
+bool
+qemuDomainIsXenFV(const virDomainDef *def)
+{
+ return qemuDomainMachineIsXenFV(def->os.machine, def->os.arch);
+}
+
bool
qemuDomainHasPCIRoot(const virDomainDef *def)
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index a5092dd7f0..ff45fb63ca 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -834,6 +834,7 @@ bool qemuDomainIsLoongArchVirt(const virDomainDef *def);
bool qemuDomainIsRISCVVirt(const virDomainDef *def);
bool qemuDomainIsPSeries(const virDomainDef *def);
bool qemuDomainIsMipsMalta(const virDomainDef *def);
+bool qemuDomainIsXenFV(const virDomainDef *def);
bool qemuDomainHasPCIRoot(const virDomainDef *def);
bool qemuDomainHasPCIeRoot(const virDomainDef *def);
bool qemuDomainHasBuiltinIDE(const virDomainDef *def);
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 0e8f0f977f..7730344c52 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4868,8 +4868,7 @@ qemuValidateDomainDeviceDefInput(const virDomainInputDef *input,
int cap;
int ccwCap;
- if (input->bus == VIR_DOMAIN_INPUT_BUS_PS2 && !ARCH_IS_X86(def->os.arch) &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_I8042)) {
+ if (input->bus == VIR_DOMAIN_INPUT_BUS_PS2 && !virQEMUCapsSupportsI8042(qemuCaps, def)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("%1$s is not supported by this QEMU binary"),
virDomainInputBusTypeToString(input->bus));
--
2.45.0
8 months, 1 week
[PATCH 0/2] qemu: Avoid false failure when resuming post-copy migration
by Jiri Denemark
See 2/2 for details.
Jiri Denemark (2):
qemu: Add support for postcopy-recover-setup migration state
qemu: Avoid false failure when resuming post-copy migration
src/conf/virdomainjob.c | 1 +
src/conf/virdomainjob.h | 1 +
src/qemu/qemu_domain.h | 4 ++++
src/qemu/qemu_driver.c | 1 +
src/qemu/qemu_migration.c | 32 +++++++++++++++++++++++++++++++-
src/qemu/qemu_monitor.c | 1 +
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 1 +
src/qemu/qemu_process.c | 4 ++++
9 files changed, 45 insertions(+), 1 deletion(-)
--
2.45.2
8 months, 1 week
Fwd:?==?utf-8?q? Re: [PATCH 1/3] Makefile: `make check` now computes env variable on the fly
by Ariel Otilibili-Anieli
Hi Jano,
Here is the PR: https://gitlab.com/libvirt/libvirt-python/-/merge_requests/151
Thank you,
Ariel
-------- Original Message --------
Subject: Re: [PATCH 1/3] Makefile: `make check` now computes env variable on the fly
Date: Tuesday, August 06, 2024 13:59 CEST
From: "Ariel Otilibili-Anieli" <Ariel.Otilibili-Anieli(a)eurecom.fr>
To: Ján Tomko <jtomko(a)redhat.com>
CC: devel(a)lists.libvirt.org
References: <20240805175423.773603-1-otilibil(a)eurecom.fr> <20240805175423.773603-2-otilibil(a)eurecom.fr>
Hi Jano,
On Tuesday, August 06, 2024 13:00 CEST, Ján Tomko <jtomko(a)redhat.com> wrote:
For repos other than the main 'libvirt' repo, we use merge requests on
GitLab.
I'll address all your feedback in a PR, later in the day. I used patches because the guidelines advise that (https://libvirt.org/hacking.html)
On a Monday in 2024, Ariel Otilibili wrote:
>* env variable used to be Python3.6
>* Python3.6 is end of life since December 2021 [1].
>
>[1] https://devguide.python.org/versions/
>
>Signed-off-by: Ariel Otilibili <otilibil(a)eurecom.fr>
>---
> Makefile | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
>diff --git a/Makefile b/Makefile
>index b08e2bd..1cab66c 100644
>--- a/Makefile
>+++ b/Makefile
>@@ -1,6 +1,7 @@
> # Shim wrapper around setup.py to allow for familiar build targets
>
> PYTHON ?= python
>+VERSION := $(shell $(PYTHON) -V | perl -nE 'print "$$1$$2" if /\s(\d+)\.(\d+)/')
>
Please, no Makefile-escaped perl. Python should be able to do it too:
python -c 'import sys; print("{}{}".format(sys.version_info.major, sys.version_info.minor))'
Will change it; I forgot I came across this guideline, https://libvirt.org/programming-languages.html
> all:
> $(PYTHON) -m build
>@@ -12,7 +13,7 @@ clean:
> rm -rf build/ dist/
>
> check: all
>- tox -e py36
>+ tox -e py$(VERSION)
If I understand correctly, the point of tox is to run the test suite
against different Python versions.
Having 'py36' hardcoded here made sure it worked against that particular
version even if the user has a different version, but I do not
understand the benefit of running it against the current version (as
opposed to just running pytest directly).
My point was to update the version used in this rule; therefore I supposed, if one version were to be used, the latest of the user would make sense. For all the versions used by tox, this patch addresses particularly that: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/V...
Ariel
Jano
>
> test: all
> tox
>--
>2.45.2
>
8 months, 1 week
[PATCH] vsh: Allow vshReadlineInit() to be called multiple times
by Michal Privoznik
Thing about vshReadlineInit() is - it's called multiple times.
The first time from vshInit(), when @ctl was filled only
partially (most notably, before any argv parsing is done, hence
ctl->imode is set to false). The second time after argv parsing,
from virshInit() -> vshInitReload(). In here, ctl->imode might
have changed and thus vshReadlineInit() can't exit early - it
needs to set up stuff for interactive mode (history basically).
To allow vshReadlineInit() to be called again,
vshReadlineDeinit() must set @autoCompleteOpaque to NULL.
Fixes: cab1e71f0161fd24c5d6ff4c379d3a242ea8c2d9
Resolves: https://issues.redhat.com/browse/RHEL-53560
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/vsh.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/vsh.c b/tools/vsh.c
index 9fbb1f9349..5f5e2f281d 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -3040,6 +3040,9 @@ vshReadlineDeinit(vshControl *ctl)
g_clear_pointer(&ctl->historydir, g_free);
g_clear_pointer(&ctl->historyfile, g_free);
+
+ /* Allow vshReadlineInit() to be called again. */
+ autoCompleteOpaque = NULL;
}
char *
--
2.44.2
8 months, 1 week
[PATCH] network: fix crashing "modify" option for hostname
by Adam Julis
The original condition caused (after adding modify option)
possibly access to not allocated memory. For consistency added
new check for multiple same records.
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/654
Signed-off-by: Adam Julis <ajulis(a)redhat.com>
---
src/conf/network_conf.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c23b0e4400..5cf419acf1 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -3167,7 +3167,7 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def,
/* when adding we want to only check duplicates of address since having
* multiple addresses with the same hostname is a legitimate configuration */
- if (!isAdd) {
+ if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
for (j = 0; j < host.nnames && !foundThisTime; j++) {
for (k = 0; k < dns->hosts[i].nnames && !foundThisTime; k++) {
if (STREQ(host.names[j], dns->hosts[i].names[k]))
@@ -3224,6 +3224,13 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def,
goto cleanup;
}
+ if (foundCt > 1) {
+ virReportError(VIR_ERR_OPERATION_INVALID,
+ _("multiple matching DNS HOST records were found in network %1$s"),
+ def->name);
+ goto cleanup;
+ }
+
virNetworkDNSHostDefClear(&dns->hosts[foundIdxModify]);
memcpy(&dns->hosts[foundIdxModify], &host, sizeof(virNetworkDNSHostDef));
--
2.45.2
8 months, 1 week