These file systems drivers have been added in virtinst, but also in the addhardware UI. --- tests/xmlparse-xml/change-filesystems-in.xml | 5 ++ tests/xmlparse-xml/change-filesystems-out.xml | 6 ++ tests/xmlparse.py | 9 +++ ui/addhardware.ui | 76 ++++++++++++++++++++---- virtManager/addhardware.py | 84 ++++++++++++++++++--------- virtinst/devicefilesystem.py | 9 ++- 6 files changed, 147 insertions(+), 42 deletions(-) diff --git a/tests/xmlparse-xml/change-filesystems-in.xml b/tests/xmlparse-xml/change-filesystems-in.xml index 9a96997..5cb8010 100644 --- a/tests/xmlparse-xml/change-filesystems-in.xml +++ b/tests/xmlparse-xml/change-filesystems-in.xml @@ -50,5 +50,10 @@ <source dev='/foo/bar'/> <target dir='/bar/baz'/> </filesystem> + <filesystem type='file' accessmode='passthrough'> + <driver type='nbd' format='qcow'/> + <source file='/foo/bar.img'/> + <target dir='/bar/baz'/> + </filesystem> </devices> </domain> diff --git a/tests/xmlparse-xml/change-filesystems-out.xml b/tests/xmlparse-xml/change-filesystems-out.xml index 0662668..90fcf27 100644 --- a/tests/xmlparse-xml/change-filesystems-out.xml +++ b/tests/xmlparse-xml/change-filesystems-out.xml @@ -52,5 +52,11 @@ <target dir="/bar/baz"/> <readonly/> </filesystem> + <filesystem type="file"> + <driver type="loop" format="raw"/> + <source file="/foo/bar.raw"/> + <target dir="/bar/baz"/> + <readonly/> + </filesystem> </devices> </domain> diff --git a/tests/xmlparse.py b/tests/xmlparse.py index 173a47a..5e14968 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -608,6 +608,7 @@ class XMLParseTest(unittest.TestCase): dev4 = guest.get_devices("filesystem")[3] dev5 = guest.get_devices("filesystem")[4] dev6 = guest.get_devices("filesystem")[5] + dev7 = guest.get_devices("filesystem")[6] check = self._make_checker(dev1) check("type", None, "mount") @@ -647,6 +648,14 @@ class XMLParseTest(unittest.TestCase): check("source", "/foo/bar", "/dev/new") check("readonly", False, True) + check = self._make_checker(dev7) + check("type", "file") + check("mode", "passthrough", None) + check("driver", "nbd", "loop") + check("format", "qcow", "raw") + check("source", "/foo/bar.img", "/foo/bar.raw") + check("readonly", False, True) + self._alter_compare(guest.get_xml_config(), outfile) def testAlterSounds(self): diff --git a/ui/addhardware.ui b/ui/addhardware.ui index cd54086..1d8f17f 100644 --- a/ui/addhardware.ui +++ b/ui/addhardware.ui @@ -1802,7 +1802,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -1875,7 +1875,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -1888,7 +1888,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">6</property> + <property name="top_attach">7</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -1905,7 +1905,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">7</property> + <property name="top_attach">8</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -1945,7 +1945,7 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -1977,7 +1977,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">2</property> + <property name="top_attach">3</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -2009,7 +2009,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">3</property> + <property name="top_attach">4</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -2025,7 +2025,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -2041,7 +2041,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">6</property> + <property name="top_attach">7</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -2056,7 +2056,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">7</property> + <property name="top_attach">8</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -2072,7 +2072,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> <property name="width">1</property> <property name="height">1</property> </packing> @@ -2111,7 +2111,59 @@ </object> <packing> <property name="left_attach">1</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> + <property name="width">1</property> + <property name="height">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="fs-format-title"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Format:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">fs-format-combo</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="GtkHBox" id="fs-format-box"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkComboBox" id="fs-format-combo"> + <property name="visible">True</property> + <property name="can_focus">False</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="fs-format-label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Default</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </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> diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py index 3294fab..3807c3a 100644 --- a/virtManager/addhardware.py +++ b/virtManager/addhardware.py @@ -328,7 +328,15 @@ class vmmAddHardware(vmmGObjectUI): simple_store_set("fs-type-combo", [VirtualFilesystem.TYPE_MOUNT]) simple_store_set("fs-mode-combo", VirtualFilesystem.MODES) - simple_store_set("fs-driver-combo", VirtualFilesystem.DRIVERS) + if self.conn.is_qemu(): + simple_store_set("fs-driver-combo", [VirtualFilesystem.DRIVER_PATH, + VirtualFilesystem.DRIVER_HANDLE, + VirtualFilesystem.DRIVER_DEFAULT]) + elif self.conn.is_lxc(): + simple_store_set("fs-driver-combo", [VirtualFilesystem.DRIVER_LOOP, + VirtualFilesystem.DRIVER_NBD, + VirtualFilesystem.DRIVER_DEFAULT]) + simple_store_set("fs-format-combo", VirtualFilesystem.NBD_FORMATS) simple_store_set("fs-wrpolicy-combo", VirtualFilesystem.WRPOLICIES) self.show_pair_combo("fs-type", self.conn.is_openvz() or self.conn.is_lxc()) self.show_check_button("fs-readonly", @@ -520,6 +528,7 @@ class vmmAddHardware(vmmGObjectUI): self.widget("fs-type-combo").set_active(0) self.widget("fs-mode-combo").set_active(0) self.widget("fs-driver-combo").set_active(0) + self.widget("fs-format-combo").set_active(0) self.widget("fs-wrpolicy-combo").set_active(0) self.widget("fs-source").set_text("") self.widget("fs-target").set_text("") @@ -927,6 +936,14 @@ class vmmAddHardware(vmmGObjectUI): return combo.get_model()[combo.get_active()][0] + def get_config_fs_format(self): + name = "fs-format-combo" + combo = self.widget(name) + if not combo.get_visible(): + return None + + return combo.get_model()[combo.get_active()][0] + def get_config_fs_units(self): name = "fs-ram-units-combo" combo = self.widget(name) @@ -1308,22 +1325,42 @@ class vmmAddHardware(vmmGObjectUI): def browse_fs_source(self, ignore1): self._browse_file(self.widget("fs-source"), isdir=True) - def change_fs_type(self, src): - idx = src.get_active() - fstype = None + def update_fs_rows(self): + fstype = self.get_config_fs_type() + fsdriver = self.get_config_fs_driver() + ismount = bool( + fstype == VirtualFilesystem.TYPE_MOUNT or + self.conn.is_qemu()) + + show_mode = bool(ismount and + (fsdriver == VirtualFilesystem.DRIVER_PATH or + fsdriver == VirtualFilesystem.DRIVER_DEFAULT)) + uihelpers.set_grid_row_visible(self.widget("fs-mode-box"), show_mode) + + show_wrpol = bool(ismount and + fsdriver and (fsdriver == VirtualFilesystem.DRIVER_PATH or + fsdriver == VirtualFilesystem.DRIVER_HANDLE)) + uihelpers.set_grid_row_visible(self.widget("fs-wrpolicy-box"), + show_wrpol) + + show_ram_source = fstype == VirtualFilesystem.TYPE_RAM + uihelpers.set_grid_row_visible(self.widget("fs-ram-source-box"), show_ram_source) + uihelpers.set_grid_row_visible(self.widget("fs-source-box"), not show_ram_source) + + show_format = bool( + fsdriver == VirtualFilesystem.DRIVER_NBD) + uihelpers.set_grid_row_visible(self.widget("fs-format-box"), show_format) + self.show_pair_combo("fs-format", True) + show_mode_combo = False show_driver_combo = False show_wrpolicy_combo = self.conn.is_qemu() - - if idx >= 0 and src.get_visible(): - fstype = src.get_model()[idx][0] - - if fstype == virtinst.VirtualFilesystem.TYPE_TEMPLATE: + if fstype == VirtualFilesystem.TYPE_TEMPLATE: source_text = _("Te_mplate:") else: source_text = _("_Source path:") show_mode_combo = self.conn.is_qemu() - show_driver_combo = self.conn.is_qemu() + show_driver_combo = self.conn.is_qemu() or self.conn.is_lxc() self.widget("fs-source-title").set_text(source_text) self.widget("fs-source-title").set_use_underline(True) @@ -1331,25 +1368,11 @@ class vmmAddHardware(vmmGObjectUI): self.show_pair_combo("fs-driver", show_driver_combo) self.show_pair_combo("fs-wrpolicy", show_wrpolicy_combo) - show_ram_source = fstype == VirtualFilesystem.TYPE_RAM - uihelpers.set_grid_row_visible(self.widget("fs-ram-source-box"), show_ram_source) - uihelpers.set_grid_row_visible(self.widget("fs-source-box"), not show_ram_source) - - def change_fs_driver(self, src): - fsdriver = None - idx = src.get_active() - if idx >= 0 and src.get_visible(): - fsdriver = src.get_model()[idx][0] + def change_fs_type(self, ignore): + self.update_fs_rows() - show_mode = bool( - fsdriver == virtinst.VirtualFilesystem.DRIVER_PATH or - fsdriver == virtinst.VirtualFilesystem.DRIVER_DEFAULT) - uihelpers.set_grid_row_visible(self.widget("fs-mode-box"), show_mode) - - show_wrpol = bool( - fsdriver and fsdriver != virtinst.VirtualFilesystem.DRIVER_DEFAULT) - uihelpers.set_grid_row_visible(self.widget("fs-wrpolicy-box"), - show_wrpol) + def change_fs_driver(self, ignore): + self.update_fs_rows() def change_ram_units(self, ignore): units = self.get_config_fs_units() @@ -1804,6 +1827,7 @@ class vmmAddHardware(vmmGObjectUI): fstype = self.get_config_fs_type() readonly = self.get_config_fs_readonly() driver = self.get_config_fs_driver() + fsformat = self.get_config_fs_format() wrpolicy = self.get_config_fs_wrpolicy() units = self.get_config_fs_units() @@ -1834,6 +1858,10 @@ class vmmAddHardware(vmmGObjectUI): self._dev.readonly = readonly if driver: self._dev.driver = driver + if driver == VirtualFilesystem.DRIVER_LOOP: + self._dev.format = "raw" + elif driver == VirtualFilesystem.DRIVER_NBD: + self._dev.format = fsformat if wrpolicy: self._dev.wrpolicy = wrpolicy except Exception, e: diff --git a/virtinst/devicefilesystem.py b/virtinst/devicefilesystem.py index 46bb45f..2b1b0ba 100644 --- a/virtinst/devicefilesystem.py +++ b/virtinst/devicefilesystem.py @@ -46,9 +46,13 @@ class VirtualFilesystem(VirtualDevice): DRIVER_PATH = "path" DRIVER_HANDLE = "handle" - DRIVER_PROXY = "proxy" + DRIVER_LOOP = "loop" + DRIVER_NBD = "nbd" DRIVER_DEFAULT = "default" - DRIVERS = [DRIVER_PATH, DRIVER_HANDLE, DRIVER_PROXY, DRIVER_DEFAULT] + DRIVERS = [DRIVER_PATH, DRIVER_HANDLE, DRIVER_LOOP, DRIVER_NBD, DRIVER_DEFAULT] + + NBD_FORMATS = ["raw", "bochs", "cloop", "cow", "dmg", "iso", "qcow", + "qcow2", "qed", "vmdk", "vpc", "fat", "vhd", "vdi"] @staticmethod def type_to_source_prop(fs_type): @@ -83,6 +87,7 @@ class VirtualFilesystem(VirtualDevice): driver = XMLProperty("./driver/@type", default_cb=lambda s: None, default_name=DRIVER_DEFAULT) + format = XMLProperty("./driver/@format") readonly = XMLProperty("./readonly", is_bool=True) -- 1.8.5.2 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list