[libvirt] [PATCH] Fix ejecting cdroms with latest qemu syntax

Cole Robinson crobinso at redhat.com
Fri Aug 29 14:27:04 UTC 2008


Jim Meyering wrote:
> Cole Robinson <crobinso at redhat.com> wrote:
> ...
>> Okay, second cut attached. I followed your recommendations:
> ...
> 
> With all of Dan's comments addressed, this should be fine.
> 
>> diff --git a/src/domain_conf.c b/src/domain_conf.c
> ...
>> +int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
> ...
>> +    switch (disk->bus) {
>> +        case VIR_DOMAIN_DISK_BUS_IDE:
>> +            *busIdx = ((idx - (idx % 2)) / 2);
>> +            *devIdx = (idx % 2);
>> +            break;
>> +        case VIR_DOMAIN_DISK_BUS_SCSI:
>> +            *busIdx = ((idx - (idx % 7)) / 7);
>> +            *devIdx = (idx % 7);
>> +            break;
> 
> It doesn't affect correctness, but you can remove the
> unnecessary "- (idx % 2)" and "- (idx % 7)" expressions:
> 
>     switch (disk->bus) {
>         case VIR_DOMAIN_DISK_BUS_IDE:
>             *busIdx = idx / 2;
>             *devIdx = idx % 2;
>             break;
>         case VIR_DOMAIN_DISK_BUS_SCSI:
>             *busIdx = idx / 7;
>             *devIdx = idx % 7;
>             break;

Okay, latest cut. This addresses the above piece pointed out
by Jim and all of Dan's comments.

Thanks,
Cole
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt-qemu-eject-cdrom-03.patch
Type: text/x-patch
Size: 10888 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20080829/5e44d3d7/attachment-0001.bin>


More information about the libvir-list mailing list