[libvirt] [libvirt-glib] Keep domain devices list sorted

From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML). --- libvirt-gobject/libvirt-gobject-domain.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 7b2c7ad..0bafa7e 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -909,5 +909,5 @@ GList *gvir_domain_get_devices(GVirDomain *domain, } g_list_free (config_devices); - return ret; + return g_list_reverse (ret); } -- 1.7.7.6

On 03/06/2012 03:27 PM, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML).
Actually, if I understand things right, preserving order _is_ important to guarantee. For example, with older XML that lacked per-device <boot order='n'/>, libvirt would determine which order devices are presented to guest BIOS boot order based on their position within XML. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Mar 7, 2012 at 1:03 AM, Eric Blake <eblake@redhat.com> wrote:
On 03/06/2012 03:27 PM, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML).
Actually, if I understand things right, preserving order _is_ important to guarantee. For example, with older XML that lacked per-device <boot order='n'/>, libvirt would determine which order devices are presented to guest BIOS boot order based on their position within XML.
Well, I agree. You only need to convince Christophe on this. :) -- Regards, Zeeshan Ali (Khattak) FSF member#5124

On Wed, Mar 07, 2012 at 01:56:44AM +0200, Zeeshan Ali (Khattak) wrote:
On Wed, Mar 7, 2012 at 1:03 AM, Eric Blake <eblake@redhat.com> wrote:
Actually, if I understand things right, preserving order _is_ important to guarantee. For example, with older XML that lacked per-device <boot order='n'/>, libvirt would determine which order devices are presented to guest BIOS boot order based on their position within XML.
Well, I agree. You only need to convince Christophe on this. :)
If there's a compelling reason for keeping it, which Eric just demonstrated, I'm all for keeping the order. All I was saying is that without such a reason, I don't think it's worth going out of our way to keep it, and that not guarateeing it's kept gives us more flexibility if needed. Since it's actually important to keep thing ordered, case is closed. Christophe

On Wed, Mar 07, 2012 at 12:27:53AM +0200, Zeeshan Ali (Khattak) wrote:
From: "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org>
While we don't guarantee the order of devices in the list returned from gvir_domain_get_devices(), its not a bad idea to keep them sorted the same way we get them from configuration (XML). --- libvirt-gobject/libvirt-gobject-domain.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 7b2c7ad..0bafa7e 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -909,5 +909,5 @@ GList *gvir_domain_get_devices(GVirDomain *domain, } g_list_free (config_devices);
- return ret; + return g_list_reverse (ret); }
ACK Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (4)
-
Christophe Fergeau
-
Daniel P. Berrange
-
Eric Blake
-
Zeeshan Ali (Khattak)