[gnome-boxes/allow-booting-from-cdrom] libvirt-machine-properties: Offer to boot from CDROM/DVD
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/allow-booting-from-cdrom] libvirt-machine-properties: Offer to boot from CDROM/DVD
- Date: Wed, 12 Jun 2019 14:52:34 +0000 (UTC)
commit 69d746383313a424f47ff36c67295aa5f3fb403c
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Jun 12 16:49:15 2019 +0200
libvirt-machine-properties: Offer to boot from CDROM/DVD
We have a "CD/DVD" option in "Devices & Shares" and that allows to
select a CD or DVD to be available inside the VM. It would be nice
being able to make this media bootable, in order to rescue a broken
system.
Fixes #34
src/libvirt-machine-properties.vala | 14 +++++++++++++-
src/vm-configurator.vala | 22 ++++++++++++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index 59673d23..1cb27e43 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -196,9 +196,21 @@ private void add_cdrom_property (GVirConfig.DomainDisk disk_config, ref List<Box
var button_label = new Gtk.Label ("");
var button = new Gtk.Button ();
button.add (button_label);
-
grid.add (button);
+ var can_boot_button = new Gtk.ToggleButton ();
+ can_boot_button.active = VMConfigurator.get_boot_device (machine.domain_config) ==
GVirConfig.DomainOsBootDevice.CDROM;
+ can_boot_button.label = can_boot_button.active ? _("Remove from boot") : _("Make it bootable");
+ can_boot_button.clicked.connect (() => {
+ var boot_device = can_boot_button.active ? GVirConfig.DomainOsBootDevice.CDROM :
GVirConfig.DomainOsBootDevice.HD;
+ can_boot_button.label = can_boot_button.active ? _("Remove from boot") : _("Make it bootable");
+
+ VMConfigurator.set_boot_device (machine.domain_config, boot_device);
+ machine.domain.set_config (machine.domain_config);
+ });
+ grid.add (can_boot_button);
+
+
if (empty)
// Translators: This is the text on the button to select an iso for the cd
button_label.set_text_with_mnemonic (_("_Select"));
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 798e9dd2..08bba189 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -332,6 +332,28 @@ public static void set_target_media_config (Domain domain,
domain.add_device (disk);
}
+ public static DomainOsBootDevice get_boot_device (Domain domain) {
+ var devices = domain.get_os ().get_boot_devices ();
+
+ return devices.first ().data;
+ }
+
+ public static void set_boot_device (Domain domain, DomainOsBootDevice boot_device) {
+ var os = new DomainOs ();
+ os.set_os_type (DomainOsType.HVM);
+
+ var old_os = domain.get_os ();
+ os.set_arch (old_os.get_arch ());
+ os.set_machine (old_os.get_machine ());
+
+ var boot_devices = new GLib.List<DomainOsBootDevice> ();
+ boot_devices.append (boot_device);
+
+ os.set_boot_devices (boot_devices);
+
+ domain.set_os (os);
+ }
+
private static void set_post_install_os_config (Domain domain) {
var os = new DomainOs ();
os.set_os_type (DomainOsType.HVM);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]