This is for avoid call target_info() in class_init. Now we directly guard in scsi_property_set_loadparm instead. Don't know if its an API break, but the smallest change.
Signed-off-by: Yonggang Luo <[email protected]> --- hw/scsi/scsi-disk.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index deb33ac1dda..276941ae537 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -3179,6 +3179,11 @@ static void scsi_property_set_loadparm(Object *obj, const char *value, { void *lp_str; + if (!target_s390x()) { + error_setg(errp, "'loadparm' is only supported on s390x"); + return; + } + if (object_property_get_int(obj, "bootindex", NULL) < 0) { error_setg(errp, "'loadparm' is only valid for boot devices"); return; @@ -3196,14 +3201,11 @@ static void scsi_property_add_specifics(DeviceClass *dc) { ObjectClass *oc = OBJECT_CLASS(dc); - /* The loadparm property is only supported on s390x */ - if (target_s390x()) { - object_class_property_add_str(oc, "loadparm", - scsi_property_get_loadparm, - scsi_property_set_loadparm); - object_class_property_set_description(oc, "loadparm", - "load parameter (s390x only)"); - } + object_class_property_add_str(oc, "loadparm", + scsi_property_get_loadparm, + scsi_property_set_loadparm); + object_class_property_set_description(oc, "loadparm", + "load parameter (s390x only)"); } static void scsi_disk_base_class_initfn(ObjectClass *klass, const void *data) -- 2.55.0.windows.3
