On 2/27/26 22:39, Jonathon Jongsma via Devel wrote:
> We already implement virDomainDefineXML(), so we can just implement one
> in terms of the other.
> 
> Signed-off-by: Jonathon Jongsma <[email protected]>
> ---
>  src/hyperv/hyperv_driver.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 8832769c7b..a78e375c9d 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -2925,7 +2925,7 @@ hypervDomainUndefine(virDomainPtr domain)
>  
>  
>  static virDomainPtr
> -hypervDomainDefineXML(virConnectPtr conn, const char *xml)
> +hypervDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int 
> flags)

I think we should take this opportunity and place one argument per line.

>  {
>      hypervPrivate *priv = conn->privateData;
>      g_autofree char *hostname = hypervConnectGetHostname(conn);
> @@ -2934,10 +2934,14 @@ hypervDomainDefineXML(virConnectPtr conn, const char 
> *xml)
>      g_autoptr(hypervInvokeParamsList) params = NULL;
>      g_autoptr(GHashTable) defineSystemParam = NULL;
>      size_t i = 0;
> +    unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE;
> +
> +    virCheckFlags(VIR_DOMAIN_DEFINE_VALIDATE, NULL);
> +
> +    if (flags & VIR_DOMAIN_DEFINE_VALIDATE)
> +        parse_flags |= VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
>  
> -    /* parse xml */
> -    def = virDomainDefParseString(xml, priv->xmlopt, NULL,
> -                                  VIR_DOMAIN_DEF_PARSE_INACTIVE);
> +    def = virDomainDefParseString(xml, priv->xmlopt, NULL, parse_flags);
>  
>      if (!def)
>          goto error;
> @@ -3034,6 +3038,13 @@ hypervDomainDefineXML(virConnectPtr conn, const char 
> *xml)
>  }
>  
>  
> +static virDomainPtr
> +hypervDomainDefineXML(virConnectPtr conn, const char *xml)

And here too.

> +{
> +    return hypervDomainDefineXMLFlags(conn, xml, 0);
> +}
> +
> +
>  static int
>  hypervDomainAttachDeviceFlags(virDomainPtr domain, const char *xml, unsigned 
> int flags)
>  {
> @@ -4099,6 +4110,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
>      .domainCreate = hypervDomainCreate, /* 0.9.5 */
>      .domainCreateWithFlags = hypervDomainCreateWithFlags, /* 0.9.5 */
>      .domainDefineXML = hypervDomainDefineXML, /* 7.1.0 */
> +    .domainDefineXMLFlags = hypervDomainDefineXMLFlags, /* 12.2.0 */
>      .domainUndefine = hypervDomainUndefine, /* 7.1.0 */
>      .domainUndefineFlags = hypervDomainUndefineFlags, /* 7.1.0 */
>      .domainAttachDevice = hypervDomainAttachDevice, /* 7.1.0 */

Both patches:

Reviewed-by: Michal Privoznik <[email protected]>

Michal

Reply via email to