On 18.02.2013 14:01, Paolo Bonzini wrote:
Il 18/02/2013 13:58, Peter Lieven ha scritto:

-    switch (iscsilun->type) {
-    case TYPE_DISK:
-        task = iscsi_readcapacity16_sync(iscsi, iscsilun->lun);
-        if (task == NULL || task->status != SCSI_STATUS_GOOD) {
-            error_report("iSCSI: failed to send readcapacity16 command.");
-            ret = -EINVAL;
-            goto out;
-        }
-        rc16 = scsi_datain_unmarshall(task);
-        if (rc16 == NULL) {
-            error_report("iSCSI: Failed to unmarshall readcapacity16
data.");
-            ret = -EINVAL;
+    if (iscsilun->type == TYPE_DISK) {
+        if ((ret = iscsi_disk_readcapacity16_sync(iscsilun))) {
              goto out;
          }
-        iscsilun->block_size = rc16->block_length;
-        iscsilun->num_blocks = rc16->returned_lba + 1;
-        break;
-    case TYPE_ROM:
+    }
+    if (iscsilun->type == TYPE_ROM) {
          task = iscsi_readcapacity10_sync(iscsi, iscsilun->lun, 0, 0);
          if (task == NULL || task->status != SCSI_STATUS_GOOD) {
              error_report("iSCSI: failed to send readcapacity10 command.");
@@ -964,10 +981,7 @@ static int iscsi_open(BlockDriverState *bs, const
char *filename, int flags)
          } else {
              iscsilun->num_blocks = rc10->lba + 1;
          }
-        break;
-    default:
-        break;
-    }
+    }

I didn't write to *remove* the switch statement, I wrote to *move* it
into a new function and use it from iscsi_truncate.

Sorry, not enough sleep. However, truncate makes only sense for lun type disk, 
doesn't it?

Peter



Paolo



Reply via email to