Re: [libvirt PATCH 04/10] virDomainFeaturesHyperVDefParse: Read attribute "mode" of element "hyperv"

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

 



On Fri, Nov 26, 2021 at 03:34:56PM +0100, Tim Wiederhake wrote:
> Currently, this attribute may either have a value of "custom", or be absent
> (which defaults to "custom"), for backwards compatibility.
> 
> Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
> ---
>  src/conf/domain_conf.c   | 11 +++++++++--
>  src/qemu/qemu_command.c  |  2 +-
>  src/qemu/qemu_validate.c |  2 +-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 74d86a346a..0ea00955c5 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -17453,7 +17453,14 @@ static int
>  virDomainFeaturesHyperVDefParse(virDomainDef *def,
>                                  xmlNodePtr node)
>  {
> -    def->features[VIR_DOMAIN_FEATURE_HYPERV] = VIR_TRISTATE_SWITCH_ON;
> +    virDomainHyperVMode mode;
> +
> +    if (virXMLPropEnumDefault(node, "mode", virDomainHyperVModeTypeFromString,
> +                              VIR_XML_PROP_NONZERO, &mode,
> +                              VIR_DOMAIN_HYPERV_MODE_CUSTOM) < 0)
> +        return -1;
> +
> +    def->features[VIR_DOMAIN_FEATURE_HYPERV] = mode;
>  
>      node = xmlFirstElementChild(node);
>      while (node != NULL) {
> @@ -21703,7 +21710,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDef *src,
>      }
>  
>      /* hyperv */
> -    if (src->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) {
> +    if (src->features[VIR_DOMAIN_FEATURE_HYPERV] != VIR_DOMAIN_HYPERV_MODE_NONE) {
>          for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
>              switch ((virDomainHyperv) i) {
>              case VIR_DOMAIN_HYPERV_RELAXED:

This change is not right. It is silently allowing the mode to be
changed, which certainly affects ABI stability. It needs to
validate src->features[VIR_DOMAIN_FEATURE_HYPERV] ==
dst->features[VIR_DOMAIN_FEATURE_HYPERV]


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




[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