From patchwork Fri Nov 24 15:36:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10074205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE1E76037F for ; Fri, 24 Nov 2017 15:40:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF20B2A271 for ; Fri, 24 Nov 2017 15:40:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2A1E2A27A; Fri, 24 Nov 2017 15:40:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D6C32A271 for ; Fri, 24 Nov 2017 15:40:32 +0000 (UTC) Received: from localhost ([::1]:49874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIG5f-0005vs-B1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Nov 2017 10:40:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eIG2T-0004DW-AJ for qemu-devel@nongnu.org; Fri, 24 Nov 2017 10:37:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eIG2P-0004bw-Ed for qemu-devel@nongnu.org; Fri, 24 Nov 2017 10:37:13 -0500 Received: from mail-eopbgr40105.outbound.protection.outlook.com ([40.107.4.105]:57962 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eIG2P-0004a7-6R for qemu-devel@nongnu.org; Fri, 24 Nov 2017 10:37:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=F8biFLnl2JrldVsM2zbE73hzXKZZXMVKNQjOMMY/N3o=; b=Uiz3T7fKYG6CHW3CZwiKl2DqzoLsOnQXJmFRSga7kxK8g58riG2OvXTgIFFR/5F0zJjsmuESFYaSwX3FiSotlluoH0H/6L9cJAgbajA45X9xWTaMm7LGUj2YhkiNbjemhGptmEDOdAzXHfwFwAAciwipkrFK2ZXRs6uyxl/kj/w= Received: from rkaganb.sw.ru (195.214.232.6) by VI1PR08MB0847.eurprd08.prod.outlook.com (2a01:111:e400:5a05::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Fri, 24 Nov 2017 15:37:04 +0000 From: Roman Kagan To: qemu-devel@nongnu.org, "Michael S. Tsirkin" , Igor Mammedov , Ben Warren Date: Fri, 24 Nov 2017 18:36:55 +0300 Message-Id: <20171124153656.30199-2-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124153656.30199-1-rkagan@virtuozzo.com> References: <20171124153656.30199-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR07CA0045.eurprd07.prod.outlook.com (2603:10a6:7:66::31) To VI1PR08MB0847.eurprd08.prod.outlook.com (2a01:111:e400:5a05::17) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(7168020)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:VI1PR08MB0847; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 3:H0GzZ9HhCSVyQLgZhMAoZ1G7wryfzz/7xhxhavr1ztrOEXgbJRsGXTvNTBW06NpJXbirz4WGGHqLK3Orb8NxAmsMQo61ORIbIxsg5qM8JQaLZKZeYM9ZXCKZLSC+AmezYl5yitOLhHD3vaTB2m0inQwXwThRoLfxA/moFq0e2u7qwXv5EsLTl+77mvb4QMtZbPgKenq4HbnXs7mq1hKvweaZ5OFlWRSZWhPXlcsAQC8Z9dPL7HcIjxwfuWGhZDvl; 25:Bkefz4qGUPylOhCSwi/8yWlngQXeXcUsf88NEbcPTEoc5Nt7dO2okzWZ2DduogJDZ/dB9KDou/FphwMqRJhmFRyXOcpjndVVKFaQ7FNfWuACHfrLHoGQAoPH66Bk6eYTG/WBbLEqRETbC9sHYdIVP+2HRe62CG9KGeF50vxFd0ER0O8mFzOETt0cKG6jJwH4IYmOWa2NbPdXqC7Pk1ucRrZYPguHzhnx3N1/DYKk2oA7qCho/xifBwaChgeaQTjdw6C8tvTu4ASRButgb5j+3y6XRDpkNxHG3X8KRWj/Iy4RMjjxey5a86aMBgXYLemdkjEBzwWH4A8FpQW+BHZfEg==; 31:TkveAssFsSvLImBHV77yayGa0CssOvL0opPsABwI5NUtUf+V2OB/UdBX/GO1PXGkWBzV1py6L+s6n7NhpQ4r5V8ml4/GMWn2p5PMuATdLol9ZRumvXno8c/S1sZv/VvDtCdL3Em3xzc2R+a0BPRaydcddy1HrMsx/tvD5qC+F9Ok3EE9O2eJ/kk3qm8iw7QTPrnDR2oT+MpY8PT/xEbxDsQrIKCM0+E/iMwNJJxBHHk= X-MS-TrafficTypeDiagnostic: VI1PR08MB0847: X-MS-Office365-Filtering-Correlation-Id: 17dd2d45-de37-4e92-589e-08d53351373d X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 20:akdtdypG5BX5G+edFzxJ8K/ZfuIWEGU9l00gD8jEMz3WbbdnX2ApLoA4E+ysyCy5/aZdwK66xOS2kosXBzebbPfAtv+8HBMjHc/t7tSivBdQ0V9W+jLS/TaHtzE8HTU1BYsJaeXqsx/SSF7sdHsI1JUMQCY0LETrICuY+XQK5TC5MyhYZhWk1i0Md7mTi7L+ZE2YFrypnCpSa5iqGtN+nkltY9IDdPBMVK4sIUT6mUAaVMldRN/f7lQCaqswScCdcZthlVOvsUxj1NDe5C4h9JLOEund5lddsMJSnq1KHF8oWUwglGEDB5d2lDZVKPD4bWPK8ukmklM0OZCnDROi8z61WIqCtxRg95Tp4918EflBT6Ox19T+oO0Q1/vQ+vfAogAp/E3TJ/hN6sdnezMB4M+jT2Si3tCjQhlrvJRW1OM=; 4:/h7eLC4Q1joewL2RrARGOaIU1mGYq3VJVEaDU1YwD5h9+r5S6eIpr6jRFIespF9mxYss7gU5szGkqBO0NRoSQS7vZzgMCVV5CR2iBCElwE9ncLgJVaycqIuYBUQjw/Q2BdKc+4G1ZT5g/YvPVKdI7TYJdLy7HqAChFCdPsj/8XcG84Cnc3i0rGphNOqi0OakSoyLIUAdOfoByv2EldYiA//qFnkkCw3HsS0ToyE6U+iCtH3iq57yP8ERYPw4+YxrGCESV21ONBpTnsDua9l+9Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(3231022)(3002001)(93006095)(93001095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123558100)(20161123555025)(20161123560025)(20161123564025)(6072148)(201708071742011); SRVR:VI1PR08MB0847; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR08MB0847; X-Forefront-PRVS: 05015EB482 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(346002)(366004)(376002)(199003)(189002)(97736004)(101416001)(48376002)(50466002)(8676002)(81156014)(5660300001)(81166006)(53936002)(2906002)(7736002)(86362001)(6116002)(3846002)(478600001)(16586007)(6486002)(66066001)(6506006)(55236003)(107886003)(105586002)(2950100002)(16526018)(8936002)(50986999)(68736007)(189998001)(47776003)(76176999)(106356001)(33646002)(4326008)(25786009)(316002)(110136005)(52116002)(69596002)(54906003)(50226002)(1076002)(6512007)(36756003)(51416003)(53416004)(305945005)(6666003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0847; H:rkaganb.sw.ru; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0847; 23:Pe083dpz1Gu1bU2cmtXYTas4S0umZ4i1XcuCQWXYI?= =?us-ascii?Q?b28FlCWh/CxIyIq5nE7+cfyx0rmBagPvnSFeNzU4H6cH+Vlx57yNcYdm4UEO?= =?us-ascii?Q?ZzXvaGC/oheAjOSYQkhA2gWVK2L1Vj4HFlrGsPb9/iqQwDoFCXFbhxdrQZRn?= =?us-ascii?Q?3rNr2zVFdZY6Sn6rC0xAcbrKL7PovLbtrQIT11x1JmmfMtbOaxs/B0DmGXSX?= =?us-ascii?Q?D+OkhX2lRCjFMSctvdiOTTCQ5OOZ1TGBBSakVAgsViUSiz0wMr4whdmBq4pw?= =?us-ascii?Q?9SOSC8uCoHBdNkquuJMMiuRsSqApTPqX84NyL/4SilNC1fsuRgzlmJ/SMe6t?= =?us-ascii?Q?6Prsxf1+w/XtyNcPQzkUqnimMdPBMi8kqwpSITYw572IuifnbSDgj8fEKHmk?= =?us-ascii?Q?EW0fnDG0mOsQP/hdNDruEwETdWQMF6WpKSrW67Z4fvwWhN/DM/mO3ulrObK8?= =?us-ascii?Q?7PaHo+vRx8dy5G7Y3YN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hvc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2017 15:37:04.8834 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 17dd2d45-de37-4e92-589e-08d53351373d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0847 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.4.105 Subject: [Qemu-devel] [PATCH 1/2] qdev-properties: add UUID property type 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , "Denis V. Lunev" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP UUIDs (GUIDs) are widely used in VMBus-related stuff, so a dedicated property type becomes helpful. Signed-off-by: Roman Kagan Reviewed-by: Marc-André Lureau Reviewed-by: Ben Warren --- include/hw/qdev-properties.h | 3 +++ hw/core/qdev-properties.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index e2321f1cc1..d4da7dd1f1 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -30,6 +30,7 @@ extern const PropertyInfo qdev_prop_vlan; extern const PropertyInfo qdev_prop_pci_devfn; extern const PropertyInfo qdev_prop_blocksize; extern const PropertyInfo qdev_prop_pci_host_devaddr; +extern const PropertyInfo qdev_prop_uuid; extern const PropertyInfo qdev_prop_arraylen; extern const PropertyInfo qdev_prop_link; @@ -212,6 +213,8 @@ extern const PropertyInfo qdev_prop_link; DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddress) #define DEFINE_PROP_MEMORY_REGION(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_ptr, MemoryRegion *) +#define DEFINE_PROP_UUID(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_uuid, QemuUUID) #define DEFINE_PROP_END_OF_LIST() \ {} diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 1dc80fcea2..49fea5a40a 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -10,6 +10,7 @@ #include "net/hub.h" #include "qapi/visitor.h" #include "chardev/char.h" +#include "qemu/uuid.h" void qdev_prop_set_after_realize(DeviceState *dev, const char *name, Error **errp) @@ -883,6 +884,57 @@ const PropertyInfo qdev_prop_pci_host_devaddr = { .set = set_pci_host_devaddr, }; +/* --- UUID --- */ + +static void get_uuid(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + DeviceState *dev = DEVICE(obj); + Property *prop = opaque; + QemuUUID *uuid = qdev_get_prop_ptr(dev, prop); + char buffer[UUID_FMT_LEN + 1]; + char *p = buffer; + + qemu_uuid_unparse(uuid, buffer); + + visit_type_str(v, name, &p, errp); +} + +static void set_uuid(Object *obj, Visitor *v, const char *name, void *opaque, + Error **errp) +{ + DeviceState *dev = DEVICE(obj); + Property *prop = opaque; + QemuUUID *uuid = qdev_get_prop_ptr(dev, prop); + Error *local_err = NULL; + char *str; + + if (dev->realized) { + qdev_prop_set_after_realize(dev, name, errp); + return; + } + + visit_type_str(v, name, &str, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + + if (!strcmp(str, "auto")) { + qemu_uuid_generate(uuid); + } else if (qemu_uuid_parse(str, uuid) < 0) { + error_set_from_qdev_prop_error(errp, EINVAL, dev, prop, str); + } + g_free(str); +} + +const PropertyInfo qdev_prop_uuid = { + .name = "str", + .description = "UUID (aka GUID) or \"auto\" for random value", + .get = get_uuid, + .set = set_uuid, +}; + /* --- support for array properties --- */ /* Used as an opaque for the object properties we add for each