[gnome-boxes] libvirt: allow changing machine name
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] libvirt: allow changing machine name
- Date: Mon, 30 Jul 2012 17:13:50 +0000 (UTC)
commit 5499c3650e411732710d24cf3cc259c74b731b66
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Wed Jul 18 19:18:50 2012 +0200
libvirt: allow changing machine name
https://bugzilla.gnome.org/show_bug.cgi?id=680187
src/libvirt-machine.vala | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index 260b30e..823c09a 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -81,6 +81,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
public void update_domain_config () {
try {
domain_config = domain.get_config (GVir.DomainXMLFlags.NONE);
+ domain_config.bind_property ("title", this, "name", BindingFlags.DEFAULT);
var volume = get_storage_volume (connection, domain, null);
storage_volume_path = (volume != null)? volume.get_path () : null;
@@ -92,7 +93,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
public LibvirtMachine (CollectionSource source,
GVir.Connection connection,
GVir.Domain domain) throws GLib.Error {
- var config = domain.get_config (0);
+ var config = domain.get_config (GVir.DomainXMLFlags.INACTIVE);
var item_name = config.get_title () ?? domain.get_name ();
base (source, item_name);
@@ -273,11 +274,28 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
}
}
+ public void try_change_name (string name) throws Boxes.Error {
+ try {
+ // We use libvirt "title" for free form user name
+ domain_config.title = name;
+
+ // This will take effect only after next reboot, but we use pending/inactive config for name and title
+ domain.set_config (domain_config);
+ } catch (GLib.Error error) {
+ warning ("Failed to change title of box '%s' to '%s': %s",
+ domain.get_name (), name, error.message);
+ throw new Boxes.Error.INVALID ("Invalid libvirt title");
+ }
+ }
+
public override List<Pair<string, Widget>> get_properties (Boxes.PropertiesPage page) {
var list = new List<Pair<string, Widget>> ();
switch (page) {
case PropertiesPage.LOGIN:
+ add_string_property (ref list, _("Name"), name, (name) => {
+ try_change_name (name);
+ });
add_string_property (ref list, _("Virtualizer"), source.uri);
add_string_property (ref list, _("URI"), display.uri);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]