Re: [PATCH 7/8] parallels: add routed pseudo network

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

 



On Tue, Dec 11, 2012 at 02:59:48PM +0400, Dmitry Guryanov wrote:
> Historically if traffic from the adapter is routed to LAN without
> NAT, it isn't connected to any virtual networks, but has a 'type'
> instead. Sinse libvirt has special virtual network type for such case,
> let's add pseudo network 'routed' to fit libvirt's API well.
> 
> Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
> ---
>  src/parallels/parallels_network.c |   43 +++++++++++++++++++++++++++++++++++++
>  src/parallels/parallels_utils.h   |    2 +
>  2 files changed, 45 insertions(+), 0 deletions(-)
> 
> diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
> index 64e5351..d6452bf 100644
> --- a/src/parallels/parallels_network.c
> +++ b/src/parallels/parallels_network.c
> @@ -30,6 +30,7 @@
>  #include "parallels_utils.h"
>  
>  #define VIR_FROM_THIS VIR_FROM_PARALLELS
> +#define PARALLELS_ROUTED_NETWORK_UUID   "eb593dd1-6846-45b0-84a0-de0729286982"
>  
>  #define parallelsParseError()                                                  \
>      virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__,    \
> @@ -250,6 +251,45 @@ cleanup:
>      return NULL;
>  }
>  
> +static virNetworkObjPtr
> +parallelsAddRoutedNetwork(parallelsConnPtr privconn)
> +{
> +    virNetworkObjPtr net;
> +    virNetworkDefPtr def;
> +
> +    if (VIR_ALLOC(def) < 0)
> +        goto no_memory;
> +
> +    def->forwardType = VIR_NETWORK_FORWARD_ROUTE;

  similar problem as for patch 6

> +    if (!(def->name = strdup(PARALLELS_ROUTED_NETWORK_NAME)))
> +        goto no_memory;
> +
> +    if (virUUIDParse(PARALLELS_ROUTED_NETWORK_UUID, def->uuid) < 0) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Can't parse UUID"));
> +        goto cleanup;
> +    }
> +    def->uuid_specified = 1;
> +
> +    if (!(net = virNetworkAssignDef(&privconn->networks, def, false))) {
> +        virNetworkDefFree(def);
> +        goto cleanup;
> +    }
> +    net->active = 1;
> +    net->persistent = 1;
> +    net->autostart = 1;
> +    virNetworkObjUnlock(net);
> +
> +    return net;
> +
> +no_memory:
> +    virReportOOMError();
> +cleanup:
> +    virNetworkDefFree(def);
> +    return NULL;
> +}
> +
>  static int parallelsLoadNetworks(parallelsConnPtr privconn)
>  {
>      virJSONValuePtr jobj, jobj2;
> @@ -283,6 +323,9 @@ static int parallelsLoadNetworks(parallelsConnPtr privconn)
>  
>      }
>  
> +    if (!parallelsAddRoutedNetwork(privconn))
> +        goto cleanup;
> +
>      ret = 0;
>  
>  cleanup:
> diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
> index aca3ee2..0010f85 100644
> --- a/src/parallels/parallels_utils.h
> +++ b/src/parallels/parallels_utils.h
> @@ -35,6 +35,8 @@
>      virReportErrorHelper(VIR_FROM_TEST, VIR_ERR_OPERATION_FAILED, __FILE__,    \
>                       __FUNCTION__, __LINE__, _("Can't parse prlctl output"))
>  
> +# define PARALLELS_ROUTED_NETWORK_NAME   "Routed"
> +
>  struct _parallelsConn {
>      virMutex lock;
>      virDomainObjList domains;

and similar fix:


diff --git a/src/parallels/parallels_network.c b/src/parallels/parallels_network.c
index 19af19a..aacceca 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -260,7 +260,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
     if (VIR_ALLOC(def) < 0)
         goto no_memory;
 
-    def->forwardType = VIR_NETWORK_FORWARD_ROUTE;
+    def->forward.type = VIR_NETWORK_FORWARD_ROUTE;
 
     if (!(def->name = strdup(PARALLELS_ROUTED_NETWORK_NAME)))
         goto no_memory;

Daniel

-- 
Daniel Veillard      | Open Source and Standards, Red Hat
veillard@xxxxxxxxxx  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | virtualization library  http://libvirt.org/

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