From patchwork Sat May 14 18:25:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 67805 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp825625qge; Sat, 14 May 2016 11:31:48 -0700 (PDT) X-Received: by 10.194.203.105 with SMTP id kp9mr22108726wjc.70.1463250707929; Sat, 14 May 2016 11:31:47 -0700 (PDT) Return-Path: Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com. [209.132.183.37]) by mx.google.com with ESMTPS id w10si10410636wmw.27.2016.05.14.11.31.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 May 2016 11:31:47 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) client-ip=209.132.183.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.37 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4EIRCn5028925; Sat, 14 May 2016 14:27:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u4EIRAiO001065 for ; Sat, 14 May 2016 14:27:10 -0400 Received: from colepc.redhat.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4EIR8cL015318; Sat, 14 May 2016 14:27:09 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Sat, 14 May 2016 14:25:54 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?J=C3=A1n=20Tomko?= Subject: [libvirt] [PATCH 1/3] domain: Add virDomainVirtioSerialAddrSetCreateFromDomain 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: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com This handles all the bits needed for generating a virDomainVirtioSerialAddrSetPtr by inspecting a virDomainDefPtr --- src/conf/domain_addr.c | 35 ++++++++++++++++++++++++++++++++--- src/conf/domain_addr.h | 7 ++----- src/libvirt_private.syms | 3 +-- src/qemu/qemu_domain_address.c | 9 +-------- 4 files changed, 36 insertions(+), 18 deletions(-) -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index acd8ce6..01a3ae1 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -845,7 +845,7 @@ virDomainCCWAddressSetCreate(void) * * Allocates an address set for virtio serial addresses */ -virDomainVirtioSerialAddrSetPtr +static virDomainVirtioSerialAddrSetPtr virDomainVirtioSerialAddrSetCreate(void) { virDomainVirtioSerialAddrSetPtr ret = NULL; @@ -947,7 +947,7 @@ virDomainVirtioSerialAddrSetAddController(virDomainVirtioSerialAddrSetPtr addrs, * Adds virtio serial ports of controllers present in the domain definition * to the address set. */ -int +static int virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs, virDomainDefPtr def) { @@ -962,7 +962,6 @@ virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs return 0; } - void virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs) { @@ -1085,6 +1084,36 @@ virDomainVirtioSerialAddrNextFromController(virDomainVirtioSerialAddrSetPtr addr return 0; } +/* virDomainVirtioSerialAddrSetCreateFromDomain + * + * @def: Domain def to introspect + * + * Inspect the domain definition and return an address set containing + * every virtio serial address we find + */ +virDomainVirtioSerialAddrSetPtr +virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def) +{ + virDomainVirtioSerialAddrSetPtr addrs; + virDomainVirtioSerialAddrSetPtr ret = NULL; + + if (!(addrs = virDomainVirtioSerialAddrSetCreate())) + goto cleanup; + + if (virDomainVirtioSerialAddrSetAddControllers(addrs, def) < 0) + goto cleanup; + + if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve, + addrs) < 0) + goto cleanup; + + ret = addrs; + cleanup: + if (!ret) + virDomainVirtioSerialAddrSetFree(addrs); + return ret; +} + /* virDomainVirtioSerialAddrAutoAssign * * reserve a virtio serial address of the device (if it has one) diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h index f3eda89..c29f85a 100644 --- a/src/conf/domain_addr.h +++ b/src/conf/domain_addr.h @@ -201,11 +201,8 @@ typedef struct _virDomainVirtioSerialAddrSet virDomainVirtioSerialAddrSet; typedef virDomainVirtioSerialAddrSet *virDomainVirtioSerialAddrSetPtr; virDomainVirtioSerialAddrSetPtr -virDomainVirtioSerialAddrSetCreate(void); -int -virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr addrs, - virDomainDefPtr def) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +virDomainVirtioSerialAddrSetCreateFromDomain(virDomainDefPtr def) + ATTRIBUTE_NONNULL(1); void virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs); bool diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fb24808..5530e05 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -113,8 +113,7 @@ virDomainVirtioSerialAddrAutoAssign; virDomainVirtioSerialAddrIsComplete; virDomainVirtioSerialAddrRelease; virDomainVirtioSerialAddrReserve; -virDomainVirtioSerialAddrSetAddControllers; -virDomainVirtioSerialAddrSetCreate; +virDomainVirtioSerialAddrSetCreateFromDomain; virDomainVirtioSerialAddrSetFree; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9c8c262..e17b34b 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -115,14 +115,7 @@ qemuDomainAssignVirtioSerialAddresses(virDomainDefPtr def, virDomainVirtioSerialAddrSetPtr addrs = NULL; qemuDomainObjPrivatePtr priv = NULL; - if (!(addrs = virDomainVirtioSerialAddrSetCreate())) - goto cleanup; - - if (virDomainVirtioSerialAddrSetAddControllers(addrs, def) < 0) - goto cleanup; - - if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve, - addrs) < 0) + if (!(addrs = virDomainVirtioSerialAddrSetCreateFromDomain(def))) goto cleanup; VIR_DEBUG("Finished reserving existing ports");