[PATCH v2 3/6] blockdev: with -drive if=virtio, use generic virtio-blk

Laurent Vivier posted 6 patches 4 years, 8 months ago
Maintainers: Thomas Huth <thuth@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Markus Armbruster <armbru@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Max Reitz <mreitz@redhat.com>
There is a newer version of this series
[PATCH v2 3/6] blockdev: with -drive if=virtio, use generic virtio-blk
Posted by Laurent Vivier 4 years, 8 months ago
Rather than checking if the machine is an s390x to use virtio-blk-ccw
instead of virtio-blk-pci, use the alias virtio-blk that is set to
the expected target.

This also enables the use of virtio-blk-device for targets without
PCI or CCW.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 blockdev.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index 5cc7c7effe9f..64da5350e3ad 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -969,11 +969,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
         QemuOpts *devopts;
         devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
                                    &error_abort);
-        if (arch_type == QEMU_ARCH_S390X) {
-            qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort);
-        } else {
-            qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort);
-        }
+        qemu_opt_set(devopts, "driver", "virtio-blk", &error_abort);
         qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
                      &error_abort);
     }
-- 
2.30.2


Re: [PATCH v2 3/6] blockdev: with -drive if=virtio, use generic virtio-blk
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
On 3/19/21 2:25 PM, Laurent Vivier wrote:
> Rather than checking if the machine is an s390x to use virtio-blk-ccw
> instead of virtio-blk-pci, use the alias virtio-blk that is set to
> the expected target.
> 
> This also enables the use of virtio-blk-device for targets without
> PCI or CCW.
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  blockdev.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Re: [PATCH v2 3/6] blockdev: with -drive if=virtio, use generic virtio-blk
Posted by Cornelia Huck 4 years, 8 months ago
On Fri, 19 Mar 2021 14:25:34 +0100
Laurent Vivier <laurent@vivier.eu> wrote:

> Rather than checking if the machine is an s390x to use virtio-blk-ccw
> instead of virtio-blk-pci, use the alias virtio-blk that is set to
> the expected target.

One side effect: if we add a new architecture and don't define the
aliases for it, this function probably won't do the right thing; prior
to the patch, it would simply default to virtio-blk-pci. Probably not a
big deal, but we need to be careful to keep the alias defines up to
date, which previously wasn't such a big deal.

> 
> This also enables the use of virtio-blk-device for targets without
> PCI or CCW.
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  blockdev.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 5cc7c7effe9f..64da5350e3ad 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -969,11 +969,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
>          QemuOpts *devopts;
>          devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
>                                     &error_abort);
> -        if (arch_type == QEMU_ARCH_S390X) {
> -            qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort);
> -        } else {
> -            qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort);
> -        }
> +        qemu_opt_set(devopts, "driver", "virtio-blk", &error_abort);
>          qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
>                       &error_abort);
>      }


Re: [PATCH v2 3/6] blockdev: with -drive if=virtio, use generic virtio-blk
Posted by Laurent Vivier 4 years, 8 months ago
Le 19/03/2021 à 15:46, Cornelia Huck a écrit :
> On Fri, 19 Mar 2021 14:25:34 +0100
> Laurent Vivier <laurent@vivier.eu> wrote:
> 
>> Rather than checking if the machine is an s390x to use virtio-blk-ccw
>> instead of virtio-blk-pci, use the alias virtio-blk that is set to
>> the expected target.
> 
> One side effect: if we add a new architecture and don't define the
> aliases for it, this function probably won't do the right thing; prior
> to the patch, it would simply default to virtio-blk-pci. Probably not a
> big deal, but we need to be careful to keep the alias defines up to
> date, which previously wasn't such a big deal.

But it will be easy to detect because we will have the error "unknown device: virtio-blk".
It will be a good reminder to add the aliases...

Thanks,
Laurent

> 
>>
>> This also enables the use of virtio-blk-device for targets without
>> PCI or CCW.
>>
>> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
>> ---
>>  blockdev.c | 6 +-----
>>  1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/blockdev.c b/blockdev.c
>> index 5cc7c7effe9f..64da5350e3ad 100644
>> --- a/blockdev.c
>> +++ b/blockdev.c
>> @@ -969,11 +969,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type,
>>          QemuOpts *devopts;
>>          devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
>>                                     &error_abort);
>> -        if (arch_type == QEMU_ARCH_S390X) {
>> -            qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort);
>> -        } else {
>> -            qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort);
>> -        }
>> +        qemu_opt_set(devopts, "driver", "virtio-blk", &error_abort);
>>          qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
>>                       &error_abort);
>>      }
>