[virt-tools-list] [PATCH virt-manager] lxc: define a private network for OS containers

Cole Robinson crobinso at redhat.com
Mon Mar 10 14:46:13 UTC 2014


On 03/10/2014 10:35 AM, Giuseppe Scrivano wrote:
> By default, specify the the "<privnet>" feature with LXC operating
> system containers.
> 
> Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1040406
> Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
> ---
>  tests/cli-test-xml/compare/virt-install-fs-default.xml |  3 +++
>  virtinst/guest.py                                      | 18 +++++++++++++-----
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/tests/cli-test-xml/compare/virt-install-fs-default.xml b/tests/cli-test-xml/compare/virt-install-fs-default.xml
> index e46a463..1f7b645 100644
> --- a/tests/cli-test-xml/compare/virt-install-fs-default.xml
> +++ b/tests/cli-test-xml/compare/virt-install-fs-default.xml
> @@ -8,6 +8,9 @@
>      <type arch="x86_64">exe</type>
>      <init>/sbin/init</init>
>    </os>
> +  <features>
> +    <privnet/>
> +  </features>
>    <on_poweroff>destroy</on_poweroff>
>    <on_reboot>restart</on_reboot>
>    <on_crash>restart</on_crash>
> diff --git a/virtinst/guest.py b/virtinst/guest.py
> index 9f8ead5..c7af16f 100644
> --- a/virtinst/guest.py
> +++ b/virtinst/guest.py
> @@ -1,7 +1,7 @@
>  #
>  # Common code for all guests
>  #
> -# Copyright 2006-2009, 2013 Red Hat, Inc.
> +# Copyright 2006-2009, 2013, 2014 Red Hat, Inc.
>  # Jeremy Katz <katzj at redhat.com>
>  #
>  # This program is free software; you can redistribute it and/or modify
> @@ -647,12 +647,18 @@ class Guest(XMLBuilder):
>          self._set_video_defaults()
>          self._set_sound_defaults()
>  
> +    def _is_os_container(self):
> +        if not self.os.is_container():
> +            return False
> +        for fs in self.get_devices("filesystem"):
> +            if fs.target == "/":
> +                return True
> +        return False
> +
>      def _set_osxml_defaults(self):
>          if self.os.is_container() and not self.os.init:
> -            for fs in self.get_devices("filesystem"):
> -                if fs.target == "/":
> -                    self.os.init = "/sbin/init"
> -                    break
> +            if self._is_os_container():
> +                self.os.init = "/sbin/init"
>              self.os.init = self.os.init or "/bin/sh"
>  
>          if not self.os.loader and self.os.is_hvm() and self.type == "xen":
> @@ -738,6 +744,8 @@ class Guest(XMLBuilder):
>              self.features.acpi = None
>              self.features.apic = None
>              self.features.pae = None
> +            if self._is_os_container():
> +                self.features.privnet = True
>              return
>  
>          if not self.os.is_hvm():
> 

ACK

- Cole




More information about the virt-tools-list mailing list