Linux Test Project
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 1/2] KVM test infrastructure
Date: Thu, 17 Mar 2022 07:59:19 +0000	[thread overview]
Message-ID: <87tubx3s9j.fsf@suse.de> (raw)
In-Reply-To: <60ee7094-fc86-b06c-87e5-500018d9de29@suse.cz>

Hi,

Martin Doucha <mdoucha@suse.cz> writes:

> On 15. 03. 22 16:00, Richard Palethorpe wrote:
>> Hi Martin,
>> 
>> Martin Doucha <mdoucha@suse.cz> writes:
>>> +void tst_kvm_print_result(const struct tst_kvm_result *result)
>>> +{
>>> +	int ttype;
>>> +
>>> +	tst_kvm_validate_result(result->result);
>>> +	ttype = TTYPE_RESULT(result->result);
>>> +
>>> +	if (ttype == TBROK)
>>> +		tst_brk(ttype, "%s", result->message);
>>> +	else
>>> +		tst_res(ttype, "%s", result->message);
>>> +}
>> 
>> Could you please pass the file and lineno from the test?
>
> I've skipped that mainly because passing the filename would require an
> extra string buffer in the result structure. But I guess I can pass just
> a 64bit string address since the filename is a string constant and then
> read the text from the VM memory buffer.

Either way sounds good to me.

>
>>> +void tst_kvm_create_instance(struct tst_kvm_instance *inst, size_t ram_size)
>>> +{
>>> +	int sys_fd;
>>> +	size_t pagesize, result_pageaddr = KVM_RESULT_BASEADDR;
>>> +	char *vm_result, *reset_ptr;
>>> +	struct kvm_cpuid2 *cpuid_data;
>>> +	const size_t payload_size = kvm_payload_end - kvm_payload_start;
>>> +
>>> +	memset(inst, 0, sizeof(struct tst_kvm_instance));
>>> +	inst->vm_fd = -1;
>>> +	inst->vcpu_fd = -1;
>>> +	inst->vcpu_info = MAP_FAILED;
>>> +
>>> +	pagesize = SAFE_SYSCONF(_SC_PAGESIZE);
>>> +	result_pageaddr -= result_pageaddr % pagesize;
>>> +
>>> +	if (payload_size + MIN_FREE_RAM > ram_size - VM_KERNEL_BASEADDR) {
>>> +		ram_size = payload_size + MIN_FREE_RAM + VM_KERNEL_BASEADDR;
>>> +		ram_size += 1024 * 1024 - 1;
>>> +		ram_size -= ram_size % (1024 * 1024);
>>> +		tst_res(TWARN, "RAM size increased to %zu bytes", ram_size);
>>> +	}
>>> +
>>> +	if (ram_size > result_pageaddr) {
>>> +		ram_size = result_pageaddr;
>>> +		tst_res(TWARN, "RAM size truncated to %zu bytes", ram_size);
>>> +	}
>>> +
>>> +	/* Create VM */
>> 
>> These comments are pretty redundant when we have ioctl's like
>> KVM_CREATE_VM and KVM_CREATE_VCPU. There are much harder things to
>> understand in this patchset.
>
> I know that the code is straightforward. But it's quite dense so I've
> added the comments as section headers for easier navigation when you
> need to change something.

Makes sense. However the style guide forbids commenting the obvious.

-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-03-17  8:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-09 16:49 [LTP] [PATCH 1/2] KVM test infrastructure Martin Doucha
2022-03-09 16:49 ` [LTP] [PATCH 2/2] Add test for CVE 2021-38198 Martin Doucha
2022-03-15 14:19   ` Richard Palethorpe
2022-03-15 15:04     ` Martin Doucha
2022-03-15 15:44       ` Richard Palethorpe
2022-03-15 16:14         ` Martin Doucha
2022-03-17  7:35           ` Richard Palethorpe
2022-03-17 11:55             ` Martin Doucha
2022-03-09 19:13 ` [LTP] [PATCH 1/2] KVM test infrastructure Petr Vorel
2022-03-10 14:10   ` Martin Doucha
2022-03-10 20:41     ` Petr Vorel
2022-03-15 15:00 ` Richard Palethorpe
2022-03-16 17:03   ` Martin Doucha
2022-03-17  7:59     ` Richard Palethorpe [this message]
2022-03-17  8:16     ` Li Wang
2022-03-17 10:42   ` Richard Palethorpe

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=87tubx3s9j.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /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