public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Janosch Frank <frankja@linux.ibm.com>
To: Pierre Morel <pmorel@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, thuth@redhat.com,
	kvm@vger.kernel.org, cohuck@redhat.com, david@redhat.com,
	nrb@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH 1/1] s390x: stsi: Define vm_is_kvm to be used in different tests
Date: Wed, 16 Feb 2022 13:55:23 +0100	[thread overview]
Message-ID: <a889bd74-0e4a-8ca7-4f45-34fb4e306d7f@linux.ibm.com> (raw)
In-Reply-To: <f5ff2f8a-1cba-d429-ad2b-32ce4ce47465@linux.ibm.com>

On 2/16/22 13:26, Pierre Morel wrote:
> 
> 
> On 2/16/22 09:13, Janosch Frank wrote:
>> On 2/15/22 18:30, Pierre Morel wrote:
>>>
>>>
>>> On 2/15/22 16:21, Claudio Imbrenda wrote:
>>>> On Tue, 15 Feb 2022 16:08:16 +0100
>>>> Janosch Frank <frankja@linux.ibm.com> wrote:
>>>>
>>>>> On 2/15/22 13:06, Claudio Imbrenda wrote:
>>>>>> On Tue, 15 Feb 2022 11:46:32 +0100
>>>>>> Pierre Morel <pmorel@linux.ibm.com> wrote:
>>>>>>> Several tests are in need of a way to check on which hypervisor
>>>>>>> and virtualization level they are running on to be able to fence
>>>>>>> certain tests. This patch adds functions that return true if a
>>>>>>> vm is running under KVM, LPAR or generally as a level 2 guest.
>>>>>>>
>>>>>>> To check if we're running under KVM we use the STSI 3.2.2
>>>>>>> instruction, let's define it's response structure in a central
>>>>>>> header.
>>>>>>
>>>>>> sorry, I had replied to the old series, let me reply here too
>>>>>>
>>>>>>
>>>>>> I think it would look cleaner if there was only one
>>>>>> "detect_environment" function, that would call stsi once and detect
>>>>>> the
>>>>>> environment, then the various vm_is_* would become something like
>>>>>>
>>>>>> bool vm_is_*(void)
>>>>>> {
>>>>>>      return detect_environment() == VM_IS_*;
>>>>>> }
>>>>>>
>>>>>> of course detect_environment would also cache the result with static
>>>>>> variables.
>>>>>>
>>>>>> bonus, we could make that function public, so a testcase could just
>>>>>> switch over the type of hypervisor it's being run on, instead of
>>>>>> having
>>>>>> to use a series of ifs.
>>>>>>
>>>>>> and then maybe the various vm_is_* could become static inlines to
>>>>>> be put
>>>>>> in the header.
>>>>>>
>>>>>> please note that "detect_environment" is just the first thing that
>>>>>> came
>>>>>> to my mind, I have no preference regarding the name.
>>>>>
>>>>> I'd like to keep this patch as simple as possible because there are
>>>>> multiple patch sets which are gated by it.
>>>>>
>>>>> The vm.h code and the skey.c z/VM 6 check is a thorn in my side anyway
>>>>> and I'd rather have it fixed properly which will likely result in a lot
>>>>> of opinions being voiced.
>>>>>
>>>>> So I'd propose to rename vm_is_vm() to vm_is_guest2() and pick this
>>>>> patch.
>>>>
>>>> ok for me
>>>>
>>>> I'll rename the function and queue the patch
>>>>
>>>
>>> Not OK for me, in the POP PTF do not do any difference between guest 2
>>> and guest 3.
>>
>> If we're running with HW virtualization then every guest >= 2 is a guest
>> 2 at the end. And most of the time we don't want to know the HW level
>> anyway, we want to know who our hypervisor is and vm_is_vm() doesn't
>> tell you one bit about that.
> 
> It tells us that we are running under a VM, the POP defines 1 as the
> basic machine, 2 as the LPAR and 3 as the Virtual Machine
> 
> I find this definition clear, much more clear than guest 2 that is why I
> used it.
> 
>>
>> At this point I would be happier if we remove the function and use
>> stsi_get_fc() == 3 directly. There's no arguing about what we're
>> checking when using that.
> 
> Speaking of function name, I do not understand the name of this function
> stsi_get_fc() : returning the function code ?

I guess it should be stsi_get_current_level() or something like that.
Let me add that to the list of vm.h rework items.

> 
>>
>> We're currently arguing about a function that's only used in this patch,
>> no?
> 
> It is absolutely unimportant for me, if you prefer this we do this.
> I send the changes.

      reply	other threads:[~2022-02-16 12:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15 10:46 [kvm-unit-tests PATCH 0/1] s390x: stsi: Define vm_is_kvm to be used in different tests Pierre Morel
2022-02-15 10:46 ` [kvm-unit-tests PATCH 1/1] " Pierre Morel
2022-02-15 12:06   ` Claudio Imbrenda
2022-02-15 15:08     ` Janosch Frank
2022-02-15 15:21       ` Claudio Imbrenda
2022-02-15 17:30         ` Pierre Morel
2022-02-16  8:13           ` Janosch Frank
2022-02-16 12:26             ` Pierre Morel
2022-02-16 12:55               ` Janosch Frank [this message]

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=a889bd74-0e4a-8ca7-4f45-34fb4e306d7f@linux.ibm.com \
    --to=frankja@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=pmorel@linux.ibm.com \
    --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