From nobody Thu Nov 6 03:26:12 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539420069741217.65891468338145; Sat, 13 Oct 2018 01:41:09 -0700 (PDT) Received: from localhost ([::1]:44193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBFTo-0000zE-Oe for importer@patchew.org; Sat, 13 Oct 2018 04:41:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47247) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBFSr-0000bb-Iy for qemu-devel@nongnu.org; Sat, 13 Oct 2018 04:40:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBFSn-0002UA-3J for qemu-devel@nongnu.org; Sat, 13 Oct 2018 04:40:01 -0400 Received: from m12-13.163.com ([220.181.12.13]:43155) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBFSm-0002TZ-6r for qemu-devel@nongnu.org; Sat, 13 Oct 2018 04:39:57 -0400 Received: from ubuntu.localdomain (unknown [115.192.95.72]) by smtp9 (Coremail) with SMTP id DcCowAA3pnJWr8Fb10pcMw--.40896S2; Sat, 13 Oct 2018 16:39:51 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=H3t7PiEypWCpshqm+r 8eULvFPPhYk5KrrYcq1jH1C5A=; b=Z8YFsETAWk0WjHDTyuAv4j/z5XJAOqnms8 rlz0aXrexTgf7/AYMkR9FzmYns0/qiIuIuXpLFGyHZAVriDgSB4hbTKLqjWqAB8g 5/o6bWfstrKRN3QRcnfWP7fgjfKwQ6bwDER4/jOBKa11K1BzjUshqcmP2gSCOaL+ z1cN/+Bfc= From: Li Qiang To: pbonzini@redhat.com, famz@redhat.com Date: Sat, 13 Oct 2018 01:39:49 -0700 Message-Id: <20181013083949.55346-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DcCowAA3pnJWr8Fb10pcMw--.40896S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxGFykAFyrGw18try3JrWUJwb_yoWrtry3pF Z8X3ZI9r4UGFW7GFZxJr95JF15WrsrK342gF97G34I9Fy5X3yDGw1ktayFvFWkWFyvyF98 ZF15XFyUZFZ7tw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UnJ5rUUUUU= X-Originating-IP: [115.192.95.72] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbitBfebVSIZGpqBwAAsv X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.12.13 Subject: [Qemu-devel] [PATCH] hw: scsi-disk: make it more QOMconventional X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Li Qiang --- hw/scsi/scsi-disk.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index c43163cef4..15582fa0e2 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -55,6 +55,10 @@ do { printf("scsi-disk: " fmt , ## __VA_ARGS__); } while= (0) #define DEFAULT_MAX_IO_SIZE INT_MAX /* 2 GB - 1 block */ =20 #define TYPE_SCSI_DISK_BASE "scsi-disk-base" +#define TYPE_SCSI_DISK "scsi-disk" +#define TYPE_SCSI_HD "scsi-hd" +#define TYPE_SCSI_BLOCK "scsi-block" +#define TYPE_SCSI_CD "scsi-cd" =20 #define SCSI_DISK_BASE(obj) \ OBJECT_CHECK(SCSIDiskState, (obj), TYPE_SCSI_DISK_BASE) @@ -2357,7 +2361,7 @@ static const BlockDevOps scsi_disk_block_ops =3D { =20 static void scsi_disk_unit_attention_reported(SCSIDevice *dev) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + SCSIDiskState *s =3D SCSI_DISK_BASE(dev); if (s->media_changed) { s->media_changed =3D false; scsi_device_set_ua(&s->qdev, SENSE_CODE(MEDIUM_CHANGED)); @@ -2366,7 +2370,7 @@ static void scsi_disk_unit_attention_reported(SCSIDev= ice *dev) =20 static void scsi_realize(SCSIDevice *dev, Error **errp) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + SCSIDiskState *s =3D SCSI_DISK_BASE(dev); =20 if (!s->qdev.conf.blk) { error_setg(errp, "drive property not set"); @@ -2429,7 +2433,7 @@ static void scsi_realize(SCSIDevice *dev, Error **err= p) =20 static void scsi_hd_realize(SCSIDevice *dev, Error **errp) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + SCSIDiskState *s =3D SCSI_DISK_BASE(dev); /* can happen for devices without drive. The error message for missing * backend will be issued in scsi_realize */ @@ -2446,7 +2450,7 @@ static void scsi_hd_realize(SCSIDevice *dev, Error **= errp) =20 static void scsi_cd_realize(SCSIDevice *dev, Error **errp) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + SCSIDiskState *s =3D SCSI_DISK_BASE(dev); int ret; =20 if (!dev->conf.blk) { @@ -2549,7 +2553,7 @@ static const SCSIReqOps *const scsi_disk_reqops_dispa= tch[256] =3D { static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t= lun, uint8_t *buf, void *hba_private) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, d); + SCSIDiskState *s =3D SCSI_DISK_BASE(d); SCSIRequest *req; const SCSIReqOps *ops; uint8_t command; @@ -2601,7 +2605,7 @@ static int get_device_type(SCSIDiskState *s) =20 static void scsi_block_realize(SCSIDevice *dev, Error **errp) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + SCSIDiskState *s =3D SCSI_DISK_BASE(dev); int sg_version; int rc; =20 @@ -2879,7 +2883,7 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice= *d, uint32_t tag, uint32_t lun, uint8_t *buf, void *hba_private) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, d); + SCSIDiskState *s =3D SCSI_DISK_BASE(d); =20 if (scsi_block_is_passthrough(s, buf)) { return scsi_req_alloc(&scsi_generic_req_ops, &s->qdev, tag, lun, @@ -2893,7 +2897,7 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice= *d, uint32_t tag, static int scsi_block_parse_cdb(SCSIDevice *d, SCSICommand *cmd, uint8_t *buf, void *hba_private) { - SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, d); + SCSIDiskState *s =3D SCSI_DISK_BASE(d); =20 if (scsi_block_is_passthrough(s, buf)) { return scsi_bus_parse_cdb(&s->qdev, cmd, buf, hba_private); @@ -3002,7 +3006,7 @@ static void scsi_hd_class_initfn(ObjectClass *klass, = void *data) } =20 static const TypeInfo scsi_hd_info =3D { - .name =3D "scsi-hd", + .name =3D TYPE_SCSI_HD, .parent =3D TYPE_SCSI_DISK_BASE, .class_init =3D scsi_hd_class_initfn, }; @@ -3033,7 +3037,7 @@ static void scsi_cd_class_initfn(ObjectClass *klass, = void *data) } =20 static const TypeInfo scsi_cd_info =3D { - .name =3D "scsi-cd", + .name =3D TYPE_SCSI_HD, .parent =3D TYPE_SCSI_DISK_BASE, .class_init =3D scsi_cd_class_initfn, }; @@ -3071,7 +3075,7 @@ static void scsi_block_class_initfn(ObjectClass *klas= s, void *data) } =20 static const TypeInfo scsi_block_info =3D { - .name =3D "scsi-block", + .name =3D TYPE_SCSI_BLOCK, .parent =3D TYPE_SCSI_DISK_BASE, .class_init =3D scsi_block_class_initfn, }; @@ -3111,7 +3115,7 @@ static void scsi_disk_class_initfn(ObjectClass *klass= , void *data) } =20 static const TypeInfo scsi_disk_info =3D { - .name =3D "scsi-disk", + .name =3D TYPE_SCSI_DISK, .parent =3D TYPE_SCSI_DISK_BASE, .class_init =3D scsi_disk_class_initfn, }; --=20 2.17.1