After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688770 - Don't lose means to detect completion of installation
Don't lose means to detect completion of installation
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: installer
unspecified
Other All
: Normal normal
: --
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks: 688333 688334
 
 
Reported: 2012-11-21 00:26 UTC by Zeeshan Ali
Modified: 2016-03-31 13:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make MediaManager a singleton (2.52 KB, patch)
2012-11-21 00:26 UTC, Zeeshan Ali
committed Details | Review
vm-configuration: Save media & OS info for new VMs (4.46 KB, patch)
2012-11-21 00:26 UTC, Zeeshan Ali
none Details | Review
installer-media: Mark nullable constructor params as such (1.05 KB, patch)
2012-11-21 00:27 UTC, Zeeshan Ali
committed Details | Review
vm-configurator: Add get_source_media_path() (1.45 KB, patch)
2012-11-21 00:27 UTC, Zeeshan Ali
committed Details | Review
media-manager: Add create_installer_media_from_config (2.10 KB, patch)
2012-11-21 00:27 UTC, Zeeshan Ali
committed Details | Review
vm-creator: Info on install media now guaranteed (2.83 KB, patch)
2012-11-21 00:27 UTC, Zeeshan Ali
accepted-commit_now Details | Review
vm-configurator: Refactor custom XML setting code (4.68 KB, patch)
2012-11-21 00:27 UTC, Zeeshan Ali
none Details | Review
vm-creator: Save number of reboots for VM under installation (4.49 KB, patch)
2012-11-21 00:27 UTC, Zeeshan Ali
committed Details | Review
vm-configuration: Save media & OS info for new VMs (4.99 KB, patch)
2012-11-23 17:27 UTC, Zeeshan Ali
committed Details | Review
vm-configurator: Refactor custom XML setting code (4.81 KB, patch)
2012-11-23 17:30 UTC, Zeeshan Ali
committed Details | Review
vm-creator: Info on install media now guaranteed (3.29 KB, patch)
2012-11-26 16:17 UTC, Zeeshan Ali
committed Details | Review

Description Zeeshan Ali 2012-11-21 00:26:52 UTC
Currently we lose the means to detect completion of installation if user exits Boxes before installation could be completed. These patches fixes this by adding more information about the VM to the domain's config: OS, media and number of reboots (last one only kept for VM under installation but the rest are saved permenantly).
Comment 1 Zeeshan Ali 2012-11-21 00:26:55 UTC
Created attachment 229523 [details] [review]
Make MediaManager a singleton
Comment 2 Zeeshan Ali 2012-11-21 00:26:58 UTC
Created attachment 229524 [details] [review]
vm-configuration: Save media & OS info for new VMs

We now put all the custom XML under a toplevel 'gnome-boxes' node. This
breaks compatibility with existing under installation and live boxes out
there but in the sense that Boxes will think that those boxes are already
in installed state. Do we really need to care enough for those cases here
to complicate code and resulting XML?
Comment 3 Zeeshan Ali 2012-11-21 00:27:00 UTC
Created attachment 229525 [details] [review]
installer-media: Mark nullable constructor params as such
Comment 4 Zeeshan Ali 2012-11-21 00:27:03 UTC
Created attachment 229526 [details] [review]
vm-configurator: Add get_source_media_path()

Add a method for retreiving the installer media from domain config.
Comment 5 Zeeshan Ali 2012-11-21 00:27:06 UTC
Created attachment 229528 [details] [review]
media-manager: Add create_installer_media_from_config

Add a method for creation of InstallerMedia from domain config.
Comment 6 Zeeshan Ali 2012-11-21 00:27:09 UTC
Created attachment 229529 [details] [review]
vm-creator: Info on install media now guaranteed

After this patch, VMCreator instance always have access to information
on original installation media even if Boxes is quit during
installation/live session.
Comment 7 Zeeshan Ali 2012-11-21 00:27:12 UTC
Created attachment 229530 [details] [review]
vm-configurator: Refactor custom XML setting code

Refactor custom XML creation and setting into one function.
Comment 8 Zeeshan Ali 2012-11-21 00:27:15 UTC
Created attachment 229531 [details] [review]
vm-creator: Save number of reboots for VM under installation

This means that now we don't lose means to detect completion of
installation just because user quit Boxes before installation was
completed.
Comment 9 Alexander Larsson 2012-11-22 12:32:20 UTC
Review of attachment 229523 [details] [review]:

ack
Comment 10 Alexander Larsson 2012-11-22 13:07:31 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +30,3 @@
+            custom_xml += OS_ID_XML.printf (install_media.os.id);
+        if (install_media.os_media != null)
+            custom_xml += MEDIA_ID_XML.printf (install_media.os_media.id);

Shouldn't these use Markup.printf_escaped to handle weird chars in the arguments.

@@ +186,3 @@
     private static void mark_as_installed (Domain domain) {
         try {
+            var custom_xml = BOXES_XML.printf (INSTALLED_XML);

This seems to override the other settings?
Comment 11 Alexander Larsson 2012-11-22 13:09:41 UTC
Review of attachment 229525 [details] [review]:

ack
Comment 12 Alexander Larsson 2012-11-22 13:25:42 UTC
Review of attachment 229526 [details] [review]:

ack
Comment 13 Alexander Larsson 2012-11-22 13:36:14 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +307,3 @@
                                                         Xml.ParserOption.COMPACT);
             do {
+                if (reader.name () == node_name)

Does this really work right?
Its seems to me like this iterates over all toplevel nodes in the custom xml, which for new data would be a single "gnome-boxes" node.

Also, it wouldn't be too bad to add some backwards compat here. If the toplevel is a "gnome-boxes" child, enumarate children of that. Otherwise enumerate the toplevel node.
Comment 14 Alexander Larsson 2012-11-22 13:42:47 UTC
Review of attachment 229530 [details] [review]:

::: src/vm-configurator.vala
@@ +342,3 @@
+            domain.set_custom_xml (custom_xml, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }

I worry somewhat over this. It overwrites *all* custom XML nodes, which is fine as long as you write every node. However, for the future case were we might add a new child it causes us to move said node if you ever run an older version of boxes, which might happen if you share homedir with multiple versions of boxes.

Not sure how much we care about this though, I can't decide...
Comment 15 Zeeshan Ali 2012-11-22 14:56:17 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +186,3 @@
     private static void mark_as_installed (Domain domain) {
         try {
+            var custom_xml = BOXES_XML.printf (INSTALLED_XML);

yikes, thats true. Feel a bit lazy to fix it though since its corrected by following changes.
Comment 16 Zeeshan Ali 2012-11-22 15:12:18 UTC
Review of attachment 229530 [details] [review]:

::: src/vm-configurator.vala
@@ +342,3 @@
+            domain.set_custom_xml (custom_xml, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }

No, set_custom_xml is taking a namespace and namespace_uri for a reason. Also we only set this XML during and at the end of installations, only read after that point.
Comment 17 Zeeshan Ali 2012-11-22 15:14:37 UTC
Review of attachment 229530 [details] [review]:

::: src/vm-configurator.vala
@@ +342,3 @@
+            domain.set_custom_xml (custom_xml, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }

to be clear, we are only overwriting our own 'gnome-boxes' node here.
Comment 18 Zeeshan Ali 2012-11-22 15:28:09 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +307,3 @@
                                                         Xml.ParserOption.COMPACT);
             do {
+                if (reader.name () == node_name)

The custom xml is the gnome-boxes node here, not its parent 'metadata' node in the config. Also, I have indeed tested this and AFAICT, it didn't break anything.

As I mentioned in the log, backwards compatiblity isn't really important here but now that i think about it again, it *is* important for live VMs that people would want to keep around in their "live" state..
Comment 19 Alexander Larsson 2012-11-22 18:02:02 UTC
Review of attachment 229530 [details] [review]:

::: src/vm-configurator.vala
@@ +342,3 @@
+            domain.set_custom_xml (custom_xml, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }

I understand that. I'm saying, a later version of boxes may put more inside the gnome-boxes node, and an older version of boxes sharing the home dir, may remove this node if it updates custom_xml.
Comment 20 Alexander Larsson 2012-11-22 18:04:05 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +307,3 @@
                                                         Xml.ParserOption.COMPACT);
             do {
+                if (reader.name () == node_name)

I didn't notice you changed it from iterating shallowly to iterating deeply.
I think this is wrong. You should only look at the toplevel, in case we later add our own nodes that have hierarchical structure.
Comment 21 Zeeshan Ali 2012-11-22 21:29:14 UTC
Review of attachment 229530 [details] [review]:

::: src/vm-configurator.vala
@@ +342,3 @@
+            domain.set_custom_xml (custom_xml, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }

I think anyone modifying boxes code in future to add more nodes should be looking at the existing custom xml handling code (which are just two simple functions) and should realize that he/she needs to also change how these functions work.
Comment 22 Zeeshan Ali 2012-11-22 21:33:36 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +307,3 @@
                                                         Xml.ParserOption.COMPACT);
             do {
+                if (reader.name () == node_name)

ah so we want both backward and forward compatibility. :) I think I know how to achieve that but it will make this code slightly more complicated..

NB: I think it will point to some fundamental problem with libvirt if we start to need a tree inside this custom node.
Comment 23 Zeeshan Ali 2012-11-23 17:27:59 UTC
Created attachment 229731 [details] [review]
vm-configuration: Save media & OS info for new VMs

We now put all the custom XML under a toplevel 'gnome-boxes' node. We do
this without breaking compatibility with existing under installation and
live boxes out there.

Currently this info is only there during the installation but the patch
to make it permanent follows in the same patch series as this.
Comment 24 Zeeshan Ali 2012-11-23 17:30:55 UTC
Created attachment 229733 [details] [review]
vm-configurator: Refactor custom XML setting code

Refactor custom XML creation and setting into one function.

This also makes the OS and media info in the domain config, permanent.
Comment 25 Alexander Larsson 2012-11-26 08:47:21 UTC
Review of attachment 229530 [details] [review]:

::: src/vm-configurator.vala
@@ +342,3 @@
+            domain.set_custom_xml (custom_xml, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }

How would you in the future change existing shipped boxes code? We want to make the current code we release supportable in the future if we need to extend the set of custom data.
Comment 26 Alexander Larsson 2012-11-26 08:49:19 UTC
Review of attachment 229524 [details] [review]:

::: src/vm-configurator.vala
@@ +307,3 @@
                                                         Xml.ParserOption.COMPACT);
             do {
+                if (reader.name () == node_name)

It not necessarily compatible in both directions. We want to properly read data from old toplevel-less nodes, as well as the new ones. We unfortunately can't make older versions handle the new toplevel.
Comment 27 Alexander Larsson 2012-11-26 08:51:03 UTC
Review of attachment 229731 [details] [review]:

Not sure exactly how this goes in the series, but this looks very right to me.
Comment 28 Alexander Larsson 2012-11-26 08:53:17 UTC
Review of attachment 229733 [details] [review]:

looks good
Comment 29 Alexander Larsson 2012-11-26 15:34:42 UTC
Review of attachment 229528 [details] [review]:

ack
Comment 30 Alexander Larsson 2012-11-26 15:34:45 UTC
Review of attachment 229529 [details] [review]:

ack
Comment 31 Alexander Larsson 2012-11-26 15:34:53 UTC
Review of attachment 229531 [details] [review]:

ack
Comment 32 Alexander Larsson 2012-11-26 15:37:34 UTC
I think this looks good to get in.

however, i still worry a bit about how when updating the custom xml we basically rewrite the whole thing. That may very well bite us in the future when we add new things in later versions and they are deleted by older versions running in the same homedir (like say you're sharing a /home partition and boot different distros as / with different boxes versions).
Comment 33 Zeeshan Ali 2012-11-26 15:52:08 UTC
(In reply to comment #32)
> I think this looks good to get in.

Thanks for reviewing.

> however, i still worry a bit about how when updating the custom xml we
> basically rewrite the whole thing. That may very well bite us in the future
> when we add new things in later versions and they are deleted by older versions
> running in the same homedir (like say you're sharing a /home partition and boot
> different distros as / with different boxes versions).

Yeah, I've added in my todo to improve the custom xml writing code.
Comment 34 Zeeshan Ali 2012-11-26 16:17:37 UTC
Created attachment 229912 [details] [review]
vm-creator: Info on install media now guaranteed

This one needed rebasing on top of current master so re-attaching..
Comment 35 Alexander Larsson 2012-11-26 16:19:49 UTC
Review of attachment 229912 [details] [review]:

ack
Comment 36 Zeeshan Ali 2012-11-26 16:21:38 UTC
Attachment 229523 [details] pushed as ca2c926 - Make MediaManager a singleton
Attachment 229525 [details] pushed as f28db61 - installer-media: Mark nullable constructor params as such
Attachment 229526 [details] pushed as b85cd41 - vm-configurator: Add get_source_media_path()
Attachment 229528 [details] pushed as 57cbb09 - media-manager: Add create_installer_media_from_config
Attachment 229531 [details] pushed as fa1d58d - vm-creator: Save number of reboots for VM under installation
Attachment 229731 [details] pushed as df36a76 - vm-configuration: Save media & OS info for new VMs
Attachment 229733 [details] pushed as db72eb4 - vm-configurator: Refactor custom XML setting code
Attachment 229912 [details] pushed as 6c112d3 - vm-creator: Info on install media now guaranteed