On Wed, Dec 10, 2008 at 07:49:32AM -0500, Itamar Heim wrote:
> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange@redhat.com]
> In this bit of the code:
>
> diff --git a/src/domain_conf.h b/src/domain_conf.h
> index 51cf6d5..436d0b1 100644
> --- a/src/domain_conf.h
> +++ b/src/domain_conf.h
> @@ -268,6 +268,7 @@ struct _virDomainGraphicsDef {
> struct {
> char *display;
> char *xauth;
> + char *fullscreen;
> } sdl;
> } data;
> };
>
>
>
> You shouldn't use a char * for fullscreen. This is a boolean flag, so
> it should just be an bitfield 'int fullscreen: 1'. This avoids the
> issue DV pointed out of unexpected values in the XML.
[IH] this is used to get the string from the xml, to compare it to the
string 'true'.
Will the xml parsing infrastructure automatically convert true/false to
int and handle parsing errors or I need to write that code in another
place?
No, do the checking of the XML attribute value at the time it is
parsed. For consistency with the VNC display 'autoport' attribute
handling, we should actually use 'yes' and 'no' rather than
'true'
and 'false'.
So, when parsing
if ((fullscreen = virXMLPropString(node, "fullscreen")) != NULL) {
if (STREQ(fullscreen, "yes")) {
def->data.sdl.fullscreen = 1;
}
VIR_FREE(fullscreen);
}
And when formatting XML
virBufferVSprintf(buf, " fullscreen='%s'",
def->data.sdl.fullscreen ? "yes" :
"no");
And in the struct
int fullscreen : 1;
Regards,
Daniel
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|