[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



Cole Robinson <crobinso 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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]