From: Farhan Ali <alifm@linux.ibm.com>
To: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>,
	cohuck@redhat.com, borntraeger@de.ibm.com, agraf@suse.de,
	rth@twiddle.net, david@redhat.com, thuth@redhat.com,
	qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] s390: Ensure IPL from SCSI works as expected
Date: Thu, 5 Apr 2018 12:54:29 -0400	[thread overview]
Message-ID: <5ea0dfa8-0965-4851-8bf6-7fc850c4dbce@linux.ibm.com> (raw)
In-Reply-To: <1522940844-12336-3-git-send-email-mihajlov@linux.vnet.ibm.com>
On 04/05/2018 11:07 AM, Viktor Mihajlovski wrote:
> Operating systems may request an IPL from a virtio-scsi device
> by specifying an IPL parameter type of CCW. In this case QEMU
> won't set up the IPLB correctly. The BIOS will still detect
> it's a SCSI device to boot from, but it will now have to search
> for the first LUN and attempt to boot from there.
> However this may not be the original boot LUN if there's more than
> one SCSI disk attached to the HBA.
> 
> With this change QEMU will detect that the request is for a
> SCSI device and will rebuild the initial IPL parameter info
> if it's the SCSI device used for the first boot. In consequence
> the BIOS can use the boot LUN from the IPL information block.
> 
> In case a different SCSI device has been set, the BIOS will find
> and use the first available LUN.
> 
> Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
> ---
>   hw/s390x/ipl.c | 31 +++++++++++++++++++++++++++++--
>   1 file changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 58e33c5..fb554ab 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -427,7 +427,8 @@ unref_mr:
>       return img_size;
>   }
> 
> -static bool is_virtio_net_device(IplParameterBlock *iplb)
> +static bool is_virtio_ccw_device_of_type(IplParameterBlock *iplb,
> +                                         int virtio_id)
>   {
>       uint8_t cssid;
>       uint8_t ssid;
> @@ -447,13 +448,23 @@ static bool is_virtio_net_device(IplParameterBlock *iplb)
>               sch = css_find_subch(1, cssid, ssid, schid);
> 
>               if (sch && sch->devno == devno) {
> -                return sch->id.cu_model == VIRTIO_ID_NET;
> +                return sch->id.cu_model == virtio_id;
>               }
>           }
>       }
>       return false;
>   }
> 
> +static bool is_virtio_net_device(IplParameterBlock *iplb)
> +{
> +    return is_virtio_ccw_device_of_type(iplb, VIRTIO_ID_NET);
> +}
> +
> +static bool is_virtio_scsi_device(IplParameterBlock *iplb)
> +{
> +    return is_virtio_ccw_device_of_type(iplb, VIRTIO_ID_SCSI);
> +}
> +
>   void s390_ipl_update_diag308(IplParameterBlock *iplb)
>   {
>       S390IPLState *ipl = get_ipl_device();
> @@ -478,6 +489,22 @@ void s390_reipl_request(void)
>       S390IPLState *ipl = get_ipl_device();
> 
>       ipl->reipl_requested = true;
> +    if (ipl->iplb_valid &&
> +        !ipl->netboot &&
> +        ipl->iplb.pbt == S390_IPL_TYPE_CCW &&
> +        is_virtio_scsi_device(&ipl->iplb)) {
> +        CcwDevice *ccw_dev = s390_get_ccw_device(get_boot_device(0));
> +
> +        if (ccw_dev &&
> +            cpu_to_be16(ccw_dev->sch->devno) == ipl->iplb.ccw.devno &&
> +            (ccw_dev->sch->ssid & 3) == ipl->iplb.ccw.ssid) {
> +            /*
> +             * this is the original boot device's SCSI
> +             * so restore IPL parameter info from it
> +             */
> +            ipl->iplb_valid = s390_gen_initial_iplb(ipl);
> +        }
> +    }
>       qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
>   }
> 
This does feel a little hackish, but I can't think of a better way to 
ensure the correct SCSI device is used for booting.
Reviewed-by: Farhan Ali <alifm@linux.vnet.ibm.com>
next prev parent reply	other threads:[~2018-04-05 16:54 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 15:07 [Qemu-devel] [PATCH 0/3] s390: Fix virtio-scsi IPL quirks Viktor Mihajlovski
2018-04-05 15:07 ` [Qemu-devel] [PATCH 1/3] s390: Refactor IPL parameter block generation Viktor Mihajlovski
2018-04-05 16:21   ` Farhan Ali
2018-04-06  7:52   ` Thomas Huth
2018-04-06  9:34     ` Cornelia Huck
2018-04-05 15:07 ` [Qemu-devel] [PATCH 2/3] s390: Ensure IPL from SCSI works as expected Viktor Mihajlovski
2018-04-05 16:54   ` Farhan Ali [this message]
2018-04-06  8:37   ` Thomas Huth
2018-04-05 15:07 ` [Qemu-devel] [PATCH 3/3] s390: Do not pass inofficial IPL type to the guest Viktor Mihajlovski
2018-04-05 15:11   ` David Hildenbrand
2018-04-05 15:16     ` Viktor VM Mihajlovski
2018-04-06  9:28   ` Thomas Huth
2018-04-06  9:42     ` Cornelia Huck
2018-04-06 10:43     ` Viktor VM Mihajlovski
2018-04-06 10:56   ` Christian Borntraeger
2018-04-06  9:47 ` [Qemu-devel] [PATCH 0/3] s390: Fix virtio-scsi IPL quirks Cornelia Huck
2018-04-06 12:30 ` Christian Borntraeger
2018-04-06 12:34   ` Cornelia Huck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=5ea0dfa8-0965-4851-8bf6-7fc850c4dbce@linux.ibm.com \
    --to=alifm@linux.ibm.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=mihajlov@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).