[libvirt] incorrect VIR_DOMAIN_NONE usage

As I was trying to understand exact semantics of the libvirt flags api, I found an error in the xs_internal.c file. When it wants to indicate that it cannot report the state of the domain, it user VIR_DOMAIN_NONE as a return value, which does not, in fact, refer to a domain state at all, but is a dummy flag for creating domains, instead of VIR_DOMAIN_NOSTATE. This patch does not affect the compiled code, only the readability. On a related note, the defined enum flags seem inconstent to me, half of them have explicitly named 0 default values, and half of them don't, it's a bit confusing. If enum virStorageVolDeleteFlags { VIR_STORAGE_VOL_DELETE_NORMAL = 0 : Delete metadata only (fast) VIR_STORAGE_VOL_DELETE_ZEROED = 1 : Clear all data to zeros (slow) } then why not enum virConnectFlags { VIR_CONNECT_RW = 0 : A read-write connection VIR_CONNECT_RO = 1 : A readonly connection } ? It would not affect existing code, and would make the library more consistent. regards István ? .project ? xs_internal_constant_semantics.patch Index: src/xs_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xs_internal.c,v retrieving revision 1.65 diff -u -p -r1.65 xs_internal.c --- src/xs_internal.c 10 Apr 2008 16:54:54 -0000 1.65 +++ src/xs_internal.c 1 Jul 2008 19:46:41 -0000 @@ -399,7 +399,7 @@ xenStoreGetDomainInfo(virDomainPtr domai info->state = VIR_DOMAIN_RUNNING; free(tmp); } else { - info->state = VIR_DOMAIN_NONE; + info->state = VIR_DOMAIN_NOSTATE; } tmp = virDomainDoStoreQuery(domain->conn, domain->id, "memory/target"); if (tmp != NULL) {

On Tue, Jul 01, 2008 at 10:04:58PM +0200, T?th Istv?n wrote:
As I was trying to understand exact semantics of the libvirt flags api, I found an error in the xs_internal.c file. When it wants to indicate that it cannot report the state of the domain, it user VIR_DOMAIN_NONE as a return value, which does not, in fact, refer to a domain state at all, but is a dummy flag for creating domains, instead of VIR_DOMAIN_NOSTATE.
This patch does not affect the compiled code, only the readability.
Thanks, I've comitted this changed.
On a related note, the defined enum flags seem inconstent to me, half of them have explicitly named 0 default values, and half of them don't, it's a bit confusing.
If
enum virStorageVolDeleteFlags { VIR_STORAGE_VOL_DELETE_NORMAL = 0 : Delete metadata only (fast) VIR_STORAGE_VOL_DELETE_ZEROED = 1 : Clear all data to zeros (slow) }
then why not
enum virConnectFlags { VIR_CONNECT_RW = 0 : A read-write connection VIR_CONNECT_RO = 1 : A readonly connection }
? It would not affect existing code, and would make the library more consistent.
That sounds like a reasonable idea to me - if anyone wants to fix this please send patches. 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 :|
participants (2)
-
Daniel P. Berrange
-
Tóth István