@@ -3411,6 +3411,38 @@ out:
}
}
+static void scsi_disk_get_alua_pref(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ SCSIDiskState *s = OBJECT_CHECK(SCSIDiskState, obj, "scsi-disk");
+ bool pref = !!(s->alua_state & 0x80);
+
+ visit_type_bool(v, &pref, name, errp);
+}
+
+static void scsi_disk_set_alua_pref(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ SCSIDiskState *s = OBJECT_CHECK(SCSIDiskState, obj, "scsi-disk");
+ bool pref;
+ Error *local_err = NULL;
+
+ visit_type_bool(v, &pref, name, &local_err);
+ if (local_err) {
+ goto out;
+ }
+
+ if (pref) {
+ s->alua_state |= 0x80;
+ } else {
+ s->alua_state &= ~0x80;
+ }
+out:
+ if (local_err) {
+ error_propagate(errp, local_err);
+ }
+}
+
static void scsi_disk_instance_initfn(Object *obj)
{
object_property_add(obj, "alua_state", "uint8",
@@ -3421,6 +3453,11 @@ static void scsi_disk_instance_initfn(Object *obj)
scsi_disk_get_alua_policy,
scsi_disk_set_alua_policy, NULL, NULL, NULL);
object_property_set_str(obj, "", "alua_policy", NULL);
+
+ object_property_add(obj, "alua_preferred", "bool",
+ scsi_disk_get_alua_pref,
+ scsi_disk_set_alua_pref, NULL, NULL, NULL);
+ object_property_set_bool(obj, false, "alua_preferred", NULL);
}
static const TypeInfo scsi_disk_info = {
Implement an option to set the 'preferred path' bit in the REPORT TARGET PORT GROUPS output. Signed-off-by: Hannes Reinecke <hare@suse.de> --- hw/scsi/scsi-disk.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)