+bool drive_check_orphaned(void)
+{
+ BlockBackend *blk;
+ DriveInfo *dinfo;
+ bool rs = false;
+
+ for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
+ dinfo = blk_legacy_dinfo(blk);
+ /* If dinfo->bdrv->dev is NULL, it has no device attached. */
+ /* Unless this is a default drive, this may be an oversight. */
+ if (!blk_get_attached_dev(blk) && !dinfo->is_default &&
+ dinfo->type != IF_NONE) {
+ fprintf(stderr, "Warning: Orphaned drive without device: "
+ "id=%s,file=%s,if=%s,bus=%d,unit=%d\n",
+ blk_name(blk), blk_bs(blk)->filename, if_name[dinfo->type],
+ dinfo->bus, dinfo->unit);
+ rs = true;
+ }
+ }
+
+ return rs;
+}
+