[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties reque
From: |
Michael Mueller |
Subject: |
[Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties requests |
Date: |
Wed, 2 Oct 2013 13:33:37 +0200 |
This patch implements the functions s390_fetch_kvm_host_props() and
s390_request_kvm_cpu_config(). They respectively retrieve or request
the machine type, cpu facilities and KVM facility mask supported by
the host. Both functions are based on the s390 configuration device
interface.
Signed-off-by: Michael Mueller <address@hidden>
---
target-s390x/cpu-models.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 16 ++++++++++++
2 files changed, 81 insertions(+)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index 4a4720a..4ce1546 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -234,6 +234,71 @@ static int set_s390_cpu_alias(const char *name, const char
*model)
return 0;
}
+/* return host specific properties */
+int s390_fetch_kvm_host_props(struct S390HostProps *prop)
+{
+ int ret;
+
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE,
+ &prop->vcpu.type);
+ if (ret) {
+ return ret;
+ }
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES,
+ &prop->vcpu.facilities);
+ if (ret) {
+ return ret;
+ }
+
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_KVM_FACILITY_MASK,
+ &prop->host.facility_mask);
+ if (ret) {
+ return ret;
+ }
+
+ return 0;
+}
+
+/* request cpu configuration defined in S390 cpu class */
+int s390_request_kvm_cpu_config(S390CPUClass *cc)
+{
+ int ret = 0;
+
+ {
+ struct kvm_s390_attr_cpu_type cpu;
+ ret = set_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, &cc->type);
+ if (ret) {
+ goto out;
+ }
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, &cpu.type);
+ if (ret) {
+ goto out;
+ }
+ if (cc->type != cpu.type) {
+ goto out;
+ }
+ }
+ {
+ struct kvm_s390_attr_cpu_facilities cpu;
+ int i;
+ ret = set_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES,
cc->kvm_facilities);
+ if (ret) {
+ goto out;
+ }
+ ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES,
&cpu.facilities);
+ if (ret) {
+ goto out;
+ }
+ for (i = 0; i < sizeof(cpu.facilities) / sizeof(unsigned long); i++) {
+ if (cc->kvm_facilities[i] != cpu.facilities[i]) {
+ goto out;
+ }
+ }
+ }
+out:
+ return ret;
+}
+
/* define S390 CPU model classes */
S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1")
S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2")
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index e188eca..0789a5e 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -34,6 +34,22 @@ typedef struct S390CPUAlias {
} S390CPUAlias;
extern GSList *s390_cpu_aliases;
+/*
+ * host system properties used to trim s390
+ * cpu class attributes during initial kvm setup
+ */
+struct S390HostProps {
+ struct {
+ unsigned long facility_mask[256];
+ } host;
+ struct {
+ unsigned short type;
+ unsigned long facilities[256];
+ } vcpu;
+};
+
+int s390_fetch_kvm_host_props(struct S390HostProps *prop);
+int s390_request_kvm_cpu_config(S390CPUClass *cc);
ObjectClass *s390_cpu_class_by_name(const char *name);
/*
--
1.8.3.1
[Qemu-devel] [PATCH RFC 05/11] s390/qemu: cpu model alias support, Michael Mueller, 2013/10/02
[Qemu-devel] [PATCH RFC 02/11] s390/qemu: cpu model extend config device, Michael Mueller, 2013/10/02
[Qemu-devel] [PATCH RFC 11/11] s390/qemu: cpu model enablement, Michael Mueller, 2013/10/02