[libvirt] [PATCH v2] conf: add enum constants for default controller models

Ján Tomko jtomko at redhat.com
Tue Feb 20 13:35:51 UTC 2018


On Tue, Feb 20, 2018 at 10:56:31AM +0000, Daniel P. Berrangé wrote:
>The controller model is slightly unusual in that the default value is
>-1, not 0. As a result the default value is not covered by any of the
>existing enum cases. This in turn means that any switch() statements
>that think they have covered all cases, will in fact not match the
>default value at all. In the qemuDomainDeviceCalculatePCIConnectFlags()
>method this has caused a serious mistake where we fallthrough from the
>SCSI controller case, to the VirtioSerial controller case, and from
>the USB controller case to the IDE controller case.
>
>By adding explicit enum constant starting at -1, we can ensure switches
>remember to handle the default case.
>
>Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
>---
> src/conf/domain_addr.c         |  6 +++---
> src/conf/domain_conf.c         |  3 ++-
> src/conf/domain_conf.h         |  4 ++++
> src/libxl/libxl_conf.c         |  2 +-
> src/qemu/qemu_command.c        | 21 ++++++++++++++++-----
> src/qemu/qemu_domain.c         | 14 +++++++++++---
> src/qemu/qemu_domain_address.c | 19 +++++++++++++++++--
> src/qemu/qemu_hotplug.c        |  2 +-
> src/vbox/vbox_common.c         | 13 +++++++++----
> src/vmx/vmx.c                  |  2 +-
> 10 files changed, 65 insertions(+), 21 deletions(-)
>

ACK

Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180220/e3f7bc0d/attachment-0001.sig>


More information about the libvir-list mailing list