Re: [libvirt PATCH v2 04/15] conf: normalize hostdev <driver> parsing to simplify adding new attr

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

 



On Mon, Nov 06, 2023 at 02:38:49 -0500, Laine Stump wrote:
> The hostdev version of the <driver> subelement appears in four places:
> 
>  * The domain XML in the <hostdev> and <interface type='hostdev'>
>    elements (that's 2)
> 
>  * The network XML inside <forward> when the network is a pool of
>    SRIOV VFs
> 
>  * the <networkport> XML, which is used to communicate between the
>    hypervisor driver and network driver.
> 
> In order to make the pending addition of a new attribute to <driver>
> in all these cases simpler, this patch refactors the parsing of
> <driver> in all four places to use virXMLProp*() and
> virXMLFormatElement().
> 
> Making all of the different instances of the separate parse/format for
> <driver> look nearly identical will make it easier to see that the
> upcoming patch that converges all four to use a common
> parser/formatter is a functional NOP.
> 
> Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
> ---
>  src/conf/domain_conf.c       | 28 ++++++++++++++++------------
>  src/conf/network_conf.c      | 26 ++++++++++++--------------
>  src/conf/network_conf.h      |  2 +-
>  src/conf/virnetworkportdef.c | 28 ++++++++++++++++++----------
>  src/conf/virnetworkportdef.h |  2 +-
>  5 files changed, 48 insertions(+), 38 deletions(-)

[...]

> @@ -351,10 +355,14 @@ virNetworkPortDefFormatBuf(virBuffer *buf,
>              }
>              virBufferAddLit(buf, ">\n");
>              virBufferAdjustIndent(buf, 2);
> -            if (def->plug.hostdevpci.driver)
> -                virBufferEscapeString(buf, "<driver name='%s'/>\n",
> +
> +            if (def->plug.hostdevpci.driver) {
> +                virBufferEscapeString(&driverAttrBuf, " name='%s'",
>                                        virNetworkForwardDriverNameTypeToString(
>                                            def->plug.hostdevpci.driver));

Please remove the linebreak;

> +            }
> +
> +            virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
>  
>              virPCIDeviceAddressFormat(buf, def->plug.hostdevpci.addr, false);
>              virBufferAdjustIndent(buf, -2);
> diff --git a/src/conf/virnetworkportdef.h b/src/conf/virnetworkportdef.h
> index 48e73dbefd..bfe1dae9ea 100644
> --- a/src/conf/virnetworkportdef.h
> +++ b/src/conf/virnetworkportdef.h
> @@ -69,7 +69,7 @@ struct _virNetworkPortDef {
>          } direct;
>          struct {
>              virPCIDeviceAddress addr; /* PCI Address of device */
> -            int driver; /* virNetworkForwardDriverNameType */
> +            unsigned int driver; /* virNetworkForwardDriverNameType */

Use the proper enum type here.

Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>
_______________________________________________
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