[libvirt] incorrect VIR_DOMAIN_NONE usage

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

 



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) {

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