From patchwork Wed Jan 23 21:32:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 156398 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1201402jaa; Wed, 23 Jan 2019 13:33:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ghTDb4nai6EuURWrq7KRWeDDYhHd4UjkCDbeQ7PpTGYjPnzLWJS9O+6FSvGZgcGNrgNhT X-Received: by 2002:aed:3442:: with SMTP id w60mr4212064qtd.339.1548279208287; Wed, 23 Jan 2019 13:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548279208; cv=none; d=google.com; s=arc-20160816; b=zotCyzm1NMy6yQOcCKevDLIRT+dQjLXKf3xrCYx9rfk97sw6FcRkM3TeAg7tZrXfGi 0Oy+l1FJOaOnW/Wo3m5YZ9L9D9xmMpg37fOsaJ1NvoOg+XEi8D0k0ImECXP1ejjFpeGb 1kI9fGNrntSme/OtlQlolfTL3GYx6bc8QzNh8evDFLcjA/bgQaLNzxPS3d7le5OUKAvk khjLkSnkiI0szvh+zqXignmVu3GsG8B8RFjkshFU/8+kNax8Hy3tgdO9ZbW0Aa63eA1J tMJIi1O5fvUEoFWwlSNq6C0xGSJQMKpvyWEFw5x7TOGoy33ZEowYxDqNi/IKg0Xh2SU8 LUPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=2Bp5dSwt7GkJEeahEaRZ0in44Dc+ZPI36g77s3EZ02M=; b=hCOKHywyKo6JjXhUtHdQoqdFrYcR7/ep/fY/PqXCDjLOeNpNeZ7aVouEYCRkYAB1wY MFwU4qsj7vCrHWD6EMoFQtGKD/baudGgEVGKDZjmuLCvhjB5zQWkEkohBREbUwgt7Pjz pf9IQY1wBQHBrvJg2X+JtJbMFCKGv1SO3ykhHfAZJK0G3X8AKVzW4KhM/hMs07V+Mh+7 L+L62XLyaVOc/qdfd48y5ir9htulIskItwzfGiM907QK6ustVmivkuTND81eJYZVVEMT XbIVgq9Tr5rv5uf2oIU2o7kBxaTxRtk5VjiKXYLkwTZcenRWpEi058HXi+SmB9hLKz+4 0R1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id t5si5435030qvj.105.2019.01.23.13.33.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Jan 2019 13:33:28 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC18B80511; Wed, 23 Jan 2019 21:33:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A8E458B2; Wed, 23 Jan 2019 21:33:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5151C3F605; Wed, 23 Jan 2019 21:33:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x0NLXMe0032297 for ; Wed, 23 Jan 2019 16:33:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 68961BA8B; Wed, 23 Jan 2019 21:33:22 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-120-34.rdu2.redhat.com [10.10.120.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E6D9BA50; Wed, 23 Jan 2019 21:33:21 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Wed, 23 Jan 2019 16:32:35 -0500 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 07/25] conf: Add virDomainDeviceSetData X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 23 Jan 2019 21:33:27 +0000 (UTC) This is essentially a wrapper for easily setting the variable name in virDomainDeviceDef that matches its associated VIR_DOMAIN_DEVICE_TYPE. Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 93 ++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 ++ src/libvirt_private.syms | 1 + 3 files changed, 97 insertions(+) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bcdb6b0a3a..8af1a4ae73 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3702,6 +3702,99 @@ virDomainSkipBackcompatConsole(virDomainDefPtr def, } +/** + * virDomainDeviceSetData + * @device: virDomainDeviceDefPtr with ->type filled in + * @data: *DefPtr data for a device. Ex: virDomainDiskDefPtr + * + * Set the data.X variable for the device->type value. Basically + * a mapping of virDomainDeviceType to the associated name in + * the virDomainDeviceDef union + */ +void +virDomainDeviceSetData(virDomainDeviceDefPtr device, + void *devicedata) +{ + switch ((virDomainDeviceType) device->type) { + case VIR_DOMAIN_DEVICE_DISK: + device->data.disk = devicedata; + break; + case VIR_DOMAIN_DEVICE_NET: + device->data.net = devicedata; + break; + case VIR_DOMAIN_DEVICE_SOUND: + device->data.sound = devicedata; + break; + case VIR_DOMAIN_DEVICE_HOSTDEV: + device->data.hostdev = devicedata; + break; + case VIR_DOMAIN_DEVICE_VIDEO: + device->data.video = devicedata; + break; + case VIR_DOMAIN_DEVICE_CONTROLLER: + device->data.controller = devicedata; + break; + case VIR_DOMAIN_DEVICE_GRAPHICS: + device->data.graphics = devicedata; + break; + case VIR_DOMAIN_DEVICE_SMARTCARD: + device->data.smartcard = devicedata; + break; + case VIR_DOMAIN_DEVICE_CHR: + device->data.chr = devicedata; + break; + case VIR_DOMAIN_DEVICE_INPUT: + device->data.input = devicedata; + break; + case VIR_DOMAIN_DEVICE_FS: + device->data.fs = devicedata; + break; + case VIR_DOMAIN_DEVICE_WATCHDOG: + device->data.watchdog = devicedata; + break; + case VIR_DOMAIN_DEVICE_MEMBALLOON: + device->data.memballoon = devicedata; + break; + case VIR_DOMAIN_DEVICE_RNG: + device->data.rng = devicedata; + break; + case VIR_DOMAIN_DEVICE_NVRAM: + device->data.nvram = devicedata; + break; + case VIR_DOMAIN_DEVICE_HUB: + device->data.hub = devicedata; + break; + case VIR_DOMAIN_DEVICE_SHMEM: + device->data.shmem = devicedata; + break; + case VIR_DOMAIN_DEVICE_TPM: + device->data.tpm = devicedata; + break; + case VIR_DOMAIN_DEVICE_PANIC: + device->data.panic = devicedata; + break; + case VIR_DOMAIN_DEVICE_MEMORY: + device->data.memory = devicedata; + break; + case VIR_DOMAIN_DEVICE_REDIRDEV: + device->data.redirdev = devicedata; + break; + case VIR_DOMAIN_DEVICE_VSOCK: + device->data.vsock = devicedata; + break; + case VIR_DOMAIN_DEVICE_IOMMU: + device->data.iommu = devicedata; + break; + case VIR_DOMAIN_DEVICE_LEASE: + device->data.lease = devicedata; + break; + case VIR_DOMAIN_DEVICE_NONE: + case VIR_DOMAIN_DEVICE_LAST: + break; + } +} + + enum { DOMAIN_DEVICE_ITERATE_ALL_CONSOLES = 1 << 0, DOMAIN_DEVICE_ITERATE_GRAPHICS = 1 << 1 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 218aa4dd94..536b02ad3d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2937,6 +2937,9 @@ virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, virDomainDeviceInfoPtr virDomainDeviceGetInfo(virDomainDeviceDefPtr device); void virDomainTPMDefFree(virDomainTPMDefPtr def); +void virDomainDeviceSetData(virDomainDeviceDefPtr device, + void *devicedata); + typedef int (*virDomainDeviceInfoCallback)(virDomainDefPtr def, virDomainDeviceDefPtr dev, virDomainDeviceInfoPtr info, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6f4809a68a..89b8ca3b4f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -307,6 +307,7 @@ virDomainDeviceDefParse; virDomainDeviceFindSCSIController; virDomainDeviceGetInfo; virDomainDeviceInfoIterate; +virDomainDeviceSetData; virDomainDeviceTypeToString; virDomainDeviceValidateAliasForHotplug; virDomainDiskBusTypeToString;