{"id":811634,"url":"http://patchwork.ozlabs.org/api/1.2/patches/811634/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504880304-12069-15-git-send-email-mst@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.2/projects/14/?format=json","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":"<1504880304-12069-15-git-send-email-mst@redhat.com>","list_archive_url":null,"date":"2017-09-08T14:19:33","name":"[PULL,14/17] vmgenid: replace x-write-pointer-available hack","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"14f805bac89d3cba90e20a2eb37ac5221af4f6b3","submitter":{"id":2235,"url":"http://patchwork.ozlabs.org/api/1.2/people/2235/?format=json","name":"Michael S. Tsirkin","email":"mst@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504880304-12069-15-git-send-email-mst@redhat.com/mbox/","series":[{"id":2227,"url":"http://patchwork.ozlabs.org/api/1.2/series/2227/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=2227","date":"2017-09-08T14:18:52","name":"[PULL,01/17] vhost: Release memory references on cleanup","version":1,"mbox":"http://patchwork.ozlabs.org/series/2227/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811634/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811634/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-mx01.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx01.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=mst@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 3xpfms372Bz9sDB\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 00:27:57 +1000 (AEST)","from localhost ([::1]:45708 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 1dqKGB-0005jB-3k\n\tfor incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 10:27:55 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:49216)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1dqK8B-0006sp-7J\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 10:19:43 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mst@redhat.com>) id 1dqK89-0005G3-Qq\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 10:19:39 -0400","from mx1.redhat.com ([209.132.183.28]:34604)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <mst@redhat.com>) id 1dqK89-0005FL-HL\n\tfor qemu-devel@nongnu.org; Fri, 08 Sep 2017 10:19:37 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\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 9F83F81E04;\n\tFri,  8 Sep 2017 14:19:36 +0000 (UTC)","from redhat.com (ovpn-120-144.rdu2.redhat.com [10.10.120.144])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 85E8B5D979;\n\tFri,  8 Sep 2017 14:19:33 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 9F83F81E04","Date":"Fri, 8 Sep 2017 17:19:33 +0300","From":"\"Michael S. Tsirkin\" <mst@redhat.com>","To":"qemu-devel@nongnu.org","Message-ID":"<1504880304-12069-15-git-send-email-mst@redhat.com>","References":"<1504880304-12069-1-git-send-email-mst@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<1504880304-12069-1-git-send-email-mst@redhat.com>","X-Mutt-Fcc":"=sent","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.25]);\n\tFri, 08 Sep 2017 14:19:36 +0000 (UTC)","Content-Transfer-Encoding":"quoted-printable","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] [PULL 14/17] vmgenid: replace\n\tx-write-pointer-available hack","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":"Peter Maydell <peter.maydell@linaro.org>, Eduardo Habkost\n\t<ehabkost@redhat.com>, Ben Warren <ben@skyportsystems.com>, \n\t=?utf-8?q?Marc-Andr=C3=A9?= Lureau <marcandre.lureau@redhat.com>,\n\tIgor Mammedov <imammedo@redhat.com>, Laszlo Ersek <lersek@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":"From: Marc-André Lureau <marcandre.lureau@redhat.com>\n\nThis compat property sole function is to prevent the device from being\ninstantiated. Instead of requiring an extra compat property, check if\nfw_cfg has DMA enabled.\n\nfw_cfg is a built-in device that is initialized very early by the\nmachine init code.  We have at least one other device that also\nassumes fw_cfg_find() can be safely used on realize: pvpanic.\n\nThis has the additional benefit of handling other cases properly, like:\n\n  $ qemu-system-x86_64 -device vmgenid -machine none\n  qemu-system-x86_64: -device vmgenid: vmgenid requires DMA write support in fw_cfg, which this machine type does not provide\n  $ qemu-system-x86_64 -device vmgenid -machine pc-i440fx-2.9 -global fw_cfg.dma_enabled=off\n  qemu-system-x86_64: -device vmgenid: vmgenid requires DMA write support in fw_cfg, which this machine type does not provide\n  $ qemu-system-x86_64 -device vmgenid -machine pc-i440fx-2.6 -global fw_cfg.dma_enabled=on\n  [boots normally]\n\nSuggested-by: Eduardo Habkost <ehabkost@redhat.com>\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nReviewed-by: Michael S. Tsirkin <mst@redhat.com>\nReviewed-by: Eduardo Habkost <ehabkost@redhat.com>\nReviewed-by: Ben Warren <ben@skyportsystems.com>\nReviewed-by: Laszlo Ersek <lersek@redhat.com>\nReviewed-by: Michael S. Tsirkin <mst@redhat.com>\nSigned-off-by: Michael S. Tsirkin <mst@redhat.com>\n---\n include/hw/acpi/bios-linker-loader.h |  2 ++\n include/hw/acpi/vmgenid.h            |  1 -\n include/hw/compat.h                  |  4 ----\n hw/acpi/bios-linker-loader.c         | 10 ++++++++++\n hw/acpi/vmgenid.c                    |  9 +--------\n 5 files changed, 13 insertions(+), 13 deletions(-)","diff":"diff --git a/include/hw/acpi/bios-linker-loader.h b/include/hw/acpi/bios-linker-loader.h\nindex efe17b0..a711dbc 100644\n--- a/include/hw/acpi/bios-linker-loader.h\n+++ b/include/hw/acpi/bios-linker-loader.h\n@@ -7,6 +7,8 @@ typedef struct BIOSLinker {\n     GArray *file_list;\n } BIOSLinker;\n \n+bool bios_linker_loader_can_write_pointer(void);\n+\n BIOSLinker *bios_linker_loader_init(void);\n \n void bios_linker_loader_alloc(BIOSLinker *linker,\ndiff --git a/include/hw/acpi/vmgenid.h b/include/hw/acpi/vmgenid.h\nindex 7beb959..38586ec 100644\n--- a/include/hw/acpi/vmgenid.h\n+++ b/include/hw/acpi/vmgenid.h\n@@ -21,7 +21,6 @@ typedef struct VmGenIdState {\n     DeviceClass parent_obj;\n     QemuUUID guid;                /* The 128-bit GUID seen by the guest */\n     uint8_t vmgenid_addr_le[8];   /* Address of the GUID (little-endian) */\n-    bool write_pointer_available;\n } VmGenIdState;\n \n /* returns NULL unless there is exactly one device */\ndiff --git a/include/hw/compat.h b/include/hw/compat.h\nindex 3e101f8..9cc14dd 100644\n--- a/include/hw/compat.h\n+++ b/include/hw/compat.h\n@@ -153,10 +153,6 @@\n         .driver   = \"fw_cfg_io\",\\\n         .property = \"dma_enabled\",\\\n         .value    = \"off\",\\\n-    },{\\\n-        .driver   = \"vmgenid\",\\\n-        .property = \"x-write-pointer-available\",\\\n-        .value    = \"off\",\\\n     },\n \n #define HW_COMPAT_2_3 \\\ndiff --git a/hw/acpi/bios-linker-loader.c b/hw/acpi/bios-linker-loader.c\nindex 046183a..d16b8bb 100644\n--- a/hw/acpi/bios-linker-loader.c\n+++ b/hw/acpi/bios-linker-loader.c\n@@ -169,6 +169,16 @@ bios_linker_find_file(const BIOSLinker *linker, const char *name)\n }\n \n /*\n+ * board code must realize fw_cfg first, as a fixed device, before\n+ * another device realize function call bios_linker_loader_can_write_pointer()\n+ */\n+bool bios_linker_loader_can_write_pointer(void)\n+{\n+    FWCfgState *fw_cfg = fw_cfg_find();\n+    return fw_cfg && fw_cfg_dma_enabled(fw_cfg);\n+}\n+\n+/*\n  * bios_linker_loader_alloc: ask guest to load file into guest memory.\n  *\n  * @linker: linker object instance\ndiff --git a/hw/acpi/vmgenid.c b/hw/acpi/vmgenid.c\nindex 876723a..2876d8a 100644\n--- a/hw/acpi/vmgenid.c\n+++ b/hw/acpi/vmgenid.c\n@@ -205,17 +205,11 @@ static void vmgenid_handle_reset(void *opaque)\n     memset(vms->vmgenid_addr_le, 0, ARRAY_SIZE(vms->vmgenid_addr_le));\n }\n \n-static Property vmgenid_properties[] = {\n-    DEFINE_PROP_BOOL(\"x-write-pointer-available\", VmGenIdState,\n-                     write_pointer_available, true),\n-    DEFINE_PROP_END_OF_LIST(),\n-};\n-\n static void vmgenid_realize(DeviceState *dev, Error **errp)\n {\n     VmGenIdState *vms = VMGENID(dev);\n \n-    if (!vms->write_pointer_available) {\n+    if (!bios_linker_loader_can_write_pointer()) {\n         error_setg(errp, \"%s requires DMA write support in fw_cfg, \"\n                    \"which this machine type does not provide\", VMGENID_DEVICE);\n         return;\n@@ -239,7 +233,6 @@ static void vmgenid_device_class_init(ObjectClass *klass, void *data)\n     dc->vmsd = &vmstate_vmgenid;\n     dc->realize = vmgenid_realize;\n     dc->hotpluggable = false;\n-    dc->props = vmgenid_properties;\n     set_bit(DEVICE_CATEGORY_MISC, dc->categories);\n \n     object_class_property_add_str(klass, VMGENID_GUID, NULL,\n","prefixes":["PULL","14/17"]}