Skip to content

fix: block model shows 'UnKnow'#155

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/1071from
itsXuSt:1071
Jul 4, 2025
Merged

fix: block model shows 'UnKnow'#155
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/1071from
itsXuSt:1071

Conversation

@itsXuSt

@itsXuSt itsXuSt commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

cannot obtain model info from either smartctl nor lshw commands, try
with udevadm command to obtain ID_MODEL field.

Log: fix block model missing.

Bug: https://pms.uniontech.com/bug-view-322579.html

Summary by Sourcery

Use udevadm to retrieve block device model as a fallback when smartctl and lshw fail, and emit a warning if still unavailable.

Bug Fixes:

  • Add udevadm-based fallback to fetch the ID_MODEL field for block devices when other methods fail.

Enhancements:

  • Log a warning if the device model cannot be determined after all attempts.

@sourcery-ai

sourcery-ai Bot commented Jul 4, 2025

Copy link
Copy Markdown

Reviewer's Guide

Introduced a new fallback step to retrieve the disk model via udevadm when smartctl and lshw both fail, parsing the ID_MODEL field and early-returning on success, and logging a warning before falling back to the existing “UnKnow” default.

Sequence diagram for updated disk model retrieval process

sequenceDiagram
    participant DeviceStorage
    participant smartctl
    participant lshw
    participant udevadm

    DeviceStorage->>smartctl: Try to get model info
    alt smartctl returns model
        DeviceStorage-->>DeviceStorage: Use model from smartctl
    else smartctl fails
        DeviceStorage->>lshw: Try to get model info
        alt lshw returns model
            DeviceStorage-->>DeviceStorage: Use model from lshw
        else lshw fails
            DeviceStorage->>udevadm: Try to get ID_MODEL
            alt udevadm returns ID_MODEL
                DeviceStorage-->>DeviceStorage: Use model from udevadm
            else udevadm fails
                DeviceStorage-->>DeviceStorage: Set model to "UnKnow"
            end
        end
    end
Loading

File-Level Changes

Change Details Files
Add udevadm-based fallback logic for disk model detection
  • Construct and execute a bash udevadm info command piping to grep ID_MODEL
  • Read and split the output on ‘=’ to extract the model value
  • Assign model and return early if a non-empty result is obtained
service/diskoperation/DeviceStorage.cpp
Log a warning when no model is found via any method
  • Insert qWarning with device path when all detection attempts fail
service/diskoperation/DeviceStorage.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

cannot obtain model info from either smartctl nor lshw commands, try
with udevadm command to obtain ID_MODEL field.

Log: fix block model missing.

Bug: https://pms.uniontech.com/bug-view-322579.html
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

关键摘要:

  • 在新添加的代码中,没有对 proc.startproc.waitForFinished 的错误进行处理,可能会导致程序在命令执行失败时崩溃。
  • qWarning 的输出信息中使用了硬编码的字符串 "tried a lot but got nothing about model for",建议使用可配置的字符串或国际化支持。
  • 新增代码中直接使用了 qWarning,但没有相应的错误处理机制,可能需要添加错误日志记录或异常处理。
  • model 变量在函数开始时就被声明,但在新添加的代码块中又重新赋值,建议优化变量声明和使用。

是否建议立即修改:

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: itsXuSt, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@itsXuSt

itsXuSt commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

/merge

@deepin-bot deepin-bot Bot merged commit 8f1185f into linuxdeepin:release/1071 Jul 4, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants