From patchwork Tue Jul 17 14:17:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 171460 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 885112C00BA for ; Wed, 18 Jul 2012 01:27:59 +1000 (EST) Received: from localhost ([::1]:38921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr8aR-0005H3-L6 for incoming@patchwork.ozlabs.org; Tue, 17 Jul 2012 10:17:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr8Zo-0003xN-El for qemu-devel@nongnu.org; Tue, 17 Jul 2012 10:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sr8Zh-0008AD-P5 for qemu-devel@nongnu.org; Tue, 17 Jul 2012 10:16:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sr8Zh-0008A6-HL for qemu-devel@nongnu.org; Tue, 17 Jul 2012 10:16:29 -0400 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 q6HEGTsE023032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Jul 2012 10:16:29 -0400 Received: from lacos-laptop.usersys.redhat.com (vpn1-5-251.ams2.redhat.com [10.36.5.251]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6HEG9KK022379; Tue, 17 Jul 2012 10:16:28 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org, lersek@redhat.com Date: Tue, 17 Jul 2012 16:17:15 +0200 Message-Id: <1342534641-22450-13-git-send-email-lersek@redhat.com> In-Reply-To: <1342534641-22450-1-git-send-email-lersek@redhat.com> References: <1342534641-22450-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 12/18] convert net_init_dump() to NetClientOptions 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 v1->v2: - NetdevDumpOptions::len is of type 'size', whose C type was changed to uint64_t. Adapt the printf() format specifier macro. Signed-off-by: Laszlo Ersek --- net/dump.c | 21 +++++++++++++++++---- 1 files changed, 17 insertions(+), 4 deletions(-) diff --git a/net/dump.c b/net/dump.c index 27e9528..f3d2fa9 100644 --- a/net/dump.c +++ b/net/dump.c @@ -144,22 +144,35 @@ static int net_dump_init(VLANState *vlan, const char *device, return 0; } -int net_init_dump(QemuOpts *opts, const NetClientOptions *new_opts, +int net_init_dump(QemuOpts *old_opts, const NetClientOptions *opts, const char *name, VLANState *vlan) { int len; const char *file; char def_file[128]; + const NetdevDumpOptions *dump; + + assert(opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP); + dump = opts->dump; assert(vlan); - file = qemu_opt_get(opts, "file"); - if (!file) { + if (dump->has_file) { + file = dump->file; + } else { snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id); file = def_file; } - len = qemu_opt_get_size(opts, "len", 65536); + if (dump->has_len) { + if (dump->len > INT_MAX) { + error_report("invalid length: %"PRIu64, dump->len); + return -1; + } + len = dump->len; + } else { + len = 65536; + } return net_dump_init(vlan, "dump", name, file, len); }