Re: [PATCH v4 5/7] parallels: make E1000 network adapter model default

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

 



On 18.03.2015 09:33, Maxim Nestratov wrote:
> and set adapter model specified in xml
> 
> Signed-off-by: Maxim Nestratov <mnestratov@xxxxxxxxxxxxx>
> ---
>  src/parallels/parallels_driver.c |    7 ++++++-
>  src/parallels/parallels_sdk.c    |   15 +++++++++++++++
>  2 files changed, 21 insertions(+), 1 deletions(-)
> 
> diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
> index 1a6d6e6..807c1b1 100644
> --- a/src/parallels/parallels_driver.c
> +++ b/src/parallels/parallels_driver.c
> @@ -168,13 +168,18 @@ parallelsDomainDefPostParse(virDomainDefPtr def ATTRIBUTE_UNUSED,
>      return 0;
>  }
>  
> -
>  static int
>  parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,

@dev is now clearly used.

>                                    const virDomainDef *def ATTRIBUTE_UNUSED,
>                                    virCapsPtr caps ATTRIBUTE_UNUSED,
>                                    void *opaque ATTRIBUTE_UNUSED)
>  {
> +    if (dev->type == VIR_DOMAIN_DEVICE_NET &&
> +        (dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
> +        dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
> +        !dev->data.net->model)
> +        return VIR_STRDUP(dev->data.net->model, "e1000");
> +
>      return 0;
>  }
>  
> diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
> index d699613..8deebd4 100644
> --- a/src/parallels/parallels_sdk.c
> +++ b/src/parallels/parallels_sdk.c
> @@ -2672,6 +2672,21 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, parallelsConnPtr privconn, virDomainN
>      pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
>      prlsdkCheckRetGoto(pret, cleanup);
>  
> +    if (STREQ(net->model, "rtl8139"))
> +        pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
> +    else if (STREQ(net->model, "e1000"))
> +        pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
> +    else if (STREQ(net->model, "virtio"))
> +        pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
> +    else {

We have this rule, that if one arm of if-else is in curly braces, the
other one has to be too. Even if it is a oneliner.

> +        

Whitespace.

> +        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                       _("Specified network adapter model is not "
> +                         "supported by Parallels Cloud Server."));
> +        goto cleanup;
> +    }
> +    prlsdkCheckRetGoto(pret, cleanup);
> +

Awesome! The code is much cleaner now.

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]