[libvirt] [PATCH v2 08/25] qemu: command: Make BuildVirtioDevStr more generic
Andrea Bolognani
abologna at redhat.com
Thu Jan 24 16:57:53 UTC 2019
On Thu, 2019-01-24 at 17:48 +0100, Andrea Bolognani wrote:
> 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 at redhat.com>
Small additional note: I won't be able to review more patches until
next week, but since everything up until here makes sense even in
isolation and there were only minor / cosmetic issues, feel free to
take care of those and then push away :)
--
Andrea Bolognani / Red Hat / Virtualization
More information about the libvir-list
mailing list