Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808934/?format=api
{ "id": 808934, "url": "http://patchwork.ozlabs.org/api/patches/808934/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170901180340.30009-28-eblake@redhat.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170901180340.30009-28-eblake@redhat.com>", "list_archive_url": null, "date": "2017-09-01T18:03:38", "name": "[v6,27/29] libqtest: Make qtest_init() accept format string", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "deaec3f2e8afe076302b85235e40fbd230cb05f4", "submitter": { "id": 6591, "url": "http://patchwork.ozlabs.org/api/people/6591/?format=api", "name": "Eric Blake", "email": "eblake@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20170901180340.30009-28-eblake@redhat.com/mbox/", "series": [ { "id": 1089, "url": "http://patchwork.ozlabs.org/api/series/1089/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=1089", "date": "2017-09-01T18:03:12", "name": "Preliminary libqtest cleanups", "version": 6, "mbox": "http://patchwork.ozlabs.org/series/1089/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808934/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808934/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx08.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com" ], "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xkSHQ3cYnz9sNr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 2 Sep 2017 04:21:22 +1000 (AEST)", "from localhost ([::1]:53348 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnqZE-000782-GZ\n\tfor incoming@patchwork.ozlabs.org; Fri, 01 Sep 2017 14:21:20 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:56374)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dnqJ0-0007cj-26\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:37 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dnqIu-00025j-PV\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:34 -0400", "from mx1.redhat.com ([209.132.183.28]:33440)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>) id 1dnqIu-00025I-Hj\n\tfor qemu-devel@nongnu.org; Fri, 01 Sep 2017 14:04:28 -0400", "from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 9A9DEC056819\n\tfor <qemu-devel@nongnu.org>; Fri, 1 Sep 2017 18:04:27 +0000 (UTC)", "from red.redhat.com (ovpn-121-149.rdu2.redhat.com [10.10.121.149])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 130325450A;\n\tFri, 1 Sep 2017 18:04:24 +0000 (UTC)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 9A9DEC056819", "From": "Eric Blake <eblake@redhat.com>", "To": "qemu-devel@nongnu.org", "Date": "Fri, 1 Sep 2017 13:03:38 -0500", "Message-Id": "<20170901180340.30009-28-eblake@redhat.com>", "In-Reply-To": "<20170901180340.30009-1-eblake@redhat.com>", "References": "<20170901180340.30009-1-eblake@redhat.com>", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.15", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.32]);\n\tFri, 01 Sep 2017 18:04:27 +0000 (UTC)", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "209.132.183.28", "Subject": "[Qemu-devel] [PATCH v6 27/29] libqtest: Make qtest_init() accept\n\tformat string", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "pbonzini@redhat.com, Igor Mammedov <imammedo@redhat.com>,\n\tarmbru@redhat.com, \"Michael S. Tsirkin\" <mst@redhat.com>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "Several callers were formatting a string into a temporary\nvariable before calling qtest_init(); factor that into the\ncommon code.\n\nSigned-off-by: Eric Blake <eblake@redhat.com>\n---\n tests/libqtest.h | 7 ++++---\n tests/libqtest.c | 13 ++++++++++--\n tests/bios-tables-test.c | 7 +------\n tests/postcopy-test.c | 4 ++--\n tests/vhost-user-test.c | 51 ++++++++++++++----------------------------------\n 5 files changed, 33 insertions(+), 49 deletions(-)", "diff": "diff --git a/tests/libqtest.h b/tests/libqtest.h\nindex 3ae570927a..d338de3e22 100644\n--- a/tests/libqtest.h\n+++ b/tests/libqtest.h\n@@ -25,11 +25,12 @@ extern QTestState *global_qtest;\n\n /**\n * qtest_init:\n- * @extra_args: other arguments to pass to QEMU.\n+ * @extra_args...: other arguments to pass to QEMU, formatted as if by\n+ * sprintf().\n *\n * Returns: #QTestState instance.\n */\n-QTestState *qtest_init(const char *extra_args);\n+QTestState *qtest_init(const char *extra_args, ...) GCC_FMT_ATTR(1, 2);\n\n /**\n * qtest_init_without_qmp_handshake:\n@@ -518,7 +519,7 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data);\n */\n static inline QTestState *qtest_start(const char *args)\n {\n- global_qtest = qtest_init(args);\n+ global_qtest = qtest_init(\"%s\", args);\n return global_qtest;\n }\n\ndiff --git a/tests/libqtest.c b/tests/libqtest.c\nindex b6dd26e54a..18facbf130 100644\n--- a/tests/libqtest.c\n+++ b/tests/libqtest.c\n@@ -347,9 +347,18 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)\n return s;\n }\n\n-QTestState *qtest_init(const char *extra_args)\n+QTestState *qtest_init(const char *extra_args, ...)\n {\n- QTestState *s = qtest_init_without_qmp_handshake(extra_args);\n+ va_list ap;\n+ QTestState *s;\n+ char *cmd;\n+\n+ va_start(ap, extra_args);\n+ cmd = g_strdup_vprintf(extra_args, ap);\n+ va_end(ap);\n+\n+ s = qtest_init_without_qmp_handshake(cmd);\n+ g_free(cmd);\n\n /* Read the QMP greeting and then do the handshake */\n qtest_qmp_discard_response(s, \"\");\ndiff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c\nindex 976792f2c5..f8a107499f 100644\n--- a/tests/bios-tables-test.c\n+++ b/tests/bios-tables-test.c\n@@ -623,18 +623,14 @@ static void test_smbios_structs(test_data *data)\n\n static void test_acpi_one(const char *params, test_data *data)\n {\n- char *args;\n-\n /* Disable kernel irqchip to be able to override apic irq0. */\n- args = g_strdup_printf(\"-machine %s,accel=%s,kernel-irqchip=off \"\n+ data->qts = qtest_init(\"-machine %s,accel=%s,kernel-irqchip=off \"\n \"-net none -display none %s \"\n \"-drive id=hd0,if=none,file=%s,format=raw \"\n \"-device ide-hd,drive=hd0 \",\n data->machine, \"kvm:tcg\",\n params ? params : \"\", disk);\n\n- data->qts = qtest_init(args);\n-\n boot_sector_test(data->qts);\n\n test_acpi_rsdp_address(data);\n@@ -657,7 +653,6 @@ static void test_acpi_one(const char *params, test_data *data)\n test_smbios_structs(data);\n\n qtest_quit(data->qts);\n- g_free(args);\n }\n\n static uint8_t base_required_struct_types[] = {\ndiff --git a/tests/postcopy-test.c b/tests/postcopy-test.c\nindex 0e5fe20a83..20cfb280f6 100644\n--- a/tests/postcopy-test.c\n+++ b/tests/postcopy-test.c\n@@ -403,10 +403,10 @@ static void test_migrate(void)\n\n g_free(bootpath);\n\n- from = qtest_init(cmd_src);\n+ from = qtest_init(\"%s\", cmd_src);\n g_free(cmd_src);\n\n- to = qtest_init(cmd_dst);\n+ to = qtest_init(\"%s\", cmd_dst);\n g_free(cmd_dst);\n\n assert(!global_qtest);\ndiff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c\nindex 1e0c50d12a..0dbed5a36a 100644\n--- a/tests/vhost-user-test.c\n+++ b/tests/vhost-user-test.c\n@@ -482,12 +482,12 @@ static inline void test_server_connect(TestServer *server)\n }\n\n #define GET_QEMU_CMD(s) \\\n- g_strdup_printf(QEMU_CMD, 512, 512, (root), (s)->chr_name, \\\n- (s)->socket_path, \"\", (s)->chr_name)\n+ QEMU_CMD, 512, 512, (root), (s)->chr_name, \\\n+ (s)->socket_path, \"\", (s)->chr_name\n\n #define GET_QEMU_CMDE(s, mem, chr_opts, extra, ...) \\\n- g_strdup_printf(QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \\\n- (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__)\n+ QEMU_CMD extra, (mem), (mem), (root), (s)->chr_name, \\\n+ (s)->socket_path, (chr_opts), (s)->chr_name, ##__VA_ARGS__\n\n static gboolean _test_server_free(TestServer *server)\n {\n@@ -637,7 +637,6 @@ static void test_migrate(void)\n TestServer *dest = test_server_new(\"dest\");\n char *uri = g_strdup_printf(\"%s%s\", \"unix:\", dest->mig_path);\n GSource *source;\n- gchar *cmd;\n QDict *rsp;\n guint8 *log;\n guint64 size;\n@@ -645,18 +644,14 @@ static void test_migrate(void)\n test_server_listen(s);\n test_server_listen(dest);\n\n- cmd = GET_QEMU_CMDE(s, 2, \"\", \"\");\n- s->qts = qtest_init(cmd);\n- g_free(cmd);\n+ s->qts = qtest_init(GET_QEMU_CMDE(s, 2, \"\", \"\"));\n\n init_virtio_dev(s);\n wait_for_fds(s);\n size = get_log_size(s);\n g_assert_cmpint(size, ==, (2 * 1024 * 1024) / (VHOST_LOG_PAGE * 8));\n\n- cmd = GET_QEMU_CMDE(dest, 2, \"\", \" -incoming %s\", uri);\n- dest->qts = qtest_init(cmd);\n- g_free(cmd);\n+ dest->qts = qtest_init(GET_QEMU_CMDE(dest, 2, \"\", \" -incoming %s\", uri));\n\n source = g_source_new(&test_migrate_source_funcs,\n sizeof(TestMigrateSource));\n@@ -749,12 +744,9 @@ connect_thread(gpointer data)\n static void test_reconnect_subprocess(void)\n {\n TestServer *s = test_server_new(\"reconnect\");\n- char *cmd;\n\n g_thread_new(\"connect\", connect_thread, s);\n- cmd = GET_QEMU_CMDE(s, 2, \",server\", \"\");\n- s->qts = qtest_init(cmd);\n- g_free(cmd);\n+ s->qts = qtest_init(GET_QEMU_CMDE(s, 2, \",server\", \"\"));\n\n init_virtio_dev(s);\n wait_for_fds(s);\n@@ -783,13 +775,10 @@ static void test_reconnect(void)\n static void test_connect_fail_subprocess(void)\n {\n TestServer *s = test_server_new(\"connect-fail\");\n- char *cmd;\n\n s->test_fail = true;\n g_thread_new(\"connect\", connect_thread, s);\n- cmd = GET_QEMU_CMDE(s, 2, \",server\", \"\");\n- s->qts = qtest_init(cmd);\n- g_free(cmd);\n+ s->qts = qtest_init(GET_QEMU_CMDE(s, 2, \",server\", \"\"));\n\n init_virtio_dev(s);\n wait_for_fds(s);\n@@ -810,13 +799,10 @@ static void test_connect_fail(void)\n static void test_flags_mismatch_subprocess(void)\n {\n TestServer *s = test_server_new(\"flags-mismatch\");\n- char *cmd;\n\n s->test_flags = TEST_FLAGS_DISCONNECT;\n g_thread_new(\"connect\", connect_thread, s);\n- cmd = GET_QEMU_CMDE(s, 2, \",server\", \"\");\n- s->qts = qtest_init(cmd);\n- g_free(cmd);\n+ s->qts = qtest_init(GET_QEMU_CMDE(s, 2, \",server\", \"\"));\n\n init_virtio_dev(s);\n wait_for_fds(s);\n@@ -875,19 +861,16 @@ static void test_multiqueue(void)\n QPCIBus *bus;\n QVirtQueuePCI *vq[queues * 2];\n QGuestAllocator *alloc;\n- char *cmd;\n int i;\n\n s->queues = queues;\n test_server_listen(s);\n\n- cmd = g_strdup_printf(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV \",queues=%d \"\n- \"-device virtio-net-pci,netdev=net0,mq=on,vectors=%d\",\n- 512, 512, root, s->chr_name,\n- s->socket_path, \"\", s->chr_name,\n- queues, queues * 2 + 2);\n- s->qts = qtest_init(cmd);\n- g_free(cmd);\n+ s->qts = qtest_init(QEMU_CMD_MEM QEMU_CMD_CHR QEMU_CMD_NETDEV \",queues=%d \"\n+ \"-device virtio-net-pci,netdev=net0,mq=on,vectors=%d\",\n+ 512, 512, root, s->chr_name,\n+ s->socket_path, \"\", s->chr_name,\n+ queues, queues * 2 + 2);\n\n bus = qpci_init_pc(s->qts, NULL);\n dev = virtio_net_pci_init(bus, PCI_SLOT);\n@@ -917,7 +900,6 @@ int main(int argc, char **argv)\n {\n TestServer *server = NULL;\n const char *hugefs;\n- char *qemu_cmd = NULL;\n int ret;\n char template[] = \"/tmp/vhost-test-XXXXXX\";\n GMainLoop *loop;\n@@ -949,10 +931,7 @@ int main(int argc, char **argv)\n /* run the main loop thread so the chardev may operate */\n thread = g_thread_new(NULL, thread_function, loop);\n\n- qemu_cmd = GET_QEMU_CMD(server);\n-\n- server->qts = qtest_init(qemu_cmd);\n- g_free(qemu_cmd);\n+ server->qts = qtest_init(GET_QEMU_CMD(server));\n init_virtio_dev(server);\n\n qtest_add_data_func(\"/vhost-user/read-guest-mem\", server, read_guest_mem);\n", "prefixes": [ "v6", "27/29" ] }