diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/ide/core.c | 4 | ||||
-rw-r--r-- | hw/pc.c | 6 | ||||
-rw-r--r-- | hw/scsi-disk.c | 5 | ||||
-rw-r--r-- | hw/virtio-9p-debug.c | 2 | ||||
-rw-r--r-- | hw/virtio-blk.c | 10 | ||||
-rw-r--r-- | hw/virtio-pci.c | 5 | ||||
-rw-r--r-- | hw/virtio-serial-bus.c | 4 |
7 files changed, 31 insertions, 5 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c index af52c2cb2d..e20f2e7cbb 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2630,6 +2630,10 @@ int ide_init_drive(IDEState *s, BlockDriverState *bs, s->drive_kind = IDE_CD; bdrv_set_change_cb(bs, cdrom_change_cb, s); } else { + if (!bdrv_is_inserted(s->bs)) { + error_report("Device needs media, but drive is empty"); + return -1; + } if (bdrv_is_read_only(bs)) { error_report("Can't use a read-only drive"); return -1; @@ -916,8 +916,10 @@ void pc_memory_init(ram_addr_t ram_size, below_4g_mem_size - 0x100000, ram_addr + 0x100000); #if TARGET_PHYS_ADDR_BITS > 32 - cpu_register_physical_memory(0x100000000ULL, above_4g_mem_size, - ram_addr + below_4g_mem_size); + if (above_4g_mem_size > 0) { + cpu_register_physical_memory(0x100000000ULL, above_4g_mem_size, + ram_addr + below_4g_mem_size); + } #endif /* BIOS load */ diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index c30709c550..f43f2d097c 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1059,6 +1059,11 @@ static int scsi_disk_initfn(SCSIDevice *dev) s->bs = s->qdev.conf.bs; is_cd = bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM; + if (!is_cd && !bdrv_is_inserted(s->bs)) { + error_report("Device needs media, but drive is empty"); + return -1; + } + if (bdrv_get_on_error(s->bs, 1) != BLOCK_ERR_REPORT) { error_report("Device doesn't support drive option rerror"); return -1; diff --git a/hw/virtio-9p-debug.c b/hw/virtio-9p-debug.c index e4ab4bca5f..c1b0e6f066 100644 --- a/hw/virtio-9p-debug.c +++ b/hw/virtio-9p-debug.c @@ -327,6 +327,8 @@ void pprint_pdu(V9fsPDU *pdu) llogfile = fopen("/tmp/pdu.log", "w"); } + BUG_ON(!llogfile); + switch (pdu->id) { case P9_TVERSION: fprintf(llogfile, "TVERSION: ("); diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 8747634fbe..f50069d20b 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -12,6 +12,7 @@ */ #include <qemu-common.h> +#include "qemu-error.h" #include "virtio-blk.h" #ifdef __linux__ # include <scsi/sg.h> @@ -490,6 +491,15 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) static int virtio_blk_id; DriveInfo *dinfo; + if (!conf->bs) { + error_report("virtio-blk-pci: drive property not set"); + return NULL; + } + if (!bdrv_is_inserted(conf->bs)) { + error_report("Device needs media, but drive is empty"); + return NULL; + } + s = (VirtIOBlock *)virtio_common_init("virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config), sizeof(VirtIOBlock)); diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index c728fffd73..31a711ef41 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -546,11 +546,10 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev) proxy->class_code != PCI_CLASS_STORAGE_OTHER) proxy->class_code = PCI_CLASS_STORAGE_SCSI; - if (!proxy->block.bs) { - error_report("virtio-blk-pci: drive property not set"); + vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block); + if (!vdev) { return -1; } - vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block); vdev->nvectors = proxy->nvectors; virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 26d5841154..8e611c03e0 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -117,6 +117,7 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq, VirtQueueElement elem; assert(port || discard); + assert(virtio_queue_ready(vq)); while ((discard || !port->throttled) && virtqueue_pop(vq, &elem)) { uint8_t *buf; @@ -139,6 +140,9 @@ static void flush_queued_data(VirtIOSerialPort *port, bool discard) { assert(port); + if (!virtio_queue_ready(port->ovq)) { + return; + } do_flush_queued_data(port, port->ovq, &port->vser->vdev, discard); } |