ide: bdrv_attach_dev() for empty CD-ROM
If no drive=... option is passed (for an empty drive), we don't only lack the BlockBackend normally created by parse_drive(), but we also need to manually call blk_attach_dev(). IDE does not support hot unplug, but if it did, qdev would take care to call the matching blk_detach_dev() on unplug. This fixes at least the bug that such devices didn't show up in query-block, and probably some more problems. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
This commit is contained in:
		
							parent
							
								
									ec18b0a93a
								
							
						
					
					
						commit
						947231ad3b
					
				| 
						 | 
				
			
			@ -164,6 +164,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
 | 
			
		|||
    IDEBus *bus = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus);
 | 
			
		||||
    IDEState *s = bus->ifs + dev->unit;
 | 
			
		||||
    Error *err = NULL;
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    if (!dev->conf.blk) {
 | 
			
		||||
        if (kind != IDE_CD) {
 | 
			
		||||
| 
						 | 
				
			
			@ -172,6 +173,8 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)
 | 
			
		|||
        } else {
 | 
			
		||||
            /* Anonymous BlockBackend for an empty drive */
 | 
			
		||||
            dev->conf.blk = blk_new(0, BLK_PERM_ALL);
 | 
			
		||||
            ret = blk_attach_dev(dev->conf.blk, &dev->qdev);
 | 
			
		||||
            assert(ret == 0);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue