[gnome-boxes] Use floppy image for only Windows express install
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Use floppy image for only Windows express install
- Date: Tue, 10 Jan 2012 15:20:04 +0000 (UTC)
commit b4a62fdd7c08f61c0b5420863c728a75152ecfba
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Dec 4 19:00:32 2011 +0200
Use floppy image for only Windows express install
The underlying image remains the same for both Fedora and Windows but
now we tell libvirt to emulate a USB drive using that image for Fedora.
According to Lucas Meneghel Rodrigues <lmr redhat com>, floppy support
on Linux isn't reliable enough to depend on and having a floppy drive
can easily lead to weird kernel crashes.
https://bugzilla.gnome.org/show_bug.cgi?id=666956
src/Makefile.am | 1 +
src/fedora-installer.vala | 12 +++++++
src/unattended-installer.vala | 72 ++++++++++++++++++++++++-----------------
src/vm-configurator.vala | 28 +++-------------
src/win7-installer.vala | 2 +-
src/windows-installer.vala | 17 ++++++++++
src/winxp-installer.vala | 2 +-
7 files changed, 79 insertions(+), 55 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index d18c625..f327f80 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,6 +60,7 @@ gnome_boxes_SOURCES = \
vm-creator.vala \
vm-configurator.vala \
vnc-display.vala \
+ windows-installer.vala \
win7-installer.vala \
winxp-installer.vala \
wizard-source.vala \
diff --git a/src/fedora-installer.vala b/src/fedora-installer.vala
index 8b0f41c..357991f 100644
--- a/src/fedora-installer.vala
+++ b/src/fedora-installer.vala
@@ -7,12 +7,24 @@ private class Boxes.FedoraInstaller: UnattendedInstaller {
private File kernel_file;
private File initrd_file;
+ private string kernel_path;
+ private string initrd_path;
+
public FedoraInstaller.copy (InstallerMedia media) throws GLib.Error {
var source_path = get_unattended_dir ("fedora.ks");
base.copy (media, source_path, "ks.cfg");
}
+ public override void set_direct_boot_params (GVirConfig.DomainOs os) {
+ if (kernel_path == null || initrd_path == null)
+ return;
+
+ os.set_kernel (kernel_path);
+ os.set_ramdisk (initrd_path);
+ os.set_cmdline ("ks=hd:sdb:" + unattended_dest_name);
+ }
+
protected override async void prepare_direct_boot (Cancellable? cancellable) throws GLib.Error {
if (!express_toggle.active)
return;
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 4fc47f2..323552d 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -1,19 +1,12 @@
// This file is part of GNOME Boxes. License: LGPLv2+
+using GVirConfig;
+
public errordomain UnattendedInstallerError {
COMMAND_FAILED
}
private abstract class Boxes.UnattendedInstaller: InstallerMedia {
- public string kernel_path;
- public string initrd_path;
-
- public string _floppy_path;
- public string floppy_path {
- get { return express_toggle.active ? _floppy_path : null; }
- private set { _floppy_path = value; }
- }
-
public bool express_install {
get { return express_toggle.active; }
}
@@ -37,7 +30,9 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
protected string unattended_dest_name;
protected DataStreamNewlineType newline_type;
- private bool created_floppy;
+ protected string disk_path;
+
+ private bool created_disk;
protected Gtk.Table setup_table;
protected Gtk.Label setup_label;
@@ -79,7 +74,7 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
from_image = media.from_image;
mount_point = media.mount_point;
- floppy_path = get_pkgcache (os.short_id + "-unattended.img");
+ disk_path = get_pkgcache (os.short_id + "-unattended.img");
this.unattended_src_path = unattended_src_path;
this.unattended_dest_name = unattended_dest_name;
newline_type = DataStreamNewlineType.LF;
@@ -106,10 +101,10 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
}
try {
- if (yield unattended_floppy_exists (cancellable))
- debug ("Found previously created unattended floppy image for '%s', re-using..", os.short_id);
+ if (yield unattended_disk_exists (cancellable))
+ debug ("Found previously created unattended disk image for '%s', re-using..", os.short_id);
else
- yield create_floppy_image (cancellable);
+ yield create_disk_image (cancellable);
yield copy_unattended_file (cancellable);
yield prepare_direct_boot (cancellable);
@@ -125,6 +120,23 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
setup_vbox.pack_start (setup_hbox, false, false);
}
+ public virtual void set_direct_boot_params (DomainOs os) {}
+
+ public virtual DomainDisk? get_unattended_disk_config () {
+ if (disk_path == null)
+ return null;
+
+ var disk = new DomainDisk ();
+ disk.set_type (DomainDiskType.FILE);
+ disk.set_guest_device_type (DomainDiskGuestDeviceType.DISK);
+ disk.set_driver_name ("qemu");
+ disk.set_driver_type ("raw");
+ disk.set_source (disk_path);
+ disk.set_target_dev ("sdb");
+
+ return disk;
+ }
+
protected virtual void setup_ui () {
setup_label = new Gtk.Label (_("Choose express install to automatically preconfigure the box with optimal settings."));
setup_label.halign = Gtk.Align.START;
@@ -201,14 +213,14 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
}
protected virtual void clean_up () throws GLib.Error {
- if (!created_floppy)
+ if (!created_disk)
return;
- var floppy_file = File.new_for_path (floppy_path);
+ var disk_file = File.new_for_path (disk_path);
- floppy_file.delete ();
+ disk_file.delete ();
- debug ("Removed '%s'.", floppy_path);
+ debug ("Removed '%s'.", disk_path);
}
protected virtual string fill_unattended_data (string data) throws RegexError {
@@ -252,16 +264,16 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
throw error;
}
- private async void create_floppy_image (Cancellable? cancellable) throws GLib.Error {
- var floppy_file = File.new_for_path (floppy_path);
- var template_path = get_unattended_dir ("floppy.img");
+ private async void create_disk_image (Cancellable? cancellable) throws GLib.Error {
+ var disk_file = File.new_for_path (disk_path);
+ var template_path = get_unattended_dir ("disk.img");
var template_file = File.new_for_path (template_path);
- debug ("Creating floppy image for unattended installation at '%s'..", floppy_path);
- yield template_file.copy_async (floppy_file, 0, Priority.DEFAULT, cancellable);
- debug ("Floppy image for unattended installation created at '%s'", floppy_path);
+ debug ("Creating disk image for unattended installation at '%s'..", disk_path);
+ yield template_file.copy_async (disk_file, 0, Priority.DEFAULT, cancellable);
+ debug ("Floppy image for unattended installation created at '%s'", disk_path);
- created_floppy = true;
+ created_disk = true;
}
private async void copy_unattended_file (Cancellable? cancellable) throws GLib.Error {
@@ -271,13 +283,13 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
create_unattended_file (unattended_src, unattended_tmp, cancellable);
- debug ("Copying unattended file '%s' into floppy drive/image '%s'", unattended_dest_name, floppy_path);
+ debug ("Copying unattended file '%s' into disk drive/image '%s'", unattended_dest_name, disk_path);
// FIXME: Perhaps we should use libarchive for this?
- string[] argv = { "mcopy", "-n", "-o", "-i", floppy_path,
+ string[] argv = { "mcopy", "-n", "-o", "-i", disk_path,
unattended_tmp_path,
"::" + unattended_dest_name };
yield exec (argv, cancellable);
- debug ("Copied unattended file '%s' into floppy drive/image '%s'", unattended_dest_name, floppy_path);
+ debug ("Copied unattended file '%s' into disk drive/image '%s'", unattended_dest_name, disk_path);
debug ("Deleting temporary file '%s'", unattended_tmp_path);
unattended_tmp.delete (cancellable);
@@ -308,8 +320,8 @@ private abstract class Boxes.UnattendedInstaller: InstallerMedia {
debug ("Created unattended file at '%s'..", destination.get_path ());
}
- private async bool unattended_floppy_exists (Cancellable? cancellable) {
- var file = File.new_for_path (floppy_path);
+ private async bool unattended_disk_exists (Cancellable? cancellable) {
+ var file = File.new_for_path (disk_path);
try {
yield file.read_async (Priority.DEFAULT, cancellable);
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 1883372..7392062 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -26,7 +26,7 @@ private class Boxes.VMConfigurator {
domain.set_clock (clock);
set_target_media_config (domain, target_path);
- set_unattended_floppy_config (domain, install_media);
+ set_unattended_disk_config (domain, install_media);
set_source_media_config (domain, install_media);
var input = new DomainInput ();
@@ -133,22 +133,14 @@ private class Boxes.VMConfigurator {
domain.add_device (disk);
}
- private void set_unattended_floppy_config (Domain domain, InstallerMedia install_media) {
+ private void set_unattended_disk_config (Domain domain, InstallerMedia install_media) {
if (!(install_media is UnattendedInstaller))
return;
- var floppy_path = (install_media as UnattendedInstaller).floppy_path;
- if (floppy_path == null)
+ var disk = (install_media as UnattendedInstaller).get_unattended_disk_config ();
+ if (disk == null)
return;
- var disk = new DomainDisk ();
- disk.set_type (DomainDiskType.FILE);
- disk.set_guest_device_type (DomainDiskGuestDeviceType.FLOPPY);
- disk.set_driver_name ("qemu");
- disk.set_driver_type ("raw");
- disk.set_source (floppy_path);
- disk.set_target_dev ("fd");
-
domain.add_device (disk);
}
@@ -172,17 +164,7 @@ private class Boxes.VMConfigurator {
if (!(install_media is UnattendedInstaller))
return;
- var unattended = install_media as UnattendedInstaller;
-
- var kernel_path = unattended.kernel_path;
- var initrd_path = unattended.initrd_path;
-
- if (kernel_path == null || initrd_path == null)
- return;
-
- os.set_kernel (kernel_path);
- os.set_ramdisk (initrd_path);
- os.set_cmdline ("ks=floppy");
+ (install_media as UnattendedInstaller).set_direct_boot_params (os);
}
private void set_video_config (Domain domain, InstallerMedia install_media) {
diff --git a/src/win7-installer.vala b/src/win7-installer.vala
index 5398fa1..88ea01d 100644
--- a/src/win7-installer.vala
+++ b/src/win7-installer.vala
@@ -1,7 +1,7 @@
// This file is part of GNOME Boxes. License: LGPLv2+
// Automated installer media for Windows 7 and 2008
-private class Boxes.Win7Installer: UnattendedInstaller {
+private class Boxes.Win7Installer: WindowsInstaller {
public Win7Installer.copy (InstallerMedia media) throws GLib.Error {
var unattended_source = get_unattended_dir (media.os.short_id + ".xml");
base.copy (media, unattended_source, "Autounattend.xml");
diff --git a/src/windows-installer.vala b/src/windows-installer.vala
new file mode 100644
index 0000000..012d5da
--- /dev/null
+++ b/src/windows-installer.vala
@@ -0,0 +1,17 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+using GVirConfig;
+
+// Automated installer media for Windows.
+private abstract class Boxes.WindowsInstaller: UnattendedInstaller {
+ public override DomainDisk? get_unattended_disk_config () {
+ var disk = base.get_unattended_disk_config ();
+ if (disk == null)
+ return null;
+
+ disk.set_guest_device_type (DomainDiskGuestDeviceType.FLOPPY);
+ disk.set_target_dev ("fd");
+
+ return disk;
+ }
+}
diff --git a/src/winxp-installer.vala b/src/winxp-installer.vala
index 5803994..0b08133 100644
--- a/src/winxp-installer.vala
+++ b/src/winxp-installer.vala
@@ -1,7 +1,7 @@
// This file is part of GNOME Boxes. License: LGPLv2+
// Automated installer media for Windows XP, 2000 and 2003
-private class Boxes.WinXPInstaller: UnattendedInstaller {
+private class Boxes.WinXPInstaller: WindowsInstaller {
private const uint[] allowed_dash_positions = { 5, 11, 17, 23 };
private static Regex key_regex;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]