[gnome-boxes] installer: Clean-up resources after installation
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] installer: Clean-up resources after installation
- Date: Fri, 21 Dec 2012 16:11:38 +0000 (UTC)
commit 4e1c6059b77175fbe13f764f6aa7d1d016129036
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Dec 20 03:56:34 2012 +0200
installer: Clean-up resources after installation
This currently only applies to unattended installations and it means
deletion of unattended disk, kernel and initrd files.
https://bugzilla.gnome.org/show_bug.cgi?id=690536
src/installer-media.vala | 1 +
src/unattended-installer.vala | 40 +++++++++++++++++++++++-----------------
src/vm-creator.vala | 2 ++
3 files changed, 26 insertions(+), 17 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index a2ffb59..88b0809 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -73,6 +73,7 @@ private class Boxes.InstallerMedia : GLib.Object {
public virtual void set_direct_boot_params (DomainOs os) {}
public virtual async void prepare_for_installation (string vm_name, Cancellable? cancellable) throws GLib.Error {}
public virtual void prepare_to_continue_installation (string vm_name) {}
+ public virtual void clean_up () {}
public virtual void setup_domain_config (Domain domain) {
add_cd_config (domain, from_image? DomainDiskType.FILE : DomainDiskType.BLOCK, device_file, "hdc", true);
diff --git a/src/unattended-installer.vala b/src/unattended-installer.vala
index 9439efb..c895398 100644
--- a/src/unattended-installer.vala
+++ b/src/unattended-installer.vala
@@ -264,6 +264,29 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
os.set_cmdline (cmdline);
}
+ public override void clean_up () {
+ base.clean_up ();
+
+ try {
+ if (disk_file != null) {
+ delete_file (disk_file);
+ disk_file = null;
+ }
+
+ if (kernel_file != null) {
+ delete_file (kernel_file);
+ kernel_file = null;
+ }
+
+ if (initrd_file != null) {
+ delete_file (initrd_file);
+ initrd_file = null;
+ }
+ } catch (GLib.Error error) {
+ debug ("Failed to clean-up: %s", error.message);
+ }
+ }
+
public string get_user_unattended (string? suffix = null) {
var filename = hostname;
if (suffix != null)
@@ -443,23 +466,6 @@ private class Boxes.UnattendedInstaller: InstallerMedia {
Signal.stop_emission_by_name (key_entry, "insert-text");
}
- private void clean_up () throws GLib.Error {
- if (disk_file != null) {
- delete_file (disk_file);
- disk_file = null;
- }
-
- if (kernel_file != null) {
- delete_file (kernel_file);
- kernel_file = null;
- }
-
- if (initrd_file != null) {
- delete_file (initrd_file);
- initrd_file = null;
- }
- }
-
private DomainDisk? get_unattended_disk_config () {
if (!express_toggle.active)
return null;
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index d469b3a..40e56b7 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -126,6 +126,7 @@ private class Boxes.VMCreator {
if (guest_installed_os (machine)) {
set_post_install_config (machine);
+ install_media.clean_up ();
try {
domain.start (0);
} catch (GLib.Error error) {
@@ -139,6 +140,7 @@ private class Boxes.VMCreator {
if (VMConfigurator.is_live_config (machine.domain_config)) {
// No installation during live session, so lets delete the VM
machine.disconnect (state_changed_id);
+ install_media.clean_up ();
App.app.delete_machine (machine);
} else
try {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]