Re: [libvirt] [PATCH 3/2] Make type & startmode optional in toplevel interface definitions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 07, 2009 at 05:04:40PM -0400, Laine Stump wrote:
> (Yes, you read the subject correctly - 3 of 2!)
> 
> The minimal XML returned from ncf_if_xml_state() doesn't contain these
> attributes, and it was preventing it from passing through the
> parse/format step (making my patches from earlier today unusable).
> 
> Because adding an "UNSPECIFIED" value to the enums for type and
> startmode would have made it possible for someone to send xml with,
> eg, type="unspecified" (which we don't want), I've followed the
> convention already used for the dhcp "peerdns" attribute - if it isn't
> specified, the value is -1.

IMHO 'type' should always be a mandatory attribute. There's no reason
why the live XML dump should not include it - we shouldn't make it
optional merely because it hasn't been implemented fully yet.

For anything which is an enum, the default value if not specified
should always be 0. This is because when allocating a new object,
everything will be memset to 0, so 0 should be a sensible default.

When declaring the enum <->  string mapping, simply put "" as the
value for that if you don't want it to be usable for incoming XML.
When generating the XML output doc, you can just make it conditional
on  if (if->startmode), so the default value is skipped when formatting
the XML

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 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]