qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] uninit drive if drive_init failed
@ 2011-02-16  2:30 Wen Congyang
  2011-02-16  9:45 ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Wen Congyang @ 2011-02-16  2:30 UTC (permalink / raw)
  To: qemu-devel

steps to reproduce this bug:
1. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver qcow2
error: Failed to attach disk
error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'

2. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver raw
error: Failed to attach disk
error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'

The format of disk image file is raw.
If we run comand 2 only, we will attach the disk successfully.

The reason of this bug is that: we do not remove dinfo from drives and dinfo->bdrv from bdrv_states
if we open the disk image file failed.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>

---
 blockdev.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 1333a4e..03cc000 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -527,7 +527,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     } else if (ro == 1) {
         if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {
             error_report("readonly not supported by this bus type");
-            return NULL;
+            goto cleanup;
         }
     }
 
@@ -537,12 +537,19 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     if (ret < 0) {
         error_report("could not open disk image %s: %s",
                      file, strerror(-ret));
-        return NULL;
+        goto cleanup;
     }
 
     if (bdrv_key_required(dinfo->bdrv))
         autostart = 0;
     return dinfo;
+
+cleanup:
+    bdrv_delete(dinfo->bdrv);
+    QTAILQ_REMOVE(&drives, dinfo, next);
+    qemu_free(dinfo->id);
+    qemu_free(dinfo);
+    return NULL;
 }
 
 void do_commit(Monitor *mon, const QDict *qdict)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] uninit drive if drive_init failed
  2011-02-16  2:30 [Qemu-devel] [PATCH] uninit drive if drive_init failed Wen Congyang
@ 2011-02-16  9:45 ` Markus Armbruster
  2011-02-16  9:58   ` Wen Congyang
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2011-02-16  9:45 UTC (permalink / raw)
  To: Wen Congyang; +Cc: qemu-devel

Wen Congyang <wency@cn.fujitsu.com> writes:

> steps to reproduce this bug:
> 1. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver qcow2
> error: Failed to attach disk
> error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
>
> 2. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver raw
> error: Failed to attach disk
> error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
>
> The format of disk image file is raw.
> If we run comand 2 only, we will attach the disk successfully.
>
> The reason of this bug is that: we do not remove dinfo from drives and dinfo->bdrv from bdrv_states
> if we open the disk image file failed.
>
> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>

Already fixed in Kevin's block tree and 0.14-rc2 (commit 08931947),
although not yet in stable.

Thanks anyway!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] uninit drive if drive_init failed
  2011-02-16  9:45 ` Markus Armbruster
@ 2011-02-16  9:58   ` Wen Congyang
  0 siblings, 0 replies; 3+ messages in thread
From: Wen Congyang @ 2011-02-16  9:58 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

At 02/16/2011 05:45 PM, Markus Armbruster Write:
> Wen Congyang <wency@cn.fujitsu.com> writes:
> 
>> steps to reproduce this bug:
>> 1. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver qcow2
>> error: Failed to attach disk
>> error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
>>
>> 2. virsh attach-disk domain --source imagefile --target sdb --sourcetype file --driver qemu --subdriver raw
>> error: Failed to attach disk
>> error: operation failed: adding scsi-disk,bus=scsi0.0,scsi-id=1,drive=drive-scsi0-0-1,id=scsi0-0-1 device failed: Property 'scsi-disk.drive' can't find value 'drive-scsi0-0-1'
>>
>> The format of disk image file is raw.
>> If we run comand 2 only, we will attach the disk successfully.
>>
>> The reason of this bug is that: we do not remove dinfo from drives and dinfo->bdrv from bdrv_states
>> if we open the disk image file failed.
>>
>> Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
> 
> Already fixed in Kevin's block tree and 0.14-rc2 (commit 08931947),
> although not yet in stable.

I only use master tree and do not notice that this bug has been fixed.
Thank you for pointing it out.

> 
> Thanks anyway!
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-02-16 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-16  2:30 [Qemu-devel] [PATCH] uninit drive if drive_init failed Wen Congyang
2011-02-16  9:45 ` Markus Armbruster
2011-02-16  9:58   ` Wen Congyang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).