From 5fb58b067ab02afd6bb1737b04f8d3d8f23a0c8d Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 9 Jul 2010 20:30:07 +0200 Subject: [PATCH 1/5] qemu-img: Fix copy+paste bug in documentation Replace rebase by resize in documentation of resize command. Cc: Stefan Hajnoczi Cc: Kevin Wolf Signed-off-by: Stefan Weil Signed-off-by: Kevin Wolf --- qemu-img-cmds.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-img-cmds.hx b/qemu-img-cmds.hx index c4cf3e7542..6d3e5f8e69 100644 --- a/qemu-img-cmds.hx +++ b/qemu-img-cmds.hx @@ -54,6 +54,6 @@ ETEXI DEF("resize", img_resize, "resize filename [+ | -]size") STEXI -@item rebase @var{filename} [+ | -]@var{size} +@item resize @var{filename} [+ | -]@var{size} @end table ETEXI From 31f54f24bb4a507543c3732c3ac1134ca3a11687 Mon Sep 17 00:00:00 2001 From: Shahar Havivi Date: Sat, 10 Jul 2010 18:59:06 +0300 Subject: [PATCH 2/5] Block migration fail, ignore error from bdrv_getlength When there is no block driver associate with BlockDriverState bdrv_getlength returns -ENOMEDIUM that cause block migration to fail Signed-off-by: Shahar Havivi Signed-off-by: Kevin Wolf --- block-migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block-migration.c b/block-migration.c index 7db6f02b96..a77106e25c 100644 --- a/block-migration.c +++ b/block-migration.c @@ -238,7 +238,7 @@ static void init_blk_migration_it(void *opaque, BlockDriverState *bs) if (!bdrv_is_read_only(bs)) { sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; - if (sectors == 0) { + if (sectors <= 0) { return; } From ac0c14d71b68ac18f03a876028e332534e1e6a3e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 6 Jul 2010 14:37:42 +0200 Subject: [PATCH 3/5] virtio-pci: Check for virtio_blk_init() failure It can't actually fail now, but the next commit will change that. s390_virtio_blk_init() already checks for failure, but virtio_blk_init_pci() doesn't. Fix that. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/virtio-pci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index c728fffd73..55831665f6 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -551,6 +551,9 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev) return -1; } vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block); + if (!vdev) { + return -1; + } vdev->nvectors = proxy->nvectors; virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, From d75d25e34e4b4eb6a18122b5fa3baac70cea0f2b Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 6 Jul 2010 14:37:43 +0200 Subject: [PATCH 4/5] virtio-blk: Fix virtio-blk-s390 to require drive Move the check from virtio_blk_init_pci(), where it protects only virtio-blk-pci, to virtio_blk_init(). Without that, virtio-blk-s390 initializes without a drive. I figure that can lead to null pointer dereferences. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/virtio-blk.c | 6 ++++++ hw/virtio-pci.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c index 8747634fbe..99e9dd294b 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -12,6 +12,7 @@ */ #include +#include "qemu-error.h" #include "virtio-blk.h" #ifdef __linux__ # include @@ -490,6 +491,11 @@ 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; + } + 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 55831665f6..31a711ef41 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -546,10 +546,6 @@ 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"); - return -1; - } vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block); if (!vdev) { return -1; From 98f28ad7a7d26e5e77c5cb37b262d76d6ccd963d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 6 Jul 2010 14:37:44 +0200 Subject: [PATCH 5/5] ide scsi virtio-blk: Reject empty drives unless media is removable Disks without media make no sense. For SCSI, a Linux guest kernel complains during boot. I didn't try other combinations. scsi-generic doesn't need the additional check, because it already requires bdrv_is_sg(), which fails without media. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/ide/core.c | 4 ++++ hw/scsi-disk.c | 5 +++++ hw/virtio-blk.c | 4 ++++ 3 files changed, 13 insertions(+) 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; 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-blk.c b/hw/virtio-blk.c index 99e9dd294b..f50069d20b 100644 --- a/hw/virtio-blk.c +++ b/hw/virtio-blk.c @@ -495,6 +495,10 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) 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),