Re: [PATCH v2 08/25] qemu: command: Make BuildVirtioDevStr more generic

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

 



On Wed, 2019-01-23 at 16:32 -0500, Cole Robinson wrote:
[...]
> +/**
> + * qemuBuildVirtioDevStr
> + * @buf: virBufferPtr to append the built string
> + * @baseName: qemu virtio device basename string. Ex: virtio-rng for <rng>
> + * @devtype: virDomainDeviceType of the device. Ex: VIR_DOMAIN_DEVICE_TYPE_RNG
> + * @devdata: *DefPtr of the device definition
> + *
> + * Build the qemu virtio -device name from the passed parameters. Currently
> + * this is mostly about attaching the correct string prefix to @baseName for
> + * the passed @type. So for @baseName "virtio-rng" and devdata->info.type
> + * VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI, generate "virtio-rng-pci"
> + *
> + * Returns: -1 on failure, 0 on success
> + */
>  static int
>  qemuBuildVirtioDevStr(virBufferPtr buf,
>                        const char *baseName,
> -                      virDomainDeviceAddressType type)
> +                      virDomainDeviceType devtype,
> +                      void *devdata)
>  {
>      const char *implName = NULL;
> +    virDomainDeviceDef device = { .type = devtype };
> +    virDomainDeviceInfoPtr info;
>  
> -    switch (type) {
> +    virDomainDeviceSetData(&device, devdata);
> +    info = virDomainDeviceGetInfo(&device);
> +
> +    switch (info->type) {

You should cast info->type to virDomainDeviceAddressType here to
force the compiler to check the switch statements covers all
possible values.

With that fixed,

  Reviewed-by: Andrea Bolognani <abologna@xxxxxxxxxx>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux