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 746656 - Don't try to call get_mode() on null GVirConfigDomainCpu
Don't try to call get_mode() on null GVirConfigDomainCpu
Status: RESOLVED FIXED
Product: gnome-boxes
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: 3.22
Assigned To: GNOME Boxes maintainer(s)
GNOME Boxes maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2015-03-23 16:20 UTC by Christophe Fergeau
Modified: 2016-03-31 13:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Don't try to call get_mode() on null GVirConfigDomainCpu (2.12 KB, patch)
2015-03-23 16:20 UTC, Christophe Fergeau
needs-work Details | Review
vm-configurator: Handle "no cpu" case gracefully (1.71 KB, patch)
2015-03-23 17:42 UTC, Christophe Fergeau
committed Details | Review

Description Christophe Fergeau 2015-03-23 16:20:37 UTC
A domain config can contain no CPU node (for example if it was removed
using virsh edit). Such a domain triggers a warning on Boxes startup:
(gnome-boxes:15373): Libvirt.GConfig-CRITICAL **: gvir_config_domain_cpu_get_mode: assertion 'GVIR_CONFIG_IS_DOMAIN_CPU(cpu)' failed

This commit makes sure we got a non-null GVirConfigDomainCpu before
attempting to call get_mode() on it.
Comment 1 Christophe Fergeau 2015-03-23 16:20:40 UTC
Created attachment 300145 [details] [review]
Don't try to call get_mode() on null GVirConfigDomainCpu
Comment 2 Zeeshan Ali 2015-03-23 16:37:14 UTC
Review of attachment 300145 [details] [review]:

* I don't see any usecase of this but since we can handle the case without complicating the code, I don't see why not.

* Shorter shortlog please and add a prefix as per conventions. I'd go for "vm-configurator: Handle "no cpu" case gracefully".

* Empty line before the pasted critical error please.

::: src/vm-configurator.vala
@@ +243,3 @@
+                    var capabilities = yield connection.get_capabilities_async (null);
+                    set_cpu_config (domain, capabilities);
+                }

Since null cpu is more of a corner/erroneous case here, I'd rather avoid further indenting/nesting the code for it. i-e:

if (cpu != null &&
    cpu.get_mode () == .. &&
    cpu.get_mode () ==)
Comment 3 Christophe Fergeau 2015-03-23 17:42:34 UTC
Created attachment 300147 [details] [review]
vm-configurator: Handle "no cpu" case gracefully

A domain config can contain no CPU node (for example if it was removed
using virsh edit). Such a domain triggers a warning on Boxes startup:

(gnome-boxes:15373): Libvirt.GConfig-CRITICAL **: gvir_config_domain_cpu_get_mode: assertion 'GVIR_CONFIG_IS_DOMAIN_CPU(cpu)' failed

This commit makes sure we got a non-null GVirConfigDomainCpu before
attempting to call get_mode() on it.
Comment 4 Christophe Fergeau 2015-03-23 17:44:10 UTC
Review of attachment 300147 [details] [review]:

::: src/vm-configurator.vala
@@ +241,1 @@
                 is_boxes_installed (domain)) {

No idea about the right indentation here.
Comment 5 Zeeshan Ali 2015-03-30 14:42:39 UTC
Review of attachment 300147 [details] [review]:

ack

::: src/vm-configurator.vala
@@ +241,1 @@
                 is_boxes_installed (domain)) {

seems right to me.
Comment 6 Zeeshan Ali 2015-04-10 20:34:27 UTC
Attachment 300147 [details] pushed as a6970ac - vm-configurator: Handle "no cpu" case gracefully