Re: [libvirt] [PATCH] libvirt.c: fix virStateActive return value; document ...

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

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:
...
>> + * Run each virtualization driver's "active" method.
>> + *
>> + * Return 0 if successful, -1 upon error.
>> + */
>>  int virStateActive(void) {
>>      int i, ret = 0;
>>
>>      for (i = 0 ; i < virStateDriverTabCount ; i++) {
>>          if (virStateDriverTab[i]->active &&
>>              virStateDriverTab[i]->active())
>> -            ret = 1;
>> +            ret = -1;
>
> This is *not* an error condition. This method is basically asking
> whether the driver is 'active' - eg, does it have any domains
> running. It returns 0 if it isn't active, or 1 if it is active.
>
> There is no error scenario - it can never fail.

Ah.  I see what you mean.
This is better:

>From a85968eed75cdbcf8848ea62b2739469fd6a9d60 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@xxxxxxxxxx>
Date: Mon, 24 Nov 2008 15:52:55 +0100
Subject: [PATCH 1/3] libvirt.c: document the virState* functions

* src/libvirt.c (virStateActive, virStateCleanup, virStateReload):
(virStateActive): Add per-function comments.
---
 src/libvirt.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index f445333..6195a4e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -636,6 +636,13 @@ virRegisterStateDriver(virStateDriverPtr driver)
     return virStateDriverTabCount++;
 }

+/**
+ * virStateInitialize:
+ *
+ * Initialize all virtualization drivers.
+ *
+ * Return 0 if all succeed, -1 upon any failure.
+ */
 int virStateInitialize(void) {
     int i, ret = 0;

@@ -650,6 +657,13 @@ int virStateInitialize(void) {
     return ret;
 }

+/**
+ * virStateCleanup:
+ *
+ * Run each virtualization driver's cleanup method.
+ *
+ * Return 0 if all succeed, -1 upon any failure.
+ */
 int virStateCleanup(void) {
     int i, ret = 0;

@@ -661,6 +675,13 @@ int virStateCleanup(void) {
     return ret;
 }

+/**
+ * virStateReload:
+ *
+ * Run each virtualization driver's reload method.
+ *
+ * Return 0 if all succeed, -1 upon any failure.
+ */
 int virStateReload(void) {
     int i, ret = 0;

@@ -672,6 +693,13 @@ int virStateReload(void) {
     return ret;
 }

+/**
+ * virStateActive:
+ *
+ * Run each virtualization driver's "active" method.
+ *
+ * Return 0 if none are active, 1 if at least one is.
+ */
 int virStateActive(void) {
     int i, ret = 0;

--
1.6.0.4.1044.g77718

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