diff mbox

unbreak booting with virtio

Message ID 1249064349-799-1-git-send-email-glommer@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Glauber Costa July 31, 2009, 6:19 p.m. UTC
Since commit 89e671e3, extboot is broken due to wrong checksum

The problem is that printf "\\$sum" syntax will require an octal
representation, so the fix I'm proposing is to convert it first.

Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: Alexander Graf <agraf@suse.de>
---
 pc-bios/optionrom/signrom.sh |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Comments

Alexander Graf July 31, 2009, 7:55 p.m. UTC | #1
On 31.07.2009, at 20:19, Glauber Costa <glommer@redhat.com> wrote:

> Since commit 89e671e3, extboot is broken due to wrong checksum
>
> The problem is that printf "\\$sum" syntax will require an octal
> representation, so the fix I'm proposing is to convert it first.

Is there no easy way to tell printf we're on decimal? I don't have a  
Linux system handy atm, but I thought \90 was in fact a 90.

Either way, my only complaint would be to introduce a dependency on bc.


Alex

>
> Signed-off-by: Glauber Costa <glommer@redhat.com>
> CC: Alexander Graf <agraf@suse.de>
> ---
> pc-bios/optionrom/signrom.sh |    1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/ 
> signrom.sh
> index 4322811..3512cc4 100755
> --- a/pc-bios/optionrom/signrom.sh
> +++ b/pc-bios/optionrom/signrom.sh
> @@ -42,4 +42,5 @@ sum=$(( 256 - $sum ))
>
> # and write the output file
> cp "$1" "$2"
> +sum=$(echo "obase=8; $sum" | bc)
> printf "\\$sum" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/ 
> dev/null
> -- 
> 1.6.2.2
>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Glauber Costa July 31, 2009, 11:39 p.m. UTC | #2
On Fri, Jul 31, 2009 at 09:55:39PM +0200, Alexander Graf wrote:
>
> On 31.07.2009, at 20:19, Glauber Costa <glommer@redhat.com> wrote:
>
>> Since commit 89e671e3, extboot is broken due to wrong checksum
>>
>> The problem is that printf "\\$sum" syntax will require an octal
>> representation, so the fix I'm proposing is to convert it first.
>
> Is there no easy way to tell printf we're on decimal? I don't have a  
> Linux system handy atm, but I thought \90 was in fact a 90.
>
> Either way, my only complaint would be to introduce a dependency on bc.
Not that I'm aware of.
But would be happy to know, too.


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ján ONDREJ (SAL) Aug. 1, 2009, 7:04 a.m. UTC | #3
On Fri, Jul 31, 2009 at 09:55:39PM +0200, Alexander Graf wrote:
>
> On 31.07.2009, at 20:19, Glauber Costa <glommer@redhat.com> wrote:
>
>> Since commit 89e671e3, extboot is broken due to wrong checksum
>>
>> The problem is that printf "\\$sum" syntax will require an octal
>> representation, so the fix I'm proposing is to convert it first.
>
> Is there no easy way to tell printf we're on decimal? I don't have a  
> Linux system handy atm, but I thought \90 was in fact a 90.
>
> Either way, my only complaint would be to introduce a dependency on bc.

>> cp "$1" "$2"
>> +sum=$(echo "obase=8; $sum" | bc)
>> printf "\\$sum" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/ 
>> dev/null

May be it's better to use awk:

echo $sum | awk '{ printf("%c", $1) }' \
  | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null

This version accepts decimal $sum, does not need conversion to octal.

			SAL
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Paolo Bonzini Aug. 1, 2009, 8:20 a.m. UTC | #4
On 07/31/2009 09:55 PM, Alexander Graf wrote:
>
> On 31.07.2009, at 20:19, Glauber Costa <glommer@redhat.com> wrote:
>
>> Since commit 89e671e3, extboot is broken due to wrong checksum
>>
>> The problem is that printf "\\$sum" syntax will require an octal
>> representation, so the fix I'm proposing is to convert it first.
>
> Is there no easy way to tell printf we're on decimal? I don't have a
> Linux system handy atm, but I thought \90 was in fact a 90.
>
> Either way, my only complaint would be to introduce a dependency on bc.

printf `printf '\\%o' $sum`

Paolo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Graf Aug. 1, 2009, 8:23 a.m. UTC | #5
On 01.08.2009, at 01:39, Glauber Costa wrote:

> On Fri, Jul 31, 2009 at 09:55:39PM +0200, Alexander Graf wrote:
>>
>> On 31.07.2009, at 20:19, Glauber Costa <glommer@redhat.com> wrote:
>>
>>> Since commit 89e671e3, extboot is broken due to wrong checksum
>>>
>>> The problem is that printf "\\$sum" syntax will require an octal
>>> representation, so the fix I'm proposing is to convert it first.
>>
>> Is there no easy way to tell printf we're on decimal? I don't have a
>> Linux system handy atm, but I thought \90 was in fact a 90.
>>
>> Either way, my only complaint would be to introduce a dependency on  
>> bc.
> Not that I'm aware of.
> But would be happy to know, too.

Hum, reading the documentation again it in fact needs an octal number.
But we could use printf for the conversion as well!

$ printf "%o" 65
101

That wouldn't introduce a new dependency that might be missing on  
random OSs and looks rather clean to me.

Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Avi Kivity Aug. 3, 2009, 12:37 p.m. UTC | #6
On 07/31/2009 09:19 PM, Glauber Costa wrote:
> Since commit 89e671e3, extboot is broken due to wrong checksum
>
> The problem is that printf "\\$sum" syntax will require an octal
> representation, so the fix I'm proposing is to convert it first.
>
>    

Whichever way this gets resolved, please send it upstream since the bug 
exists there.
diff mbox

Patch

diff --git a/pc-bios/optionrom/signrom.sh b/pc-bios/optionrom/signrom.sh
index 4322811..3512cc4 100755
--- a/pc-bios/optionrom/signrom.sh
+++ b/pc-bios/optionrom/signrom.sh
@@ -42,4 +42,5 @@  sum=$(( 256 - $sum ))
 
 # and write the output file
 cp "$1" "$2"
+sum=$(echo "obase=8; $sum" | bc)
 printf "\\$sum" | dd of="$2" bs=1 count=1 seek=$size conv=notrunc 2>/dev/null