Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-11 Thread Stefan Bader
On 10.10.2016 20:43, Eric Blake wrote:
> On 10/10/2016 11:48 AM, Stefan Bader wrote:
> 
>>> I did not hear about that before. But revisiting things again I think what
>>> happened is that the Xen patch which I had done before (but at that time 
>>> forgot
>>> to submit upstream) was adding quotes there because without, the grep does 
>>> not
>>> work. Back then I did not realize this broke the shutdown as that also had
>>> quotes around the list. All the other users of the list are ok because they 
>>> wrap
>>> the processing into for ... loops and for those newline or space does not 
>>> matter.
>>
>> I think the surprising part is that the calls to virsh like:
>>
>>   list=$(virsh ... list)
>>
>> seem to retain the newline seperator despite having no quotes. Only when 
>> using
>> echo with the unquoted variable seems to do that. That is with dash as sh at 
>> least.
> 
> That's true for ALL shells.  Word splitting does NOT happen during
> variable assignment.  list=$() is _strictly_ equivalent to list="$()",
> no matter the shell.

Funny that with all those years working with shells I never memorized that as a
fact. :) Guess it was enough to adhere to the good habit and just use "$()" all
the time.

So just as a wrap up, the first patch ends up not being a fix in the strict
sense as before the second patch word splitting would happen in the list_guest
function. Luckily it neither breaks anything on its own as the result is the
same whether list was already split or not. Somehow I subconsciously reordered
it to come before the dom0 patch which I had done here before (without noticing
that the list file is then broken for more than one guest to shutdown). Somehow
the big part of adding the grep in the dom0 patch made me miss the additional
quotes around the variable. In hindsight maybe the better way would have been to
add a new line which filters the dom0 uid and reassigns the result to list and
keep the echo line unmodified. But then, the end result now should be working
and robust enough...

-Stefan
> 
> It's just that there are so many other places where $() and "$()" behave
> differently that it's (usually) a good habit to always use "", rather
> than learning the rules on when you NEED them, vs. telling the special
> cases when you DON'T want them apart from the cases where they are optional.
> 




signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-10 Thread Eric Blake
On 10/10/2016 11:48 AM, Stefan Bader wrote:

>> I did not hear about that before. But revisiting things again I think what
>> happened is that the Xen patch which I had done before (but at that time 
>> forgot
>> to submit upstream) was adding quotes there because without, the grep does 
>> not
>> work. Back then I did not realize this broke the shutdown as that also had
>> quotes around the list. All the other users of the list are ok because they 
>> wrap
>> the processing into for ... loops and for those newline or space does not 
>> matter.
> 
> I think the surprising part is that the calls to virsh like:
> 
>   list=$(virsh ... list)
> 
> seem to retain the newline seperator despite having no quotes. Only when using
> echo with the unquoted variable seems to do that. That is with dash as sh at 
> least.

That's true for ALL shells.  Word splitting does NOT happen during
variable assignment.  list=$() is _strictly_ equivalent to list="$()",
no matter the shell.

It's just that there are so many other places where $() and "$()" behave
differently that it's (usually) a good habit to always use "", rather
than learning the rules on when you NEED them, vs. telling the special
cases when you DON'T want them apart from the cases where they are optional.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-10 Thread Cole Robinson
On 10/10/2016 12:32 PM, Stefan Bader wrote:
> On 10.10.2016 17:06, Cole Robinson wrote:
>> On 10/07/2016 03:56 AM, Stefan Bader wrote:
>>> Two small changes, before I forget about submitting them...
>>>
>>> First one affects all environments the same. The list of UIDs which
>>> is generated has each element on a separate line. And using quotes
>>> in the echo preserves those newlines. However the processing assumes
>>> one line per URI and all UIDs separated by spaces. So without dropping
>>> the quotes only one guest will get shutdown/suspended.
>>>
>>> The second change is for Xen environments only. Domain-0 appears in
>>> the list of guests and it is a persistent one. So on shutdown, the
>>> script tries to stop Domain-0 (which is not working) and then waits
>>> the whole timeout for it to stop.
>>>
>>
>> Note these patches were flagged as problematic a few months back:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1335585
>>
>> Stefan, have you heard about that issue? Was it resolved with these versions?
> 
> I did not hear about that before. But revisiting things again I think what
> happened is that the Xen patch which I had done before (but at that time 
> forgot
> to submit upstream) was adding quotes there because without, the grep does not
> work. Back then I did not realize this broke the shutdown as that also had
> quotes around the list. All the other users of the list are ok because they 
> wrap
> the processing into for ... loops and for those newline or space does not 
> matter.
> 
> So together with the other patch wich drops the quotes when writing the list
> file this should be resolved. list_guests returns a list of uids (separated by
> newline), the output of the info message is correctly showing names in one 
> line
> separated by komma, and the produced list file had only one line per uri with
> uids separated by spaces.

Sounds good, I'll close that bug then

Thanks,
Cole

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


Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-10 Thread Stefan Bader
On 10.10.2016 18:32, Stefan Bader wrote:
> On 10.10.2016 17:06, Cole Robinson wrote:
>> On 10/07/2016 03:56 AM, Stefan Bader wrote:
>>> Two small changes, before I forget about submitting them...
>>>
>>> First one affects all environments the same. The list of UIDs which
>>> is generated has each element on a separate line. And using quotes
>>> in the echo preserves those newlines. However the processing assumes
>>> one line per URI and all UIDs separated by spaces. So without dropping
>>> the quotes only one guest will get shutdown/suspended.
>>>
>>> The second change is for Xen environments only. Domain-0 appears in
>>> the list of guests and it is a persistent one. So on shutdown, the
>>> script tries to stop Domain-0 (which is not working) and then waits
>>> the whole timeout for it to stop.
>>>
>>
>> Note these patches were flagged as problematic a few months back:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1335585
>>
>> Stefan, have you heard about that issue? Was it resolved with these versions?
> 
> I did not hear about that before. But revisiting things again I think what
> happened is that the Xen patch which I had done before (but at that time 
> forgot
> to submit upstream) was adding quotes there because without, the grep does not
> work. Back then I did not realize this broke the shutdown as that also had
> quotes around the list. All the other users of the list are ok because they 
> wrap
> the processing into for ... loops and for those newline or space does not 
> matter.

I think the surprising part is that the calls to virsh like:

  list=$(virsh ... list)

seem to retain the newline seperator despite having no quotes. Only when using
echo with the unquoted variable seems to do that. That is with dash as sh at 
least.

> 
> So together with the other patch wich drops the quotes when writing the list
> file this should be resolved. list_guests returns a list of uids (separated by
> newline), the output of the info message is correctly showing names in one 
> line
> separated by komma, and the produced list file had only one line per uri with
> uids separated by spaces.
> 
> -Stefan
>>
>> Thanks,
>> Cole
>>
> 
> 




signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-10 Thread Stefan Bader
On 10.10.2016 17:06, Cole Robinson wrote:
> On 10/07/2016 03:56 AM, Stefan Bader wrote:
>> Two small changes, before I forget about submitting them...
>>
>> First one affects all environments the same. The list of UIDs which
>> is generated has each element on a separate line. And using quotes
>> in the echo preserves those newlines. However the processing assumes
>> one line per URI and all UIDs separated by spaces. So without dropping
>> the quotes only one guest will get shutdown/suspended.
>>
>> The second change is for Xen environments only. Domain-0 appears in
>> the list of guests and it is a persistent one. So on shutdown, the
>> script tries to stop Domain-0 (which is not working) and then waits
>> the whole timeout for it to stop.
>>
> 
> Note these patches were flagged as problematic a few months back:
> https://bugzilla.redhat.com/show_bug.cgi?id=1335585
> 
> Stefan, have you heard about that issue? Was it resolved with these versions?

I did not hear about that before. But revisiting things again I think what
happened is that the Xen patch which I had done before (but at that time forgot
to submit upstream) was adding quotes there because without, the grep does not
work. Back then I did not realize this broke the shutdown as that also had
quotes around the list. All the other users of the list are ok because they wrap
the processing into for ... loops and for those newline or space does not 
matter.

So together with the other patch wich drops the quotes when writing the list
file this should be resolved. list_guests returns a list of uids (separated by
newline), the output of the info message is correctly showing names in one line
separated by komma, and the produced list file had only one line per uri with
uids separated by spaces.

-Stefan
> 
> Thanks,
> Cole
> 




signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-10 Thread Cole Robinson
On 10/07/2016 03:56 AM, Stefan Bader wrote:
> Two small changes, before I forget about submitting them...
> 
> First one affects all environments the same. The list of UIDs which
> is generated has each element on a separate line. And using quotes
> in the echo preserves those newlines. However the processing assumes
> one line per URI and all UIDs separated by spaces. So without dropping
> the quotes only one guest will get shutdown/suspended.
> 
> The second change is for Xen environments only. Domain-0 appears in
> the list of guests and it is a persistent one. So on shutdown, the
> script tries to stop Domain-0 (which is not working) and then waits
> the whole timeout for it to stop.
> 

Note these patches were flagged as problematic a few months back:
https://bugzilla.redhat.com/show_bug.cgi?id=1335585

Stefan, have you heard about that issue? Was it resolved with these versions?

Thanks,
Cole

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


Re: [libvirt] libvirt-guest.sh bug fixes

2016-10-10 Thread Michal Privoznik
On 07.10.2016 15:56, Stefan Bader wrote:
> Two small changes, before I forget about submitting them...
> 
> First one affects all environments the same. The list of UIDs which
> is generated has each element on a separate line. And using quotes
> in the echo preserves those newlines. However the processing assumes
> one line per URI and all UIDs separated by spaces. So without dropping
> the quotes only one guest will get shutdown/suspended.
> 
> The second change is for Xen environments only. Domain-0 appears in
> the list of guests and it is a persistent one. So on shutdown, the
> script tries to stop Domain-0 (which is not working) and then waits
> the whole timeout for it to stop.
> 
> -Stefan
> 

Eric ACKed both of them and I've just pushed them.

Michal

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


[libvirt] libvirt-guest.sh bug fixes

2016-10-07 Thread Stefan Bader
Two small changes, before I forget about submitting them...

First one affects all environments the same. The list of UIDs which
is generated has each element on a separate line. And using quotes
in the echo preserves those newlines. However the processing assumes
one line per URI and all UIDs separated by spaces. So without dropping
the quotes only one guest will get shutdown/suspended.

The second change is for Xen environments only. Domain-0 appears in
the list of guests and it is a persistent one. So on shutdown, the
script tries to stop Domain-0 (which is not working) and then waits
the whole timeout for it to stop.

-Stefan


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