@@ -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)
@@ -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
@@ -113,8 +113,7 @@ virDomainVirtioSerialAddrAutoAssign;
virDomainVirtioSerialAddrIsComplete;
virDomainVirtioSerialAddrRelease;
virDomainVirtioSerialAddrReserve;
-virDomainVirtioSerialAddrSetAddControllers;
-virDomainVirtioSerialAddrSetCreate;
+virDomainVirtioSerialAddrSetCreateFromDomain;
virDomainVirtioSerialAddrSetFree;
@@ -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");