Add a new flag, --disable-deprecated-features, to the domcapabilities
command. This will modify the output to show the 'host-model' CPU
with features flagged as deprecated paired with the 'disable' policy.
virsh domcapabilities --disable-deprecated-features
Signed-off-by: Collin Walling <walling@linux.ibm.com>
---
docs/manpages/virsh.rst | 6 ++++++
include/libvirt/libvirt-domain.h | 12 ++++++++++++
src/libvirt-domain.c | 2 +-
src/qemu/qemu_capabilities.c | 20 ++++++++++++++++++++
src/qemu/qemu_capabilities.h | 3 +++
src/qemu/qemu_driver.c | 8 +++++++-
tools/virsh-host.c | 9 ++++++++-
7 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 6776ea53d0..2700434dc4 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -568,6 +568,7 @@ domcapabilities
domcapabilities [virttype] [emulatorbin] [arch] [machine]
[--xpath EXPRESSION] [--wrap]
+ [--disabled-deprecated-features]
Print an XML document describing the domain capabilities for the
@@ -609,6 +610,11 @@ a standalone document, however, for ease of additional processing,
the **--wrap** argument will cause the matching node to be wrapped
in a common root node.
+The **--disabled-deprecated-features** argument will modify the contents
+of host-model CPU XML, updating the features list with any features
+flagged as deprecated for the CPU model by the hypervisor. These
+features will be paired with the "disable" policy.
+
pool-capabilities
-----------------
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 9232ce2e6b..47e06fe68e 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1478,6 +1478,18 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain,
int virDomainMigrateStartPostCopy(virDomainPtr domain,
unsigned int flags);
+/**
+ * virConnectGetDomainCapabilitiesFlags:
+ *
+ * Domain capabilities flags.
+ *
+ * Since: 10.10.0
+ */
+typedef enum {
+ /* Report host model with deprecated features disabled. (Since: 10.10.0) */
+ VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES = (1 << 0),
+} virConnectGetDomainCapabilitiesFlags;
+
char * virConnectGetDomainCapabilities(virConnectPtr conn,
const char *emulatorbin,
const char *arch,
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 7c6b93963c..e8e5379672 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12166,7 +12166,7 @@ virDomainSetUserPassword(virDomainPtr dom,
* @arch: domain architecture
* @machine: machine type
* @virttype: virtualization type
- * @flags: extra flags; not used yet, so callers should always pass 0
+ * @flags: extra flags; bitwise-OR of virConnectGetDomainCapabilitiesFlags
*
* Prior creating a domain (for instance via virDomainCreateXML
* or virDomainDefineXML) it may be suitable to know what the
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 8a10816757..8f2c0c8f93 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3324,6 +3324,26 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps,
}
+void
+virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps,
+ virDomainVirtType virtType,
+ virCPUDef *cpu)
+{
+ qemuMonitorCPUModelInfo *modelInfo;
+ size_t i;
+
+ modelInfo = virQEMUCapsGetCPUModelInfo(qemuCaps, virtType);
+
+ if (!modelInfo || !modelInfo->deprecated_props)
+ return;
+
+ for (i = 0; i < g_strv_length(modelInfo->deprecated_props); i++) {
+ virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i],
+ VIR_CPU_FEATURE_DISABLE);
+ }
+}
+
+
struct tpmTypeToCaps {
int type;
virQEMUCapsFlags caps;
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 3acb903478..735db2b9af 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -763,6 +763,9 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps,
virDomainVirtType virtType,
bool migratable,
char ***features);
+void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps,
+ virDomainVirtType virtType,
+ virCPUDef *cpu);
virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 72a9542c0b..57e553cef3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16524,7 +16524,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
virDomainVirtType virttype;
g_autoptr(virDomainCaps) domCaps = NULL;
- virCheckFlags(0, NULL);
+ virCheckFlags(VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES,
+ NULL);
if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0)
return NULL;
@@ -16543,6 +16544,11 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
arch, virttype)))
return NULL;
+ if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES) {
+ virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype,
+ domCaps->cpu.hostModel);
+ }
+
return virDomainCapsFormat(domCaps);
}
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 2fe64e415f..f4e7324f42 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -114,6 +114,10 @@ static const vshCmdOptDef opts_domcapabilities[] = {
.type = VSH_OT_BOOL,
.help = N_("wrap xpath results in an common root element"),
},
+ {.name = "disable-deprecated-features",
+ .type = VSH_OT_BOOL,
+ .help = N_("report host CPU model with deprecated features disabled"),
+ },
{.name = NULL}
};
@@ -126,10 +130,13 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd)
const char *arch = NULL;
const char *machine = NULL;
const char *xpath = NULL;
- const unsigned int flags = 0; /* No flags so far */
+ unsigned int flags = 0;
bool wrap = vshCommandOptBool(cmd, "wrap");
virshControl *priv = ctl->privData;
+ if (vshCommandOptBool(cmd, "disable-deprecated-features"))
+ flags |= VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES;
+
if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 ||
vshCommandOptString(ctl, cmd, "emulatorbin", &emulatorbin) < 0 ||
vshCommandOptString(ctl, cmd, "arch", &arch) < 0 ||
--
2.45.1
© 2016 - 2024 Red Hat, Inc.