Discussion:
[libvirt] [PATCH] virsh: ensure persistence and autostart are shown for dominfo and pool-info
Justin Clift
2010-06-14 11:38:49 UTC
Permalink
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands. This patch also adds the autostart status
to the output of the virsh pool-info command.

Red Hat BZ for this:

https://bugzilla.redhat.com/show_bug.cgi?id=603696

---
tools/virsh.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 56e1bd7..90fd59e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1903,6 +1903,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
virSecurityModel secmodel;
virSecurityLabel seclabel;
+ int persistent = 0;
int ret = TRUE, autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
@@ -1956,6 +1957,15 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
ret = FALSE;
}

+ /* Check and display whether the domain is persistent or not */
+ persistent = virDomainIsPersistent(dom);
+ vshDebug(ctl, 5, "Domain persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the domain autostarts or not */
if (!virDomainGetAutostart(dom, &autostart)) {
vshPrint(ctl, "%-15s %s\n", _("Autostart:"),
autostart ? _("enable") : _("disable") );
@@ -5134,6 +5144,8 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
+ int autostart = 0;
+ int persistent = 0;
int ret = TRUE;
char uuid[VIR_UUID_STRING_BUFLEN];

@@ -5174,6 +5186,22 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
break;
}

+ /* Check and display whether the pool is persistent or not */
+ persistent = virStoragePoolIsPersistent(pool);
+ vshDebug(ctl, 5, "Pool persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the pool is autostarted or not */
+ virStoragePoolGetAutostart(pool, &autostart);
+ vshDebug(ctl, 5, "Pool autostart flag value: %d\n", autostart);
+ if (autostart < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));
+
if (info.state == VIR_STORAGE_POOL_RUNNING ||
info.state == VIR_STORAGE_POOL_DEGRADED) {
val = prettyCapacity(info.capacity, &unit);
--
1.7.0.1
Daniel P. Berrange
2010-06-16 12:03:43 UTC
Permalink
Post by Justin Clift
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands. This patch also adds the autostart status
to the output of the virsh pool-info command.
https://bugzilla.redhat.com/show_bug.cgi?id=603696
---
tools/virsh.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 56e1bd7..90fd59e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1903,6 +1903,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
virSecurityModel secmodel;
virSecurityLabel seclabel;
+ int persistent = 0;
int ret = TRUE, autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
@@ -1956,6 +1957,15 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
ret = FALSE;
}
+ /* Check and display whether the domain is persistent or not */
+ persistent = virDomainIsPersistent(dom);
+ vshDebug(ctl, 5, "Domain persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the domain autostarts or not */
if (!virDomainGetAutostart(dom, &autostart)) {
vshPrint(ctl, "%-15s %s\n", _("Autostart:"),
autostart ? _("enable") : _("disable") );
@@ -5134,6 +5144,8 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
+ int autostart = 0;
+ int persistent = 0;
int ret = TRUE;
char uuid[VIR_UUID_STRING_BUFLEN];
@@ -5174,6 +5186,22 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
break;
}
+ /* Check and display whether the pool is persistent or not */
+ persistent = virStoragePoolIsPersistent(pool);
+ vshDebug(ctl, 5, "Pool persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the pool is autostarted or not */
+ virStoragePoolGetAutostart(pool, &autostart);
+ vshDebug(ctl, 5, "Pool autostart flag value: %d\n", autostart);
+ if (autostart < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));
+
if (info.state == VIR_STORAGE_POOL_RUNNING ||
info.state == VIR_STORAGE_POOL_DEGRADED) {
val = prettyCapacity(info.capacity, &unit);
ACK. I think the net-info command probably needs the 'persistent' flag
adding too


Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Justin Clift
2010-06-16 12:13:55 UTC
Permalink
On 06/16/2010 10:03 PM, Daniel P. Berrange wrote:
<snip>
Post by Daniel P. Berrange
ACK. I think the net-info command probably needs the 'persistent' flag
adding too
Yeah, I considered that too... but then realised we don't have a
net-info command in virsh yet. :)

Also don't feel completely comfortable coding one up from scratch yet
either, having not touched much upon networking with libvirt at this
point. (sorry)

Still workable?

Regards and best wishes,

Justin Clift
Post by Daniel P. Berrange
Daniel
--
Salasaga - Open Source eLearning IDE
http://www.salasaga.org
Daniel P. Berrange
2010-06-16 12:16:14 UTC
Permalink
Post by Justin Clift
<snip>
Post by Daniel P. Berrange
ACK. I think the net-info command probably needs the 'persistent' flag
adding too
Yeah, I considered that too... but then realised we don't have a
net-info command in virsh yet. :)
Opps. Ignore me then. It isn't important :-)


Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Eric Blake
2010-06-16 23:28:54 UTC
Permalink
Post by Daniel P. Berrange
Post by Justin Clift
<snip>
Post by Daniel P. Berrange
ACK. I think the net-info command probably needs the 'persistent' flag
adding too
Yeah, I considered that too... but then realised we don't have a
net-info command in virsh yet. :)
Opps. Ignore me then. It isn't important :-)
Applying this patch causes 3 test failures in tests/virshtest; I think
you need to update the expected output to include your new row of
Persistent: information before we can apply this.
--
Eric Blake ***@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Justin Clift
2010-06-17 00:34:31 UTC
Permalink
On 06/17/2010 09:28 AM, Eric Blake wrote:
<snip>
Post by Eric Blake
Applying this patch causes 3 test failures in tests/virshtest; I think
you need to update the expected output to include your new row of
Persistent: information before we can apply this.
Ouch. Not sure how I missed that. I'll investigate and fix.

The same might apply for the --details options patches for pool-list and
vol-list from last night. Will find out. :)

Regards and best wishes,

Justin Clift
--
Salasaga - Open Source eLearning IDE
http://www.salasaga.org
Justin Clift
2010-06-17 09:13:20 UTC
Permalink
Post by Justin Clift
<snip>
Post by Eric Blake
Applying this patch causes 3 test failures in tests/virshtest; I think
you need to update the expected output to include your new row of
Persistent: information before we can apply this.
Ouch. Not sure how I missed that. I'll investigate and fix.
The same might apply for the --details options patches for pool-list and
vol-list from last night. Will find out. :)
The --details options patches for pool-list and vol-list haven't
affected the virsh tests, so no problems there anyway. :)

Regards and best wishes,

Justin Clift
--
Salasaga - Open Source eLearning IDE
http://www.salasaga.org
Justin Clift
2010-06-17 07:57:12 UTC
Permalink
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands. This patch also adds the autostart status
to the output of the virsh pool-info command.

Red Hat BZ for this:

https://bugzilla.redhat.com/show_bug.cgi?id=603696

---

This 2nd version of the patch supercedes the previous one, and now includes
the additional output line required for the virsh test suite.

Apologies for missing this first time around.

tests/virshtest.c | 1 +
tools/virsh.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index ad3e2fc..f6790bc 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -23,6 +23,7 @@ State: running\n\
CPU(s): 1\n\
Max memory: 261072 kB\n\
Used memory: 131072 kB\n\
+Persistent: yes\n\
Autostart: disable\n\
\n";
static const char *domuuid_fc4 = DOM_UUID "\n\n";
diff --git a/tools/virsh.c b/tools/virsh.c
index c103713..db14f55 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1910,6 +1910,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom;
virSecurityModel secmodel;
virSecurityLabel seclabel;
+ int persistent = 0;
int ret = TRUE, autostart;
unsigned int id;
char *str, uuid[VIR_UUID_STRING_BUFLEN];
@@ -1963,6 +1964,15 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
ret = FALSE;
}

+ /* Check and display whether the domain is persistent or not */
+ persistent = virDomainIsPersistent(dom);
+ vshDebug(ctl, 5, "Domain persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the domain autostarts or not */
if (!virDomainGetAutostart(dom, &autostart)) {
vshPrint(ctl, "%-15s %s\n", _("Autostart:"),
autostart ? _("enable") : _("disable") );
@@ -5141,6 +5151,8 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
{
virStoragePoolInfo info;
virStoragePoolPtr pool;
+ int autostart = 0;
+ int persistent = 0;
int ret = TRUE;
char uuid[VIR_UUID_STRING_BUFLEN];

@@ -5181,6 +5193,22 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
break;
}

+ /* Check and display whether the pool is persistent or not */
+ persistent = virStoragePoolIsPersistent(pool);
+ vshDebug(ctl, 5, "Pool persistent flag value: %d\n", persistent);
+ if (persistent < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), _("unknown"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
+
+ /* Check and display whether the pool is autostarted or not */
+ virStoragePoolGetAutostart(pool, &autostart);
+ vshDebug(ctl, 5, "Pool autostart flag value: %d\n", autostart);
+ if (autostart < 0)
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), _("no autostart"));
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Autostart:"), autostart ? _("yes") : _("no"));
+
if (info.state == VIR_STORAGE_POOL_RUNNING ||
info.state == VIR_STORAGE_POOL_DEGRADED) {
val = prettyCapacity(info.capacity, &unit);
--
1.7.0.1
Eric Blake
2010-06-17 18:08:44 UTC
Permalink
Post by Justin Clift
This patch adds the persistence status (yes/no) to the output of the virsh
dominfo and pool-info commands. This patch also adds the autostart status
to the output of the virsh pool-info command.
https://bugzilla.redhat.com/show_bug.cgi?id=603696
Thanks again for including the BZ info; it makes it easier to track
these reports between upstream and RHEL.
Post by Justin Clift
+ else
+ vshPrint(ctl, "%-15s %s\n", _("Persistent:"), persistent ? _("yes") : _("no"));
ACK - the only change from v1 does indeed fix 'make check', and your
code was already ACKd during v1.

I wrapped this line to fit 80 columns, then pushed.
--
Eric Blake ***@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Loading...