diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/block.c | 16 | ||||
-rw-r--r-- | hw/ide/qdev.c | 2 | ||||
-rw-r--r-- | hw/scsi/scsi-disk.c | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/hw/block/block.c b/hw/block/block.c index 0666dd337c..a625773d44 100644 --- a/hw/block/block.c +++ b/hw/block/block.c @@ -19,7 +19,9 @@ void blkconf_serial(BlockConf *conf, char **serial) if (!*serial) { /* try to fall back to value set with legacy -drive serial=... */ dinfo = blk_legacy_dinfo(conf->blk); - *serial = g_strdup(dinfo->serial); + if (dinfo) { + *serial = g_strdup(dinfo->serial); + } } } @@ -32,11 +34,13 @@ void blkconf_geometry(BlockConf *conf, int *ptrans, if (!conf->cyls && !conf->heads && !conf->secs) { /* try to fall back to value set with legacy -drive cyls=... */ dinfo = blk_legacy_dinfo(conf->blk); - conf->cyls = dinfo->cyls; - conf->heads = dinfo->heads; - conf->secs = dinfo->secs; - if (ptrans) { - *ptrans = dinfo->trans; + if (dinfo) { + conf->cyls = dinfo->cyls; + conf->heads = dinfo->heads; + conf->secs = dinfo->secs; + if (ptrans) { + *ptrans = dinfo->trans; + } } } if (!conf->cyls && !conf->heads && !conf->secs) { diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 600e67c232..b4f096e12e 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -252,7 +252,7 @@ static int ide_drive_initfn(IDEDevice *dev) { DriveInfo *dinfo = blk_legacy_dinfo(dev->conf.blk); - return ide_dev_initfn(dev, dinfo->media_cd ? IDE_CD : IDE_HD); + return ide_dev_initfn(dev, dinfo && dinfo->media_cd ? IDE_CD : IDE_HD); } #define DEFINE_IDE_DEV_PROPERTIES() \ diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 300ba01045..010eefd443 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2310,7 +2310,7 @@ static void scsi_disk_realize(SCSIDevice *dev, Error **errp) } dinfo = blk_legacy_dinfo(dev->conf.blk); - if (dinfo->media_cd) { + if (dinfo && dinfo->media_cd) { scsi_cd_realize(dev, errp); } else { scsi_hd_realize(dev, errp); |