[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH for-2.5 1/1] spapr: Handle failure of KVM_PPC_ALLO
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [PATCH for-2.5 1/1] spapr: Handle failure of KVM_PPC_ALLOCATE_HTAB ioctl |
Date: |
Mon, 9 Nov 2015 15:24:15 +1100 |
User-agent: |
Mutt/1.5.23 (2015-06-09) |
On Tue, Nov 03, 2015 at 03:38:19PM +0530, Bharata B Rao wrote:
> KVM_PPC_ALLOCATE_HTAB ioctl can return -ENOMEM for KVM guests and QEMU
> never handled this correctly. But this didn't cause any problems till
> now as KVM_PPC_ALLOCATE_HTAB ioctl returned with smaller than requested
> HTAB when enough contiguous memory wasn't available in the host.
> After the proposed kernel change: https://patchwork.ozlabs.org/patch/530501/,
> KVM_PPC_ALLOCATE_HTAB ioctl will not fallback to lower sized HTAB
> allocation and will fail if requested HTAB size can't be met.
>
> Check for such failures in QEMU and abort appropriately. This will
> prevent guest kernel from hanging/freezing during early boot by doing
> graceful exit when host is unable to allocate requested HTAB.
>
> Signed-off-by: Bharata B Rao <address@hidden>
I'm going to apply this, since it fixes a real problem.
I'm not entirely happy with the way it's done though - I'd prefer to
see a separate case for (shift < 0) giving an unconditional error.
Handling both the HV success case and the failure case in that first
branch is unnecessarily subtle and confusing, IMO.
> ---
> hw/ppc/spapr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index e1202ce..ec6e141 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1022,7 +1022,7 @@ static void spapr_alloc_htab(sPAPRMachineState *spapr)
>
> shift = kvmppc_reset_htab(spapr->htab_shift);
>
> - if (shift > 0) {
> + if (shift != 0) {
> /* Kernel handles htab, we don't need to allocate one */
> if (shift != spapr->htab_shift) {
> error_setg(&error_abort, "Failed to allocate HTAB of requested
> size, try with smaller maxmem");
> @@ -1055,7 +1055,7 @@ static void spapr_reset_htab(sPAPRMachineState *spapr)
> int index;
>
> shift = kvmppc_reset_htab(spapr->htab_shift);
> - if (shift > 0) {
> + if (shift != 0) {
> if (shift != spapr->htab_shift) {
> error_setg(&error_abort, "Requested HTAB allocation failed
> during reset");
> }
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature