We could config user namespace for LXC when creating a new container. Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> --- ui/create.ui | 185 +++++++++++++++++++++++++++++++++++++++++++++++++- virtManager/create.py | 35 ++++++++++ 2 files changed, 218 insertions(+), 2 deletions(-) diff --git a/ui/create.ui b/ui/create.ui index 05e4e4b..d52620f 100644 --- a/ui/create.ui +++ b/ui/create.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.16.1 --> +<!-- Generated with glade 3.16.0 on Tue Feb 18 02:13:26 2014 --> <interface> - <requires lib="gtk+" version="3.0"/> + <!-- interface-requires gtk+ 3.0 --> <object class="GtkAdjustment" id="adjustment2"> <property name="upper">128</property> <property name="step_increment">1</property> @@ -2481,6 +2481,187 @@ is not yet supported.</small></property> <property name="position">0</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="config-idmap"> + <property name="label" translatable="yes">Enable user namespace</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_config_idmap_toggled" swapped="no"/> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="config-idmap-grid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkLabel" id="label31"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">User ID:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label39"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">1</property> + <property name="label" translatable="yes">Group ID:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label52"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">start</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label53"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">target</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label54"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">count</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">0</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="uid-start"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="width_chars">10</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="uid-target"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="width_chars">10</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="uid-count"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="width_chars">10</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">1</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="gid-start"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="width_chars">10</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="gid-target"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="width_chars">10</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="gid-count"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="width_chars">10</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="top_attach">2</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> </object> </child> </object> diff --git a/virtManager/create.py b/virtManager/create.py index b4b1dfe..c8c1dbb 100644 --- a/virtManager/create.py +++ b/virtManager/create.py @@ -155,6 +155,7 @@ class vmmCreate(vmmGObjectUI): "on_config_hv_changed": self.hv_changed, "on_config_arch_changed": self.arch_changed, + "on_config_idmap_toggled": self.toggle_idmap, }) self.bind_escape_key_close() @@ -470,6 +471,8 @@ class vmmCreate(vmmGObjectUI): method_container_app.set_active(True) self.widget("virt-install-box").set_visible(not is_container) self.widget("container-install-box").set_visible(is_container) + self.widget("config-idmap").set_visible(is_container) + self.widget("config-idmap-grid").set_visible(is_container) show_kernel = (self.capsguest.arch not in ["x86_64", "i686"]) show_dtb = ("arm" in self.capsguest.arch or @@ -592,6 +595,17 @@ class vmmCreate(vmmGObjectUI): self.widget("config-set-macaddr").set_active(bool(newmac)) self.widget("config-macaddr").set_text(newmac) + # User namespace idmap setting + self.widget("config-idmap").set_active(False) + + self.widget("uid-start").set_text('0') + self.widget("uid-target").set_text('1000') + self.widget("uid-count").set_text('10') + + self.widget("gid-start").set_text('0') + self.widget("gid-target").set_text('1000') + self.widget("gid-count").set_text('10') + self.widget("config-advanced-expander").set_expanded(False) if self.netlist: @@ -1227,6 +1241,11 @@ class vmmCreate(vmmGObjectUI): def toggle_macaddr(self, src): self.widget("config-macaddr").set_sensitive(src.get_active()) + def toggle_idmap(self, src): + for name in ["uid-start", "uid-target", "uid-count", + "gid-start", "gid-target", "gid-count"]: + self.widget(name).set_sensitive(src.get_active()) + # Navigation methods def set_install_page(self): instnotebook = self.widget("install-method-pages") @@ -1657,6 +1676,14 @@ class vmmCreate(vmmGObjectUI): macaddr = self.widget("config-macaddr").get_text().strip() nettype = self.netlist.get_network_selection()[0] + uid_start = self.widget("uid-start").get_text().strip() + uid_target = self.widget("uid-target").get_text().strip() + uid_count = self.widget("uid-count").get_text().strip() + + gid_start = self.widget("gid-start").get_text().strip() + gid_target = self.widget("gid-target").get_text().strip() + gid_count = self.widget("gid-count").get_text().strip() + if nettype is None: # No network device available instmethod = self.get_config_install_page() @@ -1681,6 +1708,14 @@ class vmmCreate(vmmGObjectUI): self.nic = nic self.guest.add_device(self.nic) + if self.widget("config-idmap").get_active(): + self.guest.idmap.uid_start = uid_start + self.guest.idmap.uid_target = uid_target + self.guest.idmap.uid_count = uid_count + self.guest.idmap.gid_start = gid_start + self.guest.idmap.gid_target = gid_target + self.guest.idmap.gid_count = gid_count + return True def _undo_finish_cursor(self): -- 1.8.5.3 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list