958e1b
From dcbbbce1a1315b8baf85e10f43ee8355b34314cf Mon Sep 17 00:00:00 2001
958e1b
From: Fam Zheng <famz@redhat.com>
958e1b
Date: Tue, 15 Jul 2014 15:54:03 -0500
958e1b
Subject: [CHANGE 24/29] scsi: Report error when lun number is in use
958e1b
To: rhvirt-patches@redhat.com,
958e1b
    jen@redhat.com
958e1b
958e1b
RH-Author: Fam Zheng <famz@redhat.com>
958e1b
Message-id: <1405439643-14545-1-git-send-email-famz@redhat.com>
958e1b
Patchwork-id: 59914
958e1b
O-Subject: [RHEL-7 qemu-kvm PATCH] scsi: Report error when lun number is in use
958e1b
Bugzilla: 1096576
958e1b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
958e1b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
RH-Acked-by: Amos Kong <akong@redhat.com>
958e1b
958e1b
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1096576
958e1b
Brew:     http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7702061
958e1b
958e1b
In the case that the lun number is taken by another scsi device, don't
958e1b
release the existing device siliently, but report an error to user.
958e1b
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
(cherry picked from commit 2039511b8f573165420c86380762ae829dc398d9)
958e1b
Signed-off-by: Fam Zheng <famz@redhat.com>
958e1b
---
958e1b
 hw/scsi/scsi-bus.c | 3 ++-
958e1b
 1 file changed, 2 insertions(+), 1 deletion(-)
958e1b
958e1b
Signed-off-by: jen <jen@redhat.com>
958e1b
---
958e1b
 hw/scsi/scsi-bus.c | 3 ++-
958e1b
 1 file changed, 2 insertions(+), 1 deletion(-)
958e1b
958e1b
diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c
958e1b
index 77e0c10..7e25c62 100644
958e1b
--- a/hw/scsi/scsi-bus.c
958e1b
+++ b/hw/scsi/scsi-bus.c
958e1b
@@ -178,7 +178,8 @@ static int scsi_qdev_init(DeviceState *qdev)
958e1b
         d = scsi_device_find(bus, dev->channel, dev->id, dev->lun);
958e1b
         assert(d);
958e1b
         if (d->lun == dev->lun && dev != d) {
958e1b
-            object_unparent(OBJECT(d));
958e1b
+            error_report("lun already used by '%s'", d->qdev.id);
958e1b
+            goto err;
958e1b
         }
958e1b
     }
958e1b
 
958e1b
-- 
958e1b
1.9.3
958e1b