[libvirt] [PATCH] Improve filtering of Xen domain0 in libvirt-guests

Jim Fehlig posted 1 patch 6 years, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20171215230356.19491-1-jfehlig@suse.com
tools/libvirt-guests.sh.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] Improve filtering of Xen domain0 in libvirt-guests
Posted by Jim Fehlig 6 years, 4 months ago
The list_guests function in libvirt-guests uses 'grep -v' to filter
Xen domain0 from a list of guests. If domain0 is the only item in
the list, 'grep -v' returns 1, causing the 'stop' operation to fail
when action is 'suspend'. Improve the filtering by using sed to remove
domain0 from the list of guests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
---

Failure of the 'stop' operation was fixed in commit 69ed99c7 by marking
domain0 as a persistent domain. That fixes cases where domain0 is the
only domain in the list of persistent domains. But there may be cases
where domain0 is the only domain in 'virsh list --uuid', and the code
should be made more robust to handle those.

 tools/libvirt-guests.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index 791d9277b..8a158cca4 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -121,7 +121,7 @@ list_guests() {
         return 1
     fi
 
-    echo "$list" | grep -v 00000000-0000-0000-0000-000000000000
+    echo "$list" | sed "/00000000-0000-0000-0000-000000000000/d"
 }
 
 # guest_name URI UUID
-- 
2.15.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Improve filtering of Xen domain0 in libvirt-guests
Posted by Martin Kletzander 6 years, 4 months ago
On Fri, Dec 15, 2017 at 04:03:56PM -0700, Jim Fehlig wrote:
>The list_guests function in libvirt-guests uses 'grep -v' to filter
>Xen domain0 from a list of guests. If domain0 is the only item in
>the list, 'grep -v' returns 1, causing the 'stop' operation to fail
>when action is 'suspend'. Improve the filtering by using sed to remove
>domain0 from the list of guests.
>
>Signed-off-by: Jim Fehlig <jfehlig@suse.com>
>---
>
>Failure of the 'stop' operation was fixed in commit 69ed99c7 by marking
>domain0 as a persistent domain. That fixes cases where domain0 is the
>only domain in the list of persistent domains. But there may be cases
>where domain0 is the only domain in 'virsh list --uuid', and the code
>should be made more robust to handle those.
>

ACK

> tools/libvirt-guests.sh.in | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
>index 791d9277b..8a158cca4 100644
>--- a/tools/libvirt-guests.sh.in
>+++ b/tools/libvirt-guests.sh.in
>@@ -121,7 +121,7 @@ list_guests() {
>         return 1
>     fi
>
>-    echo "$list" | grep -v 00000000-0000-0000-0000-000000000000
>+    echo "$list" | sed "/00000000-0000-0000-0000-000000000000/d"
> }
>
> # guest_name URI UUID
>-- 
>2.15.1
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list

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