Re: [RFC v2: vf-token 4/7] conf: vf-token parsing and formatting

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

 



On Wed, Nov 29, 2023 at 21:07:24 -0700, Vivek Kashyap wrote:
> XML parsing and formatting of vf-token attribute
> 
> Signed-off-by: Vivek Kashyap <vivek.kashyap@xxxxxxxxxxxxxxx>
> ---
>  src/conf/device_conf.c          | 32 ++++++++++++++++++++++++++++++--
>  src/conf/device_conf.h          |  3 +++
>  src/conf/domain_conf.c          |  8 ++++++++
>  src/conf/schemas/basictypes.rng |  7 +++++++
>  src/libvirt_private.syms        |  1 +
>  src/util/virpci.c               |  7 +++++++
>  src/util/virpci.h               |  3 +++
>  7 files changed, 59 insertions(+), 2 deletions(-)
> 
> diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
> index f3d977f2b7..f365e98bfd 100644
> --- a/src/conf/device_conf.c
> +++ b/src/conf/device_conf.c
> @@ -188,11 +188,20 @@ virDeviceInfoPCIAddressExtensionIsWanted(const virDomainDeviceInfo *info)
>             virZPCIDeviceAddressIsIncomplete(&info->addr.pci.zpci);
>  }
>  
> +bool
> +virDeviceExtensionIsPresent(const virPCIDeviceAddress *pci)
> +{
> +    return (((pci->extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
> +           virZPCIDeviceAddressIsPresent(&pci->zpci)) ||
> +           ((pci->extFlags & VIR_PCI_ADDRESS_EXTENSION_VFTOKEN) &&
> +           pci->token.isSet));
> +}
> +
>  bool
>  virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info)
>  {
> -    return (info->addr.pci.extFlags & VIR_PCI_ADDRESS_EXTENSION_ZPCI) &&
> -           virZPCIDeviceAddressIsPresent(&info->addr.pci.zpci);
> +    return (info->addr.pci.extFlags != VIR_PCI_ADDRESS_EXTENSION_NONE) &&
> +           virDeviceExtensionIsPresent(&info->addr.pci);
>  }

Fixes to coding style requested before:

https://lists.libvirt.org/archives/list/devel@xxxxxxxxxxxxxxxxx/message/46WYW3QL7DNVDLVLDLEHWV46LHNTVSI3/

were not addressed. Note that reviews aren't an easy task an thus not
addressing all feedback may deter reviewers from a timely look at your
next postings.

>  
>  int
> @@ -200,6 +209,7 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
>                              virPCIDeviceAddress *addr)
>  {
>      xmlNodePtr zpci;
> +    xmlNodePtr token;
>  
>      memset(addr, 0, sizeof(*addr));
>  
> @@ -231,6 +241,11 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
>              return -1;
>      }
>  
> +    if ((token = virXMLNodeGetSubelement(node, "vf-token"))) {
> +       if (virPCIDeviceTokenParseXML(token, addr) < 0)
> +           return -1;
> +    }
> +
>      return 0;
>  }
>  
> @@ -248,6 +263,19 @@ virPCIDeviceAddressFormat(virBuffer *buf,
>                        addr.function);
>  }
>  
> +int

No need to export this function, as it's used just in this file. Place
it properly and make it static.

> +virPCIDeviceTokenParseXML(xmlNodePtr node,
> +                          virPCIDeviceAddress *addr)
> +{
> +    if (virXMLPropUUID(node, "uuid", VIR_XML_PROP_NONE,
> +                       addr->token.uuid) < 0)
> +       return -1;
> +
> +    addr->token.isSet = 1;
> +
> +    return 0;
> +}
> +
>  int
>  virCCWDeviceAddressParseXML(xmlNodePtr node,
>                              virCCWDeviceAddress *addr)
> diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
> index a83377417a..a37ee29b88 100644
> --- a/src/conf/device_conf.h
> +++ b/src/conf/device_conf.h
> @@ -188,6 +188,9 @@ bool virDeviceInfoPCIAddressExtensionIsPresent(const virDomainDeviceInfo *info);
>  int virPCIDeviceAddressParseXML(xmlNodePtr node,
>                                  virPCIDeviceAddress *addr);
>  
> +int virPCIDeviceTokenParseXML(xmlNodePtr node,
> +                              virPCIDeviceAddress *addr);
> +

Drop this hunk.

>  void virPCIDeviceAddressFormat(virBuffer *buf,
>                                 virPCIDeviceAddress addr,
>                                 bool includeTypeInAddr);
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 22ad43e1d7..8bda81815a 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -5403,6 +5403,14 @@ virDomainDeviceInfoFormat(virBuffer *buf,
>                                info->addr.pci.zpci.uid.value,
>                                info->addr.pci.zpci.fid.value);
>          }
> +
> +        if (virPCIVFIOTokenIDIsPresent(&info->addr.pci.token)) {
> +            char uuidstr[VIR_UUID_STRING_BUFLEN];
> +
> +            virBufferAsprintf(&childBuf, "<vf-token uuid='%s'/>\n",
> +                              virUUIDFormat(info->addr.pci.token.uuid,
> +                                            uuidstr));
> +        }
>          break;
>  
>      case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE:
> diff --git a/src/conf/schemas/basictypes.rng b/src/conf/schemas/basictypes.rng
> index 26eb538077..bbb7484430 100644
> --- a/src/conf/schemas/basictypes.rng
> +++ b/src/conf/schemas/basictypes.rng
> @@ -121,6 +121,13 @@
>          <ref name="virOnOff"/>
>        </attribute>
>      </optional>
> +    <optional>
> +     <element name="vf-token">
> +       <attribute name="uuid">
> +         <ref name="UUID"/>
> +       </attribute>
> +     </element>
> +    </optional>
>    </define>
>    <define name="zpciaddress">
>      <optional>

And move the documentation from the last patch to this one.
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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