[gnome-boxes] Introducing libvirt system importing classes
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Introducing libvirt system importing classes
- Date: Tue, 19 Nov 2013 14:28:53 +0000 (UTC)
commit bd756dd95384239ccd0b66ce7963e6008eb64a7a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Nov 15 16:50:18 2013 +0000
Introducing libvirt system importing classes
a. LibvirtSystemMedia: Represents main disks of system libvirt domains.
b. LibvirtSystemVMImporter: A subclass of VMImporter that will be
responsible for importing a VM from system libvirt.
https://bugzilla.gnome.org/show_bug.cgi?id=666185
src/Makefile.am | 2 +
src/libvirt-system-media.vala | 28 +++++++++++++++++++
src/libvirt-system-vm-importer.vala | 50 +++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 12c41db..78d712a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,6 +88,7 @@ gnome_boxes_SOURCES = \
i-properties-provider.vala \
installer-media.vala \
installed-media.vala \
+ libvirt-system-media.vala \
iso-extractor.vala \
libvirt-broker.vala \
libvirt-machine.vala \
@@ -113,6 +114,7 @@ gnome_boxes_SOURCES = \
vm-configurator.vala \
vm-creator.vala \
vm-importer.vala \
+ libvirt-system-vm-importer.vala \
vnc-display.vala \
wizard-source.vala \
wizard.vala \
diff --git a/src/libvirt-system-media.vala b/src/libvirt-system-media.vala
new file mode 100644
index 0000000..030f5d4
--- /dev/null
+++ b/src/libvirt-system-media.vala
@@ -0,0 +1,28 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+using GVirConfig;
+
+private class Boxes.LibvirtSystemMedia : Boxes.InstalledMedia {
+ protected override string? architecture {
+ owned get {
+ return domain_config.get_os ().get_arch ();
+ }
+ }
+
+ public Domain domain_config { get; private set; }
+
+ public LibvirtSystemMedia (string path, Domain domain_config) throws GLib.Error {
+ base (path);
+
+ this.domain_config = domain_config;
+ label = domain_config.title?? domain_config.name;
+
+ // Just initializing for sake for completion (and to avoid crashes). The CPU & RAM config comes from
the
+ // imported domain and storage volume is overwritten as well.
+ resources = OSDatabase.get_default_resources ();
+ }
+
+ public override VMCreator get_vm_creator () {
+ return new LibvirtSystemVMImporter (this);
+ }
+}
diff --git a/src/libvirt-system-vm-importer.vala b/src/libvirt-system-vm-importer.vala
new file mode 100644
index 0000000..6191d3f
--- /dev/null
+++ b/src/libvirt-system-vm-importer.vala
@@ -0,0 +1,50 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+using Osinfo;
+using GVirConfig;
+
+private class Boxes.LibvirtSystemVMImporter : Boxes.VMImporter {
+ public LibvirtSystemVMImporter (InstalledMedia source_media) {
+ base (source_media);
+ start_after_import = false;
+ }
+
+ public LibvirtSystemVMImporter.for_import_completion (LibvirtMachine machine) {
+ base.for_install_completion (machine);
+ start_after_import = false;
+ }
+
+ protected override void create_domain_base_name_and_title (out string base_name, out string base_title) {
+ var media = install_media as LibvirtSystemMedia;
+
+ base_name = media.domain_config.name;
+ base_title = media.domain_config.title?? base_name;
+ }
+
+ protected override async Domain create_domain_config (string name,
+ string title,
+ GVir.StorageVol volume,
+ Cancellable? cancellable) throws GLib.Error {
+ var media = install_media as LibvirtSystemMedia;
+ var config = media.domain_config;
+
+ config.name = name;
+ config.title = title;
+
+ var devices = config.get_devices ();
+ foreach (var device in devices) {
+ if (!(device is DomainDisk))
+ continue;
+
+ var disk = device as DomainDisk;
+ if (disk.get_source () == media.device_file) {
+ disk.set_source (volume.get_path ());
+
+ break;
+ }
+ }
+ config.set_devices (devices);
+
+ return config;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]