Skip to contentSkip to conversation

Block patches

GIT PULL New Kevin Wolf 2 participants 8 messages Jul 13, 2010

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

These are some more fixes that should go into 0.13.

The following changes since commit f077caa99c21847152e706e222277b378cb0ec2f:

Merge remote branch 'mst/for_anthony' into staging (2010-07-13 08:56:27 -0500)

are available in the git repository at:

git://repo.or.cz/qemu/kevin.git for-anthony

Markus Armbruster (3):
virtio-pci: Check for virtio_blk_init() failure
virtio-blk: Fix virtio-blk-s390 to require drive
ide scsi virtio-blk: Reject empty drives unless media is removable

Shahar Havivi (1):
Block migration fail, ignore error from bdrv_getlength

Stefan Weil (1):
qemu-img: Fix copy+paste bug in documentation

 block-migration.c |    2 +-
 hw/ide/core.c     |    4 ++++
 hw/scsi-disk.c    |    5 +++++
 hw/virtio-blk.c   |   10 ++++++++++
 hw/virtio-pci.c   |    5 ++---
 qemu-img-cmds.hx  |    2 +-
 6 files changed, 23 insertions(+), 5 deletions(-)
author
#1 lore raw

PATCH 1/5 qemu-img: Fix copy+paste bug in documentation

From: Stefan Weil <[email protected]>

Replace rebase by resize in documentation of resize command.

Cc Stefan Hajnoczi <[email protected]>
Cc Kevin Wolf <[email protected]>
---
 qemu-img-cmds.hx |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-img-cmds.hx +1 -1
index c4cf3e7..6d3e5f8 100644
@@ -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
Signature · 1 line
1.7.1.1
author
#2 lore raw

PATCH 2/5 Block migration fail, ignore error from bdrv_getlength

In reply to Kevin Wolf

From: Shahar Havivi <[email protected]>

When there is no block driver associate with BlockDriverState bdrv_getlength returns -ENOMEDIUM that cause block migration to fail

---
 block-migration.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
block-migration.c +1 -1
index 7db6f02..a77106e 100644
@@ -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;
         }
 
Signature · 1 line
1.7.1.1
author
#3 lore raw

PATCH 3/5 virtio-pci: Check for virtio_blk_init() failure

In reply to Kevin Wolf

From: Markus Armbruster <[email protected]>

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.

---
 hw/virtio-pci.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
hw/virtio-pci.c +3 -0
index c728fff..5583166 100644
@@ -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,
Signature · 1 line
1.7.1.1
author
#4 lore raw

PATCH 4/5 virtio-blk: Fix virtio-blk-s390 to require drive

In reply to Kevin Wolf

From: Markus Armbruster <[email protected]>

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.

---
 hw/virtio-blk.c |    6 ++++++
 hw/virtio-pci.c |    4 ----
 2 files changed, 6 insertions(+), 4 deletions(-)
hw/virtio-blk.c +6 -0
index 8747634..99e9dd2 100644
@@ -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,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));
hw/virtio-pci.c +0 -4
index 5583166..31a711e 100644
@@ -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;
Signature · 1 line
1.7.1.1
author
#5 lore raw

PATCH 5/5 ide scsi virtio-blk: Reject empty drives unless media is removable

In reply to Kevin Wolf

From: Markus Armbruster <[email protected]>

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.

---
 hw/ide/core.c   |    4 ++++
 hw/scsi-disk.c  |    5 +++++
 hw/virtio-blk.c |    4 ++++
 3 files changed, 13 insertions(+), 0 deletions(-)
hw/ide/core.c +4 -0
index af52c2c..e20f2e7 100644
@@ -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;
hw/scsi-disk.c +5 -0
index c30709c..f43f2d0 100644
@@ -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;
hw/virtio-blk.c +4 -0
index 99e9dd2..f50069d 100644
@@ -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),
Signature · 1 line
1.7.1.1
#6 lore raw
In reply to Kevin Wolf
Quoted 1 line · Kevin Wolf

These are some more fixes that should go into 0.13.

Any of these 0.12-stable material?

Quoted 29 lines

The following changes since commit
f077caa99c21847152e706e222277b378cb0ec2f:

Merge remote branch 'mst/for_anthony' into staging (2010-07-13 08:56:27
-0500)

are available in the git repository at:

git://repo.or.cz/qemu/kevin.git for-anthony

Markus Armbruster (3):
virtio-pci: Check for virtio_blk_init() failure
virtio-blk: Fix virtio-blk-s390 to require drive
ide scsi virtio-blk: Reject empty drives unless media is removable

Shahar Havivi (1):
Block migration fail, ignore error from bdrv_getlength

Stefan Weil (1):
qemu-img: Fix copy+paste bug in documentation

 block-migration.c |    2 +-
 hw/ide/core.c     |    4 ++++
 hw/scsi-disk.c    |    5 +++++
 hw/virtio-blk.c   |   10 ++++++++++
 hw/virtio-pci.c   |    5 ++---
 qemu-img-cmds.hx  |    2 +-
 6 files changed, 23 insertions(+), 5 deletions(-)
author
#7 lore raw

Am 13.07.2010 18:43, schrieb Brian Jackson:

Quoted 5 lines · Kevin Wolf
Quoted 1 line

These are some more fixes that should go into 0.13.

Any of these 0.12-stable material?

I'll try to have a closer look tomorrow. Probably not these, but I think there are some more patches in git master which could go into 0.12-stable.

Kevin