From patchwork Thu Dec 13 22:02:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Baron X-Patchwork-Id: 206246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B7E32C0089 for ; Fri, 14 Dec 2012 09:02:45 +1100 (EST) Received: from localhost ([::1]:51267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjGrb-0003l0-3P for incoming@patchwork.ozlabs.org; Thu, 13 Dec 2012 17:02:43 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjGrJ-0003gR-QY for qemu-devel@nongnu.org; Thu, 13 Dec 2012 17:02:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjGrH-0007r5-Ad for qemu-devel@nongnu.org; Thu, 13 Dec 2012 17:02:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48225) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjGrH-0007qO-40 for qemu-devel@nongnu.org; Thu, 13 Dec 2012 17:02:23 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBDM2M3b025383 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Dec 2012 17:02:22 -0500 Received: from redhat.com (dhcp-185-114.bos.redhat.com [10.16.185.114]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBDM2Lpo019838; Thu, 13 Dec 2012 17:02:21 -0500 Date: Thu, 13 Dec 2012 17:02:21 -0500 From: Jason Baron To: qemu-devel@nongnu.org Message-Id: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 1/3] qtest: Enable creation of multiple qemu instances X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jason Baron Currently, the qtest harness can only spawn 1 qemu instance at a time because the parent pid is used to create the socket files. Use the child pid instead, so we can remove that limitation. Signed-off-by: Jason Baron --- tests/libqtest.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 71b84c1..f3dd4e4 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -101,6 +101,10 @@ static pid_t qtest_qemu_pid(QTestState *s) return pid; } +#define QTEST_FILE_TEMP "/tmp/qtest-%d.sock" +#define QTEST_QMP_FILE_TEMP "/tmp/qtest-%d.qmp" +#define QTEST_PID_FILE_TEMP "/tmp/qtest-%d.pid" + QTestState *qtest_init(const char *extra_args) { QTestState *s; @@ -113,25 +117,16 @@ QTestState *qtest_init(const char *extra_args) qemu_binary = getenv("QTEST_QEMU_BINARY"); g_assert(qemu_binary != NULL); - s = g_malloc(sizeof(*s)); - - s->socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid()); - s->qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid()); - pid_file = g_strdup_printf("/tmp/qtest-%d.pid", getpid()); - - sock = init_socket(s->socket_path); - qmpsock = init_socket(s->qmp_socket_path); - pid = fork(); if (pid == 0) { command = g_strdup_printf("%s " - "-qtest unix:%s,nowait " + "-qtest unix:" QTEST_FILE_TEMP ",nowait " "-qtest-log /dev/null " - "-qmp unix:%s,nowait " - "-pidfile %s " + "-qmp unix:" QTEST_QMP_FILE_TEMP ",nowait " + "-pidfile " QTEST_PID_FILE_TEMP " " "-machine accel=qtest " - "%s", qemu_binary, s->socket_path, - s->qmp_socket_path, pid_file, + "%s", qemu_binary, getpid(), + getpid(), getpid(), extra_args ?: ""); ret = system(command); @@ -139,6 +134,14 @@ QTestState *qtest_init(const char *extra_args) g_free(command); } + s = g_malloc(sizeof(*s)); + s->socket_path = g_strdup_printf(QTEST_FILE_TEMP, pid); + s->qmp_socket_path = g_strdup_printf(QTEST_QMP_FILE_TEMP, pid); + pid_file = g_strdup_printf(QTEST_PID_FILE_TEMP, pid); + + sock = init_socket(s->socket_path); + qmpsock = init_socket(s->qmp_socket_path); + s->fd = socket_accept(sock); s->qmp_fd = socket_accept(qmpsock);