Skip to content

Commit 1fd396e

Browse files
Pierre Morelhuth
Pierre Morel
authored andcommitted
s390x: Register TYPE_S390_CCW_MACHINE properties as class properties
Currently, when running 'qemu-system-s390x -M s390-ccw-virtio,help' the s390x-specific properties are not listed anymore. This happens because since commit d8fb7d0 ("vl: switch -M parsing to keyval") the properties have to be defined at the class level and not at the instance level anymore. Fix it on s390x now, too, by moving the registration of the properties to the class level" Fixes: d8fb7d0 ("vl: switch -M parsing to keyval") Signed-off-by: Pierre Morel <[email protected]> Message-Id: <[email protected]> [thuth: Add patch description] Signed-off-by: Thomas Huth <[email protected]>
1 parent 4a8d21b commit 1fd396e

File tree

1 file changed

+72
-55
lines changed

1 file changed

+72
-55
lines changed

hw/s390x/s390-virtio-ccw.c

Lines changed: 72 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "sysemu/sysemu.h"
4444
#include "hw/s390x/pv.h"
4545
#include "migration/blocker.h"
46+
#include "qapi/visitor.h"
4647

4748
static Error *pv_mig_blocker;
4849

@@ -589,38 +590,6 @@ static ram_addr_t s390_fixup_ram_size(ram_addr_t sz)
589590
return newsz;
590591
}
591592

592-
static void ccw_machine_class_init(ObjectClass *oc, void *data)
593-
{
594-
MachineClass *mc = MACHINE_CLASS(oc);
595-
NMIClass *nc = NMI_CLASS(oc);
596-
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
597-
S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
598-
599-
s390mc->ri_allowed = true;
600-
s390mc->cpu_model_allowed = true;
601-
s390mc->css_migration_enabled = true;
602-
s390mc->hpage_1m_allowed = true;
603-
mc->init = ccw_init;
604-
mc->reset = s390_machine_reset;
605-
mc->block_default_type = IF_VIRTIO;
606-
mc->no_cdrom = 1;
607-
mc->no_floppy = 1;
608-
mc->no_parallel = 1;
609-
mc->no_sdcard = 1;
610-
mc->max_cpus = S390_MAX_CPUS;
611-
mc->has_hotpluggable_cpus = true;
612-
assert(!mc->get_hotplug_handler);
613-
mc->get_hotplug_handler = s390_get_hotplug_handler;
614-
mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
615-
mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
616-
/* it is overridden with 'host' cpu *in kvm_arch_init* */
617-
mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
618-
hc->plug = s390_machine_device_plug;
619-
hc->unplug_request = s390_machine_device_unplug_request;
620-
nc->nmi_monitor_handler = s390_nmi;
621-
mc->default_ram_id = "s390.ram";
622-
}
623-
624593
static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
625594
{
626595
S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
@@ -710,19 +679,29 @@ bool hpage_1m_allowed(void)
710679
return get_machine_class()->hpage_1m_allowed;
711680
}
712681

713-
static char *machine_get_loadparm(Object *obj, Error **errp)
682+
static void machine_get_loadparm(Object *obj, Visitor *v,
683+
const char *name, void *opaque,
684+
Error **errp)
714685
{
715686
S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
687+
char *str = g_strndup((char *) ms->loadparm, sizeof(ms->loadparm));
716688

717-
/* make a NUL-terminated string */
718-
return g_strndup((char *) ms->loadparm, sizeof(ms->loadparm));
689+
visit_type_str(v, name, &str, errp);
690+
g_free(str);
719691
}
720692

721-
static void machine_set_loadparm(Object *obj, const char *val, Error **errp)
693+
static void machine_set_loadparm(Object *obj, Visitor *v,
694+
const char *name, void *opaque,
695+
Error **errp)
722696
{
723697
S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
698+
char *val;
724699
int i;
725700

701+
if (!visit_type_str(v, name, &val, errp)) {
702+
return;
703+
}
704+
726705
for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) {
727706
uint8_t c = qemu_toupper(val[i]); /* mimic HMC */
728707

@@ -740,34 +719,72 @@ static void machine_set_loadparm(Object *obj, const char *val, Error **errp)
740719
ms->loadparm[i] = ' '; /* pad right with spaces */
741720
}
742721
}
743-
static inline void s390_machine_initfn(Object *obj)
722+
723+
static void ccw_machine_class_init(ObjectClass *oc, void *data)
744724
{
745-
object_property_add_bool(obj, "aes-key-wrap",
746-
machine_get_aes_key_wrap,
747-
machine_set_aes_key_wrap);
748-
object_property_set_description(obj, "aes-key-wrap",
725+
MachineClass *mc = MACHINE_CLASS(oc);
726+
NMIClass *nc = NMI_CLASS(oc);
727+
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
728+
S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
729+
730+
s390mc->ri_allowed = true;
731+
s390mc->cpu_model_allowed = true;
732+
s390mc->css_migration_enabled = true;
733+
s390mc->hpage_1m_allowed = true;
734+
mc->init = ccw_init;
735+
mc->reset = s390_machine_reset;
736+
mc->block_default_type = IF_VIRTIO;
737+
mc->no_cdrom = 1;
738+
mc->no_floppy = 1;
739+
mc->no_parallel = 1;
740+
mc->no_sdcard = 1;
741+
mc->max_cpus = S390_MAX_CPUS;
742+
mc->has_hotpluggable_cpus = true;
743+
assert(!mc->get_hotplug_handler);
744+
mc->get_hotplug_handler = s390_get_hotplug_handler;
745+
mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
746+
mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
747+
/* it is overridden with 'host' cpu *in kvm_arch_init* */
748+
mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
749+
hc->plug = s390_machine_device_plug;
750+
hc->unplug_request = s390_machine_device_unplug_request;
751+
nc->nmi_monitor_handler = s390_nmi;
752+
mc->default_ram_id = "s390.ram";
753+
754+
object_class_property_add_bool(oc, "aes-key-wrap",
755+
machine_get_aes_key_wrap,
756+
machine_set_aes_key_wrap);
757+
object_class_property_set_description(oc, "aes-key-wrap",
749758
"enable/disable AES key wrapping using the CPACF wrapping key");
750-
object_property_set_bool(obj, "aes-key-wrap", true, NULL);
751759

752-
object_property_add_bool(obj, "dea-key-wrap",
753-
machine_get_dea_key_wrap,
754-
machine_set_dea_key_wrap);
755-
object_property_set_description(obj, "dea-key-wrap",
760+
object_class_property_add_bool(oc, "dea-key-wrap",
761+
machine_get_dea_key_wrap,
762+
machine_set_dea_key_wrap);
763+
object_class_property_set_description(oc, "dea-key-wrap",
756764
"enable/disable DEA key wrapping using the CPACF wrapping key");
757-
object_property_set_bool(obj, "dea-key-wrap", true, NULL);
758-
object_property_add_str(obj, "loadparm",
759-
machine_get_loadparm, machine_set_loadparm);
760-
object_property_set_description(obj, "loadparm",
765+
766+
object_class_property_add(oc, "loadparm", "loadparm",
767+
machine_get_loadparm, machine_set_loadparm,
768+
NULL, NULL);
769+
object_class_property_set_description(oc, "loadparm",
761770
"Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
762771
" to upper case) to pass to machine loader, boot manager,"
763772
" and guest kernel");
764773

765-
object_property_add_bool(obj, "zpcii-disable",
766-
machine_get_zpcii_disable,
767-
machine_set_zpcii_disable);
768-
object_property_set_description(obj, "zpcii-disable",
774+
object_class_property_add_bool(oc, "zpcii-disable",
775+
machine_get_zpcii_disable,
776+
machine_set_zpcii_disable);
777+
object_class_property_set_description(oc, "zpcii-disable",
769778
"disable zPCI interpretation facilties");
770-
object_property_set_bool(obj, "zpcii-disable", false, NULL);
779+
}
780+
781+
static inline void s390_machine_initfn(Object *obj)
782+
{
783+
S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
784+
785+
ms->aes_key_wrap = true;
786+
ms->dea_key_wrap = true;
787+
ms->zpcii_disable = false;
771788
}
772789

773790
static const TypeInfo ccw_machine_info = {

0 commit comments

Comments
 (0)