From patchwork Mon Apr 18 16:42:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8874071 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D346EBF29F for ; Mon, 18 Apr 2016 16:43:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D1376201C8 for ; Mon, 18 Apr 2016 16:43:43 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54B0E20125 for ; Mon, 18 Apr 2016 16:43:42 +0000 (UTC) Received: from localhost ([::1]:41772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asCGz-0000UA-QA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Apr 2016 12:43:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asCFa-0006Kl-MP for qemu-devel@nongnu.org; Mon, 18 Apr 2016 12:42:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asCFZ-0002kk-BH for qemu-devel@nongnu.org; Mon, 18 Apr 2016 12:42:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48838) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asCFZ-0002kX-3a for qemu-devel@nongnu.org; Mon, 18 Apr 2016 12:42:13 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B82417F341; Mon, 18 Apr 2016 16:42:12 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-18.ams2.redhat.com [10.36.116.18]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3IGgAp3005065 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 18 Apr 2016 12:42:11 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C5B671132D8E; Mon, 18 Apr 2016 18:42:09 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 18 Apr 2016 18:42:09 +0200 Message-Id: <1460997729-29541-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.6] fw_cfg: Adopt /opt/RFQDN convention X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gabriel L. Somlo" , Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP FW CFG's primary user is QEMU, which uses it to expose configuration information (in the widest sense) to Firmware. Thus the name FW CFG. FW CFG can also be used by others for their own purposes. QEMU is merely acting as transport then. Names starting with opt/ are reseved for such uses. There is no provision, however, to guide safe sharing among different such users. Fix that, losely following QMP precedence: names should start with opt/RFQDN/, where RFQDN is a reverse fully qualified domain name you control. Based on a more ambitious patch from Michael Tsirkin. Cc: Gerd Hoffmann Cc: Gabriel L. Somlo Cc: Laszlo Ersek Cc: Michael S. Tsirkin Signed-off-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Gabriel Somlo Reviewed-by: Laszlo Ersek --- Michael's patch: Message-ID: <1460102035-15972-1-git-send-email-mst@redhat.com> http://lists.nongnu.org/archive/html/qemu-devel/2016-04/msg01381.html Michael, I'm happy to add your S-o-b if you feel this patch is derivative of yours despite my extensive changes. I didn't do it proactively because I didn't want to misrepresent your opinions on this matter. docs/specs/fw_cfg.txt | 36 +++++++++++++++++------------------- qemu-options.hx | 24 +++++++++++++++++++----- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/docs/specs/fw_cfg.txt b/docs/specs/fw_cfg.txt index 5414140..90e74bb 100644 --- a/docs/specs/fw_cfg.txt +++ b/docs/specs/fw_cfg.txt @@ -210,29 +210,27 @@ the following syntax: -fw_cfg [name=],file= -where is the fw_cfg item name, and is the location -on the host file system of a file containing the data to be inserted. - -Small enough items may be provided directly as strings on the command -line, using the syntax: +Or -fw_cfg [name=],string= -The terminating NUL character of the content will NOT be -included as part of the fw_cfg item data, which is consistent with -the absence of a NUL terminator for items inserted via the file option. +See QEMU man page for more documentation. -Both and, if applicable, the content are passed -through by QEMU without any interpretation, expansion, or further -processing. Any such processing (potentially performed e.g., by the shell) -is outside of QEMU's responsibility; as such, using plain ASCII characters -is recommended. +Using item_name with plain ASCII characters only is recommended. -NOTE: Users *SHOULD* choose item names beginning with the prefix "opt/" -when using the "-fw_cfg" command line option, to avoid conflicting with -item names used internally by QEMU. For instance: +Item names beginning with "opt/" are reserved for users. QEMU will +never create entries with such names unless explicitly ordered by the +user. - -fw_cfg name=opt/my_item_name,file=./my_blob.bin +To avoid clashes among different users, it is strongly recommended +that you use names beginning with opt/RFQDN/, where RFQDN is a +reverse fully qualified domain name you control. For instance, if +SeaBIOS wanted to define additional names, prefix "opt/org.seabios/" +would be appropriate. -Similarly, QEMU developers *SHOULD NOT* use item names prefixed with -"opt/" when inserting items programmatically, e.g. via fw_cfg_add_file(). +For historical reasons, "opt/ovmf/" is reserved for OVMF firmware. + +Prefix "opt/org.qemu/" is reserved for QEMU itself. + +Use of names not beginning with "opt/" is potentially dangerous and +entirely unsupported. QEMU will warn if you try. diff --git a/qemu-options.hx b/qemu-options.hx index 587de8f..6106520 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2864,18 +2864,32 @@ ETEXI DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg, "-fw_cfg [name=],file=\n" - " add named fw_cfg entry from file\n" + " add named fw_cfg entry with contents from file\n" "-fw_cfg [name=],string=\n" - " add named fw_cfg entry from string\n", + " add named fw_cfg entry with contents from string\n", QEMU_ARCH_ALL) STEXI + @item -fw_cfg [name=]@var{name},file=@var{file} @findex -fw_cfg -Add named fw_cfg entry from file. @var{name} determines the name of -the entry in the fw_cfg file directory exposed to the guest. +Add named fw_cfg entry with contents from file @var{file}. @item -fw_cfg [name=]@var{name},string=@var{str} -Add named fw_cfg entry from string. +Add named fw_cfg entry with contents from string @var{str}. + +The terminating NUL character of the contents of @var{str} will not be +included as part of the fw_cfg item data. To insert contents with +embedded NUL characters, you have to use the @var{file} parameter. + +The fw_cfg entries are passed by QEMU through to the guest. + +Example: +@example + -fw_cfg name=opt/com.mycompany/blob,file=./my_blob.bin +@end example +creates an fw_cfg entry named opt/com.mycompany/blob with contents +from ./my_blob.bin. + ETEXI DEF("serial", HAS_ARG, QEMU_OPTION_serial, \