From: Thomas Huth <thuth@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
"Victor Kaplansky" <victork@redhat.com>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
qemu-s390x@nongnu.org, "Hervé Poussineau" <hpoussin@reactos.org>
Subject: Re: [Qemu-devel] [PATCH 2/3] tests/cdboot: Test booting from CD-ROM ISO image file
Date: Thu, 15 Mar 2018 11:48:31 +0100 [thread overview]
Message-ID: <3d3a009b-37c3-86b0-a734-e1783f507e60@redhat.com> (raw)
In-Reply-To: <20180315092110.GD3146@redhat.com>
On 15.03.2018 10:21, Daniel P. Berrangé wrote:
> On Thu, Mar 15, 2018 at 08:49:04AM +0100, Thomas Huth wrote:
>> We already have the code for a boot file in tests/boot-sector.c,
>> so if the genisoimage program is available, we can easily create
>> a bootable CD ISO image that we can use for testing whether our
>> CD-ROM emulation and the BIOS CD-ROM boot works correctly.
>>
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>> tests/Makefile.include | 3 +
>> tests/cdrom-test.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 158 insertions(+)
>> create mode 100644 tests/cdrom-test.c
>>
>> diff --git a/tests/Makefile.include b/tests/Makefile.include
>> index ef9b88c..a104222 100644
>> --- a/tests/Makefile.include
>> +++ b/tests/Makefile.include
>> @@ -304,6 +304,7 @@ check-qtest-i386-$(CONFIG_POSIX) += tests/test-filter-redirector$(EXESUF)
>> check-qtest-i386-y += tests/migration-test$(EXESUF)
>> check-qtest-i386-y += tests/test-x86-cpuid-compat$(EXESUF)
>> check-qtest-i386-y += tests/numa-test$(EXESUF)
>> +check-qtest-i386-y += tests/cdrom-test$(EXESUF)
>> check-qtest-x86_64-y += $(check-qtest-i386-y)
>> check-qtest-x86_64-y += tests/sdhci-test$(EXESUF)
>> gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
>> @@ -398,6 +399,7 @@ check-qtest-s390x-y += tests/virtio-balloon-test$(EXESUF)
>> check-qtest-s390x-y += tests/virtio-console-test$(EXESUF)
>> check-qtest-s390x-y += tests/virtio-serial-test$(EXESUF)
>> check-qtest-s390x-y += tests/cpu-plug-test$(EXESUF)
>> +check-qtest-s390x-y += tests/cdrom-test$(EXESUF)
>>
>> check-qtest-generic-y += tests/qom-test$(EXESUF)
>> check-qtest-generic-y += tests/test-hmp$(EXESUF)
>> @@ -829,6 +831,7 @@ tests/test-qapi-util$(EXESUF): tests/test-qapi-util.o $(test-util-obj-y)
>> tests/numa-test$(EXESUF): tests/numa-test.o
>> tests/vmgenid-test$(EXESUF): tests/vmgenid-test.o tests/boot-sector.o tests/acpi-utils.o
>> tests/sdhci-test$(EXESUF): tests/sdhci-test.o $(libqos-pc-obj-y)
>> +tests/cdrom-test$(EXESUF): tests/cdrom-test.o tests/boot-sector.o $(libqos-obj-y)
>>
>> tests/migration/stress$(EXESUF): tests/migration/stress.o
>> $(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"LINK","$(TARGET_DIR)$@")
>> diff --git a/tests/cdrom-test.c b/tests/cdrom-test.c
>> new file mode 100644
>> index 0000000..1fc5230
>> --- /dev/null
>> +++ b/tests/cdrom-test.c
>> @@ -0,0 +1,155 @@
>> +/*
>> + * Various tests for emulated CD-ROM drives.
>> + *
>> + * Copyright (c) 2018 Red Hat Inc.
>> + *
>> + * Author:
>> + * Thomas Huth <thuth@redhat.com>
>> + *
>> + * This work is licensed under the terms of the GNU GPL, version 2
>> + * or later. See the COPYING file in the top-level directory.
>> + */
>> +
>> +#include "qemu/osdep.h"
>> +#include "libqtest.h"
>> +#include "boot-sector.h"
>> +
>> +static char isoimage[] = "cdrom-boot-iso-XXXXXX";
>> +
>> +static int gen_iso(const char *fmt, ...)
>> +{
>> + char *params, *command;
>> + va_list args;
>> + pid_t pid;
>> + int status;
>> +
>> + pid = fork();
>> + if (pid == 0) {
>> + va_start(args, fmt);
>> + params = g_strdup_vprintf(fmt, args);
>> + va_end(args);
>> + command = g_strdup_printf("exec genisoimage %s", params);
>> + g_free(params);
>> + execlp("/bin/sh", "sh", "-c", command, NULL);
>> + exit(1);
>> + }
>> + wait(&status);
>
> IMHO this should just use g_spawn_sync(), also the use of
> shell seems rather unneccessary - why not just run genisoimage
> directly ?
That code was simply "inspired" from the execlp() code in
qtest_init_without_qmp_handshake() ... but g_spawn_sync() sounds like a
good alternative here, so I'll try to switch to that one instead.
Thanks,
Thomas
next prev parent reply other threads:[~2018-03-15 10:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 7:49 [Qemu-devel] [PATCH 0/3] Add new CD-ROM related qtests Thomas Huth
2018-03-15 7:49 ` [Qemu-devel] [PATCH 1/3] tests/boot-sector: Add magic bytes to s390x boot code header Thomas Huth
2018-03-15 8:10 ` [Qemu-devel] [qemu-s390x] " Christian Borntraeger
2018-03-15 11:47 ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-03-15 19:32 ` Thomas Huth
2018-03-15 20:18 ` Michael S. Tsirkin
2018-03-15 7:49 ` [Qemu-devel] [PATCH 2/3] tests/cdboot: Test booting from CD-ROM ISO image file Thomas Huth
2018-03-15 9:21 ` Daniel P. Berrangé
2018-03-15 10:48 ` Thomas Huth [this message]
2018-03-15 11:57 ` Eric Blake
2018-03-15 7:49 ` [Qemu-devel] [PATCH 3/3] tests/cdrom-test: Test that -cdrom parameter is working Thomas Huth
2018-03-15 11:42 ` Philippe Mathieu-Daudé
2018-03-15 19:34 ` Thomas Huth
2018-03-15 11:58 ` Eric Blake
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=3d3a009b-37c3-86b0-a734-e1783f507e60@redhat.com \
--to=thuth@redhat.com \
--cc=berrange@redhat.com \
--cc=hpoussin@reactos.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=victork@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).