On 04.06.2013 16:33, Christophe Fergeau wrote: > This makes use of the new gvir_designer_domain_get_supported_devices() > method. > --- > libvirt-designer/libvirt-designer-domain.c | 42 +++++++++++++++++++++++++++--- > 1 file changed, 39 insertions(+), 3 deletions(-) > > diff --git a/libvirt-designer/libvirt-designer-domain.c b/libvirt-designer/libvirt-designer-domain.c > index 1d37e21..7466ee9 100644 > --- a/libvirt-designer/libvirt-designer-domain.c > +++ b/libvirt-designer/libvirt-designer-domain.c > @@ -70,6 +70,7 @@ static gboolean error_is_set(GError **error) > } > > static const char GVIR_DESIGNER_SPICE_CHANNEL_NAME[] = "com.redhat.spice.0"; > +static const char GVIR_DESIGNER_SPICE_CHANNEL_DEVICE_ID[] = "http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1003"; > static const char GVIR_DESIGNER_VIRTIO_BLOCK_DEVICE_ID[] = "http://pciids.sourceforge.net/v2.2/pci.ids/1af4/1001"; > > enum { > @@ -410,12 +411,45 @@ gvir_designer_domain_has_spice_channel(GVirDesignerDomain *design) > } > > > -static void gvir_designer_domain_add_spice_channel(GVirDesignerDomain *design) > +static gboolean > +gvir_designer_domain_supports_spice_channel(GVirDesignerDomain *design) > +{ > + OsinfoDeviceList *devices; > + OsinfoFilter *filter; > + gboolean vioserial_found = FALSE; > + > + filter = osinfo_filter_new(); > + osinfo_filter_add_constraint(filter, > + OSINFO_ENTITY_PROP_ID, > + GVIR_DESIGNER_SPICE_CHANNEL_DEVICE_ID); > + devices = gvir_designer_domain_get_supported_devices(design, filter); > + if (devices) { > + g_warn_if_fail(osinfo_list_get_length(OSINFO_LIST(devices)) <= 1); so warn if the list length is greater than 1 ... > + if (osinfo_list_get_length(OSINFO_LIST(devices)) >= 1) > + vioserial_found = TRUE; ... but that's the only way to set vioserial_found to TRUE. Or am I missing something? > + g_object_unref(G_OBJECT(devices)); > + } > + if (filter) > + g_object_unref(G_OBJECT(filter)); > + > + return vioserial_found; > +} > + > + > +static gboolean gvir_designer_domain_add_spice_channel(GVirDesignerDomain *design, > + GError **error) > { > - /* FIXME: error out if there is no support for the vioserial device */ > GVirConfigDomainChannel *channel; > GVirConfigDomainChardevSourceSpiceVmc *vmc; > > + if (!gvir_designer_domain_supports_spice_channel(design)) { > + g_set_error(error, GVIR_DESIGNER_DOMAIN_ERROR, 0, > + "OS and/or hypervisor don't support virtio-serial" > + " which is required by the SPICE channel"); > + g_debug("SPICE channel not supported"); > + return FALSE; > + } > + > channel = gvir_config_domain_channel_new(); > gvir_config_domain_channel_set_target_type(channel, > GVIR_CONFIG_DOMAIN_CHANNEL_TARGET_VIRTIO); > @@ -429,6 +463,8 @@ static void gvir_designer_domain_add_spice_channel(GVirDesignerDomain *design) > gvir_config_domain_add_device(design->priv->config, > GVIR_CONFIG_DOMAIN_DEVICE(channel)); > g_object_unref(G_OBJECT(channel)); > + > + return TRUE; > } > > > @@ -516,7 +552,7 @@ gvir_designer_domain_add_graphics(GVirDesignerDomain *design, > GVIR_CONFIG_DOMAIN_GRAPHICS_SPICE_IMAGE_COMPRESSION_OFF); > graphics = GVIR_CONFIG_DOMAIN_GRAPHICS(spice); > if (!gvir_designer_domain_has_spice_channel(design)) > - gvir_designer_domain_add_spice_channel(design); > + gvir_designer_domain_add_spice_channel(design, NULL); I think we want s/NULL/error/ here. > > break; > } > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list