[gnome-boxes] installed-image: Support all qemu-img supported formats
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] installed-image: Support all qemu-img supported formats
- Date: Mon, 17 Jun 2013 09:23:28 +0000 (UTC)
commit 46aeb7efe134a2e2ac0989850b1fd9923b36b795
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Jun 17 07:41:14 2013 +0200
installed-image: Support all qemu-img supported formats
Support import of disk images of all formats that qemu-img supports.
https://bugzilla.gnome.org/show_bug.cgi?id=690757
src/installed-media.vala | 21 ++++++++++++++++++---
src/wizard-source.vala | 6 ++----
2 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/src/installed-media.vala b/src/installed-media.vala
index 4571a4e..2c39cf4 100644
--- a/src/installed-media.vala
+++ b/src/installed-media.vala
@@ -3,6 +3,15 @@
using GVirConfig;
private class Boxes.InstalledMedia : Boxes.InstallerMedia {
+ public const string[] supported_extensions = { ".qcow2", ".qcow2.gz",
+ ".qcow", ".qcow.gz",
+ ".img", ".img.gz",
+ ".cow", ".cow.gz",
+ ".vdi", ".vdi.gz",
+ ".vmdk", ".vmdk.gz",
+ ".vpc", ".vpc.gz",
+ ".cloop", ".cloop.gz" };
+
public override bool need_user_input_for_vm_creation { get { return false; } }
public override bool ready_to_create { get { return true; } }
public override bool live { get { return false; } }
@@ -28,9 +37,15 @@ private class Boxes.InstalledMedia : Boxes.InstallerMedia {
}
public InstalledMedia (string path) throws GLib.Error {
- if (!path.has_suffix (".qcow2") && !path.has_suffix (".qcow2.gz") &&
- !path.has_suffix (".img") && !path.has_suffix (".img.gz"))
- throw new Boxes.Error.INVALID (_("Only QEMU QCOW Image (v2) and raw formats supported."));
+ var supported = false;
+ foreach (var extension in supported_extensions) {
+ supported = path.has_suffix (extension);
+ if (supported)
+ break;
+ }
+
+ if (!supported)
+ throw new Boxes.Error.INVALID (_("Unsupoorted disk image format."));
device_file = path;
from_image = true;
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index 02e12e3..f41ac85 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -309,10 +309,8 @@ private class Boxes.WizardSource: GLib.Object {
dialog.local_only = true;
dialog.filter = new Gtk.FileFilter ();
dialog.filter.add_mime_type ("application/x-cd-image");
- dialog.filter.add_pattern ("*.img");
- dialog.filter.add_pattern ("*.img.gz");
- dialog.filter.add_pattern ("*.qcow2");
- dialog.filter.add_pattern ("*.qcow2.gz");
+ foreach (var extension in InstalledMedia.supported_extensions)
+ dialog.filter.add_pattern ("*" + extension);
var ret = false;
if (dialog.run () == Gtk.ResponseType.ACCEPT) {
uri = dialog.get_uri ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]