--- nono/vm/scsidev.cpp 2026/04/29 17:05:14 1.1.1.15 +++ nono/vm/scsidev.cpp 2026/04/29 17:05:18 1.1.1.16 @@ -28,8 +28,8 @@ // // コンストラクタ -SCSIDevice::SCSIDevice(const std::string& objname_) - : inherited(objname_) +SCSIDevice::SCSIDevice(int objid_) + : inherited(objid_) { } @@ -44,8 +44,8 @@ SCSIDevice::~SCSIDevice() // // コンストラクタ -SCSIHostDevice::SCSIHostDevice(const std::string& objname_) - : inherited(objname_) +SCSIHostDevice::SCSIHostDevice(int objid_) + : inherited(objid_) { devtype = SCSI::DevType::Initiator; @@ -112,7 +112,7 @@ SCSIHostDevice::Create() } else if (type == "mo") { target_devtype = SCSI::DevType::MO; } else { - item.Err("invaild device type '%s'", type.c_str()); + item.Err("Invaild device type '%s'", type.c_str()); return false; } target[id].reset(new SCSIDisk(this, id, target_devtype)); @@ -127,6 +127,10 @@ SCSIHostDevice::Create() bool SCSIHostDevice::Init() { + if (inherited::Init() == false) { + return false; + } + // 初期化ではないけどログレベルがセットできたここでデバッグ表示。 // -L オプションの処理は Create() の後なので。 if (loglevel >= 1) { @@ -257,9 +261,9 @@ SCSIHostDevice::MonitorUpdateDevs(Monito // SCSI ターゲットデバイスの共通部分 // -// コンストラクタ -SCSITarget::SCSITarget(const std::string& objname_, SCSIHostDevice *h, int id) - : inherited(objname_) +// コンストラクタ。 +SCSITarget::SCSITarget(SCSIHostDevice *h, int id) + : inherited(OBJ_NONE) // オブジェクト ID で検索することはない { // ホストへのリンク (所有関係のないポインタ) host = h; @@ -602,7 +606,7 @@ SCSITarget::SelectCommand(const std::vec // コンストラクタ SCSIDisk::SCSIDisk(SCSIHostDevice *h, int id, SCSI::DevType devtype_) - : inherited("", h, id) + : inherited(h, id) { devtype = devtype_; @@ -614,6 +618,7 @@ SCSIDisk::SCSIDisk(SCSIHostDevice *h, in // lib/object.h 参照。 SetName(string_format("SCSI%s%d", devtypename, id)); ClearAlias(); + AddAlias(string_format("SCSI%s%d", devtypename, id)); AddAlias(string_format("SCSI%d", id)); AddAlias(string_format("%s%d", devtypename, id)); @@ -634,7 +639,7 @@ SCSIDisk::SCSIDisk(SCSIHostDevice *h, in blocksize = 512; break; default: - __unreachable(); + PANIC("corrupted devtype=%d", (int)devtype); } } @@ -648,6 +653,10 @@ SCSIDisk::~SCSIDisk() bool SCSIDisk::Init() { + if (inherited::Init() == false) { + return false; + } + const std::string keybody = string_format("%s-id%d-", host->GetConfigName(), myid); const std::string imgkey = keybody + "image"; @@ -673,9 +682,9 @@ SCSIDisk::Init() // リムーバブルデバイスのみ UI からの通知を受け取るイベントを用意 if (IsRemovableDevice()) { - gScheduler->ConnectMessage(MessageID::SCSIDEV_LOAD(myid), this, + scheduler->ConnectMessage(MessageID::SCSIDEV_LOAD(myid), this, ToMessageCallback(&SCSIDisk::LoadCallback)); - gScheduler->ConnectMessage(MessageID::SCSIDEV_UNLOAD(myid), this, + scheduler->ConnectMessage(MessageID::SCSIDEV_UNLOAD(myid), this, ToMessageCallback(&SCSIDisk::UnloadCallback)); } @@ -826,7 +835,7 @@ SCSIDisk::LoadDisk(const std::string& pa } break; default: - __unreachable(); + PANIC("corrupted devtype=%d", (int)devtype); } // 書き込みモードをここで確定 @@ -935,7 +944,7 @@ void SCSIDisk::LoadDiskUI(const std::string& pathname_) { new_pathname = pathname_; - gScheduler->SendMessage(MessageID::SCSIDEV_LOAD(GetMyID())); + scheduler->SendMessage(MessageID::SCSIDEV_LOAD(GetMyID())); } // メディアを排出する。 @@ -943,7 +952,7 @@ SCSIDisk::LoadDiskUI(const std::string& void SCSIDisk::UnloadDiskUI(bool force) { - gScheduler->SendMessage(MessageID::SCSIDEV_UNLOAD(GetMyID()), force); + scheduler->SendMessage(MessageID::SCSIDEV_UNLOAD(GetMyID()), force); } // メディア挿入メッセージコールバック @@ -1184,6 +1193,6 @@ SCSIDisk::GetWriteModeStr() const case RW::Writeable: return "Writeable"; case RW::WriteIgnore: return "WriteIgnore"; default: - __unreachable(); + PANIC("corrupted write_mode=%d", (int)write_mode); } }