[gnome-boxes] Create transient domains for pure live media
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Create transient domains for pure live media
- Date: Fri, 25 Nov 2011 23:04:22 +0000 (UTC)
commit b6aa23bb1d31d3c29ff88248e0b72bde6a726e9f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Nov 24 22:29:34 2011 +0200
Create transient domains for pure live media
For medias that do not provide an installer, we now create and launch a
transient domain w/o any storage media.
https://bugzilla.gnome.org/show_bug.cgi?id=664766
configure.ac | 2 +-
src/unattended-installer.vala | 2 +-
src/vm-creator.vala | 45 ++++++++++++++++++++++++++--------------
3 files changed, 31 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dea5237..c76a963 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ GLIB_MIN_VERSION=2.29.90
GOBJECT_INTROSPECTION_MIN_VERSION=0.9.6
GTK_MIN_VERSION=3.3.3
GTK_VNC_MIN_VERSION=0.4.4
-LIBVIRT_GLIB_MIN_VERSION=0.0.2
+LIBVIRT_GLIB_MIN_VERSION=0.0.3
LIBVIRT_GCONFIG_MIN_VERSION=0.0.1
LIBXML2_MIN_VERSION=2.7.8
SPICE_GTK_MIN_VERSION=0.7.81
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 2600601..2462125 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -95,7 +95,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
table.attach_defaults (label, 1, 2, 0, 1);
express_toggle = new Gtk.Switch ();
- express_toggle.active = true;
+ express_toggle.active = os_media.installer;
express_toggle.halign = Gtk.Align.START;
express_toggle.valign = Gtk.Align.CENTER;
table.attach_defaults (express_toggle, 2, 3, 0, 1);
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index c95c158..67e4069 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -33,22 +33,28 @@ private class Boxes.VMCreator {
else
name = install_media.label;
- var target_path = yield create_target_volume (name, resources.storage);
+ string target_path = null;
+ if (install_media.os_media.installer)
+ target_path = yield create_target_volume (name, resources.storage);
var xml = get_virt_xml (install_media, name, target_path, resources);
var config = new GVirConfig.Domain.from_xml (xml);
- var domain = connection.create_domain (config);
+ Domain domain;
+ if (install_media.os_media.installer) {
+ domain = connection.create_domain (config);
+ domain.start (0);
- domain.start (0);
+ // FIXME: We really should use GVirConfig API (as soon as its available) to modify the configuration XML.
+ xml = domain.get_config (0).to_xml ();
+ xml = direct_boot_regex.replace (xml, -1, 0, "");
+ xml = cdrom_boot_regex.replace (xml, -1, 0, "");
+ config = new GVirConfig.Domain.from_xml (xml);
- // FIXME: We really should use GVirConfig API (as soon as its available) to modify the configuration XML.
- xml = domain.get_config (0).to_xml ();
- xml = direct_boot_regex.replace (xml, -1, 0, "");
- xml = cdrom_boot_regex.replace (xml, -1, 0, "");
- config = new GVirConfig.Domain.from_xml (xml);
-
- domain.set_config (config);
+ domain.set_config (config);
+ } else
+ // We create a transient domain for media w/o an installer
+ domain = connection.start_domain (config, 0);
return domain;
}
@@ -59,7 +65,7 @@ private class Boxes.VMCreator {
yield connection.fetch_storage_pools_async (cancellable);
}
- private string get_virt_xml (InstallerMedia install_media, string name, string target_path, Resources resources) {
+ private string get_virt_xml (InstallerMedia install_media, string name, string? target_path, Resources resources) {
// FIXME: This information should come from libosinfo
var clock_offset = "utc";
if (install_media.os != null && install_media.os.short_id.contains ("win"))
@@ -88,11 +94,7 @@ private class Boxes.VMCreator {
" <on_reboot>restart</on_reboot>\n" +
" <on_crash>destroy</on_crash>\n" +
" <devices>\n" +
- " <disk type='file' device='disk'>\n" +
- " <driver name='qemu' type='qcow2'/>\n" +
- " <source file='" + target_path + "'/>\n" +
- " <target dev='hda' bus='ide'/>\n" +
- " </disk>\n" +
+ get_target_media_xml (target_path) +
get_unattended_dir_floppy_xml (install_media) +
get_source_media_xml (install_media) +
" <interface type='user'>\n" +
@@ -136,6 +138,17 @@ private class Boxes.VMCreator {
return volume.get_path ();
}
+ private string get_target_media_xml (string? target_path) {
+ if (target_path == null)
+ return "";
+
+ return " <disk type='file' device='disk'>\n" +
+ " <driver name='qemu' type='qcow2'/>\n" +
+ " <source file='" + target_path + "'/>\n" +
+ " <target dev='hda' bus='ide'/>\n" +
+ " </disk>\n";
+ }
+
private string get_source_media_xml (InstallerMedia install_media) {
string type, source_attr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]