connect: Add an option for qemu:///session (bz 557103)

But warn that it may not function like users expect.
This commit is contained in:
Cole Robinson 2014-02-01 19:44:27 -05:00
parent 032dd0cf21
commit 5bff23758c
2 changed files with 191 additions and 185 deletions

View File

@ -1,40 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name item -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">SSH</col>
</row>
<row>
<col id="0" translatable="yes">TCP (SASL, Kerberos, ...)</col>
</row>
<row>
<col id="0" translatable="yes">SSL/TLS with certificates</col>
</row>
</data>
</object>
<object class="GtkListStore" id="liststore2">
<columns>
<!-- column-name item -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">Xen</col>
</row>
<row>
<col id="0" translatable="yes">QEMU/KVM</col>
</row>
<row>
<col id="0" translatable="yes">LXC (Linux Containers)</col>
</row>
</data>
</object>
<requires lib="gtk+" version="3.0"/>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@ -101,37 +68,28 @@
</packing>
</child>
<child>
<object class="GtkTable" id="table1">
<object class="GtkGrid" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="n_rows">8</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkComboBox" id="hypervisor">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">liststore2</property>
<signal name="changed" handler="on_hypervisor_changed" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="hypervisor-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Hypervisor Select</property>
</object>
</child>
<signal name="changed" handler="on_hypervisor_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -144,35 +102,28 @@
<property name="mnemonic_widget">hypervisor</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="connection">
<object class="GtkComboBox" id="transport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">liststore1</property>
<signal name="changed" handler="on_transport_changed" swapped="no"/>
<child internal-child="accessible">
<object class="AtkObject" id="connection-atkobject">
<object class="AtkObject" id="transport-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Connection Select</property>
</object>
</child>
<signal name="changed" handler="on_connection_changed" swapped="no"/>
<child>
<object class="GtkCellRendererText" id="cellrenderertext1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -181,10 +132,10 @@
<property name="can_focus">False</property>
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="bottom_attach">6</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -195,10 +146,10 @@
<property name="label" translatable="yes">Generated URI:</property>
</object>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -211,10 +162,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="y_options"/>
<property name="top_attach">8</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -229,55 +179,10 @@
<signal name="toggled" handler="on_connect_remote_toggled" swapped="no"/>
</object>
<packing>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">22</property>
<child>
<object class="GtkLabel" id="label88">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Me_thod:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">connection</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">22</property>
<child>
<object class="GtkLabel" id="label91">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">H_ostname:</property>
<property name="use_underline">True</property>
</object>
</child>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -290,10 +195,10 @@
<property name="mnemonic_widget">autoconnect</property>
</object>
<packing>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -307,37 +212,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">6</property>
<property name="bottom_attach">7</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">22</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0.51999998092651367</property>
<property name="ypad">2</property>
<property name="label" translatable="yes">_Username:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">username-entry</property>
</object>
</child>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">7</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -349,10 +226,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="y_options"/>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -370,10 +246,106 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label91">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">24</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">H_ostname:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">24</property>
<property name="xalign">0</property>
<property name="yalign">0.51999998092651367</property>
<property name="ypad">2</property>
<property name="label" translatable="yes">_Username:</property>
<property name="use_markup">True</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">username-entry</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="y_options"/>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label88">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">24</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Me_thod:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="session-warning-box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="stock">gtk-dialog-warning</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes">&lt;small&gt;QEMU usermode session is not the virt-manager
default. It is likely that any pre-existing QEMU/KVM
guests will not be available. Networking options
are very limited. &lt;/small&gt;</property>
<property name="use_markup">True</property>
<property name="max_width_chars">20</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
</object>

View File

@ -28,15 +28,17 @@ from gi.repository import GObject
from gi.repository import Gtk
# pylint: enable=E0611
from virtManager import uiutil
from virtManager.baseclass import vmmGObjectUI
HV_XEN = 0
HV_QEMU = 1
HV_LXC = 2
(HV_QEMU,
HV_XEN,
HV_LXC,
HV_QEMU_SESSION) = range(4)
CONN_SSH = 0
CONN_TCP = 1
CONN_TLS = 2
(CONN_SSH,
CONN_TCP,
CONN_TLS) = range(3)
def current_user():
@ -64,7 +66,7 @@ class vmmConnect(vmmGObjectUI):
self.builder.connect_signals({
"on_hypervisor_changed": self.hypervisor_changed,
"on_connection_changed": self.conn_changed,
"on_transport_changed": self.transport_changed,
"on_hostname_combo_changed": self.hostname_combo_changed,
"on_connect_remote_toggled": self.connect_remote_toggled,
"on_username_entry_changed": self.username_changed,
@ -147,6 +149,23 @@ class vmmConnect(vmmGObjectUI):
def set_initial_state(self):
self.widget("connect").grab_default()
combo = self.widget("hypervisor")
model = Gtk.ListStore(str)
model.append(["QEMU/KVM"])
model.append(["Xen"])
model.append(["LXC (Linux Containers)"])
model.append(["QEMU/KVM user session"])
combo.set_model(model)
uiutil.set_combo_text_column(combo, 0)
combo = self.widget("transport")
model = Gtk.ListStore(str)
model.append(["SSH"])
model.append(["TCP (SASL, Kerberos)"])
model.append(["SSL/TLS with certificates"])
combo.set_model(model)
uiutil.set_combo_text_column(combo, 0)
# Hostname combo box entry
hostListModel = Gtk.ListStore(str, str, str)
host = self.widget("hostname")
@ -156,7 +175,7 @@ class vmmConnect(vmmGObjectUI):
def reset_state(self):
self.set_default_hypervisor()
self.widget("connection").set_active(0)
self.widget("transport").set_active(0)
self.widget("autoconnect").set_sensitive(True)
self.widget("autoconnect").set_active(True)
self.widget("hostname").get_model().clear()
@ -173,9 +192,9 @@ class vmmConnect(vmmGObjectUI):
def set_default_hypervisor(self):
default = self.default_uri(always_system=True)
if not default or default.startswith("qemu"):
self.widget("hypervisor").set_active(1)
self.widget("hypervisor").set_active(HV_QEMU)
elif default.startswith("xen"):
self.widget("hypervisor").set_active(0)
self.widget("hypervisor").set_active(HV_XEN)
def add_service(self, interface, protocol, name, typ, domain, flags):
ignore = flags
@ -293,7 +312,20 @@ class vmmConnect(vmmGObjectUI):
def hostname_changed(self, src_ignore):
self.populate_uri()
def hypervisor_changed(self, src_ignore):
def hypervisor_changed(self, src):
is_session = (src.get_active() == HV_QEMU_SESSION)
uiutil.set_grid_row_visible(
self.widget("session-warning-box"), is_session)
uiutil.set_grid_row_visible(
self.widget("connect-remote"), not is_session)
uiutil.set_grid_row_visible(
self.widget("username-entry"), not is_session)
uiutil.set_grid_row_visible(
self.widget("hostname"), not is_session)
uiutil.set_grid_row_visible(
self.widget("transport"), not is_session)
if is_session:
self.widget("connect-remote").set_active(False)
self.populate_uri()
def username_changed(self, src_ignore):
@ -302,14 +334,14 @@ class vmmConnect(vmmGObjectUI):
def connect_remote_toggled(self, src_ignore):
is_remote = self.is_remote()
self.widget("hostname").set_sensitive(is_remote)
self.widget("connection").set_sensitive(is_remote)
self.widget("transport").set_sensitive(is_remote)
self.widget("autoconnect").set_active(not is_remote)
self.widget("username-entry").set_sensitive(is_remote)
self.populate_default_user()
self.populate_uri()
def conn_changed(self, src_ignore):
def transport_changed(self, src_ignore):
self.populate_default_user()
self.populate_uri()
@ -318,13 +350,13 @@ class vmmConnect(vmmGObjectUI):
self.widget("uri-entry").set_text(uri)
def populate_default_user(self):
conn = self.widget("connection").get_active()
conn = self.widget("transport").get_active()
default_user = default_conn_user(conn)
self.widget("username-entry").set_text(default_user)
def generate_uri(self):
hv = self.widget("hypervisor").get_active()
conn = self.widget("connection").get_active()
conn = self.widget("transport").get_active()
host = self.widget("hostname").get_child().get_text().strip()
user = self.widget("username-entry").get_text()
is_remote = self.is_remote()
@ -332,7 +364,7 @@ class vmmConnect(vmmGObjectUI):
hvstr = ""
if hv == HV_XEN:
hvstr = "xen"
elif hv == HV_QEMU:
elif hv == HV_QEMU or HV_QEMU_SESSION:
hvstr = "qemu"
else:
hvstr = "lxc"
@ -357,6 +389,8 @@ class vmmConnect(vmmGObjectUI):
uri = hvstr + hoststr
if hv == HV_QEMU:
uri += "system"
elif hv == HV_QEMU_SESSION:
uri += "session"
return uri