From patchwork Tue Feb 19 20:09:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 159029 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1751894jaa; Fri, 22 Feb 2019 05:47:17 -0800 (PST) X-Google-Smtp-Source: AHgI3IY+JkEKdgR2jMeqyi+KR0eQ07+erKKX62tWiobOjKxb2rGBw+oeRPnSSj1J6/zcdPi97TSb X-Received: by 2002:a37:674c:: with SMTP id b73mr2904061qkc.184.1550843236976; Fri, 22 Feb 2019 05:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550843236; cv=none; d=google.com; s=arc-20160816; b=qj32S9ZyJjEbMDdw7VAhKp3vTbZ0dF25Cr42OEz96lmrrOMHWwkXRAEXY5oXhjqmAK 5NNfkipemVSaM2mfZzCMTkF0IqRaRfMVEvzDm2kIa1Tl8VCkKzW0H2yI53554YYrbiV+ hvWukGHFlqSCf3Pw8iSCNCGSeAm4zHniTc5s+Hv6O4fG35MQ4UCaPbuhVehu2oKnbiCZ icn+yBWTX5uQu2gkj9dBZmonIbjfK8l36xFELZfb1DCxg5FRTNk8YdRD8t0gLogIRvJ3 xgOtoqALTLH4rjoZru4acMQ6ApHJl0zWIgTvNE/LFXq5Cz/eKgUe5wy/eE/EyBb6oXAC O7ew== 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=EtJtHZftjiO/Kulc76A/etq/uTelfFdrPxCG9KfkHJg=; b=iOfOfQojR0Letbl1iO8TMZZZ1vFSodu+Fn0ABXu7GWNg9NgRU964SpuVeU9YIIOFkQ Np4FzUjhmuUNYnosS0bcwCR1SI/SMv39HbFlEcC34fPPxSmcT6Av7zj+Gyo9WOAtkkJW QBk5CX9KunxqML0mr2Chk4T8JMVNfrdN7qM+tY4x7PhnmlqUPFgqroFhfDUPmajl1vGI EMpw0rY/wmhPTm5J5WOY4qHPyQfdMPmMhECQUYLtouqMtpWywZGCRFAivzF0cGBIbiIh MZPccYqmRleT+kWmVIXNXnJQHAn/4ZgivIA07k841yg/yOfgX4pck0OoRUwWrm6uUCHD Mfhg== 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 u83si930754qka.96.2019.02.22.05.47.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 05:47:16 -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-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A49955D60E; Fri, 22 Feb 2019 13:47:15 +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 7E57F22718; Fri, 22 Feb 2019 13:47:15 +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 30D1365D1A; Fri, 22 Feb 2019 13:47:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1JKAkcm000478 for ; Tue, 19 Feb 2019 15:10:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6408460141; Tue, 19 Feb 2019 20:10:46 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.bos.redhat.com (dhcp-17-6.bos.redhat.com [10.18.17.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CA716013C; Tue, 19 Feb 2019 20:10:45 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 19 Feb 2019 15:09:34 -0500 Message-Id: <907639c4b347304e451f0a519b284dc5fd786d8a.1550606392.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 05/10] conf: domcaps: use virTristateBool for 'supported' 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 22 Feb 2019 13:47:16 +0000 (UTC) Switch most 'supported' handling to use virTristateBool, so eventually we can handle the ABSENT state. For now the XML formatter treats ABSENT the same as FALSE, so there's no functional output change. This will be addressed in later patches Signed-off-by: Cole Robinson --- src/bhyve/bhyve_capabilities.c | 10 +++++----- src/conf/domain_capabilities.c | 8 ++++---- src/conf/domain_capabilities.h | 20 ++++++++++---------- src/libxl/libxl_capabilities.c | 12 ++++++------ src/qemu/qemu_capabilities.c | 24 +++++++++++++----------- 5 files changed, 38 insertions(+), 36 deletions(-) -- 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 6feaded2ad..79d7659da3 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -75,7 +75,7 @@ virBhyveDomainCapsFill(virDomainCapsPtr caps, unsigned int bhyvecaps, virDomainCapsStringValuesPtr firmwares) { - caps->disk.supported = true; + caps->disk.supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice, VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_DEVICE_CDROM); @@ -84,10 +84,10 @@ virBhyveDomainCapsFill(virDomainCapsPtr caps, VIR_DOMAIN_DISK_BUS_SATA, VIR_DOMAIN_DISK_BUS_VIRTIO); - caps->os.supported = true; + caps->os.supported = VIR_TRISTATE_BOOL_YES; if (bhyvecaps & BHYVE_CAP_LPC_BOOTROM) { - caps->os.loader.supported = true; + caps->os.loader.supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.type, VIR_DOMAIN_LOADER_TYPE_PFLASH); VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.readonly, @@ -99,8 +99,8 @@ virBhyveDomainCapsFill(virDomainCapsPtr caps, if (bhyvecaps & BHYVE_CAP_FBUF) { - caps->graphics.supported = true; - caps->video.supported = true; + caps->graphics.supported = VIR_TRISTATE_BOOL_YES; + caps->video.supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(caps->graphics.type, VIR_DOMAIN_GRAPHICS_TYPE_VNC); VIR_DOMAIN_CAPS_ENUM_SET(caps->video.modelType, VIR_DOMAIN_VIDEO_TYPE_GOP); } diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 4539281ff5..6ae18515b6 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -371,9 +371,9 @@ virDomainCapsStringValuesFormat(virBufferPtr buf, #define FORMAT_PROLOGUE(item) \ do { \ virBufferAsprintf(buf, "<" #item " supported='%s'%s\n", \ - item->supported ? "yes" : "no", \ - item->supported ? ">" : "/>"); \ - if (!item->supported) \ + (item->supported == VIR_TRISTATE_BOOL_YES) ? "yes" : "no", \ + (item->supported == VIR_TRISTATE_BOOL_YES) ? ">" : "/>"); \ + if (item->supported != VIR_TRISTATE_BOOL_YES) \ return; \ virBufferAdjustIndent(buf, 2); \ } while (0) @@ -387,7 +387,7 @@ virDomainCapsStringValuesFormat(virBufferPtr buf, #define FORMAT_SINGLE(name, supported) \ do { \ virBufferAsprintf(&buf, "<%s supported='%s'/>\n", name, \ - supported ? "yes" : "no"); \ + (supported == VIR_TRISTATE_BOOL_YES) ? "yes" : "no"); \ } while (0) #define ENUM_PROCESS(master, capsEnum, valToStr) \ diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 15e065359b..1ebdb01716 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -46,7 +46,7 @@ struct _virDomainCapsStringValues { typedef struct _virDomainCapsLoader virDomainCapsLoader; typedef virDomainCapsLoader *virDomainCapsLoaderPtr; struct _virDomainCapsLoader { - bool supported; + virTristateBool supported; virDomainCapsStringValues values; /* Info about values for the element */ virDomainCapsEnum type; /* Info about virDomainLoader */ virDomainCapsEnum readonly; /* Info about readonly:virTristateBool */ @@ -55,14 +55,14 @@ struct _virDomainCapsLoader { typedef struct _virDomainCapsOS virDomainCapsOS; typedef virDomainCapsOS *virDomainCapsOSPtr; struct _virDomainCapsOS { - bool supported; + virTristateBool supported; virDomainCapsLoader loader; /* Info about virDomainLoaderDef */ }; typedef struct _virDomainCapsDeviceDisk virDomainCapsDeviceDisk; typedef virDomainCapsDeviceDisk *virDomainCapsDeviceDiskPtr; struct _virDomainCapsDeviceDisk { - bool supported; + virTristateBool supported; virDomainCapsEnum diskDevice; /* Info about virDomainDiskDevice enum values */ virDomainCapsEnum bus; /* Info about virDomainDiskBus enum values */ /* add new fields here */ @@ -71,21 +71,21 @@ struct _virDomainCapsDeviceDisk { typedef struct _virDomainCapsDeviceGraphics virDomainCapsDeviceGraphics; typedef virDomainCapsDeviceGraphics *virDomainCapsDeviceGraphicsPtr; struct _virDomainCapsDeviceGraphics { - bool supported; + virTristateBool supported; virDomainCapsEnum type; /* virDomainGraphicsType */ }; typedef struct _virDomainCapsDeviceVideo virDomainCapsDeviceVideo; typedef virDomainCapsDeviceVideo *virDomainCapsDeviceVideoPtr; struct _virDomainCapsDeviceVideo { - bool supported; + virTristateBool supported; virDomainCapsEnum modelType; /* virDomainVideoType */ }; typedef struct _virDomainCapsDeviceHostdev virDomainCapsDeviceHostdev; typedef virDomainCapsDeviceHostdev *virDomainCapsDeviceHostdevPtr; struct _virDomainCapsDeviceHostdev { - bool supported; + virTristateBool supported; virDomainCapsEnum mode; /* Info about virDomainHostdevMode */ virDomainCapsEnum startupPolicy; /* Info about virDomainStartupPolicy */ virDomainCapsEnum subsysType; /* Info about virDomainHostdevSubsysType */ @@ -97,7 +97,7 @@ struct _virDomainCapsDeviceHostdev { typedef struct _virDomainCapsFeatureGIC virDomainCapsFeatureGIC; typedef virDomainCapsFeatureGIC *virDomainCapsFeatureGICPtr; struct _virDomainCapsFeatureGIC { - bool supported; + virTristateBool supported; virDomainCapsEnum version; /* Info about virGICVersion */ }; @@ -155,7 +155,7 @@ struct _virDomainCaps { /* Some machine specific info */ int maxvcpus; - bool iothreads; /* Whether I/O threads are supported or not. */ + virTristateBool iothreads; /* Whether I/O threads are supported or not. */ virDomainCapsOS os; virDomainCapsCPU cpu; @@ -166,8 +166,8 @@ struct _virDomainCaps { /* add new domain devices here */ virDomainCapsFeatureGIC gic; - bool vmcoreinfo; - bool genid; + virTristateBool vmcoreinfo; + virTristateBool genid; virSEVCapabilityPtr sev; /* add new domain features here */ }; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index cc42dc6987..385b08be38 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -603,12 +603,12 @@ libxlMakeDomainOSCaps(const char *machine, virDomainCapsLoaderPtr capsLoader = &os->loader; size_t i; - os->supported = true; + os->supported = VIR_TRISTATE_BOOL_YES; if (STREQ(machine, "xenpv") || STREQ(machine, "xenpvh")) return 0; - capsLoader->supported = true; + capsLoader->supported = VIR_TRISTATE_BOOL_YES; if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0) return -1; @@ -631,7 +631,7 @@ libxlMakeDomainOSCaps(const char *machine, static int libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDiskPtr dev) { - dev->supported = true; + dev->supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(dev->diskDevice, VIR_DOMAIN_DISK_DEVICE_DISK, @@ -648,7 +648,7 @@ libxlMakeDomainDeviceDiskCaps(virDomainCapsDeviceDiskPtr dev) static int libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphicsPtr dev) { - dev->supported = true; + dev->supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_SDL, @@ -661,7 +661,7 @@ libxlMakeDomainDeviceGraphicsCaps(virDomainCapsDeviceGraphicsPtr dev) static int libxlMakeDomainDeviceVideoCaps(virDomainCapsDeviceVideoPtr dev) { - dev->supported = true; + dev->supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VGA, @@ -683,7 +683,7 @@ bool libxlCapsHasPVUSB(void) static int libxlMakeDomainDeviceHostdevCaps(virDomainCapsDeviceHostdevPtr dev) { - dev->supported = true; + dev->supported = VIR_TRISTATE_BOOL_YES; /* VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES is for containers only */ VIR_DOMAIN_CAPS_ENUM_SET(dev->mode, VIR_DOMAIN_HOSTDEV_MODE_SUBSYS); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9d9c8096ba..ea75177f39 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5119,7 +5119,7 @@ virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPtr capsLoader, { size_t i; - capsLoader->supported = true; + capsLoader->supported = VIR_TRISTATE_BOOL_YES; if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0) return -1; @@ -5159,7 +5159,7 @@ virQEMUCapsFillDomainOSCaps(virDomainCapsOSPtr os, { virDomainCapsLoaderPtr capsLoader = &os->loader; - os->supported = true; + os->supported = VIR_TRISTATE_BOOL_YES; if (virQEMUCapsFillDomainLoaderCaps(capsLoader, firmwares, nfirmwares) < 0) return -1; return 0; @@ -5212,7 +5212,8 @@ static int virQEMUCapsFillDomainIOThreadCaps(virQEMUCapsPtr qemuCaps, virDomainCapsPtr domCaps) { - domCaps->iothreads = virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD); + domCaps->iothreads = virTristateBoolFromBool( + virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_IOTHREAD)); return 0; } @@ -5223,7 +5224,7 @@ virQEMUCapsFillDomainDeviceDiskCaps(virQEMUCapsPtr qemuCaps, const char *machine, virDomainCapsDeviceDiskPtr disk) { - disk->supported = true; + disk->supported = VIR_TRISTATE_BOOL_YES; /* QEMU supports all of these */ VIR_DOMAIN_CAPS_ENUM_SET(disk->diskDevice, VIR_DOMAIN_DISK_DEVICE_DISK, @@ -5258,7 +5259,7 @@ static int virQEMUCapsFillDomainDeviceGraphicsCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceGraphicsPtr dev) { - dev->supported = true; + dev->supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(dev->type, VIR_DOMAIN_GRAPHICS_TYPE_SDL); if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC)) @@ -5274,7 +5275,7 @@ static int virQEMUCapsFillDomainDeviceVideoCaps(virQEMUCapsPtr qemuCaps, virDomainCapsDeviceVideoPtr dev) { - dev->supported = true; + dev->supported = VIR_TRISTATE_BOOL_YES; if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VGA)) VIR_DOMAIN_CAPS_ENUM_SET(dev->modelType, VIR_DOMAIN_VIDEO_TYPE_VGA); @@ -5298,7 +5299,7 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy(); bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO(); - hostdev->supported = true; + hostdev->supported = VIR_TRISTATE_BOOL_YES; /* VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES is for containers only */ VIR_DOMAIN_CAPS_ENUM_SET(hostdev->mode, VIR_DOMAIN_HOSTDEV_MODE_SUBSYS); @@ -5413,7 +5414,7 @@ virQEMUCapsFillDomainFeatureGICCaps(virQEMUCapsPtr qemuCaps, version)) continue; - gic->supported = true; + gic->supported = VIR_TRISTATE_BOOL_YES; VIR_DOMAIN_CAPS_ENUM_SET(gic->version, version); } @@ -5484,10 +5485,11 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus); } - domCaps->vmcoreinfo = virQEMUCapsGet(qemuCaps, - QEMU_CAPS_DEVICE_VMCOREINFO); + domCaps->vmcoreinfo = virTristateBoolFromBool( + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMCOREINFO)); - domCaps->genid = virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID); + domCaps->genid = virTristateBoolFromBool( + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VMGENID)); if (virQEMUCapsFillDomainOSCaps(os, firmwares, nfirmwares) < 0 || virQEMUCapsFillDomainCPUCaps(caps, qemuCaps, domCaps) < 0 ||